3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-23 23:00:08 +01:00

SPIGOT-5034: FoodLevelChangeEvent add getItem method

Dieser Commit ist enthalten in:
md_5 2019-06-14 19:41:36 +10:00
Ursprung 4090d01f6d
Commit 43431ba65b
2 geänderte Dateien mit 6 neuen und 2 gelöschten Zeilen

Datei anzeigen

@ -27,7 +27,7 @@
+ int oldFoodLevel = foodLevel; + int oldFoodLevel = foodLevel;
- this.eat(foodinfo.getNutrition(), foodinfo.getSaturationModifier()); - this.eat(foodinfo.getNutrition(), foodinfo.getSaturationModifier());
+ org.bukkit.event.entity.FoodLevelChangeEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callFoodLevelChangeEvent(entityhuman, foodinfo.getNutrition() + oldFoodLevel); + org.bukkit.event.entity.FoodLevelChangeEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callFoodLevelChangeEvent(entityhuman, foodinfo.getNutrition() + oldFoodLevel, itemstack);
+ +
+ if (!event.isCancelled()) { + if (!event.isCancelled()) {
+ this.eat(event.getFoodLevel() - oldFoodLevel, foodinfo.getSaturationModifier()); + this.eat(event.getFoodLevel() - oldFoodLevel, foodinfo.getSaturationModifier());

Datei anzeigen

@ -980,7 +980,11 @@ public class CraftEventFactory {
} }
public static FoodLevelChangeEvent callFoodLevelChangeEvent(EntityHuman entity, int level) { public static FoodLevelChangeEvent callFoodLevelChangeEvent(EntityHuman entity, int level) {
FoodLevelChangeEvent event = new FoodLevelChangeEvent(entity.getBukkitEntity(), level); return callFoodLevelChangeEvent(entity, level, null);
}
public static FoodLevelChangeEvent callFoodLevelChangeEvent(EntityHuman entity, int level, ItemStack item) {
FoodLevelChangeEvent event = new FoodLevelChangeEvent(entity.getBukkitEntity(), level, (item == null) ? null : CraftItemStack.asBukkitCopy(item));
entity.getBukkitEntity().getServer().getPluginManager().callEvent(event); entity.getBukkitEntity().getServer().getPluginManager().callEvent(event);
return event; return event;
} }