Ejemplo n.º 1
0
 @Override
 public boolean onCommand(CommandSender cs, Command cmd, String label, String[] args) {
   if (cmd.getName().equalsIgnoreCase("muteall")) {
     if (!plugin.isAuthorized(cs, "rcmds.muteall")) {
       RUtils.dispNoPerms(cs);
       return true;
     }
     Player[] ps = plugin.getServer().getOnlinePlayers();
     for (Player p : ps) {
       if (plugin.isVanished(p) || plugin.isAuthorized(p, "rcmds.exempt.mute")) continue;
       if (cs instanceof Player) {
         if (p == cs) continue;
       }
       if (!allMuted) {
         PConfManager.setPValBoolean(p, true, "muted");
         p.sendMessage(ChatColor.RED + "You have been muted!");
       } else {
         PConfManager.setPValBoolean(p, false, "muted");
         p.sendMessage(ChatColor.BLUE + "You have been unmuted!");
       }
     }
     if (!allMuted) {
       cs.sendMessage(ChatColor.BLUE + "You have muted all players.");
       allMuted = true;
     } else {
       cs.sendMessage(ChatColor.BLUE + "You have unmuted all players.");
       allMuted = false;
     }
     return true;
   }
   return false;
 }
Ejemplo n.º 2
0
 public boolean onCommand(CommandSender cs, Command cmd, String label, String[] args) {
   if (cmd.getName().equalsIgnoreCase("mobignore")) {
     if (!plugin.ah.isAuthorized(cs, "rcmds.mobignore")) {
       RUtils.dispNoPerms(cs);
       return true;
     }
     if (args.length < 1) {
       if (!(cs instanceof Player)) {
         cs.sendMessage(cmd.getDescription());
         return false;
       }
       Player p = (Player) cs;
       PConfManager pcm = PConfManager.getPConfManager(p);
       Boolean isHidden = pcm.getBoolean("mobignored");
       if (isHidden == null) isHidden = false;
       pcm.set("mobignored", !isHidden);
       String status = BooleanUtils.toStringOnOff(isHidden);
       cs.sendMessage(
           MessageColor.POSITIVE
               + "Toggled mob ignore "
               + MessageColor.NEUTRAL
               + status
               + MessageColor.POSITIVE
               + ".");
       return true;
     }
     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;
     }
     PConfManager pcm = PConfManager.getPConfManager(t);
     Boolean isHidden = pcm.getBoolean("mobignored");
     if (isHidden == null) isHidden = false;
     pcm.set("mobignored", !isHidden);
     String status = BooleanUtils.toStringOnOff(isHidden);
     cs.sendMessage(
         MessageColor.POSITIVE
             + "Toggled mob ignore "
             + MessageColor.NEUTRAL
             + status
             + MessageColor.POSITIVE
             + " for "
             + MessageColor.NEUTRAL
             + t.getName()
             + MessageColor.POSITIVE
             + ".");
     t.sendMessage(
         MessageColor.NEUTRAL
             + cs.getName()
             + MessageColor.POSITIVE
             + " toggled mob ignore "
             + MessageColor.NEUTRAL
             + status
             + MessageColor.POSITIVE
             + " for you.");
     return true;
   }
   return false;
 }
Ejemplo n.º 3
0
 @Override
 public boolean onCommand(CommandSender cs, Command cmd, String label, String[] args) {
   if (cmd.getName().equalsIgnoreCase("kill")) {
     if (!plugin.isAuthorized(cs, "rcmds.kill")) {
       RUtils.dispNoPerms(cs);
       return true;
     }
     if (args.length < 1) {
       cs.sendMessage(cmd.getDescription());
       return false;
     }
     Player t = plugin.getServer().getPlayer(args[0].trim());
     if (t == null || plugin.isVanished(t, cs)) {
       cs.sendMessage(ChatColor.RED + "That player does not exist!");
       return true;
     }
     if (plugin.isAuthorized(t, "rcmds.exempt.kill")) {
       cs.sendMessage(ChatColor.RED + "You cannot kill that player!");
       return true;
     }
     t.setHealth(0);
     cs.sendMessage(
         ChatColor.BLUE
             + "You have killed "
             + ChatColor.GRAY
             + t.getDisplayName()
             + ChatColor.BLUE
             + ".");
     return true;
   }
   return false;
 }
