13
0
geforkt von Mirrors/Paper

Refactor Bucket events

By: Erik Broes <erikbroes@grum.nl>
Dieser Commit ist enthalten in:
Bukkit/Spigot 2011-07-17 17:01:05 +02:00
Ursprung ecc7ca0477
Commit c11905550e
3 geänderte Dateien mit 83 neuen und 81 gelöschten Zeilen

Datei anzeigen

@ -4,52 +4,14 @@ import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
/** /**
* Called when a player empties a bucket * Called when a player empties a bucket
*/ */
public class PlayerBucketEmptyEvent extends PlayerEvent implements Cancellable { public class PlayerBucketEmptyEvent extends PlayerBucketEvent {
ItemStack itemStack;
boolean cancelled = false;
Block blockClicked;
BlockFace blockFace;
Material bucket;
public PlayerBucketEmptyEvent(Player who, Block blockClicked, BlockFace blockFace, Material bucket, ItemStack itemInHand) { public PlayerBucketEmptyEvent(Player who, Block blockClicked, BlockFace blockFace, Material bucket, ItemStack itemInHand) {
super(Type.PLAYER_BUCKET_EMPTY, who); super(Type.PLAYER_BUCKET_EMPTY, who, blockClicked, blockFace, bucket, itemInHand);
this.blockClicked = blockClicked;
this.blockFace = blockFace;
this.itemStack = itemInHand;
this.bucket = bucket;
}
public Material getBucket() {
return bucket;
}
public ItemStack getItemStack() {
return itemStack;
}
public Block getBlockClicked() {
return blockClicked;
}
public BlockFace getBlockFace() {
return blockFace;
}
public void setItemStack(ItemStack itemStack) {
this.itemStack = itemStack;
}
public boolean isCancelled() {
return cancelled;
}
public void setCancelled(boolean cancel) {
this.cancelled = cancel;
} }
} }

Datei anzeigen

@ -0,0 +1,79 @@
package org.bukkit.event.player;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.inventory.ItemStack;
public abstract class PlayerBucketEvent extends PlayerEvent implements Cancellable {
private ItemStack itemStack;
private boolean cancelled = false;
private Block blockClicked;
private BlockFace blockFace;
private Material bucket;
public PlayerBucketEvent(Type type, Player who, Block blockClicked, BlockFace blockFace, Material bucket, ItemStack itemInHand) {
super(type, who);
this.blockClicked = blockClicked;
this.blockFace = blockFace;
this.itemStack = itemInHand;
this.bucket = bucket;
}
/**
* Returns the bucket used in this event
*
* @return the used bucket
*/
public Material getBucket() {
return bucket;
}
/**
* Get the resulting item in hand after the bucket event
*
* @return Itemstack hold in hand after the event.
*/
public ItemStack getItemStack() {
return itemStack;
}
/**
* Set the item in hand after the event
*
* @param itemStack the new held itemstack after the bucket event.
*/
public void setItemStack(ItemStack itemStack) {
this.itemStack = itemStack;
}
/**
* Return the block clicked
*
* @return the blicked block
*/
public Block getBlockClicked() {
return blockClicked;
}
/**
* Get the face on the clicked block
*
* @return the clicked face
*/
public BlockFace getBlockFace() {
return blockFace;
}
public boolean isCancelled() {
return cancelled;
}
public void setCancelled(boolean cancel) {
this.cancelled = cancel;
}
}

Datei anzeigen

@ -4,52 +4,13 @@ import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
/** /**
* Called when a player fills a bucket * Called when a player fills a bucket
*/ */
public class PlayerBucketFillEvent extends PlayerEvent implements Cancellable { public class PlayerBucketFillEvent extends PlayerBucketEvent {
ItemStack itemStack;
boolean cancelled = false;
Block blockClicked;
BlockFace blockFace;
Material bucket;
public PlayerBucketFillEvent(Player who, Block blockClicked, BlockFace blockFace, Material bucket, ItemStack itemInHand) { public PlayerBucketFillEvent(Player who, Block blockClicked, BlockFace blockFace, Material bucket, ItemStack itemInHand) {
super(Type.PLAYER_BUCKET_FILL, who); super(Type.PLAYER_BUCKET_FILL, who, blockClicked, blockFace, bucket, itemInHand);
this.blockClicked = blockClicked;
this.blockFace = blockFace;
this.itemStack = itemInHand;
this.bucket = bucket;
}
public Material getBucket() {
return bucket;
}
public ItemStack getItemStack() {
return itemStack;
}
public Block getBlockClicked() {
return blockClicked;
}
public BlockFace getBlockFace() {
return blockFace;
}
public void setItemStack(ItemStack itemStack) {
this.itemStack = itemStack;
}
public boolean isCancelled() {
return cancelled;
}
public void setCancelled(boolean cancel) {
this.cancelled = cancel;
} }
} }