3.5.4
This commit is contained in:
parent
317d9466f4
commit
24614da164
@ -111,6 +111,18 @@ function unloadWorld(world: world, saving: boolean = true) :: boolean:
|
|||||||
send "World unload took %difference between {_n} and now%" to console
|
send "World unload took %difference between {_n} and now%" to console
|
||||||
return true
|
return true
|
||||||
function resetWorld(input: text, sender: object):
|
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
|
#mark world save as non-set
|
||||||
if {-fastworldreset::shouldreset::%{_input}%} is set:
|
if {-fastworldreset::shouldreset::%{_input}%} is set:
|
||||||
delete {-fastworldreset::shouldreset::%{_input}%}
|
delete {-fastworldreset::shouldreset::%{_input}%}
|
||||||
@ -134,10 +146,11 @@ function resetWorld(input: text, sender: object):
|
|||||||
else:
|
else:
|
||||||
set {_template} to {_input}
|
set {_template} to {_input}
|
||||||
|
|
||||||
set {_source} to new File("%{_worlddir}%/FastWorldReset/%{_template}%/region")
|
set {_source} to new File("%{_worlddir}%/FastWorldReset/%{_template}%")
|
||||||
set {_target} to new File("%{_worlddir}%/%{_input}%/region")
|
set {_target} to new File("%{_worlddir}%/%{_input}%")
|
||||||
|
|
||||||
create new section stored in {_section}:
|
create new section stored in {_section}:
|
||||||
|
FileUtils.deleteDirectory({_target})
|
||||||
FileUtils.copyDirectory({_source}, {_target})
|
FileUtils.copyDirectory({_source}, {_target})
|
||||||
|
|
||||||
run section {_section} async and wait
|
run section {_section} async and wait
|
||||||
@ -242,32 +255,23 @@ command /fastworldreset [<text>] [<text>] [<text>]:
|
|||||||
|
|
||||||
#make reset backup of the world
|
#make reset backup of the world
|
||||||
set {_n} to now
|
set {_n} to now
|
||||||
if {_notmissing} is true:
|
set {_source} to new File("%{_worlddir}%/%arg 2%")
|
||||||
set {_w} to arg 2
|
set {_target} to new File("%{_worlddir}%/FastWorldReset/%arg 2%")
|
||||||
set {_source} to new File("%{_worlddir}%/%arg 2%/region")
|
set {_targetpath} to "%{_worlddir}%/FastWorldReset/%arg 2%"
|
||||||
set {_target} to new File("%{_worlddir}%/FastWorldReset/%arg 2%/region")
|
set {_p} to sender
|
||||||
create new section stored in {_section}:
|
create new section stored in {_section}:
|
||||||
FileUtils.deleteDirectory(new File("%{_worlddir}%/FastWorldReset/%{_w}%/region"))
|
FileUtils.copyDirectory({_source}, {_target})
|
||||||
FileUtils.copyDirectory({_source}, {_target})
|
if {@AllowCreatingNewWorlds} is false:
|
||||||
run section {_section} async and wait
|
Files.isDirectory(Paths.get({_targetpath})) is false:
|
||||||
else:
|
send "&a&lFastWorldReset&2&l> &cFailed to copy world! Are file permissions right? Check console for errors." to {_p}
|
||||||
set {_source} to new File("%{_worlddir}%/%arg 2%")
|
return true
|
||||||
set {_target} to new File("%{_worlddir}%/FastWorldReset/%arg 2%")
|
set {_uid} to new File("%{_targetpath}%/uid.dat")
|
||||||
set {_targetpath} to "%{_worlddir}%/FastWorldReset/%arg 2%"
|
if {_uid}.exists() is true:
|
||||||
set {_p} to sender
|
{_uid}.delete()
|
||||||
create new section stored in {_section}:
|
return false
|
||||||
FileUtils.copyDirectory({_source}, {_target})
|
run section {_section} async and store the result in {_failed} and wait
|
||||||
if {@AllowCreatingNewWorlds} is false:
|
|
||||||
Files.isDirectory(Paths.get({_targetpath})) is false:
|
|
||||||
send "&a&lFastWorldReset&2&l> &cFailed to copy world! Are file permissions right? Check console for errors." to {_p}
|
|
||||||
return true
|
|
||||||
set {_uid} to new File("%{_targetpath}%/uid.dat")
|
|
||||||
if {_uid}.exists() is true:
|
|
||||||
{_uid}.delete()
|
|
||||||
return false
|
|
||||||
run section {_section} async and store the result in {_failed} and wait
|
|
||||||
|
|
||||||
stop if {_failed} is true
|
stop if {_failed} is true
|
||||||
|
|
||||||
|
|
||||||
set {fastworldreset::lastreset::%arg 2%} to new Date().getTime()
|
set {fastworldreset::lastreset::%arg 2%} to new Date().getTime()
|
||||||
|
Loading…
Reference in New Issue
Block a user