From 246cb359a3d602c9c2df6d8e2d9f453a9a14303f Mon Sep 17 00:00:00 2001 From: BlackBeltPanda Date: Tue, 9 Dec 2014 00:36:15 -0500 Subject: [PATCH 1/2] Fix running commands from console Using Vault for permissions checks is stupid since Vault just uses Bukkit's player.hasPermission. Checking for OP is pointless, as OPs have all permissions. Moved (sender instanceof player) checks to the couple commands that can only be run in-game. --- .../talabrek/ultimateskyblock/DevCommand.java | 223 +++++++++--------- 1 file changed, 114 insertions(+), 109 deletions(-) diff --git a/src/main/java/us/talabrek/ultimateskyblock/DevCommand.java b/src/main/java/us/talabrek/ultimateskyblock/DevCommand.java index 1e16b26b5..1fac4466f 100644 --- a/src/main/java/us/talabrek/ultimateskyblock/DevCommand.java +++ b/src/main/java/us/talabrek/ultimateskyblock/DevCommand.java @@ -1,122 +1,119 @@ -package us.talabrek.ultimateskyblock; +package src.main.java.us.talabrek.ultimateskyblock; import org.bukkit.command.*; import org.bukkit.entity.*; import java.io.*; -import org.bukkit.plugin.*; import org.bukkit.*; public class DevCommand implements CommandExecutor { public boolean onCommand(final CommandSender sender, final Command command, final String label, final String[] split) { - if (!(sender instanceof Player)) { - return false; - } - final Player player = (Player) sender; + final Player player; if (split.length == 0) { - if (VaultHandler.checkPerk(player.getName(), "usb.mod.protect", player.getWorld()) || VaultHandler.checkPerk(player.getName(), "usb.mod.protectall", player.getWorld()) || VaultHandler.checkPerk(player.getName(), "usb.mod.topten", player.getWorld()) || VaultHandler.checkPerk(player.getName(), "usb.mod.orphan", player.getWorld()) || VaultHandler.checkPerk(player.getName(), "usb.admin.delete", player.getWorld()) || VaultHandler.checkPerk(player.getName(), "usb.admin.remove", player.getWorld()) || VaultHandler.checkPerk(player.getName(), "usb.admin.register", player.getWorld()) || player.isOp()) { - player.sendMessage("[dev usage]"); - if (VaultHandler.checkPerk(player.getName(), "usb.mod.protect", player.getWorld()) || player.isOp()) { - player.sendMessage(ChatColor.YELLOW + "/dev protect :" + ChatColor.WHITE + " add protection to an island."); + if (sender.hasPermission("usb.mod.protect") || sender.hasPermission("usb.mod.protectall") || sender.hasPermission("usb.mod.topten") || sender.hasPermission("usb.mod.orphan") || sender.hasPermission("usb.admin.delete") || sender.hasPermission("usb.admin.remove") || sender.hasPermission("usb.admin.register")) { + sender.sendMessage("[dev usage]"); + if (sender.hasPermission("usb.mod.protect")) { + sender.sendMessage(ChatColor.YELLOW + "/dev protect :" + ChatColor.WHITE + " add protection to an island."); } - if (VaultHandler.checkPerk(player.getName(), "usb.admin.reload", player.getWorld()) || player.isOp()) { - player.sendMessage(ChatColor.YELLOW + "/dev reload:" + ChatColor.WHITE + " reload configuration from file."); + if (sender.hasPermission("usb.admin.reload")) { + sender.sendMessage(ChatColor.YELLOW + "/dev reload:" + ChatColor.WHITE + " reload configuration from file."); } - if (VaultHandler.checkPerk(player.getName(), "usb.mod.protectall", player.getWorld()) || player.isOp()) { - player.sendMessage(ChatColor.YELLOW + "/dev protectall:" + ChatColor.WHITE + " add island protection to unprotected islands."); + if (sender.hasPermission("usb.mod.protectall")) { + sender.sendMessage(ChatColor.YELLOW + "/dev protectall:" + ChatColor.WHITE + " add island protection to unprotected islands."); } - if (VaultHandler.checkPerk(player.getName(), "usb.mod.topten", player.getWorld()) || player.isOp()) { - player.sendMessage(ChatColor.YELLOW + "/dev topten:" + ChatColor.WHITE + " manually update the top 10 list"); + if (sender.hasPermission("usb.mod.topten")) { + sender.sendMessage(ChatColor.YELLOW + "/dev topten:" + ChatColor.WHITE + " manually update the top 10 list"); } - if (VaultHandler.checkPerk(player.getName(), "usb.mod.orphan", player.getWorld()) || player.isOp()) { - player.sendMessage(ChatColor.YELLOW + "/dev orphancount:" + ChatColor.WHITE + " unused island locations count"); + if (sender.hasPermission("usb.mod.orphan")) { + sender.sendMessage(ChatColor.YELLOW + "/dev orphancount:" + ChatColor.WHITE + " unused island locations count"); } - if (VaultHandler.checkPerk(player.getName(), "usb.mod.orphan", player.getWorld()) || player.isOp()) { - player.sendMessage(ChatColor.YELLOW + "/dev clearorphan:" + ChatColor.WHITE + " remove any unused island locations."); + if (sender.hasPermission("usb.mod.orphan")) { + sender.sendMessage(ChatColor.YELLOW + "/dev clearorphan:" + ChatColor.WHITE + " remove any unused island locations."); } - if (VaultHandler.checkPerk(player.getName(), "usb.mod.orphan", player.getWorld()) || player.isOp()) { - player.sendMessage(ChatColor.YELLOW + "/dev saveorphan:" + ChatColor.WHITE + " save the list of old (empty) island locations."); + if (sender.hasPermission("usb.mod.orphan")) { + sender.sendMessage(ChatColor.YELLOW + "/dev saveorphan:" + ChatColor.WHITE + " save the list of old (empty) island locations."); } - if (VaultHandler.checkPerk(player.getName(), "usb.admin.delete", player.getWorld()) || player.isOp()) { - player.sendMessage(ChatColor.YELLOW + "/dev delete :" + ChatColor.WHITE + " delete an island (removes blocks)."); + if (sender.hasPermission("usb.admin.delete")) { + sender.sendMessage(ChatColor.YELLOW + "/dev delete :" + ChatColor.WHITE + " delete an island (removes blocks)."); } - if (VaultHandler.checkPerk(player.getName(), "usb.admin.remove", player.getWorld()) || player.isOp()) { - player.sendMessage(ChatColor.YELLOW + "/dev remove :" + ChatColor.WHITE + " remove a player from an island."); + if (sender.hasPermission("usb.admin.remove")) { + sender.sendMessage(ChatColor.YELLOW + "/dev remove :" + ChatColor.WHITE + " remove a player from an island."); } - if (VaultHandler.checkPerk(player.getName(), "usb.admin.register", player.getWorld()) || player.isOp()) { - player.sendMessage(ChatColor.YELLOW + "/dev register :" + ChatColor.WHITE + " set a player's island to your location"); + if (sender.hasPermission("usb.admin.register")) { + sender.sendMessage(ChatColor.YELLOW + "/dev register :" + ChatColor.WHITE + " set a player's island to your location"); } - if (VaultHandler.checkPerk(player.getName(), "usb.mod.challenges", player.getWorld()) || player.isOp()) { - player.sendMessage(ChatColor.YELLOW + "/dev completechallenge :" + ChatColor.WHITE + " marks a challenge as complete"); + if (sender.hasPermission("usb.mod.challenges")) { + sender.sendMessage(ChatColor.YELLOW + "/dev completechallenge :" + ChatColor.WHITE + " marks a challenge as complete"); } - if (VaultHandler.checkPerk(player.getName(), "usb.mod.challenges", player.getWorld()) || player.isOp()) { - player.sendMessage(ChatColor.YELLOW + "/dev resetchallenge :" + ChatColor.WHITE + " marks a challenge as incomplete"); + if (sender.hasPermission("usb.mod.challenges")) { + sender.sendMessage(ChatColor.YELLOW + "/dev resetchallenge :" + ChatColor.WHITE + " marks a challenge as incomplete"); } - if (VaultHandler.checkPerk(player.getName(), "usb.mod.challenges", player.getWorld()) || player.isOp()) { - player.sendMessage(ChatColor.YELLOW + "/dev resetallchallenges :" + ChatColor.WHITE + " resets all of the player's challenges"); + if (sender.hasPermission("usb.mod.challenges")) { + sender.sendMessage(ChatColor.YELLOW + "/dev resetallchallenges :" + ChatColor.WHITE + " resets all of the player's challenges"); } - if (VaultHandler.checkPerk(player.getName(), "usb.admin.purge", player.getWorld()) || player.isOp()) { - player.sendMessage(ChatColor.YELLOW + "/dev purge [TimeInDays]:" + ChatColor.WHITE + " delete inactive islands older than [TimeInDays]."); + if (sender.hasPermission("usb.admin.purge")) { + sender.sendMessage(ChatColor.YELLOW + "/dev purge [TimeInDays]:" + ChatColor.WHITE + " delete inactive islands older than [TimeInDays]."); } - if (VaultHandler.checkPerk(player.getName(), "usb.mod.party", player.getWorld()) || player.isOp()) { - player.sendMessage(ChatColor.YELLOW + "/dev buildpartylist:" + ChatColor.WHITE + " build a new party list (use this if parties are broken)."); + if (sender.hasPermission("usb.mod.party")) { + sender.sendMessage(ChatColor.YELLOW + "/dev buildpartylist:" + ChatColor.WHITE + " build a new party list (use this if parties are broken)."); } - if (VaultHandler.checkPerk(player.getName(), "usb.mod.party", player.getWorld()) || player.isOp()) { - player.sendMessage(ChatColor.YELLOW + "/dev info :" + ChatColor.WHITE + " check the party information for the given player."); + if (sender.hasPermission("usb.mod.party")) { + sender.sendMessage(ChatColor.YELLOW + "/dev info :" + ChatColor.WHITE + " check the party information for the given player."); } } else { - player.sendMessage(ChatColor.RED + "You don't have permission to use this command."); + sender.sendMessage(ChatColor.RED + "You don't have permission to use this command."); } } else if (split.length == 1) { - if (split[0].equals("clearorphan") && (VaultHandler.checkPerk(player.getName(), "usb.mod.orphan", player.getWorld()) || player.isOp())) { - player.sendMessage(ChatColor.YELLOW + "Clearing all old (empty) island locations."); + if (split[0].equals("clearorphan") && (sender.hasPermission("usb.mod.orphan"))) { + sender.sendMessage(ChatColor.YELLOW + "Clearing all old (empty) island locations."); uSkyBlock.getInstance().clearOrphanedIsland(); - } else if (split[0].equals("protectall") && (VaultHandler.checkPerk(player.getName(), "usb.mod.protectall", player.getWorld()) || player.isOp())) { - player.sendMessage(ChatColor.YELLOW + "This command is only available using WorldGuard."); + } else if (split[0].equals("protectall") && (sender.hasPermission("usb.mod.protectall"))) { + sender.sendMessage(ChatColor.YELLOW + "This command is only available using WorldGuard."); if (Settings.island_protectWithWorldGuard) { - player.sendMessage(ChatColor.YELLOW + "This command has been disabled."); + sender.sendMessage(ChatColor.YELLOW + "This command has been disabled."); } else { - player.sendMessage(ChatColor.RED + "You must enable WorldGuard protection in the config.yml to use this!"); + sender.sendMessage(ChatColor.RED + "You must enable WorldGuard protection in the config.yml to use this!"); } - } else if (split[0].equals("buildislandlist") && (VaultHandler.checkPerk(player.getName(), "usb.mod.protectall", player.getWorld()) || player.isOp())) { - player.sendMessage(ChatColor.YELLOW + "Building island list.."); + } else if (split[0].equals("buildislandlist") && (sender.hasPermission("usb.mod.protectall"))) { + sender.sendMessage(ChatColor.YELLOW + "Building island list.."); uSkyBlock.getInstance().buildIslandList(); - player.sendMessage(ChatColor.YELLOW + "Finished building island list.."); - } else if (split[0].equals("orphancount") && (VaultHandler.checkPerk(player.getName(), "usb.mod.orphan", player.getWorld()) || player.isOp())) { - player.sendMessage(new StringBuilder().append(ChatColor.YELLOW).append(uSkyBlock.getInstance().orphanCount()).append(" old island locations will be used before new ones.").toString()); - } else if (split[0].equals("reload") && (VaultHandler.checkPerk(player.getName(), "usb.admin.reload", player.getWorld()) || player.isOp())) { + sender.sendMessage(ChatColor.YELLOW + "Finished building island list.."); + } else if (split[0].equals("orphancount") && (sender.hasPermission("usb.mod.orphan"))) { + sender.sendMessage(new StringBuilder().append(ChatColor.YELLOW).append(uSkyBlock.getInstance().orphanCount()).append(" old island locations will be used before new ones.").toString()); + } else if (split[0].equals("reload") && (sender.hasPermission("usb.admin.reload"))) { uSkyBlock.getInstance().reloadConfig(); Settings.loadPluginConfig(uSkyBlock.getInstance().getConfig()); uSkyBlock.getInstance().reloadLevelConfig(); uSkyBlock.getInstance().loadLevelConfig(); - player.sendMessage(ChatColor.YELLOW + "Configuration reloaded from file."); - } else if (split[0].equals("saveorphan") && (VaultHandler.checkPerk(player.getName(), "usb.mod.orphan", player.getWorld()) || player.isOp())) { - player.sendMessage(ChatColor.YELLOW + "Saving the orphan list."); + sender.sendMessage(ChatColor.YELLOW + "Configuration reloaded from file."); + } else if (split[0].equals("saveorphan") && (sender.hasPermission("usb.mod.orphan"))) { + sender.sendMessage(ChatColor.YELLOW + "Saving the orphan list."); uSkyBlock.getInstance().saveOrphans(); - } else if (split[0].equals("topten") && (VaultHandler.checkPerk(player.getName(), "usb.mod.topten", player.getWorld()) || player.isOp())) { - player.sendMessage(ChatColor.YELLOW + "Generating the Top Ten list"); + } else if (split[0].equals("topten") && (sender.hasPermission("usb.mod.topten"))) { + sender.sendMessage(ChatColor.YELLOW + "Generating the Top Ten list"); uSkyBlock.getInstance().updateTopTen(uSkyBlock.getInstance().generateTopTen()); - player.sendMessage(ChatColor.YELLOW + "Finished generation of the Top Ten list"); - } else if (split[0].equals("purge") && (VaultHandler.checkPerk(player.getName(), "usb.admin.purge", player.getWorld()) || player.isOp())) { + sender.sendMessage(ChatColor.YELLOW + "Finished generation of the Top Ten list"); + } else if (split[0].equals("purge") && (sender.hasPermission("usb.admin.purge"))) { if (uSkyBlock.getInstance().isPurgeActive()) { - player.sendMessage(ChatColor.RED + "A purge is already running, please wait for it to finish!"); + sender.sendMessage(ChatColor.RED + "A purge is already running, please wait for it to finish!"); return true; } - player.sendMessage(ChatColor.YELLOW + "Usage: /dev purge [TimeInDays]"); + sender.sendMessage(ChatColor.YELLOW + "Usage: /dev purge [TimeInDays]"); return true; } } else if (split.length == 2) { - if (split[0].equals("purge") && (VaultHandler.checkPerk(player.getName(), "usb.admin.purge", player.getWorld()) || player.isOp())) { + if (split[0].equals("purge") && (sender.hasPermission("usb.admin.purge"))) { if (uSkyBlock.getInstance().isPurgeActive()) { - player.sendMessage(ChatColor.RED + "A purge is already running, please wait for it to finish!"); + sender.sendMessage(ChatColor.RED + "A purge is already running, please wait for it to finish!"); return true; } uSkyBlock.getInstance().activatePurge(); final int time = Integer.parseInt(split[1]) * 24; - player.sendMessage(ChatColor.YELLOW + "Marking all islands inactive for more than " + split[1] + " days."); + sender.sendMessage(ChatColor.YELLOW + "Marking all islands inactive for more than " + split[1] + " days."); uSkyBlock.getInstance().getServer().getScheduler().runTaskAsynchronously(uSkyBlock.getInstance(), new Runnable() { - @Override + @SuppressWarnings("deprecation") + @Override public void run() { final File directoryPlayers = new File(uSkyBlock.getInstance().getDataFolder() + File.separator + "players"); long offlineTime = 0L; @@ -156,150 +153,158 @@ public void run() { }, 0L, 20L); } }); - } else if (split[0].equals("goto") && (VaultHandler.checkPerk(player.getName(), "usb.mod.goto", player.getWorld()) || player.isOp())) { + } else if (split[0].equals("goto") && (sender.hasPermission("usb.mod.goto"))) { + if (!(sender instanceof Player)) { + return false; + } + player = (Player) sender; final PlayerInfo pi = new PlayerInfo(split[1]); if (!pi.getHasIsland()) { - player.sendMessage(ChatColor.RED + "Error: Invalid Player (check spelling)"); + sender.sendMessage(ChatColor.RED + "Error: Invalid Player (check spelling)"); } else { if (pi.getHomeLocation() != null) { - player.sendMessage(ChatColor.GREEN + "Teleporting to " + split[1] + "'s island."); + sender.sendMessage(ChatColor.GREEN + "Teleporting to " + split[1] + "'s island."); player.teleport(pi.getHomeLocation()); return true; } if (pi.getIslandLocation() != null) { - player.sendMessage(ChatColor.GREEN + "Teleporting to " + split[1] + "'s island."); + sender.sendMessage(ChatColor.GREEN + "Teleporting to " + split[1] + "'s island."); player.teleport(pi.getIslandLocation()); return true; } - player.sendMessage("Error: That player does not have an island!"); + sender.sendMessage("Error: That player does not have an island!"); } - } else if (split[0].equals("remove") && (VaultHandler.checkPerk(player.getName(), "usb.admin.remove", player.getWorld()) || player.isOp())) { + } else if (split[0].equals("remove") && (sender.hasPermission("usb.admin.remove"))) { final PlayerInfo pi = new PlayerInfo(split[1]); if (!pi.getHasIsland()) { - player.sendMessage(ChatColor.RED + "Error: Invalid Player (check spelling)"); + sender.sendMessage(ChatColor.RED + "Error: Invalid Player (check spelling)"); } else { if (pi.getIslandLocation() != null) { - player.sendMessage(ChatColor.YELLOW + "Removing " + split[1] + "'s island."); + sender.sendMessage(ChatColor.YELLOW + "Removing " + split[1] + "'s island."); uSkyBlock.getInstance().devDeletePlayerIsland(split[1]); return true; } - player.sendMessage("Error: That player does not have an island!"); + sender.sendMessage("Error: That player does not have an island!"); } - } else if (split[0].equals("delete") && (VaultHandler.checkPerk(player.getName(), "usb.admin.delete", player.getWorld()) || player.isOp())) { + } else if (split[0].equals("delete") && (sender.hasPermission("usb.admin.delete"))) { final PlayerInfo pi = new PlayerInfo(split[1]); if (!pi.getHasIsland()) { - player.sendMessage(ChatColor.RED + "Error: Invalid Player (check spelling)"); + sender.sendMessage(ChatColor.RED + "Error: Invalid Player (check spelling)"); } else { if (pi.getIslandLocation() != null) { - player.sendMessage(ChatColor.YELLOW + "Removing " + split[1] + "'s island."); + sender.sendMessage(ChatColor.YELLOW + "Removing " + split[1] + "'s island."); uSkyBlock.getInstance().deletePlayerIsland(split[1]); return true; } - player.sendMessage("Error: That player does not have an island!"); + sender.sendMessage("Error: That player does not have an island!"); + } + } else if (split[0].equals("register") && (sender.hasPermission("usb.admin.register"))) { + if (!(sender instanceof Player)) { + return false; } - } else if (split[0].equals("register") && (VaultHandler.checkPerk(player.getName(), "usb.admin.register", player.getWorld()) || player.isOp())) { + player = (Player) sender; final PlayerInfo pi = new PlayerInfo(split[1]); if (pi.getHasIsland()) { uSkyBlock.getInstance().devDeletePlayerIsland(split[1]); } if (uSkyBlock.getInstance().devSetPlayerIsland(player, player.getLocation(), split[1])) { - player.sendMessage(ChatColor.GREEN + "Set " + split[1] + "'s island to the bedrock nearest you."); + sender.sendMessage(ChatColor.GREEN + "Set " + split[1] + "'s island to the bedrock nearest you."); } else { - player.sendMessage(ChatColor.RED + "Bedrock not found: unable to set the island!"); + sender.sendMessage(ChatColor.RED + "Bedrock not found: unable to set the island!"); } - } else if (!split[0].equals("info") || (!VaultHandler.checkPerk(player.getName(), "usb.mod.party", player.getWorld()) && !player.isOp())) { - if (split[0].equals("resetallchallenges") && (VaultHandler.checkPerk(player.getName(), "usb.mod.challenges", player.getWorld()) || player.isOp())) { + } else if (!split[0].equals("info") || (!sender.hasPermission("usb.mod.party"))) { + if (split[0].equals("resetallchallenges") && (sender.hasPermission("usb.mod.challenges"))) { if (!uSkyBlock.getInstance().getActivePlayers().containsKey(split[1])) { final PlayerInfo pi = new PlayerInfo(split[1]); if (!pi.getHasIsland()) { - player.sendMessage(ChatColor.RED + "Error: Invalid Player (check spelling)"); + sender.sendMessage(ChatColor.RED + "Error: Invalid Player (check spelling)"); return true; } pi.resetAllChallenges(); pi.savePlayerConfig(split[1]); - player.sendMessage(ChatColor.YELLOW + split[1] + " has had all challenges reset."); + sender.sendMessage(ChatColor.YELLOW + split[1] + " has had all challenges reset."); } else { uSkyBlock.getInstance().getActivePlayers().get(split[1]).resetAllChallenges(); - player.sendMessage(ChatColor.YELLOW + split[1] + " has had all challenges reset."); + sender.sendMessage(ChatColor.YELLOW + split[1] + " has had all challenges reset."); } - } else if (split[0].equals("setbiome") && (VaultHandler.checkPerk(player.getName(), "usb.mod.setbiome", player.getWorld()) || player.isOp())) { + } else if (split[0].equals("setbiome") && (sender.hasPermission("usb.mod.setbiome"))) { if (!uSkyBlock.getInstance().getActivePlayers().containsKey(split[1])) { final PlayerInfo pi = new PlayerInfo(split[1]); if (!pi.getHasIsland()) { - player.sendMessage(ChatColor.RED + "Error: Invalid Player (check spelling)"); + sender.sendMessage(ChatColor.RED + "Error: Invalid Player (check spelling)"); return true; } uSkyBlock.getInstance().setBiome(pi.getIslandLocation(), "OCEAN"); pi.savePlayerConfig(split[1]); - player.sendMessage(ChatColor.YELLOW + split[1] + " has had their biome changed to OCEAN."); + sender.sendMessage(ChatColor.YELLOW + split[1] + " has had their biome changed to OCEAN."); } else { uSkyBlock.getInstance().setBiome(uSkyBlock.getInstance().getActivePlayers().get(split[1]).getIslandLocation(), "OCEAN"); - player.sendMessage(ChatColor.YELLOW + split[1] + " has had their biome changed to OCEAN."); + sender.sendMessage(ChatColor.YELLOW + split[1] + " has had their biome changed to OCEAN."); } } } } else if (split.length == 3) { - if (split[0].equals("completechallenge") && (VaultHandler.checkPerk(player.getName(), "usb.mod.challenges", player.getWorld()) || player.isOp())) { + if (split[0].equals("completechallenge") && (sender.hasPermission("usb.mod.challenges"))) { if (!uSkyBlock.getInstance().getActivePlayers().containsKey(split[2])) { final PlayerInfo pi = new PlayerInfo(split[2]); if (!pi.getHasIsland()) { - player.sendMessage(ChatColor.RED + "Error: Invalid Player (check spelling)"); + sender.sendMessage(ChatColor.RED + "Error: Invalid Player (check spelling)"); return true; } if (pi.checkChallenge(split[1].toLowerCase()) > 0 || !pi.challengeExists(split[1].toLowerCase())) { - player.sendMessage(ChatColor.RED + "Challenge doesn't exist or is already completed"); + sender.sendMessage(ChatColor.RED + "Challenge doesn't exist or is already completed"); return true; } pi.completeChallenge(split[1].toLowerCase()); pi.savePlayerConfig(split[2]); - player.sendMessage(ChatColor.YELLOW + "challange: " + split[1].toLowerCase() + " has been completed for " + split[2]); + sender.sendMessage(ChatColor.YELLOW + "challange: " + split[1].toLowerCase() + " has been completed for " + split[2]); } else { if (uSkyBlock.getInstance().getActivePlayers().get(split[2]).checkChallenge(split[1].toLowerCase()) > 0 || !uSkyBlock.getInstance().getActivePlayers().get(split[2]).challengeExists(split[1].toLowerCase())) { - player.sendMessage(ChatColor.RED + "Challenge doesn't exist or is already completed"); + sender.sendMessage(ChatColor.RED + "Challenge doesn't exist or is already completed"); return true; } uSkyBlock.getInstance().getActivePlayers().get(split[2]).completeChallenge(split[1].toLowerCase()); - player.sendMessage(ChatColor.YELLOW + "challange: " + split[1].toLowerCase() + " has been completed for " + split[2]); + sender.sendMessage(ChatColor.YELLOW + "challange: " + split[1].toLowerCase() + " has been completed for " + split[2]); } - } else if (split[0].equals("resetchallenge") && (VaultHandler.checkPerk(player.getName(), "usb.mod.challenges", player.getWorld()) || player.isOp())) { + } else if (split[0].equals("resetchallenge") && (sender.hasPermission("usb.mod.challenges"))) { if (!uSkyBlock.getInstance().getActivePlayers().containsKey(split[2])) { final PlayerInfo pi = new PlayerInfo(split[2]); if (!pi.getHasIsland()) { - player.sendMessage(ChatColor.RED + "Error: Invalid Player (check spelling)"); + sender.sendMessage(ChatColor.RED + "Error: Invalid Player (check spelling)"); return true; } if (pi.checkChallenge(split[1].toLowerCase()) == 0 || !pi.challengeExists(split[1].toLowerCase())) { - player.sendMessage(ChatColor.RED + "Challenge doesn't exist or isn't yet completed"); + sender.sendMessage(ChatColor.RED + "Challenge doesn't exist or isn't yet completed"); return true; } pi.resetChallenge(split[1].toLowerCase()); pi.savePlayerConfig(split[2]); - player.sendMessage(ChatColor.YELLOW + "challange: " + split[1].toLowerCase() + " has been reset for " + split[2]); + sender.sendMessage(ChatColor.YELLOW + "challange: " + split[1].toLowerCase() + " has been reset for " + split[2]); } else { if (uSkyBlock.getInstance().getActivePlayers().get(split[2]).checkChallenge(split[1].toLowerCase()) == 0 || !uSkyBlock.getInstance().getActivePlayers().get(split[2]).challengeExists(split[1].toLowerCase())) { - player.sendMessage(ChatColor.RED + "Challenge doesn't exist or isn't yet completed"); + sender.sendMessage(ChatColor.RED + "Challenge doesn't exist or isn't yet completed"); return true; } uSkyBlock.getInstance().getActivePlayers().get(split[2]).resetChallenge(split[1].toLowerCase()); - player.sendMessage(ChatColor.YELLOW + "challange: " + split[1].toLowerCase() + " has been completed for " + split[2]); + sender.sendMessage(ChatColor.YELLOW + "challange: " + split[1].toLowerCase() + " has been completed for " + split[2]); } - } else if (split[0].equals("setbiome") && (VaultHandler.checkPerk(player.getName(), "usb.mod.setbiome", player.getWorld()) || player.isOp())) { + } else if (split[0].equals("setbiome") && (sender.hasPermission("usb.mod.setbiome"))) { if (!uSkyBlock.getInstance().getActivePlayers().containsKey(split[1])) { final PlayerInfo pi = new PlayerInfo(split[1]); if (!pi.getHasIsland()) { - player.sendMessage(ChatColor.RED + "Error: Invalid Player (check spelling)"); + sender.sendMessage(ChatColor.RED + "Error: Invalid Player (check spelling)"); return true; } if (uSkyBlock.getInstance().setBiome(pi.getIslandLocation(), split[2])) { - player.sendMessage(ChatColor.YELLOW + split[1] + " has had their biome changed to " + split[2].toUpperCase() + "."); + sender.sendMessage(ChatColor.YELLOW + split[1] + " has had their biome changed to " + split[2].toUpperCase() + "."); } else { - player.sendMessage(ChatColor.YELLOW + split[1] + " has had their biome changed to OCEAN."); + sender.sendMessage(ChatColor.YELLOW + split[1] + " has had their biome changed to OCEAN."); } pi.savePlayerConfig(split[1]); } else if (uSkyBlock.getInstance().setBiome(uSkyBlock.getInstance().getActivePlayers().get(split[1]).getIslandLocation(), split[2])) { - player.sendMessage(ChatColor.YELLOW + split[1] + " has had their biome changed to " + split[2].toUpperCase() + "."); + sender.sendMessage(ChatColor.YELLOW + split[1] + " has had their biome changed to " + split[2].toUpperCase() + "."); } else { - player.sendMessage(ChatColor.YELLOW + split[1] + " has had their biome changed to OCEAN."); + sender.sendMessage(ChatColor.YELLOW + split[1] + " has had their biome changed to OCEAN."); } } } From c21f61bb3c2ccb375644a2958ecaa060d1caef2d Mon Sep 17 00:00:00 2001 From: BlackBeltPanda Date: Tue, 9 Dec 2014 00:36:43 -0500 Subject: [PATCH 2/2] Update DevCommand.java --- src/main/java/us/talabrek/ultimateskyblock/DevCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/us/talabrek/ultimateskyblock/DevCommand.java b/src/main/java/us/talabrek/ultimateskyblock/DevCommand.java index 1fac4466f..19a3a3665 100644 --- a/src/main/java/us/talabrek/ultimateskyblock/DevCommand.java +++ b/src/main/java/us/talabrek/ultimateskyblock/DevCommand.java @@ -1,4 +1,4 @@ -package src.main.java.us.talabrek.ultimateskyblock; +package us.talabrek.ultimateskyblock; import org.bukkit.command.*; import org.bukkit.entity.*;