mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-09 19:49:35 +01:00
Add FurnaceExtractEvent. Addresses BUKKIT-2114
Added a "BlockExpEvent" to hold experience and the handlers for the events By: feildmaster <admin@feildmaster.com>
This commit is contained in:
parent
c87e48bb00
commit
7536c357fc
3 changed files with 96 additions and 32 deletions
|
@ -23,15 +23,13 @@ import org.bukkit.event.HandlerList;
|
||||||
* <p />
|
* <p />
|
||||||
* If a Block Break event is cancelled, the block will not break and experience will not drop.
|
* If a Block Break event is cancelled, the block will not break and experience will not drop.
|
||||||
*/
|
*/
|
||||||
public class BlockBreakEvent extends BlockEvent implements Cancellable {
|
public class BlockBreakEvent extends BlockExpEvent implements Cancellable {
|
||||||
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
|
||||||
private final Player player;
|
private final Player player;
|
||||||
private boolean cancel;
|
private boolean cancel;
|
||||||
private int exp;
|
|
||||||
|
|
||||||
public BlockBreakEvent(final Block theBlock, final Player player) {
|
public BlockBreakEvent(final Block theBlock, final Player player) {
|
||||||
super(theBlock);
|
super(theBlock, 0);
|
||||||
|
|
||||||
this.player = player;
|
this.player = player;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,24 +42,6 @@ public class BlockBreakEvent extends BlockEvent implements Cancellable {
|
||||||
return player;
|
return player;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the experience to drop after the block is broken.
|
|
||||||
*
|
|
||||||
* @return The experience to drop
|
|
||||||
*/
|
|
||||||
public int getExpToDrop() {
|
|
||||||
return exp;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the amount of experience to drop after the block is broken.
|
|
||||||
*
|
|
||||||
* @param exp 1 or higher to drop experience, or else nothing will drop
|
|
||||||
*/
|
|
||||||
public void setExpToDrop(int exp) {
|
|
||||||
this.exp = exp;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isCancelled() {
|
public boolean isCancelled() {
|
||||||
return cancel;
|
return cancel;
|
||||||
}
|
}
|
||||||
|
@ -69,13 +49,4 @@ public class BlockBreakEvent extends BlockEvent implements Cancellable {
|
||||||
public void setCancelled(boolean cancel) {
|
public void setCancelled(boolean cancel) {
|
||||||
this.cancel = cancel;
|
this.cancel = cancel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public HandlerList getHandlers() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static HandlerList getHandlerList() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
package org.bukkit.event.block;
|
||||||
|
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An event that's called when a block yields experience.
|
||||||
|
*/
|
||||||
|
public class BlockExpEvent extends BlockEvent {
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
private int exp;
|
||||||
|
|
||||||
|
public BlockExpEvent(Block block, int exp) {
|
||||||
|
super(block);
|
||||||
|
|
||||||
|
this.exp = exp;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the experience dropped by the block after the event has processed
|
||||||
|
*
|
||||||
|
* @return The experience to drop
|
||||||
|
*/
|
||||||
|
public int getExpToDrop() {
|
||||||
|
return exp;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the amount of experience dropped by the block after the event has processed
|
||||||
|
*
|
||||||
|
* @param exp 1 or higher to drop experience, else nothing will drop
|
||||||
|
*/
|
||||||
|
public void setExpToDrop(int exp) {
|
||||||
|
this.exp = exp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,49 @@
|
||||||
|
package org.bukkit.event.inventory;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.block.BlockExpEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This event is called when a player takes items out of the furnace
|
||||||
|
*/
|
||||||
|
public class FurnaceExtractEvent extends BlockExpEvent {
|
||||||
|
private final Player player;
|
||||||
|
private final Material itemType;
|
||||||
|
private final int itemAmount;
|
||||||
|
|
||||||
|
public FurnaceExtractEvent(Player player, Block block, Material itemType, int itemAmount, int exp) {
|
||||||
|
super(block, exp);
|
||||||
|
this.player = player;
|
||||||
|
this.itemType = itemType;
|
||||||
|
this.itemAmount = itemAmount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the player that triggered the event
|
||||||
|
*
|
||||||
|
* @return the relevant player
|
||||||
|
*/
|
||||||
|
public Player getPlayer() {
|
||||||
|
return player;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Material of the item being retrieved
|
||||||
|
*
|
||||||
|
* @return the material of the item
|
||||||
|
*/
|
||||||
|
public Material getItemType() {
|
||||||
|
return itemType;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the item count being retrieved
|
||||||
|
*
|
||||||
|
* @return the amount of the item
|
||||||
|
*/
|
||||||
|
public int getItemAmount() {
|
||||||
|
return itemAmount;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue