mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-12-29 12:37:36 +01:00
Command cleanup
This commit is contained in:
parent
e5c77c1aeb
commit
e54d73704e
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
|
@ -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)));
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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"));
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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)));
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
@ -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));
|
||||
|
@ -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();
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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(
|
||||
|
@ -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)");
|
||||
|
@ -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();
|
||||
|
@ -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())));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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"));
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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()));
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user