Ejemplo n.º 4
0
 @Override
 public boolean onCommand(CommandSender cs, Command cmd, String label, String[] args) {
   if (cmd.getName().equals("playertime")) {
     if (!plugin.isAuthorized(cs, "rcmds.playertime")) {
       RUtils.dispNoPerms(cs);
       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(ChatColor.RED + "That player does not exist!");
       return true;
     }
     String possessive = (t.getName().toLowerCase().endsWith("s")) ? "'" : "'s";
     Integer time = null;
     if (args.length > 1) {
       try {
         time = Integer.valueOf(args[1]);
       } catch (Exception e) {
         cs.sendMessage(ChatColor.RED + "That time was invalid!");
         return true;
       }
     }
     if (time == null) {
       t.resetPlayerTime();
       cs.sendMessage(
           ChatColor.BLUE
               + "Synced "
               + ChatColor.GRAY
               + t.getName()
               + possessive
               + ChatColor.BLUE
               + " time with the server's.");
       return true;
     }
     if (plugin.smoothTime) smoothPlayerTimeChange(time, t);
     t.setPlayerTime(time, true);
     cs.sendMessage(
         ChatColor.BLUE
             + "Set "
             + ChatColor.GRAY
             + t.getName()
             + possessive
             + ChatColor.BLUE
             + " time to "
             + ChatColor.GRAY
             + time
             + " ticks"
             + ChatColor.BLUE
             + ".");
     return true;
   }
   return false;
 }
Ejemplo n.º 5
0
  @Override
  public boolean onCommand(CommandSender cs, Command cmd, String label, String[] args) {
    if (cmd.getName().equalsIgnoreCase("harm")) {
      if (!plugin.ah.isAuthorized(cs, "rcmds.harm")) {
        RUtils.dispNoPerms(cs);
        return true;
      }
      if (args.length < 2) {
        return false;
      }
      Player t = plugin.getServer().getPlayer(args[0]);
      if (t == null || plugin.isVanished(t, cs)) {
        cs.sendMessage(MessageColor.NEGATIVE + "That person is not online!");
        return true;
      }
      int toDamage;
      try {
        toDamage = Integer.parseInt(args[1]);
      } catch (NumberFormatException e) {
        cs.sendMessage(MessageColor.NEGATIVE + "The damage must be a number!");
        return false;
      }
      if (toDamage > t.getMaxHealth() || toDamage <= 0) {
        cs.sendMessage(
            MessageColor.NEGATIVE
                + "The damage you entered is not within 1 and "
                + t.getMaxHealth()
                + "!");
        return true;
      }

      if (!cs.getName().equalsIgnoreCase(t.getName())
          && plugin.ah.isAuthorized(t, "rcmds.exempt.harm")) {
        cs.sendMessage(MessageColor.NEGATIVE + "You may not harm that player.");
        return true;
      }
      t.damage(toDamage);
      t.sendMessage(
          MessageColor.NEGATIVE
              + "You have just been damaged by "
              + MessageColor.NEUTRAL
              + cs.getName()
              + MessageColor.NEGATIVE
              + "!");
      cs.sendMessage(
          MessageColor.POSITIVE
              + "You just damaged "
              + MessageColor.NEUTRAL
              + t.getName()
              + MessageColor.POSITIVE
              + "!");
      return true;
    }
    return false;
  }
Ejemplo n.º 6
0
 @Override
 public boolean onCommand(CommandSender cs, Command cmd, String label, String[] args) {
   if (cmd.getName().equalsIgnoreCase("ping")) {
     if (!plugin.ah.isAuthorized(cs, "rcmds.ping")) {
       RUtils.dispNoPerms(cs);
       return true;
     }
     if (!plugin.getNMSFace().hasSupport() || (!(cs instanceof Player) && args.length < 1)) {
       cs.sendMessage(MessageColor.POSITIVE + "Pong!");
       return true;
     }
     if (args.length > 0) {
       if (!plugin.ah.isAuthorized(cs, "rcmds.others.ping")) {
         RUtils.dispNoPerms(cs);
         return true;
       }
       Player p = plugin.getServer().getPlayer(args[0]);
       if (p == null || plugin.isVanished(p, cs)) {
         cs.sendMessage(MessageColor.NEGATIVE + "That player does not exist!");
         return true;
       }
       int ping = plugin.getNMSFace().getPing(p);
       String possessive = (p.getName().endsWith("s")) ? "'" : "'s";
       cs.sendMessage(
           MessageColor.NEUTRAL
               + p.getName()
               + possessive
               + MessageColor.POSITIVE
               + " ping: "
               + MessageColor.NEUTRAL
               + ping
               + "ms");
       return true;
     }
     if (!(cs instanceof Player)) {
       cs.sendMessage(MessageColor.POSITIVE + "Pong!");
       return true;
     }
     Player p = (Player) cs;
     int ping = plugin.getNMSFace().getPing(p);
     p.sendMessage(MessageColor.POSITIVE + "Your ping: " + MessageColor.NEUTRAL + ping + "ms");
     return true;
   }
   return false;
 }
Ejemplo n.º 7
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;
 }
