From e794bcecbda050b0c91b814e163f00625dc2e7c6 Mon Sep 17 00:00:00 2001
From: Owen1212055 <23108066+Owen1212055@users.noreply.github.com>
Date: Sun, 25 Dec 2022 23:22:08 -0500
Subject: [PATCH] Respect SpigotConfig logCommands & fix stopDancing() NPE
 (#8715)

---
 ...ssing-SpigotConfig-logCommands-check.patch | 20 +++++++++++++++++++
 ...-Allay-stopDancing-while-not-dancing.patch | 19 ++++++++++++++++++
 2 files changed, 39 insertions(+)
 create mode 100644 patches/server/Add-missing-SpigotConfig-logCommands-check.patch
 create mode 100644 patches/server/Fix-NPE-on-Allay-stopDancing-while-not-dancing.patch

diff --git a/patches/server/Add-missing-SpigotConfig-logCommands-check.patch b/patches/server/Add-missing-SpigotConfig-logCommands-check.patch
new file mode 100644
index 0000000000..4a2a8a326a
--- /dev/null
+++ b/patches/server/Add-missing-SpigotConfig-logCommands-check.patch
@@ -0,0 +1,20 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: NonSwag <mrminecraft00@gmail.com>
+Date: Thu, 8 Dec 2022 20:25:05 +0100
+Subject: [PATCH] Add missing SpigotConfig logCommands check
+
+
+diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
+--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
++++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
+     private void performChatCommand(ServerboundChatCommandPacket packet, LastSeenMessages lastSeenMessages) {
+         // CraftBukkit start
+         String command = "/" + packet.command();
++        if (org.spigotmc.SpigotConfig.logCommands) { // Paper
+         ServerGamePacketListenerImpl.LOGGER.info(this.player.getScoreboardName() + " issued server command: " + command);
++        } // Paper
+ 
+         PlayerCommandPreprocessEvent event = new PlayerCommandPreprocessEvent(this.getCraftPlayer(), command, new LazyPlayerSet(this.server));
+         this.cserver.getPluginManager().callEvent(event);
diff --git a/patches/server/Fix-NPE-on-Allay-stopDancing-while-not-dancing.patch b/patches/server/Fix-NPE-on-Allay-stopDancing-while-not-dancing.patch
new file mode 100644
index 0000000000..a79457530f
--- /dev/null
+++ b/patches/server/Fix-NPE-on-Allay-stopDancing-while-not-dancing.patch
@@ -0,0 +1,19 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: NonSwag <mrminecraft00@gmail.com>
+Date: Tue, 6 Dec 2022 23:04:21 +0100
+Subject: [PATCH] Fix NPE on Allay#stopDancing while not dancing
+
+
+diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftAllay.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftAllay.java
+index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
+--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftAllay.java
++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftAllay.java
+@@ -0,0 +0,0 @@ public class CraftAllay extends CraftCreature implements org.bukkit.entity.Allay
+     public void stopDancing() {
+         this.getHandle().forceDancing = false;
+         this.getHandle().jukeboxPos = null;
+-        this.getHandle().setJukeboxPlaying(null, false);
++        this.getHandle().setDancing(false); // Paper - Directly modify set dancing to avoid NPE
+     }
+ 
+     @Override