Added Chunk events in new World category

By: Dinnerbone <dinnerbone@dinnerbone.com>
This commit is contained in:
Bukkit/Spigot
2011-01-04 14:08:56 +00:00
parent 5901415d13
commit 950ed1a52a
5 changed files with 117 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
package org.bukkit.event.world;
import org.bukkit.Chunk;
/**
* Called when a chunk is loaded
*/
public class ChunkLoadedEvent extends WorldEvent {
private final Chunk chunk;
public ChunkLoadedEvent(final Type type, final Chunk chunk) {
super(type, chunk.getWorld());
this.chunk = chunk;
}
/**
* Gets the chunk being loaded/unloaded
*
* @return Chunk that triggered this event
*/
public Chunk getChunk() {
return chunk;
}
}

View File

@@ -0,0 +1,25 @@
package org.bukkit.event.world;
import org.bukkit.Chunk;
import org.bukkit.event.Cancellable;
/**
* Called when a chunk is unloaded
*/
public class ChunkUnloadedEvent extends ChunkLoadedEvent implements Cancellable {
private boolean cancel = false;
public ChunkUnloadedEvent(final Type type, final Chunk chunk) {
super(type, chunk);
}
public boolean isCancelled() {
return cancel;
}
public void setCancelled(boolean cancel) {
this.cancel = cancel;
}
}

View File

@@ -0,0 +1,27 @@
package org.bukkit.event.world;
import org.bukkit.World;
import org.bukkit.event.Event;
/**
* Represents events within a world
*/
public class WorldEvent extends Event {
private final World world;
public WorldEvent(final Type type, final World world) {
super(type);
this.world = world;
}
/**
* Gets the world primarily involved with this event
*
* @return World which caused this event
*/
public World getWorld() {
return world;
}
}

View File

@@ -0,0 +1,25 @@
package org.bukkit.event.world;
import org.bukkit.event.Listener;
/**
* Handles all World related events
*/
public class WorldListener implements Listener {
/**
* Called when a chunk is loaded
*
* @param event Relevant event details
*/
public void onChunkLoaded(ChunkLoadedEvent event) {
}
/**
* Called when a chunk is unloaded
*
* @param event Relevant event details
*/
public void onChunkUnloaded(ChunkUnloadedEvent event) {
}
}