1
0
mirror of https://github.com/essentials/Essentials.git synced 2025-08-06 14:46:32 +02:00
This commit is contained in:
snowleo
2011-10-19 14:47:32 +02:00
parent bf03c6c8a1
commit aaf5c334b7
4 changed files with 44 additions and 36 deletions

View File

@@ -71,14 +71,16 @@ public class Commandmail extends EssentialsCommand
throw new NotEnoughArgumentsException(); throw new NotEnoughArgumentsException();
} }
@Override protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception { @Override
protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
{
if (args.length >= 1 && "read".equalsIgnoreCase(args[0])) if (args.length >= 1 && "read".equalsIgnoreCase(args[0]))
{ {
throw new Exception(Util.format("onlyPlayers", commandLabel+" read")); throw new Exception(Util.format("onlyPlayers", commandLabel + " read"));
} }
else if (args.length >= 1 && "clear".equalsIgnoreCase(args[0])) else if (args.length >= 1 && "clear".equalsIgnoreCase(args[0]))
{ {
throw new Exception(Util.format("onlyPlayers", commandLabel+" clear")); throw new Exception(Util.format("onlyPlayers", commandLabel + " clear"));
} }
else if (args.length >= 3 && "send".equalsIgnoreCase(args[0])) else if (args.length >= 3 && "send".equalsIgnoreCase(args[0]))
{ {
@@ -101,7 +103,8 @@ public class Commandmail extends EssentialsCommand
return; return;
} }
else if (args.length >= 2) else if (args.length >= 2)
{ //allow sending from console without "send" argument, since it's the only thing the console can do {
//allow sending from console without "send" argument, since it's the only thing the console can do
Player player = server.getPlayer(args[0]); Player player = server.getPlayer(args[0]);
User u; User u;
if (player != null) if (player != null)

View File

@@ -16,7 +16,8 @@ public class Commandrealname extends EssentialsCommand
} }
@Override @Override
protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception { protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
{
if (args.length < 1) if (args.length < 1)
{ {
throw new NotEnoughArgumentsException(); throw new NotEnoughArgumentsException();

View File

@@ -44,26 +44,28 @@ public class Commandweather extends EssentialsCommand
} }
} }
@Override protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception { @Override
protected void run(Server server, CommandSender sender, String commandLabel, 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"); boolean isStorm = args[1].equalsIgnoreCase("storm");
World world = server.getWorld(args[0]); 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!");
} }
if (args.length > 2) if (args.length > 2)
{ {
world.setStorm(isStorm ? true : false); world.setStorm(isStorm ? true : false);
world.setWeatherDuration(Integer.parseInt(args[1]) * 20); world.setWeatherDuration(Integer.parseInt(args[2]) * 20);
sender.sendMessage(isStorm sender.sendMessage(isStorm
? Util.format("weatherStormFor", world.getName(), args[1]) ? Util.format("weatherStormFor", world.getName(), args[2])
: Util.format("weatherSunFor", world.getName(), args[1])); : Util.format("weatherSunFor", world.getName(), args[2]));
return; return;
} }
else else

View File

@@ -35,7 +35,7 @@ public class Commandworth extends EssentialsCommand
} }
catch (NumberFormatException ex) catch (NumberFormatException ex)
{ {
amount = 64; amount = is.getType().getMaxStackSize();
} }
is.setAmount(amount); is.setAmount(amount);
@@ -59,13 +59,15 @@ public class Commandworth extends EssentialsCommand
Util.formatCurrency(worth, ess))); Util.formatCurrency(worth, ess)));
} }
@Override protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception { @Override
protected void run(Server server, CommandSender sender, String commandLabel, 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]);// = user.getInventory().getItemInHand(); ItemStack is = ess.getItemDb().get(args[0]);
int amount = is.getAmount(); int amount = is.getAmount();
try try
@@ -77,7 +79,7 @@ public class Commandworth extends EssentialsCommand
} }
catch (NumberFormatException ex) catch (NumberFormatException ex)
{ {
amount = 64; amount = is.getType().getMaxStackSize();
} }
is.setAmount(amount); is.setAmount(amount);