Command cleanup

This commit is contained in:
KHobbits 2011-11-18 12:06:59 +00:00
parent e5c77c1aeb
commit e54d73704e
36 changed files with 165 additions and 162 deletions

View File

@ -4,6 +4,7 @@ import org.bukkit.Location;
import org.bukkit.Server; import org.bukkit.Server;
import com.earth2me.essentials.User; import com.earth2me.essentials.User;
import com.earth2me.essentials.TargetBlock; import com.earth2me.essentials.TargetBlock;
import com.earth2me.essentials.Util;
import org.bukkit.entity.TNTPrimed; 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, "...lobbest thou thy Holy Hand Grenade of Antioch towards thy foe,");
ess.broadcastMessage(user, "who being naughty in My sight, shall snuff it."); 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); loc.getWorld().spawn(loc, TNTPrimed.class);
} }
} }

View File

@ -14,9 +14,9 @@ public class Commandback extends EssentialsCommand
} }
@Override @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); charge.isAffordableFor(user);
user.sendMessage(Util.i18n("backUsageMsg")); user.sendMessage(Util.i18n("backUsageMsg"));
user.getTeleport().back(charge); user.getTeleport().back(charge);

View File

@ -14,9 +14,9 @@ public class Commandbackup extends EssentialsCommand
} }
@Override @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) if (backup == null)
{ {
throw new Exception(); throw new Exception();

View File

@ -14,7 +14,7 @@ public class Commandbalance extends EssentialsCommand
} }
@Override @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) if (args.length < 1)
{ {
@ -24,13 +24,13 @@ public class Commandbalance extends EssentialsCommand
} }
@Override @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 final double bal = (args.length < 1
|| !(user.isAuthorized("essentials.balance.others") || !(user.isAuthorized("essentials.balance.others")
|| user.isAuthorized("essentials.balance.other")) || user.isAuthorized("essentials.balance.other"))
? user ? user
: getPlayer(server, args, 0, true)).getMoney(); : getPlayer(server, args, 0, true)).getMoney();
user.sendMessage(Util.format("balance", Util.formatCurrency(bal, ess))); user.sendMessage(Util.format("balance", Util.formatCurrency(bal, ess)));
} }
} }

View File

@ -21,7 +21,7 @@ public class Commandbalancetop extends EssentialsCommand
} }
@Override @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; int max = 10;
if (args.length > 0) if (args.length > 0)

View File

@ -23,8 +23,8 @@ public class Commandban extends EssentialsCommand
{ {
throw new NotEnoughArgumentsException(); throw new NotEnoughArgumentsException();
} }
final User player = getPlayer(server, args, 0, true); final User user = getPlayer(server, args, 0, true);
if (player.getBase() instanceof OfflinePlayer) if (user.getBase() instanceof OfflinePlayer)
{ {
if (sender instanceof Player if (sender instanceof Player
&& !ess.getUser(sender).isAuthorized("essentials.ban.offline")) && !ess.getUser(sender).isAuthorized("essentials.ban.offline"))
@ -35,7 +35,7 @@ public class Commandban extends EssentialsCommand
} }
else else
{ {
if (player.isAuthorized("essentials.ban.exempt")) if (user.isAuthorized("essentials.ban.exempt"))
{ {
sender.sendMessage(Util.i18n("banExempt")); sender.sendMessage(Util.i18n("banExempt"));
return; return;
@ -46,22 +46,22 @@ public class Commandban extends EssentialsCommand
if (args.length > 1) if (args.length > 1)
{ {
banReason = getFinalArg(args, 1); banReason = getFinalArg(args, 1);
player.setBanReason(banReason); user.setBanReason(banReason);
} }
else else
{ {
banReason = Util.i18n("defaultBanReason"); banReason = Util.i18n("defaultBanReason");
} }
player.setBanned(true); user.setBanned(true);
player.kickPlayer(banReason); user.kickPlayer(banReason);
String senderName = sender instanceof Player ? ((Player)sender).getDisplayName() : Console.NAME; 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); final User player = ess.getUser(onlinePlayer);
if(u.isAuthorized("essentials.ban.notify")) if (player.isAuthorized("essentials.ban.notify"))
{ {
p.sendMessage(Util.format("playerBanned", senderName, player.getName(), banReason)); onlinePlayer.sendMessage(Util.format("playerBanned", senderName, user.getName(), banReason));
} }
} }
} }

