13
0
geforkt von Mirrors/Paper
Paper/patches/api/Add-PrepareResultEvent-PrepareGrindstoneEvent.patch
Jake Potrebic a4112a5c50 Updated Upstream (Bukkit/CraftBukkit) (#8663)
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:
f50ad1f8 PR-798: Add PrepareGrindstoneEvent and refactor related events to use PrepareInventoryResultEvent
0cac7963 SPIGOT-7204: Add TeleportCause#DISMOUNT
b4dd47b0 SPIGOT-7202: Deprecate removed door effects

CraftBukkit Changes:
ab1586c2f PR-1123: Add PrepareGrindstoneEvent
b402824ea SPIGOT-7204: Add TeleportCause#DISMOUNT
06a6a1012 PR-1121: Add unit test for spawn egg meta
c18668be3 SPIGOT-7192: Call PlayerInteractEvent with Action.LEFT_CLICK_AIR if the entity interacted is hidden to the player
47124f639 Increase outdated build delay
645993470 SPIGOT-7201: Spawner ItemMeta not working as expected
2022-12-13 21:03:57 -08:00

197 Zeilen
7.9 KiB
Diff

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..0000000000000000000000000000000000000000
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/inventory/PrepareGrindstoneEvent.java
@@ -0,0 +0,0 @@
+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
+ * @deprecated use {@link org.bukkit.event.inventory.PrepareGrindstoneEvent}
+ */
+@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
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/inventory/PrepareResultEvent.java
@@ -0,0 +0,0 @@
+package com.destroystokyo.paper.event.inventory;
+
+import org.bukkit.event.inventory.PrepareInventoryResultEvent;
+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
+ */
+public class PrepareResultEvent extends PrepareInventoryResultEvent {
+
+ // HandlerList on PrepareInventoryResultEvent to ensure api compat
+ public PrepareResultEvent(@NotNull InventoryView inventory, @Nullable ItemStack result) {
+ super(inventory, result);
+ }
+
+ /**
+ * Get result item, may be null.
+ *
+ * @return result item
+ */
+ @Nullable
+ public ItemStack getResult() {
+ return super.getResult();
+ }
+
+ /**
+ * Set result item, may be null.
+ *
+ * @param result result item
+ */
+ public void setResult(@Nullable ItemStack result) {
+ super.setResult(result);
+ }
+}
diff --git a/src/main/java/org/bukkit/event/inventory/PrepareAnvilEvent.java b/src/main/java/org/bukkit/event/inventory/PrepareAnvilEvent.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/event/inventory/PrepareAnvilEvent.java
+++ b/src/main/java/org/bukkit/event/inventory/PrepareAnvilEvent.java
@@ -0,0 +0,0 @@ import org.jetbrains.annotations.Nullable;
/**
* 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 {
- private static final HandlerList handlers = new HandlerList();
+ // Paper - move HandlerList to PrepareInventoryResultEvent
public PrepareAnvilEvent(@NotNull InventoryView inventory, @Nullable ItemStack result) {
super(inventory, result);
@@ -0,0 +0,0 @@ public class PrepareAnvilEvent extends PrepareInventoryResultEvent {
return (AnvilInventory) super.getInventory();
}
- @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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/event/inventory/PrepareGrindstoneEvent.java
+++ b/src/main/java/org/bukkit/event/inventory/PrepareGrindstoneEvent.java
@@ -0,0 +0,0 @@ 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
- private static final HandlerList handlers = new HandlerList();
+ // Paper - move HandlerList to PrepareInventoryResultEvent
public PrepareGrindstoneEvent(@NotNull InventoryView inventory, @Nullable ItemStack result) {
super(inventory, result);
@@ -0,0 +0,0 @@ public class PrepareGrindstoneEvent extends PrepareInventoryResultEvent {
return (GrindstoneInventory) super.getInventory();
}
- @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/PrepareInventoryResultEvent.java b/src/main/java/org/bukkit/event/inventory/PrepareInventoryResultEvent.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/event/inventory/PrepareInventoryResultEvent.java
+++ b/src/main/java/org/bukkit/event/inventory/PrepareInventoryResultEvent.java
@@ -0,0 +0,0 @@ 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();
diff --git a/src/main/java/org/bukkit/event/inventory/PrepareSmithingEvent.java b/src/main/java/org/bukkit/event/inventory/PrepareSmithingEvent.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/event/inventory/PrepareSmithingEvent.java
+++ b/src/main/java/org/bukkit/event/inventory/PrepareSmithingEvent.java
@@ -0,0 +0,0 @@ import org.jetbrains.annotations.Nullable;
/**
* 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 {
- private static final HandlerList handlers = new HandlerList();
+ // Paper - move HandlerList ot PrepareInventoryResultEvent
public PrepareSmithingEvent(@NotNull InventoryView inventory, @Nullable ItemStack result) {
super(inventory, result);
@@ -0,0 +0,0 @@ public class PrepareSmithingEvent extends PrepareInventoryResultEvent {
return (SmithingInventory) super.getInventory();
}
- @NotNull
- @Override
- public HandlerList getHandlers() {
- return handlers;
- }
-
- @NotNull
- public static HandlerList getHandlerList() {
- return handlers;
- }
+ // Paper - move HandlerList to PrepareInventoryResultEvent
}