Some more backwards incompatible changes (minor though), also a ton of small cleanup.

onPluginEnable(PluginEvent event)   -> onPluginEnable(PluginEnableEvent event)
onPluginDisable(PluginEvent event)  -> onPluginDisable(PluginDisableEvent event)
onVehicleUpdate(VehicleEvent event) -> onVehicleUpdate(VehicleUpdateEvent event)
onWorldSave(WorldEvent event)       -> onWorldSave(WorldSaveEvent event)
onWorldLoad(WorldEvent event)       -> onWorldLoad(WorldLoadEvent event)

By: Erik Broes <erikbroes@grum.nl>
This commit is contained in:
Bukkit/Spigot
2011-03-26 22:21:20 +01:00
parent f7b70eb07b
commit 020da84ad2
60 changed files with 312 additions and 376 deletions

View File

@@ -3,7 +3,6 @@ package org.bukkit.event.block;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
/**
*
@@ -15,7 +14,7 @@ public class BlockBreakEvent extends BlockEvent implements Cancellable {
private boolean cancel;
public BlockBreakEvent(final Block theBlock, Player player) {
super(Event.Type.BLOCK_BREAK, theBlock);
super(Type.BLOCK_BREAK, theBlock);
this.player = player;
this.cancel = false;
}

View File

@@ -13,8 +13,8 @@ public class BlockCanBuildEvent extends BlockEvent {
protected boolean buildable;
protected int material;
public BlockCanBuildEvent(Type type, Block block, int id, boolean canBuild) {
super(type, block);
public BlockCanBuildEvent(Block block, int id, boolean canBuild) {
super(Type.BLOCK_CANBUILD, block);
buildable = canBuild;
material = id;
}

View File

@@ -18,7 +18,7 @@ public class BlockDamageEvent extends BlockEvent implements Cancellable {
super(Type.BLOCK_DAMAGE, block);
this.instaBreak = instaBreak;
this.player = player;
this.itemstack = itemstack;
this.itemstack = itemInHand;
this.cancel = false;
}

View File

@@ -3,7 +3,6 @@ package org.bukkit.event.block;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
/**
* Holds information for events with a source block and a destination block
@@ -13,8 +12,8 @@ public class BlockFromToEvent extends BlockEvent implements Cancellable {
protected BlockFace face;
protected boolean cancel;
public BlockFromToEvent(final Event.Type type, final Block block, final BlockFace face) {
super(type, block);
public BlockFromToEvent(final Block block, final BlockFace face) {
super(Type.BLOCK_FROMTO, block);
this.face = face;
this.cancel = false;
}

View File

@@ -11,7 +11,6 @@ import org.bukkit.event.Event;
* Represents a block ignite event.
*/
public class BlockIgniteEvent extends BlockEvent implements Cancellable {
private IgniteCause cause;
private boolean cancel;
private Player thePlayer;

View File

@@ -1,70 +0,0 @@
package org.bukkit.event.block;
import org.bukkit.block.Block;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
/**
* This event is triggered whenever an entity interacts with the universe
* it's always called, on a left click or a right click, or walking on
* (as in the case of pressure plates). Use cancellable to prevent things
* from happening (doors opening, buttons, pressure plates being walked
* on, etc). Note: even though pressure plates work totally differently
* than the other interact events, it's still thrown in with this event.
*
* @author durron597
*/
public class BlockInteractEvent extends BlockEvent implements Cancellable {
protected boolean cancel;
protected LivingEntity theEntity;
/**
* @param type The type of this event
* @param interactedBlock the block that was interacted with
* @param who The entity that interacted with
*/
public BlockInteractEvent(Type type, Block interactedBlock, LivingEntity who) {
super(type, interactedBlock);
theEntity = who;
cancel = false;
}
/**
* 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;
}
/**
* Returns the entity that triggered this event
*
* @return Entity the entity that triggered this event
*/
public LivingEntity getEntity() {
return theEntity;
}
/**
* Convenience method for seeing if this event was triggered by a player
*
* @return boolean whether this event was triggered by a player
*/
public boolean isPlayer() {
return theEntity instanceof Player;
}
}

View File

@@ -2,7 +2,6 @@ package org.bukkit.event.block;
import org.bukkit.block.Block;
import org.bukkit.Material;
import org.bukkit.event.Event;
/**
* Thrown when a block physics check is called
@@ -13,8 +12,8 @@ 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);
public BlockPhysicsEvent(final Block block, final int changed) {
super(Type.BLOCK_PHYSICS, block);
this.changed = changed;
}

View File

@@ -17,8 +17,8 @@ public class BlockPlaceEvent extends BlockEvent implements Cancellable {
protected ItemStack itemInHand;
protected Player player;
public BlockPlaceEvent(Type type, Block placedBlock, BlockState replacedBlockState, Block placedAgainst, ItemStack itemInHand, Player thePlayer, boolean canBuild) {
super(type, placedBlock);
public BlockPlaceEvent(Block placedBlock, BlockState replacedBlockState, Block placedAgainst, ItemStack itemInHand, Player thePlayer, boolean canBuild) {
super(Type.BLOCK_PLACE, placedBlock);
this.placedAgainst = placedAgainst;
this.itemInHand = itemInHand;
this.player = thePlayer;

View File

@@ -1,49 +0,0 @@
package org.bukkit.event.block;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.inventory.ItemStack;
import org.bukkit.entity.Player;
/**
* Not implemented yet
*/
public class BlockRightClickEvent extends BlockEvent {
protected Block clickedBlock;
protected BlockFace direction;
protected ItemStack itemInHand;
protected Player player;
public BlockRightClickEvent(Type type, Block placedAgainst, BlockFace direction, ItemStack itemInHand, Player thePlayer) {
super(type, placedAgainst);
this.clickedBlock = placedAgainst;
this.direction = direction;
this.itemInHand = itemInHand;
this.player = thePlayer;
}
/**
* Gets the player who placed this block
*
* @return Player who placed the block
*/
public Player getPlayer() {
return player;
}
/**
* @return BlockFace the direction this block was clicked
*/
public BlockFace getDirection() {
return direction;
}
/**
* Returns the item in your hand when you placed the block
*
* @return ItemStack the item in your hand when placing the block
*/
public ItemStack getItemInHand() {
return itemInHand;
}
}

View File

@@ -10,8 +10,8 @@ import org.bukkit.event.Cancellable;
public class LeavesDecayEvent extends BlockEvent implements Cancellable {
private boolean cancel = false;
public LeavesDecayEvent(final Type type, final Block block) {
super(type, block);
public LeavesDecayEvent(final Block block) {
super(Type.LEAVES_DECAY, block);
}
/**

View File

@@ -12,8 +12,8 @@ public class SignChangeEvent extends BlockEvent implements Cancellable {
private Player player;
private String[] lines;
public SignChangeEvent(final Type type, final Block theBlock, final Player thePlayer, String[] theLines) {
super(type, theBlock);
public SignChangeEvent(final Block theBlock, final Player thePlayer, String[] theLines) {
super(Type.SIGN_CHANGE, theBlock);
this.player = thePlayer;
this.lines = theLines;
}