View File

@ -21,21 +21,21 @@ public class Commandbanip extends EssentialsCommand
throw new NotEnoughArgumentsException(); 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]); ess.getServer().banIP(args[0]);
sender.sendMessage(Util.i18n("banIpAddress")); sender.sendMessage(Util.i18n("banIpAddress"));
} }
else else
{ {
final String ipAddress = u.getLastLoginAddress(); final String ipAddress = player.getLastLoginAddress();
if (ipAddress.length() == 0) if (ipAddress.length() == 0)
{ {
throw new Exception(Util.i18n("playerNotFound")); throw new Exception(Util.i18n("playerNotFound"));
} }
ess.getServer().banIP(u.getLastLoginAddress()); ess.getServer().banIP(player.getLastLoginAddress());
sender.sendMessage(Util.i18n("banIpAddress")); sender.sendMessage(Util.i18n("banIpAddress"));
} }
} }

View File

@ -15,7 +15,7 @@ public class Commandbigtree extends EssentialsCommand
} }
@Override @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; TreeType tree;
if (args.length > 0 && args[0].equalsIgnoreCase("redwood")) if (args.length > 0 && args[0].equalsIgnoreCase("redwood"))
@ -30,7 +30,7 @@ public class Commandbigtree extends EssentialsCommand
{ {
throw new NotEnoughArgumentsException(); throw new NotEnoughArgumentsException();
} }
final Location loc = Util.getTarget(user); final Location loc = Util.getTarget(user);
final Location safeLocation = Util.getSafeDestination(loc); final Location safeLocation = Util.getSafeDestination(loc);
final boolean success = user.getWorld().generateTree(safeLocation, tree); final boolean success = user.getWorld().generateTree(safeLocation, tree);

View File

@ -21,7 +21,6 @@ public class Commandbroadcast extends EssentialsCommand
throw new NotEnoughArgumentsException(); throw new NotEnoughArgumentsException();
} }
ess.broadcastMessage(null, ess.broadcastMessage(null, Util.format("broadcast", getFinalArg(args, 0)));
Util.format("broadcast", getFinalArg(args, 0)));
} }
} }

View File

@ -14,7 +14,7 @@ public class Commandburn extends EssentialsCommand
} }
@Override @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) if (args.length < 2)
{ {

View File

@ -15,6 +15,7 @@ public class Commandclearinventory extends EssentialsCommand
super("clearinventory"); super("clearinventory");
} }
//TODO: Cleanup
@Override @Override
public void run(Server server, User user, String commandLabel, String[] args) throws Exception public void run(Server server, User user, String commandLabel, String[] args) throws Exception
{ {

View File

@ -13,39 +13,39 @@ public class Commandcompass extends EssentialsCommand
} }
@Override @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; String dir;
if (r < 23) if (bearing < 23)
{ {
dir = "N"; dir = "N";
} }
else if (r < 68) else if (bearing < 68)
{ {
dir = "NE"; dir = "NE";
} }
else if (r < 113) else if (bearing < 113)
{ {
dir = "E"; dir = "E";
} }
else if (r < 158) else if (bearing < 158)
{ {
dir = "SE"; dir = "SE";
} }
else if (r < 203) else if (bearing < 203)
{ {
dir = "S"; dir = "S";
} }
else if (r < 248) else if (bearing < 248)
{ {
dir = "SW"; dir = "SW";
} }
else if (r < 293) else if (bearing < 293)
{ {
dir = "W"; dir = "W";
} }
else if (r < 338) else if (bearing < 338)
{ {
dir = "NW"; dir = "NW";
} }
@ -53,6 +53,6 @@ public class Commandcompass extends EssentialsCommand
{ {
dir = "N"; dir = "N";
} }
user.sendMessage(Util.format("compassBearing", dir, r)); user.sendMessage(Util.format("compassBearing", dir, bearing));
} }
} }

View File

