Better world saving control & optimizations

This commit is contained in:
Govindas 2021-06-21 10:07:29 +00:00
parent f71148c0eb
commit f4561a7535

View File

@ -6,13 +6,18 @@ options:
ResetResettableWorldsOnRestart: true ResetResettableWorldsOnRestart: true
AutoDeleteClonesOnRestart: true AutoDeleteClonesOnRestart: true
#whether it should only reset "region" world folder contents and not other things like level.dat (It's cheaper to reset only region folder, but it doesn't reset world metadata, only the chunks, which may be not what you wish) #whether it should only reset "region" world folder contents and not other things like level.dat (It's cheaper to reset only region folder, but it doesn't reset world metadata, only the chunks, which may be not what you wish)
ResetOnlyRegionFolder: false ResetOnlyRegionFolder: true
#whether /fwr create will look for existing world folder or allow to create a new blank one. #whether /fwr create will look for existing world folder or allow to create a new blank one.
#Creating blank world will not function for resetting (as there will be no template) until you update template by running /fwr create on the same world again. #Creating blank world will not function for resetting (as there will be no template) until you update template by running /fwr create on the same world again.
#useful for when you want to copypaste a map into a newly created world and then make it resettable #useful for when you want to copypaste a map into a newly created world and then make it resettable
#without having to go through another world management plugin to do it #without having to go through another world management plugin to do it
AllowCreatingNewWorlds: true AllowCreatingNewWorlds: true
#by default saving is only disabled in chunk-based reset worlds, not world-based reset ones.
#this option disables world saving in all resettable worlds
DisableSavingInAllResettableWorlds: false
#------------- End of Configuration ------------- #------------- End of Configuration -------------
#The script starts here, only edit if you know what you are doing. #The script starts here, only edit if you know what you are doing.
@ -735,9 +740,10 @@ function initWorlds():
if {@ResetResettableWorldsOnRestart} is true: if {@ResetResettableWorldsOnRestart} is true:
make console execute command "/fastworldreset reset %loop-value%" make console execute command "/fastworldreset reset %loop-value%"
else if loop-value parsed as a world is not a world: else if (loop-value parsed as a world) is not a world:
loadWorld(loop-value) loadWorld(loop-value)
function deleteClones(): function deleteClones():
{fastworldresetclone::*} is set
set {_worlddir} to {-fwrcache::worlddir} set {_worlddir} to {-fwrcache::worlddir}
create section stored in {_section}: create section stored in {_section}:
loop {fastworldresetclone::*}: loop {fastworldresetclone::*}:
@ -771,7 +777,17 @@ on world init:
else: else:
set {_options} to "%event-world%" set {_options} to "%event-world%"
{-fastworldresetworld::%{_options}%} is set {-fastworldresetworld::%{_options}%} is set
#reduces ram usage by disabling spawn chunks
event-world.setKeepSpawnInMemory(false)
{fastworldreset::chunkresetdisabled::%{_options}%} is not set: {fastworldreset::chunkresetdisabled::%{_options}%} is not set:
set {_disablesaving} to true
else if {@DisableSavingInAllResettableWorlds} is true:
set {_disablesaving} to true
{_disablesaving} is set:
event-world.setAutoSave(false) event-world.setAutoSave(false)
#for Paper servers, to disable saving #for Paper servers, to disable saving
@ -782,11 +798,7 @@ on world init:
set {_config}.autoSavePeriod to 0 set {_config}.autoSavePeriod to 0
set {_config}.maxAutoSaveChunksPerTick to 0 set {_config}.maxAutoSaveChunksPerTick to 0
#in the past I thought this is needed, now I am not sure as I haven't noticed a difference, but I'll keep it here, just in case, it sounds logical to disable it for chunk-based reset
set {_config}.skipEntityTickingInChunksScheduledForUnload to false
event-world.setKeepSpawnInMemory(false)
on world saving: on world saving:
{fastworldreset::chunkresetdisabled::%event-world%} is not set {fastworldreset::chunkresetdisabled::%event-world%} is not set
set {-fastworldreset::shouldreset::%event-world%} to true set {-fastworldreset::shouldreset::%event-world%} to true