mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-08 19:34:09 +01:00
SPIGOT-5034: FoodLevelChangeEvent add getItem method
By: md_5 <git@md-5.net>
This commit is contained in:
parent
157abe40d4
commit
ca368c2f9f
1 changed files with 18 additions and 0 deletions
|
@ -3,7 +3,9 @@ package org.bukkit.event.entity;
|
||||||
import org.bukkit.entity.HumanEntity;
|
import org.bukkit.entity.HumanEntity;
|
||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a human entity's food level changes
|
* Called when a human entity's food level changes
|
||||||
|
@ -12,10 +14,16 @@ public class FoodLevelChangeEvent extends EntityEvent implements Cancellable {
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
private boolean cancel = false;
|
private boolean cancel = false;
|
||||||
private int level;
|
private int level;
|
||||||
|
private final ItemStack item;
|
||||||
|
|
||||||
public FoodLevelChangeEvent(@NotNull final HumanEntity what, final int level) {
|
public FoodLevelChangeEvent(@NotNull final HumanEntity what, final int level) {
|
||||||
|
this(what, level, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public FoodLevelChangeEvent(@NotNull final HumanEntity what, final int level, @Nullable final ItemStack item) {
|
||||||
super(what);
|
super(what);
|
||||||
this.level = level;
|
this.level = level;
|
||||||
|
this.item = item;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
@ -24,6 +32,16 @@ public class FoodLevelChangeEvent extends EntityEvent implements Cancellable {
|
||||||
return (HumanEntity) entity;
|
return (HumanEntity) entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the item that triggered this event, if any.
|
||||||
|
*
|
||||||
|
* @return an ItemStack for the item being consumed
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public ItemStack getItem() {
|
||||||
|
return (item == null) ? null : item.clone();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the resultant food level that the entity involved in this event
|
* Gets the resultant food level that the entity involved in this event
|
||||||
* should be set to.
|
* should be set to.
|
||||||
|
|
Loading…
Reference in a new issue