13
0
geforkt von Mirrors/Paper

Added ChunkPopulateEvent, new "newChunk" property on ChunkLoadEvent

By: Dinnerbone <dinnerbone@dinnerbone.com>
Dieser Commit ist enthalten in:
Bukkit/Spigot 2011-06-16 19:32:14 +01:00
Ursprung caf78a759e
Commit ae44a5e666
5 geänderte Dateien mit 51 neuen und 4 gelöschten Zeilen

Datei anzeigen

@ -455,11 +455,13 @@ public abstract class Event implements Serializable {
*/ */
CHUNK_UNLOAD (Category.WORLD), 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 * Called when an ItemEntity spawns in the world
* *

Datei anzeigen

@ -6,7 +6,20 @@ import org.bukkit.Chunk;
* Called when a chunk is loaded * Called when a chunk is loaded
*/ */
public class ChunkLoadEvent extends ChunkEvent { 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); 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;
} }
} }

Datei anzeigen

@ -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);
}
}

Datei anzeigen

@ -15,6 +15,15 @@ public class WorldListener implements Listener {
*/ */
public void onChunkLoad(ChunkLoadEvent event) {} 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 * Called when a chunk is unloaded
* *

Datei anzeigen

@ -526,6 +526,13 @@ public final class JavaPluginLoader implements PluginLoader {
((WorldListener) listener).onChunkLoad((ChunkLoadEvent) event); ((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: case CHUNK_UNLOAD:
return new EventExecutor() { return new EventExecutor() {