Esempio n. 1
0
 @Override
 public boolean onCommand(CommandSender cs, Command cmd, String label, String[] args) {
   if (cmd.getName().equalsIgnoreCase("teleport")) {
     if (!plugin.ah.isAuthorized(cs, "rcmds.teleport")) {
       RUtils.dispNoPerms(cs);
       return true;
     }
     if (!(cs instanceof Player)) {
       cs.sendMessage(MessageColor.NEGATIVE + "This command is only available to players!");
       return true;
     }
     if (args.length < 1) {
       cs.sendMessage(cmd.getDescription());
       return false;
     }
     Player t = plugin.getServer().getPlayer(args[0]);
     if (t == null || plugin.isVanished(t, cs)) {
       cs.sendMessage(MessageColor.NEGATIVE + "That player does not exist!");
       return true;
     }
     if (!RUtils.isTeleportAllowed(t) && !plugin.ah.isAuthorized(cs, "rcmds.tpoverride")) {
       cs.sendMessage(MessageColor.NEGATIVE + "That player has teleportation off!");
       return true;
     }
     Player p = (Player) cs;
     p.sendMessage(
         MessageColor.POSITIVE
             + "Teleporting you to "
             + MessageColor.NEUTRAL
             + t.getName()
             + MessageColor.POSITIVE
             + ".");
     String error = RUtils.teleport(p, t);
     if (!error.isEmpty()) {
       p.sendMessage(MessageColor.NEGATIVE + error);
       return true;
     }
     return true;
   }
   return false;
 }