PaperMC/patches/api/0196-Add-PrepareResultEvent-PrepareGrindstoneEvent.patch

207 lines
8.2 KiB
Diff
Raw Normal View History

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
index 0000000000000000000000000000000000000000..f75933948cdf0aa0c9bb2f06da5418f164af1148
2021-06-11 14:02:28 +02:00
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/inventory/PrepareGrindstoneEvent.java
2024-02-01 10:15:57 +01:00
@@ -0,0 +1,31 @@
2021-06-11 14:02:28 +02:00
+package com.destroystokyo.paper.event.inventory;
+
+import org.bukkit.Warning;
2021-06-11 14:02:28 +02:00
+import org.bukkit.inventory.GrindstoneInventory;
+import org.bukkit.inventory.InventoryView;
+import org.bukkit.inventory.ItemStack;
2024-02-01 10:15:57 +01:00
+import org.jetbrains.annotations.ApiStatus;
2021-06-11 14:02:28 +02:00
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Called when an item is put in a slot for grinding in a Grindstone
2024-02-01 10:15:57 +01:00
+ *
+ * @deprecated use {@link org.bukkit.event.inventory.PrepareGrindstoneEvent}
2021-06-11 14:02:28 +02:00
+ */
+@Deprecated(since = "1.16.1")
2024-02-01 10:15:57 +01:00
+@Warning
2021-06-11 14:02:28 +02:00
+public class PrepareGrindstoneEvent extends PrepareResultEvent {
+
2024-02-01 10:15:57 +01:00
+ @ApiStatus.Internal
2021-06-11 14:02:28 +02:00
+ 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
index 0000000000000000000000000000000000000000..8ca7858613bb78ee1f9453b55fc38e00414fefb5
2021-06-11 14:02:28 +02:00
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/inventory/PrepareResultEvent.java
@@ -0,0 +1,42 @@
2021-06-11 14:02:28 +02:00
+package com.destroystokyo.paper.event.inventory;
+
+import org.bukkit.event.inventory.PrepareInventoryResultEvent;
2021-06-11 14:02:28 +02:00
+import org.bukkit.inventory.InventoryView;
+import org.bukkit.inventory.ItemStack;
2024-02-01 10:15:57 +01:00
+import org.jetbrains.annotations.ApiStatus;
+import org.jspecify.annotations.NullMarked;
+import org.jspecify.annotations.Nullable;
2021-06-11 14:02:28 +02:00
+
+/**
+ * Called when an item is put in an inventory containing a result slot
+ */
+@NullMarked
+public class PrepareResultEvent extends PrepareInventoryResultEvent {
2021-06-11 14:02:28 +02:00
+
+ // HandlerList on PrepareInventoryResultEvent to ensure api compat
2024-02-01 10:15:57 +01:00
+
+ @ApiStatus.Internal
+ public PrepareResultEvent(final InventoryView inventory, final @Nullable ItemStack result) {
+ super(inventory, result);
2021-06-11 14:02:28 +02:00
+ }
+
+ /**
2024-02-01 10:15:57 +01:00
+ * Get result item, may be {@code null}.
2021-06-11 14:02:28 +02:00
+ *
+ * @return result item
+ */
+ @Override
+ public @Nullable ItemStack getResult() {
+ return super.getResult();
2021-06-11 14:02:28 +02:00
+ }
+
+ /**
2024-02-01 10:15:57 +01:00
+ * Set result item, may be {@code null}.
+ *
+ * @param result result item
+ */
+ @Override
+ public void setResult(final @Nullable ItemStack result) {
+ 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
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#11197) Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: 2ec53f49 PR-1050: Fix empty result check for Complex Recipes 10671012 PR-1044: Add CrafterCraftEvent 4d87ffe0 Use correct method in JavaDoc ae5e5817 SPIGOT-7850: Add API for Bogged shear state 46b6d445 SPIGOT-7837: Support data pack banner patterns d5d0cefc Fix JavaDoc error b3c2b83d PR-1036: Add API for InventoryView derivatives 1fe2c75a SPIGOT-7809: Add ShieldMeta CraftBukkit Changes: 8ee6fd1b8 SPIGOT-7857: Improve ItemMeta block data deserialization 8f26c30c6 SPIGOT-7857: Fix spurious internal NBT tag when deserializing BlockStateMeta 759061b93 SPIGOT-7855: Fire does not spread or burn blocks 00fc9fb64 SPIGOT-7853: AnvilInventory#getRepairCost() always returns 0 7501e2e04 PR-1450: Add CrafterCraftEvent 8c51673e7 SPIGOT-5731: PortalCreateEvent#getEntity returns null for nether portals ignited by flint and steel d53d0d0b1 PR-1456: Fix inverted logic in CraftCrafterView#setSlotDisabled 682a678c8 SPIGOT-7850: Add API for Bogged shear state fccf5243a SPIGOT-7837: Support data pack banner patterns 9c3bd4390 PR-1431: Add API for InventoryView derivatives 0cc6acbc4 SPIGOT-7849: Fix FoodComponent serialize with "using-converts-to" using null 2c5474952 Don't rely on tags for CraftItemMetas 20d107e46 SPIGOT-7846: Fix ItemMeta for hanging signs 76f59e315 Remove redundant clone in Dropper InventoryMoveItemEvent e61a53d25 SPIGOT-7817: Call InventoryMoveItemEvent for Crafters 894682e2d SPIGOT-7839: Remove redundant Java version checks 2c12b2187 SPIGOT-7809: Add ShieldMeta and fix setting shield base colours Spigot Changes: fb8fb722 Rebuild patches 34bd42b7 SPIGOT-7835: Fix issue with custom hopper settings
2024-08-09 22:05:50 +02:00
index 8a5be3f0322ac19aeac3f00df54add0e73bc87ed..d2b4b2e9385e7c1e0e1e42886481b99ecc8dcf8e 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
@@ -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.
*/
-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();
+ // Paper - move HandlerList to PrepareInventoryResultEvent
2021-06-11 14:02:28 +02:00
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#11197) Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: 2ec53f49 PR-1050: Fix empty result check for Complex Recipes 10671012 PR-1044: Add CrafterCraftEvent 4d87ffe0 Use correct method in JavaDoc ae5e5817 SPIGOT-7850: Add API for Bogged shear state 46b6d445 SPIGOT-7837: Support data pack banner patterns d5d0cefc Fix JavaDoc error b3c2b83d PR-1036: Add API for InventoryView derivatives 1fe2c75a SPIGOT-7809: Add ShieldMeta CraftBukkit Changes: 8ee6fd1b8 SPIGOT-7857: Improve ItemMeta block data deserialization 8f26c30c6 SPIGOT-7857: Fix spurious internal NBT tag when deserializing BlockStateMeta 759061b93 SPIGOT-7855: Fire does not spread or burn blocks 00fc9fb64 SPIGOT-7853: AnvilInventory#getRepairCost() always returns 0 7501e2e04 PR-1450: Add CrafterCraftEvent 8c51673e7 SPIGOT-5731: PortalCreateEvent#getEntity returns null for nether portals ignited by flint and steel d53d0d0b1 PR-1456: Fix inverted logic in CraftCrafterView#setSlotDisabled 682a678c8 SPIGOT-7850: Add API for Bogged shear state fccf5243a SPIGOT-7837: Support data pack banner patterns 9c3bd4390 PR-1431: Add API for InventoryView derivatives 0cc6acbc4 SPIGOT-7849: Fix FoodComponent serialize with "using-converts-to" using null 2c5474952 Don't rely on tags for CraftItemMetas 20d107e46 SPIGOT-7846: Fix ItemMeta for hanging signs 76f59e315 Remove redundant clone in Dropper InventoryMoveItemEvent e61a53d25 SPIGOT-7817: Call InventoryMoveItemEvent for Crafters 894682e2d SPIGOT-7839: Remove redundant Java version checks 2c12b2187 SPIGOT-7809: Add ShieldMeta and fix setting shield base colours Spigot Changes: fb8fb722 Rebuild patches 34bd42b7 SPIGOT-7835: Fix issue with custom hopper settings
2024-08-09 22:05:50 +02:00
public PrepareAnvilEvent(@NotNull AnvilView inventory, @Nullable ItemStack result) {
super(inventory, result);
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#11197) Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: 2ec53f49 PR-1050: Fix empty result check for Complex Recipes 10671012 PR-1044: Add CrafterCraftEvent 4d87ffe0 Use correct method in JavaDoc ae5e5817 SPIGOT-7850: Add API for Bogged shear state 46b6d445 SPIGOT-7837: Support data pack banner patterns d5d0cefc Fix JavaDoc error b3c2b83d PR-1036: Add API for InventoryView derivatives 1fe2c75a SPIGOT-7809: Add ShieldMeta CraftBukkit Changes: 8ee6fd1b8 SPIGOT-7857: Improve ItemMeta block data deserialization 8f26c30c6 SPIGOT-7857: Fix spurious internal NBT tag when deserializing BlockStateMeta 759061b93 SPIGOT-7855: Fire does not spread or burn blocks 00fc9fb64 SPIGOT-7853: AnvilInventory#getRepairCost() always returns 0 7501e2e04 PR-1450: Add CrafterCraftEvent 8c51673e7 SPIGOT-5731: PortalCreateEvent#getEntity returns null for nether portals ignited by flint and steel d53d0d0b1 PR-1456: Fix inverted logic in CraftCrafterView#setSlotDisabled 682a678c8 SPIGOT-7850: Add API for Bogged shear state fccf5243a SPIGOT-7837: Support data pack banner patterns 9c3bd4390 PR-1431: Add API for InventoryView derivatives 0cc6acbc4 SPIGOT-7849: Fix FoodComponent serialize with "using-converts-to" using null 2c5474952 Don't rely on tags for CraftItemMetas 20d107e46 SPIGOT-7846: Fix ItemMeta for hanging signs 76f59e315 Remove redundant clone in Dropper InventoryMoveItemEvent e61a53d25 SPIGOT-7817: Call InventoryMoveItemEvent for Crafters 894682e2d SPIGOT-7839: Remove redundant Java version checks 2c12b2187 SPIGOT-7809: Add ShieldMeta and fix setting shield base colours Spigot Changes: fb8fb722 Rebuild patches 34bd42b7 SPIGOT-7835: Fix issue with custom hopper settings
2024-08-09 22:05:50 +02:00
@@ -44,14 +44,5 @@ public class PrepareAnvilEvent extends PrepareInventoryResultEvent {
return (AnvilView) super.getView();
2021-06-11 14:02:28 +02: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
- private static final HandlerList handlers = new HandlerList();
+ // Paper - move HandlerList to PrepareInventoryResultEvent
2021-06-11 14:02:28 +02: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
}
- @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
}
diff --git a/src/main/java/org/bukkit/event/inventory/PrepareInventoryResultEvent.java b/src/main/java/org/bukkit/event/inventory/PrepareInventoryResultEvent.java
index b543bc17fb9354d1939c67c1fb6c92d88fdbe4ec..0b58ffff39845b658dee7c35dcae6cdb333f20b3 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 @org.bukkit.Warning(false) // 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
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
@@ -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.
*/
-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();
+ // Paper - move HandlerList ot PrepareInventoryResultEvent
2021-06-11 14:02:28 +02:00
public PrepareSmithingEvent(@NotNull InventoryView inventory, @Nullable ItemStack result) {
super(inventory, result);
@@ -24,14 +24,5 @@ public class PrepareSmithingEvent extends PrepareInventoryResultEvent {
return (SmithingInventory) super.getInventory();
2021-06-11 14:02:28 +02: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
}