SHARE
TWEET

Untitled

a guest May 20th, 2019 52 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class BanCommand extends PlayerCommand {
  2.  
  3.     public BanCommand() {
  4.         super("ban", RankUtil.Rank.ADMIN);
  5.     }
  6.     public void execute(CommandSender sender, String[] args) {
  7.         if(args.length < 2) {
  8.             Utils.sendMessage(Messages.USAGE_BAN, sender);
  9.             return;
  10.         }
  11.         ProxiedPlayer victim = ProxyServer.getInstance().getPlayer(args[0]);
  12.         if(victim == null) {
  13.             Utils.sendMessage(Messages.PLAYER_OFFLINE, sender);
  14.             return;
  15.         }
  16.         UserData user = UserHandler.getUserData(victim.getUniqueId());
  17.         if(user == null) return;
  18.         if(user.isBanned()) {
  19.             Utils.sendMessage(Messages.PLAYER_ALREADY_BANNED, sender);
  20.             return;
  21.         }
  22.         StringBuilder builder = new StringBuilder();
  23.         for(int i = 1; i < args.length; i++) {
  24.             builder.append(args[i]);
  25.             builder.append(" ");
  26.         }
  27.         String reason = builder.toString();
  28.         String author = sender.getName();
  29.         user.setBanned(true);
  30.         user.setBanReason(reason);
  31.         user.setBanAuthor(author);
  32.         Utils.disconnectPlayer(victim, Messages.BANNED_PERM.replace("%author%", user.getBan_author()).replace("%reason%", user.getBan_reason()));
  33.         Utils.sendALLPlayers(Messages.BAN_PERM_BROADCAST.replace("%author%", user.getBan_author()).replace("%reason%", user.getBan_reason()).replace("%victim%", victim.getName()));
  34.     }
  35.  
  36. }
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