mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-05 02:10:30 +01:00
fb2c24b36d
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: 05ae036c PR-746: Add option to use cached map color palette 57849c1b PR-759: Add preview chat option in ServerListPingEvent 0169e65d PR-758: Add missing server properties methods from 1.19 CraftBukkit Changes: 622dbe6c2 SPIGOT-7068: SKULK and SKULK_VEIN BlockSpreadEvents Still do not reference the correct source (SKULK_CATALYST) 6c61b73f3 PR-1052: Add option to use cached map color palette c882f38ea SPIGOT-7066: Fix custom END worlds not generating DragonBattle 6866aab59 SPIGOT-2420: Can't set exp drops for EnderDragon death 9dcd46530 PR-1067: Add preview chat option in ServerListPingEvent 36c2681af PR-1066: Add missing server properties methods from 1.19 031eaadd0 Increase outdated build delay 8fda4b12f SPIGOT-7060: SCULK and SCULK_VEIN BlockSpreadEvents do not reference the correct source
153 lines
8.7 KiB
Diff
153 lines
8.7 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
|
|
|
|
Adds a new event for all crafting stations that generate a result slot item
|
|
|
|
Anvil, Grindstone and Smithing now extend this event
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/inventory/AnvilMenu.java b/src/main/java/net/minecraft/world/inventory/AnvilMenu.java
|
|
index eb22059fe008c3d3fc0364a7f85f91b4cca8b328..506d758efbf16da9467f120321d2359a8832e477 100644
|
|
--- a/src/main/java/net/minecraft/world/inventory/AnvilMenu.java
|
|
+++ b/src/main/java/net/minecraft/world/inventory/AnvilMenu.java
|
|
@@ -316,6 +316,7 @@ public class AnvilMenu extends ItemCombinerMenu {
|
|
}
|
|
|
|
this.createResult();
|
|
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareResultEvent(this, RESULT_SLOT); // Paper
|
|
}
|
|
|
|
public int getCost() {
|
|
diff --git a/src/main/java/net/minecraft/world/inventory/CartographyTableMenu.java b/src/main/java/net/minecraft/world/inventory/CartographyTableMenu.java
|
|
index fc2b400c58ddbd7b012707c61d9a37363d351251..4f5593d387545545e30475d3edaa92a4306ba96b 100644
|
|
--- a/src/main/java/net/minecraft/world/inventory/CartographyTableMenu.java
|
|
+++ b/src/main/java/net/minecraft/world/inventory/CartographyTableMenu.java
|
|
@@ -150,6 +150,7 @@ public class CartographyTableMenu extends AbstractContainerMenu {
|
|
this.setupResultSlot(itemstack, itemstack1, itemstack2);
|
|
}
|
|
|
|
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareResultEvent(this, RESULT_SLOT); // Paper
|
|
}
|
|
|
|
private void setupResultSlot(ItemStack map, ItemStack item, ItemStack oldResult) {
|
|
diff --git a/src/main/java/net/minecraft/world/inventory/GrindstoneMenu.java b/src/main/java/net/minecraft/world/inventory/GrindstoneMenu.java
|
|
index aa0ba9c7dcb0ee81c9081031c447eeab61d92a10..7a0c38c743ef02f5b9c052f88c2d6429a53b8286 100644
|
|
--- a/src/main/java/net/minecraft/world/inventory/GrindstoneMenu.java
|
|
+++ b/src/main/java/net/minecraft/world/inventory/GrindstoneMenu.java
|
|
@@ -159,6 +159,7 @@ public class GrindstoneMenu extends AbstractContainerMenu {
|
|
super.slotsChanged(inventory);
|
|
if (inventory == this.repairSlots) {
|
|
this.createResult();
|
|
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareResultEvent(this, RESULT_SLOT); // Paper
|
|
}
|
|
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/world/inventory/ItemCombinerMenu.java b/src/main/java/net/minecraft/world/inventory/ItemCombinerMenu.java
|
|
index f5e52220abc5c678c090b32d83eb9644fa91ce9d..35575434f3c90f1bd23df6584ee8a5a991f93f9f 100644
|
|
--- a/src/main/java/net/minecraft/world/inventory/ItemCombinerMenu.java
|
|
+++ b/src/main/java/net/minecraft/world/inventory/ItemCombinerMenu.java
|
|
@@ -78,6 +78,7 @@ public abstract class ItemCombinerMenu extends AbstractContainerMenu {
|
|
super.slotsChanged(inventory);
|
|
if (inventory == this.inputSlots) {
|
|
this.createResult();
|
|
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareResultEvent(this, RESULT_SLOT); // Paper
|
|
}
|
|
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/world/inventory/LoomMenu.java b/src/main/java/net/minecraft/world/inventory/LoomMenu.java
|
|
index 3b3e7a89ce1fc719d241c7a3dc8c746191d91f85..9cbdcb87d76fa36887413754ef625a16624aadd7 100644
|
|
--- a/src/main/java/net/minecraft/world/inventory/LoomMenu.java
|
|
+++ b/src/main/java/net/minecraft/world/inventory/LoomMenu.java
|
|
@@ -243,7 +243,8 @@ public class LoomMenu extends AbstractContainerMenu {
|
|
this.resultSlot.set(ItemStack.EMPTY);
|
|
}
|
|
|
|
- this.broadcastChanges();
|
|
+ // this.broadcastChanges(); // Paper - done below
|
|
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareResultEvent(this, 3); // Paper
|
|
} else {
|
|
this.resultSlot.set(ItemStack.EMPTY);
|
|
this.selectablePatterns = List.of();
|
|
diff --git a/src/main/java/net/minecraft/world/inventory/SmithingMenu.java b/src/main/java/net/minecraft/world/inventory/SmithingMenu.java
|
|
index 92dd2ea23185bba311e184b2ac9744a423c102ea..71bb09e3d31f098503d0e1bdf073b60f07d76ed0 100644
|
|
--- a/src/main/java/net/minecraft/world/inventory/SmithingMenu.java
|
|
+++ b/src/main/java/net/minecraft/world/inventory/SmithingMenu.java
|
|
@@ -76,6 +76,7 @@ public class SmithingMenu extends ItemCombinerMenu {
|
|
// CraftBukkit end
|
|
}
|
|
|
|
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareResultEvent(this, RESULT_SLOT); // Paper
|
|
}
|
|
|
|
@Override
|
|
diff --git a/src/main/java/net/minecraft/world/inventory/StonecutterMenu.java b/src/main/java/net/minecraft/world/inventory/StonecutterMenu.java
|
|
index cdebd0cdf6eb901464cf4c16089b10ea0147b54d..b47dc7671fab2117b989d647d7e8e36d12af5f76 100644
|
|
--- a/src/main/java/net/minecraft/world/inventory/StonecutterMenu.java
|
|
+++ b/src/main/java/net/minecraft/world/inventory/StonecutterMenu.java
|
|
@@ -176,6 +176,7 @@ public class StonecutterMenu extends AbstractContainerMenu {
|
|
this.setupRecipeList(inventory, itemstack);
|
|
}
|
|
|
|
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareResultEvent(this, RESULT_SLOT); // Paper
|
|
}
|
|
|
|
private void setupRecipeList(Container input, ItemStack stack) {
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
index 9b94df9940040f51fdcc1af5c7da96117af9017e..c2eefe215f47e36cc2b8476750ae00ec88f826a6 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
@@ -1594,19 +1594,44 @@ public class CraftEventFactory {
|
|
return event;
|
|
}
|
|
|
|
- public static PrepareAnvilEvent callPrepareAnvilEvent(InventoryView view, ItemStack item) {
|
|
- PrepareAnvilEvent event = new PrepareAnvilEvent(view, CraftItemStack.asCraftMirror(item).clone());
|
|
- event.getView().getPlayer().getServer().getPluginManager().callEvent(event);
|
|
+ // Paper start - disable this method, handled below
|
|
+ public static void callPrepareAnvilEvent(InventoryView view, ItemStack item) { // Paper - verify nothing uses return - handled below in PrepareResult
|
|
+ PrepareAnvilEvent event = new PrepareAnvilEvent(view, CraftItemStack.asCraftMirror(item)); // Paper - remove clone
|
|
+ //event.getView().getPlayer().getServer().getPluginManager().callEvent(event); // disable event
|
|
event.getInventory().setItem(2, event.getResult());
|
|
- return event;
|
|
+ //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(AbstractContainerMenu container, int resultSlot) {
|
|
+ com.destroystokyo.paper.event.inventory.PrepareResultEvent event;
|
|
+ InventoryView view = container.getBukkitView();
|
|
+ org.bukkit.inventory.ItemStack origItem = view.getTopInventory().getItem(resultSlot);
|
|
+ CraftItemStack result = origItem != null ? CraftItemStack.asCraftCopy(origItem) : null;
|
|
+ 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 if (view.getTopInventory() instanceof org.bukkit.inventory.SmithingInventory) {
|
|
+ event = new PrepareSmithingEvent(view, result);
|
|
+ } else {
|
|
+ event = new com.destroystokyo.paper.event.inventory.PrepareResultEvent(view, result);
|
|
+ }
|
|
+ event.callEvent();
|
|
+ event.getInventory().setItem(resultSlot, event.getResult());
|
|
+ container.broadcastChanges();;
|
|
+ }
|
|
+ // Paper end
|
|
|
|
/**
|
|
* Mob spawner event.
|