geforkt von Mirrors/Paper
SPIGOT-2695: Added BrewingStandFuelEvent and added fuel level to the BrewEvent
By: LukBukkit <luk.bukkit@gmail.com>
Dieser Commit ist enthalten in:
Ursprung
389da4ad7b
Commit
986f585dba
@ -13,11 +13,13 @@ import org.bukkit.inventory.BrewerInventory;
|
|||||||
public class BrewEvent extends BlockEvent implements Cancellable {
|
public class BrewEvent extends BlockEvent implements Cancellable {
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
private BrewerInventory contents;
|
private BrewerInventory contents;
|
||||||
|
private int fuelLevel;
|
||||||
private boolean cancelled;
|
private boolean cancelled;
|
||||||
|
|
||||||
public BrewEvent(Block brewer, BrewerInventory contents) {
|
public BrewEvent(Block brewer, BrewerInventory contents, int fuelLevel) {
|
||||||
super(brewer);
|
super(brewer);
|
||||||
this.contents = contents;
|
this.contents = contents;
|
||||||
|
this.fuelLevel = fuelLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -29,6 +31,15 @@ public class BrewEvent extends BlockEvent implements Cancellable {
|
|||||||
return contents;
|
return contents;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the remaining fuel level.
|
||||||
|
*
|
||||||
|
* @return the remaining fuel
|
||||||
|
*/
|
||||||
|
public int getFuelLevel() {
|
||||||
|
return fuelLevel;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isCancelled() {
|
public boolean isCancelled() {
|
||||||
return cancelled;
|
return cancelled;
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren