diff options
author | Dinnerbone <dinnerbone@dinnerbone.com> | 2011-06-16 19:32:14 +0100 |
---|---|---|
committer | Dinnerbone <dinnerbone@dinnerbone.com> | 2011-06-16 19:32:14 +0100 |
commit | 04494c5b07e43eba6f7974d81a59897c1d65d46b (patch) | |
tree | 18ce7ae876824d6a3fa56d333ece8ed0e0c47f10 | |
parent | 1b8709ff5643fbd0ab5d8b07135e6869effafffe (diff) | |
download | bukkit-04494c5b07e43eba6f7974d81a59897c1d65d46b.tar bukkit-04494c5b07e43eba6f7974d81a59897c1d65d46b.tar.gz bukkit-04494c5b07e43eba6f7974d81a59897c1d65d46b.tar.lz bukkit-04494c5b07e43eba6f7974d81a59897c1d65d46b.tar.xz bukkit-04494c5b07e43eba6f7974d81a59897c1d65d46b.zip |
Added ChunkPopulateEvent, new "newChunk" property on ChunkLoadEvent
5 files changed, 51 insertions, 4 deletions
diff --git a/src/main/java/org/bukkit/event/Event.java b/src/main/java/org/bukkit/event/Event.java index 2c00151c..079b4158 100644 --- a/src/main/java/org/bukkit/event/Event.java +++ b/src/main/java/org/bukkit/event/Event.java @@ -455,11 +455,13 @@ public abstract class Event implements Serializable { */ CHUNK_UNLOAD (Category.WORLD), /** - * Called when a chunk needs to be generated + * Called when a newly created chunk has been populated. * - * @todo: add javadoc see comment + * If your intent is to populate the chunk using this event, please see {@link BlockPopulator} + * + * @see org.bukkit.event.world.ChunkPopulateEvent */ - CHUNK_GENERATION (Category.WORLD), + CHUNK_POPULATED (Category.WORLD), /** * Called when an ItemEntity spawns in the world * diff --git a/src/main/java/org/bukkit/event/world/ChunkLoadEvent.java b/src/main/java/org/bukkit/event/world/ChunkLoadEvent.java index 207c1b55..9eb6cc42 100644 --- a/src/main/java/org/bukkit/event/world/ChunkLoadEvent.java +++ b/src/main/java/org/bukkit/event/world/ChunkLoadEvent.java @@ -6,7 +6,20 @@ import org.bukkit.Chunk; * Called when a chunk is loaded */ public class ChunkLoadEvent extends ChunkEvent { - public ChunkLoadEvent(final Chunk chunk) { + private final boolean newChunk; + + public ChunkLoadEvent(final Chunk chunk, final boolean newChunk) { super(Type.CHUNK_LOAD, chunk); + this.newChunk = newChunk; + } + + /** + * Gets if this chunk was newly created or not. + * Note that if this chunk is new, it will not be populated at this time. + * + * @return true if the chunk is new, otherwise false + */ + public boolean isNewChunk() { + return newChunk; } } diff --git a/src/main/java/org/bukkit/event/world/ChunkPopulateEvent.java b/src/main/java/org/bukkit/event/world/ChunkPopulateEvent.java new file mode 100644 index 00000000..3f8f6459 --- /dev/null +++ b/src/main/java/org/bukkit/event/world/ChunkPopulateEvent.java @@ -0,0 +1,16 @@ + +package org.bukkit.event.world; + +import org.bukkit.Chunk; +import org.bukkit.generator.BlockPopulator; + +/** + * Thrown when a new chunk has finished being populated. + * + * If your intent is to populate the chunk using this event, please see {@link BlockPopulator} + */ +public class ChunkPopulateEvent extends ChunkEvent { + public ChunkPopulateEvent(final Chunk chunk) { + super(Type.CHUNK_POPULATED, chunk); + } +} diff --git a/src/main/java/org/bukkit/event/world/WorldListener.java b/src/main/java/org/bukkit/event/world/WorldListener.java index ec50218a..55a13f8b 100644 --- a/src/main/java/org/bukkit/event/world/WorldListener.java +++ b/src/main/java/org/bukkit/event/world/WorldListener.java @@ -16,6 +16,15 @@ public class WorldListener implements Listener { public void onChunkLoad(ChunkLoadEvent event) {} /** + * Called when a newly created chunk has been populated. + * + * If your intent is to populate the chunk using this event, please see {@link BlockPopulator} + * + * @param event Relevant event details + */ + public void onChunkPopulate(ChunkPopulateEvent event) {} + + /** * Called when a chunk is unloaded * * @param event Relevant event details diff --git a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java index f757c234..c69b4720 100644 --- a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java +++ b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java @@ -526,6 +526,13 @@ public final class JavaPluginLoader implements PluginLoader { ((WorldListener) listener).onChunkLoad((ChunkLoadEvent) event); } }; + + case CHUNK_POPULATED: + return new EventExecutor() { + public void execute(Listener listener, Event event) { + ((WorldListener) listener).onChunkPopulate((ChunkPopulateEvent) event); + } + }; case CHUNK_UNLOAD: return new EventExecutor() { |