@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 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);
 }
Ejemplo n.º 4
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 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;
 }