summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKHobbits <rob@khobbits.co.uk>2012-08-08 00:52:43 +0100
committerKHobbits <rob@khobbits.co.uk>2012-08-08 00:52:43 +0100
commit101ae201d65852cc7aee8b0edf16e21d81f2cdc0 (patch)
treec988f6ee036a173af24049dcf705dd2438a0a893
parent5c1eea0953860c0cfc40993442a608542876ca5f (diff)
downloadEssentials-101ae201d65852cc7aee8b0edf16e21d81f2cdc0.tar
Essentials-101ae201d65852cc7aee8b0edf16e21d81f2cdc0.tar.gz
Essentials-101ae201d65852cc7aee8b0edf16e21d81f2cdc0.tar.lz
Essentials-101ae201d65852cc7aee8b0edf16e21d81f2cdc0.tar.xz
Essentials-101ae201d65852cc7aee8b0edf16e21d81f2cdc0.zip
Fix /day /night /sun and /storm aliases to actually set to the current status if used without parameters.
fixes #2365
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandtime.java44
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandweather.java21
-rw-r--r--Essentials/src/plugin.yml4
3 files changed, 54 insertions, 15 deletions
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtime.java b/Essentials/src/com/earth2me/essentials/commands/Commandtime.java
index 8e5b7c017..92d564391 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandtime.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandtime.java
@@ -20,10 +20,16 @@ public class Commandtime extends EssentialsCommand
@Override
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
+ boolean add = false;
final List<String> argList = new ArrayList<String>(Arrays.asList(args));
- if ((argList.remove("set") || argList.remove("add")) && Util.isInt(argList.get(0)))
+ if (argList.remove("set") && !argList.isEmpty() && Util.isInt(argList.get(0)))
{
- ess.getLogger().info("debug edited 0" + argList.get(0).toString());
+ argList.set(0, argList.get(0) + "t");
+ }
+ if (argList.remove("add") && !argList.isEmpty() && Util.isInt(argList.get(0)))
+ {
+ add = true;
+ argList.set(0, argList.get(0) + "t");
}
final String[] validArgs = argList.toArray(new String[0]);
@@ -34,12 +40,27 @@ public class Commandtime extends EssentialsCommand
worldSelector = validArgs[1];
}
final Set<World> worlds = getWorlds(server, sender, worldSelector);
+ final String setTime;
// If no arguments we are reading the time
if (validArgs.length == 0)
{
- getWorldsTime(sender, worlds);
- return;
+ if (commandLabel.equalsIgnoreCase("day") || commandLabel.equalsIgnoreCase("eday"))
+ {
+ setTime = "day";
+ }
+ else if (commandLabel.equalsIgnoreCase("night") || commandLabel.equalsIgnoreCase("enight"))
+ {
+ setTime = "night";
+ }
+ else
+ {
+ getWorldsTime(sender, worlds);
+ return;
+ }
+ }
+ else {
+ setTime = validArgs[0];
}
final User user = ess.getUser(sender);
@@ -53,14 +74,14 @@ public class Commandtime extends EssentialsCommand
long ticks;
try
{
- ticks = DescParseTickFormat.parse(validArgs[0]);
+ ticks = DescParseTickFormat.parse(setTime);
}
catch (NumberFormatException e)
{
throw new NotEnoughArgumentsException(e);
}
- setWorldsTime(sender, worlds, ticks);
+ setWorldsTime(sender, worlds, ticks, add);
}
/**
@@ -84,14 +105,17 @@ public class Commandtime extends EssentialsCommand
/**
* Used to set the time and inform of the change
*/
- private void setWorldsTime(final CommandSender sender, final Collection<World> worlds, final long ticks)
+ private void setWorldsTime(final CommandSender sender, final Collection<World> worlds, final long ticks, final boolean add)
{
// Update the time
for (World world : worlds)
{
long time = world.getTime();
- time -= time % 24000;
- world.setTime(time + 24000 + ticks);
+ if (!add)
+ {
+ time -= time % 24000;
+ }
+ world.setTime(time + (add ? 0 : 24000) + ticks);
}
final StringBuilder output = new StringBuilder();
@@ -159,4 +183,4 @@ class WorldNameComparator implements Comparator<World>
{
return a.getName().compareTo(b.getName());
}
-}
+} \ No newline at end of file
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandweather.java b/Essentials/src/com/earth2me/essentials/commands/Commandweather.java
index 1229c9ee4..dc9f767d5 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandweather.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandweather.java
@@ -18,12 +18,27 @@ public class Commandweather extends EssentialsCommand
@Override
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
{
+ final boolean isStorm;
if (args.length < 1)
{
- throw new NotEnoughArgumentsException();
+ if (commandLabel.equalsIgnoreCase("sun") || commandLabel.equalsIgnoreCase("esun"))
+ {
+ isStorm = false;
+ }
+ else if (commandLabel.equalsIgnoreCase("storm") || commandLabel.equalsIgnoreCase("estorm")
+ || commandLabel.equalsIgnoreCase("rain") || commandLabel.equalsIgnoreCase("erain"))
+ {
+ isStorm = true;
+ }
+ else
+ {
+ throw new NotEnoughArgumentsException();
+ }
+ }
+ else
+ {
+ isStorm = args[0].equalsIgnoreCase("storm");
}
-
- final boolean isStorm = args[0].equalsIgnoreCase("storm");
final World world = user.getWorld();
if (args.length > 1)
{
diff --git a/Essentials/src/plugin.yml b/Essentials/src/plugin.yml
index 98058ab38..98af00ea3 100644
--- a/Essentials/src/plugin.yml
+++ b/Essentials/src/plugin.yml
@@ -341,7 +341,7 @@ commands:
time:
description: Display/Change the world time. Defaults to current world.
usage: /<command> [day|night|dawn|17:30|4pm|4000ticks] [worldname|all]
- aliases: [etime, day, night]
+ aliases: [etime, day, night, eday, enight]
togglejail:
description: Jails/Unjails a player and tp them to the jail specified.
usage: /<command> <player> <jailname> [datediff]
@@ -425,7 +425,7 @@ commands:
weather:
description: Setting the weather.
usage: /<command> <storm/sun> [duration]
- aliases: [sky,sun,storm,eweather,esky,esun,estorm]
+ aliases: [sky,sun,storm,eweather,rain,erain,esky,esun,estorm]
whois:
description: Determine the username behind a nickname.
usage: /<command> <nickname>