From 178a6e502d891faf809d7f76898a7b60fe34b53c Mon Sep 17 00:00:00 2001 From: BillyGalbreath Date: Sat, 4 Jul 2020 22:36:46 -0500 Subject: [PATCH] Add PrepareResultEvent (#3776) Adds a new event for all crafting stations that generate a result slot item Anvil and Grindstone now extend this event --- .../0213-Add-PrepareGrindstoneEvent.patch | 66 -------- ...0213-Support-components-in-ItemMeta.patch} | 0 ...TargetReasons-for-1.16-mob-behavior.patch} | 0 ...reResultEvent-PrepareGrindstoneEvent.patch | 155 ++++++++++++++++++ .../0517-Add-PrepareGrindstoneEvent.patch | 33 ---- ...-Hide-sync-chunk-writes-behind-flag.patch} | 0 ...it-lightning-strike-effect-distance.patch} | 0 ...9-Add-permission-for-command-blocks.patch} | 0 ...ure-Entity-AABB-s-are-never-invalid.patch} | 0 ...orldBorder-collision-checks-and-air.patch} | 0 ...d-Difficulty-Remembering-Difficulty.patch} | 0 ...atch => 0523-Paper-dumpitem-command.patch} | 0 ...24-Don-t-allow-null-UUID-s-for-chat.patch} | 0 ...Legacy-Component-serialization-size.patch} | 0 ...526-Support-old-UUID-format-for-NBT.patch} | 0 ...p-duplicated-GameProfile-Properties.patch} | 0 ...vert-legacy-attributes-in-Item-Meta.patch} | 0 ...Remove-some-streams-from-structures.patch} | 0 ...rom-classes-related-villager-gossip.patch} | 0 ...0531-Support-components-in-ItemMeta.patch} | 0 ...argetLivingEntityEvent-to-1.16-mobs.patch} | 0 ...date-itemstack-legacy-name-and-lore.patch} | 0 ...wn-player-in-correct-world-on-login.patch} | 0 .../0535-Add-PrepareResultEvent.patch | 144 ++++++++++++++++ 24 files changed, 299 insertions(+), 99 deletions(-) delete mode 100644 Spigot-API-Patches/0213-Add-PrepareGrindstoneEvent.patch rename Spigot-API-Patches/{0214-Support-components-in-ItemMeta.patch => 0213-Support-components-in-ItemMeta.patch} (100%) rename Spigot-API-Patches/{0215-added-2-new-TargetReasons-for-1.16-mob-behavior.patch => 0214-added-2-new-TargetReasons-for-1.16-mob-behavior.patch} (100%) create mode 100644 Spigot-API-Patches/0215-Add-PrepareResultEvent-PrepareGrindstoneEvent.patch delete mode 100644 Spigot-Server-Patches/0517-Add-PrepareGrindstoneEvent.patch rename Spigot-Server-Patches/{0518-Hide-sync-chunk-writes-behind-flag.patch => 0517-Hide-sync-chunk-writes-behind-flag.patch} (100%) rename Spigot-Server-Patches/{0519-Limit-lightning-strike-effect-distance.patch => 0518-Limit-lightning-strike-effect-distance.patch} (100%) rename Spigot-Server-Patches/{0520-Add-permission-for-command-blocks.patch => 0519-Add-permission-for-command-blocks.patch} (100%) rename Spigot-Server-Patches/{0521-Ensure-Entity-AABB-s-are-never-invalid.patch => 0520-Ensure-Entity-AABB-s-are-never-invalid.patch} (100%) rename Spigot-Server-Patches/{0522-Optimize-WorldBorder-collision-checks-and-air.patch => 0521-Optimize-WorldBorder-collision-checks-and-air.patch} (100%) rename Spigot-Server-Patches/{0523-Fix-Per-World-Difficulty-Remembering-Difficulty.patch => 0522-Fix-Per-World-Difficulty-Remembering-Difficulty.patch} (100%) rename Spigot-Server-Patches/{0524-Paper-dumpitem-command.patch => 0523-Paper-dumpitem-command.patch} (100%) rename Spigot-Server-Patches/{0525-Don-t-allow-null-UUID-s-for-chat.patch => 0524-Don-t-allow-null-UUID-s-for-chat.patch} (100%) rename Spigot-Server-Patches/{0526-Improve-Legacy-Component-serialization-size.patch => 0525-Improve-Legacy-Component-serialization-size.patch} (100%) rename Spigot-Server-Patches/{0527-Support-old-UUID-format-for-NBT.patch => 0526-Support-old-UUID-format-for-NBT.patch} (100%) rename Spigot-Server-Patches/{0528-Clean-up-duplicated-GameProfile-Properties.patch => 0527-Clean-up-duplicated-GameProfile-Properties.patch} (100%) rename Spigot-Server-Patches/{0529-Convert-legacy-attributes-in-Item-Meta.patch => 0528-Convert-legacy-attributes-in-Item-Meta.patch} (100%) rename Spigot-Server-Patches/{0530-Remove-some-streams-from-structures.patch => 0529-Remove-some-streams-from-structures.patch} (100%) rename Spigot-Server-Patches/{0531-Remove-streams-from-classes-related-villager-gossip.patch => 0530-Remove-streams-from-classes-related-villager-gossip.patch} (100%) rename Spigot-Server-Patches/{0532-Support-components-in-ItemMeta.patch => 0531-Support-components-in-ItemMeta.patch} (100%) rename Spigot-Server-Patches/{0533-added-EntityTargetLivingEntityEvent-to-1.16-mobs.patch => 0532-added-EntityTargetLivingEntityEvent-to-1.16-mobs.patch} (100%) rename Spigot-Server-Patches/{0534-Update-itemstack-legacy-name-and-lore.patch => 0533-Update-itemstack-legacy-name-and-lore.patch} (100%) rename Spigot-Server-Patches/{0535-Spawn-player-in-correct-world-on-login.patch => 0534-Spawn-player-in-correct-world-on-login.patch} (100%) create mode 100644 Spigot-Server-Patches/0535-Add-PrepareResultEvent.patch diff --git a/Spigot-API-Patches/0213-Add-PrepareGrindstoneEvent.patch b/Spigot-API-Patches/0213-Add-PrepareGrindstoneEvent.patch deleted file mode 100644 index fa5a9fb52..000000000 --- a/Spigot-API-Patches/0213-Add-PrepareGrindstoneEvent.patch +++ /dev/null @@ -1,66 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Jan Tuck -Date: Sat, 20 Jun 2020 22:34:21 +0200 -Subject: [PATCH] Add 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..889185bf73ef2d834e5d416d1cf13c2363453c42 ---- /dev/null -+++ b/src/main/java/com/destroystokyo/paper/event/inventory/PrepareGrindstoneEvent.java -@@ -0,0 +1,54 @@ -+package com.destroystokyo.paper.event.inventory; -+ -+import org.bukkit.event.HandlerList; -+import org.bukkit.event.inventory.InventoryEvent; -+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 -+ */ -+public class PrepareGrindstoneEvent extends InventoryEvent { -+ -+ private static final HandlerList handlers = new HandlerList(); -+ private ItemStack result; -+ -+ public PrepareGrindstoneEvent(@NotNull InventoryView inventory, @Nullable ItemStack result) { -+ super(inventory); -+ this.result = result; -+ } -+ -+ @NotNull -+ @Override -+ public GrindstoneInventory getInventory() { -+ return (GrindstoneInventory) super.getInventory(); -+ } -+ -+ /** -+ * Get result item, may be null. -+ * -+ * @return result item -+ */ -+ @Nullable -+ public ItemStack getResult() { -+ return result; -+ } -+ -+ public void setResult(@Nullable ItemStack result) { -+ this.result = result; -+ } -+ -+ @NotNull -+ @Override -+ public HandlerList getHandlers() { -+ return handlers; -+ } -+ -+ @NotNull -+ public static HandlerList getHandlerList() { -+ return handlers; -+ } -+} diff --git a/Spigot-API-Patches/0214-Support-components-in-ItemMeta.patch b/Spigot-API-Patches/0213-Support-components-in-ItemMeta.patch similarity index 100% rename from Spigot-API-Patches/0214-Support-components-in-ItemMeta.patch rename to Spigot-API-Patches/0213-Support-components-in-ItemMeta.patch diff --git a/Spigot-API-Patches/0215-added-2-new-TargetReasons-for-1.16-mob-behavior.patch b/Spigot-API-Patches/0214-added-2-new-TargetReasons-for-1.16-mob-behavior.patch similarity index 100% rename from Spigot-API-Patches/0215-added-2-new-TargetReasons-for-1.16-mob-behavior.patch rename to Spigot-API-Patches/0214-added-2-new-TargetReasons-for-1.16-mob-behavior.patch diff --git a/Spigot-API-Patches/0215-Add-PrepareResultEvent-PrepareGrindstoneEvent.patch b/Spigot-API-Patches/0215-Add-PrepareResultEvent-PrepareGrindstoneEvent.patch new file mode 100644 index 000000000..249759846 --- /dev/null +++ b/Spigot-API-Patches/0215-Add-PrepareResultEvent-PrepareGrindstoneEvent.patch @@ -0,0 +1,155 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: William Blake Galbreath +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 and Grindstone 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..449e8c06f8434b59d49a76481fa60c5c49e80579 +--- /dev/null ++++ b/src/main/java/com/destroystokyo/paper/event/inventory/PrepareGrindstoneEvent.java +@@ -0,0 +1,28 @@ ++package com.destroystokyo.paper.event.inventory; ++ ++import org.bukkit.event.HandlerList; ++import org.bukkit.event.inventory.InventoryEvent; ++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 ++ * @see com.destroystokyo.paper.event.inventory.PrepareResultEvent ++ */ ++@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..045ce9ec3c9134aced5f5235b760ac85599d16c6 +--- /dev/null ++++ b/src/main/java/com/destroystokyo/paper/event/inventory/PrepareResultEvent.java +@@ -0,0 +1,48 @@ ++package com.destroystokyo.paper.event.inventory; ++ ++import org.bukkit.event.HandlerList; ++import org.bukkit.event.inventory.InventoryEvent; ++import org.bukkit.event.inventory.InventoryType; ++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 InventoryEvent { ++ ++ private static final HandlerList handlers = new HandlerList(); ++ private ItemStack result; ++ ++ public PrepareResultEvent(@NotNull InventoryView inventory, @Nullable ItemStack result) { ++ super(inventory); ++ this.result = result; ++ } ++ ++ /** ++ * Get result item, may be null. ++ * ++ * @return result item ++ */ ++ @Nullable ++ public ItemStack getResult() { ++ return result; ++ } ++ ++ public void setResult(@Nullable ItemStack result) { ++ this.result = result; ++ } ++ ++ @NotNull ++ @Override ++ public HandlerList getHandlers() { ++ return handlers; ++ } ++ ++ @NotNull ++ public static HandlerList getHandlerList() { ++ return handlers; ++ } ++} +diff --git a/src/main/java/org/bukkit/event/inventory/PrepareAnvilEvent.java b/src/main/java/org/bukkit/event/inventory/PrepareAnvilEvent.java +index 77109a07f07aa6985106dc1a9ad5218f6c7f360f..f1f6f4ab4f81a3f21e757fef4a30b00e94371f8d 100644 +--- a/src/main/java/org/bukkit/event/inventory/PrepareAnvilEvent.java ++++ b/src/main/java/org/bukkit/event/inventory/PrepareAnvilEvent.java +@@ -1,5 +1,6 @@ + package org.bukkit.event.inventory; + ++import com.destroystokyo.paper.event.inventory.PrepareResultEvent; + import org.bukkit.event.HandlerList; + import org.bukkit.inventory.AnvilInventory; + import org.bukkit.inventory.InventoryView; +@@ -10,14 +11,16 @@ import org.jetbrains.annotations.Nullable; + /** + * Called when an item is put in a slot for repair by an anvil. + */ +-public class PrepareAnvilEvent extends InventoryEvent { ++// Paper start - extend PrepareResultEvent ++public class PrepareAnvilEvent extends PrepareResultEvent { + +- private static final HandlerList handlers = new HandlerList(); +- private ItemStack result; ++ //private static final HandlerList handlers = new HandlerList(); ++ //private ItemStack result; + + public PrepareAnvilEvent(@NotNull InventoryView inventory, @Nullable ItemStack result) { +- super(inventory); +- this.result = result; ++ super(inventory, result); ++ //this.result = result; ++ // Paper end + } + + @NotNull +@@ -33,13 +36,14 @@ public class PrepareAnvilEvent extends InventoryEvent { + */ + @Nullable + public ItemStack getResult() { +- return result; ++ return super.getResult(); // Paper + } + + public void setResult(@Nullable ItemStack result) { +- this.result = result; ++ super.setResult(result); // Paper + } + ++ /* // Paper - comment out + @NotNull + @Override + public HandlerList getHandlers() { +@@ -50,4 +54,5 @@ public class PrepareAnvilEvent extends InventoryEvent { + public static HandlerList getHandlerList() { + return handlers; + } ++ */ // Paper + } diff --git a/Spigot-Server-Patches/0517-Add-PrepareGrindstoneEvent.patch b/Spigot-Server-Patches/0517-Add-PrepareGrindstoneEvent.patch deleted file mode 100644 index a6c0e1687..000000000 --- a/Spigot-Server-Patches/0517-Add-PrepareGrindstoneEvent.patch +++ /dev/null @@ -1,33 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Jan Tuck -Date: Sat, 20 Jun 2020 22:34:20 +0200 -Subject: [PATCH] Add PrepareGrindstoneEvent - - -diff --git a/src/main/java/net/minecraft/server/ContainerGrindstone.java b/src/main/java/net/minecraft/server/ContainerGrindstone.java -index fe9a083b724a8657cac8462b3f44d3cc12a4db58..716304021f85a86a2f9492f5fb98e86bb7f089d2 100644 ---- a/src/main/java/net/minecraft/server/ContainerGrindstone.java -+++ b/src/main/java/net/minecraft/server/ContainerGrindstone.java -@@ -10,6 +10,10 @@ import org.bukkit.craftbukkit.inventory.CraftInventoryGrindstone; - import org.bukkit.craftbukkit.inventory.CraftInventoryView; - import org.bukkit.entity.Player; - // CraftBukkit end -+// Paper start -+import org.bukkit.craftbukkit.inventory.CraftItemStack; -+import com.destroystokyo.paper.event.inventory.PrepareGrindstoneEvent; -+// Paper end - - public class ContainerGrindstone extends Container { - -@@ -144,6 +148,11 @@ public class ContainerGrindstone extends Container { - super.a(iinventory); - if (iinventory == this.craftInventory) { - this.e(); -+ // Paper start -+ PrepareGrindstoneEvent event = new PrepareGrindstoneEvent(this.getBukkitView(), CraftItemStack.asBukkitCopy(this.resultInventory.getItem(0))); -+ event.callEvent(); -+ this.resultInventory.setItem(0, CraftItemStack.asNMSCopy(event.getResult())); -+ // Paper end - } - - } diff --git a/Spigot-Server-Patches/0518-Hide-sync-chunk-writes-behind-flag.patch b/Spigot-Server-Patches/0517-Hide-sync-chunk-writes-behind-flag.patch similarity index 100% rename from Spigot-Server-Patches/0518-Hide-sync-chunk-writes-behind-flag.patch rename to Spigot-Server-Patches/0517-Hide-sync-chunk-writes-behind-flag.patch diff --git a/Spigot-Server-Patches/0519-Limit-lightning-strike-effect-distance.patch b/Spigot-Server-Patches/0518-Limit-lightning-strike-effect-distance.patch similarity index 100% rename from Spigot-Server-Patches/0519-Limit-lightning-strike-effect-distance.patch rename to Spigot-Server-Patches/0518-Limit-lightning-strike-effect-distance.patch diff --git a/Spigot-Server-Patches/0520-Add-permission-for-command-blocks.patch b/Spigot-Server-Patches/0519-Add-permission-for-command-blocks.patch similarity index 100% rename from Spigot-Server-Patches/0520-Add-permission-for-command-blocks.patch rename to Spigot-Server-Patches/0519-Add-permission-for-command-blocks.patch diff --git a/Spigot-Server-Patches/0521-Ensure-Entity-AABB-s-are-never-invalid.patch b/Spigot-Server-Patches/0520-Ensure-Entity-AABB-s-are-never-invalid.patch similarity index 100% rename from Spigot-Server-Patches/0521-Ensure-Entity-AABB-s-are-never-invalid.patch rename to Spigot-Server-Patches/0520-Ensure-Entity-AABB-s-are-never-invalid.patch diff --git a/Spigot-Server-Patches/0522-Optimize-WorldBorder-collision-checks-and-air.patch b/Spigot-Server-Patches/0521-Optimize-WorldBorder-collision-checks-and-air.patch similarity index 100% rename from Spigot-Server-Patches/0522-Optimize-WorldBorder-collision-checks-and-air.patch rename to Spigot-Server-Patches/0521-Optimize-WorldBorder-collision-checks-and-air.patch diff --git a/Spigot-Server-Patches/0523-Fix-Per-World-Difficulty-Remembering-Difficulty.patch b/Spigot-Server-Patches/0522-Fix-Per-World-Difficulty-Remembering-Difficulty.patch similarity index 100% rename from Spigot-Server-Patches/0523-Fix-Per-World-Difficulty-Remembering-Difficulty.patch rename to Spigot-Server-Patches/0522-Fix-Per-World-Difficulty-Remembering-Difficulty.patch diff --git a/Spigot-Server-Patches/0524-Paper-dumpitem-command.patch b/Spigot-Server-Patches/0523-Paper-dumpitem-command.patch similarity index 100% rename from Spigot-Server-Patches/0524-Paper-dumpitem-command.patch rename to Spigot-Server-Patches/0523-Paper-dumpitem-command.patch diff --git a/Spigot-Server-Patches/0525-Don-t-allow-null-UUID-s-for-chat.patch b/Spigot-Server-Patches/0524-Don-t-allow-null-UUID-s-for-chat.patch similarity index 100% rename from Spigot-Server-Patches/0525-Don-t-allow-null-UUID-s-for-chat.patch rename to Spigot-Server-Patches/0524-Don-t-allow-null-UUID-s-for-chat.patch diff --git a/Spigot-Server-Patches/0526-Improve-Legacy-Component-serialization-size.patch b/Spigot-Server-Patches/0525-Improve-Legacy-Component-serialization-size.patch similarity index 100% rename from Spigot-Server-Patches/0526-Improve-Legacy-Component-serialization-size.patch rename to Spigot-Server-Patches/0525-Improve-Legacy-Component-serialization-size.patch diff --git a/Spigot-Server-Patches/0527-Support-old-UUID-format-for-NBT.patch b/Spigot-Server-Patches/0526-Support-old-UUID-format-for-NBT.patch similarity index 100% rename from Spigot-Server-Patches/0527-Support-old-UUID-format-for-NBT.patch rename to Spigot-Server-Patches/0526-Support-old-UUID-format-for-NBT.patch diff --git a/Spigot-Server-Patches/0528-Clean-up-duplicated-GameProfile-Properties.patch b/Spigot-Server-Patches/0527-Clean-up-duplicated-GameProfile-Properties.patch similarity index 100% rename from Spigot-Server-Patches/0528-Clean-up-duplicated-GameProfile-Properties.patch rename to Spigot-Server-Patches/0527-Clean-up-duplicated-GameProfile-Properties.patch diff --git a/Spigot-Server-Patches/0529-Convert-legacy-attributes-in-Item-Meta.patch b/Spigot-Server-Patches/0528-Convert-legacy-attributes-in-Item-Meta.patch similarity index 100% rename from Spigot-Server-Patches/0529-Convert-legacy-attributes-in-Item-Meta.patch rename to Spigot-Server-Patches/0528-Convert-legacy-attributes-in-Item-Meta.patch diff --git a/Spigot-Server-Patches/0530-Remove-some-streams-from-structures.patch b/Spigot-Server-Patches/0529-Remove-some-streams-from-structures.patch similarity index 100% rename from Spigot-Server-Patches/0530-Remove-some-streams-from-structures.patch rename to Spigot-Server-Patches/0529-Remove-some-streams-from-structures.patch diff --git a/Spigot-Server-Patches/0531-Remove-streams-from-classes-related-villager-gossip.patch b/Spigot-Server-Patches/0530-Remove-streams-from-classes-related-villager-gossip.patch similarity index 100% rename from Spigot-Server-Patches/0531-Remove-streams-from-classes-related-villager-gossip.patch rename to Spigot-Server-Patches/0530-Remove-streams-from-classes-related-villager-gossip.patch diff --git a/Spigot-Server-Patches/0532-Support-components-in-ItemMeta.patch b/Spigot-Server-Patches/0531-Support-components-in-ItemMeta.patch similarity index 100% rename from Spigot-Server-Patches/0532-Support-components-in-ItemMeta.patch rename to Spigot-Server-Patches/0531-Support-components-in-ItemMeta.patch diff --git a/Spigot-Server-Patches/0533-added-EntityTargetLivingEntityEvent-to-1.16-mobs.patch b/Spigot-Server-Patches/0532-added-EntityTargetLivingEntityEvent-to-1.16-mobs.patch similarity index 100% rename from Spigot-Server-Patches/0533-added-EntityTargetLivingEntityEvent-to-1.16-mobs.patch rename to Spigot-Server-Patches/0532-added-EntityTargetLivingEntityEvent-to-1.16-mobs.patch diff --git a/Spigot-Server-Patches/0534-Update-itemstack-legacy-name-and-lore.patch b/Spigot-Server-Patches/0533-Update-itemstack-legacy-name-and-lore.patch similarity index 100% rename from Spigot-Server-Patches/0534-Update-itemstack-legacy-name-and-lore.patch rename to Spigot-Server-Patches/0533-Update-itemstack-legacy-name-and-lore.patch diff --git a/Spigot-Server-Patches/0535-Spawn-player-in-correct-world-on-login.patch b/Spigot-Server-Patches/0534-Spawn-player-in-correct-world-on-login.patch similarity index 100% rename from Spigot-Server-Patches/0535-Spawn-player-in-correct-world-on-login.patch rename to Spigot-Server-Patches/0534-Spawn-player-in-correct-world-on-login.patch diff --git a/Spigot-Server-Patches/0535-Add-PrepareResultEvent.patch b/Spigot-Server-Patches/0535-Add-PrepareResultEvent.patch new file mode 100644 index 000000000..e2b19f1be --- /dev/null +++ b/Spigot-Server-Patches/0535-Add-PrepareResultEvent.patch @@ -0,0 +1,144 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: William Blake Galbreath +Date: Fri, 3 Jul 2020 11:58:56 -0500 +Subject: [PATCH] Add PrepareResultEvent + +Adds a new event for all crafting stations that generate a result slot item + +Anvil and Grindstone now extend this event + +diff --git a/src/main/java/net/minecraft/server/ContainerAnvil.java b/src/main/java/net/minecraft/server/ContainerAnvil.java +index 24631b2bcb2a1d057c1fb6596ff401133c8b548a..a2eee6ed8f166d1ff42dc913ea34e80032d90e3a 100644 +--- a/src/main/java/net/minecraft/server/ContainerAnvil.java ++++ b/src/main/java/net/minecraft/server/ContainerAnvil.java +@@ -294,6 +294,8 @@ public class ContainerAnvil extends ContainerAnvilAbstract { + } + + this.e(); ++ ++ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareResultEvent(getBukkitView(), this.resultInventory.getItem(0), 2); // Paper + } + + // CraftBukkit start +diff --git a/src/main/java/net/minecraft/server/ContainerAnvilAbstract.java b/src/main/java/net/minecraft/server/ContainerAnvilAbstract.java +index 2029d4dd9a2abe693c34723c379009578ab52503..71f588be3dfd840f2cd3d5a4f19cf8ff24d3837b 100644 +--- a/src/main/java/net/minecraft/server/ContainerAnvilAbstract.java ++++ b/src/main/java/net/minecraft/server/ContainerAnvilAbstract.java +@@ -67,6 +67,7 @@ public abstract class ContainerAnvilAbstract extends Container { + this.e(); + } + ++ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareResultEvent(getBukkitView(), this.resultInventory.getItem(0), 2); // Paper + } + + @Override +diff --git a/src/main/java/net/minecraft/server/ContainerCartography.java b/src/main/java/net/minecraft/server/ContainerCartography.java +index 91e1372952f07087f51b22f1c53f63d2cf2f40fc..1acc7f4eaede582f79f6e17c594d8553582c675d 100644 +--- a/src/main/java/net/minecraft/server/ContainerCartography.java ++++ b/src/main/java/net/minecraft/server/ContainerCartography.java +@@ -154,6 +154,7 @@ public class ContainerCartography extends Container { + this.a(itemstack, itemstack1, itemstack2); + } + ++ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareResultEvent(getBukkitView(), this.resultInventory.getItem(0), 2); // Paper + } + + private void a(ItemStack itemstack, ItemStack itemstack1, ItemStack itemstack2) { +diff --git a/src/main/java/net/minecraft/server/ContainerGrindstone.java b/src/main/java/net/minecraft/server/ContainerGrindstone.java +index fe9a083b724a8657cac8462b3f44d3cc12a4db58..cd7914ea4cc606b980aa22662beae2d4d8f3e0e9 100644 +--- a/src/main/java/net/minecraft/server/ContainerGrindstone.java ++++ b/src/main/java/net/minecraft/server/ContainerGrindstone.java +@@ -10,6 +10,10 @@ import org.bukkit.craftbukkit.inventory.CraftInventoryGrindstone; + import org.bukkit.craftbukkit.inventory.CraftInventoryView; + import org.bukkit.entity.Player; + // CraftBukkit end ++// Paper start ++import org.bukkit.craftbukkit.inventory.CraftItemStack; ++import com.destroystokyo.paper.event.inventory.PrepareGrindstoneEvent; ++// Paper end + + public class ContainerGrindstone extends Container { + +@@ -144,6 +148,9 @@ public class ContainerGrindstone extends Container { + super.a(iinventory); + if (iinventory == this.craftInventory) { + this.e(); ++ // Paper start ++ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareResultEvent(getBukkitView(), this.resultInventory.getItem(0), 2); // Paper ++ // Paper end + } + + } +diff --git a/src/main/java/net/minecraft/server/ContainerLoom.java b/src/main/java/net/minecraft/server/ContainerLoom.java +index 9490f74ee426e162844432073b3d78a2b6cddb32..e309f71e56933f0e7d2d9fc72a7681d4916eea3d 100644 +--- a/src/main/java/net/minecraft/server/ContainerLoom.java ++++ b/src/main/java/net/minecraft/server/ContainerLoom.java +@@ -175,6 +175,8 @@ public class ContainerLoom extends Container { + + this.j(); + this.c(); ++ ++ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareResultEvent(getBukkitView(), this.resultInventory.getItem(0), 3); // Paper + } + + @Override +diff --git a/src/main/java/net/minecraft/server/ContainerSmithing.java b/src/main/java/net/minecraft/server/ContainerSmithing.java +index 76a81b30fa9e53952202c61717231d68d7be8e71..5392d82b90abe0de907c238153f4c769e5d998fa 100644 +--- a/src/main/java/net/minecraft/server/ContainerSmithing.java ++++ b/src/main/java/net/minecraft/server/ContainerSmithing.java +@@ -65,6 +65,7 @@ public class ContainerSmithing extends ContainerAnvilAbstract { + this.resultInventory.setItem(0, itemstack); + } + ++ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareResultEvent(getBukkitView(), this.resultInventory.getItem(0), 2); // Paper + } + + @Override +diff --git a/src/main/java/net/minecraft/server/ContainerStonecutter.java b/src/main/java/net/minecraft/server/ContainerStonecutter.java +index 270bf7f3e6ca15891419f1ce3e88d9aff094bee6..ce63c715e4920ad272e7c3dffb8f3279118d0fae 100644 +--- a/src/main/java/net/minecraft/server/ContainerStonecutter.java ++++ b/src/main/java/net/minecraft/server/ContainerStonecutter.java +@@ -133,6 +133,7 @@ public class ContainerStonecutter extends Container { + this.a(iinventory, itemstack); + } + ++ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareResultEvent(getBukkitView(), this.resultInventory.getItem(0), 1); // Paper + } + + private void a(IInventory iinventory, ItemStack itemstack) { +diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +index 6c5036b23a41769167fd53b8cc5454e5e747598e..7a55bc4796317976e05eb53535eb420eed51e9c6 100644 +--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java ++++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +@@ -1548,12 +1548,30 @@ public class CraftEventFactory { + return event; + } + +- public static PrepareAnvilEvent callPrepareAnvilEvent(InventoryView view, ItemStack item) { ++ public static void callPrepareAnvilEvent(InventoryView view, ItemStack item) { // Paper - verify nothing uses return - handled below in PrepareResult ++ if (true) return; // Paper - nothing + PrepareAnvilEvent event = new PrepareAnvilEvent(view, CraftItemStack.asCraftMirror(item).clone()); + event.getView().getPlayer().getServer().getPluginManager().callEvent(event); + event.getInventory().setItem(2, event.getResult()); ++ //return event; // Paper ++ } ++ ++ // Paper start - support specific overrides for prepare result ++ public static com.destroystokyo.paper.event.inventory.PrepareResultEvent callPrepareResultEvent(InventoryView view, ItemStack item, int resultSlot) { ++ com.destroystokyo.paper.event.inventory.PrepareResultEvent event; ++ CraftItemStack result = CraftItemStack.asCraftMirror(item).clone(); ++ if (view.getTopInventory() instanceof org.bukkit.inventory.AnvilInventory) { ++ event = new PrepareAnvilEvent(view, result); ++ } else if (view.getTopInventory() instanceof org.bukkit.inventory.GrindstoneInventory) { ++ event = new com.destroystokyo.paper.event.inventory.PrepareGrindstoneEvent(view, result); ++ } else { ++ event = new com.destroystokyo.paper.event.inventory.PrepareResultEvent(view, result); ++ } ++ event.callEvent(); ++ event.getInventory().setItem(resultSlot, event.getResult()); + return event; + } ++ // Paper end + + /** + * Mob spawner event.