[Bleeding] Changed event system into a new, much faster design. Huge thanks to @zml2008 & @lahwran.

This commit is contained in:
Nathan Adams
2012-01-16 18:25:17 +00:00
committed by Erik Broes
parent 5c8bc62f26
commit e35037ab50
132 changed files with 1691 additions and 225 deletions

View File

@@ -6,7 +6,7 @@ import org.bukkit.Chunk;
* Represents a Chunk related event
*/
@SuppressWarnings("serial")
public class ChunkEvent extends WorldEvent {
public abstract class ChunkEvent extends WorldEvent {
protected Chunk chunk;
protected ChunkEvent(Type type, Chunk chunk) {

View File

@@ -1,12 +1,14 @@
package org.bukkit.event.world;
import org.bukkit.Chunk;
import org.bukkit.event.HandlerList;
/**
* Called when a chunk is loaded
*/
@SuppressWarnings("serial")
public class ChunkLoadEvent extends ChunkEvent {
private static final HandlerList handlers = new HandlerList();
private final boolean newChunk;
public ChunkLoadEvent(final Chunk chunk, final boolean newChunk) {
@@ -23,4 +25,13 @@ public class ChunkLoadEvent extends ChunkEvent {
public boolean isNewChunk() {
return newChunk;
}
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}

View File

@@ -1,6 +1,7 @@
package org.bukkit.event.world;
import org.bukkit.Chunk;
import org.bukkit.event.HandlerList;
import org.bukkit.generator.BlockPopulator;
/**
@@ -10,7 +11,17 @@ import org.bukkit.generator.BlockPopulator;
*/
@SuppressWarnings("serial")
public class ChunkPopulateEvent extends ChunkEvent {
private static final HandlerList handlers = new HandlerList();
public ChunkPopulateEvent(final Chunk chunk) {
super(Type.CHUNK_POPULATED, chunk);
}
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}

View File

@@ -2,12 +2,14 @@ package org.bukkit.event.world;
import org.bukkit.Chunk;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
/**
* Called when a chunk is unloaded
*/
@SuppressWarnings("serial")
public class ChunkUnloadEvent extends ChunkEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private boolean cancel = false;
public ChunkUnloadEvent(final Chunk chunk) {
@@ -21,4 +23,13 @@ public class ChunkUnloadEvent extends ChunkEvent implements Cancellable {
public void setCancelled(boolean cancel) {
this.cancel = cancel;
}
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}

View File

@@ -3,6 +3,8 @@ package org.bukkit.event.world;
import org.bukkit.block.Block;
import org.bukkit.World;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import java.util.ArrayList;
import java.util.Collection;
@@ -11,6 +13,7 @@ import java.util.Collection;
*/
@SuppressWarnings("serial")
public class PortalCreateEvent extends WorldEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private boolean cancel = false;
private ArrayList<Block> blocks = new ArrayList<Block>();
@@ -35,4 +38,13 @@ public class PortalCreateEvent extends WorldEvent implements Cancellable {
public void setCancelled(boolean cancel) {
this.cancel = cancel;
}
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}

View File

@@ -2,6 +2,7 @@ package org.bukkit.event.world;
import org.bukkit.World;
import org.bukkit.Location;
import org.bukkit.event.HandlerList;
/**
* An event that is called when a world's spawn changes. The
@@ -9,6 +10,7 @@ import org.bukkit.Location;
*/
@SuppressWarnings("serial")
public class SpawnChangeEvent extends WorldEvent {
private static final HandlerList handlers = new HandlerList();
private Location previousLocation;
public SpawnChangeEvent(World world, Location previousLocation) {
@@ -24,4 +26,13 @@ public class SpawnChangeEvent extends WorldEvent {
public Location getPreviousLocation() {
return previousLocation;
}
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}

View File

@@ -6,11 +6,13 @@ import org.bukkit.TreeType;
import org.bukkit.block.BlockState;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
/**
* Event that is called when an organic structure attempts to grow (Sapling -> Tree), (Mushroom -> Huge Mushroom), naturally or using bonemeal.
*/
public class StructureGrowEvent extends WorldEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private static final long serialVersionUID = 1L;
private boolean cancelled = false;
private Location location;
@@ -80,4 +82,13 @@ public class StructureGrowEvent extends WorldEvent implements Cancellable {
public void setCancelled(boolean cancel) {
cancelled = cancel;
}
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}

View File

@@ -7,7 +7,7 @@ import org.bukkit.event.Event;
* Represents events within a world
*/
@SuppressWarnings("serial")
public class WorldEvent extends Event {
public abstract class WorldEvent extends Event {
private final World world;
public WorldEvent(final Type type, final World world) {

View File

@@ -1,13 +1,24 @@
package org.bukkit.event.world;
import org.bukkit.World;
import org.bukkit.event.HandlerList;
/**
* Called when a World is initializing
*/
@SuppressWarnings("serial")
public class WorldInitEvent extends WorldEvent {
private static final HandlerList handlers = new HandlerList();
public WorldInitEvent(World world) {
super(Type.WORLD_INIT, world);
}
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}

View File

@@ -5,6 +5,7 @@ import org.bukkit.event.Listener;
/**
* Handles all World related events
*/
@Deprecated
public class WorldListener implements Listener {
/**

View File

@@ -1,13 +1,24 @@
package org.bukkit.event.world;
import org.bukkit.World;
import org.bukkit.event.HandlerList;
/**
* Called when a World is loaded
*/
@SuppressWarnings("serial")
public class WorldLoadEvent extends WorldEvent {
private static final HandlerList handlers = new HandlerList();
public WorldLoadEvent(World world) {
super(Type.WORLD_LOAD, world);
}
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}

View File

@@ -1,10 +1,21 @@
package org.bukkit.event.world;
import org.bukkit.World;
import org.bukkit.event.HandlerList;
@SuppressWarnings("serial")
public class WorldSaveEvent extends WorldEvent {
private static final HandlerList handlers = new HandlerList();
public WorldSaveEvent(World world) {
super(Type.WORLD_SAVE, world);
}
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}

View File

@@ -2,12 +2,14 @@ package org.bukkit.event.world;
import org.bukkit.World;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
/**
* Called when a World is unloaded
*/
@SuppressWarnings("serial")
public class WorldUnloadEvent extends WorldEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private boolean isCancelled;
public WorldUnloadEvent(World world) {
@@ -21,4 +23,13 @@ public class WorldUnloadEvent extends WorldEvent implements Cancellable {
public void setCancelled(boolean cancel) {
this.isCancelled = cancel;
}
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}