Exemplo n.º 1
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.º 2
0
 @Override
 public boolean runCommand(
     final CommandSender cs, final Command cmd, final String label, final String[] args) {
   if (args.length < 1) {
     cs.sendMessage(cmd.getDescription());
     return false;
   }
   final OfflinePlayer t = RUtils.getOfflinePlayer(args[0]);
   if (t.isOnline() && !this.plugin.isVanished((Player) t, cs)) {
     cs.sendMessage(
         MessageColor.POSITIVE
             + "The player "
             + MessageColor.NEUTRAL
             + t.getName()
             + MessageColor.POSITIVE
             + " was last seen "
             + MessageColor.NEUTRAL
             + "now"
             + MessageColor.POSITIVE
             + ".");
     return true;
   }
   final PlayerConfiguration pcm = PlayerConfigurationManager.getConfiguration(t);
   if (!pcm.exists()) {
     cs.sendMessage(MessageColor.NEGATIVE + "That player doesn't exist!");
     return true;
   }
   if (pcm.get("seen") == null) {
     cs.sendMessage(MessageColor.NEGATIVE + "I don't know when that player was last seen!");
     return true;
   }
   final long seen = pcm.getLong("seen");
   if (seen < 1L) {
     cs.sendMessage(MessageColor.NEGATIVE + "I don't know when that player was last seen!");
     return true;
   }
   final String lastseen = RUtils.formatDateDiff(seen);
   cs.sendMessage(
       MessageColor.POSITIVE
           + "The player "
           + MessageColor.NEUTRAL
           + t.getName()
           + MessageColor.POSITIVE
           + " was last seen"
           + MessageColor.NEUTRAL
           + lastseen
           + MessageColor.POSITIVE
           + " ago.");
   return true;
 }
Exemplo n.º 3
0
 @Override
 public boolean onCommand(CommandSender cs, Command cmd, String label, String[] args) {
   if (cmd.getName().equalsIgnoreCase("kits")) {
     if (!plugin.isAuthorized(cs, "rcmds.kits")) {
       RUtils.dispNoPerms(cs);
       return true;
     }
     if (!(cs instanceof Player) && args.length < 1) {
       cs.sendMessage(cmd.getDescription());
       return false;
     }
     final Map<String, Object> opts =
         plugin.getConfig().getConfigurationSection("kits").getValues(false);
     if (opts.keySet().isEmpty()) {
       cs.sendMessage(ChatColor.RED + "No kits found!");
       return true;
     }
     String kits = "";
     for (String s : opts.keySet()) {
       if (plugin.kitPerms && plugin.isAuthorized(cs, "rcmds.kit." + s))
         kits = (kits.isEmpty()) ? kits + s : kits + ", " + s;
       else if (!plugin.kitPerms) kits = (kits.isEmpty()) ? kits + s : kits + ", " + s;
     }
     cs.sendMessage(ChatColor.BLUE + "Kits:");
     if (kits.isEmpty()) return true;
     cs.sendMessage(kits);
     return true;
   }
   return false;
 }
Exemplo n.º 4
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;
 }