Ejemplo n.º 8
0
 @Override
 public boolean onCommand(CommandSender cs, Command cmd, String label, String[] args) {
   if (cmd.getName().equalsIgnoreCase("slap")) {
     if (!plugin.isAuthorized(cs, "rcmds.slap")) {
       RUtils.dispNoPerms(cs);
       return true;
     }
     if (args.length < 1) {
       cs.sendMessage(cmd.getDescription());
       return false;
     }
     Player victim;
     victim = plugin.getServer().getPlayer(args[0]);
     if (victim == null || plugin.isVanished(victim)) {
       cs.sendMessage(ChatColor.RED + "That person is not online!");
       return true;
     }
     if (plugin.isAuthorized(victim, "rcmds.exempt.slap")) {
       cs.sendMessage(ChatColor.RED + "You may not slap that player.");
       return true;
     }
     Vector push = victim.getVelocity();
     push.setY(push.getY() + .5);
     push.setX(push.getX() + .5);
     push.setZ(push.getZ() + .5);
     victim.setVelocity(push);
     plugin
         .getServer()
         .broadcastMessage(
             ChatColor.GOLD
                 + cs.getName()
                 + ChatColor.WHITE
                 + " slaps "
                 + ChatColor.RED
                 + victim.getName()
                 + ChatColor.WHITE
                 + "!");
     return true;
   }
   return false;
 }
Ejemplo n.º 9
0
 @Override
 public boolean onCommand(CommandSender cs, Command cmd, String label, String[] args) {
   if (cmd.getName().equalsIgnoreCase("ragequit")) {
     if (!plugin.isAuthorized(cs, "rcmds.ragequit")) {
       RUtils.dispNoPerms(cs);
       return true;
     }
     if (args.length < 1) {
       if (cs instanceof Player) {
         plugin
             .getServer()
             .broadcastMessage(
                 ChatColor.DARK_RED + cs.getName() + ChatColor.RED + " has ragequit!");
         ((Player) cs).kickPlayer(ChatColor.DARK_RED + "RAAAGGGEEEE!!!");
         return true;
       }
     }
     if (args.length == 1) {
       if (!plugin.isAuthorized(cs, "rcmds.others.ragequit")) {
         cs.sendMessage(ChatColor.RED + "You don't have permission for that!");
         return true;
       }
       Player victim = plugin.getServer().getPlayer(args[0]);
       if (victim == null || plugin.isVanished(victim, cs)) {
         cs.sendMessage(ChatColor.RED + "That player does not exist!");
         return true;
       }
       plugin
           .getServer()
           .broadcastMessage(
               ChatColor.DARK_RED + victim.getName() + ChatColor.RED + " has ragequit!");
       victim.kickPlayer(ChatColor.DARK_RED + "RAAAGGGEEEE!!!");
       return true;
     }
   }
   return false;
 }
Ejemplo n.º 10
0
  @Override
  public boolean onCommand(CommandSender cs, Command cmd, String label, String[] args) {
    if (cmd.getName().equalsIgnoreCase("message")) {
      if (!plugin.ah.isAuthorized(cs, "rcmds.message")) {
        RUtils.dispNoPerms(cs);
        return true;
      }
      if (args.length < 2) {
        return false;
      }
      Player t = plugin.getServer().getPlayer(args[0]);
      String m = RoyalCommands.getFinalArg(args, 1).trim();
      if (t == null || t.getName().trim().equals("")) {
        cs.sendMessage(MessageColor.NEGATIVE + "That player is not online!");
        return true;
      }
      if (plugin.isVanished(t, cs)) {
        cs.sendMessage(MessageColor.NEGATIVE + "That player does not exist!");
        return true;
      }
      synchronized (replydb) {
        replydb.put(t.getName(), cs.getName());
        replydb.put(cs.getName(), t.getName());
      }

      if (m == null || m.equals("")) {
        cs.sendMessage(MessageColor.NEGATIVE + "You entered no message!");
        return true;
      }
      t.sendMessage(
          MessageColor.NEUTRAL
              + "["
              + MessageColor.POSITIVE
              + cs.getName()
              + MessageColor.NEUTRAL
              + " -> "
              + MessageColor.POSITIVE
              + "You"
              + MessageColor.NEUTRAL
              + "] "
              + m);
      cs.sendMessage(
          MessageColor.NEUTRAL
              + "["
              + MessageColor.POSITIVE
              + "You"
              + MessageColor.NEUTRAL
              + " -> "
              + MessageColor.POSITIVE
              + t.getName()
              + MessageColor.NEUTRAL
              + "] "
              + m);
      Player[] ps = plugin.getServer().getOnlinePlayers();
      for (Player p1 : ps) {
        if (PConfManager.getPConfManager(p1).getBoolean("spy")) {
          if (t == p1 || cs == p1) continue;
          p1.sendMessage(
              MessageColor.NEUTRAL
                  + "["
                  + MessageColor.POSITIVE
                  + cs.getName()
                  + MessageColor.NEUTRAL
                  + " -> "
                  + MessageColor.POSITIVE
                  + t.getName()
                  + MessageColor.NEUTRAL
                  + "] "
                  + m);
        }
      }
      return true;
    }
    return false;
  }