示例#1
0
  public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {

    if (args.length > 0) {
      if (args[0].equalsIgnoreCase("reload")) {
        if (!FOPMR_Rank.isAdmin(sender)) {
          sender.sendMessage(ChatColor.RED + "Only admins can reload the FOPM: R config.");
          return true;
        }
        FreedomOpModRemastered.plugin.reloadConfig();
        FOPMR_DatabaseInterface.closeConnection(FOPMR_DatabaseInterface.getConnection());
      }
      return true;
    }
    sender.sendMessage(ChatColor.GREEN + "This is the FreedomOpMod Remastered!");
    sender.sendMessage(CUtils_Methods.randomChatColour() + "an all new form of All-Op management.");
    sender.sendMessage(
        CUtils_Methods.colour(
            "&-Created in the likes of the TFM but with more "
                + CUtils_Methods.randomChatColour()
                + "flexibility&- by "
                + CUtils_Methods.randomChatColour()
                + "Camzie99&-!"));

    return true;
  }
 @Override
 public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
   if (args.length != 1) {
     return false;
   }
   Player player = FOPMR_Rank.getPlayer(args[0]);
   if (player == null) {
     sender.sendMessage("Player is not online.");
     return true;
   }
   if (FOPMR_Rank.isEqualOrHigher(FOPMR_Rank.getRank(player), FOPMR_Rank.getRank(sender))) {
     sender.sendMessage(
         "You can only block the commands of a player with lower clearance than yourself.");
     return true;
   }
   Bukkit.broadcastMessage(
       ChatColor.AQUA
           + sender.getName()
           + " - toggling command blockage for "
           + player.getName()
           + ".");
   try {
     FOPMR_DatabaseInterface.updateInTable(
         "UUID",
         player.getUniqueId().toString(),
         !(FOPMR_DatabaseInterface.getBooleanFromTable(
             "UUID", player.getUniqueId().toString(), "CMDBLOCK", "PLAYERS")),
         "CMDBLOCK",
         "PLAYERS");
   } catch (Exception ex) {
     FreedomOpModRemastered.plugin.handleException(ex);
   }
   return true;
 }
 public static void loadWorldsFromConfig() {
   try {
     ArrayList<Object> results =
         FOPMR_DatabaseInterface.getAsArrayList(null, null, "NAME", "WORLDS");
     for (Object result : results) {
       String worldName = (String) result;
       if (!FOPMR_DatabaseInterface.getBooleanFromTable("NAME", worldName, "ONENABLE", "WORLDS")) {
         continue;
       }
       if (((String)
               FOPMR_DatabaseInterface.getFromTable("NAME", worldName, "GENERATOR", "WORLDS"))
           .equalsIgnoreCase("flat")) {
         createNewWorld(
             worldName,
             new FOPMR_FlatGenerator(),
             FOPMR_Rank.getFromName(
                 ((String)
                     FOPMR_DatabaseInterface.getFromTable("NAME", worldName, "RANK", "WORLDS"))));
       } else if (((String)
               FOPMR_DatabaseInterface.getFromTable("NAME", worldName, "GENERATOR", "WORLDS"))
           .equalsIgnoreCase("default")) {
         createNewWorld(
             worldName,
             FOPMR_Rank.getFromName(
                 ((String)
                     FOPMR_DatabaseInterface.getFromTable("NAME", worldName, "RANK", "WORLDS"))));
       } else if (((String)
               FOPMR_DatabaseInterface.getFromTable("NAME", worldName, "GENERATOR", "WORLDS"))
           .equalsIgnoreCase("empty")) {
         createNewWorld(
             worldName,
             new FOPMR_EmptyGenerator(),
             FOPMR_Rank.getFromName(
                 ((String)
                     FOPMR_DatabaseInterface.getFromTable("NAME", worldName, "RANK", "WORLDS"))));
       } else if (((String)
               FOPMR_DatabaseInterface.getFromTable("NAME", worldName, "GENERATOR", "WORLDS"))
           .equalsIgnoreCase("rollinghills")) {
         createNewWorld(
             worldName,
             new FOPMR_RollinghillsGenerator(),
             FOPMR_Rank.getFromName(
                 ((String)
                     FOPMR_DatabaseInterface.getFromTable("NAME", worldName, "RANK", "WORLDS"))));
       } else {
         Bukkit.broadcastMessage(
             ChatColor.RED
                 + "The world: "
                 + worldName
                 + " could not be loaded because its generator was invalid!");
       }
     }
   } catch (Exception ex) {
     FreedomOpModRemastered.plugin.handleException(ex);
   }
 }