@ -14,25 +14,21 @@ public class Commanddelhome extends EssentialsCommand
} }
@Override @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 //Allowing both formats /delhome khobbits house | /delhome khobbits:house
final String[] nameParts = args[0].split(":"); final String[] expandedArgs = args[0].split(":");
if (nameParts[0].length() != args[0].length())
{
args = nameParts;
}
User user = ess.getUser(sender); User user = ess.getUser(sender);
String name; String name;
if (args.length < 1) if (expandedArgs.length < 1)
{ {
throw new NotEnoughArgumentsException(); 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); user = getPlayer(server, expandedArgs, 0, true);
name = args[1]; name = expandedArgs[1];
} }
else else
{ {
@ -40,7 +36,7 @@ public class Commanddelhome extends EssentialsCommand
{ {
throw new NotEnoughArgumentsException(); throw new NotEnoughArgumentsException();
} }
name = args[0]; name = expandedArgs[0];
} }
user.delHome(name.toLowerCase()); user.delHome(name.toLowerCase());
sender.sendMessage(Util.format("deleteHome", name)); sender.sendMessage(Util.format("deleteHome", name));

View File

@ -4,14 +4,17 @@ import com.earth2me.essentials.Util;
import org.bukkit.Server; import org.bukkit.Server;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
public class Commanddeljail extends EssentialsCommand {
public Commanddeljail() { public class Commanddeljail extends EssentialsCommand
{
public Commanddeljail()
{
super("deljail"); super("deljail");
} }
@Override @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) if (args.length < 1)
{ {
throw new NotEnoughArgumentsException(); throw new NotEnoughArgumentsException();

View File

@ -13,7 +13,7 @@ public class Commanddelwarp extends EssentialsCommand
} }
@Override @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) if (args.length < 1)
{ {

View File

@ -13,16 +13,16 @@ public class Commanddepth extends EssentialsCommand
} }
@Override @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; final int depth = user.getLocation().getBlockY() - 63;
if (y > 0) 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 else
{ {

View File

@ -14,7 +14,7 @@ public class Commandeco extends EssentialsCommand
} }
@Override @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) if (args.length < 2)
{ {
@ -34,45 +34,46 @@ public class Commandeco extends EssentialsCommand
if (args[1].contentEquals("*")) 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) switch (cmd)
{ {
case GIVE: case GIVE:
u.giveMoney(amount); player.giveMoney(amount);
break; break;
case TAKE: case TAKE:
u.takeMoney(amount); player.takeMoney(amount);
break; break;
case RESET: case RESET:
u.setMoney(amount == 0 ? ess.getSettings().getStartingBalance() : amount); player.setMoney(amount == 0 ? ess.getSettings().getStartingBalance() : amount);
break; break;
} }
} }
} }
else else
{ {
User u = getPlayer(server, args, 1, true); final User player = getPlayer(server, args, 1, true);
switch (cmd) switch (cmd)
{ {
case GIVE: case GIVE:
u.giveMoney(amount, sender); player.giveMoney(amount, sender);
break; break;
case TAKE: case TAKE:
u.takeMoney(amount, sender); player.takeMoney(amount, sender);
break; break;
case RESET: case RESET:
u.setMoney(amount == 0 ? ess.getSettings().getStartingBalance() : amount); player.setMoney(amount == 0 ? ess.getSettings().getStartingBalance() : amount);
break; break;
} }
} }
} }
private enum EcoCommands private enum EcoCommands
{ {
GIVE, TAKE, RESET GIVE, TAKE, RESET

View File

@ -93,14 +93,14 @@ public class Commandessentials extends EssentialsCommand
return; return;
} }
Map<Player, Block> noteBlocks = Commandessentials.this.noteBlocks; 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) if (block == null || block.getType() != Material.NOTE_BLOCK)
{ {
continue; continue;
} }
player.playNote(block.getLocation(), (byte)0, noteMap.get(note)); onlinePlayer.playNote(block.getLocation(), (byte)0, noteMap.get(note));
} }
} }
}, 20, 2); }, 20, 2);

View File

@ -15,7 +15,7 @@ public class Commandext extends EssentialsCommand
} }
@Override @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) if (args.length < 1)
{ {
@ -26,7 +26,7 @@ public class Commandext extends EssentialsCommand
} }
@Override @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) if (args.length < 1)
{ {
@ -38,12 +38,12 @@ public class Commandext extends EssentialsCommand
extinguishPlayers(server, user, commandLabel); 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); matchPlayer.setFireTicks(0);
sender.sendMessage(Util.format("extinguishOthers", p.getDisplayName())); sender.sendMessage(Util.format("extinguishOthers", matchPlayer.getDisplayName()));
} }
} }
} }

