Updated Upstream (Bukkit/CraftBukkit)

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:
0c5d8709 SPIGOT-7400: Downgrade maven-resolver due to issues resolving certain depends
255c4fdb SPIGOT-7380: Add PlayerInteractEvent#getClickedPosition and ChiseledBookshelf#getSlot

CraftBukkit Changes:
b6b514b7e SPIGOT-7400: Downgrade maven-resolver due to issues resolving certain depends
fcff84de9 SPIGOT-7399: Revert null check in CraftMetaItem#safelyAdd
44a4b5649 SPIGOT-7380: Add PlayerInteractEvent#getClickedPosition and ChiseledBookshelf#getSlot
676969d01 SPIGOT-7389: Handle setting null items in ChiseledBookshelf Inventory
This commit is contained in:
Nassim Jahnke 2023-06-18 13:03:18 +02:00
parent fb0fd871fe
commit fb00916689
16 changed files with 55 additions and 132 deletions

View file

@ -16,38 +16,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
@@ -0,0 +0,0 @@ public class PlayerInteractEvent extends PlayerEvent implements Cancellable {
private Result useClickedBlock;
private Result useItemInHand;
private EquipmentSlot hand;
+ private Location interactionPoint; // Paper
public PlayerInteractEvent(@NotNull final Player who, @NotNull final Action action, @Nullable final ItemStack item, @Nullable final Block clickedBlock, @NotNull final BlockFace clickedFace) {
this(who, action, item, clickedBlock, clickedFace, EquipmentSlot.HAND);
}
public PlayerInteractEvent(@NotNull final Player who, @NotNull final Action action, @Nullable final ItemStack item, @Nullable final Block clickedBlock, @NotNull final BlockFace clickedFace, @Nullable final EquipmentSlot hand) {
+ // Paper start - Add interactionPoint
+ this(who, action, item, clickedBlock, clickedFace, hand, null);
+ }
+
+ public PlayerInteractEvent(@NotNull final Player who, @NotNull final Action action, @Nullable final ItemStack item, @Nullable final Block clickedBlock, @NotNull final BlockFace clickedFace, @Nullable final EquipmentSlot hand, @Nullable final Location interactionPoint) {
super(who);
this.action = action;
this.item = item;
this.blockClicked = clickedBlock;
this.blockFace = clickedFace;
this.hand = hand;
+ this.interactionPoint = interactionPoint;
useItemInHand = Result.DEFAULT;
useClickedBlock = clickedBlock == null ? Result.DENY : Result.ALLOW;
}
+ // Paper end
/**
* Returns the action type
@@ -0,0 +0,0 @@ public class PlayerInteractEvent extends PlayerEvent implements Cancellable {
return hand;
* <p>
* All vector components are between 0.0 and 1.0 inclusive.
*
+ * @deprecated misleading, use {@link #getInteractionPoint()}
* @return the clicked position. May be null.
*/
@Nullable
+ @Deprecated // Paper
public Vector getClickedPosition() {
return clickedPosistion;
}
+ // Paper start
@ -58,7 +36,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ */
+ @Nullable
+ public Location getInteractionPoint() {
+ return interactionPoint;
+ if (this.blockClicked == null || this.clickedPosistion == null) {
+ return null;
+ }
+ return this.blockClicked.getLocation().add(this.clickedPosistion);
+ }
+ // Paper end
+

View file

@ -16,4 +16,4 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ api("it.unimi.dsi:fastutil:8.5.6")
// Paper end
compileOnly("org.apache.maven:maven-resolver-provider:3.9.2")
compileOnly("org.apache.maven:maven-resolver-provider:3.8.5")

View file

@ -51,7 +51,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ apiAndDocs("net.kyori:adventure-text-logger-slf4j")
// Paper end
compileOnly("org.apache.maven:maven-resolver-provider:3.9.2")
compileOnly("org.apache.maven:maven-resolver-provider:3.8.5")
@@ -0,0 +0,0 @@ tasks.withType<Javadoc> {
"https://guava.dev/releases/31.1-jre/api/docs/",
"https://javadoc.io/doc/org.yaml/snakeyaml/2.0/",

View file

@ -18,9 +18,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ }
+ // Paper end
compileOnly("org.apache.maven:maven-resolver-provider:3.9.2")
compileOnly("org.apache.maven.resolver:maven-resolver-connector-basic:1.9.10")
compileOnly("org.apache.maven.resolver:maven-resolver-transport-http:1.9.10")
compileOnly("org.apache.maven:maven-resolver-provider:3.8.5")
compileOnly("org.apache.maven.resolver:maven-resolver-connector-basic:1.7.3")
compileOnly("org.apache.maven.resolver:maven-resolver-transport-http:1.7.3")
+ compileOnly("com.google.code.findbugs:jsr305:1.3.9") // Paper
- val annotations = "org.jetbrains:annotations-java5:$annotationsVersion"

View file

@ -51,9 +51,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ api("org.yaml:snakeyaml:2.0")
+ api("org.joml:joml:1.10.5")
+
+ compileOnly("org.apache.maven:maven-resolver-provider:3.9.2")
+ compileOnly("org.apache.maven.resolver:maven-resolver-connector-basic:1.9.10")
+ compileOnly("org.apache.maven.resolver:maven-resolver-transport-http:1.9.10")
+ compileOnly("org.apache.maven:maven-resolver-provider:3.8.5")
+ compileOnly("org.apache.maven.resolver:maven-resolver-connector-basic:1.7.3")
+ compileOnly("org.apache.maven.resolver:maven-resolver-transport-http:1.7.3")
+
+ val annotations = "org.jetbrains:annotations-java5:$annotationsVersion"
+ compileOnly(annotations)
@ -193,19 +193,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-resolver-provider</artifactId>
- <version>3.9.2</version>
- <version>3.8.5</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.maven.resolver</groupId>
- <artifactId>maven-resolver-connector-basic</artifactId>
- <version>1.9.10</version>
- <version>1.7.3</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.maven.resolver</groupId>
- <artifactId>maven-resolver-transport-http</artifactId>
- <version>1.9.10</version>
- <version>1.7.3</version>
- <scope>provided</scope>
- </dependency>
- <!-- annotations -->

View file

@ -12,10 +12,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
implementation("org.ow2.asm:asm-commons:9.4")
// Paper end
- compileOnly("org.apache.maven:maven-resolver-provider:3.9.2")
+ api("org.apache.maven:maven-resolver-provider:3.9.2")
compileOnly("org.apache.maven.resolver:maven-resolver-connector-basic:1.9.10")
compileOnly("org.apache.maven.resolver:maven-resolver-transport-http:1.9.10")
- compileOnly("org.apache.maven:maven-resolver-provider:3.8.5")
+ api("org.apache.maven:maven-resolver-provider:3.8.5")
compileOnly("org.apache.maven.resolver:maven-resolver-connector-basic:1.7.3")
compileOnly("org.apache.maven.resolver:maven-resolver-transport-http:1.7.3")
compileOnly("com.google.code.findbugs:jsr305:1.3.9") // Paper
diff --git a/src/main/java/io/papermc/paper/plugin/PermissionManager.java b/src/main/java/io/papermc/paper/plugin/PermissionManager.java
new file mode 100644

View file

@ -18,7 +18,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ implementation("org.ow2.asm:asm-commons:9.4")
// Paper end
compileOnly("org.apache.maven:maven-resolver-provider:3.9.2")
compileOnly("org.apache.maven:maven-resolver-provider:3.8.5")
diff --git a/src/main/java/com/destroystokyo/paper/event/executor/MethodHandleEventExecutor.java b/src/main/java/com/destroystokyo/paper/event/executor/MethodHandleEventExecutor.java
new file mode 100644
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000

View file

@ -24,7 +24,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ cancelledItem = true; // Paper - correctly handle items on cooldown
}
- PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(player, Action.RIGHT_CLICK_BLOCK, blockposition, hitResult.getDirection(), stack, cancelledBlock, hand, hitResult.getLocation()); // Paper
- PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(player, Action.RIGHT_CLICK_BLOCK, blockposition, hitResult.getDirection(), stack, cancelledBlock, hand, hitResult.getLocation());
+ PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(player, Action.RIGHT_CLICK_BLOCK, blockposition, hitResult.getDirection(), stack, cancelledBlock, cancelledItem, hand, hitResult.getLocation()); // Paper
this.firedInteract = true;
this.interactResult = event.useItemInHand() == Event.Result.DENY;
@ -34,18 +34,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
@@ -0,0 +0,0 @@ public class CraftEventFactory {
return CraftEventFactory.callPlayerInteractEvent(who, action, position, direction, itemstack, false, hand, null);
}
public static PlayerInteractEvent callPlayerInteractEvent(net.minecraft.world.entity.player.Player who, Action action, BlockPos position, Direction direction, ItemStack itemstack, boolean cancelledBlock, InteractionHand hand, Vec3 hitVec) {
+ // Paper start - correctly handle items on cooldown
+ return callPlayerInteractEvent(who, action, position, direction, itemstack, cancelledBlock, false, hand, hitVec);
+ }
+
+ public static PlayerInteractEvent callPlayerInteractEvent(net.minecraft.world.entity.player.Player who, Action action, BlockPos position, Direction direction, ItemStack itemstack, boolean cancelledBlock, boolean cancelledItem, InteractionHand hand, Vec3 hitVec) {
+ // Paper end - correctly handle items on cooldown
// Paper end
+ // Paper start - cancelledItem param
public static PlayerInteractEvent callPlayerInteractEvent(net.minecraft.world.entity.player.Player who, Action action, BlockPos position, Direction direction, ItemStack itemstack, boolean cancelledBlock, InteractionHand hand, Vec3 targetPos) {
+ return CraftEventFactory.callPlayerInteractEvent(who, action, position, direction, itemstack, false, false, hand, null);
+ }
+ public static PlayerInteractEvent callPlayerInteractEvent(net.minecraft.world.entity.player.Player who, Action action, BlockPos position, Direction direction, ItemStack itemstack, boolean cancelledBlock, boolean cancelledItem, InteractionHand hand, Vec3 targetPos) {
+ // Paper end - cancelledItem param
Player player = (who == null) ? null : (Player) who.getBukkitEntity();
CraftItemStack itemInHand = CraftItemStack.asCraftMirror(itemstack);
@@ -0,0 +0,0 @@ public class CraftEventFactory {
if (cancelledBlock) {
event.setUseInteractedBlock(Event.Result.DENY);

View file

@ -1,59 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Madeline Miller <mnmiller1@me.com>
Date: Mon, 4 Jan 2021 16:40:27 +1000
Subject: [PATCH] Implement API to expose exact interaction point
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
@@ -0,0 +0,0 @@ public class ServerPlayerGameMode {
cancelledBlock = true;
}
- PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(player, Action.RIGHT_CLICK_BLOCK, blockposition, hitResult.getDirection(), stack, cancelledBlock, hand);
+ PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(player, Action.RIGHT_CLICK_BLOCK, blockposition, hitResult.getDirection(), stack, cancelledBlock, hand, hitResult.getLocation()); // Paper
this.firedInteract = true;
this.interactResult = event.useItemInHand() == Event.Result.DENY;
this.interactPosition = blockposition.immutable();
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
@@ -0,0 +0,0 @@ import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.EntityHitResult;
import net.minecraft.world.phys.HitResult;
+import net.minecraft.world.phys.Vec3;
import org.bukkit.Bukkit;
+import org.bukkit.Location; // Paper
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.Server;
@@ -0,0 +0,0 @@ public class CraftEventFactory {
return CraftEventFactory.callPlayerInteractEvent(who, action, position, direction, itemstack, false, hand);
}
+ // Paper start - Add interactionPoint
public static PlayerInteractEvent callPlayerInteractEvent(net.minecraft.world.entity.player.Player who, Action action, BlockPos position, Direction direction, ItemStack itemstack, boolean cancelledBlock, InteractionHand hand) {
+ return callPlayerInteractEvent(who, action, position, direction, itemstack, cancelledBlock, hand, null);
+ }
+
+ public static PlayerInteractEvent callPlayerInteractEvent(net.minecraft.world.entity.player.Player who, Action action, BlockPos position, Direction direction, ItemStack itemstack, boolean cancelledBlock, InteractionHand hand, Vec3 hitVec) {
+ // Paper end
Player player = (who == null) ? null : (Player) who.getBukkitEntity();
CraftItemStack itemInHand = CraftItemStack.asCraftMirror(itemstack);
@@ -0,0 +0,0 @@ public class CraftEventFactory {
itemInHand = null;
}
- PlayerInteractEvent event = new PlayerInteractEvent(player, action, itemInHand, blockClicked, blockFace, (hand == null) ? null : ((hand == InteractionHand.OFF_HAND) ? EquipmentSlot.OFF_HAND : EquipmentSlot.HAND));
+ // Paper start
+ Location interactionPoint = hitVec == null ? null : new Location(craftWorld, hitVec.x, hitVec.y, hitVec.z);
+ PlayerInteractEvent event = new PlayerInteractEvent(player, action, itemInHand, blockClicked, blockFace, (hand == null) ? null : ((hand == InteractionHand.OFF_HAND) ? EquipmentSlot.OFF_HAND : EquipmentSlot.HAND), interactionPoint);
+ // Paper end
if (cancelledBlock) {
event.setUseInteractedBlock(Event.Result.DENY);
}

View file

@ -9,8 +9,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -0,0 +0,0 @@ dependencies {
runtimeOnly("org.apache.maven.resolver:maven-resolver-connector-basic:1.9.10")
runtimeOnly("org.apache.maven.resolver:maven-resolver-transport-http:1.9.10")
runtimeOnly("org.apache.maven.resolver:maven-resolver-connector-basic:1.7.3")
runtimeOnly("org.apache.maven.resolver:maven-resolver-transport-http:1.7.3")
+ testImplementation("io.github.classgraph:classgraph:4.8.47") // Paper - mob goal test
testImplementation("junit:junit:4.13.2")

View file

@ -51,9 +51,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ runtimeOnly("org.xerial:sqlite-jdbc:3.42.0.0")
+ runtimeOnly("com.mysql:mysql-connector-j:8.0.33")
+
+ runtimeOnly("org.apache.maven:maven-resolver-provider:3.9.2")
+ runtimeOnly("org.apache.maven.resolver:maven-resolver-connector-basic:1.9.10")
+ runtimeOnly("org.apache.maven.resolver:maven-resolver-transport-http:1.9.10")
+ runtimeOnly("org.apache.maven:maven-resolver-provider:3.8.5")
+ runtimeOnly("org.apache.maven.resolver:maven-resolver-connector-basic:1.7.3")
+ runtimeOnly("org.apache.maven.resolver:maven-resolver-transport-http:1.7.3")
+
+ testImplementation("junit:junit:4.13.2")
+ testImplementation("org.hamcrest:hamcrest-library:1.3")
@ -419,19 +419,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-resolver-provider</artifactId>
- <version>3.9.2</version>
- <version>3.8.5</version>
- <scope>runtime</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.maven.resolver</groupId>
- <artifactId>maven-resolver-connector-basic</artifactId>
- <version>1.9.10</version>
- <version>1.7.3</version>
- <scope>runtime</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.maven.resolver</groupId>
- <artifactId>maven-resolver-transport-http</artifactId>
- <version>1.9.10</version>
- <version>1.7.3</version>
- <scope>runtime</scope>
- </dependency>
- <!-- annotations -->

View file

@ -79,5 +79,5 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } else
+ // Paper end
if (!(object instanceof String)) {
Preconditions.checkArgument(object == null, "%s cannot contain non-string %s", addFrom, object.getClass().getName());
if (object != null) {
// SPIGOT-7399: Null check via if is important,

View file

@ -14,8 +14,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
runtimeOnly("com.mysql:mysql-connector-j:8.0.33")
+ runtimeOnly("com.lmax:disruptor:3.4.4") // Paper
runtimeOnly("org.apache.maven:maven-resolver-provider:3.9.2")
runtimeOnly("org.apache.maven.resolver:maven-resolver-connector-basic:1.9.10")
runtimeOnly("org.apache.maven:maven-resolver-provider:3.8.5")
runtimeOnly("org.apache.maven.resolver:maven-resolver-connector-basic:1.7.3")
diff --git a/src/main/resources/log4j2.xml b/src/main/resources/log4j2.xml
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/resources/log4j2.xml

View file

@ -18,8 +18,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ }
+ // Paper end
runtimeOnly("org.apache.maven:maven-resolver-provider:3.9.2")
runtimeOnly("org.apache.maven.resolver:maven-resolver-connector-basic:1.9.10")
runtimeOnly("org.apache.maven:maven-resolver-provider:3.8.5")
runtimeOnly("org.apache.maven.resolver:maven-resolver-connector-basic:1.7.3")
diff --git a/src/main/java/net/minecraft/network/CipherDecoder.java b/src/main/java/net/minecraft/network/CipherDecoder.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/network/CipherDecoder.java

@ -1 +1 @@
Subproject commit be1f33449ea205e494a7bcf2e9322319c6166204
Subproject commit 0c5d870919854258f5f51530a66d839fba20e288

@ -1 +1 @@
Subproject commit 3b557627cd8274a4a2b16375886c492964db38eb
Subproject commit b6b514b7ec49531dc334c4e7bfee2569cfe33398