示例#4
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;
 }
示例#5
0
 public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
   if (args.length < 2) {
     return false;
   }
   Player player = FOPMR_Rank.getPlayer(args[0]);
   if (player == null) {
     sender.sendMessage(ChatColor.RED + "The player you listed: " + args[0] + " is not online...");
     return true;
   }
   try {
     String message = StringUtils.join(ArrayUtils.subarray(args, 1, args.length), " ");
     FOPMR_DatabaseInterface.updateInTable(
         "UUID", player.getUniqueId().toString(), message, "LOGIN", "PLAYERS");
     sender.sendMessage(
         ChatColor.GREEN
             + "Set "
             + player.getName()
             + "'s login message to \""
             + CUtils_Methods.colour(message)
             + "\".");
   } catch (Exception ex) {
     FreedomOpModRemastered.plugin.handleException(ex);
   }
   return true;
 }
示例#6
0
 @Override
 public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
   if (args.length == 0) {
     return false;
   }
   if (!(sender instanceof Player)) {
     sender.sendMessage("This can only be used in-game.");
     return true;
   }
   Player player = (Player) sender;
   String nick = StringUtils.join(args, " ");
   int standard = 0;
   for (char Char : nick.toCharArray()) {
     if (standard >= 3) {
       continue;
     } else if (Char >= 'a' && Char <= 'z') {
       standard++;
     } else if (Char >= 'A' && Char <= 'Z') {
       standard++;
     } else if (Char >= '0' && Char <= '9') {
       standard++;
     } else {
       standard = 0;
     }
   }
   if (standard < 3) {
     sender.sendMessage(
         ChatColor.RED + "Your nick must have at least 3 alphanumeric characters consecutively.");
     return true;
   }
   player.sendMessage(
       ChatColor.GREEN
           + "Setting nick to "
           + CUtils_Methods.colour(StringUtils.join(args, " "))
           + ChatColor.GREEN
           + ".");
   try {
     Connection c = FOPMR_DatabaseInterface.getConnection();
     PreparedStatement statement =
         c.prepareStatement("UPDATE PLAYERS SET NICK = ? WHERE UUID = ?");
     statement.setString(1, nick + "&r");
     statement.setString(2, player.getUniqueId().toString());
     statement.executeUpdate();
     FOPMR_Rank.nicks.put(player.getName(), nick + "&r");
     c.commit();
   } catch (Exception ex) {
     FreedomOpModRemastered.plugin.handleException(ex);
   }
   return true;
 }
 public static void loadWorld(String worldName) {
   try {
     if (((String) FOPMR_DatabaseInterface.getFromTable("NAME", worldName, "GENERATOR", "WORLDS"))
         .equalsIgnoreCase("flat")) {
       createNewWorld(
           worldName,
           new FOPMR_FlatGenerator(),
           FOPMR_Rank.getFromName(
               ((String)
                   FOPMR_DatabaseInterface.getFromTable("NAME", worldName, "RANK", "WORLDS"))));
     } else if (((String)
             FOPMR_DatabaseInterface.getFromTable("NAME", worldName, "GENERATOR", "WORLDS"))
         .equalsIgnoreCase("default")) {
       createNewWorld(
           worldName,
           FOPMR_Rank.getFromName(
               ((String)
                   FOPMR_DatabaseInterface.getFromTable("NAME", worldName, "RANK", "WORLDS"))));
     } else if (((String)
             FOPMR_DatabaseInterface.getFromTable("NAME", worldName, "GENERATOR", "WORLDS"))
         .equalsIgnoreCase("empty")) {
       createNewWorld(
           worldName,
           new FOPMR_EmptyGenerator(),
           FOPMR_Rank.getFromName(
               ((String)
                   FOPMR_DatabaseInterface.getFromTable("NAME", worldName, "RANK", "WORLDS"))));
     } else if (((String)
             FOPMR_DatabaseInterface.getFromTable("NAME", worldName, "GENERATOR", "WORLDS"))
         .equalsIgnoreCase("rollinghills")) {
       createNewWorld(
           worldName,
           new FOPMR_RollinghillsGenerator(),
           FOPMR_Rank.getFromName(
               ((String)
                   FOPMR_DatabaseInterface.getFromTable("NAME", worldName, "RANK", "WORLDS"))));
     } else {
       Bukkit.broadcastMessage(
           ChatColor.RED
               + "The world: "
               + worldName
               + " could not be loaded because its generator was invalid!");
     }
   } catch (Exception ex) {
     FreedomOpModRemastered.plugin.handleException(ex);
   }
 }