From 26707ee92999ee0b7f18c75e3c03f21ab5cc463b Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot Date: Thu, 28 Jul 2011 00:32:28 -0400 Subject: [PATCH] Added various utility methods to make chunk handling easier. Thanks Meaglin! By: EvilSeph --- paper-api/src/main/java/org/bukkit/Chunk.java | 46 +++++++++++++++++++ paper-api/src/main/java/org/bukkit/World.java | 10 ++++ 2 files changed, 56 insertions(+) diff --git a/paper-api/src/main/java/org/bukkit/Chunk.java b/paper-api/src/main/java/org/bukkit/Chunk.java index 91cb8a4f86..f45a2c9c40 100644 --- a/paper-api/src/main/java/org/bukkit/Chunk.java +++ b/paper-api/src/main/java/org/bukkit/Chunk.java @@ -58,4 +58,50 @@ public interface Chunk { Entity[] getEntities(); BlockState[] getTileEntities(); + + /** + * Checks if the chunk is loaded. + * + * @return + */ + boolean isLoaded(); + + /** + * Loads the chunk. + * + * @param generate Whether or not to generate a chunk if it doesn't already exist + * @return true if the chunk has loaded successfully, otherwise false + */ + boolean load(boolean generate); + + /** + * Loads the chunk. + * + * @return true if the chunk has loaded successfully, otherwise false + */ + boolean load(); + + /** + * Unloads and optionally saves the Chunk + * + * @param save Controls whether the chunk is saved + * @param safe Controls whether to unload the chunk when players are nearby + * @return true if the chunk has unloaded successfully, otherwise false + */ + boolean unload(boolean save, boolean safe); + + /** + * Unloads and optionally saves the Chunk + * + * @param save Controls whether the chunk is saved + * @return true if the chunk has unloaded successfully, otherwise false + */ + boolean unload(boolean save); + + /** + * Unloads and optionally saves the Chunk + * + * @return true if the chunk has unloaded successfully, otherwise false + */ + boolean unload(); } diff --git a/paper-api/src/main/java/org/bukkit/World.java b/paper-api/src/main/java/org/bukkit/World.java index b09fb13108..b8330493eb 100644 --- a/paper-api/src/main/java/org/bukkit/World.java +++ b/paper-api/src/main/java/org/bukkit/World.java @@ -171,6 +171,16 @@ public interface World { */ public boolean loadChunk(int x, int z, boolean generate); + /** + * Safely unloads and saves the {@link Chunk} at the specified coordinates + * + * This method is analogous to {@link #unloadChunk(int, int, boolean, boolean)} where safe and saveis true + * + * @param chunk the chunk to unload + * @return true if the chunk has unloaded successfully, otherwise false + */ + public boolean unloadChunk(Chunk chunk); + /** * Safely unloads and saves the {@link Chunk} at the specified coordinates *