Exemplo n.º 5
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.º 6
0
 @Override
 public boolean onCommand(CommandSender cs, Command cmd, String label, String[] args) {
   if (cmd.getName().equalsIgnoreCase("loadplayer")) {
     if (!plugin.ah.isAuthorized(cs, "rcmds.loadplayer")) {
       RUtils.dispNoPerms(cs);
       return true;
     }
     if (args.length < 1) {
       cs.sendMessage(cmd.getDescription());
       return false;
     }
     final Player t = plugin.getServer().getPlayer(args[0]);
     if (t == null) {
       cs.sendMessage(MessageColor.NEGATIVE + "No such player!");
       return true;
     }
     if (!t.getName().equals(cs.getName())
         && !plugin.ah.isAuthorized(cs, "rcmds.others.loadplayer")) {
       cs.sendMessage(MessageColor.NEGATIVE + "You cannot load other players' data!");
       return true;
     }
     t.loadData();
     cs.sendMessage(MessageColor.POSITIVE + "Data loaded.");
     return true;
   }
   return false;
 }
 @EventHandler
 public void commandCooldown(PlayerCommandPreprocessEvent e) {
   if (e.isCancelled()) return;
   String command = e.getMessage().split(" ")[0].toLowerCase().substring(1);
   if (plugin.getCommand(command) != null) command = plugin.getCommand(command).getName();
   Player p = e.getPlayer();
   if (plugin.isAuthorized(p, "rcmds.exempt.cooldown.commands")) return;
   Long currentcd = PConfManager.getPValLong(p, "command_cooldowns." + command);
   if (currentcd != null) {
     if (currentcd <= new Date().getTime()) {
       setCooldown(command, p);
       return;
     }
     p.sendMessage(
         ChatColor.RED
             + "You can't use that command for"
             + ChatColor.GRAY
             + RUtils.formatDateDiff(currentcd)
             + ChatColor.RED
             + ".");
     e.setCancelled(true);
     return;
   }
   setCooldown(command, p);
 }
Exemplo n.º 8
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;
 }
 @EventHandler(priority = EventPriority.HIGH)
 public void onPlayerLogin(PlayerLoginEvent event) {
   if (event.getResult() != Result.ALLOWED) return;
   // Define the player
   Player p = event.getPlayer();
   // Pretty sure this isn't even necessary, but I just can't figure out wtf is throwing the NPE
   if (p == null) return;
   // Check if player is banned
   if (!p.isBanned()) return;
   // Check to see that they have a bantime, and that if they do, if the timestamp is invalid.
   if (PConfManager.getPVal(p, "bantime") != null && !RUtils.isTimeStampValid(p, "bantime")) {
     // Set them unbanned
     p.setBanned(false);
     // Stop the method
     return;
   }
   // Get the banreason from the player's userdata file
   String kickMessage = PConfManager.getPValString(p, "banreason"); // Returns string or null
   // Check if there was none, and if there wasn't, set it to default ban message.
   if (kickMessage == null) kickMessage = plugin.banMessage;
   // Set the kick message to the ban reason
   event.setKickMessage(kickMessage);
   // Disallow the event
   event.disallow(Result.KICK_BANNED, kickMessage);
 }
  @EventHandler(priority = EventPriority.LOWEST)
  public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
    if (event.isCancelled()) return;
    if (plugin.showcommands)
      log.info("[PLAYER_COMMAND] " + event.getPlayer().getName() + ": " + event.getMessage());
    if (PConfManager.getPValBoolean(event.getPlayer(), "muted")) {
      if (PConfManager.getPVal(event.getPlayer(), "mutetime") != null
          && !RUtils.isTimeStampValid(event.getPlayer(), "mutetime"))
        PConfManager.setPValBoolean(event.getPlayer(), false, "muted");
      for (String command : plugin.muteCmds) {
        if (!(event.getMessage().toLowerCase().startsWith(command.toLowerCase() + " ")
            || event.getMessage().equalsIgnoreCase(command.toLowerCase()))) continue;
        event.getPlayer().sendMessage(ChatColor.RED + "You are muted.");
        log.info(
            "[RoyalCommands] "
                + event.getPlayer().getName()
                + " tried to use that command, but is muted.");
        event.setCancelled(true);
      }
    }

    if (PConfManager.getPValBoolean(event.getPlayer(), "jailed")) {
      event.getPlayer().sendMessage(ChatColor.RED + "You are jailed.");
      log.info(
          "[RoyalCommands] "
              + event.getPlayer().getName()
              + " tried to use that command, but is jailed.");
      event.setCancelled(true);
    }
  }
Exemplo n.º 11
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;
 }
Exemplo n.º 12
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;
 }
Exemplo n.º 13
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;
  }
Exemplo n.º 14
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;
 }
