summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEvilSeph <evilseph@gmail.com>2011-07-28 00:32:28 -0400
committerEvilSeph <evilseph@gmail.com>2011-07-28 00:32:28 -0400
commitbf3af40b2d0a0f6eebb25e98f3246870b486d1c2 (patch)
treee41bcaa4f55625dd418522e7ae54628ad4949506 /src
parentf3fcc6f81fc7fb5be1997bb999940978636c6121 (diff)
downloadbukkit-bf3af40b2d0a0f6eebb25e98f3246870b486d1c2.tar
bukkit-bf3af40b2d0a0f6eebb25e98f3246870b486d1c2.tar.gz
bukkit-bf3af40b2d0a0f6eebb25e98f3246870b486d1c2.tar.lz
bukkit-bf3af40b2d0a0f6eebb25e98f3246870b486d1c2.tar.xz
bukkit-bf3af40b2d0a0f6eebb25e98f3246870b486d1c2.zip
Added various utility methods to make chunk handling easier. Thanks Meaglin!
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/bukkit/Chunk.java46
-rw-r--r--src/main/java/org/bukkit/World.java10
2 files changed, 56 insertions, 0 deletions
diff --git a/src/main/java/org/bukkit/Chunk.java b/src/main/java/org/bukkit/Chunk.java
index 91cb8a4f..f45a2c9c 100644
--- a/src/main/java/org/bukkit/Chunk.java
+++ b/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/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java
index b09fb131..b8330493 100644
--- a/src/main/java/org/bukkit/World.java
+++ b/src/main/java/org/bukkit/World.java
@@ -176,6 +176,16 @@ public interface World {
*
* 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
+ *
+ * This method is analogous to {@link #unloadChunk(int, int, boolean, boolean)} where safe and saveis true
+ *
* @param x X-coordinate of the chunk
* @param z Z-coordinate of the chunk
* @return true if the chunk has unloaded successfully, otherwise false