Exemplo n.º 1
0
 public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
   try {
     if (!(sender instanceof Player)) {
       sender.sendMessage(ChatColor.RED + "You must be ingame to use this command.");
       return true;
     }
     if (args.length == 0 || args.length > 2) {
       return false;
     }
     if (args.length == 1) {
       if (args[0].equalsIgnoreCase("list")) {
         sender.sendMessage(ChatColor.GREEN + "The following users are Master Builders.");
         Connection c = FOPMR_DatabaseInterface.getConnection();
         PreparedStatement statement =
             c.prepareStatement("SELECT * FROM PLAYERS WHERE BUILDER = 1");
         ResultSet set = statement.executeQuery();
         while (set.next()) {
           sender.sendMessage(ChatColor.GREEN + " - " + set.getString("NAME"));
         }
         return true;
       }
     }
     if (args.length == 2) {
       if (!FOPMR_Rank.isSpecialist(sender)) {
         sender.sendMessage("You do not have permission to use this command.");
         return true;
       }
       Player player = FOPMR_Rank.getPlayer(args[1]);
       if (player == null) {
         sender.sendMessage(ChatColor.RED + "The player could not be found.");
         return true;
       }
       if (args[0].equalsIgnoreCase("add")) {
         FOPMR_Commons.adminAction(
             sender.getName(), "Adding " + player.getName() + " to Master Builder.", false);
         FOPMR_DatabaseInterface.updateInTable(
             "UUID", player.getUniqueId().toString(), true, "BUILDER", "PLAYERS");
         FOPMR_BoardManager.updateStats(player);
         return true;
       }
       if (args[0].equalsIgnoreCase("remove")) {
         FOPMR_Commons.adminAction(
             sender.getName(), "Removing " + player.getName() + " from Master Builder.", true);
         FOPMR_DatabaseInterface.updateInTable(
             "UUID", player.getUniqueId().toString(), false, "BUILDER", "PLAYERS");
         FOPMR_BoardManager.updateStats(player);
         return true;
       }
     }
   } catch (Exception ex) {
     FreedomOpModRemastered.plugin.handleException(ex);
   }
   return false;
 }
 public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
   if (args.length == 0) {
     return false;
   }
   if (args.length == 1) {
     if (args[0].equalsIgnoreCase("on")) {
       FreedomOpModRemastered.plugin.getConfig().set("jumppads.speed", true);
       FreedomOpModRemastered.plugin.saveConfig();
       FOPMR_Commons.adminAction(sender.getName(), "Enabling speedpads!", false);
       return true;
     }
     if (args[0].equalsIgnoreCase("off")) {
       FreedomOpModRemastered.plugin.getConfig().set("jumppads.speed", false);
       FreedomOpModRemastered.plugin.saveConfig();
       FOPMR_Commons.adminAction(sender.getName(), "Disabling speedpads!", true);
       return true;
     }
   }
   if (args.length == 2) {
     if (args[0].equalsIgnoreCase("strength")) {
       double strength;
       try {
         strength = Double.parseDouble(args[1]);
       } catch (Exception ex) {
         return false;
       }
       if (strength > 10) {
         sender.sendMessage(ChatColor.RED + "The value must be a double below or equal to 10.");
         return true;
       }
       FreedomOpModRemastered.plugin.getConfig().set("jumppads.speedstrength", strength);
       FreedomOpModRemastered.plugin.saveConfig();
       FOPMR_Commons.adminAction(
           sender.getName(), "Seting speedpad strength to " + strength + "!", false);
       return true;
     }
   }
   return false;
 }