Exemplo n.º 15
0
 @Override
 public boolean onCommand(CommandSender cs, Command cmd, String label, String[] args) {
   if (cmd.getName().equalsIgnoreCase("spawn")) {
     if (!plugin.ah.isAuthorized(cs, "rcmds.spawn")) {
       RUtils.dispNoPerms(cs);
       return true;
     }
     if (!(cs instanceof Player)) {
       cs.sendMessage(MessageColor.NEGATIVE + "This command is only available to players!");
       return true;
     }
     Player p = (Player) cs;
     World w;
     if (args.length > 0) {
       if (!plugin.ah.isAuthorized(cs, "rcmds.spawn.other")) {
         cs.sendMessage(
             MessageColor.NEGATIVE + "You don't have permission to spawn in other worlds.");
         return true;
       }
       w = plugin.getServer().getWorld(args[0]);
       if (w == null) {
         cs.sendMessage(MessageColor.NEGATIVE + "No such world!");
         return true;
       }
     } else w = p.getWorld();
     Location l = getGroupSpawn(p, w);
     if (l == null) l = getWorldSpawn(w);
     p.sendMessage(
         MessageColor.POSITIVE
             + "Going to spawn in "
             + MessageColor.NEUTRAL
             + RUtils.getMVWorldName(w)
             + MessageColor.POSITIVE
             + ".");
     String error = RUtils.teleport(p, l);
     if (!error.isEmpty()) p.sendMessage(MessageColor.NEGATIVE + error);
     return true;
   }
   return false;
 }
Exemplo n.º 16
0
 @Override
 public boolean onCommand(CommandSender cs, Command cmd, String label, String[] args) {
   if (cmd.getName().equalsIgnoreCase("vtphere")) {
     if (!plugin.isAuthorized(cs, "rcmds.vtphere")) {
       RUtils.dispNoPerms(cs);
       return true;
     }
     if (args.length < 1) {
       cs.sendMessage(cmd.getDescription());
       return false;
     }
     Player victim = plugin.getServer().getPlayer(args[0]);
     if (victim == null) {
       cs.sendMessage(ChatColor.RED + "That player does not exist!");
       return true;
     }
     if (!(cs instanceof Player)) {
       cs.sendMessage(ChatColor.RED + "This command cannot be used in console.");
       return true;
     }
     Player player = (Player) cs;
     cs.sendMessage(
         ChatColor.BLUE
             + "Teleporting player "
             + ChatColor.GRAY
             + victim.getName()
             + ChatColor.BLUE
             + " to you.");
     String error = RUtils.teleport(victim, player);
     if (!error.isEmpty()) {
       cs.sendMessage(ChatColor.RED + error);
       return true;
     }
     return true;
   }
   return false;
 }
Exemplo n.º 17
0
 public boolean onCommand(CommandSender cs, Command cmd, String label, String[] args) {
   if (cmd.getName().equalsIgnoreCase("workbench")) {
     if (!plugin.ah.isAuthorized(cs, "rcmds.workbench")) {
       RUtils.dispNoPerms(cs);
       return true;
     }
     if (!(cs instanceof Player)) {
       cs.sendMessage(MessageColor.NEGATIVE + "This command is only available to players!");
       return true;
     }
     Player p = (Player) cs;
     p.openWorkbench(null, true);
     p.sendMessage(MessageColor.POSITIVE + "Opened a workbench for you.");
     return true;
   }
   return false;
 }
 @EventHandler(priority = EventPriority.LOW)
 public void onPlayerChat(PlayerChatEvent event) {
   if (event.isCancelled()) return;
   if (AFKUtils.isAfk(event.getPlayer())) {
     AFKUtils.unsetAfk(event.getPlayer());
     plugin.getServer().broadcastMessage(event.getPlayer().getName() + " is no longer AFK.");
   }
   if (PConfManager.getPValBoolean(event.getPlayer(), "muted")) {
     if (PConfManager.getPVal(event.getPlayer(), "mutetime") != null
         && !RUtils.isTimeStampValid(event.getPlayer(), "mutetime"))
       PConfManager.setPValBoolean(event.getPlayer(), false, "muted");
     event.setFormat("");
     event.setCancelled(true);
     event.getPlayer().sendMessage(ChatColor.RED + "You are muted.");
     plugin.log.info(
         "[RoyalCommands] "
             + event.getPlayer().getName()
             + " tried to speak, but has been muted.");
   }
 }
