Transition to Maven

By: Erik Broes <erikbroes@grum.nl>
This commit is contained in:
Bukkit/Spigot
2011-01-01 11:23:14 +01:00
parent e8a16bb993
commit a0fc0979f7
42 changed files with 31 additions and 5 deletions

View File

@@ -0,0 +1,6 @@
package org.bukkit.event;
public interface Cancellable {
public boolean isCancelled();
public void setCancelled(boolean cancel);
}

View File

@@ -0,0 +1,140 @@
package org.bukkit.event;
/**
* Represents an event
*/
public abstract class Event {
private final Type type;
protected Event(final Type type) {
this.type = type;
}
/**
* Gets the Type of this event
* @return Server which this event was triggered on
*/
public Type getType() {
return type;
}
/**
* Represents an events priority
*/
public enum Priority {
/**
* Event is critical and must be called near-first
*/
Highest,
/**
* Event is of high importance
*/
High,
/**
* Event is neither important or unimportant, and may be ran normally
*/
Normal,
/**
* Event is of low importance
*/
Low,
/**
* Event is of extremely low importance, most likely just to monitor events, and must be run near-last
*/
Lowest
}
public enum Category {
PLAYER,
BLOCK,
ITEM,
ENVIRONMENT,
ENTITY,
VEHICLE,
INVENTORY,
SIGN,
CUSTOM;
}
public enum Type {
/**
* Player Events
*/
PLAYER_JOIN (Category.PLAYER),
PLAYER_LOGIN (Category.PLAYER),
PLAYER_CHAT (Category.PLAYER),
PLAYER_COMMAND (Category.PLAYER),
PLAYER_QUIT (Category.PLAYER),
PLAYER_MOVE (Category.PLAYER),
//PLAYER_ANIMATION (Category.PLAYER),
PLAYER_TELEPORT (Category.PLAYER),
/**
* Block Events
*/
BLOCK_BROKEN (Category.BLOCK),
BLOCK_CANBUILD (Category.BLOCK),
BLOCK_FLOW (Category.BLOCK),
BLOCK_IGNITE (Category.BLOCK),
BLOCK_PHYSICS (Category.BLOCK),
BLOCK_PLACED (Category.BLOCK),
BLOCK_RIGHTCLICKED (Category.BLOCK),
REDSTONE_CHANGE (Category.BLOCK);
/**
* Item Events
ITEM_DROP (Category.ITEM),
ITEM_PICK_UP (Category.ITEM),
ITEM_USE (Category.ITEM),
/**
* Environment Events
IGNITE (Category.ENVIRONMENT),
FLOW (Category.ENVIRONMENT),
EXPLODE (Category.ENVIRONMENT),
LIQUID_DESTROY (Category.ENVIRONMENT),
/**
* Non-player Entity Events
MOB_SPAWN (Category.ENTITY),
DAMAGE (Category.ENTITY),
HEALTH_CHANGE (Category.ENTITY),
ATTACK (Category.ENTITY), // Need to look into this category more
/**
* Vehicle Events
VEHICLE_CREATE (Category.VEHICLE),
VEHICLE_UPDATE (Category.VEHICLE),
VEHICLE_DAMAGE (Category.VEHICLE),
VEHICLE_COLLISION (Category.VEHICLE),
VEHICLE_DESTROYED (Category.VEHICLE),
VEHICLE_ENTERED (Category.VEHICLE),
VEHICLE_POSITIONCHANGE (Category.VEHICLE),
/**
* Inventory Events
OPEN_INVENTORY (Category.INVENTORY),
/**
* Sign Events (Item events??)
SIGN_SHOW (Category.SIGN),
SIGN_CHANGE (Category.SIGN);
*/
private Category category;
private Type(Category category) {
this.category = category;
}
public Category getCategory() {
return category;
}
}
}

View File

@@ -0,0 +1,48 @@
package org.bukkit.event;
public class EventException extends Exception {
private static final long serialVersionUID = 3532808232324183999L;
private final Throwable cause;
/**
* Constructs a new EventException based on the given Exception
*
* @param throwable Exception that triggered this Exception
*/
public EventException(Throwable throwable) {
cause = throwable;
}
/**
* Constructs a new EventException
*/
public EventException() {
cause = null;
}
/**
* Constructs a new EventException with the given message
*/
public EventException(Throwable cause, String message) {
super(message);
this.cause = cause;
}
/**
* Constructs a new EventException with the given message
*/
public EventException(String message) {
super(message);
cause = null;
}
/**
* If applicable, returns the Exception that triggered this Exception
*
* @return Inner exception, or null if one does not exist
*/
@Override
public Throwable getCause() {
return cause;
}
}

View File

@@ -0,0 +1,9 @@
package org.bukkit.event;
/**
* Simple interface for tagging all EventListeners
*/
public interface Listener {
}

