Merge pull request #1139 from YMC-Minecraft/tickfreeze
support '/tick freeze on', '/tick freeze off' and '/tick freeze status'
This commit is contained in:
1 file changed
+25
-3
@@ -45,7 +45,11 @@ public class TickCommand
|
|||||||
getInteger(c,"ticks"),
|
getInteger(c,"ticks"),
|
||||||
getString(c, "tail command")))))).
|
getString(c, "tail command")))))).
|
||||||
then(literal("freeze").executes( (c)-> toggleFreeze(c.getSource(), false)).
|
then(literal("freeze").executes( (c)-> toggleFreeze(c.getSource(), false)).
|
||||||
then(literal("deep").executes( (c)-> toggleFreeze(c.getSource(), true)))).
|
then(literal("status").executes( (c) -> freezeStatus(c.getSource()))).
|
||||||
|
then(literal("deep").executes( (c) -> toggleFreeze(c.getSource(), true))).
|
||||||
|
then(literal("on").executes( (c) -> setFreeze(c.getSource(), false, true)).
|
||||||
|
then(literal("deep").executes( (c)-> setFreeze(c.getSource(), true, true)))).
|
||||||
|
then(literal("off").executes( (c) -> setFreeze(c.getSource(), false, false)))).
|
||||||
then(literal("step").
|
then(literal("step").
|
||||||
executes((c) -> step(1)).
|
executes((c) -> step(1)).
|
||||||
then(argument("ticks", integer(1,72000)).
|
then(argument("ticks", integer(1,72000)).
|
||||||
@@ -94,9 +98,22 @@ public class TickCommand
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int toggleFreeze(ServerCommandSource source, boolean isDeep)
|
private static int freezeStatus(ServerCommandSource source)
|
||||||
{
|
{
|
||||||
TickSpeed.setFrozenState(!TickSpeed.isPaused(), isDeep);
|
if(TickSpeed.isPaused())
|
||||||
|
{
|
||||||
|
Messenger.m(source, "gi Freeze Status: Game is "+(TickSpeed.deeplyFrozen()?"deeply ":"")+"frozen");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Messenger.m(source, "gi Freeze Status: Game runs normally");
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int setFreeze(ServerCommandSource source, boolean isDeep, boolean freeze)
|
||||||
|
{
|
||||||
|
TickSpeed.setFrozenState(freeze, isDeep);
|
||||||
if (TickSpeed.isPaused())
|
if (TickSpeed.isPaused())
|
||||||
{
|
{
|
||||||
Messenger.m(source, "gi Game is "+(isDeep?"deeply ":"")+"frozen");
|
Messenger.m(source, "gi Game is "+(isDeep?"deeply ":"")+"frozen");
|
||||||
@@ -108,6 +125,11 @@ public class TickCommand
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static int toggleFreeze(ServerCommandSource source, boolean isDeep)
|
||||||
|
{
|
||||||
|
return setFreeze(source, isDeep, !TickSpeed.isPaused());
|
||||||
|
}
|
||||||
|
|
||||||
private static int step(int advance)
|
private static int step(int advance)
|
||||||
{
|
{
|
||||||
TickSpeed.add_ticks_to_run_in_pause(advance);
|
TickSpeed.add_ticks_to_run_in_pause(advance);
|
||||||
|
|||||||
Reference in new issue
Block a user