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
This commit is contained in:
Jake Potrebic 2022-12-13 21:03:57 -08:00
parent e849888abb
commit a4112a5c50
9 changed files with 114 additions and 116 deletions

View file

@ -17,8 +17,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@@ -0,0 +0,0 @@
+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;
@ -27,7 +25,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+
+/**
+ * Called when an item is put in a slot for grinding in a Grindstone
+ * @see com.destroystokyo.paper.event.inventory.PrepareResultEvent
+ * @deprecated use {@link org.bukkit.event.inventory.PrepareGrindstoneEvent}
+ */
+@Deprecated
+public class PrepareGrindstoneEvent extends PrepareResultEvent {
@ -51,9 +49,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@@ -0,0 +0,0 @@
+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.event.inventory.PrepareInventoryResultEvent;
+import org.bukkit.inventory.InventoryView;
+import org.bukkit.inventory.ItemStack;
+import org.jetbrains.annotations.NotNull;
@ -62,14 +58,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+/**
+ * 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 class PrepareResultEvent extends PrepareInventoryResultEvent {
+
+ // HandlerList on PrepareInventoryResultEvent to ensure api compat
+ public PrepareResultEvent(@NotNull InventoryView inventory, @Nullable ItemStack result) {
+ super(inventory);
+ this.result = result;
+ super(inventory, result);
+ }
+
+ /**
@ -79,133 +72,125 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ */
+ @Nullable
+ public ItemStack getResult() {
+ return result;
+ return super.getResult();
+ }
+
+ /**
+ * Set result item, may be null.
+ *
+ * @param result result item
+ */
+ public void setResult(@Nullable ItemStack result) {
+ this.result = result;
+ }
+
+ @NotNull
+ @Override
+ public HandlerList getHandlers() {
+ return handlers;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return handlers;
+ 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 @@
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;
@@ -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 InventoryEvent {
+// Paper start - extend PrepareResultEvent
+public class PrepareAnvilEvent extends PrepareResultEvent {
-public class PrepareAnvilEvent extends PrepareInventoryResultEvent {
+public class PrepareAnvilEvent extends com.destroystokyo.paper.event.inventory.PrepareResultEvent {
- private static final HandlerList handlers = new HandlerList();
- private ItemStack result;
+ //private static final HandlerList handlers = new HandlerList();
+ //private ItemStack result;
+ // Paper - move HandlerList to PrepareInventoryResultEvent
public PrepareAnvilEvent(@NotNull InventoryView inventory, @Nullable ItemStack result) {
- super(inventory);
- this.result = result;
+ super(inventory, result);
+ //this.result = result;
+ // Paper end
super(inventory, result);
@@ -0,0 +0,0 @@ public class PrepareAnvilEvent extends PrepareInventoryResultEvent {
return (AnvilInventory) super.getInventory();
}
@NotNull
@@ -0,0 +0,0 @@ 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() {
@@ -0,0 +0,0 @@ public class PrepareAnvilEvent extends InventoryEvent {
public static HandlerList getHandlerList() {
return handlers;
}
+ */ // Paper
- @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 @@
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 {
-public class PrepareSmithingEvent extends PrepareInventoryResultEvent {
+public class PrepareSmithingEvent extends com.destroystokyo.paper.event.inventory.PrepareResultEvent {
- private static final HandlerList handlers = new HandlerList();
- private ItemStack result;
+ //private static final HandlerList handlers = new HandlerList();
+ //private ItemStack result;
+ // Paper - move HandlerList ot PrepareInventoryResultEvent
public PrepareSmithingEvent(@NotNull InventoryView inventory, @Nullable ItemStack result) {
- super(inventory);
- this.result = result;
+ super(inventory, result);
+ //this.result = result;
+ // Paper end
super(inventory, result);
@@ -0,0 +0,0 @@ public class PrepareSmithingEvent extends PrepareInventoryResultEvent {
return (SmithingInventory) super.getInventory();
}
@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
- @NotNull
- @Override
- public HandlerList getHandlers() {
- return handlers;
- }
-
- @NotNull
- public static HandlerList getHandlerList() {
- return handlers;
- }
+ // Paper - move HandlerList to PrepareInventoryResultEvent
}

View file

@ -107,13 +107,26 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // 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.getView().getPlayer().getServer().getPluginManager().callEvent(event); // Paper - disable event
event.getInventory().setItem(2, event.getResult());
- return event;
+ //return event; // Paper
}
+ // Paper end
- public static PrepareGrindstoneEvent callPrepareGrindstoneEvent(InventoryView view, ItemStack item) {
- PrepareGrindstoneEvent event = new PrepareGrindstoneEvent(view, CraftItemStack.asCraftMirror(item).clone());
- event.getView().getPlayer().getServer().getPluginManager().callEvent(event);
+ // Paper start - disable this method, handled below
+ public static void callPrepareGrindstoneEvent(InventoryView view, ItemStack item) {
+ PrepareGrindstoneEvent event = new PrepareGrindstoneEvent(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
- public static PrepareSmithingEvent callPrepareSmithingEvent(InventoryView view, ItemStack item) {
- PrepareSmithingEvent event = new PrepareSmithingEvent(view, CraftItemStack.asCraftMirror(item).clone());
- event.getView().getPlayer().getServer().getPluginManager().callEvent(event);
@ -136,7 +149,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ 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);
+ event = new PrepareGrindstoneEvent(view, result);
+ } else if (view.getTopInventory() instanceof org.bukkit.inventory.SmithingInventory) {
+ event = new PrepareSmithingEvent(view, result);
+ } else {

View file

@ -78,7 +78,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ Date buildDate = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z").parse(Main.class.getPackage().getImplementationVendor()); // Paper
Calendar deadline = Calendar.getInstance();
deadline.add(Calendar.DAY_OF_YEAR, -3);
deadline.add(Calendar.DAY_OF_YEAR, -7);
diff --git a/src/main/java/org/bukkit/craftbukkit/util/Versioning.java b/src/main/java/org/bukkit/craftbukkit/util/Versioning.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/Versioning.java

View file

@ -20,7 +20,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
}
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
// SPIGOT-5607: Only call interact event if no block or entity is being clicked. Use bukkit ray trace method, because it handles blocks and entities at the same time
org.bukkit.util.RayTraceResult result = this.player.level.getWorld().rayTrace(origin, origin.getDirection(), d3, org.bukkit.FluidCollisionMode.NEVER, false, 0.1, entity -> entity != this.player.getBukkitEntity());
org.bukkit.util.RayTraceResult result = this.player.level.getWorld().rayTrace(origin, origin.getDirection(), d3, org.bukkit.FluidCollisionMode.NEVER, false, 0.1, entity -> entity != this.player.getBukkitEntity() && this.player.getBukkitEntity().canSee(entity));
- if (result == null) {
+ if (result == null || this.player.gameMode.getGameModeForPlayer() == GameType.ADVENTURE) { // Paper - call PlayerInteractEvent when left-clicking on a block in adventure mode

View file

@ -36,7 +36,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+++ b/src/main/java/org/bukkit/craftbukkit/Main.java
@@ -0,0 +0,0 @@ public class Main {
Calendar deadline = Calendar.getInstance();
deadline.add(Calendar.DAY_OF_YEAR, -3);
deadline.add(Calendar.DAY_OF_YEAR, -7);
if (buildDate.before(deadline.getTime())) {
- System.err.println("*** Error, this build is outdated ***");
+ // Paper start - This is some stupid bullshit

View file

@ -14,7 +14,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
if (!itemstack2.isDamageableItem()) {
- if (!ItemStack.matches(itemstack, itemstack1)) {
+ if (!ItemStack.matches(itemstack, itemstack1) || (itemstack2.getMaxStackSize() == 1 && !io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.allowGrindstoneOverstacking)) { // Paper - add max stack size check & config value
this.resultSlots.setItem(0, ItemStack.EMPTY);
org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareGrindstoneEvent(this.getBukkitView(), ItemStack.EMPTY); // CraftBukkit
this.broadcastChanges();
return;
}

View file

@ -36,7 +36,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/org/bukkit/craftbukkit/Main.java
+++ b/src/main/java/org/bukkit/craftbukkit/Main.java
@@ -0,0 +0,0 @@ public class Main {
deadline.add(Calendar.DAY_OF_YEAR, -3);
deadline.add(Calendar.DAY_OF_YEAR, -7);
if (buildDate.before(deadline.getTime())) {
System.err.println("*** Error, this build is outdated ***");
- System.err.println("*** Please download a new build as per instructions from https://www.spigotmc.org/go/outdated-spigot ***");

@ -1 +1 @@
Subproject commit dea9ce0a799f48e90e17e0f8c3db89bfb7cda3cd
Subproject commit f50ad1f8b307cda71968d3f53921ab29d1e5835a

@ -1 +1 @@
Subproject commit 4fa7e1c31d8f2b8dd3ec002563f11c4136f15491
Subproject commit ab1586c2fb5fa7a381e6191e1137acc69aeebbf2