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

By: Nathan Adams <dinnerbone@dinnerbone.com>
This commit is contained in:
Bukkit/Spigot
2012-01-16 18:25:17 +00:00
parent 94bc6ec0e6
commit e0c7fc6bf5
132 changed files with 1691 additions and 225 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -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<Player> getRecipients() {
return recipients;
}
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}

View File

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

View File

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

View File

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

View File

@@ -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) {

View File

@@ -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
*/

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -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() {}

View File

@@ -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
*/

View File

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

View File

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

View File

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

View File

@@ -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
*/

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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