View File

@ -8,7 +8,6 @@ import org.bukkit.util.Vector;
public class Commandfireball extends EssentialsCommand public class Commandfireball extends EssentialsCommand
{ {
public Commandfireball() public Commandfireball()
{ {
super("fireball"); super("fireball");
@ -17,7 +16,7 @@ public class Commandfireball extends EssentialsCommand
@Override @Override
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception 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); user.getWorld().spawn(user.getEyeLocation().add(direction.getX(), direction.getY(), direction.getZ()), Fireball.class);
} }
} }

View File

@ -14,11 +14,12 @@ public class Commandgc extends EssentialsCommand
} }
@Override @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("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("gctotal", (Runtime.getRuntime().totalMemory() / 1024 / 1024)));
sender.sendMessage(Util.format("gcfree", (Runtime.getRuntime().freeMemory() / 1024 / 1024)));
for (World w : server.getWorlds()) for (World w : server.getWorlds())
{ {
sender.sendMessage( sender.sendMessage(

View File

@ -13,9 +13,9 @@ public class Commandgetpos extends EssentialsCommand
} }
@Override @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("§7X: " + coords.getBlockX() + " (+East <-> -West)");
user.sendMessage("§7Y: " + coords.getBlockY() + " (+Up <-> -Down)"); user.sendMessage("§7Y: " + coords.getBlockY() + " (+Up <-> -Down)");
user.sendMessage("§7Z: " + coords.getBlockZ() + " (+South <-> -North)"); user.sendMessage("§7Z: " + coords.getBlockZ() + " (+South <-> -North)");

View File

@ -18,16 +18,16 @@ public class Commandgive extends EssentialsCommand
//TODO: move these messages to message file //TODO: move these messages to message file
@Override @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) if (args.length < 2)
{ {
throw new NotEnoughArgumentsException(); 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 if (sender instanceof Player
&& (ess.getSettings().permissionBasedItemSpawn() && (ess.getSettings().permissionBasedItemSpawn()
? (!ess.getUser(sender).isAuthorized("essentials.give.item-all") ? (!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."); throw new Exception(ChatColor.RED + "You can't give air.");
} }
User giveTo = getPlayer(server, args, 0); final User giveTo = getPlayer(server, args, 0);
String itemName = stack.getType().toString().toLowerCase().replace('_', ' '); final String itemName = stack.getType().toString().toLowerCase().replace('_', ' ');
sender.sendMessage(ChatColor.BLUE + "Giving " + stack.getAmount() + " of " + itemName + " to " + giveTo.getDisplayName() + "."); sender.sendMessage(ChatColor.BLUE + "Giving " + stack.getAmount() + " of " + itemName + " to " + giveTo.getDisplayName() + ".");
giveTo.getInventory().addItem(stack); giveTo.getInventory().addItem(stack);
giveTo.updateInventory(); giveTo.updateInventory();

View File

@ -15,7 +15,7 @@ public class Commandgod extends EssentialsCommand
} }
@Override @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) if (args.length < 1)
{ {
@ -26,7 +26,7 @@ public class Commandgod extends EssentialsCommand
} }
@Override @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")) 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")))); 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); final User player = ess.getUser(matchPlayer);
if (u.isHidden()) if (player.isHidden())
{ {
continue; continue;
} }
boolean enabled = u.toggleGodModeEnabled(); final boolean enabled = player.toggleGodModeEnabled();
u.sendMessage(Util.format("godMode", (enabled ? Util.i18n("enabled") : Util.i18n("disabled")))); player.sendMessage(Util.format("godMode", (enabled ? Util.i18n("enabled") : Util.i18n("disabled"))));
sender.sendMessage(Util.format("godMode",Util.format(enabled ? "godEnabledFor": "godDisabledFor", p.getDisplayName()))); sender.sendMessage(Util.format("godMode",Util.format(enabled ? "godEnabledFor": "godDisabledFor", matchPlayer.getDisplayName())));
} }
} }
} }

