geforkt von Mirrors/Paper
de04cbced5
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: f29cb801 Separate checkstyle-suppressions file is not required 86f99bbe SPIGOT-7540, PR-946: Add ServerTickManager API d4119585 SPIGOT-6903, PR-945: Add BlockData#getMapColor b7a2ed41 SPIGOT-7530, PR-947: Add Player#removeResourcePack 9dd56255 SPIGOT-7527, PR-944: Add WindCharge#explode() 994a6163 Attempt upgrade of resolver libraries CraftBukkit Changes: b3b43a6ad Add Checkstyle check for unused imports 13fb3358e SPIGOT-7544: Scoreboard#getEntries() doesn't get entries but class names 3dda99c06 SPIGOT-7540, PR-1312: Add ServerTickManager API 2ab4508c0 SPIGOT-6903, PR-1311: Add BlockData#getMapColor 1dbdbbed4 PR-1238: Remove unnecessary sign ticking 659728d2a MC-264285, SPIGOT-7439, PR-1237: Fix unbreakable flint and steel is completely consumed while igniting creeper e37e29ce0 Increase outdated build delay c00438b39 SPIGOT-7530, PR-1313: Add Player#removeResourcePack 492dd80ce SPIGOT-7527, PR-1310: Add WindCharge#explode() e11fbb9d7 Upgrade MySQL driver 9f3a0bd2a Attempt upgrade of resolver libraries 60d16d7ca PR-1306: Centralize Bukkit and Minecraft entity conversion Spigot Changes: 06d602e7 Rebuild patches
54 Zeilen
3.0 KiB
Diff
54 Zeilen
3.0 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 3384501f83d445f45aa8233e98c7597daa67b8ef..6875e15aac37d3566bf04f1a6ee79a21537d2939 100644
|
|
--- a/src/main/java/com/mojang/brigadier/tree/CommandNode.java
|
|
+++ b/src/main/java/com/mojang/brigadier/tree/CommandNode.java
|
|
@@ -75,10 +75,10 @@ public abstract class CommandNode<S> implements Comparable<CommandNode<S>> {
|
|
public synchronized boolean canUse(final S source) {
|
|
if (source instanceof CommandSourceStack) {
|
|
try {
|
|
- ((CommandSourceStack) source).currentCommand = this;
|
|
+ ((CommandSourceStack) source).currentCommand.put(Thread.currentThread(), this); // Paper
|
|
return this.requirement.test(source);
|
|
} finally {
|
|
- ((CommandSourceStack) source).currentCommand = null;
|
|
+ ((CommandSourceStack) source).currentCommand.remove(Thread.currentThread()); // Paper
|
|
}
|
|
}
|
|
// CraftBukkit end
|
|
diff --git a/src/main/java/net/minecraft/commands/CommandSourceStack.java b/src/main/java/net/minecraft/commands/CommandSourceStack.java
|
|
index 75b7b3cf90d1d67203ae19dc3302f06a57470f92..e58c2844356c71973d81b460a21aab795b506d77 100644
|
|
--- a/src/main/java/net/minecraft/commands/CommandSourceStack.java
|
|
+++ b/src/main/java/net/minecraft/commands/CommandSourceStack.java
|
|
@@ -64,7 +64,7 @@ public class CommandSourceStack implements ExecutionCommandSource<CommandSourceS
|
|
private final Vec2 rotation;
|
|
private final CommandSigningContext signingContext;
|
|
private final TaskChainer chatMessageChainer;
|
|
- public volatile CommandNode currentCommand; // CraftBukkit
|
|
+ public java.util.Map<Thread, CommandNode> currentCommand = new java.util.concurrent.ConcurrentHashMap<>(); // CraftBukkit // Paper
|
|
public boolean bypassSelectorPermissions = false; // Paper
|
|
|
|
public CommandSourceStack(CommandSource output, Vec3 pos, Vec2 rot, ServerLevel world, int level, String name, Component displayName, MinecraftServer server, @Nullable Entity entity) {
|
|
@@ -193,9 +193,11 @@ public class CommandSourceStack implements ExecutionCommandSource<CommandSourceS
|
|
@Override
|
|
public boolean hasPermission(int level) {
|
|
// CraftBukkit start
|
|
- CommandNode currentCommand = this.currentCommand;
|
|
+ // Paper start - fix concurrency issue
|
|
+ CommandNode currentCommand = this.currentCommand.get(Thread.currentThread());
|
|
if (currentCommand != null) {
|
|
return this.hasPermission(level, org.bukkit.craftbukkit.command.VanillaCommandWrapper.getPermission(currentCommand));
|
|
+ // Paper end
|
|
}
|
|
// CraftBukkit end
|
|
|