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;
  }
Exemple #2
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;
 }
Exemple #3
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;
 }