From 044f54a26447b48c189179fdf8829fb57f9ec8a6 Mon Sep 17 00:00:00 2001 From: Govindas Date: Sat, 25 Dec 2021 16:30:02 +0200 Subject: [PATCH] Better integration with other scripts, -inworldreset::worldname variable --- fastworldreset.sk | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/fastworldreset.sk b/fastworldreset.sk index e518b4e..3353444 100644 --- a/fastworldreset.sk +++ b/fastworldreset.sk @@ -306,7 +306,6 @@ command /fastworldreset [] [] []: set {fastworldreset::chunkresetdisabled::%arg 2%} to true send "&a&lFastWorldReset&2&l> &cDisabled chunk-based reset for this world by default. Because you're running 1.13+ where only world-based reset is effective." else if arg 1 is "reset": - if arg 2 is not set: send "&a&lFastWorldReset&2&l> &cPlease specify world name!" stop @@ -316,6 +315,13 @@ command /fastworldreset [] [] []: if {-fastworldresetworld::%arg 2%} is set: set {_world} to arg 2 parsed as a world + set {_ev::world} to {_world} + call event (custom event "world_reset_start" with {_ev::*}) + + #this can be used to delay the reset by a specific amount of seconds + if arg 3 is set: + wait "%arg 3 parsed as a number% seconds" parsed as a timespan + if {_world} is not a world: set {_worldreset} to true else if {fastworldreset::chunkresetdisabled::%arg 2%} or {-fastworldreset::shouldreset::%arg 2%} is set: @@ -325,13 +331,10 @@ command /fastworldreset [] [] []: set {_template} to {fastworldresetclone::%arg 2%} ? arg 2 - set {_ev::world} to {_world} - set {_w} to arg 2 - call event (custom event "world_reset_start" with {_ev::*}) {_worldreset} is not set: + set {_w} to arg 2 #detect world save as world save event doesn't always call - create section stored in {_section}: if ((new File("%{_worlddir}%/%{_w}%/level.dat")).lastModified()) is higher than {fastworldreset::lastreset::%{_w}%}: return true @@ -717,7 +720,7 @@ command /fastworldreset [] [] []: send "&f/fwr create [generator] &a- Add a world to FastWorldReset system or create a completely new world into the system. (Or update existing world's template)" send "&f/fwr delete &a- Removes the world from FastWorldReset system, does not unload or delete the world." send "&f/fwr clone &a- Clones a FWR world." - send "&f/fwr reset &a- to reset a world. (Must be in FastWorldReset system)" + send "&f/fwr reset [seconds] &a- to reset a FastWorldReset world, with optional delay." send "&f/fwr exit &a- sets exit point to where players get teleported when their world resets." send "&f/fwr load [generator] &a- loads a world. Optionally with a generator." send "&f/fwr unload [] &a- loads a world. true/false if the world should be saved, defaults to true." @@ -737,7 +740,7 @@ command /fastworldreset [] [] []: function initWorlds(): #just in case if the user hasn't configured variables starting with "-" character to not save to database. - delete {-fastworldresetworld::*}, {-unloading::*}, {-resetting::*} and {-initload::*} + delete {-fastworldresetworld::*}, {-unloading::*}, {-resetting::*}, {-inworldreset::*} and {-initload::*} set {_worlddir} to {-fwrcache::worlddir} create section stored in {_section}: @@ -830,3 +833,9 @@ on skript unload: {-fastworldresetworld::%loop-world%} is set {fastworldreset::chunkresetdisabled::%loop-world%} is not set unloadWorld(loop-world, false) + +#for use of {-inworldreset::worldname} variable in your scripts, this can help to tell whether a world is currently in a reset process +on start of world reset: + set {-inworldreset::%event-world%} to now +on complete of world reset: + delete {-inworldreset::%event-world%}