From 38b061c12c8f437e9fb99c4830a9701f4b4a9b43 Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Fri, 1 Aug 2025 22:32:55 +0200 Subject: [PATCH] Add JavaDoc to RegionSystem --- .../src/de/steamwar/bausystem/BauSystem.java | 9 +++++++- .../bausystem/region/RegionSystem.java | 21 +++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java index 4774565c..af84b780 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java @@ -40,6 +40,7 @@ import de.steamwar.bausystem.worlddata.WorldData; import de.steamwar.command.AbstractValidator; import de.steamwar.command.SWCommand; import de.steamwar.command.SWCommandUtils; +import de.steamwar.core.CRIUSleepEvent; import de.steamwar.core.Core; import de.steamwar.core.WorldEditRendererCUIEditor; import de.steamwar.linkage.LinkedInstance; @@ -54,6 +55,7 @@ import lombok.Getter; import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; import org.bukkit.event.HandlerList; import org.bukkit.event.Listener; import org.bukkit.plugin.Plugin; @@ -72,7 +74,7 @@ import java.util.function.Consumer; import java.util.logging.Level; import java.util.stream.Collectors; -public class BauSystem extends JavaPlugin { +public class BauSystem extends JavaPlugin implements Listener { // This should be treated as final! public static Message MESSAGE; @@ -212,6 +214,11 @@ public class BauSystem extends JavaPlugin { new WorldEditRendererCUIEditor(); } + @EventHandler + public void onCRIUSleep(CRIUSleepEvent event) { + RegionSystem.INSTANCE.save(); + } + @Override public void onDisable() { instances.forEach((aClass, o) -> { diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionSystem.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionSystem.java index 5222a415..4289fb1b 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionSystem.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionSystem.java @@ -32,18 +32,39 @@ public interface RegionSystem { RegionSystem INSTANCE = init(); + /** + * Loads and initializes the Regions and anything that should be loaded on startup. + */ void load(); + + /** + * Saves anything that should be written to file on either CRIUSleepEvent or plugin disable. + */ void save(); + /** + * Returns the GlobalRegion. This Region should have their {@link Region#getID()} return the + * '00000000-0000-0000-0000-000000000000' UUID for easier retrieval with {@link #getRegion(UUID)}. + */ @NonNull Region getGlobalRegion(); + /** + * Should return a Region that is present at the specific Location or the {@link #getGlobalRegion()} + * if none are present. + */ @NonNull Region get(@NonNull Location location); + /** + * Should return the Region by their UUID. + */ @CheckReturnValue Optional getRegion(@NonNull UUID id); + /** + * Does and should not contain the GlobalRegion returned by {@link #getGlobalRegion()}. + */ @NonNull Stream getRegions();