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

@@ -70,15 +70,17 @@ 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]))
{ {
@@ -99,9 +101,10 @@ public class Commandmail extends EssentialsCommand
u.addMail("Server: " + getFinalArg(args, 2)); u.addMail("Server: " + getFinalArg(args, 2));
sender.sendMessage(Util.i18n("mailSent")); sender.sendMessage(Util.i18n("mailSent"));
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

@@ -14,9 +14,10 @@ public class Commandrealname extends EssentialsCommand
{ {
super("realname"); super("realname");
} }
@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

@@ -43,35 +43,37 @@ public class Commandweather extends EssentialsCommand
return; return;
} }
} }
@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
{ {
world.setStorm(isStorm ? true : false); world.setStorm(isStorm ? true : false);
sender.sendMessage(isStorm sender.sendMessage(isStorm
? Util.format("weatherStorm", world.getName()) ? Util.format("weatherStorm", world.getName())
: Util.format("weatherSun", world.getName())); : Util.format("weatherSun", world.getName()));
return; return;
} }
} }

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);
@@ -58,14 +58,16 @@ public class Commandworth extends EssentialsCommand
amount, amount,
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);
@@ -88,17 +90,17 @@ public class Commandworth extends EssentialsCommand
} }
sender.sendMessage(is.getDurability() != 0 sender.sendMessage(is.getDurability() != 0
? Util.format("worthMeta", ? Util.format("worthMeta",
is.getType().toString().toLowerCase().replace("_", ""), is.getType().toString().toLowerCase().replace("_", ""),
is.getDurability(), is.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("_", ""), is.getType().toString().toLowerCase().replace("_", ""),
Util.formatCurrency(worth * amount, ess), Util.formatCurrency(worth * amount, ess),
amount, amount,
Util.formatCurrency(worth, ess))); Util.formatCurrency(worth, ess)));
} }
} }