SHARE
TWEET

Untitled

a guest Sep 19th, 2019 96 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Calendar;
  2. import java.util.Date;
  3.  
  4. import org.bukkit.BanList;
  5. import org.bukkit.Bukkit;
  6. import org.bukkit.command.Command;
  7. import org.bukkit.command.CommandExecutor;
  8. import org.bukkit.command.CommandSender;
  9. import org.bukkit.entity.Player;
  10.  
  11. import net.md_5.bungee.api.ChatColor;
  12.  
  13. public class TestCommands implements CommandExecutor
  14. {
  15.  
  16.     private Main main;
  17.    
  18.     public ModerationCommands(Main main)
  19.     {
  20.         this.main = main;
  21.     }
  22.    
  23.     public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args)
  24.     {
  25.         if (sender instanceof Player)
  26.         {
  27.             Player player = (Player) sender;
  28.             if (args.length == 1)
  29.             {
  30.                 int action;
  31.                
  32.                 try
  33.                 {
  34.                     action = Integer.parseInt(args[0]);
  35.                 }
  36.                 catch (NumberFormatException e)
  37.                 {
  38.                     player.sendMessage(ChatColor.RED + "Invalid Error #1");
  39.                     return false;
  40.                 }
  41.                
  42.                 switch (action)
  43.                 {
  44.                 case 1:
  45.                     player.kickPlayer(ChatColor.GRAY + "You have been" + ChatColor.RED + " kicked " + ChatColor.GRAY + "for:" + "\n" + ChatColor.DARK_GRAY + "IDK");
  46.                     break;
  47.                 case 2:
  48.                     Bukkit.getBanList(BanList.Type.NAME).addBan(player.getName(), ChatColor.GRAY + "You have been" + ChatColor.DARK_RED + " perma banned " + ChatColor.GRAY + "for:" + "\n" + ChatColor.DARK_GRAY + "IDK", null, null);
  49.                     break;
  50.                 case 3:
  51.                     Calendar cal = Calendar.getInstance();
  52.                     cal.set(2019, 8, 21);
  53.                     Date date = cal.getTime();
  54.                     Bukkit.getBanList(BanList.Type.NAME).addBan(player.getName(), ChatColor.GRAY + "You have been" + ChatColor.DARK_RED + " temp banned " + ChatColor.GRAY + "for:" + "\n" + ChatColor.DARK_GRAY + "IDK" + "\n" + ChatColor.GRAY + "Time Left: " + ChatColor.GREEN + date, date, null);
  55.                     break;
  56.                     default:
  57.                         return false;
  58.                 }
  59.                
  60.             }
  61.             else
  62.             {
  63.                 player.sendMessage(ChatColor.RED + "Invalid Error #2");
  64.             }
  65.            
  66.         }
  67.         else
  68.         {
  69.             System.out.println("This command can only be used ingame!");
  70.         }
  71.            
  72.         return false;
  73.        
  74.     }
  75. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top