2021-06-11 14:02:28 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
|
|
|
|
Date: Fri, 3 Jul 2020 11:58:56 -0500
|
|
|
|
Subject: [PATCH] Add PrepareResultEvent / PrepareGrindstoneEvent
|
|
|
|
|
|
|
|
Adds a new event for all crafting stations that generate a result slot item
|
|
|
|
|
|
|
|
Anvil, Grindstone and Smithing now extend this event
|
|
|
|
|
|
|
|
Grindstone is a backwards compat from a previous PrepareGrindstoneEvent
|
|
|
|
|
|
|
|
diff --git a/src/main/java/com/destroystokyo/paper/event/inventory/PrepareGrindstoneEvent.java b/src/main/java/com/destroystokyo/paper/event/inventory/PrepareGrindstoneEvent.java
|
|
|
|
new file mode 100644
|
2022-12-14 06:03:57 +01:00
|
|
|
index 0000000000000000000000000000000000000000..a89d189e1175e980e5af8476f539f0a025e8903b
|
2021-06-11 14:02:28 +02:00
|
|
|
--- /dev/null
|
|
|
|
+++ b/src/main/java/com/destroystokyo/paper/event/inventory/PrepareGrindstoneEvent.java
|
2022-12-14 06:03:57 +01:00
|
|
|
@@ -0,0 +1,26 @@
|
2021-06-11 14:02:28 +02:00
|
|
|
+package com.destroystokyo.paper.event.inventory;
|
|
|
|
+
|
|
|
|
+import org.bukkit.inventory.GrindstoneInventory;
|
|
|
|
+import org.bukkit.inventory.InventoryView;
|
|
|
|
+import org.bukkit.inventory.ItemStack;
|
|
|
|
+import org.jetbrains.annotations.NotNull;
|
|
|
|
+import org.jetbrains.annotations.Nullable;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * Called when an item is put in a slot for grinding in a Grindstone
|
2022-12-14 06:03:57 +01:00
|
|
|
+ * @deprecated use {@link org.bukkit.event.inventory.PrepareGrindstoneEvent}
|
2021-06-11 14:02:28 +02:00
|
|
|
+ */
|
|
|
|
+@Deprecated
|
|
|
|
+public class PrepareGrindstoneEvent extends PrepareResultEvent {
|
|
|
|
+
|
|
|
|
+ public PrepareGrindstoneEvent(@NotNull InventoryView inventory, @Nullable ItemStack result) {
|
|
|
|
+ super(inventory, result);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @NotNull
|
|
|
|
+ @Override
|
|
|
|
+ public GrindstoneInventory getInventory() {
|
|
|
|
+ return (GrindstoneInventory) super.getInventory();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+}
|
|
|
|
diff --git a/src/main/java/com/destroystokyo/paper/event/inventory/PrepareResultEvent.java b/src/main/java/com/destroystokyo/paper/event/inventory/PrepareResultEvent.java
|
|
|
|
new file mode 100644
|
2022-12-14 06:03:57 +01:00
|
|
|
index 0000000000000000000000000000000000000000..25e5f0354b3b65c656d6c173ec108825f1e8b1be
|
2021-06-11 14:02:28 +02:00
|
|
|
--- /dev/null
|
|
|
|
+++ b/src/main/java/com/destroystokyo/paper/event/inventory/PrepareResultEvent.java
|
2022-12-14 06:03:57 +01:00
|
|
|
@@ -0,0 +1,37 @@
|
2021-06-11 14:02:28 +02:00
|
|
|
+package com.destroystokyo.paper.event.inventory;
|
|
|
|
+
|
2022-12-14 06:03:57 +01:00
|
|
|
+import org.bukkit.event.inventory.PrepareInventoryResultEvent;
|
2021-06-11 14:02:28 +02:00
|
|
|
+import org.bukkit.inventory.InventoryView;
|
|
|
|
+import org.bukkit.inventory.ItemStack;
|
|
|
|
+import org.jetbrains.annotations.NotNull;
|
|
|
|
+import org.jetbrains.annotations.Nullable;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * Called when an item is put in an inventory containing a result slot
|
|
|
|
+ */
|
2022-12-14 06:03:57 +01:00
|
|
|
+public class PrepareResultEvent extends PrepareInventoryResultEvent {
|
2021-06-11 14:02:28 +02:00
|
|
|
+
|
2022-12-14 06:03:57 +01:00
|
|
|
+ // HandlerList on PrepareInventoryResultEvent to ensure api compat
|
2021-06-11 14:02:28 +02:00
|
|
|
+ public PrepareResultEvent(@NotNull InventoryView inventory, @Nullable ItemStack result) {
|
2022-12-14 06:03:57 +01:00
|
|
|
+ super(inventory, result);
|
2021-06-11 14:02:28 +02:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Get result item, may be null.
|
|
|
|
+ *
|
|
|
|
+ * @return result item
|
|
|
|
+ */
|
|
|
|
+ @Nullable
|
|
|
|
+ public ItemStack getResult() {
|
2022-12-14 06:03:57 +01:00
|
|
|
+ return super.getResult();
|
2021-06-11 14:02:28 +02:00
|
|
|
+ }
|
|
|
|
+
|
2022-12-14 06:03:57 +01:00
|
|
|
+ /**
|
|
|
|
+ * Set result item, may be null.
|
|
|
|
+ *
|
|
|
|
+ * @param result result item
|
|
|
|
+ */
|
2021-06-11 14:02:28 +02:00
|
|
|
+ public void setResult(@Nullable ItemStack result) {
|
2022-12-14 06:03:57 +01:00
|
|
|
+ super.setResult(result);
|
2021-06-11 14:02:28 +02:00
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
diff --git a/src/main/java/org/bukkit/event/inventory/PrepareAnvilEvent.java b/src/main/java/org/bukkit/event/inventory/PrepareAnvilEvent.java
|
2022-12-14 06:03:57 +01:00
|
|
|
index 6782024735a885ba0b1b4dba4a576740c1410366..8695715c10d81b06c088ff0c8d401875d26879b5 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/org/bukkit/event/inventory/PrepareAnvilEvent.java
|
|
|
|
+++ b/src/main/java/org/bukkit/event/inventory/PrepareAnvilEvent.java
|
2022-12-14 06:03:57 +01:00
|
|
|
@@ -10,9 +10,9 @@ import org.jetbrains.annotations.Nullable;
|
2021-06-11 14:02:28 +02:00
|
|
|
/**
|
|
|
|
* Called when an item is put in a slot for repair by an anvil.
|
|
|
|
*/
|
2022-12-14 06:03:57 +01:00
|
|
|
-public class PrepareAnvilEvent extends PrepareInventoryResultEvent {
|
|
|
|
+public class PrepareAnvilEvent extends com.destroystokyo.paper.event.inventory.PrepareResultEvent {
|
2021-06-11 14:02:28 +02:00
|
|
|
|
|
|
|
- private static final HandlerList handlers = new HandlerList();
|
2022-12-14 06:03:57 +01:00
|
|
|
+ // Paper - move HandlerList to PrepareInventoryResultEvent
|
2021-06-11 14:02:28 +02:00
|
|
|
|
|
|
|
public PrepareAnvilEvent(@NotNull InventoryView inventory, @Nullable ItemStack result) {
|
2022-12-14 06:03:57 +01:00
|
|
|
super(inventory, result);
|
|
|
|
@@ -24,14 +24,5 @@ public class PrepareAnvilEvent extends PrepareInventoryResultEvent {
|
|
|
|
return (AnvilInventory) super.getInventory();
|
2021-06-11 14:02:28 +02:00
|
|
|
}
|
|
|
|
|
2022-12-14 06:03:57 +01:00
|
|
|
- @NotNull
|
|
|
|
- @Override
|
|
|
|
- public HandlerList getHandlers() {
|
|
|
|
- return handlers;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @NotNull
|
|
|
|
- public static HandlerList getHandlerList() {
|
|
|
|
- return handlers;
|
|
|
|
- }
|
|
|
|
+ // Paper - move HandlerList to PrepareInventoryResultEvent
|
|
|
|
}
|
|
|
|
diff --git a/src/main/java/org/bukkit/event/inventory/PrepareGrindstoneEvent.java b/src/main/java/org/bukkit/event/inventory/PrepareGrindstoneEvent.java
|
|
|
|
index fb172479ce28edbf969b9492236e30fb04395bf9..a7e03600099b8d6a117b8f5455fee24eed03e3a3 100644
|
|
|
|
--- a/src/main/java/org/bukkit/event/inventory/PrepareGrindstoneEvent.java
|
|
|
|
+++ b/src/main/java/org/bukkit/event/inventory/PrepareGrindstoneEvent.java
|
|
|
|
@@ -10,9 +10,9 @@ import org.jetbrains.annotations.Nullable;
|
|
|
|
/**
|
|
|
|
* Called when an item is put in a slot for repair or unenchanting in a grindstone.
|
|
|
|
*/
|
|
|
|
-public class PrepareGrindstoneEvent extends PrepareInventoryResultEvent {
|
|
|
|
+public class PrepareGrindstoneEvent extends com.destroystokyo.paper.event.inventory.PrepareGrindstoneEvent { // Paper
|
2021-06-11 14:02:28 +02:00
|
|
|
|
2022-12-14 06:03:57 +01:00
|
|
|
- private static final HandlerList handlers = new HandlerList();
|
|
|
|
+ // Paper - move HandlerList to PrepareInventoryResultEvent
|
2021-06-11 14:02:28 +02:00
|
|
|
|
2022-12-14 06:03:57 +01:00
|
|
|
public PrepareGrindstoneEvent(@NotNull InventoryView inventory, @Nullable ItemStack result) {
|
|
|
|
super(inventory, result);
|
|
|
|
@@ -24,14 +24,5 @@ public class PrepareGrindstoneEvent extends PrepareInventoryResultEvent {
|
|
|
|
return (GrindstoneInventory) super.getInventory();
|
2021-06-11 14:02:28 +02:00
|
|
|
}
|
2022-12-14 06:03:57 +01:00
|
|
|
|
|
|
|
- @NotNull
|
|
|
|
- @Override
|
|
|
|
- public HandlerList getHandlers() {
|
|
|
|
- return handlers;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @NotNull
|
|
|
|
- public static HandlerList getHandlerList() {
|
|
|
|
- return handlers;
|
|
|
|
- }
|
|
|
|
+ // Paper - move HandlerList to PrepareInventoryResultEvent
|
2021-06-11 14:02:28 +02:00
|
|
|
}
|
2022-12-14 06:03:57 +01:00
|
|
|
diff --git a/src/main/java/org/bukkit/event/inventory/PrepareInventoryResultEvent.java b/src/main/java/org/bukkit/event/inventory/PrepareInventoryResultEvent.java
|
|
|
|
index b543bc17fb9354d1939c67c1fb6c92d88fdbe4ec..656ffd4cf7851d6862cc9b675502efa03f4eb94c 100644
|
|
|
|
--- a/src/main/java/org/bukkit/event/inventory/PrepareInventoryResultEvent.java
|
|
|
|
+++ b/src/main/java/org/bukkit/event/inventory/PrepareInventoryResultEvent.java
|
|
|
|
@@ -8,7 +8,9 @@ import org.jetbrains.annotations.Nullable;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when an item is put in a slot and the result is calculated.
|
|
|
|
+ * @deprecated use {@link com.destroystokyo.paper.event.inventory.PrepareResultEvent}
|
|
|
|
*/
|
|
|
|
+@Deprecated // Paper
|
|
|
|
public class PrepareInventoryResultEvent extends InventoryEvent {
|
|
|
|
|
|
|
|
private static final HandlerList handlers = new HandlerList();
|
2021-06-11 14:02:28 +02:00
|
|
|
diff --git a/src/main/java/org/bukkit/event/inventory/PrepareSmithingEvent.java b/src/main/java/org/bukkit/event/inventory/PrepareSmithingEvent.java
|
2022-12-14 06:03:57 +01:00
|
|
|
index 901774e03f8789dddff4e7695ac599ff69cc97a5..8d7924fa81e9b53514fa534f0572fd7effef73c4 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/org/bukkit/event/inventory/PrepareSmithingEvent.java
|
|
|
|
+++ b/src/main/java/org/bukkit/event/inventory/PrepareSmithingEvent.java
|
2022-12-14 06:03:57 +01:00
|
|
|
@@ -10,9 +10,9 @@ import org.jetbrains.annotations.Nullable;
|
2021-06-11 14:02:28 +02:00
|
|
|
/**
|
|
|
|
* Called when an item is put in a slot for upgrade by a Smithing Table.
|
|
|
|
*/
|
2022-12-14 06:03:57 +01:00
|
|
|
-public class PrepareSmithingEvent extends PrepareInventoryResultEvent {
|
|
|
|
+public class PrepareSmithingEvent extends com.destroystokyo.paper.event.inventory.PrepareResultEvent {
|
2021-06-11 14:02:28 +02:00
|
|
|
|
|
|
|
- private static final HandlerList handlers = new HandlerList();
|
2022-12-14 06:03:57 +01:00
|
|
|
+ // Paper - move HandlerList ot PrepareInventoryResultEvent
|
2021-06-11 14:02:28 +02:00
|
|
|
|
|
|
|
public PrepareSmithingEvent(@NotNull InventoryView inventory, @Nullable ItemStack result) {
|
2022-12-14 06:03:57 +01:00
|
|
|
super(inventory, result);
|
|
|
|
@@ -24,14 +24,5 @@ public class PrepareSmithingEvent extends PrepareInventoryResultEvent {
|
|
|
|
return (SmithingInventory) super.getInventory();
|
2021-06-11 14:02:28 +02:00
|
|
|
}
|
|
|
|
|
2022-12-14 06:03:57 +01:00
|
|
|
- @NotNull
|
|
|
|
- @Override
|
|
|
|
- public HandlerList getHandlers() {
|
|
|
|
- return handlers;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @NotNull
|
|
|
|
- public static HandlerList getHandlerList() {
|
|
|
|
- return handlers;
|
|
|
|
- }
|
|
|
|
+ // Paper - move HandlerList to PrepareInventoryResultEvent
|
2021-06-11 14:02:28 +02:00
|
|
|
}
|