Yatopia/patches/server/0005-EMC-Anvil-Event.patch
2020-02-26 20:12:29 +01:00

46 lines
2.0 KiB
Diff

From 12d1be74c6892d67c0c4e134b3bceb7de7806e34 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Mon, 31 Dec 2012 01:25:46 -0500
Subject: [PATCH] EMC Anvil Event
Fire an event for anvil usage, remove cap from server, send level to client
---
.../java/net/minecraft/server/ContainerAnvil.java | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/src/main/java/net/minecraft/server/ContainerAnvil.java b/src/main/java/net/minecraft/server/ContainerAnvil.java
index 286b930d..49c264b3 100644
--- a/src/main/java/net/minecraft/server/ContainerAnvil.java
+++ b/src/main/java/net/minecraft/server/ContainerAnvil.java
@@ -7,6 +7,10 @@ import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
// CraftBukkit start
+import com.empireminecraft.customevents.AnvilEvent; // EMC
+import org.bukkit.Bukkit; // EMC
+import org.bukkit.entity.Player; // EMC
+import org.bukkit.craftbukkit.inventory.CraftItemStack; // EMC
import org.bukkit.craftbukkit.inventory.CraftInventoryView;
// CraftBukkit end
@@ -298,6 +302,16 @@ public class ContainerAnvil extends Container {
if (this.levelCost.get() >= maximumRepairCost && !this.player.abilities.canInstantlyBuild) { // CraftBukkit
itemstack1 = ItemStack.a;
}
+ // EMC start
+ AnvilEvent event = new AnvilEvent((Player) player.getBukkitEntity(), CraftItemStack.asBukkitCopy(itemstack), CraftItemStack.asBukkitCopy(itemstack2), CraftItemStack.asBukkitCopy(itemstack1), this.levelCost.get());
+ Bukkit.getPluginManager().callEvent(event);
+ if (event.isCancelled()) {
+ itemstack1 = ItemStack.NULL_ITEM;
+ } else {
+ itemstack1 = CraftItemStack.asNMSCopy(event.getResult());
+ this.levelCost.set(event.getCost());
+ }
+ // EMC end
if (!itemstack1.isEmpty()) {
int k2 = itemstack1.getRepairCost();
--
2.25.1.windows.1