Exemplo n.º 19
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;
 }
Exemplo n.º 20
0
 @Override
 public boolean onCommand(CommandSender cs, Command cmd, String label, String[] args) {
   if (cmd.getName().equalsIgnoreCase("banned")) {
     if (!plugin.isAuthorized(cs, "rcmds.banned")) {
       RUtils.dispNoPerms(cs);
       return true;
     }
     if (args.length < 1) {
       cs.sendMessage(cmd.getDescription());
       return false;
     }
     OfflinePlayer t = plugin.getServer().getOfflinePlayer(args[0]);
     if (!t.isBanned()) {
       cs.sendMessage(ChatColor.GREEN + t.getName() + ChatColor.WHITE + " is not banned.");
       return true;
     }
     cs.sendMessage(ChatColor.RED + t.getName() + ChatColor.WHITE + " is banned.");
     return true;
   }
   return false;
 }
 @EventHandler(priority = EventPriority.LOW)
 public void teleCooldown(PlayerTeleportEvent e) {
   if (e.isCancelled()) return;
   Player p = e.getPlayer();
   if (plugin.isAuthorized(p, "rcmds.exempt.cooldown.teleports")) return;
   Long currentcd = PConfManager.getPValLong(p, "teleport_cooldown");
   if (currentcd != null) {
     if (currentcd <= new Date().getTime()) {
       setTeleCooldown(p);
       return;
     }
     p.sendMessage(
         ChatColor.RED
             + "You can't teleport for"
             + ChatColor.GRAY
             + RUtils.formatDateDiff(currentcd)
             + ChatColor.RED
             + ".");
     e.setCancelled(true);
     return;
   }
   setTeleCooldown(p);
 }
Exemplo n.º 22
0
 public boolean onCommand(CommandSender cs, Command cmd, String label, String[] args) {
   if (cmd.getName().equalsIgnoreCase("fireball")) {
     if (!plugin.isAuthorized(cs, "rcmds.fireball")) {
       RUtils.dispNoPerms(cs);
       return true;
     }
     if (!(cs instanceof Player)) {
       cs.sendMessage(ChatColor.RED + "This command is only available to players!");
       return true;
     }
     Player p = (Player) cs;
     // Fireball fb = p.launchProjectile(Fireball.class);
     Vector dir = p.getEyeLocation().getDirection().multiply(2);
     Fireball fb =
         p.getWorld()
             .spawn(p.getEyeLocation().add(dir.getX(), dir.getY(), dir.getZ()), Fireball.class);
     fb.setDirection(dir);
     // fb.teleport(p.getEyeLocation().add(dir.getX(), dir.getY(), dir.getZ()));
     fb.setIsIncendiary(true);
     return true;
   }
   return false;
 }
Exemplo n.º 23
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;
 }
Exemplo n.º 24
0
  @Override
  public boolean onCommand(CommandSender cs, Command cmd, String label, String[] args) {
    if (cmd.getName().equalsIgnoreCase("weather")) {
      if (!plugin.isAuthorized(cs, "rcmds.weather")) {
        RUtils.dispNoPerms(cs);
        return true;
      }
      if (args.length < 1) {
        cs.sendMessage(cmd.getDescription());
        return false;
      }

      if (!(cs instanceof Player)) {
        cs.sendMessage(ChatColor.RED + "This command is only available to players!");
        return true;
      }
      if (args.length == 1) {
        Player p = (Player) cs;
        changeWeather(p, args[0].trim());
        return true;
      } else if (args.length == 2) {
        Player p = (Player) cs;
        String conds = args[0].trim();
        String slength = args[1].trim();
        int length;
        try {
          length = Integer.parseInt(slength);
        } catch (Exception e) {
          p.sendMessage(ChatColor.RED + "The time specified was invalid!");
          return true;
        }
        changeWeather(p, conds, length);
        return true;
      }
    }
    return false;
  }
Exemplo n.º 25
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;
  }