mirror of
https://github.com/PaperMC/Paper.git
synced 2025-03-02 11:22:01 +01:00
SPIGOT-7224: Add events for brewing stands and campfires starting their actions
By: FreeSoccerHDX <freesoccerhdx@gmail.com>
This commit is contained in:
parent
a74a60046d
commit
eb1da343c8
@ -0,0 +1,49 @@
|
||||
package org.bukkit.event.block;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Called when a brewing stand starts to brew.
|
||||
*/
|
||||
public class BrewingStartEvent extends InventoryBlockStartEvent {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private int brewingTime;
|
||||
|
||||
public BrewingStartEvent(@NotNull final Block furnace, @NotNull ItemStack source, int brewingTime) {
|
||||
super(furnace, source);
|
||||
this.brewingTime = brewingTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the total brew time associated with this event.
|
||||
*
|
||||
* @return the total brew time
|
||||
*/
|
||||
public int getTotalBrewTime() {
|
||||
return brewingTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the total brew time for this event.
|
||||
*
|
||||
* @param brewTime the new total brew time
|
||||
*/
|
||||
public void setTotalBrewTime(int brewTime) {
|
||||
this.brewingTime = brewTime;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
package org.bukkit.event.block;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.inventory.CampfireRecipe;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Called when a Campfire starts to cook.
|
||||
*/
|
||||
public class CampfireStartEvent extends InventoryBlockStartEvent {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private int cookingTime;
|
||||
private CampfireRecipe campfireRecipe;
|
||||
|
||||
public CampfireStartEvent(@NotNull final Block furnace, @NotNull ItemStack source, @NotNull CampfireRecipe recipe) {
|
||||
super(furnace, source);
|
||||
this.cookingTime = recipe.getCookingTime();
|
||||
this.campfireRecipe = recipe;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the CampfireRecipe associated with this event.
|
||||
*
|
||||
* @return the CampfireRecipe being cooked
|
||||
*/
|
||||
@NotNull
|
||||
public CampfireRecipe getRecipe() {
|
||||
return campfireRecipe;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the total cook time associated with this event.
|
||||
*
|
||||
* @return the total cook time
|
||||
*/
|
||||
public int getTotalCookTime() {
|
||||
return cookingTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the total cook time for this event.
|
||||
*
|
||||
* @param cookTime the new total cook time
|
||||
*/
|
||||
public void setTotalCookTime(int cookTime) {
|
||||
this.cookingTime = cookTime;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
package org.bukkit.event.block;
|
||||
|
||||
import org.bukkit.Warning;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.inventory.FurnaceStartSmeltEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Used when:
|
||||
* <ul>
|
||||
* <li>A Furnace starts smelting {@link FurnaceStartSmeltEvent}</li>
|
||||
* <li>A Brewing-Stand starts brewing {@link BrewingStartEvent}</li>
|
||||
* <li>A Campfire starts cooking {@link CampfireStartEvent}</li>
|
||||
* </ul>
|
||||
*
|
||||
* @deprecated draft API
|
||||
*/
|
||||
@Deprecated
|
||||
@Warning(false)
|
||||
public class InventoryBlockStartEvent extends BlockEvent {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private final ItemStack source;
|
||||
|
||||
public InventoryBlockStartEvent(@NotNull final Block block, @NotNull ItemStack source) {
|
||||
super(block);
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the source ItemStack for this event.
|
||||
*
|
||||
* @return the source ItemStack
|
||||
*/
|
||||
@NotNull
|
||||
public ItemStack getSource() {
|
||||
return source;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
@ -2,34 +2,25 @@ package org.bukkit.event.inventory;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.block.BlockEvent;
|
||||
import org.bukkit.event.block.InventoryBlockStartEvent;
|
||||
import org.bukkit.inventory.CookingRecipe;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class FurnaceStartSmeltEvent extends BlockEvent {
|
||||
/**
|
||||
* Called when a Furnace starts smelting.
|
||||
*/
|
||||
public class FurnaceStartSmeltEvent extends InventoryBlockStartEvent {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private final ItemStack source;
|
||||
private final CookingRecipe<?> recipe;
|
||||
private int totalCookTime;
|
||||
|
||||
public FurnaceStartSmeltEvent(@NotNull final Block furnace, @NotNull ItemStack source, @NotNull final CookingRecipe<?> recipe) {
|
||||
super(furnace);
|
||||
this.source = source;
|
||||
super(furnace, source);
|
||||
this.recipe = recipe;
|
||||
this.totalCookTime = recipe.getCookingTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the source ItemStack for this event
|
||||
*
|
||||
* @return the source ItemStack
|
||||
*/
|
||||
@NotNull
|
||||
public ItemStack getSource() {
|
||||
return source;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the FurnaceRecipe associated with this event
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user