SPIGOT-2695: Added BrewingStandFuelEvent and added fuel level to the BrewEvent

By: LukBukkit <luk.bukkit@gmail.com>
This commit is contained in:
Bukkit/Spigot 2016-11-26 16:15:32 +01:00
parent 389da4ad7b
commit 986f585dba
2 changed files with 104 additions and 1 deletions

View File

@ -13,11 +13,13 @@ import org.bukkit.inventory.BrewerInventory;
public class BrewEvent extends BlockEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private BrewerInventory contents;
private int fuelLevel;
private boolean cancelled;
public BrewEvent(Block brewer, BrewerInventory contents) {
public BrewEvent(Block brewer, BrewerInventory contents, int fuelLevel) {
super(brewer);
this.contents = contents;
this.fuelLevel = fuelLevel;
}
/**
@ -29,6 +31,15 @@ public class BrewEvent extends BlockEvent implements Cancellable {
return contents;
}
/**
* Gets the remaining fuel level.
*
* @return the remaining fuel
*/
public int getFuelLevel() {
return fuelLevel;
}
public boolean isCancelled() {
return cancelled;
}

View File

@ -0,0 +1,92 @@
package org.bukkit.event.inventory;
import org.bukkit.block.Block;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.bukkit.event.block.BlockEvent;
import org.bukkit.inventory.ItemStack;
/**
* Called when an ItemStack is about to increase the fuel level of a brewing
* stand.
*/
public class BrewingStandFuelEvent extends BlockEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private final ItemStack fuel;
private int fuelPower;
private boolean cancelled;
private boolean consuming;
public BrewingStandFuelEvent(Block brewingStand, ItemStack fuel, int fuelPower) {
super(brewingStand);
this.fuel = fuel;
this.fuelPower = fuelPower;
}
/**
* Gets the ItemStack of the fuel before the amount was subtracted.
*
* @return the fuel ItemStack
*/
public ItemStack getFuel() {
return fuel;
}
/**
* Gets the fuel power for this fuel. Each unit of power can fuel one
* brewing operation.
*
* @return the fuel power for this fuel
*/
public int getFuelPower() {
return fuelPower;
}
/**
* Sets the fuel power for this fuel. Each unit of power can fuel one
* brewing operation.
*
* @param fuelPower the fuel power for this fuel
*/
public void setFuelPower(int fuelPower) {
this.fuelPower = fuelPower;
}
/**
* Gets whether the brewing stand's fuel will be reduced / consumed or not.
*
* @return whether the fuel will be reduced or not
*/
public boolean isConsuming() {
return consuming;
}
/**
* Sets whether the brewing stand's fuel will be reduced / consumed or not.
*
* @param consuming whether the fuel will be reduced or not
*/
public void setConsuming(boolean consuming) {
this.consuming = consuming;
}
@Override
public boolean isCancelled() {
return cancelled;
}
@Override
public void setCancelled(boolean cancel) {
this.cancelled = cancel;
}
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}