From e0c7fc6bf5af811ae5301d7b64da2611d7afaedf Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot Date: Mon, 16 Jan 2012 18:25:17 +0000 Subject: [PATCH] [Bleeding] Changed event system into a new, much faster design. Huge thanks to @zml2008 & @lahwran. By: Nathan Adams --- .../org/bukkit/event/CustomEventListener.java | 2 + .../src/main/java/org/bukkit/event/Event.java | 290 +++++++++++------- .../java/org/bukkit/event/EventException.java | 1 + .../java/org/bukkit/event/EventHandler.java | 15 + .../java/org/bukkit/event/EventPriority.java | 45 +++ .../java/org/bukkit/event/HandlerList.java | 133 ++++++++ .../bukkit/event/TransitionalCustomEvent.java | 18 ++ .../bukkit/event/block/BlockBreakEvent.java | 11 + .../bukkit/event/block/BlockBurnEvent.java | 11 + .../event/block/BlockCanBuildEvent.java | 11 + .../bukkit/event/block/BlockDamageEvent.java | 11 + .../event/block/BlockDispenseEvent.java | 11 + .../org/bukkit/event/block/BlockEvent.java | 2 +- .../bukkit/event/block/BlockFadeEvent.java | 11 + .../bukkit/event/block/BlockFormEvent.java | 11 + .../bukkit/event/block/BlockFromToEvent.java | 11 + .../bukkit/event/block/BlockIgniteEvent.java | 11 + .../org/bukkit/event/block/BlockListener.java | 1 + .../bukkit/event/block/BlockPhysicsEvent.java | 11 + .../event/block/BlockPistonExtendEvent.java | 11 + .../event/block/BlockPistonRetractEvent.java | 11 + .../bukkit/event/block/BlockPlaceEvent.java | 11 + .../event/block/BlockRedstoneEvent.java | 11 + .../bukkit/event/block/BlockSpreadEvent.java | 11 + .../bukkit/event/block/LeavesDecayEvent.java | 11 + .../bukkit/event/block/SignChangeEvent.java | 11 + .../event/entity/CreatureSpawnEvent.java | 11 + .../event/entity/CreeperPowerEvent.java | 11 + .../event/entity/EndermanPickupEvent.java | 11 + .../event/entity/EndermanPlaceEvent.java | 11 + .../event/entity/EntityCombustEvent.java | 11 + .../event/entity/EntityCreatePortalEvent.java | 11 + .../event/entity/EntityDamageEvent.java | 11 + .../bukkit/event/entity/EntityDeathEvent.java | 11 + .../org/bukkit/event/entity/EntityEvent.java | 2 +- .../event/entity/EntityExplodeEvent.java | 11 + .../event/entity/EntityInteractEvent.java | 11 + .../bukkit/event/entity/EntityListener.java | 1 + .../event/entity/EntityPortalEnterEvent.java | 11 + .../event/entity/EntityRegainHealthEvent.java | 11 + .../bukkit/event/entity/EntityTameEvent.java | 11 + .../event/entity/EntityTargetEvent.java | 11 + .../event/entity/ExplosionPrimeEvent.java | 11 + .../event/entity/FoodLevelChangeEvent.java | 11 + .../bukkit/event/entity/ItemDespawnEvent.java | 11 + .../bukkit/event/entity/ItemSpawnEvent.java | 11 + .../org/bukkit/event/entity/PigZapEvent.java | 11 + .../event/entity/ProjectileHitEvent.java | 11 + .../bukkit/event/entity/SlimeSplitEvent.java | 11 + .../event/inventory/FurnaceBurnEvent.java | 11 + .../event/inventory/FurnaceSmeltEvent.java | 11 + .../event/inventory/InventoryListener.java | 1 + .../event/painting/PaintingBreakEvent.java | 11 + .../bukkit/event/painting/PaintingEvent.java | 2 +- .../event/painting/PaintingPlaceEvent.java | 11 + .../event/player/PlayerAnimationEvent.java | 11 + .../event/player/PlayerBedEnterEvent.java | 11 + .../event/player/PlayerBedLeaveEvent.java | 11 + .../event/player/PlayerBucketEmptyEvent.java | 11 + .../event/player/PlayerBucketFillEvent.java | 11 + .../event/player/PlayerChangedWorldEvent.java | 11 + .../bukkit/event/player/PlayerChatEvent.java | 11 + .../player/PlayerCommandPreprocessEvent.java | 11 + .../event/player/PlayerDropItemEvent.java | 11 + .../event/player/PlayerEggThrowEvent.java | 11 + .../org/bukkit/event/player/PlayerEvent.java | 2 +- .../bukkit/event/player/PlayerFishEvent.java | 11 + .../player/PlayerGameModeChangeEvent.java | 11 + .../player/PlayerInteractEntityEvent.java | 11 + .../event/player/PlayerInteractEvent.java | 11 + .../event/player/PlayerInventoryEvent.java | 11 + .../event/player/PlayerItemHeldEvent.java | 11 + .../bukkit/event/player/PlayerJoinEvent.java | 11 + .../bukkit/event/player/PlayerKickEvent.java | 11 + .../bukkit/event/player/PlayerListener.java | 1 + .../bukkit/event/player/PlayerLoginEvent.java | 11 + .../bukkit/event/player/PlayerMoveEvent.java | 11 + .../event/player/PlayerPickupItemEvent.java | 11 + .../event/player/PlayerPortalEvent.java | 11 + .../event/player/PlayerPreLoginEvent.java | 11 + .../bukkit/event/player/PlayerQuitEvent.java | 11 + .../event/player/PlayerRespawnEvent.java | 11 + .../event/player/PlayerTeleportEvent.java | 11 + .../event/player/PlayerToggleSneakEvent.java | 11 + .../event/player/PlayerToggleSprintEvent.java | 11 + .../event/player/PlayerVelocityEvent.java | 11 + .../event/server/MapInitializeEvent.java | 11 + .../event/server/PluginDisableEvent.java | 11 + .../event/server/PluginEnableEvent.java | 11 + .../org/bukkit/event/server/PluginEvent.java | 2 +- .../event/server/ServerCommandEvent.java | 11 + .../org/bukkit/event/server/ServerEvent.java | 2 +- .../event/server/ServerListPingEvent.java | 11 + .../bukkit/event/server/ServerListener.java | 1 + .../vehicle/VehicleBlockCollisionEvent.java | 11 + .../event/vehicle/VehicleCollisionEvent.java | 2 +- .../event/vehicle/VehicleCreateEvent.java | 11 + .../event/vehicle/VehicleDamageEvent.java | 11 + .../event/vehicle/VehicleDestroyEvent.java | 11 + .../event/vehicle/VehicleEnterEvent.java | 11 + .../vehicle/VehicleEntityCollisionEvent.java | 11 + .../bukkit/event/vehicle/VehicleEvent.java | 2 +- .../event/vehicle/VehicleExitEvent.java | 11 + .../bukkit/event/vehicle/VehicleListener.java | 1 + .../event/vehicle/VehicleMoveEvent.java | 12 + .../event/vehicle/VehicleUpdateEvent.java | 11 + .../event/weather/LightningStrikeEvent.java | 11 + .../event/weather/ThunderChangeEvent.java | 11 + .../event/weather/WeatherChangeEvent.java | 11 + .../bukkit/event/weather/WeatherEvent.java | 2 +- .../bukkit/event/weather/WeatherListener.java | 1 + .../org/bukkit/event/world/ChunkEvent.java | 2 +- .../bukkit/event/world/ChunkLoadEvent.java | 11 + .../event/world/ChunkPopulateEvent.java | 11 + .../bukkit/event/world/ChunkUnloadEvent.java | 11 + .../bukkit/event/world/PortalCreateEvent.java | 12 + .../bukkit/event/world/SpawnChangeEvent.java | 11 + .../event/world/StructureGrowEvent.java | 11 + .../org/bukkit/event/world/WorldEvent.java | 2 +- .../bukkit/event/world/WorldInitEvent.java | 11 + .../org/bukkit/event/world/WorldListener.java | 1 + .../bukkit/event/world/WorldLoadEvent.java | 11 + .../bukkit/event/world/WorldSaveEvent.java | 11 + .../bukkit/event/world/WorldUnloadEvent.java | 11 + .../java/org/bukkit/plugin/EventExecutor.java | 3 +- .../java/org/bukkit/plugin/PluginLoader.java | 12 + .../java/org/bukkit/plugin/PluginManager.java | 24 +- .../org/bukkit/plugin/RegisteredListener.java | 17 +- .../bukkit/plugin/SimplePluginManager.java | 182 ++++++----- .../bukkit/plugin/java/JavaPluginLoader.java | 52 +++- .../bukkit/plugin/messaging/Messenger.java | 2 +- .../file/YamlConfigurationTest.java | 10 +- 132 files changed, 1691 insertions(+), 225 deletions(-) create mode 100644 paper-api/src/main/java/org/bukkit/event/EventHandler.java create mode 100644 paper-api/src/main/java/org/bukkit/event/EventPriority.java create mode 100644 paper-api/src/main/java/org/bukkit/event/HandlerList.java create mode 100644 paper-api/src/main/java/org/bukkit/event/TransitionalCustomEvent.java diff --git a/paper-api/src/main/java/org/bukkit/event/CustomEventListener.java b/paper-api/src/main/java/org/bukkit/event/CustomEventListener.java index 7fdf9b9af2..afdf924a6f 100644 --- a/paper-api/src/main/java/org/bukkit/event/CustomEventListener.java +++ b/paper-api/src/main/java/org/bukkit/event/CustomEventListener.java @@ -5,7 +5,9 @@ import org.bukkit.event.Listener; /** * Handles all custom events */ +@Deprecated public class CustomEventListener implements Listener { + private static final HandlerList handlers = new HandlerList(); public CustomEventListener() {} /** diff --git a/paper-api/src/main/java/org/bukkit/event/Event.java b/paper-api/src/main/java/org/bukkit/event/Event.java index 90ff6dbdb9..7dc9e82e61 100644 --- a/paper-api/src/main/java/org/bukkit/event/Event.java +++ b/paper-api/src/main/java/org/bukkit/event/Event.java @@ -1,14 +1,27 @@ package org.bukkit.event; import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; -import org.bukkit.entity.Projectile; +import org.bukkit.event.block.*; +import org.bukkit.event.entity.*; +import org.bukkit.event.inventory.*; +import org.bukkit.event.painting.*; +import org.bukkit.event.player.*; +import org.bukkit.event.server.*; +import org.bukkit.event.vehicle.*; +import org.bukkit.event.weather.*; +import org.bukkit.event.world.*; /** * Represents an event */ @SuppressWarnings("serial") public abstract class Event implements Serializable { + @Deprecated + private final static Map customHandlers = new HashMap(); + @Deprecated private final Type type; private final String name; @@ -16,7 +29,12 @@ public abstract class Event implements Serializable { exAssert(type != null, "type is null"); exAssert(type != Type.CUSTOM_EVENT, "use Event(String) to make custom events"); this.type = type; - this.name = null; + this.name = getClass().getName(); + } + + protected Event() { + this.type = Type.FIXED_EVENT; + this.name = getClass().getName(); } protected Event(final String name) { @@ -30,6 +48,7 @@ public abstract class Event implements Serializable { * * @return Event type that this object represents */ + @Deprecated public final Type getType() { return type; } @@ -46,47 +65,73 @@ public abstract class Event implements Serializable { * @return Name of this event */ public final String getEventName() { - return (type != Type.CUSTOM_EVENT) ? type.toString() : name; + return name; + } + + public HandlerList getHandlers() { + if (type == Type.CUSTOM_EVENT) { + HandlerList result = customHandlers.get(getEventName()); + + if (result == null) { + result = new HandlerList(); + customHandlers.put(getEventName(), result); + } + + return result; + } else { + throw new IllegalStateException("Event must implement getHandlers()"); + } } /** * Represents an events priority in execution */ + @Deprecated public enum Priority { /** * Event call is of very low importance and should be ran first, to allow * other plugins to further customise the outcome */ - Lowest, + Lowest(EventPriority.LOWEST), /** * Event call is of low importance */ - Low, + Low(EventPriority.LOW), /** * Event call is neither important or unimportant, and may be ran normally */ - Normal, + Normal(EventPriority.NORMAL), /** * Event call is of high importance */ - High, + High(EventPriority.HIGH), /** * Event call is critical and must have the final say in what happens * to the event */ - Highest, + Highest(EventPriority.HIGHEST), /** * Event is listened to purely for monitoring the outcome of an event. *

* No modifications to the event should be made under this priority */ - Monitor + Monitor(EventPriority.MONITOR); + + private final EventPriority priority; + private Priority(EventPriority priority) { + this.priority = priority; + } + + public EventPriority getNewPriority() { + return priority; + } } /** * Represents a category used by Type */ + @Deprecated public enum Category { /** @@ -136,6 +181,7 @@ public abstract class Event implements Serializable { /** * Provides a lookup for all core events */ + @Deprecated public enum Type { /** @@ -147,178 +193,176 @@ public abstract class Event implements Serializable { * * @see org.bukkit.event.player.PlayerJoinEvent */ - PLAYER_JOIN(Category.PLAYER), + PLAYER_JOIN(Category.PLAYER, PlayerJoinEvent.class), /** * Called when a player is attempting to connect to the server * * @see org.bukkit.event.player.PlayerLoginEvent */ - PLAYER_LOGIN(Category.PLAYER), + PLAYER_LOGIN(Category.PLAYER, PlayerLoginEvent.class), /** * Called when a player has just been authenticated * * @see org.bukkit.event.player.PlayerPreLoginEvent */ - PLAYER_PRELOGIN(Category.PLAYER), + PLAYER_PRELOGIN(Category.PLAYER, PlayerPreLoginEvent.class), /** * Called when a player respawns * * @see org.bukkit.event.player.PlayerRespawnEvent */ - PLAYER_RESPAWN(Category.PLAYER), + PLAYER_RESPAWN(Category.PLAYER, PlayerRespawnEvent.class), /** * Called when a player gets kicked from the server * * @see org.bukkit.event.player.PlayerKickEvent */ - PLAYER_KICK(Category.PLAYER), + PLAYER_KICK(Category.PLAYER, PlayerKickEvent.class), /** * Called when a player sends a chat message * * @see org.bukkit.event.player.PlayerChatEvent */ - PLAYER_CHAT(Category.PLAYER), + PLAYER_CHAT(Category.PLAYER, PlayerChatEvent.class), /** * Called when a player uses a command (early in the command handling process) * * @see org.bukkit.event.player.PlayerCommandPreprocessEvent */ - PLAYER_COMMAND_PREPROCESS(Category.PLAYER), + PLAYER_COMMAND_PREPROCESS(Category.PLAYER, PlayerCommandPreprocessEvent.class), /** * Called when a player leaves the server * * @see org.bukkit.event.player.PlayerQuitEvent */ - PLAYER_QUIT(Category.PLAYER), + PLAYER_QUIT(Category.PLAYER, PlayerQuitEvent.class), /** * Called when a player moves position in the world * * @see org.bukkit.event.player.PlayerMoveEvent */ - PLAYER_MOVE(Category.PLAYER), + PLAYER_MOVE(Category.PLAYER, PlayerMoveEvent.class), /** * Called before a player gets a velocity vector sent, which will instruct him to * get "pushed" into a specific direction, e.g. after an explosion * * @see org.bukkit.event.player.PlayerVelocityEvent */ - PLAYER_VELOCITY(Category.PLAYER), + PLAYER_VELOCITY(Category.PLAYER, PlayerVelocityEvent.class), /** * Called when a player undergoes an animation (Arm Swing is the only animation currently supported) * * @see org.bukkit.event.player.PlayerAnimationEvent */ - PLAYER_ANIMATION(Category.PLAYER), + PLAYER_ANIMATION(Category.PLAYER, PlayerAnimationEvent.class), /** * Called when a player toggles sneak mode * * @see org.bukkit.event.player.PlayerToggleSneakEvent */ - PLAYER_TOGGLE_SNEAK(Category.PLAYER), + PLAYER_TOGGLE_SNEAK(Category.PLAYER, PlayerToggleSneakEvent.class), /** * Called when a player toggles sprint mode * * @see org.bukkit.event.player.PlayerToggleSprintEvent */ - PLAYER_TOGGLE_SPRINT(Category.PLAYER), + PLAYER_TOGGLE_SPRINT(Category.PLAYER, PlayerToggleSprintEvent.class), /** * Called when a player interacts with an object or air * * @see org.bukkit.event.player.PlayerInteractEvent */ - PLAYER_INTERACT(Category.PLAYER), + PLAYER_INTERACT(Category.PLAYER, PlayerInteractEvent.class), /** * Called when a player right clicks an entity * * @see org.bukkit.event.player.PlayerInteractEntityEvent */ - PLAYER_INTERACT_ENTITY(Category.PLAYER), + PLAYER_INTERACT_ENTITY(Category.PLAYER, PlayerInteractEntityEvent.class), /** * Called when a player throws an egg * * @see org.bukkit.event.player.PlayerEggThrowEvent */ - PLAYER_EGG_THROW(Category.PLAYER), + PLAYER_EGG_THROW(Category.PLAYER, PlayerEggThrowEvent.class), /** * Called when a player teleports from one position to another * * @see org.bukkit.event.player.PlayerTeleportEvent */ - PLAYER_TELEPORT(Category.PLAYER), + PLAYER_TELEPORT(Category.PLAYER, PlayerTeleportEvent.class), /** * Called when a player completes the portaling process by standing in a portal * * @see org.bukkit.event.player.PlayerPortalEvent */ - PLAYER_PORTAL(Category.PLAYER), + PLAYER_PORTAL(Category.PLAYER, PlayerPortalEvent.class), /** * Called when a player changes their held item * * @see org.bukkit.event.player.PlayerItemHeldEvent */ - PLAYER_ITEM_HELD(Category.PLAYER), + PLAYER_ITEM_HELD(Category.PLAYER, PlayerItemHeldEvent.class), /** * Called when a player drops an item * * @see org.bukkit.event.player.PlayerDropItemEvent */ - PLAYER_DROP_ITEM(Category.PLAYER), + PLAYER_DROP_ITEM(Category.PLAYER, PlayerDropItemEvent.class), /** * Called when a player picks an item up off the ground * * @see org.bukkit.event.player.PlayerPickupItemEvent */ - PLAYER_PICKUP_ITEM(Category.PLAYER), + PLAYER_PICKUP_ITEM(Category.PLAYER, PlayerPickupItemEvent.class), /** * Called when a player empties a bucket * * @see org.bukkit.event.player.PlayerBucketEmptyEvent */ - PLAYER_BUCKET_EMPTY(Category.PLAYER), + PLAYER_BUCKET_EMPTY(Category.PLAYER, PlayerBucketEmptyEvent.class), /** * Called when a player fills a bucket * * @see org.bukkit.event.player.PlayerBucketFillEvent */ - PLAYER_BUCKET_FILL(Category.PLAYER), + PLAYER_BUCKET_FILL(Category.PLAYER, PlayerBucketFillEvent.class), /** * Called when a player interacts with the inventory * * @see org.bukkit.event.player.PlayerInventoryEvent */ - PLAYER_INVENTORY(Category.PLAYER), + PLAYER_INVENTORY(Category.PLAYER, PlayerInventoryEvent.class), /** * Called when a player enter a bed * * @see org.bukkit.event.player.PlayerBedEnterEvent */ - PLAYER_BED_ENTER(Category.PLAYER), + PLAYER_BED_ENTER(Category.PLAYER, PlayerBedEnterEvent.class), /** * Called when a player leaves a bed * * @see org.bukkit.event.player.PlayerBedLeaveEvent */ - PLAYER_BED_LEAVE(Category.PLAYER), + PLAYER_BED_LEAVE(Category.PLAYER, PlayerBedLeaveEvent.class), /** * Called when a player is fishing * * @see org.bukkit.event.player.PlayerFishEvent */ - PLAYER_FISH(Category.PLAYER), - + PLAYER_FISH(Category.PLAYER, PlayerFishEvent.class), /** * Called when the game mode of a player is changed * * @see org.bukkit.event.player.PlayerGameModeChangeEvent */ - PLAYER_GAME_MODE_CHANGE(Category.PLAYER), - + PLAYER_GAME_MODE_CHANGE(Category.PLAYER, PlayerGameModeChangeEvent.class), /** * Called after a player has changed to a new world * * @see org.bukkit.event.player.PlayerChangedWorldEvent */ - PLAYER_CHANGED_WORLD(Category.PLAYER), + PLAYER_CHANGED_WORLD(Category.PLAYER, PlayerChangedWorldEvent.class), /** * BLOCK EVENTS @@ -329,7 +373,7 @@ public abstract class Event implements Serializable { * * @see org.bukkit.event.block.BlockDamageEvent */ - BLOCK_DAMAGE(Category.BLOCK), + BLOCK_DAMAGE(Category.BLOCK, BlockDamageEvent.class), /** * Called when a block is undergoing a universe physics * check on whether it can be built @@ -338,21 +382,21 @@ public abstract class Event implements Serializable { * * @see org.bukkit.event.block.BlockCanBuildEvent */ - BLOCK_CANBUILD(Category.BLOCK), + BLOCK_CANBUILD(Category.BLOCK, BlockCanBuildEvent.class), /** * Called when a block of water or lava attempts to flow into another * block * * @see org.bukkit.event.block.BlockFromToEvent */ - BLOCK_FROMTO(Category.BLOCK), + BLOCK_FROMTO(Category.BLOCK, BlockFromToEvent.class), /** * Called when a block is being set on fire from another block, such as * an adjacent block of fire attempting to set fire to wood * * @see org.bukkit.event.block.BlockIgniteEvent */ - BLOCK_IGNITE(Category.BLOCK), + BLOCK_IGNITE(Category.BLOCK, BlockIgniteEvent.class), /** * Called when a block undergoes a physics check *

@@ -361,37 +405,37 @@ public abstract class Event implements Serializable { * * @see org.bukkit.event.block.BlockPhysicsEvent */ - BLOCK_PHYSICS(Category.BLOCK), + BLOCK_PHYSICS(Category.BLOCK, BlockPhysicsEvent.class), /** * Called when a player is attempting to place a block * * @see org.bukkit.event.block.BlockPlaceEvent */ - BLOCK_PLACE(Category.BLOCK), + BLOCK_PLACE(Category.BLOCK, BlockPlaceEvent.class), /** * Called when a block dispenses something * * @see org.bukkit.event.block.BlockDispenseEvent */ - BLOCK_DISPENSE(Category.BLOCK), + BLOCK_DISPENSE(Category.BLOCK, BlockDispenseEvent.class), /** * Called when a block is destroyed from being burnt by fire * * @see org.bukkit.event.block.BlockBurnEvent */ - BLOCK_BURN(Category.BLOCK), + BLOCK_BURN(Category.BLOCK, BlockBurnEvent.class), /** * Called when leaves are decaying naturally * * @see org.bukkit.event.block.LeavesDecayEvent */ - LEAVES_DECAY(Category.BLOCK), + LEAVES_DECAY(Category.BLOCK, LeavesDecayEvent.class), /** * Called when a sign is changed * * @see org.bukkit.event.block.SignChangeEvent */ - SIGN_CHANGE(Category.BLOCK), + SIGN_CHANGE(Category.BLOCK, SignChangeEvent.class), /** * Called when a block changes redstone current. Only triggered on blocks * that are actually capable of transmitting or carrying a redstone @@ -399,44 +443,43 @@ public abstract class Event implements Serializable { * * @see org.bukkit.event.block.BlockRedstoneEvent */ - REDSTONE_CHANGE(Category.BLOCK), + REDSTONE_CHANGE(Category.BLOCK, BlockRedstoneEvent.class), /** * Called when a block is broken by a player * * @see org.bukkit.event.block.BlockBreakEvent */ - BLOCK_BREAK(Category.BLOCK), + BLOCK_BREAK(Category.BLOCK, BlockBreakEvent.class), /** * Called when a block is formed based on world conditions * * @see org.bukkit.event.block.BlockFormEvent */ - BLOCK_FORM(Category.BLOCK), + BLOCK_FORM(Category.BLOCK, BlockFormEvent.class), /** * Called when a block spreads based on world conditions * * @see org.bukkit.event.block.BlockSpreadEvent */ - BLOCK_SPREAD(Category.BLOCK), + BLOCK_SPREAD(Category.BLOCK, BlockSpreadEvent.class), /** * Called when a block fades, melts or disappears based on world conditions * * @see org.bukkit.event.block.BlockFadeEvent */ - BLOCK_FADE(Category.BLOCK), + BLOCK_FADE(Category.BLOCK, BlockFadeEvent.class), /** * Called when a piston extends * * @see org.bukkit.event.block.BlockPistonExtendEvent */ - BLOCK_PISTON_EXTEND(Category.BLOCK), + BLOCK_PISTON_EXTEND(Category.BLOCK, BlockPistonExtendEvent.class), /** * Called when a piston retracts * * @see org.bukkit.event.block.BlockPistonRetractEvent */ - BLOCK_PISTON_RETRACT(Category.BLOCK), - + BLOCK_PISTON_RETRACT(Category.BLOCK, BlockPistonRetractEvent.class), /** * INVENTORY EVENTS */ @@ -446,44 +489,43 @@ public abstract class Event implements Serializable { * * @todo: add javadoc see comment */ - INVENTORY_OPEN(Category.INVENTORY), + INVENTORY_OPEN(Category.INVENTORY, null), /** * Called when a player closes an inventory * * @todo: add javadoc see comment */ - INVENTORY_CLOSE(Category.INVENTORY), + INVENTORY_CLOSE(Category.INVENTORY, null), /** * Called when a player clicks on an inventory slot * * @todo: add javadoc see comment */ - INVENTORY_CLICK(Category.INVENTORY), + INVENTORY_CLICK(Category.INVENTORY, null), /** * Called when an inventory slot changes values or type * * @todo: add javadoc see comment */ - INVENTORY_CHANGE(Category.INVENTORY), + INVENTORY_CHANGE(Category.INVENTORY, null), /** * Called when a player is attempting to perform an inventory transaction * * @todo: add javadoc see comment */ - INVENTORY_TRANSACTION(Category.INVENTORY), + INVENTORY_TRANSACTION(Category.INVENTORY, null), /** * Called when an ItemStack is successfully smelted in a furnace. * * @see org.bukkit.event.inventory.FurnaceSmeltEvent */ - FURNACE_SMELT(Category.INVENTORY), + FURNACE_SMELT(Category.INVENTORY, FurnaceSmeltEvent.class), /** * Called when an ItemStack is successfully burned as fuel in a furnace. * * @see org.bukkit.event.inventory.FurnaceBurnEvent */ - FURNACE_BURN(Category.INVENTORY), - + FURNACE_BURN(Category.INVENTORY, FurnaceBurnEvent.class), /** * SERVER EVENTS */ @@ -493,37 +535,37 @@ public abstract class Event implements Serializable { * * @see org.bukkit.event.server.PluginEnableEvent */ - PLUGIN_ENABLE(Category.SERVER), + PLUGIN_ENABLE(Category.SERVER, PluginEnableEvent.class), /** * Called when a plugin is disabled * * @see org.bukkit.event.server.PluginDisableEvent */ - PLUGIN_DISABLE(Category.SERVER), + PLUGIN_DISABLE(Category.SERVER, PluginDisableEvent.class), /** * Called when a server command is called * * @see org.bukkit.event.server.ServerCommandEvent */ - SERVER_COMMAND(Category.SERVER), + SERVER_COMMAND(Category.SERVER, ServerCommandEvent.class), /** * Called when a remote server command is called * * @see org.bukkit.event.server.ServerCommandEvent */ - REMOTE_COMMAND(Category.SERVER), + REMOTE_COMMAND(Category.SERVER, ServerCommandEvent.class), /** * Called when a map is initialized (created or loaded into memory) * * @see org.bukkit.event.server.MapInitializeEvent */ - MAP_INITIALIZE(Category.SERVER), + MAP_INITIALIZE(Category.SERVER, MapInitializeEvent.class), /** * Called when a client pings a server. * * @see org.bukkit.event.server.ServerListPingEvent */ - SERVER_LIST_PING(Category.SERVER), + SERVER_LIST_PING(Category.SERVER, ServerListPingEvent.class), /** * WORLD EVENTS @@ -537,13 +579,13 @@ public abstract class Event implements Serializable { * * @see org.bukkit.event.world.ChunkLoadEvent */ - CHUNK_LOAD(Category.WORLD), + CHUNK_LOAD(Category.WORLD, ChunkLoadEvent.class), /** * Called when a chunk is unloaded * * @see org.bukkit.event.world.ChunkUnloadEvent */ - CHUNK_UNLOAD(Category.WORLD), + CHUNK_UNLOAD(Category.WORLD, ChunkUnloadEvent.class), /** * Called when a newly created chunk has been populated. *

@@ -551,61 +593,61 @@ public abstract class Event implements Serializable { * * @see org.bukkit.event.world.ChunkPopulateEvent */ - CHUNK_POPULATED(Category.WORLD), + CHUNK_POPULATED(Category.WORLD, ChunkPopulateEvent.class), /** * Called when an ItemEntity spawns in the world * * @see org.bukkit.event.entity.ItemSpawnEvent */ - ITEM_SPAWN(Category.WORLD), + ITEM_SPAWN(Category.WORLD, ItemSpawnEvent.class), /** * Called when a World's spawn is changed * * @see org.bukkit.event.world.SpawnChangeEvent */ - SPAWN_CHANGE(Category.WORLD), + SPAWN_CHANGE(Category.WORLD, SpawnChangeEvent.class), /** * Called when a world is saved * * @see org.bukkit.event.world.WorldSaveEvent */ - WORLD_SAVE(Category.WORLD), + WORLD_SAVE(Category.WORLD, WorldSaveEvent.class), /** * Called when a World is initializing * * @see org.bukkit.event.world.WorldInitEvent */ - WORLD_INIT(Category.WORLD), + WORLD_INIT(Category.WORLD, WorldInitEvent.class), /** * Called when a World is loaded * * @see org.bukkit.event.world.WorldLoadEvent */ - WORLD_LOAD(Category.WORLD), + WORLD_LOAD(Category.WORLD, WorldLoadEvent.class), /** * Called when a World is unloaded * * @see org.bukkit.event.world.WorldUnloadEvent */ - WORLD_UNLOAD(Category.WORLD), + WORLD_UNLOAD(Category.WORLD, WorldUnloadEvent.class), /** * Called when world attempts to create a matching end to a portal * * @see org.bukkit.event.world.PortalCreateEvent */ - PORTAL_CREATE(Category.WORLD), + PORTAL_CREATE(Category.WORLD, PortalCreateEvent.class), /** * Called when an organic structure attempts to grow (Sapling -> Tree), (Mushroom -> Huge Mushroom), naturally or using bonemeal. * * @see org.bukkit.event.world.StructureGrowEvent */ - STRUCTURE_GROW(Category.WORLD), + STRUCTURE_GROW(Category.WORLD, StructureGrowEvent.class), /** * Called when an item despawns from a world * * @see org.bukkit.event.entity.ItemDespawnEvent */ - ITEM_DESPAWN(Category.WORLD), + ITEM_DESPAWN(Category.WORLD, ItemDespawnEvent.class), /** * ENTITY EVENTS @@ -616,19 +658,19 @@ public abstract class Event implements Serializable { * * @see org.bukkit.event.painting.PaintingPlaceEvent */ - PAINTING_PLACE(Category.ENTITY), + PAINTING_PLACE(Category.ENTITY, PaintingPlaceEvent.class), /** * Called when a painting is removed * * @see org.bukkit.event.painting.PaintingBreakEvent */ - PAINTING_BREAK(Category.ENTITY), + PAINTING_BREAK(Category.ENTITY, PaintingBreakEvent.class), /** * Called when an entity touches a portal block * * @see org.bukkit.event.entity.EntityPortalEnterEvent */ - ENTITY_PORTAL_ENTER(Category.ENTITY), + ENTITY_PORTAL_ENTER(Category.ENTITY, EntityPortalEnterEvent.class), /** * LIVING_ENTITY EVENTS @@ -640,31 +682,31 @@ public abstract class Event implements Serializable { * * @see org.bukkit.event.entity.CreatureSpawnEvent */ - CREATURE_SPAWN(Category.LIVING_ENTITY), + CREATURE_SPAWN(Category.LIVING_ENTITY, CreatureSpawnEvent.class), /** * Called when a LivingEntity is damaged with no source. * * @see org.bukkit.event.entity.EntityDamageEvent */ - ENTITY_DAMAGE(Category.LIVING_ENTITY), + ENTITY_DAMAGE(Category.LIVING_ENTITY, EntityDamageEvent.class), /** * Called when a LivingEntity dies * * @see org.bukkit.event.entity.EntityDeathEvent */ - ENTITY_DEATH(Category.LIVING_ENTITY), + ENTITY_DEATH(Category.LIVING_ENTITY, EntityDeathEvent.class), /** * Called when a Skeleton or Zombie catch fire due to the sun * * @see org.bukkit.event.entity.EntityCombustEvent */ - ENTITY_COMBUST(Category.LIVING_ENTITY), + ENTITY_COMBUST(Category.LIVING_ENTITY, EntityCombustEvent.class), /** * Called when an entity explodes, either TNT, Creeper, or Ghast Fireball * * @see org.bukkit.event.entity.EntityExplodeEvent */ - ENTITY_EXPLODE(Category.LIVING_ENTITY), + ENTITY_EXPLODE(Category.LIVING_ENTITY, EntityExplodeEvent.class), /** * Called when an entity has made a decision to explode. *

@@ -677,80 +719,80 @@ public abstract class Event implements Serializable { * * @see org.bukkit.event.entity.ExplosionPrimeEvent */ - EXPLOSION_PRIME(Category.LIVING_ENTITY), + EXPLOSION_PRIME(Category.LIVING_ENTITY, ExplosionPrimeEvent.class), /** * Called when an entity targets another entity * * @see org.bukkit.event.entity.EntityTargetEvent */ - ENTITY_TARGET(Category.LIVING_ENTITY), + ENTITY_TARGET(Category.LIVING_ENTITY, EntityTargetEvent.class), /** * Called when an entity interacts with a block * This event specifically excludes player entities * * @see org.bukkit.event.entity.EntityInteractEvent */ - ENTITY_INTERACT(Category.LIVING_ENTITY), + ENTITY_INTERACT(Category.LIVING_ENTITY, EntityInteractEvent.class), /** * Called when a creeper gains or loses a power shell * * @see org.bukkit.event.entity.CreeperPowerEvent */ - CREEPER_POWER(Category.LIVING_ENTITY), + CREEPER_POWER(Category.LIVING_ENTITY, CreeperPowerEvent.class), /** * Called when a pig is zapped, zombifying it * * @see org.bukkit.event.entity.PigZapEvent */ - PIG_ZAP(Category.LIVING_ENTITY), + PIG_ZAP(Category.LIVING_ENTITY, PigZapEvent.class), /** * Called when a LivingEntity is tamed * * @see org.bukkit.event.entity.EntityTameEvent */ - ENTITY_TAME(Category.LIVING_ENTITY), + ENTITY_TAME(Category.LIVING_ENTITY, EntityTameEvent.class), /** * Called when a {@link Projectile} hits something * * @see org.bukkit.event.entity.ProjectileHitEvent */ - PROJECTILE_HIT(Category.ENTITY), + PROJECTILE_HIT(Category.ENTITY, ProjectileHitEvent.class), /** * Called when a Slime splits into smaller Slimes upon death * * @see org.bukkit.event.entity.SlimeSplitEvent */ - SLIME_SPLIT(Category.LIVING_ENTITY), + SLIME_SPLIT(Category.LIVING_ENTITY, SlimeSplitEvent.class), /** * Called when a LivingEntity is regains health * * @see org.bukkit.event.entity.EntityRegainHealthEvent */ - ENTITY_REGAIN_HEALTH(Category.LIVING_ENTITY), + ENTITY_REGAIN_HEALTH(Category.LIVING_ENTITY, EntityRegainHealthEvent.class), /** * Called when an Enderman picks a block up * * @see org.bukkit.event.entity.EndermanPickupEvent */ - ENDERMAN_PICKUP(Category.LIVING_ENTITY), + ENDERMAN_PICKUP(Category.LIVING_ENTITY, EndermanPickupEvent.class), /** * Called when an Enderman places a block * * @see org.bukkit.event.entity.EndermanPlaceEvent */ - ENDERMAN_PLACE(Category.LIVING_ENTITY), + ENDERMAN_PLACE(Category.LIVING_ENTITY, EndermanPlaceEvent.class), /** * Called when a human entity's food level changes * * @see org.bukkit.event.entity.FoodLevelChangeEvent */ - FOOD_LEVEL_CHANGE(Category.LIVING_ENTITY), + FOOD_LEVEL_CHANGE(Category.LIVING_ENTITY, FoodLevelChangeEvent.class), /** * Called when an entity creates a portal in a world * * @see org.bukkit.event.entity.EntityCreatePortalEvent */ - ENTITY_CREATE_PORTAL(Category.LIVING_ENTITY), + ENTITY_CREATE_PORTAL(Category.LIVING_ENTITY, EntityCreatePortalEvent.class), /** * WEATHER EVENTS @@ -761,19 +803,19 @@ public abstract class Event implements Serializable { * * @see org.bukkit.event.weather.LightningStrikeEvent */ - LIGHTNING_STRIKE(Category.WEATHER), + LIGHTNING_STRIKE(Category.WEATHER, LightningStrikeEvent.class), /** * Called when the weather in a world changes * * @see org.bukkit.event.weather.WeatherChangeEvent */ - WEATHER_CHANGE(Category.WEATHER), + WEATHER_CHANGE(Category.WEATHER, WeatherChangeEvent.class), /** * Called when the thunder state in a world changes * * @see org.bukkit.event.weather.ThunderChangeEvent */ - THUNDER_CHANGE(Category.WEATHER), + THUNDER_CHANGE(Category.WEATHER, ThunderChangeEvent.class), /** * VEHICLE EVENTS @@ -784,55 +826,55 @@ public abstract class Event implements Serializable { * * @see org.bukkit.event.vehicle.VehicleCreateEvent */ - VEHICLE_CREATE(Category.VEHICLE), + VEHICLE_CREATE(Category.VEHICLE, VehicleCreateEvent.class), /** * Called when a vehicle is destroyed * * @see org.bukkit.event.vehicle.VehicleDestroyEvent */ - VEHICLE_DESTROY(Category.VEHICLE), + VEHICLE_DESTROY(Category.VEHICLE, VehicleDestroyEvent.class), /** * Called when a vehicle is damaged by a LivingEntity * * @see org.bukkit.event.vehicle.VehicleDamageEvent */ - VEHICLE_DAMAGE(Category.VEHICLE), + VEHICLE_DAMAGE(Category.VEHICLE, VehicleDamageEvent.class), /** * Called when a vehicle collides with an Entity * * @see org.bukkit.event.vehicle.VehicleCollisionEvent */ - VEHICLE_COLLISION_ENTITY(Category.VEHICLE), + VEHICLE_COLLISION_ENTITY(Category.VEHICLE, VehicleEntityCollisionEvent.class), /** * Called when a vehicle collides with a Block * * @see org.bukkit.event.vehicle.VehicleBlockCollisionEvent */ - VEHICLE_COLLISION_BLOCK(Category.VEHICLE), + VEHICLE_COLLISION_BLOCK(Category.VEHICLE, VehicleBlockCollisionEvent.class), /** * Called when a vehicle is entered by a LivingEntity * * @see org.bukkit.event.vehicle.VehicleEnterEvent */ - VEHICLE_ENTER(Category.VEHICLE), + VEHICLE_ENTER(Category.VEHICLE, VehicleEnterEvent.class), /** * Called when a vehicle is exited by a LivingEntity * * @see org.bukkit.event.vehicle.VehicleExitEvent */ - VEHICLE_EXIT(Category.VEHICLE), + VEHICLE_EXIT(Category.VEHICLE, VehicleExitEvent.class), /** * Called when a vehicle moves position in the world * * @see org.bukkit.event.vehicle.VehicleMoveEvent */ - VEHICLE_MOVE(Category.VEHICLE), + VEHICLE_MOVE(Category.VEHICLE, VehicleMoveEvent.class), /** * Called when a vehicle is going through an update cycle, rechecking itself * * @see org.bukkit.event.vehicle.VehicleUpdateEvent */ - VEHICLE_UPDATE(Category.VEHICLE), + VEHICLE_UPDATE(Category.VEHICLE, VehicleUpdateEvent.class), /** * MISCELLANEOUS EVENTS */ @@ -840,12 +882,18 @@ public abstract class Event implements Serializable { /** * Represents a custom event, isn't actually used */ - CUSTOM_EVENT(Category.MISCELLANEOUS); + CUSTOM_EVENT(Category.MISCELLANEOUS, TransitionalCustomEvent.class), + /** + * Represents an event using the new, Event.Type-less event system to avoid NPE-ing + */ + FIXED_EVENT(Category.MISCELLANEOUS, Event.class); private final Category category; + private final Class clazz; - private Type(Category category) { + private Type(Category category, Class clazz) { this.category = category; + this.clazz = clazz; } /** @@ -856,6 +904,10 @@ public abstract class Event implements Serializable { public Category getCategory() { return category; } + + public Class getEventClass() { + return clazz; + } } public enum Result { diff --git a/paper-api/src/main/java/org/bukkit/event/EventException.java b/paper-api/src/main/java/org/bukkit/event/EventException.java index 84638e8525..47ceb1ed5f 100644 --- a/paper-api/src/main/java/org/bukkit/event/EventException.java +++ b/paper-api/src/main/java/org/bukkit/event/EventException.java @@ -1,6 +1,7 @@ package org.bukkit.event; public class EventException extends Exception { + private static final HandlerList handlers = new HandlerList(); private static final long serialVersionUID = 3532808232324183999L; private final Throwable cause; diff --git a/paper-api/src/main/java/org/bukkit/event/EventHandler.java b/paper-api/src/main/java/org/bukkit/event/EventHandler.java new file mode 100644 index 0000000000..afd0904841 --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/event/EventHandler.java @@ -0,0 +1,15 @@ +package org.bukkit.event; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +/** + * An annotation to mark methods as being event handler methods + */ +@Retention(RetentionPolicy.RUNTIME) +public @interface EventHandler { + + Class event(); + + EventPriority priority(); +} diff --git a/paper-api/src/main/java/org/bukkit/event/EventPriority.java b/paper-api/src/main/java/org/bukkit/event/EventPriority.java new file mode 100644 index 0000000000..d087dec950 --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/event/EventPriority.java @@ -0,0 +1,45 @@ +package org.bukkit.event; + +/** + * Represents an event's priority in execution + */ +public enum EventPriority { + /** + * Event call is of very low importance and should be ran first, to allow + * other plugins to further customise the outcome + */ + LOWEST(0), + /** + * Event call is of low importance + */ + LOW(1), + /** + * Event call is neither important or unimportant, and may be ran normally + */ + NORMAL(2), + /** + * Event call is of high importance + */ + HIGH(3), + /** + * Event call is critical and must have the final say in what happens + * to the event + */ + HIGHEST(4), + /** + * Event is listened to purely for monitoring the outcome of an event. + *

+ * No modifications to the event should be made under this priority + */ + MONITOR(5); + + private final int slot; + + private EventPriority(int slot) { + this.slot = slot; + } + + public int getSlot() { + return slot; + } +} diff --git a/paper-api/src/main/java/org/bukkit/event/HandlerList.java b/paper-api/src/main/java/org/bukkit/event/HandlerList.java new file mode 100644 index 0000000000..643939f288 --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/event/HandlerList.java @@ -0,0 +1,133 @@ +package org.bukkit.event; + +import org.bukkit.plugin.Plugin; +import org.bukkit.plugin.RegisteredListener; + +import java.util.*; +import java.util.Map.Entry; + +/** + * A list of event handlers, stored per-event. Based on lahwran's fevents. + */ +@SuppressWarnings("unchecked") +public class HandlerList { + /** + * Handler array. This field being an array is the key to this system's speed. + */ + private RegisteredListener[][] handlers = new RegisteredListener[EventPriority.values().length][]; + + /** + * Dynamic handler lists. These are changed using register() and + * unregister() and are automatically baked to the handlers array any + * time they have changed. + */ + private final EnumMap> handlerslots; + + /** + * Whether the current HandlerList has been fully baked. When this is set + * to false, the Map> will be baked to RegisteredListener[][] + * next time the event is called. + * + * @see org.bukkit.plugin.SimplePluginManager#callEvent + */ + private boolean baked = false; + + /** + * List of all HandlerLists which have been created, for use in bakeAll() + */ + private static ArrayList alllists = new ArrayList(); + + /** + * Bake all handler lists. Best used just after all normal event + * registration is complete, ie just after all plugins are loaded if + * you're using fevents in a plugin system. + */ + public static void bakeAll() { + for (HandlerList h : alllists) { + h.bake(); + } + } + + public static void unregisterAll() { + for (HandlerList h : alllists) { + h.handlerslots.clear(); + h.baked = false; + } + } + + public static void unregisterAll(Plugin plugin) { + for (HandlerList h : alllists) { + h.unregister(plugin); + } + } + + /** + * Create a new handler list and initialize using EventPriority + * The HandlerList is then added to meta-list for use in bakeAll() + */ + public HandlerList() { + handlerslots = new EnumMap>(EventPriority.class); + for (EventPriority o : EventPriority.values()) { + handlerslots.put(o, new ArrayList()); + } + alllists.add(this); + } + + /** + * Register a new listener in this handler list + * + * @param listener listener to register + */ + public void register(RegisteredListener listener) { + if (handlerslots.get(listener.getPriority()).contains(listener)) + throw new IllegalStateException("This listener is already registered to priority " + listener.getPriority().toString()); + baked = false; + handlerslots.get(listener.getPriority()).add(listener); + } + + public void registerAll(Collection listeners) { + for (RegisteredListener listener : listeners) { + register(listener); + } + } + + /** + * Remove a listener from a specific order slot + * + * @param listener listener to remove + */ + public void unregister(RegisteredListener listener) { + if (handlerslots.get(listener.getPriority()).contains(listener)) { + baked = false; + handlerslots.get(listener.getPriority()).remove(listener); + } + } + + void unregister(Plugin plugin) { + boolean changed = false; + for (List list : handlerslots.values()) { + for (ListIterator i = list.listIterator(); i.hasNext();) { + if (i.next().getPlugin().equals(plugin)) { + i.remove(); + changed = true; + } + } + } + if (changed) baked = false; + } + + /** + * Bake HashMap and ArrayLists to 2d array - does nothing if not necessary + */ + public void bake() { + if (baked) return; // don't re-bake when still valid + for (Entry> entry : handlerslots.entrySet()) { + handlers[entry.getKey().getSlot()] = (entry.getValue().toArray(new RegisteredListener[entry.getValue().size()])); + } + baked = true; + } + + public RegisteredListener[][] getRegisteredListeners() { + return handlers; + } +} diff --git a/paper-api/src/main/java/org/bukkit/event/TransitionalCustomEvent.java b/paper-api/src/main/java/org/bukkit/event/TransitionalCustomEvent.java new file mode 100644 index 0000000000..e82c56189b --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/event/TransitionalCustomEvent.java @@ -0,0 +1,18 @@ +package org.bukkit.event; + +/** + * A transitional class to avoid breaking plugins using custom events. + */ +@Deprecated +public class TransitionalCustomEvent extends Event { + private static final HandlerList handlers = new HandlerList(); + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } +} diff --git a/paper-api/src/main/java/org/bukkit/event/block/BlockBreakEvent.java b/paper-api/src/main/java/org/bukkit/event/block/BlockBreakEvent.java index 972b8b63f6..780ed48f1e 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/BlockBreakEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/BlockBreakEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.block; import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; /** * Called when a block is broken by a player. @@ -16,6 +17,7 @@ import org.bukkit.event.Cancellable; @SuppressWarnings("serial") public class BlockBreakEvent extends BlockEvent implements Cancellable { + private static final HandlerList handlers = new HandlerList(); private Player player; private boolean cancel; @@ -41,4 +43,13 @@ public class BlockBreakEvent extends BlockEvent implements Cancellable { public void setCancelled(boolean cancel) { this.cancel = cancel; } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/block/BlockBurnEvent.java b/paper-api/src/main/java/org/bukkit/event/block/BlockBurnEvent.java index fc53334c31..665b1bd887 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/BlockBurnEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/BlockBurnEvent.java @@ -2,6 +2,7 @@ package org.bukkit.event.block; import org.bukkit.block.Block; import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; /** * Called when a block is destroyed as a result of being burnt by fire. @@ -10,6 +11,7 @@ import org.bukkit.event.Cancellable; */ @SuppressWarnings("serial") public class BlockBurnEvent extends BlockEvent implements Cancellable { + private static final HandlerList handlers = new HandlerList(); private boolean cancelled; public BlockBurnEvent(Block block) { @@ -24,4 +26,13 @@ public class BlockBurnEvent extends BlockEvent implements Cancellable { public void setCancelled(boolean cancel) { this.cancelled = cancel; } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/block/BlockCanBuildEvent.java b/paper-api/src/main/java/org/bukkit/event/block/BlockCanBuildEvent.java index 191bf9f8cf..5efc16d4d1 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/BlockCanBuildEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/BlockCanBuildEvent.java @@ -2,6 +2,7 @@ package org.bukkit.event.block; import org.bukkit.block.Block; import org.bukkit.Material; +import org.bukkit.event.HandlerList; /** * Called when we try to place a block, to see if we can build it here or not. @@ -14,6 +15,7 @@ import org.bukkit.Material; */ @SuppressWarnings("serial") public class BlockCanBuildEvent extends BlockEvent { + private static final HandlerList handlers = new HandlerList(); protected boolean buildable; protected int material; @@ -59,4 +61,13 @@ public class BlockCanBuildEvent extends BlockEvent { public int getMaterialId() { return material; } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/block/BlockDamageEvent.java b/paper-api/src/main/java/org/bukkit/event/block/BlockDamageEvent.java index 6100d9ad97..0353c3f121 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/BlockDamageEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/BlockDamageEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.block; import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; import org.bukkit.inventory.ItemStack; /** @@ -12,6 +13,7 @@ import org.bukkit.inventory.ItemStack; */ @SuppressWarnings("serial") public class BlockDamageEvent extends BlockEvent implements Cancellable { + private static final HandlerList handlers = new HandlerList(); private Player player; private boolean instaBreak; private boolean cancel; @@ -68,4 +70,13 @@ public class BlockDamageEvent extends BlockEvent implements Cancellable { public void setCancelled(boolean cancel) { this.cancel = cancel; } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/block/BlockDispenseEvent.java b/paper-api/src/main/java/org/bukkit/event/block/BlockDispenseEvent.java index b4279efaa8..7b2963ad60 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/BlockDispenseEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/BlockDispenseEvent.java @@ -2,6 +2,7 @@ package org.bukkit.event.block; import org.bukkit.block.Block; import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; import org.bukkit.inventory.ItemStack; import org.bukkit.util.Vector; @@ -12,6 +13,7 @@ import org.bukkit.util.Vector; */ @SuppressWarnings("serial") public class BlockDispenseEvent extends BlockEvent implements Cancellable { + private static final HandlerList handlers = new HandlerList(); private boolean cancelled = false; private ItemStack item; @@ -69,4 +71,13 @@ public class BlockDispenseEvent extends BlockEvent implements Cancellable { public void setCancelled(boolean cancel) { cancelled = cancel; } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/block/BlockEvent.java b/paper-api/src/main/java/org/bukkit/event/block/BlockEvent.java index 2ebb6a2881..d3ba7a9d38 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/BlockEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/BlockEvent.java @@ -7,7 +7,7 @@ import org.bukkit.event.Event; * Represents a block related event. */ @SuppressWarnings("serial") -public class BlockEvent extends Event { +public abstract class BlockEvent extends Event { protected Block block; public BlockEvent(final Event.Type type, final Block theBlock) { diff --git a/paper-api/src/main/java/org/bukkit/event/block/BlockFadeEvent.java b/paper-api/src/main/java/org/bukkit/event/block/BlockFadeEvent.java index cfd26e9565..ac937656f8 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/BlockFadeEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/BlockFadeEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.block; import org.bukkit.block.Block; import org.bukkit.block.BlockState; import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; /** * Called when a block fades, melts or disappears based on world conditions @@ -17,6 +18,7 @@ import org.bukkit.event.Cancellable; */ @SuppressWarnings("serial") public class BlockFadeEvent extends BlockEvent implements Cancellable { + private static final HandlerList handlers = new HandlerList(); private boolean cancelled; private BlockState newState; @@ -42,4 +44,13 @@ public class BlockFadeEvent extends BlockEvent implements Cancellable { public void setCancelled(boolean cancel) { this.cancelled = cancel; } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/block/BlockFormEvent.java b/paper-api/src/main/java/org/bukkit/event/block/BlockFormEvent.java index 209a5659f4..c3b824f841 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/BlockFormEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/BlockFormEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.block; import org.bukkit.block.Block; import org.bukkit.block.BlockState; import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; /** * Called when a block is formed or spreads based on world conditions. @@ -20,6 +21,7 @@ import org.bukkit.event.Cancellable; */ @SuppressWarnings("serial") public class BlockFormEvent extends BlockEvent implements Cancellable { + private static final HandlerList handlers = new HandlerList(); private boolean cancelled; private BlockState newState; @@ -53,4 +55,13 @@ public class BlockFormEvent extends BlockEvent implements Cancellable { public void setCancelled(boolean cancel) { this.cancelled = cancel; } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/block/BlockFromToEvent.java b/paper-api/src/main/java/org/bukkit/event/block/BlockFromToEvent.java index 0f43c93154..271b789c75 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/BlockFromToEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/BlockFromToEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.block; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; /** * Represents events with a source block and a destination block, currently only applies to liquid (lava and water). @@ -11,6 +12,7 @@ import org.bukkit.event.Cancellable; */ @SuppressWarnings("serial") public class BlockFromToEvent extends BlockEvent implements Cancellable { + private static final HandlerList handlers = new HandlerList(); protected Block to; protected BlockFace face; protected boolean cancel; @@ -49,4 +51,13 @@ public class BlockFromToEvent extends BlockEvent implements Cancellable { public void setCancelled(boolean cancel) { this.cancel = cancel; } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/block/BlockIgniteEvent.java b/paper-api/src/main/java/org/bukkit/event/block/BlockIgniteEvent.java index a98b15f80d..30a5b0c7ab 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/BlockIgniteEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/BlockIgniteEvent.java @@ -4,6 +4,7 @@ import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; /** * Called when a block is ignited. If you want to catch when a Player places fire, you need to use {@link BlockPlaceEvent}. @@ -12,6 +13,7 @@ import org.bukkit.event.Event; */ @SuppressWarnings("serial") public class BlockIgniteEvent extends BlockEvent implements Cancellable { + private static final HandlerList handlers = new HandlerList(); private IgniteCause cause; private boolean cancel; private Player thePlayer; @@ -71,4 +73,13 @@ public class BlockIgniteEvent extends BlockEvent implements Cancellable { */ LIGHTNING, } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/block/BlockListener.java b/paper-api/src/main/java/org/bukkit/event/block/BlockListener.java index 383b34e22e..fa0bd18f60 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/BlockListener.java +++ b/paper-api/src/main/java/org/bukkit/event/block/BlockListener.java @@ -5,6 +5,7 @@ import org.bukkit.event.Listener; /** * Handles all events thrown in relation to Blocks */ +@Deprecated public class BlockListener implements Listener { /** diff --git a/paper-api/src/main/java/org/bukkit/event/block/BlockPhysicsEvent.java b/paper-api/src/main/java/org/bukkit/event/block/BlockPhysicsEvent.java index f35be74f1c..29c5d9e03e 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/BlockPhysicsEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/BlockPhysicsEvent.java @@ -3,12 +3,14 @@ package org.bukkit.event.block; import org.bukkit.block.Block; import org.bukkit.Material; import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; /** * Thrown when a block physics check is called */ @SuppressWarnings("serial") public class BlockPhysicsEvent extends BlockEvent implements Cancellable { + private static final HandlerList handlers = new HandlerList(); private final int changed; private boolean cancel = false; @@ -42,4 +44,13 @@ public class BlockPhysicsEvent extends BlockEvent implements Cancellable { public void setCancelled(boolean cancel) { this.cancel = cancel; } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/block/BlockPistonExtendEvent.java b/paper-api/src/main/java/org/bukkit/event/block/BlockPistonExtendEvent.java index d4cadb22a4..5e94588ee8 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/BlockPistonExtendEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/BlockPistonExtendEvent.java @@ -6,9 +6,11 @@ import java.util.List; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; +import org.bukkit.event.HandlerList; @SuppressWarnings("serial") public class BlockPistonExtendEvent extends BlockPistonEvent { + private static final HandlerList handlers = new HandlerList(); private int length; private List blocks; @@ -42,4 +44,13 @@ public class BlockPistonExtendEvent extends BlockPistonEvent { } return blocks; } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/block/BlockPistonRetractEvent.java b/paper-api/src/main/java/org/bukkit/event/block/BlockPistonRetractEvent.java index 0fec1e045a..48c3c59a3e 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/BlockPistonRetractEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/BlockPistonRetractEvent.java @@ -3,9 +3,11 @@ package org.bukkit.event.block; import org.bukkit.Location; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; +import org.bukkit.event.HandlerList; @SuppressWarnings("serial") public class BlockPistonRetractEvent extends BlockPistonEvent { + private static final HandlerList handlers = new HandlerList(); public BlockPistonRetractEvent(Block block, BlockFace direction) { super(Type.BLOCK_PISTON_RETRACT, block, direction); } @@ -19,4 +21,13 @@ public class BlockPistonRetractEvent extends BlockPistonEvent { public Location getRetractLocation() { return getBlock().getRelative(getDirection(), 2).getLocation(); } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/block/BlockPlaceEvent.java b/paper-api/src/main/java/org/bukkit/event/block/BlockPlaceEvent.java index 0a9f122fab..27ee1cd9b1 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/BlockPlaceEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/BlockPlaceEvent.java @@ -4,6 +4,7 @@ import org.bukkit.block.Block; import org.bukkit.block.BlockState; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; import org.bukkit.inventory.ItemStack; /** @@ -13,6 +14,7 @@ import org.bukkit.inventory.ItemStack; */ @SuppressWarnings("serial") public class BlockPlaceEvent extends BlockEvent implements Cancellable { + private static final HandlerList handlers = new HandlerList(); protected boolean cancel; protected boolean canBuild; protected Block placedAgainst; @@ -106,4 +108,13 @@ public class BlockPlaceEvent extends BlockEvent implements Cancellable { public void setBuild(boolean canBuild) { this.canBuild = canBuild; } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/block/BlockRedstoneEvent.java b/paper-api/src/main/java/org/bukkit/event/block/BlockRedstoneEvent.java index be0a530afa..b1179d21e5 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/BlockRedstoneEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/BlockRedstoneEvent.java @@ -1,12 +1,14 @@ package org.bukkit.event.block; import org.bukkit.block.Block; +import org.bukkit.event.HandlerList; /** * Called when a redstone current changes */ @SuppressWarnings("serial") public class BlockRedstoneEvent extends BlockEvent { + private static final HandlerList handlers = new HandlerList(); private int oldCurrent; private int newCurrent; @@ -42,4 +44,13 @@ public class BlockRedstoneEvent extends BlockEvent { public void setNewCurrent(int newCurrent) { this.newCurrent = newCurrent; } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/block/BlockSpreadEvent.java b/paper-api/src/main/java/org/bukkit/event/block/BlockSpreadEvent.java index 6001d0ad0a..e90a2b81e4 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/BlockSpreadEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/BlockSpreadEvent.java @@ -2,6 +2,7 @@ package org.bukkit.event.block; import org.bukkit.block.Block; import org.bukkit.block.BlockState; +import org.bukkit.event.HandlerList; /** * Called when a block spreads based on world conditions. @@ -19,6 +20,7 @@ import org.bukkit.block.BlockState; */ @SuppressWarnings("serial") public class BlockSpreadEvent extends BlockFormEvent { + private static final HandlerList handlers = new HandlerList(); private Block source; public BlockSpreadEvent(Block block, Block source, BlockState newState) { @@ -34,4 +36,13 @@ public class BlockSpreadEvent extends BlockFormEvent { public Block getSource() { return source; } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/block/LeavesDecayEvent.java b/paper-api/src/main/java/org/bukkit/event/block/LeavesDecayEvent.java index 07dd2e5f3b..f52d677f27 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/LeavesDecayEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/LeavesDecayEvent.java @@ -2,6 +2,7 @@ package org.bukkit.event.block; import org.bukkit.block.Block; import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; /** * Called when leaves are decaying naturally. @@ -10,6 +11,7 @@ import org.bukkit.event.Cancellable; */ @SuppressWarnings("serial") public class LeavesDecayEvent extends BlockEvent implements Cancellable { + private static final HandlerList handlers = new HandlerList(); private boolean cancel = false; public LeavesDecayEvent(final Block block) { @@ -23,4 +25,13 @@ public class LeavesDecayEvent extends BlockEvent implements Cancellable { public void setCancelled(boolean cancel) { this.cancel = cancel; } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/block/SignChangeEvent.java b/paper-api/src/main/java/org/bukkit/event/block/SignChangeEvent.java index 28e69b943f..3fbe31a7d5 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/SignChangeEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/SignChangeEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.block; import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; /** * Called when a sign is changed by a player. @@ -11,6 +12,7 @@ import org.bukkit.event.Cancellable; */ @SuppressWarnings("serial") public class SignChangeEvent extends BlockEvent implements Cancellable { + private static final HandlerList handlers = new HandlerList(); private boolean cancel = false; private Player player; private String[] lines; @@ -68,4 +70,13 @@ public class SignChangeEvent extends BlockEvent implements Cancellable { public void setCancelled(boolean cancel) { this.cancel = cancel; } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/CreatureSpawnEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/CreatureSpawnEvent.java index 0dbcbf3ba6..d7f55f6cd1 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/CreatureSpawnEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/CreatureSpawnEvent.java @@ -4,6 +4,7 @@ import org.bukkit.entity.CreatureType; import org.bukkit.entity.Entity; import org.bukkit.Location; import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; /** * Called when a creature is spawned into a world. @@ -12,6 +13,7 @@ import org.bukkit.event.Cancellable; */ @SuppressWarnings("serial") public class CreatureSpawnEvent extends EntityEvent implements Cancellable { + private static final HandlerList handlers = new HandlerList(); private Location location; private boolean canceled; @@ -60,6 +62,15 @@ public class CreatureSpawnEvent extends EntityEvent implements Cancellable { return spawnReason; } + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } + /** * An enum to specify the type of spawning */ diff --git a/paper-api/src/main/java/org/bukkit/event/entity/CreeperPowerEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/CreeperPowerEvent.java index 7386f401f2..e6900a08bf 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/CreeperPowerEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/CreeperPowerEvent.java @@ -2,6 +2,7 @@ package org.bukkit.event.entity; import org.bukkit.entity.Entity; import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; /** * Called when a Creeper is struck by lightning. @@ -10,6 +11,7 @@ import org.bukkit.event.Cancellable; */ @SuppressWarnings("serial") public class CreeperPowerEvent extends EntityEvent implements Cancellable { + private static final HandlerList handlers = new HandlerList(); private boolean canceled; private PowerCause cause; @@ -53,6 +55,15 @@ public class CreeperPowerEvent extends EntityEvent implements Cancellable { return cause; } + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } + /** * An enum to specify the cause of the change in power */ diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EndermanPickupEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EndermanPickupEvent.java index ee5a5f3548..c3207a661e 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EndermanPickupEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EndermanPickupEvent.java @@ -3,9 +3,11 @@ package org.bukkit.event.entity; import org.bukkit.block.Block; import org.bukkit.entity.Entity; import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; @SuppressWarnings("serial") public class EndermanPickupEvent extends EntityEvent implements Cancellable { + private static final HandlerList handlers = new HandlerList(); private boolean cancel; private Block block; @@ -32,4 +34,13 @@ public class EndermanPickupEvent extends EntityEvent implements Cancellable { public Block getBlock() { return block; } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EndermanPlaceEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EndermanPlaceEvent.java index 1c85eb7828..ecb3f23153 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EndermanPlaceEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EndermanPlaceEvent.java @@ -3,9 +3,11 @@ package org.bukkit.event.entity; import org.bukkit.Location; import org.bukkit.entity.Entity; import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; @SuppressWarnings("serial") public class EndermanPlaceEvent extends EntityEvent implements Cancellable { + private static final HandlerList handlers = new HandlerList(); private boolean cancel; private Location location; @@ -32,4 +34,13 @@ public class EndermanPlaceEvent extends EntityEvent implements Cancellable { public Location getLocation() { return location; } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityCombustEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityCombustEvent.java index 0f1ecdbdf7..d37f94cdda 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityCombustEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityCombustEvent.java @@ -2,6 +2,7 @@ package org.bukkit.event.entity; import org.bukkit.entity.Entity; import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; /** * Called when an entity combusts. @@ -10,6 +11,7 @@ import org.bukkit.event.Cancellable; */ @SuppressWarnings("serial") public class EntityCombustEvent extends EntityEvent implements Cancellable { + private static final HandlerList handlers = new HandlerList(); private int duration; private boolean cancel; @@ -44,4 +46,13 @@ public class EntityCombustEvent extends EntityEvent implements Cancellable { public void setDuration(int duration) { this.duration = duration; } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityCreatePortalEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityCreatePortalEvent.java index 37712ea676..f798559d34 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityCreatePortalEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityCreatePortalEvent.java @@ -5,11 +5,13 @@ import org.bukkit.PortalType; import org.bukkit.block.BlockState; import org.bukkit.entity.Entity; import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; /** * Thrown when a Living Entity creates a portal in a world. */ public class EntityCreatePortalEvent extends EntityEvent implements Cancellable { + private static final HandlerList handlers = new HandlerList(); private List blocks; private boolean cancelled = false; private PortalType type = PortalType.CUSTOM; @@ -46,4 +48,13 @@ public class EntityCreatePortalEvent extends EntityEvent implements Cancellable public PortalType getPortalType() { return type; } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityDamageEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityDamageEvent.java index fc8767ca5e..4706bb53ad 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityDamageEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityDamageEvent.java @@ -3,12 +3,14 @@ package org.bukkit.event.entity; import org.bukkit.entity.Entity; import org.bukkit.event.Cancellable; import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; /** * Stores data for damage events */ @SuppressWarnings("serial") public class EntityDamageEvent extends EntityEvent implements Cancellable { + private static final HandlerList handlers = new HandlerList(); private int damage; private boolean cancelled; @@ -61,6 +63,15 @@ public class EntityDamageEvent extends EntityEvent implements Cancellable { return cause; } + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } + /** * An enum to specify the cause of the damage */ diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityDeathEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityDeathEvent.java index 96d0ef706b..0935f0224e 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityDeathEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityDeathEvent.java @@ -2,6 +2,7 @@ package org.bukkit.event.entity; import java.util.List; import org.bukkit.entity.Entity; +import org.bukkit.event.HandlerList; import org.bukkit.inventory.ItemStack; /** @@ -9,6 +10,7 @@ import org.bukkit.inventory.ItemStack; */ @SuppressWarnings("serial") public class EntityDeathEvent extends EntityEvent { + private static final HandlerList handlers = new HandlerList(); private List drops; private int dropExp = 0; @@ -54,4 +56,13 @@ public class EntityDeathEvent extends EntityEvent { public List getDrops() { return drops; } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityEvent.java index af93e074be..de99917095 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityEvent.java @@ -7,7 +7,7 @@ import org.bukkit.event.Event; * Represents an Entity-related event */ @SuppressWarnings("serial") -public class EntityEvent extends Event { +public abstract class EntityEvent extends Event { protected Entity entity; public EntityEvent(final Event.Type type, final Entity what) { diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityExplodeEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityExplodeEvent.java index 7eed8f4a7a..50036565ac 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityExplodeEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityExplodeEvent.java @@ -4,6 +4,7 @@ import org.bukkit.Location; import org.bukkit.block.Block; import org.bukkit.entity.Entity; import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; import java.util.List; @@ -12,6 +13,7 @@ import java.util.List; */ @SuppressWarnings("serial") public class EntityExplodeEvent extends EntityEvent implements Cancellable { + private static final HandlerList handlers = new HandlerList(); private boolean cancel; private Location location; private List blocks; @@ -76,4 +78,13 @@ public class EntityExplodeEvent extends EntityEvent implements Cancellable { public void setYield(float yield) { this.yield = yield; } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityInteractEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityInteractEvent.java index b1b58a5c4e..c6da06bf3e 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityInteractEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityInteractEvent.java @@ -3,12 +3,14 @@ package org.bukkit.event.entity; import org.bukkit.block.Block; import org.bukkit.entity.Entity; import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; /** * Called when an entity interacts with an object */ @SuppressWarnings("serial") public class EntityInteractEvent extends EntityEvent implements Cancellable { + private static final HandlerList handlers = new HandlerList(); protected Block block; private boolean cancelled; @@ -34,4 +36,13 @@ public class EntityInteractEvent extends EntityEvent implements Cancellable { public Block getBlock() { return block; } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityListener.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityListener.java index 58ac39d930..3fda2181d6 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityListener.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityListener.java @@ -7,6 +7,7 @@ import org.bukkit.event.painting.PaintingBreakEvent; /** * Handles all events fired in relation to entities */ +@Deprecated public class EntityListener implements Listener { public EntityListener() {} diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityPortalEnterEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityPortalEnterEvent.java index 44f506b16a..caa0435497 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityPortalEnterEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityPortalEnterEvent.java @@ -2,12 +2,14 @@ package org.bukkit.event.entity; import org.bukkit.entity.Entity; import org.bukkit.Location; +import org.bukkit.event.HandlerList; /** * Stores data for entities standing inside a portal block */ @SuppressWarnings("serial") public class EntityPortalEnterEvent extends EntityEvent { + private static final HandlerList handlers = new HandlerList(); private Location location; @@ -24,4 +26,13 @@ public class EntityPortalEnterEvent extends EntityEvent { public Location getLocation() { return location; } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityRegainHealthEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityRegainHealthEvent.java index dd1679121a..059dea537a 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityRegainHealthEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityRegainHealthEvent.java @@ -3,12 +3,14 @@ package org.bukkit.event.entity; import org.bukkit.entity.Entity; import org.bukkit.event.Cancellable; import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; /** * Stores data for health-regain events */ @SuppressWarnings("serial") public class EntityRegainHealthEvent extends EntityEvent implements Cancellable { + private static final HandlerList handlers = new HandlerList(); private boolean cancelled; private int amount; @@ -55,6 +57,15 @@ public class EntityRegainHealthEvent extends EntityEvent implements Cancellable return regainReason; } + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } + /** * An enum to specify the type of health regaining that is occurring */ diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityTameEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityTameEvent.java index 5b0759f8e1..3f53a13b9a 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityTameEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityTameEvent.java @@ -3,12 +3,14 @@ package org.bukkit.event.entity; import org.bukkit.entity.AnimalTamer; import org.bukkit.entity.Entity; import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; /** * Thrown when a LivingEntity is tamed */ @SuppressWarnings("serial") public class EntityTameEvent extends EntityEvent implements Cancellable { + private static final HandlerList handlers = new HandlerList(); private boolean cancelled; private AnimalTamer owner; @@ -33,4 +35,13 @@ public class EntityTameEvent extends EntityEvent implements Cancellable { public AnimalTamer getOwner() { return owner; } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityTargetEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityTargetEvent.java index b1231d1bc8..b202410191 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityTargetEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityTargetEvent.java @@ -2,12 +2,14 @@ package org.bukkit.event.entity; import org.bukkit.entity.Entity; import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; /** * Called when a creature targets or untargets another entity */ @SuppressWarnings("serial") public class EntityTargetEvent extends EntityEvent implements Cancellable { + private static final HandlerList handlers = new HandlerList(); private boolean cancel; private Entity target; private TargetReason reason; @@ -62,6 +64,15 @@ public class EntityTargetEvent extends EntityEvent implements Cancellable { this.target = target; } + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } + /** * An enum to specify the reason for the targeting */ diff --git a/paper-api/src/main/java/org/bukkit/event/entity/ExplosionPrimeEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/ExplosionPrimeEvent.java index 850aa8deac..a5d73bfdca 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/ExplosionPrimeEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/ExplosionPrimeEvent.java @@ -3,12 +3,14 @@ package org.bukkit.event.entity; import org.bukkit.entity.Entity; import org.bukkit.entity.Explosive; import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; /** * Called when an entity has made a decision to explode. */ @SuppressWarnings("serial") public class ExplosionPrimeEvent extends EntityEvent implements Cancellable { + private static final HandlerList handlers = new HandlerList(); private boolean cancel; private float radius; private boolean fire; @@ -67,4 +69,13 @@ public class ExplosionPrimeEvent extends EntityEvent implements Cancellable { public void setFire(boolean fire) { this.fire = fire; } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/FoodLevelChangeEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/FoodLevelChangeEvent.java index f6854ce720..975388c980 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/FoodLevelChangeEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/FoodLevelChangeEvent.java @@ -2,12 +2,14 @@ package org.bukkit.event.entity; import org.bukkit.entity.Entity; import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; /** * Called when a human entity's food level changes */ @SuppressWarnings("serial") public class FoodLevelChangeEvent extends EntityEvent implements Cancellable { + private static final HandlerList handlers = new HandlerList(); private boolean cancel = false; private int level; @@ -46,4 +48,13 @@ public class FoodLevelChangeEvent extends EntityEvent implements Cancellable { public void setCancelled(boolean cancel) { this.cancel = cancel; } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/ItemDespawnEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/ItemDespawnEvent.java index 620e247a5b..2d55b85383 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/ItemDespawnEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/ItemDespawnEvent.java @@ -3,8 +3,10 @@ package org.bukkit.event.entity; import org.bukkit.Location; import org.bukkit.entity.Entity; import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; public class ItemDespawnEvent extends EntityEvent implements Cancellable { + private static final HandlerList handlers = new HandlerList(); private boolean canceled; private Location location; @@ -29,4 +31,13 @@ public class ItemDespawnEvent extends EntityEvent implements Cancellable { public Location getLocation() { return location; } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/ItemSpawnEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/ItemSpawnEvent.java index 19544295a0..091a54675a 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/ItemSpawnEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/ItemSpawnEvent.java @@ -3,12 +3,14 @@ package org.bukkit.event.entity; import org.bukkit.entity.Entity; import org.bukkit.Location; import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; /** * Called when an item is spawned into a world */ @SuppressWarnings("serial") public class ItemSpawnEvent extends EntityEvent implements Cancellable { + private static final HandlerList handlers = new HandlerList(); private Location location; private boolean canceled; @@ -34,4 +36,13 @@ public class ItemSpawnEvent extends EntityEvent implements Cancellable { public Location getLocation() { return location; } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/PigZapEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/PigZapEvent.java index 174a2d087a..89db40bb9f 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/PigZapEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/PigZapEvent.java @@ -2,12 +2,14 @@ package org.bukkit.event.entity; import org.bukkit.entity.Entity; import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; /** * Stores data for pigs being zapped */ @SuppressWarnings("serial") public class PigZapEvent extends EntityEvent implements Cancellable { + private static final HandlerList handlers = new HandlerList(); private boolean canceled; private Entity pigzombie; @@ -45,4 +47,13 @@ public class PigZapEvent extends EntityEvent implements Cancellable { public Entity getPigZombie() { return pigzombie; } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/ProjectileHitEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/ProjectileHitEvent.java index e5b2e60a88..c019e5864f 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/ProjectileHitEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/ProjectileHitEvent.java @@ -1,15 +1,26 @@ package org.bukkit.event.entity; import org.bukkit.entity.Projectile; +import org.bukkit.event.HandlerList; /** * Called when a projectile hits an object */ @SuppressWarnings("serial") public class ProjectileHitEvent extends EntityEvent { + private static final HandlerList handlers = new HandlerList(); public ProjectileHitEvent(Projectile projectile) { super(Type.PROJECTILE_HIT, projectile); } + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } + } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/SlimeSplitEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/SlimeSplitEvent.java index 57d52baca1..73013cc6a1 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/SlimeSplitEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/SlimeSplitEvent.java @@ -2,12 +2,14 @@ package org.bukkit.event.entity; import org.bukkit.entity.Entity; import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; /** * Called when a Slime splits into smaller Slimes upon death */ @SuppressWarnings("serial") public class SlimeSplitEvent extends EntityEvent implements Cancellable { + private static final HandlerList handlers = new HandlerList(); private boolean cancel; private int count; @@ -42,4 +44,13 @@ public class SlimeSplitEvent extends EntityEvent implements Cancellable { public void setCount(int count) { this.count = count; } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } } \ No newline at end of file diff --git a/paper-api/src/main/java/org/bukkit/event/inventory/FurnaceBurnEvent.java b/paper-api/src/main/java/org/bukkit/event/inventory/FurnaceBurnEvent.java index d1849f96be..3d2cfd2bab 100644 --- a/paper-api/src/main/java/org/bukkit/event/inventory/FurnaceBurnEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/inventory/FurnaceBurnEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.inventory; import org.bukkit.block.Block; import org.bukkit.event.Cancellable; import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; import org.bukkit.inventory.ItemStack; /** @@ -10,6 +11,7 @@ import org.bukkit.inventory.ItemStack; */ @SuppressWarnings("serial") public class FurnaceBurnEvent extends Event implements Cancellable { + private static final HandlerList handlers = new HandlerList(); private Block furnace; private ItemStack fuel; private int burnTime; @@ -87,4 +89,13 @@ public class FurnaceBurnEvent extends Event implements Cancellable { public void setCancelled(boolean cancel) { this.cancelled = cancel; } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/inventory/FurnaceSmeltEvent.java b/paper-api/src/main/java/org/bukkit/event/inventory/FurnaceSmeltEvent.java index 9b00384d19..f1c498e84e 100644 --- a/paper-api/src/main/java/org/bukkit/event/inventory/FurnaceSmeltEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/inventory/FurnaceSmeltEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.inventory; import org.bukkit.block.Block; import org.bukkit.event.Cancellable; import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; import org.bukkit.inventory.ItemStack; /** @@ -10,6 +11,7 @@ import org.bukkit.inventory.ItemStack; */ @SuppressWarnings("serial") public class FurnaceSmeltEvent extends Event implements Cancellable { + private static final HandlerList handlers = new HandlerList(); private Block furnace; private ItemStack source; private ItemStack result; @@ -67,4 +69,13 @@ public class FurnaceSmeltEvent extends Event implements Cancellable { public void setCancelled(boolean cancel) { this.cancelled = cancel; } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/inventory/InventoryListener.java b/paper-api/src/main/java/org/bukkit/event/inventory/InventoryListener.java index f34fa2baf9..e93f5d5e51 100644 --- a/paper-api/src/main/java/org/bukkit/event/inventory/InventoryListener.java +++ b/paper-api/src/main/java/org/bukkit/event/inventory/InventoryListener.java @@ -5,6 +5,7 @@ import org.bukkit.event.Listener; /** * Handles all events thrown in relation to Blocks */ +@Deprecated public class InventoryListener implements Listener { public InventoryListener() {} diff --git a/paper-api/src/main/java/org/bukkit/event/painting/PaintingBreakEvent.java b/paper-api/src/main/java/org/bukkit/event/painting/PaintingBreakEvent.java index 8268b00d44..cd08626955 100644 --- a/paper-api/src/main/java/org/bukkit/event/painting/PaintingBreakEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/painting/PaintingBreakEvent.java @@ -2,12 +2,14 @@ package org.bukkit.event.painting; import org.bukkit.entity.Painting; import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; /** * Triggered when a painting is removed */ @SuppressWarnings("serial") public class PaintingBreakEvent extends PaintingEvent implements Cancellable { + private static final HandlerList handlers = new HandlerList(); private boolean cancelled; private RemoveCause cause; @@ -59,4 +61,13 @@ public class PaintingBreakEvent extends PaintingEvent implements Cancellable { */ PHYSICS, } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/painting/PaintingEvent.java b/paper-api/src/main/java/org/bukkit/event/painting/PaintingEvent.java index c2c606ba91..4d2f441de5 100644 --- a/paper-api/src/main/java/org/bukkit/event/painting/PaintingEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/painting/PaintingEvent.java @@ -7,7 +7,7 @@ import org.bukkit.event.Event; * Represents a painting-related event. */ @SuppressWarnings("serial") -public class PaintingEvent extends Event { +public abstract class PaintingEvent extends Event { protected Painting painting; diff --git a/paper-api/src/main/java/org/bukkit/event/painting/PaintingPlaceEvent.java b/paper-api/src/main/java/org/bukkit/event/painting/PaintingPlaceEvent.java index 7e460c8309..251bcee06e 100644 --- a/paper-api/src/main/java/org/bukkit/event/painting/PaintingPlaceEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/painting/PaintingPlaceEvent.java @@ -6,12 +6,14 @@ import org.bukkit.entity.Painting; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; /** * Triggered when a painting is created in the world */ @SuppressWarnings("serial") public class PaintingPlaceEvent extends PaintingEvent implements Cancellable { + private static final HandlerList handlers = new HandlerList(); private boolean cancelled; @@ -60,4 +62,13 @@ public class PaintingPlaceEvent extends PaintingEvent implements Cancellable { public void setCancelled(boolean cancel) { this.cancelled = cancel; } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerAnimationEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerAnimationEvent.java index 4f703f3ac9..ad590980fe 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerAnimationEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerAnimationEvent.java @@ -2,12 +2,14 @@ package org.bukkit.event.player; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; /** * Represents a player animation event */ @SuppressWarnings("serial") public class PlayerAnimationEvent extends PlayerEvent implements Cancellable { + private static final HandlerList handlers = new HandlerList(); private PlayerAnimationType animationType; private boolean isCancelled = false; @@ -40,4 +42,13 @@ public class PlayerAnimationEvent extends PlayerEvent implements Cancellable { public void setCancelled(boolean cancel) { this.isCancelled = cancel; } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerBedEnterEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerBedEnterEvent.java index 53aeac38d6..174676be5e 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerBedEnterEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerBedEnterEvent.java @@ -3,12 +3,14 @@ package org.bukkit.event.player; import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; /** * This event is fired when the player is almost about to enter the bed. */ @SuppressWarnings("serial") public class PlayerBedEnterEvent extends PlayerEvent implements Cancellable { + private static final HandlerList handlers = new HandlerList(); private boolean cancel = false; private Block bed; @@ -34,4 +36,13 @@ public class PlayerBedEnterEvent extends PlayerEvent implements Cancellable { public Block getBed() { return bed; } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerBedLeaveEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerBedLeaveEvent.java index 2cc36edd33..01d0cfac17 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerBedLeaveEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerBedLeaveEvent.java @@ -2,12 +2,14 @@ package org.bukkit.event.player; import org.bukkit.block.Block; import org.bukkit.entity.Player; +import org.bukkit.event.HandlerList; /** * This event is fired when the player is leaving a bed. */ @SuppressWarnings("serial") public class PlayerBedLeaveEvent extends PlayerEvent { + private static final HandlerList handlers = new HandlerList(); private Block bed; @@ -24,4 +26,13 @@ public class PlayerBedLeaveEvent extends PlayerEvent { public Block getBed() { return bed; } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerBucketEmptyEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerBucketEmptyEvent.java index b44155e4f9..afdde9ae6f 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerBucketEmptyEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerBucketEmptyEvent.java @@ -4,6 +4,7 @@ import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.entity.Player; +import org.bukkit.event.HandlerList; import org.bukkit.inventory.ItemStack; /** @@ -11,8 +12,18 @@ import org.bukkit.inventory.ItemStack; */ @SuppressWarnings("serial") public class PlayerBucketEmptyEvent extends PlayerBucketEvent { + private static final HandlerList handlers = new HandlerList(); public PlayerBucketEmptyEvent(Player who, Block blockClicked, BlockFace blockFace, Material bucket, ItemStack itemInHand) { super(Type.PLAYER_BUCKET_EMPTY, who, blockClicked, blockFace, bucket, itemInHand); } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerBucketFillEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerBucketFillEvent.java index 4a5dbe4867..065df40986 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerBucketFillEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerBucketFillEvent.java @@ -4,6 +4,7 @@ import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.entity.Player; +import org.bukkit.event.HandlerList; import org.bukkit.inventory.ItemStack; /** @@ -11,7 +12,17 @@ import org.bukkit.inventory.ItemStack; */ @SuppressWarnings("serial") public class PlayerBucketFillEvent extends PlayerBucketEvent { + private static final HandlerList handlers = new HandlerList(); public PlayerBucketFillEvent(Player who, Block blockClicked, BlockFace blockFace, Material bucket, ItemStack itemInHand) { super(Type.PLAYER_BUCKET_FILL, who, blockClicked, blockFace, bucket, itemInHand); } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerChangedWorldEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerChangedWorldEvent.java index e718dc0a8d..ee24b9c039 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerChangedWorldEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerChangedWorldEvent.java @@ -2,9 +2,11 @@ package org.bukkit.event.player; import org.bukkit.World; import org.bukkit.entity.Player; +import org.bukkit.event.HandlerList; @SuppressWarnings("serial") public class PlayerChangedWorldEvent extends PlayerEvent { + private static final HandlerList handlers = new HandlerList(); private final World from; @@ -16,4 +18,13 @@ public class PlayerChangedWorldEvent extends PlayerEvent { public World getFrom() { return from; } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerChatEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerChatEvent.java index 67067d875d..e0975e775e 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerChatEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerChatEvent.java @@ -6,12 +6,14 @@ import java.util.Set; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; /** * Holds information for player chat and commands */ @SuppressWarnings("serial") public class PlayerChatEvent extends PlayerEvent implements Cancellable { + private static final HandlerList handlers = new HandlerList(); private boolean cancel = false; private String message; private String format = "<%1$s> %2$s"; @@ -97,4 +99,13 @@ public class PlayerChatEvent extends PlayerEvent implements Cancellable { public Set getRecipients() { return recipients; } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerCommandPreprocessEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerCommandPreprocessEvent.java index 67addfe95c..fd2fa75238 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerCommandPreprocessEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerCommandPreprocessEvent.java @@ -1,6 +1,7 @@ package org.bukkit.event.player; import org.bukkit.entity.Player; +import org.bukkit.event.HandlerList; /** * Called early in the command handling process. This event is only @@ -8,7 +9,17 @@ import org.bukkit.entity.Player; */ @SuppressWarnings("serial") public class PlayerCommandPreprocessEvent extends PlayerChatEvent { + private static final HandlerList handlers = new HandlerList(); public PlayerCommandPreprocessEvent(final Player player, final String message) { super(Type.PLAYER_COMMAND_PREPROCESS, player, message); } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerDropItemEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerDropItemEvent.java index 50928987af..274a02ebaf 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerDropItemEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerDropItemEvent.java @@ -3,12 +3,14 @@ package org.bukkit.event.player; import org.bukkit.entity.Item; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; /** * Thrown when a player drops an item from their inventory */ @SuppressWarnings("serial") public class PlayerDropItemEvent extends PlayerEvent implements Cancellable { + private static final HandlerList handlers = new HandlerList(); private final Item drop; private boolean cancel = false; @@ -33,4 +35,13 @@ public class PlayerDropItemEvent extends PlayerEvent implements Cancellable { public void setCancelled(boolean cancel) { this.cancel = cancel; } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerEggThrowEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerEggThrowEvent.java index 669f4c7a87..a0736f584a 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerEggThrowEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerEggThrowEvent.java @@ -3,12 +3,14 @@ package org.bukkit.event.player; import org.bukkit.entity.CreatureType; import org.bukkit.entity.Egg; import org.bukkit.entity.Player; +import org.bukkit.event.HandlerList; /** * Called when a player throws an egg and it might hatch */ @SuppressWarnings("serial") public class PlayerEggThrowEvent extends PlayerEvent { + private static final HandlerList handlers = new HandlerList(); private Egg egg; private boolean hatching; private CreatureType hatchType; @@ -94,4 +96,13 @@ public class PlayerEggThrowEvent extends PlayerEvent { public void setNumHatches(byte numHatches) { this.numHatches = numHatches; } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerEvent.java index c567a0e8d0..54ad08e1ad 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerEvent.java @@ -7,7 +7,7 @@ import org.bukkit.event.Event; * Represents a player related event */ @SuppressWarnings("serial") -public class PlayerEvent extends Event { +public abstract class PlayerEvent extends Event { protected Player player; public PlayerEvent(final Event.Type type, final Player who) { diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerFishEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerFishEvent.java index 285e8ab866..5b5cdab6b4 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerFishEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerFishEvent.java @@ -3,12 +3,14 @@ package org.bukkit.event.player; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.entity.Entity; +import org.bukkit.event.HandlerList; /** * Thrown when a player is fishing */ @SuppressWarnings("serial") public class PlayerFishEvent extends PlayerEvent implements Cancellable { + private static final HandlerList handlers = new HandlerList(); private final Entity entity; private boolean cancel = false; private State state; @@ -45,6 +47,15 @@ public class PlayerFishEvent extends PlayerEvent implements Cancellable { return state; } + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } + /** * An enum to specify the state of the fishing */ diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerGameModeChangeEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerGameModeChangeEvent.java index e1dc0da34d..c8406a89fa 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerGameModeChangeEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerGameModeChangeEvent.java @@ -3,9 +3,11 @@ package org.bukkit.event.player; import org.bukkit.GameMode; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; @SuppressWarnings("serial") public class PlayerGameModeChangeEvent extends PlayerEvent implements Cancellable { + private static final HandlerList handlers = new HandlerList(); private boolean cancelled; private GameMode newGameMode; @@ -26,4 +28,13 @@ public class PlayerGameModeChangeEvent extends PlayerEvent implements Cancellabl public GameMode getNewGameMode() { return newGameMode; } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerInteractEntityEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerInteractEntityEvent.java index 3a8d3d441f..59f872fb29 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerInteractEntityEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerInteractEntityEvent.java @@ -3,12 +3,14 @@ package org.bukkit.event.player; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; /** * Represents an event that is called when a player right clicks an entity. */ @SuppressWarnings("serial") public class PlayerInteractEntityEvent extends PlayerEvent implements Cancellable { + private static final HandlerList handlers = new HandlerList(); protected Entity clickedEntity; boolean cancelled = false; @@ -33,4 +35,13 @@ public class PlayerInteractEntityEvent extends PlayerEvent implements Cancellabl public Entity getRightClicked() { return this.clickedEntity; } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerInteractEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerInteractEvent.java index 3b7fcd3a92..837ffa27f2 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerInteractEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerInteractEvent.java @@ -2,6 +2,7 @@ package org.bukkit.event.player; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; +import org.bukkit.event.HandlerList; import org.bukkit.inventory.ItemStack; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -13,6 +14,7 @@ import org.bukkit.event.block.Action; */ @SuppressWarnings("serial") public class PlayerInteractEvent extends PlayerEvent implements Cancellable { + private static final HandlerList handlers = new HandlerList(); protected ItemStack item; protected Action action; protected Block blockClicked; @@ -173,4 +175,13 @@ public class PlayerInteractEvent extends PlayerEvent implements Cancellable { public void setUseItemInHand(Result useItemInHand) { this.useItemInHand = useItemInHand; } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerInventoryEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerInventoryEvent.java index b425fe2224..5993e84143 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerInventoryEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerInventoryEvent.java @@ -1,6 +1,7 @@ package org.bukkit.event.player; import org.bukkit.entity.Player; +import org.bukkit.event.HandlerList; import org.bukkit.inventory.Inventory; /** @@ -8,6 +9,7 @@ import org.bukkit.inventory.Inventory; */ @SuppressWarnings("serial") public class PlayerInventoryEvent extends PlayerEvent { + private static final HandlerList handlers = new HandlerList(); protected Inventory inventory; public PlayerInventoryEvent(final Player player, final Inventory inventory) { @@ -23,4 +25,13 @@ public class PlayerInventoryEvent extends PlayerEvent { public Inventory getInventory() { return inventory; } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerItemHeldEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerItemHeldEvent.java index 8a7fad3c41..d345c8618d 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerItemHeldEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerItemHeldEvent.java @@ -1,12 +1,14 @@ package org.bukkit.event.player; import org.bukkit.entity.Player; +import org.bukkit.event.HandlerList; /** * Fired when a player changes their currently held item */ @SuppressWarnings("serial") public class PlayerItemHeldEvent extends PlayerEvent { + private static final HandlerList handlers = new HandlerList(); private int previous; private int current; @@ -33,4 +35,13 @@ public class PlayerItemHeldEvent extends PlayerEvent { public int getNewSlot() { return current; } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerJoinEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerJoinEvent.java index a0672940ee..481e96cc5a 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerJoinEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerJoinEvent.java @@ -1,12 +1,14 @@ package org.bukkit.event.player; import org.bukkit.entity.Player; +import org.bukkit.event.HandlerList; /** * Called when a player joins a server */ @SuppressWarnings("serial") public class PlayerJoinEvent extends PlayerEvent { + private static final HandlerList handlers = new HandlerList(); private String joinMessage; public PlayerJoinEvent(Player playerJoined, String joinMessage) { @@ -31,4 +33,13 @@ public class PlayerJoinEvent extends PlayerEvent { public void setJoinMessage(String joinMessage) { this.joinMessage = joinMessage; } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerKickEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerKickEvent.java index 97559f3ee8..4715561678 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerKickEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerKickEvent.java @@ -2,12 +2,14 @@ package org.bukkit.event.player; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; /** * Called when a player gets kicked from the server */ @SuppressWarnings("serial") public class PlayerKickEvent extends PlayerEvent implements Cancellable { + private static final HandlerList handlers = new HandlerList(); private String leaveMessage; private String kickReason; private Boolean cancel; @@ -62,4 +64,13 @@ public class PlayerKickEvent extends PlayerEvent implements Cancellable { public void setLeaveMessage(String leaveMessage) { this.leaveMessage = leaveMessage; } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerListener.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerListener.java index f108a32fbb..508c8d2fb5 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerListener.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerListener.java @@ -5,6 +5,7 @@ import org.bukkit.event.Listener; /** * Handles all events thrown in relation to a Player */ +@Deprecated public class PlayerListener implements Listener { public PlayerListener() {} diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerLoginEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerLoginEvent.java index 2bda0ec34f..1982878c37 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerLoginEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerLoginEvent.java @@ -1,12 +1,14 @@ package org.bukkit.event.player; import org.bukkit.entity.Player; +import org.bukkit.event.HandlerList; /** * Stores details for players attempting to log in */ @SuppressWarnings("serial") public class PlayerLoginEvent extends PlayerEvent { + private static final HandlerList handlers = new HandlerList(); private Result result; private String message; @@ -77,6 +79,15 @@ public class PlayerLoginEvent extends PlayerEvent { this.message = message; } + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } + /** * Basic kick reasons for communicating to plugins */ diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerMoveEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerMoveEvent.java index 5130cc69ff..faa50282aa 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerMoveEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerMoveEvent.java @@ -4,12 +4,14 @@ import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; /** * Holds information for player movement events */ @SuppressWarnings("serial") public class PlayerMoveEvent extends PlayerEvent implements Cancellable { + private static final HandlerList handlers = new HandlerList(); private boolean cancel = false; private Location from; private Location to; @@ -89,4 +91,13 @@ public class PlayerMoveEvent extends PlayerEvent implements Cancellable { public void setTo(Location to) { this.to = to; } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerPickupItemEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerPickupItemEvent.java index ac1b27b06e..e20b1c5ad7 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerPickupItemEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerPickupItemEvent.java @@ -3,12 +3,14 @@ package org.bukkit.event.player; import org.bukkit.entity.Item; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; /** * Thrown when a player picks an item up from the ground */ @SuppressWarnings("serial") public class PlayerPickupItemEvent extends PlayerEvent implements Cancellable { + private static final HandlerList handlers = new HandlerList(); private final Item item; private boolean cancel = false; private int remaining; @@ -44,4 +46,13 @@ public class PlayerPickupItemEvent extends PlayerEvent implements Cancellable { public void setCancelled(boolean cancel) { this.cancel = cancel; } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerPortalEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerPortalEvent.java index ad500f4dde..a5d80a715e 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerPortalEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerPortalEvent.java @@ -3,12 +3,14 @@ package org.bukkit.event.player; import org.bukkit.Location; import org.bukkit.TravelAgent; import org.bukkit.entity.Player; +import org.bukkit.event.HandlerList; /** * Called when a player completes the portaling process by standing in a portal */ @SuppressWarnings("serial") public class PlayerPortalEvent extends PlayerTeleportEvent { + private static final HandlerList handlers = new HandlerList(); protected boolean useTravelAgent = true; @@ -35,4 +37,13 @@ public class PlayerPortalEvent extends PlayerTeleportEvent { public void setPortalTravelAgent(TravelAgent travelAgent) { this.travelAgent = travelAgent; } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } } \ No newline at end of file diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerPreLoginEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerPreLoginEvent.java index cfdc2fc2a6..e83724cb34 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerPreLoginEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerPreLoginEvent.java @@ -2,12 +2,14 @@ package org.bukkit.event.player; import java.net.InetAddress; import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; /** * Stores details for players attempting to log in */ @SuppressWarnings("serial") public class PlayerPreLoginEvent extends Event { + private static final HandlerList handlers = new HandlerList(); private Result result; private String message; private String name; @@ -94,6 +96,15 @@ public class PlayerPreLoginEvent extends Event { return ipAddress; } + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } + /** * Basic kick reasons for communicating to plugins */ diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerQuitEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerQuitEvent.java index 28598e70bb..6eea9dc5a2 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerQuitEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerQuitEvent.java @@ -1,12 +1,14 @@ package org.bukkit.event.player; import org.bukkit.entity.Player; +import org.bukkit.event.HandlerList; /** * Called when a player leaves a server */ @SuppressWarnings("serial") public class PlayerQuitEvent extends PlayerEvent { + private static final HandlerList handlers = new HandlerList(); private String quitMessage; @@ -32,4 +34,13 @@ public class PlayerQuitEvent extends PlayerEvent { public void setQuitMessage(String quitMessage) { this.quitMessage = quitMessage; } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerRespawnEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerRespawnEvent.java index 6b82420de4..9a3014d216 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerRespawnEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerRespawnEvent.java @@ -2,9 +2,11 @@ package org.bukkit.event.player; import org.bukkit.Location; import org.bukkit.entity.Player; +import org.bukkit.event.HandlerList; @SuppressWarnings("serial") public class PlayerRespawnEvent extends PlayerEvent { + private static final HandlerList handlers = new HandlerList(); private Location respawnLocation; private boolean isBedSpawn; @@ -40,4 +42,13 @@ public class PlayerRespawnEvent extends PlayerEvent { public boolean isBedSpawn() { return this.isBedSpawn; } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerTeleportEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerTeleportEvent.java index 468f9e574d..e3cbb4c711 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerTeleportEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerTeleportEvent.java @@ -3,12 +3,14 @@ package org.bukkit.event.player; import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; /** * Holds information for player teleport events */ @SuppressWarnings("serial") public class PlayerTeleportEvent extends PlayerMoveEvent { + private static final HandlerList handlers = new HandlerList(); private TeleportCause cause = TeleportCause.UNKNOWN; public PlayerTeleportEvent(Player player, Location from, Location to) { @@ -58,4 +60,13 @@ public class PlayerTeleportEvent extends PlayerMoveEvent { */ UNKNOWN; } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerToggleSneakEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerToggleSneakEvent.java index 1c6eb41839..dcd39bc6e6 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerToggleSneakEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerToggleSneakEvent.java @@ -2,12 +2,14 @@ package org.bukkit.event.player; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; /** * Called when a player toggles their sneaking state */ @SuppressWarnings("serial") public class PlayerToggleSneakEvent extends PlayerEvent implements Cancellable { + private static final HandlerList handlers = new HandlerList(); private boolean isSneaking; private boolean cancel = false; @@ -32,4 +34,13 @@ public class PlayerToggleSneakEvent extends PlayerEvent implements Cancellable { public void setCancelled(boolean cancel) { this.cancel = cancel; } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerToggleSprintEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerToggleSprintEvent.java index be8d53faf8..24a3cd8c99 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerToggleSprintEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerToggleSprintEvent.java @@ -2,12 +2,14 @@ package org.bukkit.event.player; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; /** * Called when a player toggles their sprinting state */ @SuppressWarnings("serial") public class PlayerToggleSprintEvent extends PlayerEvent implements Cancellable { + private static final HandlerList handlers = new HandlerList(); private boolean isSprinting; private boolean cancel = false; @@ -32,4 +34,13 @@ public class PlayerToggleSprintEvent extends PlayerEvent implements Cancellable public void setCancelled(boolean cancel) { this.cancel = cancel; } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } } \ No newline at end of file diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerVelocityEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerVelocityEvent.java index 45575cf033..a4309535c7 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerVelocityEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerVelocityEvent.java @@ -3,10 +3,12 @@ package org.bukkit.event.player; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; import org.bukkit.util.Vector; @SuppressWarnings("serial") public class PlayerVelocityEvent extends PlayerEvent implements Cancellable { + private static final HandlerList handlers = new HandlerList(); /** * Holds information for player velocity events @@ -61,4 +63,13 @@ public class PlayerVelocityEvent extends PlayerEvent implements Cancellable { public void setVelocity(Vector velocity) { this.velocity = velocity; } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/server/MapInitializeEvent.java b/paper-api/src/main/java/org/bukkit/event/server/MapInitializeEvent.java index 003bff4fb1..5b5b15e1bf 100644 --- a/paper-api/src/main/java/org/bukkit/event/server/MapInitializeEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/server/MapInitializeEvent.java @@ -1,6 +1,7 @@ package org.bukkit.event.server; import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; import org.bukkit.map.MapView; /** @@ -8,6 +9,7 @@ import org.bukkit.map.MapView; */ @SuppressWarnings("serial") public class MapInitializeEvent extends ServerEvent { + private static final HandlerList handlers = new HandlerList(); private final MapView mapView; public MapInitializeEvent(MapView mapView) { @@ -23,4 +25,13 @@ public class MapInitializeEvent extends ServerEvent { public MapView getMap() { return mapView; } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/server/PluginDisableEvent.java b/paper-api/src/main/java/org/bukkit/event/server/PluginDisableEvent.java index 195c93bfa9..498aeaee51 100644 --- a/paper-api/src/main/java/org/bukkit/event/server/PluginDisableEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/server/PluginDisableEvent.java @@ -1,5 +1,6 @@ package org.bukkit.event.server; +import org.bukkit.event.HandlerList; import org.bukkit.plugin.Plugin; /** @@ -7,7 +8,17 @@ import org.bukkit.plugin.Plugin; */ @SuppressWarnings("serial") public class PluginDisableEvent extends PluginEvent { + private static final HandlerList handlers = new HandlerList(); public PluginDisableEvent(Plugin plugin) { super(Type.PLUGIN_DISABLE, plugin); } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/server/PluginEnableEvent.java b/paper-api/src/main/java/org/bukkit/event/server/PluginEnableEvent.java index 089b679e2d..4bd5fd8495 100644 --- a/paper-api/src/main/java/org/bukkit/event/server/PluginEnableEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/server/PluginEnableEvent.java @@ -1,5 +1,6 @@ package org.bukkit.event.server; +import org.bukkit.event.HandlerList; import org.bukkit.plugin.Plugin; /** @@ -7,7 +8,17 @@ import org.bukkit.plugin.Plugin; */ @SuppressWarnings("serial") public class PluginEnableEvent extends PluginEvent { + private static final HandlerList handlers = new HandlerList(); public PluginEnableEvent(Plugin plugin) { super(Type.PLUGIN_ENABLE, plugin); } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/server/PluginEvent.java b/paper-api/src/main/java/org/bukkit/event/server/PluginEvent.java index 13c2619505..987ac5245d 100644 --- a/paper-api/src/main/java/org/bukkit/event/server/PluginEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/server/PluginEvent.java @@ -6,7 +6,7 @@ import org.bukkit.plugin.Plugin; * Used for plugin enable and disable events */ @SuppressWarnings("serial") -public class PluginEvent extends ServerEvent { +public abstract class PluginEvent extends ServerEvent { private final Plugin plugin; public PluginEvent(final Type type, final Plugin plugin) { diff --git a/paper-api/src/main/java/org/bukkit/event/server/ServerCommandEvent.java b/paper-api/src/main/java/org/bukkit/event/server/ServerCommandEvent.java index c4c41ba208..ebf9079b35 100644 --- a/paper-api/src/main/java/org/bukkit/event/server/ServerCommandEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/server/ServerCommandEvent.java @@ -2,12 +2,14 @@ package org.bukkit.event.server; import org.bukkit.command.CommandSender; import org.bukkit.command.ConsoleCommandSender; +import org.bukkit.event.HandlerList; /** * Server Command events */ @SuppressWarnings("serial") public class ServerCommandEvent extends ServerEvent { + private static final HandlerList handlers = new HandlerList(); private String command; private CommandSender sender; @@ -48,4 +50,13 @@ public class ServerCommandEvent extends ServerEvent { public CommandSender getSender() { return sender; } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/server/ServerEvent.java b/paper-api/src/main/java/org/bukkit/event/server/ServerEvent.java index 8c2ed26c9d..1ac8c3596b 100644 --- a/paper-api/src/main/java/org/bukkit/event/server/ServerEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/server/ServerEvent.java @@ -6,7 +6,7 @@ import org.bukkit.event.Event; * Miscellaneous server events */ @SuppressWarnings("serial") -public class ServerEvent extends Event { +public abstract class ServerEvent extends Event { public ServerEvent(final Type type) { super(type); } diff --git a/paper-api/src/main/java/org/bukkit/event/server/ServerListPingEvent.java b/paper-api/src/main/java/org/bukkit/event/server/ServerListPingEvent.java index d5162faa94..0df6f3cd60 100644 --- a/paper-api/src/main/java/org/bukkit/event/server/ServerListPingEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/server/ServerListPingEvent.java @@ -3,12 +3,14 @@ package org.bukkit.event.server; import java.net.InetAddress; import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; /** * Called when a server list ping is coming in. */ @SuppressWarnings("serial") public class ServerListPingEvent extends ServerEvent { + private static final HandlerList handlers = new HandlerList(); private InetAddress address; private String motd; @@ -76,4 +78,13 @@ public class ServerListPingEvent extends ServerEvent { public void setMaxPlayers(int maxPlayers) { this.maxPlayers = maxPlayers; } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/server/ServerListener.java b/paper-api/src/main/java/org/bukkit/event/server/ServerListener.java index 24a550a3a9..5c76e4f36e 100644 --- a/paper-api/src/main/java/org/bukkit/event/server/ServerListener.java +++ b/paper-api/src/main/java/org/bukkit/event/server/ServerListener.java @@ -5,6 +5,7 @@ import org.bukkit.event.Listener; /** * Handles all miscellaneous server events */ +@Deprecated public class ServerListener implements Listener { /** diff --git a/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleBlockCollisionEvent.java b/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleBlockCollisionEvent.java index 5d53ec2916..af840d49b7 100644 --- a/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleBlockCollisionEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleBlockCollisionEvent.java @@ -2,12 +2,14 @@ package org.bukkit.event.vehicle; import org.bukkit.block.Block; import org.bukkit.entity.Vehicle; +import org.bukkit.event.HandlerList; /** * Raised when a vehicle collides with a block. */ @SuppressWarnings("serial") public class VehicleBlockCollisionEvent extends VehicleCollisionEvent { + private static final HandlerList handlers = new HandlerList(); private Block block; public VehicleBlockCollisionEvent(Vehicle vehicle, Block block) { @@ -23,4 +25,13 @@ public class VehicleBlockCollisionEvent extends VehicleCollisionEvent { public Block getBlock() { return block; } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleCollisionEvent.java b/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleCollisionEvent.java index 526adeef68..7a3f7ac6c3 100644 --- a/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleCollisionEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleCollisionEvent.java @@ -6,7 +6,7 @@ import org.bukkit.entity.Vehicle; * Raised when a vehicle collides. */ @SuppressWarnings("serial") -public class VehicleCollisionEvent extends VehicleEvent { +public abstract class VehicleCollisionEvent extends VehicleEvent { public VehicleCollisionEvent(Type type, Vehicle vehicle) { super(type, vehicle); } diff --git a/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleCreateEvent.java b/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleCreateEvent.java index f9ea795827..2050c9d31f 100644 --- a/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleCreateEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleCreateEvent.java @@ -1,13 +1,24 @@ package org.bukkit.event.vehicle; import org.bukkit.entity.Vehicle; +import org.bukkit.event.HandlerList; /** * Raised when a vehicle is created. */ @SuppressWarnings("serial") public class VehicleCreateEvent extends VehicleEvent { + private static final HandlerList handlers = new HandlerList(); public VehicleCreateEvent(Vehicle vehicle) { super(Type.VEHICLE_CREATE, vehicle); } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleDamageEvent.java b/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleDamageEvent.java index 3811049da0..e67a9e780e 100644 --- a/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleDamageEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleDamageEvent.java @@ -3,12 +3,14 @@ package org.bukkit.event.vehicle; import org.bukkit.entity.Entity; import org.bukkit.entity.Vehicle; import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; /** * Raised when a vehicle receives damage. */ @SuppressWarnings("serial") public class VehicleDamageEvent extends VehicleEvent implements Cancellable { + private static final HandlerList handlers = new HandlerList(); private Entity attacker; private int damage; private boolean cancelled; @@ -53,4 +55,13 @@ public class VehicleDamageEvent extends VehicleEvent implements Cancellable { public void setCancelled(boolean cancel) { this.cancelled = cancel; } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleDestroyEvent.java b/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleDestroyEvent.java index ac087e34a8..d833e6366f 100644 --- a/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleDestroyEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleDestroyEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.vehicle; import org.bukkit.entity.Entity; import org.bukkit.entity.Vehicle; import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; /** * Raised when a vehicle is destroyed, which could be caused by either a player @@ -11,6 +12,7 @@ import org.bukkit.event.Cancellable; */ @SuppressWarnings("serial") public class VehicleDestroyEvent extends VehicleEvent implements Cancellable { + private static final HandlerList handlers = new HandlerList(); private Entity attacker; private boolean cancelled; @@ -35,4 +37,13 @@ public class VehicleDestroyEvent extends VehicleEvent implements Cancellable { public void setCancelled(boolean cancel) { this.cancelled = cancel; } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleEnterEvent.java b/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleEnterEvent.java index 04b3e06902..eeb0eb357c 100644 --- a/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleEnterEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleEnterEvent.java @@ -3,12 +3,14 @@ package org.bukkit.event.vehicle; import org.bukkit.entity.Entity; import org.bukkit.entity.Vehicle; import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; /** * Raised when an entity enters a vehicle. */ @SuppressWarnings("serial") public class VehicleEnterEvent extends VehicleEvent implements Cancellable { + private static final HandlerList handlers = new HandlerList(); private boolean cancelled; private Entity entered; @@ -33,4 +35,13 @@ public class VehicleEnterEvent extends VehicleEvent implements Cancellable { public void setCancelled(boolean cancel) { this.cancelled = cancel; } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleEntityCollisionEvent.java b/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleEntityCollisionEvent.java index a2b285a4de..22877d6c9b 100644 --- a/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleEntityCollisionEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleEntityCollisionEvent.java @@ -3,12 +3,14 @@ package org.bukkit.event.vehicle; import org.bukkit.entity.Entity; import org.bukkit.entity.Vehicle; import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; /** * Raised when a vehicle collides with an entity. */ @SuppressWarnings("serial") public class VehicleEntityCollisionEvent extends VehicleCollisionEvent implements Cancellable { + private static final HandlerList handlers = new HandlerList(); private Entity entity; private boolean cancelled = false; private boolean cancelledPickup = false; @@ -46,4 +48,13 @@ public class VehicleEntityCollisionEvent extends VehicleCollisionEvent implement public void setCollisionCancelled(boolean cancel) { cancelledCollision = cancel; } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleEvent.java b/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleEvent.java index 5e2a1fd973..cd1ac7e960 100644 --- a/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleEvent.java @@ -7,7 +7,7 @@ import org.bukkit.event.Event; * Represents a vehicle-related event. */ @SuppressWarnings("serial") -public class VehicleEvent extends Event { +public abstract class VehicleEvent extends Event { protected Vehicle vehicle; public VehicleEvent(final Event.Type type, final Vehicle vehicle) { diff --git a/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleExitEvent.java b/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleExitEvent.java index e6a44e02b3..10223e6078 100644 --- a/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleExitEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleExitEvent.java @@ -3,12 +3,14 @@ package org.bukkit.event.vehicle; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Vehicle; import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; /** * Raised when a living entity exits a vehicle. */ @SuppressWarnings("serial") public class VehicleExitEvent extends VehicleEvent implements Cancellable { + private static final HandlerList handlers = new HandlerList(); private boolean cancelled; private LivingEntity exited; @@ -33,4 +35,13 @@ public class VehicleExitEvent extends VehicleEvent implements Cancellable { public void setCancelled(boolean cancel) { this.cancelled = cancel; } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleListener.java b/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleListener.java index 20125f2a9e..2d7fc208a4 100644 --- a/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleListener.java +++ b/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleListener.java @@ -5,6 +5,7 @@ import org.bukkit.event.Listener; /** * Listener for vehicle events. */ +@Deprecated public class VehicleListener implements Listener { public VehicleListener() {} diff --git a/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleMoveEvent.java b/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleMoveEvent.java index 9365d7beb9..6bf31c8dfe 100644 --- a/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleMoveEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleMoveEvent.java @@ -2,12 +2,14 @@ package org.bukkit.event.vehicle; import org.bukkit.Location; import org.bukkit.entity.Vehicle; +import org.bukkit.event.HandlerList; /** * Raised when a vehicle moves. */ @SuppressWarnings("serial") public class VehicleMoveEvent extends VehicleEvent { + private static final HandlerList handlers = new HandlerList(); private Location from; private Location to; @@ -35,4 +37,14 @@ public class VehicleMoveEvent extends VehicleEvent { public Location getTo() { return to; } + + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleUpdateEvent.java b/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleUpdateEvent.java index 5fc193f3fa..9e2342e4a2 100644 --- a/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleUpdateEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleUpdateEvent.java @@ -1,10 +1,21 @@ package org.bukkit.event.vehicle; import org.bukkit.entity.Vehicle; +import org.bukkit.event.HandlerList; @SuppressWarnings("serial") public class VehicleUpdateEvent extends VehicleEvent { + private static final HandlerList handlers = new HandlerList(); public VehicleUpdateEvent(Vehicle vehicle) { super(Type.VEHICLE_UPDATE, vehicle); } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/weather/LightningStrikeEvent.java b/paper-api/src/main/java/org/bukkit/event/weather/LightningStrikeEvent.java index 2bcd37a0e0..b778c595be 100644 --- a/paper-api/src/main/java/org/bukkit/event/weather/LightningStrikeEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/weather/LightningStrikeEvent.java @@ -3,12 +3,14 @@ package org.bukkit.event.weather; import org.bukkit.World; import org.bukkit.entity.LightningStrike; import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; /** * Stores data for lightning striking */ @SuppressWarnings("serial") public class LightningStrikeEvent extends WeatherEvent implements Cancellable { + private static final HandlerList handlers = new HandlerList(); private boolean canceled; private LightningStrike bolt; @@ -34,4 +36,13 @@ public class LightningStrikeEvent extends WeatherEvent implements Cancellable { public LightningStrike getLightning() { return bolt; } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/weather/ThunderChangeEvent.java b/paper-api/src/main/java/org/bukkit/event/weather/ThunderChangeEvent.java index 891537668f..2c36e2a194 100644 --- a/paper-api/src/main/java/org/bukkit/event/weather/ThunderChangeEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/weather/ThunderChangeEvent.java @@ -2,12 +2,14 @@ package org.bukkit.event.weather; import org.bukkit.World; import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; /** * Stores data for thunder state changing in a world */ @SuppressWarnings("serial") public class ThunderChangeEvent extends WeatherEvent implements Cancellable { + private static final HandlerList handlers = new HandlerList(); private boolean canceled; private boolean to; @@ -33,4 +35,13 @@ public class ThunderChangeEvent extends WeatherEvent implements Cancellable { public boolean toThunderState() { return to; } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/weather/WeatherChangeEvent.java b/paper-api/src/main/java/org/bukkit/event/weather/WeatherChangeEvent.java index 955be2eee3..631e0a04cb 100644 --- a/paper-api/src/main/java/org/bukkit/event/weather/WeatherChangeEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/weather/WeatherChangeEvent.java @@ -2,12 +2,14 @@ package org.bukkit.event.weather; import org.bukkit.World; import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; /** * Stores data for weather changing in a world */ @SuppressWarnings("serial") public class WeatherChangeEvent extends WeatherEvent implements Cancellable { + private static final HandlerList handlers = new HandlerList(); private boolean canceled; private boolean to; @@ -33,4 +35,13 @@ public class WeatherChangeEvent extends WeatherEvent implements Cancellable { public boolean toWeatherState() { return to; } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/weather/WeatherEvent.java b/paper-api/src/main/java/org/bukkit/event/weather/WeatherEvent.java index 5036a3e06c..7d548f32ed 100644 --- a/paper-api/src/main/java/org/bukkit/event/weather/WeatherEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/weather/WeatherEvent.java @@ -7,7 +7,7 @@ import org.bukkit.event.Event; * Represents a Weather-related event */ @SuppressWarnings("serial") -public class WeatherEvent extends Event { +public abstract class WeatherEvent extends Event { protected World world; public WeatherEvent(final Event.Type type, final World where) { diff --git a/paper-api/src/main/java/org/bukkit/event/weather/WeatherListener.java b/paper-api/src/main/java/org/bukkit/event/weather/WeatherListener.java index 1a6d6ce844..98212480f2 100644 --- a/paper-api/src/main/java/org/bukkit/event/weather/WeatherListener.java +++ b/paper-api/src/main/java/org/bukkit/event/weather/WeatherListener.java @@ -5,6 +5,7 @@ import org.bukkit.event.Listener; /** * Handles all events fired in relation to weather */ +@Deprecated public class WeatherListener implements Listener { public WeatherListener() {} diff --git a/paper-api/src/main/java/org/bukkit/event/world/ChunkEvent.java b/paper-api/src/main/java/org/bukkit/event/world/ChunkEvent.java index c36fe670e4..f7702de033 100644 --- a/paper-api/src/main/java/org/bukkit/event/world/ChunkEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/world/ChunkEvent.java @@ -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) { diff --git a/paper-api/src/main/java/org/bukkit/event/world/ChunkLoadEvent.java b/paper-api/src/main/java/org/bukkit/event/world/ChunkLoadEvent.java index 870de349ec..9941cc56f7 100644 --- a/paper-api/src/main/java/org/bukkit/event/world/ChunkLoadEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/world/ChunkLoadEvent.java @@ -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; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/world/ChunkPopulateEvent.java b/paper-api/src/main/java/org/bukkit/event/world/ChunkPopulateEvent.java index d5d476afd4..830189b364 100644 --- a/paper-api/src/main/java/org/bukkit/event/world/ChunkPopulateEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/world/ChunkPopulateEvent.java @@ -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; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/world/ChunkUnloadEvent.java b/paper-api/src/main/java/org/bukkit/event/world/ChunkUnloadEvent.java index 8c4e7667e5..b08ab9b16e 100644 --- a/paper-api/src/main/java/org/bukkit/event/world/ChunkUnloadEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/world/ChunkUnloadEvent.java @@ -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; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/world/PortalCreateEvent.java b/paper-api/src/main/java/org/bukkit/event/world/PortalCreateEvent.java index 26f357353b..3c71935fef 100644 --- a/paper-api/src/main/java/org/bukkit/event/world/PortalCreateEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/world/PortalCreateEvent.java @@ -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 blocks = new ArrayList(); @@ -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; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/world/SpawnChangeEvent.java b/paper-api/src/main/java/org/bukkit/event/world/SpawnChangeEvent.java index 4ea14dc6d7..c7bb1b3dfb 100644 --- a/paper-api/src/main/java/org/bukkit/event/world/SpawnChangeEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/world/SpawnChangeEvent.java @@ -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; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/world/StructureGrowEvent.java b/paper-api/src/main/java/org/bukkit/event/world/StructureGrowEvent.java index b3e3382223..8b7b168519 100644 --- a/paper-api/src/main/java/org/bukkit/event/world/StructureGrowEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/world/StructureGrowEvent.java @@ -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; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/world/WorldEvent.java b/paper-api/src/main/java/org/bukkit/event/world/WorldEvent.java index e822dae49a..6194177344 100644 --- a/paper-api/src/main/java/org/bukkit/event/world/WorldEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/world/WorldEvent.java @@ -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) { diff --git a/paper-api/src/main/java/org/bukkit/event/world/WorldInitEvent.java b/paper-api/src/main/java/org/bukkit/event/world/WorldInitEvent.java index 79fbcd33b8..340bcd0f90 100644 --- a/paper-api/src/main/java/org/bukkit/event/world/WorldInitEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/world/WorldInitEvent.java @@ -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; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/world/WorldListener.java b/paper-api/src/main/java/org/bukkit/event/world/WorldListener.java index 2d1f791638..df46cb2388 100644 --- a/paper-api/src/main/java/org/bukkit/event/world/WorldListener.java +++ b/paper-api/src/main/java/org/bukkit/event/world/WorldListener.java @@ -5,6 +5,7 @@ import org.bukkit.event.Listener; /** * Handles all World related events */ +@Deprecated public class WorldListener implements Listener { /** diff --git a/paper-api/src/main/java/org/bukkit/event/world/WorldLoadEvent.java b/paper-api/src/main/java/org/bukkit/event/world/WorldLoadEvent.java index 3519d3382a..fdc5fdfad8 100644 --- a/paper-api/src/main/java/org/bukkit/event/world/WorldLoadEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/world/WorldLoadEvent.java @@ -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; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/world/WorldSaveEvent.java b/paper-api/src/main/java/org/bukkit/event/world/WorldSaveEvent.java index 414bd2963a..3db8ff3479 100644 --- a/paper-api/src/main/java/org/bukkit/event/world/WorldSaveEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/world/WorldSaveEvent.java @@ -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; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/world/WorldUnloadEvent.java b/paper-api/src/main/java/org/bukkit/event/world/WorldUnloadEvent.java index 821d6ef735..2063e7e80a 100644 --- a/paper-api/src/main/java/org/bukkit/event/world/WorldUnloadEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/world/WorldUnloadEvent.java @@ -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; + } } diff --git a/paper-api/src/main/java/org/bukkit/plugin/EventExecutor.java b/paper-api/src/main/java/org/bukkit/plugin/EventExecutor.java index aad7f14098..3b2c99ea7b 100644 --- a/paper-api/src/main/java/org/bukkit/plugin/EventExecutor.java +++ b/paper-api/src/main/java/org/bukkit/plugin/EventExecutor.java @@ -1,11 +1,12 @@ package org.bukkit.plugin; import org.bukkit.event.Event; +import org.bukkit.event.EventException; import org.bukkit.event.Listener; /** * Interface which defines the class for event call backs to plugins */ public interface EventExecutor { - public void execute(Listener listener, Event event); + public void execute(Listener listener, Event event) throws EventException; } diff --git a/paper-api/src/main/java/org/bukkit/plugin/PluginLoader.java b/paper-api/src/main/java/org/bukkit/plugin/PluginLoader.java index 07b50e256c..bc4e849fe7 100644 --- a/paper-api/src/main/java/org/bukkit/plugin/PluginLoader.java +++ b/paper-api/src/main/java/org/bukkit/plugin/PluginLoader.java @@ -1,6 +1,8 @@ package org.bukkit.plugin; import java.io.File; +import java.util.Map; +import java.util.Set; import java.util.regex.Pattern; import org.bukkit.event.Event; @@ -51,8 +53,18 @@ public interface PluginLoader { * @param listener the object that will handle the eventual call back * @return The new executor */ + @Deprecated public EventExecutor createExecutor(Event.Type type, Listener listener); + /** + * Creates and returns registered listeners for the event classes used in this listener + * + * @param listener The object that will handle the eventual call back + * @param plugin The plugin to use when creating registered listeners + * @return The registered listeners. + */ + public Map, Set> createRegisteredListeners(Listener listener, Plugin plugin); + /** * Enables the specified plugin *

diff --git a/paper-api/src/main/java/org/bukkit/plugin/PluginManager.java b/paper-api/src/main/java/org/bukkit/plugin/PluginManager.java index 2ecc1e0c5b..ea59dcdebc 100644 --- a/paper-api/src/main/java/org/bukkit/plugin/PluginManager.java +++ b/paper-api/src/main/java/org/bukkit/plugin/PluginManager.java @@ -2,9 +2,9 @@ package org.bukkit.plugin; import java.io.File; import java.util.Set; - import org.bukkit.event.Event; import org.bukkit.event.Event.Priority; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.permissions.Permissible; import org.bukkit.permissions.Permission; @@ -92,6 +92,7 @@ public interface PluginManager { * Calls an event with the given details * * @param event Event details + * @return Called event */ public void callEvent(Event event); @@ -103,6 +104,7 @@ public interface PluginManager { * @param priority Priority of this event * @param plugin Plugin to register */ + @Deprecated public void registerEvent(Event.Type type, Listener listener, Priority priority, Plugin plugin); /** @@ -114,8 +116,28 @@ public interface PluginManager { * @param priority Priority of this event * @param plugin Plugin to register */ + @Deprecated public void registerEvent(Event.Type type, Listener listener, EventExecutor executor, Priority priority, Plugin plugin); + /** + * Registers all the events in the given listener class + * + * @param listener Listener to register + * @param plugin Plugin to register + */ + public void registerEvents(Listener listener, Plugin plugin); + + /** + * Registers the specified executor to the given event class + * + * @param event Event type to register + * @param listener Listener to register + * @param priority Priority to register this event at + * @param executor EventExecutor to register + * @param plugin Plugin to register + */ + public void registerEvent(Class event, Listener listener, EventPriority priority, EventExecutor executor, Plugin plugin); + /** * Enables the specified plugin *

diff --git a/paper-api/src/main/java/org/bukkit/plugin/RegisteredListener.java b/paper-api/src/main/java/org/bukkit/plugin/RegisteredListener.java index 4f7e7bf299..9111ae43b3 100644 --- a/paper-api/src/main/java/org/bukkit/plugin/RegisteredListener.java +++ b/paper-api/src/main/java/org/bukkit/plugin/RegisteredListener.java @@ -1,6 +1,8 @@ package org.bukkit.plugin; import org.bukkit.event.Event; +import org.bukkit.event.EventException; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; /** @@ -8,24 +10,17 @@ import org.bukkit.event.Listener; */ public class RegisteredListener { private final Listener listener; - private final Event.Priority priority; + private final EventPriority priority; private final Plugin plugin; private final EventExecutor executor; - public RegisteredListener(final Listener pluginListener, final EventExecutor eventExecutor, final Event.Priority eventPriority, final Plugin registeredPlugin) { + public RegisteredListener(final Listener pluginListener, final EventExecutor eventExecutor, final EventPriority eventPriority, final Plugin registeredPlugin) { listener = pluginListener; priority = eventPriority; plugin = registeredPlugin; executor = eventExecutor; } - public RegisteredListener(final Listener pluginListener, final Event.Priority eventPriority, final Plugin registeredPlugin, Event.Type type) { - listener = pluginListener; - priority = eventPriority; - plugin = registeredPlugin; - executor = registeredPlugin.getPluginLoader().createExecutor(type, pluginListener); - } - /** * Gets the listener for this registration * @@ -49,7 +44,7 @@ public class RegisteredListener { * * @return Registered Priority */ - public Event.Priority getPriority() { + public EventPriority getPriority() { return priority; } @@ -58,7 +53,7 @@ public class RegisteredListener { * * @param event The event */ - public void callEvent(Event event) { + public void callEvent(Event event) throws EventException { executor.execute(listener, event); } } diff --git a/paper-api/src/main/java/org/bukkit/plugin/SimplePluginManager.java b/paper-api/src/main/java/org/bukkit/plugin/SimplePluginManager.java index ea2f023d76..8411e5b0fb 100644 --- a/paper-api/src/main/java/org/bukkit/plugin/SimplePluginManager.java +++ b/paper-api/src/main/java/org/bukkit/plugin/SimplePluginManager.java @@ -3,36 +3,20 @@ package org.bukkit.plugin; import com.google.common.collect.ImmutableSet; import java.io.File; import java.lang.reflect.Constructor; -import java.util.ArrayList; -import java.util.Comparator; -import java.util.EnumMap; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.SortedSet; -import java.util.TreeSet; -import java.util.Arrays; -import java.util.HashSet; -import java.util.LinkedList; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.WeakHashMap; +import java.lang.reflect.Method; +import java.util.*; import java.util.logging.Level; import java.util.regex.Matcher; -import org.bukkit.Server; import java.util.regex.Pattern; +import org.bukkit.Server; import org.bukkit.command.Command; import org.bukkit.command.PluginCommandYamlParser; import org.bukkit.command.SimpleCommandMap; - -import org.bukkit.event.Event; import org.bukkit.event.Event.Priority; -import org.bukkit.event.Listener; +import org.bukkit.event.*; import org.bukkit.permissions.Permissible; import org.bukkit.permissions.Permission; import org.bukkit.permissions.PermissionDefault; - import org.bukkit.util.FileUtil; /** @@ -43,24 +27,12 @@ public final class SimplePluginManager implements PluginManager { private final Map fileAssociations = new HashMap(); private final List plugins = new ArrayList(); private final Map lookupNames = new HashMap(); - private final Map> listeners = new EnumMap>(Event.Type.class); private static File updateDirectory = null; private final SimpleCommandMap commandMap; private final Map permissions = new HashMap(); private final Map> defaultPerms = new LinkedHashMap>(); private final Map> permSubs = new HashMap>(); private final Map> defSubs = new HashMap>(); - private final Comparator comparer = new Comparator() { - public int compare(RegisteredListener i, RegisteredListener j) { - int result = i.getPriority().compareTo(j.getPriority()); - - if ((result == 0) && (i != j)) { - result = 1; - } - - return result; - } - }; public SimplePluginManager(Server instance, SimpleCommandMap commandMap) { server = instance; @@ -281,6 +253,8 @@ public final class SimplePluginManager implements PluginManager { } catch (Throwable ex) { server.getLogger().log(Level.SEVERE, "Error occurred (in the plugin loader) while enabling " + plugin.getDescription().getFullName() + " (Is it up to date?): " + ex.getMessage(), ex); } + + HandlerList.bakeAll(); } } @@ -309,6 +283,12 @@ public final class SimplePluginManager implements PluginManager { } catch (Throwable ex) { server.getLogger().log(Level.SEVERE, "Error occurred (in the plugin loader) while unregistering services for " + plugin.getDescription().getFullName() + " (Is it up to date?): " + ex.getMessage(), ex); } + + try { + HandlerList.unregisterAll(plugin); + } catch (Throwable ex) { + server.getLogger().log(Level.SEVERE, "Error occurred (in the plugin loader) while unregistering events for " + plugin.getDescription().getFullName() + " (Is it up to date?): " + ex.getMessage(), ex); + } } } @@ -317,7 +297,7 @@ public final class SimplePluginManager implements PluginManager { disablePlugins(); plugins.clear(); lookupNames.clear(); - listeners.clear(); + HandlerList.unregisterAll(); fileAssociations.clear(); permissions.clear(); defaultPerms.get(true).clear(); @@ -331,35 +311,59 @@ public final class SimplePluginManager implements PluginManager { * @param event Event details */ public synchronized void callEvent(Event event) { - for (RegisteredListener registration : getEventListeners(event.getType())) { - if (!registration.getPlugin().isEnabled()) { - continue; - } + HandlerList handlers = event.getHandlers(); + handlers.bake(); + RegisteredListener[][] listeners = handlers.getRegisteredListeners(); - try { - long start = System.nanoTime(); - registration.callEvent(event); - registration.getPlugin().incTiming(event.getType(), System.nanoTime() - start); - } catch (AuthorNagException ex) { - Plugin plugin = registration.getPlugin(); - - if (plugin.isNaggable()) { - plugin.setNaggable(false); - - String author = ""; - - if (plugin.getDescription().getAuthors().size() > 0) { - author = plugin.getDescription().getAuthors().get(0); + if (listeners != null) { + for (int i = 0; i < listeners.length; i++) { + for (RegisteredListener registration : listeners[i]) { + if (!registration.getPlugin().isEnabled()) { + continue; + } + + try { + long start = System.nanoTime(); + registration.callEvent(event); + registration.getPlugin().incTiming(event.getType(), System.nanoTime() - start); + } catch (AuthorNagException ex) { + Plugin plugin = registration.getPlugin(); + + if (plugin.isNaggable()) { + plugin.setNaggable(false); + + String author = ""; + + if (plugin.getDescription().getAuthors().size() > 0) { + author = plugin.getDescription().getAuthors().get(0); + } + server.getLogger().log(Level.SEVERE, String.format( + "Nag author: '%s' of '%s' about the following: %s", + author, + plugin.getDescription().getName(), + ex.getMessage() + )); + } + } catch (Throwable ex) { + server.getLogger().log(Level.SEVERE, "Could not pass event " + event.getEventName() + " to " + registration.getPlugin().getDescription().getName(), ex); + } + } + } + } + // This is an ugly hack to handle old-style custom events in old plugins without breakage. All in the name of plugin compatibility. + if (event.getType() == Event.Type.CUSTOM_EVENT) { + TransitionalCustomEvent.getHandlerList().bake(); + listeners = TransitionalCustomEvent.getHandlerList().getRegisteredListeners(); + if (listeners != null) { + for (int i = 0; i < listeners.length; i++) { + for (RegisteredListener registration : listeners[i]) { + try { + registration.callEvent(event); + } catch (Throwable ex) { + server.getLogger().log(Level.SEVERE, "Could not pass event " + event.getEventName() + " to " + registration.getPlugin().getDescription().getName(), ex); + } } - server.getLogger().log(Level.SEVERE, String.format( - "Nag author: '%s' of '%s' about the following: %s", - author, - plugin.getDescription().getName(), - ex.getMessage() - )); } - } catch (Throwable ex) { - server.getLogger().log(Level.SEVERE, "Could not pass event " + event.getType() + " to " + registration.getPlugin().getDescription().getName(), ex); } } } @@ -389,7 +393,7 @@ public final class SimplePluginManager implements PluginManager { throw new IllegalPluginAccessException("Plugin attempted to register " + type + " while not enabled"); } - getEventListeners(type).add(new RegisteredListener(listener, priority, plugin, type)); + getEventListeners(type.getEventClass()).register(new RegisteredListener(listener, plugin.getPluginLoader().createExecutor(type, listener), priority.getNewPriority(), plugin)); } /** @@ -418,25 +422,61 @@ public final class SimplePluginManager implements PluginManager { throw new IllegalPluginAccessException("Plugin attempted to register " + type + " while not enabled"); } - getEventListeners(type).add(new RegisteredListener(listener, executor, priority, plugin)); + getEventListeners(type.getEventClass()).register(new RegisteredListener(listener, executor, priority.getNewPriority(), plugin)); + } + + public void registerEvents(Listener listener, Plugin plugin) { + if (!plugin.isEnabled()) { + throw new IllegalPluginAccessException("Plugin attempted to register " + listener + " while not enabled"); + } + for (Map.Entry, Set> entry : plugin.getPluginLoader().createRegisteredListeners(listener, plugin).entrySet()) { + Class delegatedClass = getRegistrationClass(entry.getKey()); + if (!entry.getKey().equals(delegatedClass)) { + plugin.getServer().getLogger().severe("Plugin attempted to register delegated event class " + entry.getKey() + ". It should be using " + delegatedClass + "!"); + continue; + } + getEventListeners(delegatedClass).registerAll(entry.getValue()); + } + + } + + public void registerEvent(Class event, Listener listener, EventPriority priority, EventExecutor executor, Plugin plugin) { + if (!plugin.isEnabled()) { + throw new IllegalPluginAccessException("Plugin attempted to register " + event + " while not enabled"); + } + + getEventListeners(event).register(new RegisteredListener(listener, executor, priority, plugin)); } /** - * Returns a SortedSet of RegisteredListener for the specified event type creating a new queue if needed + * Returns the specified event type's HandlerList * * @param type EventType to lookup - * @return SortedSet the looked up or create queue matching the requested type + * @return HandlerList The list of registered handlers for the event. */ - private SortedSet getEventListeners(Event.Type type) { - SortedSet eventListeners = listeners.get(type); - - if (eventListeners != null) { - return eventListeners; + private HandlerList getEventListeners(Class type) { + try { + Method method = getRegistrationClass(type).getDeclaredMethod("getHandlerList"); + method.setAccessible(true); + return (HandlerList)method.invoke(null); + } catch (Exception e) { + throw new IllegalPluginAccessException(e.toString()); } + } - eventListeners = new TreeSet(comparer); - listeners.put(type, eventListeners); - return eventListeners; + private Class getRegistrationClass(Class clazz) { + try { + clazz.getDeclaredMethod("getHandlerList"); + return clazz; + } catch (NoSuchMethodException e) { + if (clazz.getSuperclass() != null + && !clazz.getSuperclass().equals(Event.class) + && clazz.getSuperclass().isAssignableFrom(Event.class)) { + return getRegistrationClass(clazz.getSuperclass().asSubclass(Event.class)); + } else { + throw new IllegalPluginAccessException("Unable to find handler list for event " + clazz.getName()); + } + } } public Permission getPermission(String name) { diff --git a/paper-api/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java b/paper-api/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java index 423598eed8..46fe3340f9 100644 --- a/paper-api/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java +++ b/paper-api/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java @@ -5,21 +5,23 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.lang.reflect.Constructor; +import java.lang.reflect.Method; import java.net.URL; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; -import java.util.ArrayList; +import java.util.*; import java.util.jar.JarEntry; import java.util.jar.JarFile; import java.util.logging.Level; import java.util.regex.Pattern; + +import org.bukkit.Bukkit; import org.bukkit.Server; + import org.bukkit.configuration.serialization.ConfigurationSerializable; import org.bukkit.configuration.serialization.ConfigurationSerialization; import org.bukkit.event.CustomEventListener; import org.bukkit.event.Event; import org.bukkit.event.Listener; +import org.bukkit.event.*; import org.bukkit.event.block.*; import org.bukkit.event.painting.*; import org.bukkit.event.entity.*; @@ -262,7 +264,7 @@ public class JavaPluginLoader implements PluginLoader { } public EventExecutor createExecutor(Event.Type type, Listener listener) { - // TODO: remove multiple Listener type and hence casts + // TODONE: remove multiple Listener type and hence casts switch (type) { // Player Events @@ -971,6 +973,46 @@ public class JavaPluginLoader implements PluginLoader { throw new IllegalArgumentException("Event " + type + " is not supported"); } + public Map, Set> createRegisteredListeners(Listener listener, final Plugin plugin) { + Map, Set> ret = new HashMap, Set>(); + Method[] methods; + try { + methods = listener.getClass().getDeclaredMethods(); + } catch (NoClassDefFoundError e) { + Bukkit.getServer().getLogger().severe("Plugin " + plugin.getDescription().getName() + " is attempting to register event " + e.getMessage() + ", which does not exist. Ignoring events registered in " + listener.getClass()); + return ret; + } + for (int i = 0; i < methods.length; i++) { + final Method method = methods[i]; + final EventHandler eh = method.getAnnotation(EventHandler.class); + if (eh == null) continue; + final Class checkClass = method.getParameterTypes()[0]; + if (!checkClass.isAssignableFrom(eh.event()) || method.getParameterTypes().length != 1) { + plugin.getServer().getLogger().severe("Wrong method arguments used for event type registered"); + continue; + } + method.setAccessible(true); + Set eventSet = ret.get(eh.event()); + if (eventSet == null) { + eventSet = new HashSet(); + ret.put(eh.event(), eventSet); + } + eventSet.add(new RegisteredListener(listener, new EventExecutor() { + public void execute(Listener listener, Event event) throws EventException { + try { + if (!checkClass.isAssignableFrom(event.getClass())) { + throw new EventException("Wrong event type passed to registered method"); + } + method.invoke(listener, event); + } catch (Throwable t) { + throw new EventException(t); + } + } + }, eh.priority(), plugin)); + } + return ret; + } + public void enablePlugin(final Plugin plugin) { if (!(plugin instanceof JavaPlugin)) { throw new IllegalArgumentException("Plugin is not associated with this PluginLoader"); diff --git a/paper-api/src/main/java/org/bukkit/plugin/messaging/Messenger.java b/paper-api/src/main/java/org/bukkit/plugin/messaging/Messenger.java index 5083587ee2..238643e906 100644 --- a/paper-api/src/main/java/org/bukkit/plugin/messaging/Messenger.java +++ b/paper-api/src/main/java/org/bukkit/plugin/messaging/Messenger.java @@ -164,7 +164,7 @@ public interface Messenger { *

* A registration is considered valid if it has not be unregistered and that the plugin * is still enabled. - * + * * @param registration Registration to check. * @return True if the registration is valid, otherwise false. */ diff --git a/paper-api/src/test/java/org/bukkit/configuration/file/YamlConfigurationTest.java b/paper-api/src/test/java/org/bukkit/configuration/file/YamlConfigurationTest.java index 2fbb13681f..dfab8a3407 100644 --- a/paper-api/src/test/java/org/bukkit/configuration/file/YamlConfigurationTest.java +++ b/paper-api/src/test/java/org/bukkit/configuration/file/YamlConfigurationTest.java @@ -37,11 +37,11 @@ public class YamlConfigurationTest extends FileConfigurationTest { " x: 12345.67\n" + " y: 64.0\n" + " z: -12345.6789\n" + - "list:\n" + - "- 1\n" + - "- 2\n" + - "- 3\n" + - "- 4\n" + + "list:\n" + + "- 1\n" + + "- 2\n" + + "- 3\n" + + "- 4\n" + "- 5\n" + "'42': The Answer\n"; }