update to 26.1.2#403
Conversation
|
|
the jitpack file is useless for a PR btw, since @WesJD doesn't use it anyway |
Yeah, he can remove it. I just added it, so im able to use it in my projects without referring to a local jar file. |
WesJD
left a comment
There was a problem hiding this comment.
Thanks for submitting this! Just a few things to fix and this is good to merge.
Corrected the XML formatting in the POM file.
|
@WesJD @feeeedox I could be wrong because I don't have time to test/investigate this for a few days, but my initial reaction is that this seems like the wrong way to fix #401. This is the diff between the diff --git a/Wrapper26_R1.java b/Wrapper26_R2.java
index 020216b..a1ad266 100644
--- a/Wrapper26_R1.java
+++ b/Wrapper26_R2.java
@@ -9,11 +9,7 @@ import net.minecraft.network.protocol.game.ClientboundOpenScreenPacket;
import net.minecraft.network.protocol.game.ClientboundSetExperiencePacket;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.Container;
-import net.minecraft.world.inventory.AbstractContainerMenu;
-import net.minecraft.world.inventory.AnvilMenu;
-import net.minecraft.world.inventory.ContainerLevelAccess;
-import net.minecraft.world.inventory.MenuType;
-import net.minecraft.world.inventory.Slot;
+import net.minecraft.world.inventory.*;
import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.craftbukkit.entity.CraftPlayer;
import org.bukkit.craftbukkit.event.CraftEventFactory;
@@ -21,7 +17,7 @@ import org.bukkit.craftbukkit.util.CraftChatMessage;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
-public final class Wrapper26_R1 implements VersionWrapper {
+public final class Wrapper26_R2 implements VersionWrapper {
private int getRealNextContainerId(Player player) {
return toNMS(player).nextContainerCounter();
}
@@ -51,14 +47,18 @@ public final class Wrapper26_R1 implements VersionWrapper {
} catch (NoSuchMethodError ignored) {
// Workaround for Paper servers
try {
- Class<?> inventoryCloseEventReasonClass =
- Class.forName("org.bukkit.event.inventory.InventoryCloseEvent$Reason");
+ ServerPlayer nmsPlayer = toNMS(player);
+
+ Object reasonPlugin = Enum.valueOf(
+ (Class<? extends Enum>) Class.forName("org.bukkit.event.inventory.InventoryCloseEvent$Reason"),
+ "PLUGIN");
+
Method handleInventoryCloseEventMethod = CraftEventFactory.class.getMethod(
- "handleInventoryCloseEvent", ServerPlayer.class, inventoryCloseEventReasonClass);
- handleInventoryCloseEventMethod.invoke(
- null,
- toNMS(player),
- inventoryCloseEventReasonClass.getField("UNKNOWN").get(null));
+ "handleInventoryCloseEvent",
+ net.minecraft.world.entity.player.Player.class,
+ Class.forName("org.bukkit.event.inventory.InventoryCloseEvent$Reason"));
+
+ handleInventoryCloseEventMethod.invoke(null, nmsPlayer, reasonPlugin);
} catch (ReflectiveOperationException e) {
throw new RuntimeException(e);
}The only meaningful changes I see are:
@WesJD did you ever test #398 on a Paper 26.1.1 server? The PR message seems to indicate that you only tested on Spigot because Paper was not released at that time? Again, I haven't had time to test, but my suspicion is that #401 affects For context, in the |
Fixes #401