PaperMC/Spigot-Server-Patches/Thread-Safe-Vanilla-Command-permission-checking.patch
Daniel Ennis 69ee95fa42 1.16.2 Release (#4123)
PaperMC believes that 1.16.2 is now ready for general release as we fixed the main issue plagueing the 1.16.x release, the MapLike data conversion issues.

Until now, it was not safe for a server to convert a world to 1.16.2 without data conversion issues around villages and potentially other things. If you did, those MapLike errors meant something went wrong.

This is now resolved.

Big thanks to all those that helped, notably @BillyGalbreath and @Proximyst who did large parts of the update process with me.

Please as always, backup your worlds and test before updating to 1.16.2!

If you update to 1.16.2, there is no going back to an older build than this.

---------------------------------

Co-authored-by: William Blake Galbreath <Blake.Galbreath@GMail.com>
Co-authored-by: Mariell Hoversholm <proximyst@proximyst.com>
Co-authored-by: krolik-exe <69214078+krolik-exe@users.noreply.github.com>
Co-authored-by: BillyGalbreath <BillyGalbreath@users.noreply.github.com>
Co-authored-by: stonar96 <minecraft.stonar96@gmail.com>
Co-authored-by: Shane Freeder <theboyetronic@gmail.com>
Co-authored-by: Jason Penilla <11360596+jpenilla@users.noreply.github.com>
Co-authored-by: Riley Park <rileysebastianpark@gmail.com>
Co-authored-by: Aurora <21148213+aurorasmiles@users.noreply.github.com>
Co-authored-by: Nassim Jahnke <nassim@njahnke.dev>
Co-authored-by: commandblockguy <commandblockguy1@gmail.com>
Co-authored-by: DigitalRegent <misterwener@gmail.com>
Co-authored-by: ishland <ishlandmc@yeah.net>
2020-08-24 22:22:08 -04:00

53 lines
3.1 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sat, 11 Jul 2020 03:54:28 -0400
Subject: [PATCH] Thread Safe Vanilla Command permission checking
Datapacks check this on load and are built concurrently. This was breaking them badly due
to race conditions.
Plus, .canUse we want to be safe for async anyways.
diff --git a/src/main/java/com/mojang/brigadier/tree/CommandNode.java b/src/main/java/com/mojang/brigadier/tree/CommandNode.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/com/mojang/brigadier/tree/CommandNode.java
+++ b/src/main/java/com/mojang/brigadier/tree/CommandNode.java
@@ -0,0 +0,0 @@ public abstract class CommandNode<S> implements Comparable<CommandNode<S>> {
public synchronized boolean canUse(final S source) {
if (source instanceof CommandListenerWrapper) {
try {
- ((CommandListenerWrapper) source).currentCommand = this;
+ ((CommandListenerWrapper) source).currentCommand.set(this); // Paper
return requirement.test(source);
} finally {
- ((CommandListenerWrapper) source).currentCommand = null;
+ ((CommandListenerWrapper) source).currentCommand.set(null); // Paper
}
}
// CraftBukkit end
diff --git a/src/main/java/net/minecraft/server/CommandListenerWrapper.java b/src/main/java/net/minecraft/server/CommandListenerWrapper.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/CommandListenerWrapper.java
+++ b/src/main/java/net/minecraft/server/CommandListenerWrapper.java
@@ -0,0 +0,0 @@ public class CommandListenerWrapper implements ICompletionProvider, com.destroys
private final ResultConsumer<CommandListenerWrapper> l;
private final ArgumentAnchor.Anchor m;
private final Vec2F n;
- public volatile CommandNode currentCommand; // CraftBukkit
+ public ThreadLocal<CommandNode> currentCommand = new ThreadLocal<>(); // CraftBukkit // Paper
public CommandListenerWrapper(ICommandListener icommandlistener, Vec3D vec3d, Vec2F vec2f, WorldServer worldserver, int i, String s, IChatBaseComponent ichatbasecomponent, MinecraftServer minecraftserver, @Nullable Entity entity) {
this(icommandlistener, vec3d, vec2f, worldserver, i, s, ichatbasecomponent, minecraftserver, entity, false, (commandcontext, flag, j) -> {
@@ -0,0 +0,0 @@ public class CommandListenerWrapper implements ICompletionProvider, com.destroys
@Override
public boolean hasPermission(int i) {
// CraftBukkit start
- CommandNode currentCommand = this.currentCommand;
+ // Paper start - fix concurrency issue
+ CommandNode currentCommand = this.currentCommand.get();
if (currentCommand != null) {
return hasPermission(i, org.bukkit.craftbukkit.command.VanillaCommandWrapper.getPermission(currentCommand));
+ // Paper end
}
// CraftBukkit end