mirror of
https://github.com/essentials/Essentials.git
synced 2025-08-19 13:01:20 +02:00
Fix /time command
This commit is contained in:
@@ -16,10 +16,16 @@ public class Commandtime extends EssentialsCommand
|
|||||||
@Override
|
@Override
|
||||||
public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||||
{
|
{
|
||||||
|
boolean add = false;
|
||||||
final List<String> argList = new ArrayList<String>(Arrays.asList(args));
|
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]);
|
final String[] validArgs = argList.toArray(new String[0]);
|
||||||
|
|
||||||
@@ -55,7 +61,7 @@ public class Commandtime extends EssentialsCommand
|
|||||||
throw new NotEnoughArgumentsException(e);
|
throw new NotEnoughArgumentsException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
setWorldsTime(sender, worlds, ticks);
|
setWorldsTime(sender, worlds, ticks, add);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -79,14 +85,17 @@ 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(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
|
// Update the time
|
||||||
for (World world : worlds)
|
for (World world : worlds)
|
||||||
{
|
{
|
||||||
long time = world.getTime();
|
long time = world.getTime();
|
||||||
|
if (!add)
|
||||||
|
{
|
||||||
time -= time % 24000;
|
time -= time % 24000;
|
||||||
world.setTime(time + 24000 + ticks);
|
}
|
||||||
|
world.setTime(time + (add ? 0 : 24000) + ticks);
|
||||||
}
|
}
|
||||||
|
|
||||||
final StringBuilder output = new StringBuilder();
|
final StringBuilder output = new StringBuilder();
|
||||||
|
Reference in New Issue
Block a user