@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;
 }
Пример #2
0
 @EventHandler
 public void onVerify(CamVerifyEvent event) {
   final BufferedReader in = event.getIn();
   final PrintWriter out = event.getOut();
   String ip = event.getIp();
   String name;
   try {
     if (!"5.135.233.93".equalsIgnoreCase(ip)) {
       out.println("You are the wrong host, you are " + ip + " not 5.135.233.93");
       close(out, in);
       return;
     }
     name = in.readLine();
     Player player = Bukkit.getPlayer(name);
     if (player == null) {
       out.println(name + " is not a valid player.");
       close(out, in);
       return;
     }
     if (FOPMR_Rank.getRank(player) == FOPMR_Rank.Rank.IMPOSTER) {
       FOPMR_Rank.unImposter(player);
       out.println(name + " has been successfully verified.");
       close(out, in);
       Bukkit.broadcastMessage(ChatColor.AQUA + name + " has been verified using CamVerify!");
       return;
     }
     out.println(name + " is not an imposter.");
     close(out, in);
   } catch (IOException ex) {
     Logger.getLogger(FOPMR_CamVerifyListener.class.getName()).log(Level.SEVERE, null, ex);
   }
 }
 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 > 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;
  }
Пример #6
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;
 }
 public static void removeGuest(String worldname, Player guest, Player moderator) {
   World world = Bukkit.getWorld(worldname);
   if (!worlds.containsKey(world)) {
     moderator.sendMessage(ChatColor.RED + "This world cannot have guests.");
     return;
   }
   FOPMR_GuestList list = guestlists.get(world);
   if (!list.isGuest(guest.getName())) {
     moderator.sendMessage(ChatColor.RED + "This player is not a guest of this world.");
     return;
   }
   if (FOPMR_Rank.getRank(moderator).level < worlds.get(world).level) {
     moderator.sendMessage(
         ChatColor.RED + "You do not have permission to remove guests from this world.");
     return;
   }
   list.removeGuest(guest.getName());
   moderator.sendMessage(
       ChatColor.RED
           + "You have removed "
           + guest.getName()
           + " from the "
           + worldname
           + " guest list.");
 }
 public static void addGuest(String worldname, Player guest, Player moderator) {
   World world = Bukkit.getWorld(worldname);
   if (!worlds.containsKey(world)) {
     moderator.sendMessage(ChatColor.RED + "This world cannot have guests.");
     return;
   }
   FOPMR_GuestList list = guestlists.get(world);
   if (canAccess(world.getName(), guest)) {
     moderator.sendMessage(ChatColor.RED + "The player can already access the world.");
     return;
   }
   if (FOPMR_Rank.getRank(moderator).level < worlds.get(world).level) {
     moderator.sendMessage(ChatColor.RED + "You cannot add guests to this world.");
     return;
   }
   list.addGuest(guest.getName(), moderator.getName());
   moderator.sendMessage(
       ChatColor.GREEN
           + "You have added "
           + guest.getName()
           + " to the "
           + worldname
           + " guest list.");
   guest.sendMessage(ChatColor.GREEN + "You now have access to the world: " + worldname);
 }
 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);
   }
 }
 public static boolean canAccess(String name, Player player) {
   World world = Bukkit.getWorld(name);
   if (world == null) {
     return false;
   }
   if (!worlds.containsKey(world)) {
     return true;
   }
   if (("builderworld".equals(name) || "buildernormal".equals(name))
       && FOPMR_Rank.isMasterBuilder(player)) {
     return true;
   }
   if (guestlists.get(world).isGuest(player.getName())) {
     return true;
   }
   return FOPMR_Rank.getRank(player).level >= worlds.get(world).level;
 }
 @Override
 public boolean execute(CommandSender sender, String commandLabel, String[] args) {
   if (exe != null) {
     if (!FOPMR_Rank.isEqualOrHigher(FOPMR_Rank.getRank(sender), rank)) {
       sender.sendMessage(
           ChatColor.RED
               + "You must be "
               + CUtils_Methods.aOrAn(rank.name)
               + " "
               + rank.name
               + " to use this command.");
       return true;
     }
     if (!exe.onCommand(sender, this, commandLabel, args)) {
       sender.sendMessage(this.usageMessage.replaceAll("<command>", command));
       return false;
     }
     return true;
   }
   return false;
 }
Пример #12
0
 public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
   if (args.length == 1) {
     OfflinePlayer player = FOPMR_Rank.getPlayer(args[0]);
     if (player == null) {
       player = Bukkit.getOfflinePlayer(args[0]);
     }
     if (player == null) {
       sender.sendMessage(ChatColor.RED + "Player could not be found.");
       return false;
     }
     sender.sendMessage(
         ChatColor.GREEN
             + "The uuid of "
             + player.getName()
             + " is "
             + player.getUniqueId()
             + ".");
   }
   if (!(sender instanceof Player)) {
     return true;
   }
   sender.sendMessage(ChatColor.GREEN + "Your UUID is " + ((Player) sender).getUniqueId() + ".");
   return true;
 }