From 7673fda496e923910ff785dd9b3528172b1ac853 Mon Sep 17 00:00:00 2001 From: Prof-Bloodstone <46570876+Prof-Bloodstone@users.noreply.github.com> Date: Thu, 23 Jul 2020 01:35:44 +0200 Subject: [PATCH] Updated Upstream (Bukkit/CraftBukkit) (#3980) Upstream has released updates that appears 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: 09f10fd9 SPIGOT-5950: Add PrepareSmithingEvent event CraftBukkit Changes: 7c03d257 SPIGOT-6011: End Gateways do not work on Non-Main End Worlds d492e363 SPIGOT-6015: Small Armor Stand doesn't drop items 5db13eea SPIGOT-5950: Add PrepareSmithingEvent event --- ...reResultEvent-PrepareGrindstoneEvent.patch | 58 ++++++++++++++++++- .../Add-PrepareResultEvent.patch | 19 +++++- .../Improve-death-events.patch | 20 ++----- work/Bukkit | 2 +- work/CraftBukkit | 2 +- 5 files changed, 81 insertions(+), 20 deletions(-) diff --git a/Spigot-API-Patches/Add-PrepareResultEvent-PrepareGrindstoneEvent.patch b/Spigot-API-Patches/Add-PrepareResultEvent-PrepareGrindstoneEvent.patch index 7b1433d810..9395f0c46d 100644 --- a/Spigot-API-Patches/Add-PrepareResultEvent-PrepareGrindstoneEvent.patch +++ b/Spigot-API-Patches/Add-PrepareResultEvent-PrepareGrindstoneEvent.patch @@ -5,7 +5,7 @@ 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 +Anvil, Grindstone and Smithing now extend this event Grindstone is a backwards compat from a previous PrepareGrindstoneEvent @@ -153,3 +153,59 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } + */ // Paper } +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 @@ + package org.bukkit.event.inventory; + ++import com.destroystokyo.paper.event.inventory.PrepareResultEvent; + import org.bukkit.event.HandlerList; + import org.bukkit.inventory.InventoryView; + import org.bukkit.inventory.ItemStack; +@@ -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 InventoryEvent { ++// Paper start - extend PrepareResultEvent ++public class PrepareSmithingEvent extends PrepareResultEvent { + +- private static final HandlerList handlers = new HandlerList(); +- private ItemStack result; ++ //private static final HandlerList handlers = new HandlerList(); ++ //private ItemStack result; + + public PrepareSmithingEvent(@NotNull InventoryView inventory, @Nullable ItemStack result) { +- super(inventory); +- this.result = result; ++ super(inventory, result); ++ //this.result = result; ++ // Paper end + } + + @NotNull +@@ -0,0 +0,0 @@ public class PrepareSmithingEvent 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() { +@@ -0,0 +0,0 @@ public class PrepareSmithingEvent extends InventoryEvent { + public static HandlerList getHandlerList() { + return handlers; + } ++ */ // Paper + } diff --git a/Spigot-Server-Patches/Add-PrepareResultEvent.patch b/Spigot-Server-Patches/Add-PrepareResultEvent.patch index 1d8b8385ae..72274781ac 100644 --- a/Spigot-Server-Patches/Add-PrepareResultEvent.patch +++ b/Spigot-Server-Patches/Add-PrepareResultEvent.patch @@ -5,7 +5,7 @@ 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 +Anvil, Grindstone and Smithing now extend this event diff --git a/src/main/java/net/minecraft/server/Container.java b/src/main/java/net/minecraft/server/Container.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 @@ -86,7 +86,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/ContainerSmithing.java +++ b/src/main/java/net/minecraft/server/ContainerSmithing.java @@ -0,0 +0,0 @@ public class ContainerSmithing extends ContainerAnvilAbstract { - this.resultInventory.setItem(0, itemstack); + org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareSmithingEvent(getBukkitView(), itemstack); // CraftBukkit } + org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareResultEvent(this, 2); // Paper @@ -125,6 +125,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + //return event; // Paper } + // Paper end + +- public static PrepareSmithingEvent callPrepareSmithingEvent(InventoryView view, ItemStack item) { +- PrepareSmithingEvent event = new PrepareSmithingEvent(view, CraftItemStack.asCraftMirror(item).clone()); +- event.getView().getPlayer().getServer().getPluginManager().callEvent(event); ++ // Paper start - disable this method, handled in callPrepareResultEvent ++ public static void callPrepareSmithingEvent(InventoryView view, ItemStack item) { // Paper - verify nothing uses return - handled below in PrepareResult ++ PrepareSmithingEvent event = new PrepareSmithingEvent(view, CraftItemStack.asCraftMirror(item)); // Paper - remove clone ++ //event.getView().getPlayer().getServer().getPluginManager().callEvent(event); // Paper - disable event + event.getInventory().setItem(2, event.getResult()); +- return event; ++ //return event; // Paper + } ++ // Paper end + + // Paper start - support specific overrides for prepare result + public static void callPrepareResultEvent(net.minecraft.server.Container container, int resultSlot) { @@ -136,6 +149,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + 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 if (view.getTopInventory() instanceof org.bukkit.inventory.SmithingInventory) { ++ event = new PrepareSmithingEvent(view, result); + } else { + event = new com.destroystokyo.paper.event.inventory.PrepareResultEvent(view, result); + } diff --git a/Spigot-Server-Patches/Improve-death-events.patch b/Spigot-Server-Patches/Improve-death-events.patch index bf963279f6..69868f867c 100644 --- a/Spigot-Server-Patches/Improve-death-events.patch +++ b/Spigot-Server-Patches/Improve-death-events.patch @@ -228,24 +228,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 int i; @@ -0,0 +0,0 @@ public abstract class EntityLiving extends Entity { - boolean flag = this.lastDamageByPlayerTime > 0; - - this.dropInventory(); // CraftBukkit - from below -+ org.bukkit.event.entity.EntityDeathEvent deathEvent; // Paper - if (this.cV() && this.world.getGameRules().getBoolean(GameRules.DO_MOB_LOOT)) { - this.a(damagesource, flag); this.dropDeathLoot(damagesource, i, flag); - // CraftBukkit start - Call death event -- CraftEventFactory.callEntityDeathEvent(this, this.drops); -- this.drops = new ArrayList(); -+ deathEvent = CraftEventFactory.callEntityDeathEvent(this, this.drops); // Paper - } else { -- CraftEventFactory.callEntityDeathEvent(this); -+ deathEvent = CraftEventFactory.callEntityDeathEvent(this); // Paper - // CraftBukkit end } + // CraftBukkit start - Call death event +- CraftEventFactory.callEntityDeathEvent(this, this.drops); ++ org.bukkit.event.entity.EntityDeathEvent deathEvent = CraftEventFactory.callEntityDeathEvent(this, this.drops); // Paper + this.postDeathDropItems(deathEvent); // Paper -+ this.drops = new ArrayList<>(); // Paper + this.drops = new ArrayList<>(); + // CraftBukkit end // this.dropInventory();// CraftBukkit - moved up this.dropExperience(); diff --git a/work/Bukkit b/work/Bukkit index f1e73b038b..09f10fd900 160000 --- a/work/Bukkit +++ b/work/Bukkit @@ -1 +1 @@ -Subproject commit f1e73b038b29211b199ff9b13bca576daeb660b2 +Subproject commit 09f10fd90008c556aafbfaaa256fd7199db45056 diff --git a/work/CraftBukkit b/work/CraftBukkit index 8b831a9652..7c03d257dd 160000 --- a/work/CraftBukkit +++ b/work/CraftBukkit @@ -1 +1 @@ -Subproject commit 8b831a965200a2ba7d1c01d720e265565ae9f4d4 +Subproject commit 7c03d257dda5e6d029d4a14a3d1e811801938efb