Exemplo n.º 1
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;
 }
Exemplo n.º 2
0
 @Override
 public boolean onCommand(CommandSender cs, Command cmd, String label, String[] args) {
   if (cmd.getName().equalsIgnoreCase("banip")) {
     if (!plugin.ah.isAuthorized(cs, "rcmds.banip")) {
       RUtils.dispNoPerms(cs);
       return true;
     }
     if (args.length < 1) {
       cs.sendMessage(cmd.getDescription());
       return false;
     }
     OfflinePlayer op = plugin.getServer().getOfflinePlayer(args[0]);
     String ip =
         (!op.hasPlayedBefore()) ? args[0] : PConfManager.getPConfManager(op).getString("ip");
     if (ip == null) ip = args[0];
     if (!isValid(ip)) {
       cs.sendMessage(
           MessageColor.NEGATIVE
               + "Invalid IP ("
               + MessageColor.NEUTRAL
               + ip
               + MessageColor.NEGATIVE
               + ").");
       return true;
     }
     plugin.getServer().banIP(ip);
     if (!op.hasPlayedBefore()) {
       cs.sendMessage(
           MessageColor.POSITIVE
               + "Banned IP "
               + MessageColor.NEUTRAL
               + ip
               + MessageColor.POSITIVE
               + ".");
       return true;
     } else {
       op.setBanned(true);
       RUtils.writeBanHistory(op);
       cs.sendMessage(
           MessageColor.POSITIVE
               + "Banned IP of "
               + MessageColor.NEUTRAL
               + op.getName()
               + MessageColor.POSITIVE
               + " ("
               + MessageColor.NEUTRAL
               + ip
               + MessageColor.POSITIVE
               + ").");
       return true;
     }
   }
   return false;
 }
Exemplo n.º 3
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;
  }
Exemplo n.º 4
0
 /**
  * Gets the player configuration manager of the OfflinePlayer.
  *
  * @param p OfflinePlayer to get config for
  * @return A PConfManager - never null
  */
 public PConfManager getConfiguration(OfflinePlayer p) {
   return PConfManager.getPConfManager(p);
 }
Exemplo n.º 5
0
 /**
  * Returns the display name of a player. This will return a nickname set by /nick, and if one is
  * not set, it will return the player's default name.
  *
  * @param p Player to get name for
  * @return Name - never null
  */
 public String getDisplayName(Player p) {
   PConfManager pcm = PConfManager.getPConfManager(p);
   String name = pcm.getString("dispname");
   if (name == null) name = p.getName();
   return name;
 }