summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKHobbits <rob@khobbits.co.uk>2011-11-18 19:30:05 +0000
committerKHobbits <rob@khobbits.co.uk>2011-11-18 22:09:26 +0000
commitcd9ea163e4864151df0360bb1c1a58101e706b1c (patch)
tree4145bc50bd3f3fd7d98961b8fbbe097fa05ca9a0
parentfc00ff471d0ff9d821d2ba70ef0137f31390294a (diff)
downloadEssentials-cd9ea163e4864151df0360bb1c1a58101e706b1c.tar
Essentials-cd9ea163e4864151df0360bb1c1a58101e706b1c.tar.gz
Essentials-cd9ea163e4864151df0360bb1c1a58101e706b1c.tar.lz
Essentials-cd9ea163e4864151df0360bb1c1a58101e706b1c.tar.xz
Essentials-cd9ea163e4864151df0360bb1c1a58101e706b1c.zip
Continuing code cleanup
-rw-r--r--Essentials/src/com/earth2me/essentials/UserData.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandinvsee.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java9
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandsudo.java6
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandsuicide.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandtempban.java24
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandthunder.java6
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandtime.java26
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandtogglejail.java60
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandtop.java8
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandtp.java24
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandtpa.java18
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandtpaall.java22
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandtpahere.java16
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandtpall.java16
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandtpdeny.java8
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandtphere.java12
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandtpo.java10
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandtpohere.java10
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandtppos.java18
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandtptoggle.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandtree.java6
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandunban.java4
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandunlimited.java32
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandwarp.java12
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandweather.java14
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandwhois.java40
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandworth.java43
28 files changed, 223 insertions, 229 deletions
diff --git a/Essentials/src/com/earth2me/essentials/UserData.java b/Essentials/src/com/earth2me/essentials/UserData.java
index 928fcb484..54bb31cdc 100644
--- a/Essentials/src/com/earth2me/essentials/UserData.java
+++ b/Essentials/src/com/earth2me/essentials/UserData.java
@@ -278,7 +278,7 @@ public abstract class UserData extends PlayerExtension implements IConf
public boolean hasPowerTools()
{
- return powertools.size() > 0;
+ return !powertools.isEmpty();
}
private Location lastLocation;
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandinvsee.java b/Essentials/src/com/earth2me/essentials/commands/Commandinvsee.java
index c6b5c58a7..0decb00bf 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandinvsee.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandinvsee.java
@@ -40,7 +40,7 @@ public class Commandinvsee extends EssentialsCommand
user.setSavedInventory(user.getInventory().getContents());
}
ItemStack[] invUserStack = invUser.getInventory().getContents();
- int userStackLength = user.getInventory().getContents().length;
+ final int userStackLength = user.getInventory().getContents().length;
if (invUserStack.length < userStackLength) {
invUserStack = Arrays.copyOf(invUserStack, userStackLength);
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java b/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java
index 7f62e7add..49f2a67d1 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java
@@ -67,12 +67,7 @@ public class Commandspawnmob extends EssentialsCommand
{
throw new Exception(Util.i18n("unableToSpawnMob"));
}
-
- int[] ignore =
- {
- 8, 9
- };
-
+
final Block block = Util.getTarget(user).getBlock();
if (block == null)
{
@@ -211,7 +206,7 @@ public class Commandspawnmob extends EssentialsCommand
}
if ("Wolf".equalsIgnoreCase(type) && data.equalsIgnoreCase("tamed"))
{
- Wolf wolf = ((Wolf)spawned);
+ final Wolf wolf = ((Wolf)spawned);
wolf.setTamed(true);
wolf.setOwner(user);
wolf.setSitting(true);
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandsudo.java b/Essentials/src/com/earth2me/essentials/commands/Commandsudo.java
index a7976e8a6..eb0934b6a 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandsudo.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandsudo.java
@@ -31,10 +31,10 @@ public class Commandsudo extends EssentialsCommand
//TODO: Translate this.
sender.sendMessage("Running the command as " + user.getDisplayName());
- final PluginCommand pc = ess.getServer().getPluginCommand(command);
- if (pc != null)
+ final PluginCommand execCommand = ess.getServer().getPluginCommand(command);
+ if (execCommand != null)
{
- pc.execute(user.getBase(), command, arguments);
+ execCommand.execute(user.getBase(), command, arguments);
}
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandsuicide.java b/Essentials/src/com/earth2me/essentials/commands/Commandsuicide.java
index 5db36161e..ec99dd712 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandsuicide.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandsuicide.java
@@ -13,7 +13,7 @@ public class Commandsuicide 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
{
user.setHealth(0);
user.sendMessage(Util.i18n("suicideMessage"));
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtempban.java b/Essentials/src/com/earth2me/essentials/commands/Commandtempban.java
index 4c877fe77..eaabdaa68 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandtempban.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandtempban.java
@@ -23,8 +23,8 @@ public class Commandtempban 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.tempban.offline"))
@@ -35,7 +35,7 @@ public class Commandtempban extends EssentialsCommand
}
else
{
- if (player.isAuthorized("essentials.tempban.exempt"))
+ if (user.isAuthorized("essentials.tempban.exempt"))
{
sender.sendMessage(Util.i18n("tempbanExempt"));
return;
@@ -45,18 +45,18 @@ public class Commandtempban extends EssentialsCommand
final long banTimestamp = Util.parseDateDiff(time, true);
final String banReason = Util.format("tempBanned", Util.formatDateDiff(banTimestamp));
- player.setBanReason(banReason);
- player.setBanTimeout(banTimestamp);
- player.setBanned(true);
- player.kickPlayer(banReason);
- String senderName = sender instanceof Player ? ((Player)sender).getDisplayName() : Console.NAME;
+ user.setBanReason(banReason);
+ user.setBanTimeout(banTimestamp);
+ user.setBanned(true);
+ user.kickPlayer(banReason);
+ final String senderName = sender instanceof Player ? ((Player)sender).getDisplayName() : Console.NAME;
- for(Player p : server.getOnlinePlayers())
+ 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/Commandthunder.java b/Essentials/src/com/earth2me/essentials/commands/Commandthunder.java
index 34f5c3fed..678eebafd 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandthunder.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandthunder.java
@@ -14,15 +14,15 @@ public class Commandthunder 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();
}
- World world = user.getWorld();
- boolean setThunder = args[0].equalsIgnoreCase("true");
+ final World world = user.getWorld();
+ final boolean setThunder = args[0].equalsIgnoreCase("true");
if (args.length > 1)
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtime.java b/Essentials/src/com/earth2me/essentials/commands/Commandtime.java
index 57ab8a6c6..30ecaaf54 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandtime.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandtime.java
@@ -58,11 +58,11 @@ public class Commandtime extends EssentialsCommand
/**
* Used to get the time and inform
*/
- private void getWorldsTime(CommandSender sender, Collection<World> worlds)
+ private void getWorldsTime(final CommandSender sender, final Collection<World> worlds)
{
if (worlds.size() == 1)
{
- Iterator<World> iter = worlds.iterator();
+ final Iterator<World> iter = worlds.iterator();
sender.sendMessage(DescParseTickFormat.format(iter.next().getTime()));
return;
}
@@ -76,7 +76,7 @@ public class Commandtime extends EssentialsCommand
/**
* Used to set the time and inform of the change
*/
- private void setWorldsTime(CommandSender sender, Collection<World> worlds, long ticks)
+ private void setWorldsTime(final CommandSender sender, final Collection<World> worlds, final long ticks)
{
// Update the time
for (World world : worlds)
@@ -86,31 +86,31 @@ public class Commandtime extends EssentialsCommand
world.setTime(time + 24000 + ticks);
}
- StringBuilder msg = new StringBuilder();
+ final StringBuilder output = new StringBuilder();
for (World world : worlds)
{
- if (msg.length() > 0)
+ if (output.length() > 0)
{
- msg.append(", ");
+ output.append(", ");
}
- msg.append(world.getName());
+ output.append(world.getName());
}
- sender.sendMessage(Util.format("timeWorldSet", DescParseTickFormat.format(ticks), msg.toString()));
+ sender.sendMessage(Util.format("timeWorldSet", DescParseTickFormat.format(ticks), output.toString()));
}
/**
* Used to parse an argument of the type "world(s) selector"
*/
- private Set<World> getWorlds(Server server, CommandSender sender, String selector) throws Exception
+ private Set<World> getWorlds(final Server server, final CommandSender sender, final String selector) throws Exception
{
- Set<World> worlds = new TreeSet<World>(new WorldNameComparator());
+ final Set<World> worlds = new TreeSet<World>(new WorldNameComparator());
// If there is no selector we want the world the user is currently in. Or all worlds if it isn't a user.
if (selector == null)
{
- User user = ess.getUser(sender);
+ final User user = ess.getUser(sender);
if (user == null)
{
worlds.addAll(server.getWorlds());
@@ -123,7 +123,7 @@ public class Commandtime extends EssentialsCommand
}
// Try to find the world with name = selector
- World world = server.getWorld(selector);
+ final World world = server.getWorld(selector);
if (world != null)
{
worlds.add(world);
@@ -147,7 +147,7 @@ public class Commandtime extends EssentialsCommand
class WorldNameComparator implements Comparator<World>
{
@Override
- public int compare(World a, World b)
+ public int compare(final World a, final World b)
{
return a.getName().compareTo(b.getName());
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtogglejail.java b/Essentials/src/com/earth2me/essentials/commands/Commandtogglejail.java
index f7cacb9f5..61edd2054 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandtogglejail.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandtogglejail.java
@@ -16,18 +16,18 @@ public class Commandtogglejail 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)
{
throw new NotEnoughArgumentsException();
}
- User p = getPlayer(server, args, 0, true);
+ final User player = getPlayer(server, args, 0, true);
- if (args.length >= 2 && !p.isJailed())
+ if (args.length >= 2 && !player.isJailed())
{
- if (p.getBase() instanceof OfflinePlayer)
+ if (player.getBase() instanceof OfflinePlayer)
{
if (sender instanceof Player
&& !ess.getUser(sender).isAuthorized("essentials.togglejail.offline"))
@@ -38,68 +38,68 @@ public class Commandtogglejail extends EssentialsCommand
}
else
{
- if (p.isAuthorized("essentials.jail.exempt"))
+ if (player.isAuthorized("essentials.jail.exempt"))
{
sender.sendMessage(Util.i18n("mayNotJail"));
return;
}
}
- if (!(p.getBase() instanceof OfflinePlayer))
+ if (!(player.getBase() instanceof OfflinePlayer))
{
- ess.getJail().sendToJail(p, args[1]);
+ ess.getJail().sendToJail(player, args[1]);
}
else
{
// Check if jail exists
ess.getJail().getJail(args[1]);
}
- p.setJailed(true);
- p.sendMessage(Util.i18n("userJailed"));
- p.setJail(null);
- p.setJail(args[1]);
+ player.setJailed(true);
+ player.sendMessage(Util.i18n("userJailed"));
+ player.setJail(null);
+ player.setJail(args[1]);
long timeDiff = 0;
if (args.length > 2)
{
- String time = getFinalArg(args, 2);
+ final String time = getFinalArg(args, 2);
timeDiff = Util.parseDateDiff(time, true);
- p.setJailTimeout(timeDiff);
+ player.setJailTimeout(timeDiff);
}
sender.sendMessage((timeDiff > 0
- ? Util.format("playerJailedFor", p.getName(), Util.formatDateDiff(timeDiff))
- : Util.format("playerJailed", p.getName())));
+ ? Util.format("playerJailedFor", player.getName(), Util.formatDateDiff(timeDiff))
+ : Util.format("playerJailed", player.getName())));
return;
}
- if (args.length >= 2 && p.isJailed() && !args[1].equalsIgnoreCase(p.getJail()))
+ if (args.length >= 2 && player.isJailed() && !args[1].equalsIgnoreCase(player.getJail()))
{
- sender.sendMessage(Util.format("jailAlreadyIncarcerated", p.getJail()));
+ sender.sendMessage(Util.format("jailAlreadyIncarcerated", player.getJail()));
return;
}
- if (args.length >= 2 && p.isJailed() && args[1].equalsIgnoreCase(p.getJail()))
+ if (args.length >= 2 && player.isJailed() && args[1].equalsIgnoreCase(player.getJail()))
{
- String time = getFinalArg(args, 2);
- long timeDiff = Util.parseDateDiff(time, true);
- p.setJailTimeout(timeDiff);
+ final String time = getFinalArg(args, 2);
+ final long timeDiff = Util.parseDateDiff(time, true);
+ player.setJailTimeout(timeDiff);
sender.sendMessage(Util.format("jailSentenceExtended", Util.formatDateDiff(timeDiff)));
return;
}
- if (args.length == 1 || (args.length == 2 && args[1].equalsIgnoreCase(p.getJail())))
+ if (args.length == 1 || (args.length == 2 && args[1].equalsIgnoreCase(player.getJail())))
{
- if (!p.isJailed())
+ if (!player.isJailed())
{
throw new NotEnoughArgumentsException();
}
- p.setJailed(false);
- p.setJailTimeout(0);
- p.sendMessage(Util.format("jailReleasedPlayerNotify"));
- p.setJail(null);
- if (!(p.getBase() instanceof OfflinePlayer))
+ player.setJailed(false);
+ player.setJailTimeout(0);
+ player.sendMessage(Util.format("jailReleasedPlayerNotify"));
+ player.setJail(null);
+ if (!(player.getBase() instanceof OfflinePlayer))
{
- p.getTeleport().back();
+ player.getTeleport().back();
}
- sender.sendMessage(Util.format("jailReleased", p.getName()));
+ sender.sendMessage(Util.format("jailReleased", player.getName()));
}
}
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtop.java b/Essentials/src/com/earth2me/essentials/commands/Commandtop.java
index 7967b72de..99f665184 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandtop.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandtop.java
@@ -15,11 +15,11 @@ public class Commandtop 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 topX = user.getLocation().getBlockX();
- int topZ = user.getLocation().getBlockZ();
- int topY = user.getWorld().getHighestBlockYAt(topX, topZ);
+ final int topX = user.getLocation().getBlockX();
+ final int topZ = user.getLocation().getBlockZ();
+ final int topY = user.getWorld().getHighestBlockYAt(topX, topZ);
user.getTeleport().teleport(new Location(user.getWorld(), user.getLocation().getX(), topY + 1, user.getLocation().getZ()), new Trade(this.getName(), ess));
user.sendMessage(Util.i18n("teleportTop"));
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtp.java b/Essentials/src/com/earth2me/essentials/commands/Commandtp.java
index 8ad8a217c..c93f05a29 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandtp.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandtp.java
@@ -16,7 +16,7 @@ public class Commandtp 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
{
switch (args.length)
{
@@ -24,25 +24,25 @@ public class Commandtp extends EssentialsCommand
throw new NotEnoughArgumentsException();
case 1:
- User p = getPlayer(server, args, 0);
- if (!p.isTeleportEnabled())
+ final User player = getPlayer(server, args, 0);
+ if (!player.isTeleportEnabled())
{
- throw new Exception(Util.format("teleportDisabled", p.getDisplayName()));
+ throw new Exception(Util.format("teleportDisabled", player.getDisplayName()));
}
user.sendMessage(Util.i18n("teleporting"));
- Trade charge = new Trade(this.getName(), ess);
+ final Trade charge = new Trade(this.getName(), ess);
charge.isAffordableFor(user);
- user.getTeleport().teleport(p, charge);
+ user.getTeleport().teleport(player, charge);
throw new NoChargeException();
- case 2:
+ default:
if (!user.isAuthorized("essentials.tpohere"))
{
throw new Exception("You need access to /tpohere to teleport other players.");
}
user.sendMessage(Util.i18n("teleporting"));
- User target = getPlayer(server, args, 0);
- User toPlayer = getPlayer(server, args, 1);
+ final User target = getPlayer(server, args, 0);
+ final User toPlayer = getPlayer(server, args, 1);
target.getTeleport().now(toPlayer, false);
target.sendMessage(Util.format("teleportAtoB", user.getDisplayName(), toPlayer.getDisplayName()));
break;
@@ -50,7 +50,7 @@ public class Commandtp 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)
{
@@ -58,8 +58,8 @@ public class Commandtp extends EssentialsCommand
}
sender.sendMessage(Util.i18n("teleporting"));
- User target = getPlayer(server, args, 0);
- User toPlayer = getPlayer(server, args, 1);
+ final User target = getPlayer(server, args, 0);
+ final User toPlayer = getPlayer(server, args, 1);
target.getTeleport().now(toPlayer, false);
target.sendMessage(Util.format("teleportAtoB", Console.NAME, toPlayer.getDisplayName()));
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtpa.java b/Essentials/src/com/earth2me/essentials/commands/Commandtpa.java
index 786b08629..c9f41f4d8 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandtpa.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandtpa.java
@@ -20,18 +20,18 @@ public class Commandtpa extends EssentialsCommand
throw new NotEnoughArgumentsException();
}
- User p = getPlayer(server, args, 0);
- if (!p.isTeleportEnabled())
+ User player = getPlayer(server, args, 0);
+ if (!player.isTeleportEnabled())
{
- throw new Exception(Util.format("teleportDisabled", p.getDisplayName()));
+ throw new Exception(Util.format("teleportDisabled", player.getDisplayName()));
}
- if (!p.isIgnoredPlayer(user.getName()))
+ if (!player.isIgnoredPlayer(user.getName()))
{
- p.requestTeleport(user, false);
- p.sendMessage(Util.format("teleportRequest", user.getDisplayName()));
- p.sendMessage(Util.i18n("typeTpaccept"));
- p.sendMessage(Util.i18n("typeTpdeny"));
+ player.requestTeleport(user, false);
+ player.sendMessage(Util.format("teleportRequest", user.getDisplayName()));
+ player.sendMessage(Util.i18n("typeTpaccept"));
+ player.sendMessage(Util.i18n("typeTpdeny"));
}
- user.sendMessage(Util.format("requestSent", p.getDisplayName()));
+ user.sendMessage(Util.format("requestSent", player.getDisplayName()));
}
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtpaall.java b/Essentials/src/com/earth2me/essentials/commands/Commandtpaall.java
index dd5696f00..59d66da3e 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandtpaall.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandtpaall.java
@@ -15,7 +15,7 @@ public class Commandtpaall 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)
{
@@ -27,29 +27,29 @@ public class Commandtpaall extends EssentialsCommand
throw new NotEnoughArgumentsException();
}
- User p = getPlayer(server, args, 0);
- teleportAAllPlayers(server, sender, p);
+ final User player = getPlayer(server, args, 0);
+ teleportAAllPlayers(server, sender, player);
}
- private void teleportAAllPlayers(Server server, CommandSender sender, User p)
+ private void teleportAAllPlayers(final Server server, final CommandSender sender, final User user)
{
sender.sendMessage(Util.i18n("teleportAAll"));
- for (Player player : server.getOnlinePlayers())
+ for (Player onlinePlayer : server.getOnlinePlayers())
{
- User u = ess.getUser(player);
- if (p == u)
+ final User player = ess.getUser(onlinePlayer);
+ if (user == player)
{
continue;
}
- if (!u.isTeleportEnabled())
+ if (!player.isTeleportEnabled())
{
continue;
}
try
{
- u.requestTeleport(p, true);
- u.sendMessage(Util.format("teleportHereRequest", p.getDisplayName()));
- u.sendMessage(Util.i18n("typeTpaccept"));
+ player.requestTeleport(user, true);
+ player.sendMessage(Util.format("teleportHereRequest", user.getDisplayName()));
+ player.sendMessage(Util.i18n("typeTpaccept"));
}
catch (Exception ex)
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtpahere.java b/Essentials/src/com/earth2me/essentials/commands/Commandtpahere.java
index d121094a8..3f120037b 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandtpahere.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandtpahere.java
@@ -13,21 +13,21 @@ public class Commandtpahere 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();
}
- User p = getPlayer(server, args, 0);
- if (!p.isTeleportEnabled())
+ final User player = getPlayer(server, args, 0);
+ if (!player.isTeleportEnabled())
{
- throw new Exception(Util.format("teleportDisabled", p.getDisplayName()));
+ throw new Exception(Util.format("teleportDisabled", player.getDisplayName()));
}
- p.requestTeleport(user, true);
- p.sendMessage(Util.format("teleportHereRequest", user.getDisplayName()));
- p.sendMessage(Util.i18n("typeTpaccept"));
- user.sendMessage(Util.format("requestSent", p.getDisplayName()));
+ player.requestTeleport(user, true);
+ player.sendMessage(Util.format("teleportHereRequest", user.getDisplayName()));
+ player.sendMessage(Util.i18n("typeTpaccept"));
+ user.sendMessage(Util.format("requestSent", player.getDisplayName()));
}
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtpall.java b/Essentials/src/com/earth2me/essentials/commands/Commandtpall.java
index b03c2d931..a9ccb91e3 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandtpall.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandtpall.java
@@ -15,7 +15,7 @@ public class Commandtpall 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)
{
@@ -27,23 +27,23 @@ public class Commandtpall extends EssentialsCommand
throw new NotEnoughArgumentsException();
}
- User p = getPlayer(server, args, 0);
- teleportAllPlayers(server, sender, p);
+ final User player = getPlayer(server, args, 0);
+ teleportAllPlayers(server, sender, player);
}
- private void teleportAllPlayers(Server server, CommandSender sender, User p)
+ private void teleportAllPlayers(Server server, CommandSender sender, User user)
{
sender.sendMessage(Util.i18n("teleportAll"));
- for (Player player : server.getOnlinePlayers())
+ for (Player onlinePlayer : server.getOnlinePlayers())
{
- User u = ess.getUser(player);
- if (p == u)
+ final User player = ess.getUser(onlinePlayer);
+ if (user == player)
{
continue;
}
try
{
- u.getTeleport().now(p, false);
+ player.getTeleport().now(user, false);
}
catch (Exception ex)
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtpdeny.java b/Essentials/src/com/earth2me/essentials/commands/Commandtpdeny.java
index 9ec54cd9b..b8de959ee 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandtpdeny.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandtpdeny.java
@@ -13,16 +13,16 @@ public class Commandtpdeny 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
{
- User p = user.getTeleportRequest();
- if (p == null)
+ final User player = user.getTeleportRequest();
+ if (player == null)
{
throw new Exception(Util.i18n("noPendingRequest"));
}
user.sendMessage(Util.i18n("requestDenied"));
- p.sendMessage(Util.format("requestDeniedFrom", user.getDisplayName()));
+ player.sendMessage(Util.format("requestDeniedFrom", user.getDisplayName()));
user.requestTeleport(null, false);
}
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtphere.java b/Essentials/src/com/earth2me/essentials/commands/Commandtphere.java
index 2d618b6d5..121e06c2a 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandtphere.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandtphere.java
@@ -14,16 +14,16 @@ public class Commandtphere 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
{
- User p = getPlayer(server, args, 0);
- if (!p.isTeleportEnabled())
+ final User player = getPlayer(server, args, 0);
+ if (!player.isTeleportEnabled())
{
- throw new Exception(Util.format("teleportDisabled", p.getDisplayName()));
+ throw new Exception(Util.format("teleportDisabled", player.getDisplayName()));
}
- p.getTeleport().teleport(user, new Trade(this.getName(), ess));
+ player.getTeleport().teleport(user, new Trade(this.getName(), ess));
user.sendMessage(Util.i18n("teleporting"));
- p.sendMessage(Util.i18n("teleporting"));
+ player.sendMessage(Util.i18n("teleporting"));
throw new NoChargeException();
}
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtpo.java b/Essentials/src/com/earth2me/essentials/commands/Commandtpo.java
index 540982e7f..2411bae6e 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandtpo.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandtpo.java
@@ -14,7 +14,7 @@ public class Commandtpo 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)
{
@@ -22,17 +22,17 @@ public class Commandtpo extends EssentialsCommand
}
//Just basically the old tp command
- User p = getPlayer(server, args, 0, true);
+ final User player = getPlayer(server, args, 0, true);
// Check if user is offline
- if (p.getBase() instanceof OfflinePlayer)
+ if (player.getBase() instanceof OfflinePlayer)
{
throw new NoSuchFieldException(Util.i18n("playerNotFound"));
}
// Verify permission
- if (!p.isHidden() || user.isAuthorized("essentials.teleport.hidden"))
+ if (!player.isHidden() || user.isAuthorized("essentials.teleport.hidden"))
{
- user.getTeleport().now(p, false);
+ user.getTeleport().now(player, false);
user.sendMessage(Util.i18n("teleporting"));
}
else
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtpohere.java b/Essentials/src/com/earth2me/essentials/commands/Commandtpohere.java
index 15a016aee..2e58ae3a0 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandtpohere.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandtpohere.java
@@ -14,7 +14,7 @@ public class Commandtpohere 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)
{
@@ -22,18 +22,18 @@ public class Commandtpohere extends EssentialsCommand
}
//Just basically the old tphere command
- User p = getPlayer(server, args, 0, true);
+ final User player = getPlayer(server, args, 0, true);
// Check if user is offline
- if (p.getBase() instanceof OfflinePlayer)
+ if (player.getBase() instanceof OfflinePlayer)
{
throw new NoSuchFieldException(Util.i18n("playerNotFound"));
}
// Verify permission
- if (!p.isHidden() || user.isAuthorized("essentials.teleport.hidden"))
+ if (!player.isHidden() || user.isAuthorized("essentials.teleport.hidden"))
{
- p.getTeleport().now(user, false);
+ player.getTeleport().now(user, false);
user.sendMessage(Util.i18n("teleporting"));
}
else
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtppos.java b/Essentials/src/com/earth2me/essentials/commands/Commandtppos.java
index 55517b9f7..5b2ee2890 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandtppos.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandtppos.java
@@ -15,27 +15,27 @@ public class Commandtppos 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 < 3)
{
throw new NotEnoughArgumentsException();
}
- int x = Integer.parseInt(args[0]);
- int y = Integer.parseInt(args[1]);
- int z = Integer.parseInt(args[2]);
- Location l = new Location(user.getWorld(), x, y, z);
+ final int x = Integer.parseInt(args[0]);
+ final int y = Integer.parseInt(args[1]);
+ final int z = Integer.parseInt(args[2]);
+ final Location location = new Location(user.getWorld(), x, y, z);
if (args.length > 3) {
- l.setYaw(Float.parseFloat(args[3]));
+ location.setYaw(Float.parseFloat(args[3]));
}
if (args.length > 4) {
- l.setPitch(Float.parseFloat(args[4]));
+ location.setPitch(Float.parseFloat(args[4]));
}
- Trade charge = new Trade(this.getName(), ess);
+ final Trade charge = new Trade(this.getName(), ess);
charge.isAffordableFor(user);
user.sendMessage(Util.i18n("teleporting"));
- user.getTeleport().teleport(l, charge);
+ user.getTeleport().teleport(location, charge);
throw new NoChargeException();
}
} \ No newline at end of file
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtptoggle.java b/Essentials/src/com/earth2me/essentials/commands/Commandtptoggle.java
index ad9b4231b..c42862514 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandtptoggle.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandtptoggle.java
@@ -13,7 +13,7 @@ public class Commandtptoggle 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
{
user.sendMessage(user.toggleTeleportEnabled()
? Util.i18n("teleportationEnabled")
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtree.java b/Essentials/src/com/earth2me/essentials/commands/Commandtree.java
index a7bd6d549..bec23d834 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandtree.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandtree.java
@@ -15,7 +15,7 @@ public class Commandtree 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 < 1)
@@ -39,10 +39,6 @@ public class Commandtree extends EssentialsCommand
throw new NotEnoughArgumentsException();
}
- final int[] ignore =
- {
- 8, 9
- };
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/Commandunban.java b/Essentials/src/com/earth2me/essentials/commands/Commandunban.java
index c36fde0e7..ac6818c80 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandunban.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandunban.java
@@ -23,8 +23,8 @@ public class Commandunban extends EssentialsCommand
try
{
- final User u = getPlayer(server, args, 0, true);
- u.setBanned(false);
+ final User player = getPlayer(server, args, 0, true);
+ player.setBanned(false);
sender.sendMessage(Util.i18n("unbannedPlayer"));
}
catch (NoSuchFieldException e)
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandunlimited.java b/Essentials/src/com/earth2me/essentials/commands/Commandunlimited.java
index cebbcaf8c..93e6235dc 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandunlimited.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandunlimited.java
@@ -17,7 +17,7 @@ public class Commandunlimited 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)
{
@@ -33,17 +33,17 @@ public class Commandunlimited extends EssentialsCommand
if (args[0].equalsIgnoreCase("list"))
{
- String list = getList(target);
+ final String list = getList(target);
user.sendMessage(list);
}
else if (args[0].equalsIgnoreCase("clear"))
{
- List<Integer> itemList = target.getUnlimited();
+ final List<Integer> itemList = target.getUnlimited();
int index = 0;
while (itemList.size() > index)
{
- Integer item = itemList.get(index);
+ final Integer item = itemList.get(index);
if (toggleUnlimited(user, target, item.toString()) == false)
{
index++;
@@ -56,36 +56,36 @@ public class Commandunlimited extends EssentialsCommand
}
}
- private String getList(User target)
+ private String getList(final User target)
{
- StringBuilder sb = new StringBuilder();
- sb.append(Util.i18n("unlimitedItems")).append(" ");
+ final StringBuilder output = new StringBuilder();
+ output.append(Util.i18n("unlimitedItems")).append(" ");
boolean first = true;
- List<Integer> items = target.getUnlimited();
+ final List<Integer> items = target.getUnlimited();
if (items.isEmpty())
{
- sb.append(Util.i18n("none"));
+ output.append(Util.i18n("none"));
}
for (Integer integer : items)
{
if (!first)
{
- sb.append(", ");
+ output.append(", ");
}
first = false;
- String matname = Material.getMaterial(integer).toString().toLowerCase().replace("_", "");
- sb.append(matname);
+ final String matname = Material.getMaterial(integer).toString().toLowerCase().replace("_", "");
+ output.append(matname);
}
- return sb.toString();
+ return output.toString();
}
- private Boolean toggleUnlimited(User user, User target, String item) throws Exception
+ private Boolean toggleUnlimited(final User user, final User target, final String item) throws Exception
{
- ItemStack stack = ess.getItemDb().get(item, 1);
+ final ItemStack stack = ess.getItemDb().get(item, 1);
stack.setAmount(Math.min(stack.getType().getMaxStackSize(), 2));
- String itemname = stack.getType().toString().toLowerCase().replace("_", "");
+ final String itemname = stack.getType().toString().toLowerCase().replace("_", "");
if (ess.getSettings().permissionBasedItemSpawn()
&& (!user.isAuthorized("essentials.unlimited.item-all")
&& !user.isAuthorized("essentials.unlimited.item-" + itemname)
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandwarp.java b/Essentials/src/com/earth2me/essentials/commands/Commandwarp.java
index dce5faf41..81207b740 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandwarp.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandwarp.java
@@ -21,7 +21,7 @@ public class Commandwarp 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 || args[0].matches("[0-9]+"))
{
@@ -51,7 +51,7 @@ public class Commandwarp 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 || args[0].matches("[0-9]+"))
{
@@ -68,9 +68,9 @@ public class Commandwarp extends EssentialsCommand
}
- private void warpList(CommandSender sender, String[] args) throws Exception
+ private void warpList(final CommandSender sender, final String[] args) throws Exception
{
- Warps warps = ess.getWarps();
+ final Warps warps = ess.getWarps();
if (warps.isEmpty())
{
throw new Exception(Util.i18n("noWarpsDefined"));
@@ -108,9 +108,9 @@ public class Commandwarp extends EssentialsCommand
}
}
- private void warpUser(User user, String name) throws Exception
+ private void warpUser(final User user, final String name) throws Exception
{
- Trade charge = new Trade(this.getName(), ess);
+ final Trade charge = new Trade(this.getName(), ess);
charge.isAffordableFor(user);
if (ess.getSettings().getPerWarpPermission())
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandweather.java b/Essentials/src/com/earth2me/essentials/commands/Commandweather.java
index b2b6cefa8..2af6f8abf 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandweather.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandweather.java
@@ -13,17 +13,19 @@ public class Commandweather extends EssentialsCommand
{
super("weather");
}
+
+ //TODO: Remove duplication
@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();
}
- boolean isStorm = args[0].equalsIgnoreCase("storm");
- World world = user.getWorld();
+ final boolean isStorm = args[0].equalsIgnoreCase("storm");
+ final World world = user.getWorld();
if (args.length > 1)
{
@@ -43,15 +45,15 @@ public class Commandweather 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) //running from console means inserting a world arg before other args
{
throw new Exception("When running from console, usage is: /" + commandLabel + " <world> <storm/sun> [duration]");
}
- boolean isStorm = args[1].equalsIgnoreCase("storm");
- World world = server.getWorld(args[0]);
+ final boolean isStorm = args[1].equalsIgnoreCase("storm");
+ final World world = server.getWorld(args[0]);
if (world == null)
{
throw new Exception("World named " + args[0] + " not found!");
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandwhois.java b/Essentials/src/com/earth2me/essentials/commands/Commandwhois.java
index d437682ee..b8081d04e 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandwhois.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandwhois.java
@@ -16,7 +16,7 @@ public class Commandwhois 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)
{
@@ -34,38 +34,38 @@ public class Commandwhois extends EssentialsCommand
{
showhidden = true;
}
- String whois = args[0].toLowerCase();
- int prefixLength = ChatColor.stripColor(ess.getSettings().getNicknamePrefix()).length();
- for (Player p : server.getOnlinePlayers())
+ final String whois = args[0].toLowerCase();
+ final int prefixLength = ChatColor.stripColor(ess.getSettings().getNicknamePrefix()).length();
+ for (Player onlinePlayer : server.getOnlinePlayers())
{
- User u = ess.getUser(p);
- if (u.isHidden() && !showhidden)
+ final User user = ess.getUser(onlinePlayer);
+ if (user.isHidden() && !showhidden)
{
continue;
}
- String dn = ChatColor.stripColor(u.getNick());
- if (!whois.equalsIgnoreCase(dn)
- && !whois.equalsIgnoreCase(dn.substring(prefixLength))
- && !whois.equalsIgnoreCase(u.getName()))
+ final String displayName = ChatColor.stripColor(user.getNick());
+ if (!whois.equalsIgnoreCase(displayName)
+ && !whois.equalsIgnoreCase(displayName.substring(prefixLength))
+ && !whois.equalsIgnoreCase(user.getName()))
{
continue;
}
sender.sendMessage("");
- sender.sendMessage(Util.format("whoisIs", u.getDisplayName(), u.getName()));
- sender.sendMessage(Util.format("whoisHealth", u.getHealth()));
- sender.sendMessage(Util.format("whoisOP", (u.isOp() ? Util.i18n("true") : Util.i18n("false"))));
- sender.sendMessage(Util.format("whoisGod", (u.isGodModeEnabled() ? Util.i18n("true") : Util.i18n("false"))));
- sender.sendMessage(Util.format("whoisGamemode", Util.i18n(u.getGameMode().toString().toLowerCase())));
- sender.sendMessage(Util.format("whoisLocation", u.getLocation().getWorld().getName(), u.getLocation().getBlockX(), u.getLocation().getBlockY(), u.getLocation().getBlockZ()));
+ sender.sendMessage(Util.format("whoisIs", user.getDisplayName(), user.getName()));
+ sender.sendMessage(Util.format("whoisHealth", user.getHealth()));
+ sender.sendMessage(Util.format("whoisOP", (user.isOp() ? Util.i18n("true") : Util.i18n("false"))));
+ sender.sendMessage(Util.format("whoisGod", (user.isGodModeEnabled() ? Util.i18n("true") : Util.i18n("false"))));
+ sender.sendMessage(Util.format("whoisGamemode", Util.i18n(user.getGameMode().toString().toLowerCase())));
+ sender.sendMessage(Util.format("whoisLocation", user.getLocation().getWorld().getName(), user.getLocation().getBlockX(), user.getLocation().getBlockY(), user.getLocation().getBlockZ()));
if (!ess.getSettings().isEcoDisabled())
{
- sender.sendMessage(Util.format("whoisMoney", Util.formatCurrency(u.getMoney(), ess)));
+ sender.sendMessage(Util.format("whoisMoney", Util.formatCurrency(user.getMoney(), ess)));
}
- sender.sendMessage(u.isAfk()
+ sender.sendMessage(user.isAfk()
? Util.i18n("whoisStatusAway")
: Util.i18n("whoisStatusAvailable"));
- sender.sendMessage(Util.format("whoisIPAddress", u.getAddress().getAddress().toString()));
- final String location = u.getGeoLocation();
+ sender.sendMessage(Util.format("whoisIPAddress", user.getAddress().getAddress().toString()));
+ final String location = user.getGeoLocation();
if (location != null
&& (sender instanceof Player ? ess.getUser(sender).isAuthorized("essentials.geoip.show") : true))
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandworth.java b/Essentials/src/com/earth2me/essentials/commands/Commandworth.java
index 0d6ee0e6f..d88fb4e68 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandworth.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandworth.java
@@ -15,15 +15,16 @@ public class Commandworth extends EssentialsCommand
super("worth");
}
+ //TODO: Remove duplication
@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
{
- ItemStack is = user.getInventory().getItemInHand();
- int amount = is.getAmount();
+ ItemStack iStack = user.getInventory().getItemInHand();
+ int amount = iStack.getAmount();
if (args.length > 0)
{
- is = ess.getItemDb().get(args[0]);
+ iStack = ess.getItemDb().get(args[0]);
}
try
@@ -35,40 +36,40 @@ public class Commandworth extends EssentialsCommand
}
catch (NumberFormatException ex)
{
- amount = is.getType().getMaxStackSize();
+ amount = iStack.getType().getMaxStackSize();
}
- is.setAmount(amount);
- double worth = ess.getWorth().getPrice(is);
+ iStack.setAmount(amount);
+ final double worth = ess.getWorth().getPrice(iStack);
if (Double.isNaN(worth))
{
throw new Exception(Util.i18n("itemCannotBeSold"));
}
- user.sendMessage(is.getDurability() != 0
+ user.sendMessage(iStack.getDurability() != 0
? Util.format("worthMeta",
- is.getType().toString().toLowerCase().replace("_", ""),
- is.getDurability(),
+ iStack.getType().toString().toLowerCase().replace("_", ""),
+ iStack.getDurability(),
Util.formatCurrency(worth * amount, ess),
amount,
Util.formatCurrency(worth, ess))
: Util.format("worth",
- is.getType().toString().toLowerCase().replace("_", ""),
+ iStack.getType().toString().toLowerCase().replace("_", ""),
Util.formatCurrency(worth * amount, ess),
amount,
Util.formatCurrency(worth, ess)));
}
@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();
}
- ItemStack is = ess.getItemDb().get(args[0]);
- int amount = is.getAmount();
+ ItemStack iStack = ess.getItemDb().get(args[0]);
+ int amount = iStack.getAmount();
try
{
@@ -79,25 +80,25 @@ public class Commandworth extends EssentialsCommand
}
catch (NumberFormatException ex)
{
- amount = is.getType().getMaxStackSize();
+ amount = iStack.getType().getMaxStackSize();
}
- is.setAmount(amount);
- double worth = ess.getWorth().getPrice(is);
+ iStack.setAmount(amount);
+ final double worth = ess.getWorth().getPrice(iStack);
if (Double.isNaN(worth))
{
throw new Exception(Util.i18n("itemCannotBeSold"));
}
- sender.sendMessage(is.getDurability() != 0
+ sender.sendMessage(iStack.getDurability() != 0
? Util.format("worthMeta",
- is.getType().toString().toLowerCase().replace("_", ""),
- is.getDurability(),
+ iStack.getType().toString().toLowerCase().replace("_", ""),
+ iStack.getDurability(),
Util.formatCurrency(worth * amount, ess),
amount,
Util.formatCurrency(worth, ess))
: Util.format("worth",
- is.getType().toString().toLowerCase().replace("_", ""),
+ iStack.getType().toString().toLowerCase().replace("_", ""),
Util.formatCurrency(worth * amount, ess),
amount,
Util.formatCurrency(worth, ess)));