This commit is contained in:
Govindas 2021-01-09 13:41:49 +02:00
parent 317d9466f4
commit 24614da164
1 changed files with 31 additions and 27 deletions

View File

@ -111,6 +111,18 @@ function unloadWorld(world: world, saving: boolean = true) :: boolean:
send "World unload took %difference between {_n} and now%" to console
return true
function resetWorld(input: text, sender: object):
set {_world} to {_input} parsed as a world
{_world} is a world:
#teleport out is needed to be able to unload the world
teleportOut({_world})
#waiting until all players are teleported out, to support asynchronous teleportations
while amount of players in {_world} is not 0:
wait a tick
#mark world save as non-set
if {-fastworldreset::shouldreset::%{_input}%} is set:
delete {-fastworldreset::shouldreset::%{_input}%}
@ -134,10 +146,11 @@ function resetWorld(input: text, sender: object):
else:
set {_template} to {_input}
set {_source} to new File("%{_worlddir}%/FastWorldReset/%{_template}%/region")
set {_target} to new File("%{_worlddir}%/%{_input}%/region")
set {_source} to new File("%{_worlddir}%/FastWorldReset/%{_template}%")
set {_target} to new File("%{_worlddir}%/%{_input}%")
create new section stored in {_section}:
FileUtils.deleteDirectory({_target})
FileUtils.copyDirectory({_source}, {_target})
run section {_section} async and wait
@ -242,15 +255,6 @@ command /fastworldreset [<text>] [<text>] [<text>]:
#make reset backup of the world
set {_n} to now
if {_notmissing} is true:
set {_w} to arg 2
set {_source} to new File("%{_worlddir}%/%arg 2%/region")
set {_target} to new File("%{_worlddir}%/FastWorldReset/%arg 2%/region")
create new section stored in {_section}:
FileUtils.deleteDirectory(new File("%{_worlddir}%/FastWorldReset/%{_w}%/region"))
FileUtils.copyDirectory({_source}, {_target})
run section {_section} async and wait
else:
set {_source} to new File("%{_worlddir}%/%arg 2%")
set {_target} to new File("%{_worlddir}%/FastWorldReset/%arg 2%")
set {_targetpath} to "%{_worlddir}%/FastWorldReset/%arg 2%"