mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-09-29 16:17:25 +02:00
Continuing code cleanup
This commit is contained in:
parent
fc00ff471d
commit
cd9ea163e4
@ -278,7 +278,7 @@ public abstract class UserData extends PlayerExtension implements IConf
|
|||||||
|
|
||||||
public boolean hasPowerTools()
|
public boolean hasPowerTools()
|
||||||
{
|
{
|
||||||
return powertools.size() > 0;
|
return !powertools.isEmpty();
|
||||||
}
|
}
|
||||||
private Location lastLocation;
|
private Location lastLocation;
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ public class Commandinvsee extends EssentialsCommand
|
|||||||
user.setSavedInventory(user.getInventory().getContents());
|
user.setSavedInventory(user.getInventory().getContents());
|
||||||
}
|
}
|
||||||
ItemStack[] invUserStack = invUser.getInventory().getContents();
|
ItemStack[] invUserStack = invUser.getInventory().getContents();
|
||||||
int userStackLength = user.getInventory().getContents().length;
|
final int userStackLength = user.getInventory().getContents().length;
|
||||||
if (invUserStack.length < userStackLength) {
|
if (invUserStack.length < userStackLength) {
|
||||||
invUserStack = Arrays.copyOf(invUserStack, userStackLength);
|
invUserStack = Arrays.copyOf(invUserStack, userStackLength);
|
||||||
}
|
}
|
||||||
|
@ -67,12 +67,7 @@ public class Commandspawnmob extends EssentialsCommand
|
|||||||
{
|
{
|
||||||
throw new Exception(Util.i18n("unableToSpawnMob"));
|
throw new Exception(Util.i18n("unableToSpawnMob"));
|
||||||
}
|
}
|
||||||
|
|
||||||
int[] ignore =
|
|
||||||
{
|
|
||||||
8, 9
|
|
||||||
};
|
|
||||||
|
|
||||||
final Block block = Util.getTarget(user).getBlock();
|
final Block block = Util.getTarget(user).getBlock();
|
||||||
if (block == null)
|
if (block == null)
|
||||||
{
|
{
|
||||||
@ -211,7 +206,7 @@ public class Commandspawnmob extends EssentialsCommand
|
|||||||
}
|
}
|
||||||
if ("Wolf".equalsIgnoreCase(type) && data.equalsIgnoreCase("tamed"))
|
if ("Wolf".equalsIgnoreCase(type) && data.equalsIgnoreCase("tamed"))
|
||||||
{
|
{
|
||||||
Wolf wolf = ((Wolf)spawned);
|
final Wolf wolf = ((Wolf)spawned);
|
||||||
wolf.setTamed(true);
|
wolf.setTamed(true);
|
||||||
wolf.setOwner(user);
|
wolf.setOwner(user);
|
||||||
wolf.setSitting(true);
|
wolf.setSitting(true);
|
||||||
|
@ -31,10 +31,10 @@ public class Commandsudo extends EssentialsCommand
|
|||||||
//TODO: Translate this.
|
//TODO: Translate this.
|
||||||
sender.sendMessage("Running the command as " + user.getDisplayName());
|
sender.sendMessage("Running the command as " + user.getDisplayName());
|
||||||
|
|
||||||
final PluginCommand pc = ess.getServer().getPluginCommand(command);
|
final PluginCommand execCommand = ess.getServer().getPluginCommand(command);
|
||||||
if (pc != null)
|
if (execCommand != null)
|
||||||
{
|
{
|
||||||
pc.execute(user.getBase(), command, arguments);
|
execCommand.execute(user.getBase(), command, arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ public class Commandsuicide 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
|
||||||
{
|
{
|
||||||
user.setHealth(0);
|
user.setHealth(0);
|
||||||
user.sendMessage(Util.i18n("suicideMessage"));
|
user.sendMessage(Util.i18n("suicideMessage"));
|
||||||
|
@ -23,8 +23,8 @@ public class Commandtempban 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.tempban.offline"))
|
&& !ess.getUser(sender).isAuthorized("essentials.tempban.offline"))
|
||||||
@ -35,7 +35,7 @@ public class Commandtempban extends EssentialsCommand
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (player.isAuthorized("essentials.tempban.exempt"))
|
if (user.isAuthorized("essentials.tempban.exempt"))
|
||||||
{
|
{
|
||||||
sender.sendMessage(Util.i18n("tempbanExempt"));
|
sender.sendMessage(Util.i18n("tempbanExempt"));
|
||||||
return;
|
return;
|
||||||
@ -45,18 +45,18 @@ public class Commandtempban extends EssentialsCommand
|
|||||||
final long banTimestamp = Util.parseDateDiff(time, true);
|
final long banTimestamp = Util.parseDateDiff(time, true);
|
||||||
|
|
||||||
final String banReason = Util.format("tempBanned", Util.formatDateDiff(banTimestamp));
|
final String banReason = Util.format("tempBanned", Util.formatDateDiff(banTimestamp));
|
||||||
player.setBanReason(banReason);
|
user.setBanReason(banReason);
|
||||||
player.setBanTimeout(banTimestamp);
|
user.setBanTimeout(banTimestamp);
|
||||||
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,15 +14,15 @@ public class Commandthunder 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();
|
||||||
}
|
}
|
||||||
|
|
||||||
World world = user.getWorld();
|
final World world = user.getWorld();
|
||||||
boolean setThunder = args[0].equalsIgnoreCase("true");
|
final boolean setThunder = args[0].equalsIgnoreCase("true");
|
||||||
if (args.length > 1)
|
if (args.length > 1)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -58,11 +58,11 @@ public class Commandtime extends EssentialsCommand
|
|||||||
/**
|
/**
|
||||||
* Used to get the time and inform
|
* 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)
|
if (worlds.size() == 1)
|
||||||
{
|
{
|
||||||
Iterator<World> iter = worlds.iterator();
|
final Iterator<World> iter = worlds.iterator();
|
||||||
sender.sendMessage(DescParseTickFormat.format(iter.next().getTime()));
|
sender.sendMessage(DescParseTickFormat.format(iter.next().getTime()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -76,7 +76,7 @@ public class Commandtime extends EssentialsCommand
|
|||||||
/**
|
/**
|
||||||
* Used to set the time and inform of the change
|
* 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
|
// Update the time
|
||||||
for (World world : worlds)
|
for (World world : worlds)
|
||||||
@ -86,31 +86,31 @@ public class Commandtime extends EssentialsCommand
|
|||||||
world.setTime(time + 24000 + ticks);
|
world.setTime(time + 24000 + ticks);
|
||||||
}
|
}
|
||||||
|
|
||||||
StringBuilder msg = new StringBuilder();
|
final StringBuilder output = new StringBuilder();
|
||||||
for (World world : worlds)
|
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"
|
* 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 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)
|
if (selector == null)
|
||||||
{
|
{
|
||||||
User user = ess.getUser(sender);
|
final User user = ess.getUser(sender);
|
||||||
if (user == null)
|
if (user == null)
|
||||||
{
|
{
|
||||||
worlds.addAll(server.getWorlds());
|
worlds.addAll(server.getWorlds());
|
||||||
@ -123,7 +123,7 @@ public class Commandtime extends EssentialsCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Try to find the world with name = selector
|
// Try to find the world with name = selector
|
||||||
World world = server.getWorld(selector);
|
final World world = server.getWorld(selector);
|
||||||
if (world != null)
|
if (world != null)
|
||||||
{
|
{
|
||||||
worlds.add(world);
|
worlds.add(world);
|
||||||
@ -147,7 +147,7 @@ public class Commandtime extends EssentialsCommand
|
|||||||
class WorldNameComparator implements Comparator<World>
|
class WorldNameComparator implements Comparator<World>
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public int compare(World a, World b)
|
public int compare(final World a, final World b)
|
||||||
{
|
{
|
||||||
return a.getName().compareTo(b.getName());
|
return a.getName().compareTo(b.getName());
|
||||||
}
|
}
|
||||||
|
@ -16,18 +16,18 @@ public class Commandtogglejail 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)
|
||||||
{
|
{
|
||||||
throw new NotEnoughArgumentsException();
|
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
|
if (sender instanceof Player
|
||||||
&& !ess.getUser(sender).isAuthorized("essentials.togglejail.offline"))
|
&& !ess.getUser(sender).isAuthorized("essentials.togglejail.offline"))
|
||||||
@ -38,68 +38,68 @@ public class Commandtogglejail extends EssentialsCommand
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (p.isAuthorized("essentials.jail.exempt"))
|
if (player.isAuthorized("essentials.jail.exempt"))
|
||||||
{
|
{
|
||||||
sender.sendMessage(Util.i18n("mayNotJail"));
|
sender.sendMessage(Util.i18n("mayNotJail"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!(p.getBase() instanceof OfflinePlayer))
|
if (!(player.getBase() instanceof OfflinePlayer))
|
||||||
{
|
{
|
||||||
ess.getJail().sendToJail(p, args[1]);
|
ess.getJail().sendToJail(player, args[1]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Check if jail exists
|
// Check if jail exists
|
||||||
ess.getJail().getJail(args[1]);
|
ess.getJail().getJail(args[1]);
|
||||||
}
|
}
|
||||||
p.setJailed(true);
|
player.setJailed(true);
|
||||||
p.sendMessage(Util.i18n("userJailed"));
|
player.sendMessage(Util.i18n("userJailed"));
|
||||||
p.setJail(null);
|
player.setJail(null);
|
||||||
p.setJail(args[1]);
|
player.setJail(args[1]);
|
||||||
long timeDiff = 0;
|
long timeDiff = 0;
|
||||||
if (args.length > 2)
|
if (args.length > 2)
|
||||||
{
|
{
|
||||||
String time = getFinalArg(args, 2);
|
final String time = getFinalArg(args, 2);
|
||||||
timeDiff = Util.parseDateDiff(time, true);
|
timeDiff = Util.parseDateDiff(time, true);
|
||||||
p.setJailTimeout(timeDiff);
|
player.setJailTimeout(timeDiff);
|
||||||
}
|
}
|
||||||
sender.sendMessage((timeDiff > 0
|
sender.sendMessage((timeDiff > 0
|
||||||
? Util.format("playerJailedFor", p.getName(), Util.formatDateDiff(timeDiff))
|
? Util.format("playerJailedFor", player.getName(), Util.formatDateDiff(timeDiff))
|
||||||
: Util.format("playerJailed", p.getName())));
|
: Util.format("playerJailed", player.getName())));
|
||||||
return;
|
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;
|
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);
|
final String time = getFinalArg(args, 2);
|
||||||
long timeDiff = Util.parseDateDiff(time, true);
|
final long timeDiff = Util.parseDateDiff(time, true);
|
||||||
p.setJailTimeout(timeDiff);
|
player.setJailTimeout(timeDiff);
|
||||||
sender.sendMessage(Util.format("jailSentenceExtended", Util.formatDateDiff(timeDiff)));
|
sender.sendMessage(Util.format("jailSentenceExtended", Util.formatDateDiff(timeDiff)));
|
||||||
return;
|
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();
|
throw new NotEnoughArgumentsException();
|
||||||
}
|
}
|
||||||
p.setJailed(false);
|
player.setJailed(false);
|
||||||
p.setJailTimeout(0);
|
player.setJailTimeout(0);
|
||||||
p.sendMessage(Util.format("jailReleasedPlayerNotify"));
|
player.sendMessage(Util.format("jailReleasedPlayerNotify"));
|
||||||
p.setJail(null);
|
player.setJail(null);
|
||||||
if (!(p.getBase() instanceof OfflinePlayer))
|
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()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,11 +15,11 @@ public class Commandtop 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 topX = user.getLocation().getBlockX();
|
final int topX = user.getLocation().getBlockX();
|
||||||
int topZ = user.getLocation().getBlockZ();
|
final int topZ = user.getLocation().getBlockZ();
|
||||||
int topY = user.getWorld().getHighestBlockYAt(topX, topZ);
|
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.getTeleport().teleport(new Location(user.getWorld(), user.getLocation().getX(), topY + 1, user.getLocation().getZ()), new Trade(this.getName(), ess));
|
||||||
user.sendMessage(Util.i18n("teleportTop"));
|
user.sendMessage(Util.i18n("teleportTop"));
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ public class Commandtp 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
|
||||||
{
|
{
|
||||||
switch (args.length)
|
switch (args.length)
|
||||||
{
|
{
|
||||||
@ -24,25 +24,25 @@ public class Commandtp extends EssentialsCommand
|
|||||||
throw new NotEnoughArgumentsException();
|
throw new NotEnoughArgumentsException();
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
User p = getPlayer(server, args, 0);
|
final User player = getPlayer(server, args, 0);
|
||||||
if (!p.isTeleportEnabled())
|
if (!player.isTeleportEnabled())
|
||||||
{
|
{
|
||||||
throw new Exception(Util.format("teleportDisabled", p.getDisplayName()));
|
throw new Exception(Util.format("teleportDisabled", player.getDisplayName()));
|
||||||
}
|
}
|
||||||
user.sendMessage(Util.i18n("teleporting"));
|
user.sendMessage(Util.i18n("teleporting"));
|
||||||
Trade charge = new Trade(this.getName(), ess);
|
final Trade charge = new Trade(this.getName(), ess);
|
||||||
charge.isAffordableFor(user);
|
charge.isAffordableFor(user);
|
||||||
user.getTeleport().teleport(p, charge);
|
user.getTeleport().teleport(player, charge);
|
||||||
throw new NoChargeException();
|
throw new NoChargeException();
|
||||||
|
|
||||||
case 2:
|
default:
|
||||||
if (!user.isAuthorized("essentials.tpohere"))
|
if (!user.isAuthorized("essentials.tpohere"))
|
||||||
{
|
{
|
||||||
throw new Exception("You need access to /tpohere to teleport other players.");
|
throw new Exception("You need access to /tpohere to teleport other players.");
|
||||||
}
|
}
|
||||||
user.sendMessage(Util.i18n("teleporting"));
|
user.sendMessage(Util.i18n("teleporting"));
|
||||||
User target = getPlayer(server, args, 0);
|
final User target = getPlayer(server, args, 0);
|
||||||
User toPlayer = getPlayer(server, args, 1);
|
final User toPlayer = getPlayer(server, args, 1);
|
||||||
target.getTeleport().now(toPlayer, false);
|
target.getTeleport().now(toPlayer, false);
|
||||||
target.sendMessage(Util.format("teleportAtoB", user.getDisplayName(), toPlayer.getDisplayName()));
|
target.sendMessage(Util.format("teleportAtoB", user.getDisplayName(), toPlayer.getDisplayName()));
|
||||||
break;
|
break;
|
||||||
@ -50,7 +50,7 @@ public class Commandtp 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)
|
||||||
{
|
{
|
||||||
@ -58,8 +58,8 @@ public class Commandtp extends EssentialsCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
sender.sendMessage(Util.i18n("teleporting"));
|
sender.sendMessage(Util.i18n("teleporting"));
|
||||||
User target = getPlayer(server, args, 0);
|
final User target = getPlayer(server, args, 0);
|
||||||
User toPlayer = getPlayer(server, args, 1);
|
final User toPlayer = getPlayer(server, args, 1);
|
||||||
target.getTeleport().now(toPlayer, false);
|
target.getTeleport().now(toPlayer, false);
|
||||||
target.sendMessage(Util.format("teleportAtoB", Console.NAME, toPlayer.getDisplayName()));
|
target.sendMessage(Util.format("teleportAtoB", Console.NAME, toPlayer.getDisplayName()));
|
||||||
}
|
}
|
||||||
|
@ -20,18 +20,18 @@ public class Commandtpa extends EssentialsCommand
|
|||||||
throw new NotEnoughArgumentsException();
|
throw new NotEnoughArgumentsException();
|
||||||
}
|
}
|
||||||
|
|
||||||
User p = getPlayer(server, args, 0);
|
User player = getPlayer(server, args, 0);
|
||||||
if (!p.isTeleportEnabled())
|
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);
|
player.requestTeleport(user, false);
|
||||||
p.sendMessage(Util.format("teleportRequest", user.getDisplayName()));
|
player.sendMessage(Util.format("teleportRequest", user.getDisplayName()));
|
||||||
p.sendMessage(Util.i18n("typeTpaccept"));
|
player.sendMessage(Util.i18n("typeTpaccept"));
|
||||||
p.sendMessage(Util.i18n("typeTpdeny"));
|
player.sendMessage(Util.i18n("typeTpdeny"));
|
||||||
}
|
}
|
||||||
user.sendMessage(Util.format("requestSent", p.getDisplayName()));
|
user.sendMessage(Util.format("requestSent", player.getDisplayName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ public class Commandtpaall 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)
|
||||||
{
|
{
|
||||||
@ -27,29 +27,29 @@ public class Commandtpaall extends EssentialsCommand
|
|||||||
throw new NotEnoughArgumentsException();
|
throw new NotEnoughArgumentsException();
|
||||||
}
|
}
|
||||||
|
|
||||||
User p = getPlayer(server, args, 0);
|
final User player = getPlayer(server, args, 0);
|
||||||
teleportAAllPlayers(server, sender, p);
|
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"));
|
sender.sendMessage(Util.i18n("teleportAAll"));
|
||||||
for (Player player : server.getOnlinePlayers())
|
for (Player onlinePlayer : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
User u = ess.getUser(player);
|
final User player = ess.getUser(onlinePlayer);
|
||||||
if (p == u)
|
if (user == player)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!u.isTeleportEnabled())
|
if (!player.isTeleportEnabled())
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
u.requestTeleport(p, true);
|
player.requestTeleport(user, true);
|
||||||
u.sendMessage(Util.format("teleportHereRequest", p.getDisplayName()));
|
player.sendMessage(Util.format("teleportHereRequest", user.getDisplayName()));
|
||||||
u.sendMessage(Util.i18n("typeTpaccept"));
|
player.sendMessage(Util.i18n("typeTpaccept"));
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
@ -13,21 +13,21 @@ public class Commandtpahere 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();
|
||||||
}
|
}
|
||||||
|
|
||||||
User p = getPlayer(server, args, 0);
|
final User player = getPlayer(server, args, 0);
|
||||||
if (!p.isTeleportEnabled())
|
if (!player.isTeleportEnabled())
|
||||||
{
|
{
|
||||||
throw new Exception(Util.format("teleportDisabled", p.getDisplayName()));
|
throw new Exception(Util.format("teleportDisabled", player.getDisplayName()));
|
||||||
}
|
}
|
||||||
p.requestTeleport(user, true);
|
player.requestTeleport(user, true);
|
||||||
p.sendMessage(Util.format("teleportHereRequest", user.getDisplayName()));
|
player.sendMessage(Util.format("teleportHereRequest", user.getDisplayName()));
|
||||||
p.sendMessage(Util.i18n("typeTpaccept"));
|
player.sendMessage(Util.i18n("typeTpaccept"));
|
||||||
user.sendMessage(Util.format("requestSent", p.getDisplayName()));
|
user.sendMessage(Util.format("requestSent", player.getDisplayName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ public class Commandtpall 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)
|
||||||
{
|
{
|
||||||
@ -27,23 +27,23 @@ public class Commandtpall extends EssentialsCommand
|
|||||||
throw new NotEnoughArgumentsException();
|
throw new NotEnoughArgumentsException();
|
||||||
}
|
}
|
||||||
|
|
||||||
User p = getPlayer(server, args, 0);
|
final User player = getPlayer(server, args, 0);
|
||||||
teleportAllPlayers(server, sender, p);
|
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"));
|
sender.sendMessage(Util.i18n("teleportAll"));
|
||||||
for (Player player : server.getOnlinePlayers())
|
for (Player onlinePlayer : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
User u = ess.getUser(player);
|
final User player = ess.getUser(onlinePlayer);
|
||||||
if (p == u)
|
if (user == player)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
u.getTeleport().now(p, false);
|
player.getTeleport().now(user, false);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
@ -13,16 +13,16 @@ public class Commandtpdeny 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
|
||||||
{
|
{
|
||||||
User p = user.getTeleportRequest();
|
final User player = user.getTeleportRequest();
|
||||||
if (p == null)
|
if (player == null)
|
||||||
{
|
{
|
||||||
throw new Exception(Util.i18n("noPendingRequest"));
|
throw new Exception(Util.i18n("noPendingRequest"));
|
||||||
}
|
}
|
||||||
|
|
||||||
user.sendMessage(Util.i18n("requestDenied"));
|
user.sendMessage(Util.i18n("requestDenied"));
|
||||||
p.sendMessage(Util.format("requestDeniedFrom", user.getDisplayName()));
|
player.sendMessage(Util.format("requestDeniedFrom", user.getDisplayName()));
|
||||||
user.requestTeleport(null, false);
|
user.requestTeleport(null, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,16 +14,16 @@ public class Commandtphere 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
|
||||||
{
|
{
|
||||||
User p = getPlayer(server, args, 0);
|
final User player = getPlayer(server, args, 0);
|
||||||
if (!p.isTeleportEnabled())
|
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"));
|
user.sendMessage(Util.i18n("teleporting"));
|
||||||
p.sendMessage(Util.i18n("teleporting"));
|
player.sendMessage(Util.i18n("teleporting"));
|
||||||
throw new NoChargeException();
|
throw new NoChargeException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ public class Commandtpo 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)
|
||||||
{
|
{
|
||||||
@ -22,17 +22,17 @@ public class Commandtpo extends EssentialsCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Just basically the old tp command
|
//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
|
// Check if user is offline
|
||||||
if (p.getBase() instanceof OfflinePlayer)
|
if (player.getBase() instanceof OfflinePlayer)
|
||||||
{
|
{
|
||||||
throw new NoSuchFieldException(Util.i18n("playerNotFound"));
|
throw new NoSuchFieldException(Util.i18n("playerNotFound"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify permission
|
// 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"));
|
user.sendMessage(Util.i18n("teleporting"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -14,7 +14,7 @@ public class Commandtpohere 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)
|
||||||
{
|
{
|
||||||
@ -22,18 +22,18 @@ public class Commandtpohere extends EssentialsCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Just basically the old tphere command
|
//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
|
// Check if user is offline
|
||||||
if (p.getBase() instanceof OfflinePlayer)
|
if (player.getBase() instanceof OfflinePlayer)
|
||||||
{
|
{
|
||||||
throw new NoSuchFieldException(Util.i18n("playerNotFound"));
|
throw new NoSuchFieldException(Util.i18n("playerNotFound"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify permission
|
// 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"));
|
user.sendMessage(Util.i18n("teleporting"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -15,27 +15,27 @@ public class Commandtppos 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 < 3)
|
if (args.length < 3)
|
||||||
{
|
{
|
||||||
throw new NotEnoughArgumentsException();
|
throw new NotEnoughArgumentsException();
|
||||||
}
|
}
|
||||||
|
|
||||||
int x = Integer.parseInt(args[0]);
|
final int x = Integer.parseInt(args[0]);
|
||||||
int y = Integer.parseInt(args[1]);
|
final int y = Integer.parseInt(args[1]);
|
||||||
int z = Integer.parseInt(args[2]);
|
final int z = Integer.parseInt(args[2]);
|
||||||
Location l = new Location(user.getWorld(), x, y, z);
|
final Location location = new Location(user.getWorld(), x, y, z);
|
||||||
if (args.length > 3) {
|
if (args.length > 3) {
|
||||||
l.setYaw(Float.parseFloat(args[3]));
|
location.setYaw(Float.parseFloat(args[3]));
|
||||||
}
|
}
|
||||||
if (args.length > 4) {
|
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);
|
charge.isAffordableFor(user);
|
||||||
user.sendMessage(Util.i18n("teleporting"));
|
user.sendMessage(Util.i18n("teleporting"));
|
||||||
user.getTeleport().teleport(l, charge);
|
user.getTeleport().teleport(location, charge);
|
||||||
throw new NoChargeException();
|
throw new NoChargeException();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -13,7 +13,7 @@ public class Commandtptoggle 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
|
||||||
{
|
{
|
||||||
user.sendMessage(user.toggleTeleportEnabled()
|
user.sendMessage(user.toggleTeleportEnabled()
|
||||||
? Util.i18n("teleportationEnabled")
|
? Util.i18n("teleportationEnabled")
|
||||||
|
@ -15,7 +15,7 @@ public class Commandtree 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 < 1)
|
if (args.length < 1)
|
||||||
@ -39,10 +39,6 @@ public class Commandtree extends EssentialsCommand
|
|||||||
throw new NotEnoughArgumentsException();
|
throw new NotEnoughArgumentsException();
|
||||||
}
|
}
|
||||||
|
|
||||||
final int[] ignore =
|
|
||||||
{
|
|
||||||
8, 9
|
|
||||||
};
|
|
||||||
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);
|
||||||
|
@ -23,8 +23,8 @@ public class Commandunban extends EssentialsCommand
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
final User u = getPlayer(server, args, 0, true);
|
final User player = getPlayer(server, args, 0, true);
|
||||||
u.setBanned(false);
|
player.setBanned(false);
|
||||||
sender.sendMessage(Util.i18n("unbannedPlayer"));
|
sender.sendMessage(Util.i18n("unbannedPlayer"));
|
||||||
}
|
}
|
||||||
catch (NoSuchFieldException e)
|
catch (NoSuchFieldException e)
|
||||||
|
@ -17,7 +17,7 @@ public class Commandunlimited 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)
|
||||||
{
|
{
|
||||||
@ -33,17 +33,17 @@ public class Commandunlimited extends EssentialsCommand
|
|||||||
|
|
||||||
if (args[0].equalsIgnoreCase("list"))
|
if (args[0].equalsIgnoreCase("list"))
|
||||||
{
|
{
|
||||||
String list = getList(target);
|
final String list = getList(target);
|
||||||
user.sendMessage(list);
|
user.sendMessage(list);
|
||||||
}
|
}
|
||||||
else if (args[0].equalsIgnoreCase("clear"))
|
else if (args[0].equalsIgnoreCase("clear"))
|
||||||
{
|
{
|
||||||
List<Integer> itemList = target.getUnlimited();
|
final List<Integer> itemList = target.getUnlimited();
|
||||||
|
|
||||||
int index = 0;
|
int index = 0;
|
||||||
while (itemList.size() > index)
|
while (itemList.size() > index)
|
||||||
{
|
{
|
||||||
Integer item = itemList.get(index);
|
final Integer item = itemList.get(index);
|
||||||
if (toggleUnlimited(user, target, item.toString()) == false)
|
if (toggleUnlimited(user, target, item.toString()) == false)
|
||||||
{
|
{
|
||||||
index++;
|
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();
|
final StringBuilder output = new StringBuilder();
|
||||||
sb.append(Util.i18n("unlimitedItems")).append(" ");
|
output.append(Util.i18n("unlimitedItems")).append(" ");
|
||||||
boolean first = true;
|
boolean first = true;
|
||||||
List<Integer> items = target.getUnlimited();
|
final List<Integer> items = target.getUnlimited();
|
||||||
if (items.isEmpty())
|
if (items.isEmpty())
|
||||||
{
|
{
|
||||||
sb.append(Util.i18n("none"));
|
output.append(Util.i18n("none"));
|
||||||
}
|
}
|
||||||
for (Integer integer : items)
|
for (Integer integer : items)
|
||||||
{
|
{
|
||||||
if (!first)
|
if (!first)
|
||||||
{
|
{
|
||||||
sb.append(", ");
|
output.append(", ");
|
||||||
}
|
}
|
||||||
first = false;
|
first = false;
|
||||||
String matname = Material.getMaterial(integer).toString().toLowerCase().replace("_", "");
|
final String matname = Material.getMaterial(integer).toString().toLowerCase().replace("_", "");
|
||||||
sb.append(matname);
|
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));
|
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()
|
if (ess.getSettings().permissionBasedItemSpawn()
|
||||||
&& (!user.isAuthorized("essentials.unlimited.item-all")
|
&& (!user.isAuthorized("essentials.unlimited.item-all")
|
||||||
&& !user.isAuthorized("essentials.unlimited.item-" + itemname)
|
&& !user.isAuthorized("essentials.unlimited.item-" + itemname)
|
||||||
|
@ -21,7 +21,7 @@ public class Commandwarp 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 || args[0].matches("[0-9]+"))
|
if (args.length == 0 || args[0].matches("[0-9]+"))
|
||||||
{
|
{
|
||||||
@ -51,7 +51,7 @@ public class Commandwarp 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 || args[0].matches("[0-9]+"))
|
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())
|
if (warps.isEmpty())
|
||||||
{
|
{
|
||||||
throw new Exception(Util.i18n("noWarpsDefined"));
|
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);
|
charge.isAffordableFor(user);
|
||||||
if (ess.getSettings().getPerWarpPermission())
|
if (ess.getSettings().getPerWarpPermission())
|
||||||
{
|
{
|
||||||
|
@ -13,17 +13,19 @@ public class Commandweather extends EssentialsCommand
|
|||||||
{
|
{
|
||||||
super("weather");
|
super("weather");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO: Remove duplication
|
||||||
|
|
||||||
@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();
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean isStorm = args[0].equalsIgnoreCase("storm");
|
final boolean isStorm = args[0].equalsIgnoreCase("storm");
|
||||||
World world = user.getWorld();
|
final World world = user.getWorld();
|
||||||
if (args.length > 1)
|
if (args.length > 1)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -43,15 +45,15 @@ public class Commandweather 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) //running from console means inserting a world arg before other args
|
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]");
|
throw new Exception("When running from console, usage is: /" + commandLabel + " <world> <storm/sun> [duration]");
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean isStorm = args[1].equalsIgnoreCase("storm");
|
final boolean isStorm = args[1].equalsIgnoreCase("storm");
|
||||||
World world = server.getWorld(args[0]);
|
final World world = server.getWorld(args[0]);
|
||||||
if (world == null)
|
if (world == null)
|
||||||
{
|
{
|
||||||
throw new Exception("World named " + args[0] + " not found!");
|
throw new Exception("World named " + args[0] + " not found!");
|
||||||
|
@ -16,7 +16,7 @@ public class Commandwhois 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)
|
||||||
{
|
{
|
||||||
@ -34,38 +34,38 @@ public class Commandwhois extends EssentialsCommand
|
|||||||
{
|
{
|
||||||
showhidden = true;
|
showhidden = true;
|
||||||
}
|
}
|
||||||
String whois = args[0].toLowerCase();
|
final String whois = args[0].toLowerCase();
|
||||||
int prefixLength = ChatColor.stripColor(ess.getSettings().getNicknamePrefix()).length();
|
final int prefixLength = ChatColor.stripColor(ess.getSettings().getNicknamePrefix()).length();
|
||||||
for (Player p : server.getOnlinePlayers())
|
for (Player onlinePlayer : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
User u = ess.getUser(p);
|
final User user = ess.getUser(onlinePlayer);
|
||||||
if (u.isHidden() && !showhidden)
|
if (user.isHidden() && !showhidden)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
String dn = ChatColor.stripColor(u.getNick());
|
final String displayName = ChatColor.stripColor(user.getNick());
|
||||||
if (!whois.equalsIgnoreCase(dn)
|
if (!whois.equalsIgnoreCase(displayName)
|
||||||
&& !whois.equalsIgnoreCase(dn.substring(prefixLength))
|
&& !whois.equalsIgnoreCase(displayName.substring(prefixLength))
|
||||||
&& !whois.equalsIgnoreCase(u.getName()))
|
&& !whois.equalsIgnoreCase(user.getName()))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
sender.sendMessage("");
|
sender.sendMessage("");
|
||||||
sender.sendMessage(Util.format("whoisIs", u.getDisplayName(), u.getName()));
|
sender.sendMessage(Util.format("whoisIs", user.getDisplayName(), user.getName()));
|
||||||
sender.sendMessage(Util.format("whoisHealth", u.getHealth()));
|
sender.sendMessage(Util.format("whoisHealth", user.getHealth()));
|
||||||
sender.sendMessage(Util.format("whoisOP", (u.isOp() ? Util.i18n("true") : Util.i18n("false"))));
|
sender.sendMessage(Util.format("whoisOP", (user.isOp() ? Util.i18n("true") : Util.i18n("false"))));
|
||||||
sender.sendMessage(Util.format("whoisGod", (u.isGodModeEnabled() ? 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(u.getGameMode().toString().toLowerCase())));
|
sender.sendMessage(Util.format("whoisGamemode", Util.i18n(user.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("whoisLocation", user.getLocation().getWorld().getName(), user.getLocation().getBlockX(), user.getLocation().getBlockY(), user.getLocation().getBlockZ()));
|
||||||
if (!ess.getSettings().isEcoDisabled())
|
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("whoisStatusAway")
|
||||||
: Util.i18n("whoisStatusAvailable"));
|
: Util.i18n("whoisStatusAvailable"));
|
||||||
sender.sendMessage(Util.format("whoisIPAddress", u.getAddress().getAddress().toString()));
|
sender.sendMessage(Util.format("whoisIPAddress", user.getAddress().getAddress().toString()));
|
||||||
final String location = u.getGeoLocation();
|
final String location = user.getGeoLocation();
|
||||||
if (location != null
|
if (location != null
|
||||||
&& (sender instanceof Player ? ess.getUser(sender).isAuthorized("essentials.geoip.show") : true))
|
&& (sender instanceof Player ? ess.getUser(sender).isAuthorized("essentials.geoip.show") : true))
|
||||||
{
|
{
|
||||||
|
@ -15,15 +15,16 @@ public class Commandworth extends EssentialsCommand
|
|||||||
super("worth");
|
super("worth");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO: Remove duplication
|
||||||
@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
|
||||||
{
|
{
|
||||||
ItemStack is = user.getInventory().getItemInHand();
|
ItemStack iStack = user.getInventory().getItemInHand();
|
||||||
int amount = is.getAmount();
|
int amount = iStack.getAmount();
|
||||||
|
|
||||||
if (args.length > 0)
|
if (args.length > 0)
|
||||||
{
|
{
|
||||||
is = ess.getItemDb().get(args[0]);
|
iStack = ess.getItemDb().get(args[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
@ -35,40 +36,40 @@ public class Commandworth extends EssentialsCommand
|
|||||||
}
|
}
|
||||||
catch (NumberFormatException ex)
|
catch (NumberFormatException ex)
|
||||||
{
|
{
|
||||||
amount = is.getType().getMaxStackSize();
|
amount = iStack.getType().getMaxStackSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
is.setAmount(amount);
|
iStack.setAmount(amount);
|
||||||
double worth = ess.getWorth().getPrice(is);
|
final double worth = ess.getWorth().getPrice(iStack);
|
||||||
if (Double.isNaN(worth))
|
if (Double.isNaN(worth))
|
||||||
{
|
{
|
||||||
throw new Exception(Util.i18n("itemCannotBeSold"));
|
throw new Exception(Util.i18n("itemCannotBeSold"));
|
||||||
}
|
}
|
||||||
|
|
||||||
user.sendMessage(is.getDurability() != 0
|
user.sendMessage(iStack.getDurability() != 0
|
||||||
? Util.format("worthMeta",
|
? Util.format("worthMeta",
|
||||||
is.getType().toString().toLowerCase().replace("_", ""),
|
iStack.getType().toString().toLowerCase().replace("_", ""),
|
||||||
is.getDurability(),
|
iStack.getDurability(),
|
||||||
Util.formatCurrency(worth * amount, ess),
|
Util.formatCurrency(worth * amount, ess),
|
||||||
amount,
|
amount,
|
||||||
Util.formatCurrency(worth, ess))
|
Util.formatCurrency(worth, ess))
|
||||||
: Util.format("worth",
|
: Util.format("worth",
|
||||||
is.getType().toString().toLowerCase().replace("_", ""),
|
iStack.getType().toString().toLowerCase().replace("_", ""),
|
||||||
Util.formatCurrency(worth * amount, ess),
|
Util.formatCurrency(worth * amount, ess),
|
||||||
amount,
|
amount,
|
||||||
Util.formatCurrency(worth, ess)));
|
Util.formatCurrency(worth, ess)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@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();
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemStack is = ess.getItemDb().get(args[0]);
|
ItemStack iStack = ess.getItemDb().get(args[0]);
|
||||||
int amount = is.getAmount();
|
int amount = iStack.getAmount();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -79,25 +80,25 @@ public class Commandworth extends EssentialsCommand
|
|||||||
}
|
}
|
||||||
catch (NumberFormatException ex)
|
catch (NumberFormatException ex)
|
||||||
{
|
{
|
||||||
amount = is.getType().getMaxStackSize();
|
amount = iStack.getType().getMaxStackSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
is.setAmount(amount);
|
iStack.setAmount(amount);
|
||||||
double worth = ess.getWorth().getPrice(is);
|
final double worth = ess.getWorth().getPrice(iStack);
|
||||||
if (Double.isNaN(worth))
|
if (Double.isNaN(worth))
|
||||||
{
|
{
|
||||||
throw new Exception(Util.i18n("itemCannotBeSold"));
|
throw new Exception(Util.i18n("itemCannotBeSold"));
|
||||||
}
|
}
|
||||||
|
|
||||||
sender.sendMessage(is.getDurability() != 0
|
sender.sendMessage(iStack.getDurability() != 0
|
||||||
? Util.format("worthMeta",
|
? Util.format("worthMeta",
|
||||||
is.getType().toString().toLowerCase().replace("_", ""),
|
iStack.getType().toString().toLowerCase().replace("_", ""),
|
||||||
is.getDurability(),
|
iStack.getDurability(),
|
||||||
Util.formatCurrency(worth * amount, ess),
|
Util.formatCurrency(worth * amount, ess),
|
||||||
amount,
|
amount,
|
||||||
Util.formatCurrency(worth, ess))
|
Util.formatCurrency(worth, ess))
|
||||||
: Util.format("worth",
|
: Util.format("worth",
|
||||||
is.getType().toString().toLowerCase().replace("_", ""),
|
iStack.getType().toString().toLowerCase().replace("_", ""),
|
||||||
Util.formatCurrency(worth * amount, ess),
|
Util.formatCurrency(worth * amount, ess),
|
||||||
amount,
|
amount,
|
||||||
Util.formatCurrency(worth, ess)));
|
Util.formatCurrency(worth, ess)));
|
||||||
|
Loading…
Reference in New Issue
Block a user