From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
Date: Sun, 19 Apr 2020 00:25:09 -0500
Subject: [PATCH] Anvil API


diff --git a/src/main/java/net/pl3x/purpur/event/inventory/AnvilTakeResultEvent.java b/src/main/java/net/pl3x/purpur/event/inventory/AnvilTakeResultEvent.java
new file mode 100644
index 0000000000000000000000000000000000000000..85663c0a44695f7b7f01a68693cac3d99f4b56ca
--- /dev/null
+++ b/src/main/java/net/pl3x/purpur/event/inventory/AnvilTakeResultEvent.java
@@ -0,0 +1,52 @@
+package net.pl3x.purpur.event.inventory;
+
+import org.bukkit.entity.HumanEntity;
+import org.bukkit.entity.Player;
+import org.bukkit.event.HandlerList;
+import org.bukkit.event.inventory.InventoryEvent;
+import org.bukkit.inventory.AnvilInventory;
+import org.bukkit.inventory.InventoryView;
+import org.bukkit.inventory.ItemStack;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * Called when a player takes the result item out of an anvil
+ */
+public class AnvilTakeResultEvent extends InventoryEvent {
+    private static final HandlerList handlers = new HandlerList();
+    private final Player player;
+    private final ItemStack result;
+
+    public AnvilTakeResultEvent(@NotNull HumanEntity player, @NotNull InventoryView view, @NotNull ItemStack result) {
+        super(view);
+        this.player = (Player) player;
+        this.result = result;
+    }
+
+    @NotNull
+    public Player getPlayer() {
+        return player;
+    }
+
+    @NotNull
+    public ItemStack getResult() {
+        return result;
+    }
+
+    @NotNull
+    @Override
+    public AnvilInventory getInventory() {
+        return (AnvilInventory) super.getInventory();
+    }
+
+    @NotNull
+    @Override
+    public HandlerList getHandlers() {
+        return handlers;
+    }
+
+    @NotNull
+    public static HandlerList getHandlerList() {
+        return handlers;
+    }
+}
diff --git a/src/main/java/net/pl3x/purpur/event/inventory/AnvilUpdateResultEvent.java b/src/main/java/net/pl3x/purpur/event/inventory/AnvilUpdateResultEvent.java
new file mode 100644
index 0000000000000000000000000000000000000000..2717ad82ccc0d39c5a69b8890303c245e9a17f83
--- /dev/null
+++ b/src/main/java/net/pl3x/purpur/event/inventory/AnvilUpdateResultEvent.java
@@ -0,0 +1,35 @@
+package net.pl3x.purpur.event.inventory;
+
+import org.bukkit.event.HandlerList;
+import org.bukkit.event.inventory.InventoryEvent;
+import org.bukkit.inventory.AnvilInventory;
+import org.bukkit.inventory.InventoryView;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * Called when anvil slots change, triggering the result slot to be updated
+ */
+public class AnvilUpdateResultEvent extends InventoryEvent {
+    private static final HandlerList handlers = new HandlerList();
+
+    public AnvilUpdateResultEvent(@NotNull InventoryView view) {
+        super(view);
+    }
+
+    @NotNull
+    @Override
+    public AnvilInventory getInventory() {
+        return (AnvilInventory) super.getInventory();
+    }
+
+    @NotNull
+    @Override
+    public HandlerList getHandlers() {
+        return handlers;
+    }
+
+    @NotNull
+    public static HandlerList getHandlerList() {
+        return handlers;
+    }
+}
diff --git a/src/main/java/org/bukkit/inventory/AnvilInventory.java b/src/main/java/org/bukkit/inventory/AnvilInventory.java
index b95e563b5454306a9188ae3295309ee86a756477..435026e533ea9edb8c1800d35c63543ca023a904 100644
--- a/src/main/java/org/bukkit/inventory/AnvilInventory.java
+++ b/src/main/java/org/bukkit/inventory/AnvilInventory.java
@@ -109,4 +109,14 @@ public interface AnvilInventory extends Inventory {
         setItem(2, result);
     }
     // Paper end
+
+    // Purpur start
+    boolean canBypassCost();
+
+    void setBypassCost(boolean bypassCost);
+
+    boolean canDoUnsafeEnchants();
+
+    void setDoUnsafeEnchants(boolean canDoUnsafeEnchants);
+    // Purpur end
 }