View File

@@ -0,0 +1,13 @@
package org.bukkit.event.block;
import org.bukkit.Block;
/**
* Not implemented yet
*/
public class BlockBrokenEvent extends BlockEvent {
public BlockBrokenEvent(Type type, Block block ) {
super(type, block);
}
}

View File

@@ -0,0 +1,47 @@
/**
*
*/
package org.bukkit.event.block;
import org.bukkit.Block;
import org.bukkit.Material;
import org.bukkit.event.Cancellable;
/**
* @author durron597
*/
public class BlockCanBuildEvent extends BlockEvent {
protected boolean buildable;
protected int material;
public BlockCanBuildEvent(Type type, Block block, int id, boolean canBuild) {
super(type, block);
buildable = canBuild;
material = id;
}
/**
* Returns whether or not the block can be built here. By default, returns
* Minecraft's answer on whether the block can be built
*
* @return boolean whether or not the block can be built
*/
public boolean isBuildable() {
return buildable;
}
/**
* Set whether the block can be built here.
*/
public void setBuildable(boolean cancel) {
this.buildable = cancel;
}
public Material getMaterial() {
return Material.getMaterial(material);
}
public int getMaterialID() {
return material;
}
}

View File

@@ -0,0 +1,24 @@
package org.bukkit.event.block;
import org.bukkit.Block;
import org.bukkit.event.Event;
/**
* Represents a block related event
*/
public class BlockEvent extends Event {
protected Block block;
public BlockEvent(final Event.Type type, final Block theBlock) {
super(type);
block = theBlock;
}
/**
* Returns the block involved in this event
* @return Block which block is involved in this event
*/
public final Block getBlock() {
return block;
}
}

View File

@@ -0,0 +1,50 @@
package org.bukkit.event.block;
import org.bukkit.Block;
import org.bukkit.BlockFace;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
/**
* Holds information for events with a source block and a destination block
*/
public class BlockFromToEvent extends BlockEvent implements Cancellable {
protected Block from;
protected BlockFace face;
protected boolean cancel;
public BlockFromToEvent(final Event.Type type, final Block block, final BlockFace face) {
super(type, block);
this.face = face;
this.from = block.getRelative(face.getModX(), face.getModY(), face.getModZ());
this.cancel = false;
}
/**
* Gets the location this player moved to
*
* @return Block the block is event originated from
*/
public BlockFace getFace() {
return face;
}
/**
* Convenience method for getting the faced block
*
* @return Block the faced block
*/
public Block getFromBlock() {
return from;
}
@Override
public boolean isCancelled() {
return cancel;
}
@Override
public void setCancelled(boolean cancel) {
this.cancel = cancel;
}
}

View File

@@ -0,0 +1,19 @@
package org.bukkit.event.block;
import org.bukkit.event.Event;
/**
* @author durron597
*
*/
public class BlockIgniteEvent extends Event {
/**
* @param type
*/
public BlockIgniteEvent(Type type) {
super(type);
// TODO Auto-generated constructor stub
}
}

View File

@@ -0,0 +1,81 @@
package org.bukkit.event.block;
import org.bukkit.event.Listener;
/**
* Handles all events thrown in relation to Blocks
*
* @author durron597
*/
public class BlockListener implements Listener {
/**
* Default Constructor
*/
public BlockListener() {
}
/**
* Called when a block is broken (or destroyed)
*
* @param event Relevant event details
*/
public void onBlockBroken(BlockBrokenEvent event) {
}
/**
* Called when we try to place a block, to see if we can build it
*/
public void onBlockCanBuild(BlockCanBuildEvent event) {
}
/**
* Called when a block flows (water/lava)
*
* @param event Relevant event details
*/
public void onBlockFlow(BlockFromToEvent event) {
}
/**
* Called when a block gets ignited
*
* @param event Relevant event details
*/
public void onBlockIgnite(BlockIgniteEvent event) {
}
/**
* Called when block physics occurs
*
* @param event Relevant event details
*/
public void onBlockPhysics(BlockPhysicsEvent event) {
}
/**
* Called when a player places a block
*
* @param event Relevant event details
*/
public void onBlockPlaced(BlockPlacedEvent event) {
}
/**
* Called when redstone changes
* From: the source of the redstone change
* To: The redstone dust that changed
*
* @param event Relevant event details
*/
public void onBlockRedstoneChange(BlockFromToEvent event) {
}
/**
* Called when a player right clicks a block
*
* @param event Relevant event details
*/
public void onBlockRightClicked(BlockRightClickedEvent event) {
}
}

View File

