diff options
author | KHobbits <rob@khobbits.co.uk> | 2011-11-18 12:06:59 +0000 |
---|---|---|
committer | KHobbits <rob@khobbits.co.uk> | 2011-11-18 12:06:59 +0000 |
commit | e54d73704e9fb99b99324c5407c6bfddac860a26 (patch) | |
tree | e5fadd64f907a7701192751eaf6d4c81fdd52a23 | |
parent | e5c77c1aeb2d7e8571061778f2612c2a65c6a8b9 (diff) | |
download | Essentials-e54d73704e9fb99b99324c5407c6bfddac860a26.tar Essentials-e54d73704e9fb99b99324c5407c6bfddac860a26.tar.gz Essentials-e54d73704e9fb99b99324c5407c6bfddac860a26.tar.lz Essentials-e54d73704e9fb99b99324c5407c6bfddac860a26.tar.xz Essentials-e54d73704e9fb99b99324c5407c6bfddac860a26.zip |
Command cleanup
36 files changed, 165 insertions, 162 deletions
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandantioch.java b/Essentials/src/com/earth2me/essentials/commands/Commandantioch.java index 5bfdd3835..57d5a9c75 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandantioch.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandantioch.java @@ -4,6 +4,7 @@ import org.bukkit.Location; import org.bukkit.Server; import com.earth2me.essentials.User; import com.earth2me.essentials.TargetBlock; +import com.earth2me.essentials.Util; import org.bukkit.entity.TNTPrimed; @@ -20,7 +21,7 @@ public class Commandantioch extends EssentialsCommand ess.broadcastMessage(user, "...lobbest thou thy Holy Hand Grenade of Antioch towards thy foe,"); ess.broadcastMessage(user, "who being naughty in My sight, shall snuff it."); - final Location loc = new TargetBlock(user).getTargetBlock().getLocation(); + final Location loc = Util.getTarget(user); loc.getWorld().spawn(loc, TNTPrimed.class); } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandback.java b/Essentials/src/com/earth2me/essentials/commands/Commandback.java index 26456a5d7..fa57f7a29 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandback.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandback.java @@ -14,9 +14,9 @@ public class Commandback extends EssentialsCommand } @Override - protected void run(Server server, User user, String commandLabel, String[] args) throws Exception + protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception { - Trade charge = new Trade(this.getName(), ess); + final Trade charge = new Trade(this.getName(), ess); charge.isAffordableFor(user); user.sendMessage(Util.i18n("backUsageMsg")); user.getTeleport().back(charge); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandbackup.java b/Essentials/src/com/earth2me/essentials/commands/Commandbackup.java index 6bbf8361c..3498d6cdf 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandbackup.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandbackup.java @@ -14,9 +14,9 @@ public class Commandbackup extends EssentialsCommand } @Override - protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception + protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception { - Backup backup = ess.getBackup(); + final Backup backup = ess.getBackup(); if (backup == null) { throw new Exception(); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandbalance.java b/Essentials/src/com/earth2me/essentials/commands/Commandbalance.java index d26df68cb..e1ad11f9f 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandbalance.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandbalance.java @@ -14,7 +14,7 @@ public class Commandbalance extends EssentialsCommand } @Override - protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception + protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception { if (args.length < 1) { @@ -24,13 +24,13 @@ public class Commandbalance extends EssentialsCommand } @Override - public void run(Server server, User user, String commandLabel, String[] args) throws Exception + public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception { - double bal = (args.length < 1 - || !(user.isAuthorized("essentials.balance.others") - || user.isAuthorized("essentials.balance.other")) - ? user - : getPlayer(server, args, 0, true)).getMoney(); + final double bal = (args.length < 1 + || !(user.isAuthorized("essentials.balance.others") + || user.isAuthorized("essentials.balance.other")) + ? user + : getPlayer(server, args, 0, true)).getMoney(); user.sendMessage(Util.format("balance", Util.formatCurrency(bal, ess))); } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandbalancetop.java b/Essentials/src/com/earth2me/essentials/commands/Commandbalancetop.java index a162ea73f..159e16a59 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandbalancetop.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandbalancetop.java @@ -21,7 +21,7 @@ public class Commandbalancetop extends EssentialsCommand } @Override - protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception + protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception { int max = 10; if (args.length > 0) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandban.java b/Essentials/src/com/earth2me/essentials/commands/Commandban.java index a4a5e2839..38e7d7c3f 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandban.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandban.java @@ -23,8 +23,8 @@ public class Commandban extends EssentialsCommand { throw new NotEnoughArgumentsException(); } - final User player = getPlayer(server, args, 0, true); - if (player.getBase() instanceof OfflinePlayer) + final User user = getPlayer(server, args, 0, true); + if (user.getBase() instanceof OfflinePlayer) { if (sender instanceof Player && !ess.getUser(sender).isAuthorized("essentials.ban.offline")) @@ -35,7 +35,7 @@ public class Commandban extends EssentialsCommand } else { - if (player.isAuthorized("essentials.ban.exempt")) + if (user.isAuthorized("essentials.ban.exempt")) { sender.sendMessage(Util.i18n("banExempt")); return; @@ -46,22 +46,22 @@ public class Commandban extends EssentialsCommand if (args.length > 1) { banReason = getFinalArg(args, 1); - player.setBanReason(banReason); + user.setBanReason(banReason); } else { banReason = Util.i18n("defaultBanReason"); } - player.setBanned(true); - player.kickPlayer(banReason); - String senderName = sender instanceof Player ? ((Player)sender).getDisplayName() : Console.NAME; - - for(Player p : server.getOnlinePlayers()) + user.setBanned(true); + user.kickPlayer(banReason); + final String senderName = sender instanceof Player ? ((Player)sender).getDisplayName() : Console.NAME; + + for (Player onlinePlayer : server.getOnlinePlayers()) { - User u = ess.getUser(p); - if(u.isAuthorized("essentials.ban.notify")) + final User player = ess.getUser(onlinePlayer); + if (player.isAuthorized("essentials.ban.notify")) { - p.sendMessage(Util.format("playerBanned", senderName, player.getName(), banReason)); + onlinePlayer.sendMessage(Util.format("playerBanned", senderName, user.getName(), banReason)); } } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandbanip.java b/Essentials/src/com/earth2me/essentials/commands/Commandbanip.java index eab34b122..05cd0aa3e 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandbanip.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandbanip.java @@ -21,21 +21,21 @@ public class Commandbanip extends EssentialsCommand throw new NotEnoughArgumentsException(); } - final User u = ess.getUser(args[0]); + final User player = ess.getUser(args[0]); - if (u == null) + if (player == null) { ess.getServer().banIP(args[0]); sender.sendMessage(Util.i18n("banIpAddress")); } else { - final String ipAddress = u.getLastLoginAddress(); + final String ipAddress = player.getLastLoginAddress(); if (ipAddress.length() == 0) { throw new Exception(Util.i18n("playerNotFound")); } - ess.getServer().banIP(u.getLastLoginAddress()); + ess.getServer().banIP(player.getLastLoginAddress()); sender.sendMessage(Util.i18n("banIpAddress")); } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandbigtree.java b/Essentials/src/com/earth2me/essentials/commands/Commandbigtree.java index c6cf83df4..cd45e73c3 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandbigtree.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandbigtree.java @@ -15,7 +15,7 @@ public class Commandbigtree extends EssentialsCommand } @Override - public void run(Server server, User user, String commandLabel, String[] args) throws Exception + public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception { TreeType tree; if (args.length > 0 && args[0].equalsIgnoreCase("redwood")) @@ -30,7 +30,7 @@ public class Commandbigtree extends EssentialsCommand { throw new NotEnoughArgumentsException(); } - + final Location loc = Util.getTarget(user); final Location safeLocation = Util.getSafeDestination(loc); final boolean success = user.getWorld().generateTree(safeLocation, tree); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandbroadcast.java b/Essentials/src/com/earth2me/essentials/commands/Commandbroadcast.java index 9b92434a4..8587c31c1 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandbroadcast.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandbroadcast.java @@ -21,7 +21,6 @@ public class Commandbroadcast extends EssentialsCommand throw new NotEnoughArgumentsException(); } - ess.broadcastMessage(null, - Util.format("broadcast", getFinalArg(args, 0))); + ess.broadcastMessage(null, Util.format("broadcast", getFinalArg(args, 0))); } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandburn.java b/Essentials/src/com/earth2me/essentials/commands/Commandburn.java index 5df3cb5d8..5c35c7486 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandburn.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandburn.java @@ -14,7 +14,7 @@ public class Commandburn extends EssentialsCommand } @Override - protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception + protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception { if (args.length < 2) { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandclearinventory.java b/Essentials/src/com/earth2me/essentials/commands/Commandclearinventory.java index 447689691..52c8afd48 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandclearinventory.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandclearinventory.java @@ -15,6 +15,7 @@ public class Commandclearinventory extends EssentialsCommand super("clearinventory"); } + //TODO: Cleanup @Override public void run(Server server, User user, String commandLabel, String[] args) throws Exception { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandcompass.java b/Essentials/src/com/earth2me/essentials/commands/Commandcompass.java index eae10f0a5..6cff8fa71 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandcompass.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandcompass.java @@ -13,39 +13,39 @@ public class Commandcompass extends EssentialsCommand } @Override - public void run(Server server, User user, String commandLabel, String[] args) throws Exception + public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception { - int r = (int)(user.getLocation().getYaw() + 180 + 360) % 360; + final int bearing = (int)(user.getLocation().getYaw() + 180 + 360) % 360; String dir; - if (r < 23) + if (bearing < 23) { dir = "N"; } - else if (r < 68) + else if (bearing < 68) { dir = "NE"; } - else if (r < 113) + else if (bearing < 113) { dir = "E"; } - else if (r < 158) + else if (bearing < 158) { dir = "SE"; } - else if (r < 203) + else if (bearing < 203) { dir = "S"; } - else if (r < 248) + else if (bearing < 248) { dir = "SW"; } - else if (r < 293) + else if (bearing < 293) { dir = "W"; } - else if (r < 338) + else if (bearing < 338) { dir = "NW"; } @@ -53,6 +53,6 @@ public class Commandcompass extends EssentialsCommand { dir = "N"; } - user.sendMessage(Util.format("compassBearing", dir, r)); + user.sendMessage(Util.format("compassBearing", dir, bearing)); } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commanddelhome.java b/Essentials/src/com/earth2me/essentials/commands/Commanddelhome.java index 1d80b6a17..558964da7 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commanddelhome.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commanddelhome.java @@ -14,25 +14,21 @@ public class Commanddelhome extends EssentialsCommand } @Override - public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception + public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception { //Allowing both formats /delhome khobbits house | /delhome khobbits:house - final String[] nameParts = args[0].split(":"); - if (nameParts[0].length() != args[0].length()) - { - args = nameParts; - } + final String[] expandedArgs = args[0].split(":"); User user = ess.getUser(sender); String name; - if (args.length < 1) + if (expandedArgs.length < 1) { throw new NotEnoughArgumentsException(); } - else if (args.length > 1 && (user == null || user.isAuthorized("essentials.delhome.others"))) + else if (expandedArgs.length > 1 && (user == null || user.isAuthorized("essentials.delhome.others"))) { - user = getPlayer(server, args, 0, true); - name = args[1]; + user = getPlayer(server, expandedArgs, 0, true); + name = expandedArgs[1]; } else { @@ -40,7 +36,7 @@ public class Commanddelhome extends EssentialsCommand { throw new NotEnoughArgumentsException(); } - name = args[0]; + name = expandedArgs[0]; } user.delHome(name.toLowerCase()); sender.sendMessage(Util.format("deleteHome", name)); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commanddeljail.java b/Essentials/src/com/earth2me/essentials/commands/Commanddeljail.java index 23ec04c4e..ebede7e00 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commanddeljail.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commanddeljail.java @@ -4,14 +4,17 @@ import com.earth2me.essentials.Util; import org.bukkit.Server; import org.bukkit.command.CommandSender; -public class Commanddeljail extends EssentialsCommand { - public Commanddeljail() { +public class Commanddeljail extends EssentialsCommand +{ + public Commanddeljail() + { super("deljail"); } @Override - protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception { + protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception + { if (args.length < 1) { throw new NotEnoughArgumentsException(); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commanddelwarp.java b/Essentials/src/com/earth2me/essentials/commands/Commanddelwarp.java index 7c2795dda..ea5ef2613 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commanddelwarp.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commanddelwarp.java @@ -13,7 +13,7 @@ public class Commanddelwarp extends EssentialsCommand } @Override - public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception + public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception { if (args.length < 1) { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commanddepth.java b/Essentials/src/com/earth2me/essentials/commands/Commanddepth.java index 5ceb62591..c23e05fc7 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commanddepth.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commanddepth.java @@ -13,16 +13,16 @@ public class Commanddepth extends EssentialsCommand } @Override - public void run(Server server, User user, String commandLabel, String[] args) throws Exception + public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception { - int y = user.getLocation().getBlockY() - 63; - if (y > 0) + final int depth = user.getLocation().getBlockY() - 63; + if (depth > 0) { - user.sendMessage(Util.format("depthAboveSea", y)); + user.sendMessage(Util.format("depthAboveSea", depth)); } - else if (y < 0) + else if (depth < 0) { - user.sendMessage(Util.format("depthBelowSea", (-y))); + user.sendMessage(Util.format("depthBelowSea", (-depth))); } else { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandeco.java b/Essentials/src/com/earth2me/essentials/commands/Commandeco.java index 2aa883bbf..d20474540 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandeco.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandeco.java @@ -14,7 +14,7 @@ public class Commandeco extends EssentialsCommand } @Override - public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception + public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception { if (args.length < 2) { @@ -34,45 +34,46 @@ public class Commandeco extends EssentialsCommand if (args[1].contentEquals("*")) { - for (Player p : server.getOnlinePlayers()) + for (Player onlinePlayer : server.getOnlinePlayers()) { - User u = ess.getUser(p); + final User player = ess.getUser(onlinePlayer); switch (cmd) { case GIVE: - u.giveMoney(amount); + player.giveMoney(amount); break; case TAKE: - u.takeMoney(amount); + player.takeMoney(amount); break; case RESET: - u.setMoney(amount == 0 ? ess.getSettings().getStartingBalance() : amount); + player.setMoney(amount == 0 ? ess.getSettings().getStartingBalance() : amount); break; } } } else { - User u = getPlayer(server, args, 1, true); + final User player = getPlayer(server, args, 1, true); switch (cmd) { case GIVE: - u.giveMoney(amount, sender); + player.giveMoney(amount, sender); break; case TAKE: - u.takeMoney(amount, sender); + player.takeMoney(amount, sender); break; case RESET: - u.setMoney(amount == 0 ? ess.getSettings().getStartingBalance() : amount); + player.setMoney(amount == 0 ? ess.getSettings().getStartingBalance() : amount); break; } } } + private enum EcoCommands { GIVE, TAKE, RESET diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandessentials.java b/Essentials/src/com/earth2me/essentials/commands/Commandessentials.java index a1a66854f..044539c2e 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandessentials.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandessentials.java @@ -93,14 +93,14 @@ public class Commandessentials extends EssentialsCommand return; } Map<Player, Block> noteBlocks = Commandessentials.this.noteBlocks; - for (Player player : server.getOnlinePlayers()) + for (Player onlinePlayer : server.getOnlinePlayers()) { - Block block = noteBlocks.get(player); + final Block block = noteBlocks.get(onlinePlayer); if (block == null || block.getType() != Material.NOTE_BLOCK) { continue; } - player.playNote(block.getLocation(), (byte)0, noteMap.get(note)); + onlinePlayer.playNote(block.getLocation(), (byte)0, noteMap.get(note)); } } }, 20, 2); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandext.java b/Essentials/src/com/earth2me/essentials/commands/Commandext.java index afb9fa3a6..fd35df530 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandext.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandext.java @@ -15,7 +15,7 @@ public class Commandext extends EssentialsCommand } @Override - protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception + protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception { if (args.length < 1) { @@ -26,7 +26,7 @@ public class Commandext extends EssentialsCommand } @Override - public void run(Server server, User user, String commandLabel, String[] args) throws Exception + public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception { if (args.length < 1) { @@ -38,12 +38,12 @@ public class Commandext extends EssentialsCommand extinguishPlayers(server, user, commandLabel); } - private void extinguishPlayers(Server server, CommandSender sender, String name) throws Exception + private void extinguishPlayers(final Server server, final CommandSender sender, final String name) throws Exception { - for (Player p : server.matchPlayer(name)) + for (Player matchPlayer : server.matchPlayer(name)) { - p.setFireTicks(0); - sender.sendMessage(Util.format("extinguishOthers", p.getDisplayName())); + matchPlayer.setFireTicks(0); + sender.sendMessage(Util.format("extinguishOthers", matchPlayer.getDisplayName())); } } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandfireball.java b/Essentials/src/com/earth2me/essentials/commands/Commandfireball.java index 19e7eddf1..0dc78474b 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandfireball.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandfireball.java @@ -8,7 +8,6 @@ import org.bukkit.util.Vector; public class Commandfireball extends EssentialsCommand { - public Commandfireball() { super("fireball"); @@ -17,7 +16,7 @@ public class Commandfireball extends EssentialsCommand @Override protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception { - final Vector direction = user.getEyeLocation().getDirection().multiply(2); + final Vector direction = user.getEyeLocation().getDirection().multiply(2); user.getWorld().spawn(user.getEyeLocation().add(direction.getX(), direction.getY(), direction.getZ()), Fireball.class); } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandgc.java b/Essentials/src/com/earth2me/essentials/commands/Commandgc.java index 28164bd78..24de3b04c 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandgc.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandgc.java @@ -14,11 +14,12 @@ public class Commandgc extends EssentialsCommand } @Override - protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception + protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception { sender.sendMessage(Util.format("gcmax", (Runtime.getRuntime().maxMemory() / 1024 / 1024))); - sender.sendMessage(Util.format("gcfree", (Runtime.getRuntime().freeMemory() / 1024 / 1024))); sender.sendMessage(Util.format("gctotal", (Runtime.getRuntime().totalMemory() / 1024 / 1024))); + sender.sendMessage(Util.format("gcfree", (Runtime.getRuntime().freeMemory() / 1024 / 1024))); + for (World w : server.getWorlds()) { sender.sendMessage( diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandgetpos.java b/Essentials/src/com/earth2me/essentials/commands/Commandgetpos.java index 6f1fd7d6c..b8616e75f 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandgetpos.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandgetpos.java @@ -13,9 +13,9 @@ public class Commandgetpos extends EssentialsCommand } @Override - public void run(Server server, User user, String commandLabel, String[] args) throws Exception + public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception { - Location coords = user.getLocation(); + final Location coords = user.getLocation(); user.sendMessage("§7X: " + coords.getBlockX() + " (+East <-> -West)"); user.sendMessage("§7Y: " + coords.getBlockY() + " (+Up <-> -Down)"); user.sendMessage("§7Z: " + coords.getBlockZ() + " (+South <-> -North)"); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandgive.java b/Essentials/src/com/earth2me/essentials/commands/Commandgive.java index 065b76d03..32dbb9c70 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandgive.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandgive.java @@ -18,16 +18,16 @@ public class Commandgive extends EssentialsCommand //TODO: move these messages to message file @Override - public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception + public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception { if (args.length < 2) { throw new NotEnoughArgumentsException(); } - ItemStack stack = ess.getItemDb().get(args[1]); + final ItemStack stack = ess.getItemDb().get(args[1]); - String itemname = stack.getType().toString().toLowerCase().replace("_", ""); + final String itemname = stack.getType().toString().toLowerCase().replace("_", ""); if (sender instanceof Player && (ess.getSettings().permissionBasedItemSpawn() ? (!ess.getUser(sender).isAuthorized("essentials.give.item-all") @@ -48,8 +48,8 @@ public class Commandgive extends EssentialsCommand throw new Exception(ChatColor.RED + "You can't give air."); } - User giveTo = getPlayer(server, args, 0); - String itemName = stack.getType().toString().toLowerCase().replace('_', ' '); + final User giveTo = getPlayer(server, args, 0); + final String itemName = stack.getType().toString().toLowerCase().replace('_', ' '); sender.sendMessage(ChatColor.BLUE + "Giving " + stack.getAmount() + " of " + itemName + " to " + giveTo.getDisplayName() + "."); giveTo.getInventory().addItem(stack); giveTo.updateInventory(); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandgod.java b/Essentials/src/com/earth2me/essentials/commands/Commandgod.java index d4c35e113..67f8b4086 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandgod.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandgod.java @@ -15,7 +15,7 @@ public class Commandgod extends EssentialsCommand } @Override - protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception + protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception { if (args.length < 1) { @@ -26,7 +26,7 @@ public class Commandgod extends EssentialsCommand } @Override - protected void run(Server server, User user, String commandLabel, String[] args) throws Exception + protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception { if (args.length > 0 && user.isAuthorized("essentials.god.others")) { @@ -37,18 +37,18 @@ public class Commandgod extends EssentialsCommand user.sendMessage(Util.format("godMode", (user.toggleGodModeEnabled()? Util.i18n("enabled") : Util.i18n("disabled")))); } - private void godOtherPlayers(Server server, CommandSender sender, String name) + private void godOtherPlayers(final Server server, final CommandSender sender, final String name) { - for (Player p : server.matchPlayer(name)) + for (Player matchPlayer : server.matchPlayer(name)) { - User u = ess.getUser(p); - if (u.isHidden()) + final User player = ess.getUser(matchPlayer); + if (player.isHidden()) { continue; } - boolean enabled = u.toggleGodModeEnabled(); - u.sendMessage(Util.format("godMode", (enabled ? Util.i18n("enabled") : Util.i18n("disabled")))); - sender.sendMessage(Util.format("godMode",Util.format(enabled ? "godEnabledFor": "godDisabledFor", p.getDisplayName()))); + final boolean enabled = player.toggleGodModeEnabled(); + player.sendMessage(Util.format("godMode", (enabled ? Util.i18n("enabled") : Util.i18n("disabled")))); + sender.sendMessage(Util.format("godMode",Util.format(enabled ? "godEnabledFor": "godDisabledFor", matchPlayer.getDisplayName()))); } } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandheal.java b/Essentials/src/com/earth2me/essentials/commands/Commandheal.java index 68de488af..f805eacc3 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandheal.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandheal.java @@ -16,7 +16,7 @@ public class Commandheal extends EssentialsCommand } @Override - public void run(Server server, User user, String commandLabel, String[] args) throws Exception + public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception { if (args.length > 0 && user.isAuthorized("essentials.heal.others")) @@ -39,7 +39,7 @@ public class Commandheal extends EssentialsCommand } @Override - public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception + public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception { if (args.length < 1) { @@ -49,9 +49,9 @@ public class Commandheal extends EssentialsCommand healOtherPlayers(server, sender, args[0]); } - private void healOtherPlayers(Server server, CommandSender sender, String name) + private void healOtherPlayers(final Server server, final CommandSender sender, final String name) { - List<Player> players = server.matchPlayer(name); + final List<Player> players = server.matchPlayer(name); if (players.isEmpty()) { sender.sendMessage(Util.i18n("playerNotFound")); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandhelp.java b/Essentials/src/com/earth2me/essentials/commands/Commandhelp.java index 8e99dc1ed..36e2fc223 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandhelp.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandhelp.java @@ -30,6 +30,7 @@ public class Commandhelp extends EssentialsCommand super("help"); } + //TODO: Update to use new text file and command parser classes @Override protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandhelpop.java b/Essentials/src/com/earth2me/essentials/commands/Commandhelpop.java index 158b0d40b..51309e40f 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandhelpop.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandhelpop.java @@ -15,7 +15,7 @@ public class Commandhelpop extends EssentialsCommand } @Override - public void run(Server server, User user, String commandLabel, String[] args) throws Exception + public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception { if (args.length < 1) { @@ -24,14 +24,14 @@ public class Commandhelpop extends EssentialsCommand final String message = Util.format("helpOp", user.getDisplayName(), getFinalArg(args, 0)); logger.log(Level.INFO, message); - for (Player p : server.getOnlinePlayers()) + for (Player onlinePlayer : server.getOnlinePlayers()) { - User u = ess.getUser(p); - if (!u.isAuthorized("essentials.helpop.receive")) + final User player = ess.getUser(onlinePlayer); + if (!player.isAuthorized("essentials.helpop.receive")) { continue; } - u.sendMessage(message); + player.sendMessage(message); } } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandhome.java b/Essentials/src/com/earth2me/essentials/commands/Commandhome.java index 16b9fca2a..e3bc88c0f 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandhome.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandhome.java @@ -15,11 +15,11 @@ public class Commandhome extends EssentialsCommand } @Override - public void run(Server server, User user, String commandLabel, String[] args) throws Exception + public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception { - Trade charge = new Trade(this.getName(), ess); + final Trade charge = new Trade(this.getName(), ess); charge.isAffordableFor(user); - User u = user; + User player = user; String homeName = ""; String[] nameParts; if (args.length > 0) @@ -31,7 +31,7 @@ public class Commandhome extends EssentialsCommand } else { - u = getPlayer(server, nameParts[0].split(" "), 0, true); + player = getPlayer(server, nameParts[0].split(" "), 0, true); if (nameParts.length > 1) { homeName = nameParts[1]; @@ -40,22 +40,22 @@ public class Commandhome extends EssentialsCommand } try { - user.getTeleport().home(u, homeName.toLowerCase(), charge); + user.getTeleport().home(player, homeName.toLowerCase(), charge); } catch (NotEnoughArgumentsException e) { - List<String> homes = u.getHomes(); - if (homes.isEmpty() && u.equals(user) && ess.getSettings().spawnIfNoHome()) + final List<String> homes = player.getHomes(); + if (homes.isEmpty() && player.equals(user) && ess.getSettings().spawnIfNoHome()) { - user.getTeleport().respawn(ess.getSpawn(), charge); + user.getTeleport().respawn(ess.getSpawn(), charge); } else if (homes.isEmpty()) { - throw new Exception(u == user ? Util.i18n("noHomeSet") : Util.i18n("noHomeSetPlayer")); + throw new Exception(player == user ? Util.i18n("noHomeSet") : Util.i18n("noHomeSetPlayer")); } - else if (homes.size() == 1 && u.equals(user)) + else if (homes.size() == 1 && player.equals(user)) { - user.getTeleport().home(u, homes.get(0), charge); + user.getTeleport().home(player, homes.get(0), charge); } else { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandignore.java b/Essentials/src/com/earth2me/essentials/commands/Commandignore.java index 953bf742c..57c68105a 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandignore.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandignore.java @@ -14,36 +14,36 @@ public class Commandignore extends EssentialsCommand } @Override - protected void run(Server server, User user, String commandLabel, String[] args) throws Exception + protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception { if (args.length < 1) { throw new NotEnoughArgumentsException(); } - User u; + User player; try { - u = getPlayer(server, args, 0); + player = getPlayer(server, args, 0); } catch(NoSuchFieldException ex) { - u = ess.getOfflineUser(args[0]); + player = ess.getOfflineUser(args[0]); } - if (u == null) + if (player == null) { throw new Exception(Util.i18n("playerNotFound")); } - String name = u.getName(); + final String name = player.getName(); if (user.isIgnoredPlayer(name)) { user.setIgnoredPlayer(name, false); - user.sendMessage(Util.format("unignorePlayer", u.getName())); + user.sendMessage(Util.format("unignorePlayer", player.getName())); } else { user.setIgnoredPlayer(name, true); - user.sendMessage(Util.format("ignorePlayer", u.getName())); + user.sendMessage(Util.format("ignorePlayer", player.getName())); } } - - + + } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandinfo.java b/Essentials/src/com/earth2me/essentials/commands/Commandinfo.java index 05985e9d9..2ae348696 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandinfo.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandinfo.java @@ -16,7 +16,7 @@ public class Commandinfo extends EssentialsCommand } @Override - protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception + protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception { final IText input = new TextInput(sender, "info", true, ess); final IText output = new KeywordReplacer(input, sender, ess); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandinvsee.java b/Essentials/src/com/earth2me/essentials/commands/Commandinvsee.java index 2a730b533..c6b5c58a7 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandinvsee.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandinvsee.java @@ -15,7 +15,7 @@ public class Commandinvsee extends EssentialsCommand } @Override - protected void run(Server server, User user, String commandLabel, String[] args) throws Exception + protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception { if (args.length < 1 && user.getSavedInventory() == null) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commanditem.java b/Essentials/src/com/earth2me/essentials/commands/Commanditem.java index 352ce18eb..3d10ae198 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commanditem.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commanditem.java @@ -15,15 +15,15 @@ public class Commanditem extends EssentialsCommand } @Override - public void run(Server server, User user, String commandLabel, String[] args) throws Exception + public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception { if (args.length < 1) { throw new NotEnoughArgumentsException(); } - ItemStack stack = ess.getItemDb().get(args[0]); + final ItemStack stack = ess.getItemDb().get(args[0]); - String itemname = stack.getType().toString().toLowerCase().replace("_", ""); + final String itemname = stack.getType().toString().toLowerCase().replace("_", ""); if (ess.getSettings().permissionBasedItemSpawn() ? (!user.isAuthorized("essentials.itemspawn.item-all") && !user.isAuthorized("essentials.itemspawn.item-" + itemname) @@ -44,8 +44,8 @@ public class Commanditem extends EssentialsCommand throw new Exception(Util.format("cantSpawnItem", "Air")); } - String itemName = stack.getType().toString().toLowerCase().replace('_', ' '); - user.sendMessage(Util.format("itemSpawn", stack.getAmount(), itemName)); + final String displayName = stack.getType().toString().toLowerCase().replace('_', ' '); + user.sendMessage(Util.format("itemSpawn", stack.getAmount(), displayName)); user.getInventory().addItem(stack); user.updateInventory(); } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandjails.java b/Essentials/src/com/earth2me/essentials/commands/Commandjails.java index 36eb633fc..c5473e08d 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandjails.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandjails.java @@ -13,7 +13,7 @@ public class Commandjails extends EssentialsCommand } @Override - protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception + protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception { sender.sendMessage("§7" + Util.joinList(" ", ess.getJail().getJails())); } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandjump.java b/Essentials/src/com/earth2me/essentials/commands/Commandjump.java index 5cdcbb2f2..b7627f4bf 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandjump.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandjump.java @@ -15,11 +15,12 @@ public class Commandjump extends EssentialsCommand super("jump"); } + //TODO: Update to use new target methods @Override - public void run(Server server, User user, String commandLabel, String[] args) throws Exception + public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception { Location loc; - Location cloc = user.getLocation(); + final Location cloc = user.getLocation(); try { @@ -36,7 +37,7 @@ public class Commandjump extends EssentialsCommand throw new Exception(Util.i18n("jumpError"), ex); } - Trade charge = new Trade(this.getName(), ess); + final Trade charge = new Trade(this.getName(), ess); charge.isAffordableFor(user); user.getTeleport().teleport(loc, charge); } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandkick.java b/Essentials/src/com/earth2me/essentials/commands/Commandkick.java index fd0d4a8e0..039badc80 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandkick.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandkick.java @@ -14,30 +14,30 @@ public class Commandkick extends EssentialsCommand { super("kick"); } - + @Override - public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception + public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception { if (args.length < 1) { throw new NotEnoughArgumentsException(); } - - User player = getPlayer(server, args, 0); - if (player.isAuthorized("essentials.kick.exempt")) + + final User user = getPlayer(server, args, 0); + if (user.isAuthorized("essentials.kick.exempt")) { throw new Exception(Util.i18n("kickExempt")); } final String kickReason = args.length > 1 ? getFinalArg(args, 1) : Util.i18n("kickDefault"); - player.kickPlayer(kickReason); - String senderName = sender instanceof Player ? ((Player)sender).getDisplayName() : Console.NAME; - - for(Player p : server.getOnlinePlayers()) + user.kickPlayer(kickReason); + final String senderName = sender instanceof Player ? ((Player)sender).getDisplayName() : Console.NAME; + + for(Player onlinePlayer : server.getOnlinePlayers()) { - User u = ess.getUser(p); - if(u.isAuthorized("essentials.kick.notify")) + User player = ess.getUser(onlinePlayer); + if(player.isAuthorized("essentials.kick.notify")) { - p.sendMessage(Util.format("playerKicked", senderName, player.getName(), kickReason)); + onlinePlayer.sendMessage(Util.format("playerKicked", senderName, user.getName(), kickReason)); } } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandkickall.java b/Essentials/src/com/earth2me/essentials/commands/Commandkickall.java index 8d36f50d5..ac140840c 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandkickall.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandkickall.java @@ -14,17 +14,17 @@ public class Commandkickall extends EssentialsCommand } @Override - public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception + public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception { - for (Player p : server.getOnlinePlayers()) + for (Player onlinePlaer : server.getOnlinePlayers()) { - if (sender instanceof Player && p.getName().equalsIgnoreCase(((Player)sender).getName())) + if (sender instanceof Player && onlinePlaer.getName().equalsIgnoreCase(((Player)sender).getName())) { continue; } else { - p.kickPlayer(args.length > 0 ? getFinalArg(args, 0) : Util.i18n("kickDefault")); + onlinePlaer.kickPlayer(args.length > 0 ? getFinalArg(args, 0) : Util.i18n("kickDefault")); } } } |