Better 1.13+ support

This commit is contained in:
Govindas 2021-12-15 13:48:37 +02:00
parent 1fc1bd59e9
commit a034ca69e6

View File

@ -33,7 +33,10 @@ import:
java.util.Arrays java.util.Arrays
java.nio.file.Files java.nio.file.Files
java.nio.file.Paths java.nio.file.Paths
ch.njol.skript.Skript
on script load: on script load:
if Skript.isRunningMinecraft(1, 13) is true:
set {-fwrcache::modern} to true
wait a tick #needed to wait for plugins to load wait a tick #needed to wait for plugins to load
set {-fwrcache::bukkitgetserver} to Bukkit.getServer() set {-fwrcache::bukkitgetserver} to Bukkit.getServer()
@ -55,7 +58,8 @@ on script load:
send "[FastWorldReset] GovindaSK found! Enabling faster chunk unloads in chunk-based reset." to console send "[FastWorldReset] GovindaSK found! Enabling faster chunk unloads in chunk-based reset." to console
set {-govindask} to true set {-govindask} to true
else: else:
send "[FastWorldReset] GovindaSK not found, falling back to a slower, reflection way of unloading chunks in chunk-based reset. (2 errors related to chunk unloading will appear, but you can safely ignore them)" to console if {-fwrcache::modern} is not set:
send "[FastWorldReset] GovindaSK not found, falling back to a slower, reflection way of unloading chunks in chunk-based reset." to console
event "world_reset_start": event "world_reset_start":
@ -298,7 +302,9 @@ command /fastworldreset [<text>] [<text>] [<text>]:
send "&a&lFastWorldReset&2&l> &aSuccessfully copied &e&l%arg 2% &aand made it resettable in &e&l%difference between {_n} and now%&e! If it doesn't work check console for errors." send "&a&lFastWorldReset&2&l> &aSuccessfully copied &e&l%arg 2% &aand made it resettable in &e&l%difference between {_n} and now%&e! If it doesn't work check console for errors."
send "&a&lFastWorldReset&2&l> &eIf you ever wish to update the template of this world, just run &b/fwr create %arg 2% &eagain!" send "&a&lFastWorldReset&2&l> &eIf you ever wish to update the template of this world, just run &b/fwr create %arg 2% &eagain!"
if {-fwrcache::modern} is set:
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": else if arg 1 is "reset":
if arg 2 is not set: if arg 2 is not set:
@ -566,7 +572,10 @@ command /fastworldreset [<text>] [<text>] [<text>]:
if {fastworldreset::chunkresetdisabled::%arg 2%} is not set: if {fastworldreset::chunkresetdisabled::%arg 2%} is not set:
set {fastworldreset::chunkresetdisabled::%arg 2%} to true set {fastworldreset::chunkresetdisabled::%arg 2%} to true
(arg 2 parsed as a world).setAutoSave(true) (arg 2 parsed as a world).setAutoSave(true)
if {-fwrcache::modern} is not set:
send "&a&lFastWorldReset&2&l> &aYou have disabled chunk-based reset for the world &e%arg 2% &aplease note that this makes reset slower and more likely to cause lag spikes, but it makes chunks automatically unload in the world as usual, making the world lighter on RAM usage." send "&a&lFastWorldReset&2&l> &aYou have disabled chunk-based reset for the world &e%arg 2% &aplease note that this makes reset slower and more likely to cause lag spikes, but it makes chunks automatically unload in the world as usual, making the world lighter on RAM usage."
else:
send "&a&lFastWorldReset&2&l> &aYou have disabled chunk-based reset for the world &e%arg 2%&a. This is a good choice for 1.13+ version as chunk-based reset is only helpful below 1.13."
else: else:
send "&a&lFastWorldReset&2&l> &cChunk-based reset is already disabled in world &e%arg 2%&c!" send "&a&lFastWorldReset&2&l> &cChunk-based reset is already disabled in world &e%arg 2%&c!"
else if arg 1 is "enable-chunk-reset": else if arg 1 is "enable-chunk-reset":
@ -578,7 +587,7 @@ command /fastworldreset [<text>] [<text>] [<text>]:
stop stop
if {fastworldreset::chunkresetdisabled::%arg 2%} is set: if {fastworldreset::chunkresetdisabled::%arg 2%} is set:
delete {fastworldreset::chunkresetdisabled::%arg 2%} delete {fastworldreset::chunkresetdisabled::%arg 2%}
send "&a&lFastWorldReset&2&l> &aYou have enabled chunk-based reset for the world &e%arg 2% &aagain! Yay, faster world reset! (Note chunk-based reset is only effective in 1.8-1.12.2)" send "&a&lFastWorldReset&2&l> &aYou have enabled chunk-based reset for the world &e%arg 2%&a! Yay, faster world reset! (Note chunk-based reset is only effective in 1.8-1.12.2)"
(arg 2 parsed as a world).setAutoSave(false) (arg 2 parsed as a world).setAutoSave(false)
else: else:
send "&a&lFastWorldReset&2&l> &cChunk-based reset is already enabled for the world &e%arg 2%&c!" send "&a&lFastWorldReset&2&l> &cChunk-based reset is already enabled for the world &e%arg 2%&c!"
@ -715,7 +724,7 @@ command /fastworldreset [<text>] [<text>] [<text>]:
send formatted "<ttp:&f/fwr unload <world>%newline%&7May be useful for unloading worlds which you no longer need.>&f/fwr unload <world> &a- unload a world." send formatted "<ttp:&f/fwr unload <world>%newline%&7May be useful for unloading worlds which you no longer need.>&f/fwr unload <world> &a- unload a world."
send "&f/fwr unload-chunks <world> <true/false> &a- unloads chunks in the specified world, with saving or without." send "&f/fwr unload-chunks <world> <true/false> &a- unloads chunks in the specified world, with saving or without."
send "&f/fwr tp <world> [player] &a- teleport to a world or teleport another player to the world." send "&f/fwr tp <world> [player] &a- teleport to a world or teleport another player to the world."
send formatted "<ttp:&f/fwr disable-chunk-reset <world>%{_newline}%&7May be useful in situations where the world uses very much RAM and you prefer slower reset than higher RAM usage>&f/fwr disable-chunk-reset <world> &a- disables chunk-based resetting of the specified world, which makes the chunks unload normally." send formatted "<ttp:&f/fwr disable-chunk-reset <world>%newline%&7May be useful in situations where the world uses very much RAM and you prefer slower reset than higher RAM usage>&f/fwr disable-chunk-reset <world> &a- disables chunk-based resetting of the specified world, which makes the chunks unload normally."
send "&f/fwr enable-chunk-reset <world> &a- enables chunk-based reset, this is enabled by default for fastest speed, see above to disable. (This is only meant for things like minigame maps, not where you need changes to persist across server restarts!)" send "&f/fwr enable-chunk-reset <world> &a- enables chunk-based reset, this is enabled by default for fastest speed, see above to disable. (This is only meant for things like minigame maps, not where you need changes to persist across server restarts!)"
send "&f/fwr worlds &a- shows the list of all worlds and their data." send "&f/fwr worlds &a- shows the list of all worlds and their data."
send "&f/fwr generator <world> <generator> &a- set a generator for a world." send "&f/fwr generator <world> <generator> &a- set a generator for a world."
@ -774,6 +783,7 @@ on skript load:
#chunk-based reset, which resets by not saving chunks and re-loading them instead of reloading the whole world. it reloads the world only if the world got saved by some system. #chunk-based reset, which resets by not saving chunks and re-loading them instead of reloading the whole world. it reloads the world only if the world got saved by some system.
on chunk unload: on chunk unload:
parse if Skript.isRunningMinecraft(1, 13) is false:
{-fastworldresetworld::%event-world%} is set {-fastworldresetworld::%event-world%} is set
{fastworldreset::chunkresetdisabled::%event-world%} is not set {fastworldreset::chunkresetdisabled::%event-world%} is not set
{-resetting::%event-world%} is not set {-resetting::%event-world%} is not set