View File

@ -16,7 +16,7 @@ public class Commandheal extends EssentialsCommand
} }
@Override @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")) if (args.length > 0 && user.isAuthorized("essentials.heal.others"))
@ -39,7 +39,7 @@ public class Commandheal extends EssentialsCommand
} }
@Override @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) if (args.length < 1)
{ {
@ -49,9 +49,9 @@ public class Commandheal extends EssentialsCommand
healOtherPlayers(server, sender, args[0]); 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()) if (players.isEmpty())
{ {
sender.sendMessage(Util.i18n("playerNotFound")); sender.sendMessage(Util.i18n("playerNotFound"));

View File

@ -30,6 +30,7 @@ public class Commandhelp extends EssentialsCommand
super("help"); super("help");
} }
//TODO: Update to use new text file and command parser classes
@Override @Override
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
{ {

View File

@ -15,7 +15,7 @@ public class Commandhelpop extends EssentialsCommand
} }
@Override @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) if (args.length < 1)
{ {
@ -24,14 +24,14 @@ public class Commandhelpop extends EssentialsCommand
final String message = Util.format("helpOp", user.getDisplayName(), getFinalArg(args, 0)); final String message = Util.format("helpOp", user.getDisplayName(), getFinalArg(args, 0));
logger.log(Level.INFO, message); logger.log(Level.INFO, message);
for (Player p : server.getOnlinePlayers()) for (Player onlinePlayer : server.getOnlinePlayers())
{ {
User u = ess.getUser(p); final User player = ess.getUser(onlinePlayer);
if (!u.isAuthorized("essentials.helpop.receive")) if (!player.isAuthorized("essentials.helpop.receive"))
{ {
continue; continue;
} }
u.sendMessage(message); player.sendMessage(message);
} }
} }
} }

View File

@ -15,11 +15,11 @@ public class Commandhome extends EssentialsCommand
} }
@Override @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); charge.isAffordableFor(user);
User u = user; User player = user;
String homeName = ""; String homeName = "";
String[] nameParts; String[] nameParts;
if (args.length > 0) if (args.length > 0)
@ -31,7 +31,7 @@ public class Commandhome extends EssentialsCommand
} }
else else
{ {
u = getPlayer(server, nameParts[0].split(" "), 0, true); player = getPlayer(server, nameParts[0].split(" "), 0, true);
if (nameParts.length > 1) if (nameParts.length > 1)
{ {
homeName = nameParts[1]; homeName = nameParts[1];
@ -40,22 +40,22 @@ public class Commandhome extends EssentialsCommand
} }
try try
{ {
user.getTeleport().home(u, homeName.toLowerCase(), charge); user.getTeleport().home(player, homeName.toLowerCase(), charge);
} }
catch (NotEnoughArgumentsException e) catch (NotEnoughArgumentsException e)
{ {
List<String> homes = u.getHomes(); final List<String> homes = player.getHomes();
if (homes.isEmpty() && u.equals(user) && ess.getSettings().spawnIfNoHome()) 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()) 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 else
{ {

View File

@ -14,36 +14,36 @@ public class Commandignore extends EssentialsCommand
} }
@Override @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) if (args.length < 1)
{ {
throw new NotEnoughArgumentsException(); throw new NotEnoughArgumentsException();
} }
User u; User player;
try try
{ {
u = getPlayer(server, args, 0); player = getPlayer(server, args, 0);
} }
catch(NoSuchFieldException ex) 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")); throw new Exception(Util.i18n("playerNotFound"));
} }
String name = u.getName(); final String name = player.getName();
if (user.isIgnoredPlayer(name)) { if (user.isIgnoredPlayer(name)) {
user.setIgnoredPlayer(name, false); user.setIgnoredPlayer(name, false);
user.sendMessage(Util.format("unignorePlayer", u.getName())); user.sendMessage(Util.format("unignorePlayer", player.getName()));
} }
else else
{ {
user.setIgnoredPlayer(name, true); user.setIgnoredPlayer(name, true);
user.sendMessage(Util.format("ignorePlayer", u.getName())); user.sendMessage(Util.format("ignorePlayer", player.getName()));
} }
} }
} }

View File

