Ignore AsyncCatcher setting for Command Dispatch, always force sync
Plugins were abusing this to dispatch commands async anyways. We will no longer check that flag, and force all commands to be ran sync. Use a different boolean for allowing things go to through on shutdown/restart instead. Resolves #1004 Resolves #1005
This commit is contained in:
@@ -14,7 +14,7 @@ big slowdown in execution but throwing an exception at same time to raise awaren
|
||||
that it is happening so that plugin authors can fix their code to stop executing commands async.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
|
||||
index da25a8be..5348c0cb 100644
|
||||
index da25a8bea..48379f414 100644
|
||||
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
|
||||
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
|
||||
@@ -0,0 +0,0 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
|
||||
@@ -22,7 +22,7 @@ index da25a8be..5348c0cb 100644
|
||||
|
||||
if (!async && s.startsWith("/")) {
|
||||
+ // Paper Start
|
||||
+ if (org.spigotmc.AsyncCatcher.enabled && !org.bukkit.Bukkit.isPrimaryThread()) {
|
||||
+ if (!org.spigotmc.AsyncCatcher.shuttingDown && !org.bukkit.Bukkit.isPrimaryThread()) {
|
||||
+ final String fCommandLine = s;
|
||||
+ MinecraftServer.LOGGER.log(org.apache.logging.log4j.Level.ERROR, "Command Dispatched Async: " + fCommandLine);
|
||||
+ MinecraftServer.LOGGER.log(org.apache.logging.log4j.Level.ERROR, "Please notify author of plugin causing this execution to fix this bug! see: http://bit.ly/1oSiM6C", new Throwable());
|
||||
@@ -48,7 +48,7 @@ index da25a8be..5348c0cb 100644
|
||||
} else if (this.player.getChatFlags() == EntityHuman.EnumChatVisibility.SYSTEM) {
|
||||
// Do nothing, this is coming from a plugin
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
index bfddd168..082957d3 100644
|
||||
index bfddd1685..462ad1024 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -0,0 +0,0 @@ public final class CraftServer implements Server {
|
||||
@@ -56,7 +56,7 @@ index bfddd168..082957d3 100644
|
||||
Validate.notNull(commandLine, "CommandLine cannot be null");
|
||||
|
||||
+ // Paper Start
|
||||
+ if (org.spigotmc.AsyncCatcher.enabled && !Bukkit.isPrimaryThread()) {
|
||||
+ if (!org.spigotmc.AsyncCatcher.shuttingDown && !Bukkit.isPrimaryThread()) {
|
||||
+ final CommandSender fSender = sender;
|
||||
+ final String fCommandLine = commandLine;
|
||||
+ Bukkit.getLogger().log(Level.SEVERE, "Command Dispatched Async: " + commandLine);
|
||||
@@ -81,4 +81,40 @@ index bfddd168..082957d3 100644
|
||||
if (commandMap.dispatch(sender, commandLine)) {
|
||||
return true;
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/util/ServerShutdownThread.java b/src/main/java/org/bukkit/craftbukkit/util/ServerShutdownThread.java
|
||||
index a0cdd2317..984df4083 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/util/ServerShutdownThread.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/util/ServerShutdownThread.java
|
||||
@@ -0,0 +0,0 @@ public class ServerShutdownThread extends Thread {
|
||||
public void run() {
|
||||
try {
|
||||
org.spigotmc.AsyncCatcher.enabled = false; // Spigot
|
||||
+ org.spigotmc.AsyncCatcher.shuttingDown = true; // Paper
|
||||
server.stop();
|
||||
} catch (ExceptionWorldConflict ex) {
|
||||
ex.printStackTrace();
|
||||
diff --git a/src/main/java/org/spigotmc/AsyncCatcher.java b/src/main/java/org/spigotmc/AsyncCatcher.java
|
||||
index 4b3aa85c9..e44c23016 100644
|
||||
--- a/src/main/java/org/spigotmc/AsyncCatcher.java
|
||||
+++ b/src/main/java/org/spigotmc/AsyncCatcher.java
|
||||
@@ -0,0 +0,0 @@ public class AsyncCatcher
|
||||
{
|
||||
|
||||
public static boolean enabled = true;
|
||||
+ public static boolean shuttingDown = false; // Paper
|
||||
|
||||
public static void catchOp(String reason)
|
||||
{
|
||||
diff --git a/src/main/java/org/spigotmc/RestartCommand.java b/src/main/java/org/spigotmc/RestartCommand.java
|
||||
index 49768734d..947c43a5d 100644
|
||||
--- a/src/main/java/org/spigotmc/RestartCommand.java
|
||||
+++ b/src/main/java/org/spigotmc/RestartCommand.java
|
||||
@@ -0,0 +0,0 @@ public class RestartCommand extends Command
|
||||
public static void restart(final File script)
|
||||
{
|
||||
AsyncCatcher.enabled = false; // Disable async catcher incase it interferes with us
|
||||
+ org.spigotmc.AsyncCatcher.shuttingDown = true; // Paper
|
||||
try
|
||||
{
|
||||
if ( script.isFile() )
|
||||
--
|
||||
Reference in New Issue
Block a user