2014-11-07 01:31:52 +01:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Aikar <aikar@aikar.co>
|
2016-03-01 00:09:49 +01:00
|
|
|
Date: Mon, 29 Feb 2016 17:43:33 -0600
|
2014-11-07 01:31:52 +01:00
|
|
|
Subject: [PATCH] Add async chunk load API
|
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java
|
|
|
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
|
|
--- a/src/main/java/org/bukkit/World.java
|
|
|
|
+++ b/src/main/java/org/bukkit/World.java
|
|
|
|
@@ -0,0 +0,0 @@ public interface World extends PluginMessageRecipient, Metadatable {
|
|
|
|
public Chunk getChunkAt(Block block);
|
|
|
|
|
2016-03-01 00:09:49 +01:00
|
|
|
/**
|
|
|
|
+ * Used by {@link World#getChunkAtAsync(Location,ChunkLoadCallback)} methods
|
|
|
|
+ * to request a {@link Chunk} to be loaded, with this callback receiving
|
|
|
|
+ * the chunk when it is finished.
|
|
|
|
+ *
|
|
|
|
+ * This callback will be executed on synchronously on the main thread.
|
|
|
|
+ *
|
|
|
|
+ * Timing and order this callback is fired is intentionally not defined and
|
|
|
|
+ * and subject to change.
|
|
|
|
+ */
|
2014-11-07 01:31:52 +01:00
|
|
|
+ public static interface ChunkLoadCallback {
|
|
|
|
+ public void onLoad(Chunk chunk);
|
|
|
|
+ }
|
2016-03-01 00:09:49 +01:00
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Requests a {@link Chunk} to be loaded at the given coordinates
|
|
|
|
+ *
|
|
|
|
+ * This method makes no guarantee on how fast the chunk will load,
|
|
|
|
+ * and will return the chunk to the callback at a later time.
|
|
|
|
+ *
|
|
|
|
+ * You should use this method if you need a chunk but do not need it
|
|
|
|
+ * immediately, and you wish to let the server control the speed
|
|
|
|
+ * of chunk loads, keeping performance in mind.
|
|
|
|
+ *
|
|
|
|
+ * The {@link ChunkLoadCallback} will always be executed synchronously
|
|
|
|
+ * on the main Server Thread.
|
|
|
|
+ *
|
|
|
|
+ * @param x Chunk X-coordinate of the chunk - (world coordinate / 16)
|
|
|
|
+ * @param z Chunk Z-coordinate of the chunk - (world coordinate / 16)
|
|
|
|
+ * @param cb Callback to receive the chunk when it is loaded.
|
|
|
|
+ * will be executed synchronously
|
|
|
|
+ */
|
2014-11-07 01:31:52 +01:00
|
|
|
+ public void getChunkAtAsync(int x, int z, ChunkLoadCallback cb);
|
2016-03-01 00:09:49 +01:00
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Requests a {@link Chunk} to be loaded at the given {@link Location}
|
|
|
|
+ *
|
|
|
|
+ * This method makes no guarantee on how fast the chunk will load,
|
|
|
|
+ * and will return the chunk to the callback at a later time.
|
|
|
|
+ *
|
|
|
|
+ * You should use this method if you need a chunk but do not need it
|
|
|
|
+ * immediately, and you wish to let the server control the speed
|
|
|
|
+ * of chunk loads, keeping performance in mind.
|
|
|
|
+ *
|
|
|
|
+ * The {@link ChunkLoadCallback} will always be executed synchronously
|
|
|
|
+ * on the main Server Thread.
|
|
|
|
+ *
|
|
|
|
+ * @param location Location of the chunk
|
|
|
|
+ * @param cb Callback to receive the chunk when it is loaded.
|
|
|
|
+ * will be executed synchronously
|
|
|
|
+ */
|
2014-11-07 01:31:52 +01:00
|
|
|
+ public void getChunkAtAsync(Location location, ChunkLoadCallback cb);
|
2016-03-01 00:09:49 +01:00
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Requests {@link Chunk} to be loaded that contains the given {@link Block}
|
|
|
|
+ *
|
|
|
|
+ * This method makes no guarantee on how fast the chunk will load,
|
|
|
|
+ * and will return the chunk to the callback at a later time.
|
|
|
|
+ *
|
|
|
|
+ * You should use this method if you need a chunk but do not need it
|
|
|
|
+ * immediately, and you wish to let the server control the speed
|
|
|
|
+ * of chunk loads, keeping performance in mind.
|
|
|
|
+ *
|
|
|
|
+ * The {@link ChunkLoadCallback} will always be executed synchronously
|
|
|
|
+ * on the main Server Thread.
|
|
|
|
+ *
|
|
|
|
+ * @param block Block to get the containing chunk from
|
|
|
|
+ * @param cb Callback to receive the chunk when it is loaded.
|
|
|
|
+ * will be executed synchronously
|
|
|
|
+ */
|
2014-11-07 01:31:52 +01:00
|
|
|
+ public void getChunkAtAsync(Block block, ChunkLoadCallback cb);
|
|
|
|
+
|
2016-03-01 00:09:49 +01:00
|
|
|
+ /**
|
2014-11-07 01:31:52 +01:00
|
|
|
* Checks if the specified {@link Chunk} is loaded
|
|
|
|
*
|
2016-03-01 00:09:49 +01:00
|
|
|
* @param chunk The chunk to check
|
2014-11-07 01:31:52 +01:00
|
|
|
--
|