Added Furnace smelt and burn events.
This commit is contained in:
parent
3b7f86ba5b
commit
82a04fda10
@ -432,6 +432,20 @@ public abstract class Event implements Serializable {
|
|||||||
*/
|
*/
|
||||||
INVENTORY_TRANSACTION (Category.INVENTORY),
|
INVENTORY_TRANSACTION (Category.INVENTORY),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when an ItemStack is successfully smelted in a furnace.
|
||||||
|
*
|
||||||
|
* @see org.bukkit.event.inventory.FurnaceSmeltEvent
|
||||||
|
*/
|
||||||
|
FURNACE_SMELT (Category.INVENTORY),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when an ItemStack is successfully burned as fuel in a furnace.
|
||||||
|
*
|
||||||
|
* @see org.bukkit.event.inventory.FurnaceBurnEvent
|
||||||
|
*/
|
||||||
|
FURNACE_BURN (Category.INVENTORY),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SERVER EVENTS
|
* SERVER EVENTS
|
||||||
*/
|
*/
|
||||||
|
@ -0,0 +1,71 @@
|
|||||||
|
package org.bukkit.event.inventory;
|
||||||
|
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
/**
|
||||||
|
* Called when an ItemStack is successfully burned as fuel in a furnace.
|
||||||
|
*/
|
||||||
|
public class FurnaceBurnEvent extends Event implements Cancellable {
|
||||||
|
private Block furnace;
|
||||||
|
private ItemStack fuel;
|
||||||
|
private int burnTime;
|
||||||
|
private boolean cancelled;
|
||||||
|
|
||||||
|
public FurnaceBurnEvent(Block furnace, ItemStack fuel, int burnTime) {
|
||||||
|
super(Type.FURNACE_BURN);
|
||||||
|
|
||||||
|
this.furnace = furnace;
|
||||||
|
this.fuel = fuel;
|
||||||
|
this.burnTime = burnTime;
|
||||||
|
this.cancelled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the block for the furnace involved in this event
|
||||||
|
*
|
||||||
|
* @return the block of the furnace
|
||||||
|
*/
|
||||||
|
public Block getFurnace() {
|
||||||
|
return furnace;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the fuel ItemStack for this event
|
||||||
|
*
|
||||||
|
* @return the fuel ItemStack
|
||||||
|
*/
|
||||||
|
public ItemStack getFuel() {
|
||||||
|
return fuel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the default burn time for this fuel
|
||||||
|
*
|
||||||
|
* @return the default burn time for this fuel
|
||||||
|
*/
|
||||||
|
public int getBurnTime() {
|
||||||
|
return burnTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 cancelled;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.cancelled = cancel;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,81 @@
|
|||||||
|
package org.bukkit.event.inventory;
|
||||||
|
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when an ItemStack is successfully smelted in a furnace.
|
||||||
|
*/
|
||||||
|
public class FurnaceSmeltEvent extends Event implements Cancellable{
|
||||||
|
private Block furnace;
|
||||||
|
private ItemStack source;
|
||||||
|
private ItemStack result;
|
||||||
|
private boolean cancelled;
|
||||||
|
|
||||||
|
public FurnaceSmeltEvent(Block furnace, ItemStack source, ItemStack result) {
|
||||||
|
super(Type.FURNACE_SMELT);
|
||||||
|
|
||||||
|
this.furnace = furnace;
|
||||||
|
this.source = source;
|
||||||
|
this.result = result;
|
||||||
|
this.cancelled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the block for the furnace involved in this event
|
||||||
|
*
|
||||||
|
* @return the block of the furnace
|
||||||
|
*/
|
||||||
|
public Block getFurnace() {
|
||||||
|
return furnace;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the smelted ItemStack for this event
|
||||||
|
*
|
||||||
|
* @return smelting source ItemStack
|
||||||
|
*/
|
||||||
|
public ItemStack getSource() {
|
||||||
|
return source;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the resultant ItemStack for this event
|
||||||
|
*
|
||||||
|
* @return smelting result ItemStack
|
||||||
|
*/
|
||||||
|
public ItemStack getResult() {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the resultant ItemStack for this event
|
||||||
|
*
|
||||||
|
* @param result new result ItemStack
|
||||||
|
*/
|
||||||
|
public void setResult(ItemStack result) {
|
||||||
|
this.result = result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 cancelled;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.cancelled = cancel;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
package org.bukkit.event.inventory;
|
||||||
|
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
/**
|
||||||
|
* Handles all events thrown in relation to Blocks
|
||||||
|
*/
|
||||||
|
public class InventoryListener implements Listener {
|
||||||
|
public InventoryListener() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when an ItemStack is successfully smelted in a furnace.
|
||||||
|
*
|
||||||
|
* @param event Relevant event details
|
||||||
|
*/
|
||||||
|
public void onFurnaceSmelt(FurnaceSmeltEvent event) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when an ItemStack is successfully burned as fuel in a furnace.
|
||||||
|
*
|
||||||
|
* @param event Relevant event details
|
||||||
|
*/
|
||||||
|
public void onFurnaceBurn(FurnaceBurnEvent event) {}
|
||||||
|
}
|
@ -26,6 +26,7 @@ import org.bukkit.event.server.*;
|
|||||||
import org.bukkit.event.vehicle.*;
|
import org.bukkit.event.vehicle.*;
|
||||||
import org.bukkit.event.world.*;
|
import org.bukkit.event.world.*;
|
||||||
import org.bukkit.event.weather.*;
|
import org.bukkit.event.weather.*;
|
||||||
|
import org.bukkit.event.inventory.*;
|
||||||
import org.bukkit.plugin.*;
|
import org.bukkit.plugin.*;
|
||||||
import org.yaml.snakeyaml.error.YAMLException;
|
import org.yaml.snakeyaml.error.YAMLException;
|
||||||
|
|
||||||
@ -812,6 +813,20 @@ public final class JavaPluginLoader implements PluginLoader {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Inventory Events
|
||||||
|
case FURNACE_SMELT:
|
||||||
|
return new EventExecutor() {
|
||||||
|
public void execute(Listener listener, Event event) {
|
||||||
|
((InventoryListener) listener).onFurnaceSmelt((FurnaceSmeltEvent) event);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
case FURNACE_BURN:
|
||||||
|
return new EventExecutor() {
|
||||||
|
public void execute(Listener listener, Event event) {
|
||||||
|
((InventoryListener) listener).onFurnaceBurn((FurnaceBurnEvent) event);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// Custom Events
|
// Custom Events
|
||||||
case CUSTOM_EVENT:
|
case CUSTOM_EVENT:
|
||||||
return new EventExecutor() {
|
return new EventExecutor() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user