@@ -0,0 +1,59 @@
package org.bukkit.event.block;
import org.bukkit.Block;
import org.bukkit.ItemStack;
import org.bukkit.Material;
import org.bukkit.event.Event;
/**
* Thrown when a block physics check is called
*
* @author Dinnerbone
*/
public class BlockPhysicsEvent extends BlockEvent {
private final int changed;
private boolean cancel = false;
public BlockPhysicsEvent(final Event.Type type, final Block block, final int changed) {
super(type, block);
this.changed = changed;
}
/**
* Gets the type of block that changed, causing this event
*
* @return Changed block's type ID
*/
public int getChangedTypeID() {
return changed;
}
/**
* Gets the type of block that changed, causing this event
*
* @return Changed block's type
*/
public Material getChangedType() {
return Material.getMaterial(changed);
}
/**
* Gets the cancellation state of this event. A cancelled event will not
* be executed in the server, but will still pass to other plugins
*
* @return true if this event is cancelled
*/
public boolean isCancelled() {
return cancel;
}
/**
* Sets the cancellation state of this event. A cancelled event will not
* be executed in the server, but will still pass to other plugins
*
* @param cancel true if you wish to cancel this event
*/
public void setCancelled(boolean cancel) {
this.cancel = cancel;
}
}

View File

@@ -0,0 +1,32 @@
package org.bukkit.event.block;
import org.bukkit.Block;
import org.bukkit.event.Cancellable;
/**
* Not implemented yet
*/
public class BlockPlacedEvent extends BlockEvent implements Cancellable {
private boolean cancel;
/**
* @param type
* @param theBlock
*/
public BlockPlacedEvent(Type type, Block theBlock) {
super(type, theBlock);
cancel = false;
}
@Override
public boolean isCancelled() {
// TODO Auto-generated method stub
return cancel;
}
@Override
public void setCancelled(boolean cancel) {
this.cancel = cancel;
}
}

View File

@@ -0,0 +1,53 @@
/**
*
*/
package org.bukkit.event.block;
import org.bukkit.Block;
import org.bukkit.BlockFace;
import org.bukkit.ItemStack;
import org.bukkit.Player;
/**
* @author durron597
*/
public class BlockRightClickedEvent extends BlockEvent {
protected Player clicker;
protected BlockFace direction;
protected ItemStack clickedWith;
/**
* @param type The type of event this is
* @param theBlock The clicked block
* @param direction The face we clicked from
* @param clicker The player who clicked a block
* @param clickedWith Item in player's hand
*/
public BlockRightClickedEvent(Type type, Block theBlock, BlockFace direction, Player clicker, ItemStack clickedWith) {
super(type, theBlock);
this.direction = direction;
this.clicker = clicker;
this.clickedWith = clickedWith;
}
/**
* @return the clicker
*/
public Player getClicker() {
return clicker;
}
/**
* @return the direction
*/
public BlockFace getDirection() {
return direction;
}
/**
* @return the clickedWith
*/
public ItemStack getClickedWith() {
return clickedWith;
}
}

View File

@@ -0,0 +1,66 @@
package org.bukkit.event.player;
import org.bukkit.Player;
import org.bukkit.event.Cancellable;
/**
* Holds information for player chat and commands
*/
public class PlayerChatEvent extends PlayerEvent implements Cancellable {
private boolean cancel = false;
private String message;
public PlayerChatEvent(final Type type, final Player player, final String message) {
super(type, player);
this.message = message;
}
/**
* Gets the cancellation state of this event. A cancelled event will not
* be executed in the server, but will still pass to other plugins
*
* @return true if this event is cancelled
*/
public boolean isCancelled() {
return cancel;
}
/**
* Sets the cancellation state of this event. A cancelled event will not
* be executed in the server, but will still pass to other plugins
*
* @param cancel true if you wish to cancel this event
*/
public void setCancelled(boolean cancel) {
this.cancel = cancel;
}
/**
* Gets the message that the player is attempting to send
*
* @return Message the player is attempting to send
*/
public String getMessage() {
return message;
}
/**
* Sets the message that the player will send
*
* @param message New message that the player will send
*/
public void setMessage(String message) {
this.message = message;
}
/**
* Sets the player that this message will display as, or command will be
* executed as
*
* @param player New player which this event will execute as
*/
public void setPlayer(final Player player) {
this.player = player;
}
}

View File

@@ -0,0 +1,25 @@
package org.bukkit.event.player;
import org.bukkit.Player;
import org.bukkit.event.Event;
/**
* Represents a player related event
*/
public class PlayerEvent extends Event {
protected Player player;
public PlayerEvent(final Event.Type type, final Player who) {
super(type);
player = who;
}
/**
* Returns the player involved in this event
* @return Player who is involved in this event
*/
public final Player getPlayer() {
return player;
}
}

View File

@@ -0,0 +1,68 @@
package org.bukkit.event.player;
import org.bukkit.event.Listener;
/**
* Handles all events thrown in relation to a Player
*/
public class PlayerListener implements Listener {
public PlayerListener() {
}
/**
* Called when a player joins a server
*
* @param event Relevant event details
*/
public void onPlayerJoin(PlayerEvent event) {
}
/**
* Called when a player leaves a server
*
* @param event Relevant event details
*/
public void onPlayerQuit(PlayerEvent event) {
}
/**
* Called when a player sends a chat message
*
* @param event Relevant event details
*/
public void onPlayerChat(PlayerChatEvent event) {
}
/**
* Called when a player attempts to use a command
*
* @param event Relevant event details
*/
public void onPlayerCommand(PlayerChatEvent event) {
}
/**
* Called when a player attempts to move location in a world
*
* @param event Relevant event details
*/
public void onPlayerMove(PlayerMoveEvent event) {
}
/**
* Called when a player attempts to teleport to a new location in a world
*
* @param event Relevant event details
*/
public void onPlayerTeleport(PlayerMoveEvent event) {
}
/**
* Called when a player attempts to log in to the server
*
* @param event Relevant event details
*/
public void onPlayerLogin(PlayerLoginEvent event) {
}
}

View File

@@ -0,0 +1,104 @@
package org.bukkit.event.player;
import org.bukkit.Player;
/**
* Stores details for players attempting to log in
*/
public class PlayerLoginEvent extends PlayerEvent {
private Result result;
private String message;
public PlayerLoginEvent(final Type type, final Player player) {
super(type, player);
this.result = Result.ALLOWED;
this.message = "";
}
public PlayerLoginEvent(final Type type, final Player player, final Result result, final String message) {
super(type, player);
this.result = result;
this.message = message;
}
/**
* Gets the current result of the login, as an enum
*
* @return Current Result of the login
*/
public Result getResult() {
return result;
}
/**
* Sets the new result of the login, as an enum
*
* @param result New result to set
*/
public void setResult(final Result result) {
this.result = result;
}
/**
* Gets the current kick message that will be used if getResult() != Result.ALLOWED
*
* @return Current kick message
*/
public String getKickMessage() {
return message;
}
/**
* Sets the kick message to display if getResult() != Result.ALLOWED
*
* @param message New kick message
*/
public void setKickMessage(final String message) {
this.message = message;
}
/**
* Allows the player to log in
*/
public void allow() {
result = Result.ALLOWED;
message = "";
}
/**
* Disallows the player from logging in, with the given reason
*
* @param result New result for disallowing the player
* @param message Kick message to display to the user
*/
public void disallow(final Result result, final String message) {
this.result = result;
this.message = message;
}
/**
* Basic kick reasons for communicating to plugins
*/
public enum Result {
/**
* The player is allowed to log in
*/
ALLOWED,
/**
* The player is not allowed to log in, due to the server being full
*/
KICK_FULL,
/**
* The player is not allowed to log in, due to them being banned
*/
KICK_BANNED,
/**
* The player is not allowed to log in, for reasons undefined
*/
KICK_OTHER
}
}

View File

@@ -0,0 +1,86 @@
package org.bukkit.event.player;
import org.bukkit.Location;
import org.bukkit.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
/**
* Holds information for player movement and teleportation events
*/
public class PlayerMoveEvent extends PlayerEvent implements Cancellable {
private boolean cancel = false;
private Location from;
private Location to;
public PlayerMoveEvent(final Event.Type type, final Player player, final Location from, final Location to) {
super(type, player);
this.from = from;
this.to = to;
}
/**
* Gets the cancellation state of this event. A cancelled event will not
* be executed in the server, but will still pass to other plugins
*
* If a move or teleport event is cancelled, the player will be moved or
* teleported back to the Location as defined by getFrom(). This will not
* fire an event
*
* @return true if this event is cancelled
*/
public boolean isCancelled() {
return cancel;
}
/**
* Sets the cancellation state of this event. A cancelled event will not
* be executed in the server, but will still pass to other plugins
*
* If a move or teleport event is cancelled, the player will be moved or
* teleported back to the Location as defined by getFrom(). This will not
* fire an event
*
* @param cancel true if you wish to cancel this event
*/
public void setCancelled(boolean cancel) {
this.cancel = cancel;
}
/**
* Gets the location this player moved from
*
* @return Location the player moved from
*/
public Location getFrom() {
return from;
}
/**
* Sets the location to mark as where the player moved from
*
* @param from New location to mark as the players previous location
*/
public void setFrom(Location from) {
this.from = from;
}
/**
* Gets the location this player moved to
*
* @return Location the player moved to
*/
public Location getTo() {
return to;
}
/**
* Sets the location that this player will move to
*
* @param to New Location this player will move to
*/
public void setTo(Location to) {
this.to = to;
}
}