@ -16,7 +16,7 @@ public class Commandinfo extends EssentialsCommand
} }
@Override @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 input = new TextInput(sender, "info", true, ess);
final IText output = new KeywordReplacer(input, sender, ess); final IText output = new KeywordReplacer(input, sender, ess);

View File

@ -15,7 +15,7 @@ public class Commandinvsee extends EssentialsCommand
} }
@Override @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) if (args.length < 1 && user.getSavedInventory() == null)

View File

@ -15,15 +15,15 @@ public class Commanditem extends EssentialsCommand
} }
@Override @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) if (args.length < 1)
{ {
throw new NotEnoughArgumentsException(); 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() if (ess.getSettings().permissionBasedItemSpawn()
? (!user.isAuthorized("essentials.itemspawn.item-all") ? (!user.isAuthorized("essentials.itemspawn.item-all")
&& !user.isAuthorized("essentials.itemspawn.item-" + itemname) && !user.isAuthorized("essentials.itemspawn.item-" + itemname)
@ -44,8 +44,8 @@ public class Commanditem extends EssentialsCommand
throw new Exception(Util.format("cantSpawnItem", "Air")); throw new Exception(Util.format("cantSpawnItem", "Air"));
} }
String itemName = stack.getType().toString().toLowerCase().replace('_', ' '); final String displayName = stack.getType().toString().toLowerCase().replace('_', ' ');
user.sendMessage(Util.format("itemSpawn", stack.getAmount(), itemName)); user.sendMessage(Util.format("itemSpawn", stack.getAmount(), displayName));
user.getInventory().addItem(stack); user.getInventory().addItem(stack);
user.updateInventory(); user.updateInventory();
} }

View File

@ -13,7 +13,7 @@ public class Commandjails extends EssentialsCommand
} }
@Override @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())); sender.sendMessage("§7" + Util.joinList(" ", ess.getJail().getJails()));
} }

View File

@ -15,11 +15,12 @@ public class Commandjump extends EssentialsCommand
super("jump"); super("jump");
} }
//TODO: Update to use new target methods
@Override @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 loc;
Location cloc = user.getLocation(); final Location cloc = user.getLocation();
try try
{ {
@ -36,7 +37,7 @@ public class Commandjump extends EssentialsCommand
throw new Exception(Util.i18n("jumpError"), ex); 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); charge.isAffordableFor(user);
user.getTeleport().teleport(loc, charge); user.getTeleport().teleport(loc, charge);
} }

View File

@ -14,30 +14,30 @@ public class Commandkick extends EssentialsCommand
{ {
super("kick"); super("kick");
} }
@Override @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) if (args.length < 1)
{ {
throw new NotEnoughArgumentsException(); throw new NotEnoughArgumentsException();
} }
User player = getPlayer(server, args, 0); final User user = getPlayer(server, args, 0);
if (player.isAuthorized("essentials.kick.exempt")) if (user.isAuthorized("essentials.kick.exempt"))
{ {
throw new Exception(Util.i18n("kickExempt")); throw new Exception(Util.i18n("kickExempt"));
} }
final String kickReason = args.length > 1 ? getFinalArg(args, 1) : Util.i18n("kickDefault"); final String kickReason = args.length > 1 ? getFinalArg(args, 1) : Util.i18n("kickDefault");
player.kickPlayer(kickReason); user.kickPlayer(kickReason);
String senderName = sender instanceof Player ? ((Player)sender).getDisplayName() : Console.NAME; 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); User player = ess.getUser(onlinePlayer);
if(u.isAuthorized("essentials.kick.notify")) if(player.isAuthorized("essentials.kick.notify"))
{ {
p.sendMessage(Util.format("playerKicked", senderName, player.getName(), kickReason)); onlinePlayer.sendMessage(Util.format("playerKicked", senderName, user.getName(), kickReason));
} }
} }
} }

View File

@ -14,17 +14,17 @@ public class Commandkickall extends EssentialsCommand
} }
@Override @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; continue;
} }
else else
{ {
p.kickPlayer(args.length > 0 ? getFinalArg(args, 0) : Util.i18n("kickDefault")); onlinePlaer.kickPlayer(args.length > 0 ? getFinalArg(args, 0) : Util.i18n("kickDefault"));
} }
} }
} }