From acaa9f2d3fe2e7293323c690e623583b413562bb Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Thu, 11 Jan 2024 08:15:17 -0800
Subject: [PATCH] Log command execution exceptions if debug=true (#10130)

---
 patches/server/misc-debugging-dumps.patch | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/patches/server/misc-debugging-dumps.patch b/patches/server/misc-debugging-dumps.patch
index 9d77bb0583..18f0e71375 100644
--- a/patches/server/misc-debugging-dumps.patch
+++ b/patches/server/misc-debugging-dumps.patch
@@ -28,6 +28,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 +        new Throwable(reason).printStackTrace();
 +    }
 +}
+diff --git a/src/main/java/net/minecraft/commands/Commands.java b/src/main/java/net/minecraft/commands/Commands.java
+index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
+--- a/src/main/java/net/minecraft/commands/Commands.java
++++ b/src/main/java/net/minecraft/commands/Commands.java
+@@ -0,0 +0,0 @@ public class Commands {
+         } catch (Exception exception) {
+             MutableComponent ichatmutablecomponent = Component.literal(exception.getMessage() == null ? exception.getClass().getName() : exception.getMessage());
+ 
+-            if (Commands.LOGGER.isDebugEnabled()) {
++            if (commandlistenerwrapper.getServer().isDebugging() || Commands.LOGGER.isDebugEnabled()) { // Paper
+                 Commands.LOGGER.error("Command exception: /{}", s, exception);
+                 StackTraceElement[] astacktraceelement = exception.getStackTrace();
+ 
 diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
 --- a/src/main/java/net/minecraft/server/MinecraftServer.java