mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-08-06 12:33:03 +00:00
Cleanup
This commit is contained in:
parent
1c7dcfc63d
commit
358456c8ea
4 changed files with 44 additions and 36 deletions
|
@ -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)
|
||||||
|
|
|
@ -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();
|
||||||
|
|
|
@ -44,34 +44,36 @@ 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
|
||||||
{
|
{
|
||||||
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
||||||
|
@ -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)));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue