From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com> Date: Mon, 18 Sep 2023 00:35:27 +0300 Subject: [PATCH] Do not process chat/commands before player has joined diff --git a/src/main/java/gq/bxteam/divinemc/configuration/DivineConfig.java b/src/main/java/gq/bxteam/divinemc/configuration/DivineConfig.java index 512afaa97e89e3beb92cf2ebc46248eddd22cf5c..b8fa8f551c95503be60f990099b2d41296ea91de 100644 --- a/src/main/java/gq/bxteam/divinemc/configuration/DivineConfig.java +++ b/src/main/java/gq/bxteam/divinemc/configuration/DivineConfig.java @@ -162,4 +162,9 @@ public class DivineConfig { private static void allowAnyUsername() { allowAnyUsername = getBoolean("settings.player.allow-any-username", allowAnyUsername); } + + public static boolean doNotProcessChatCommands = true; + private static void doNotProcessChatCommands() { + doNotProcessChatCommands = getBoolean("settings.do-not-process-chat-commands", doNotProcessChatCommands); + } } \ No newline at end of file diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java index 6638d769a34287d54b22e4416003556915e153f1..32d2e53a73f70d64db13a7da01c3157bb0cd7395 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java @@ -6,6 +6,7 @@ import com.mojang.authlib.GameProfile; import com.mojang.brigadier.ParseResults; import com.mojang.brigadier.StringReader; import com.mojang.logging.LogUtils; +import gq.bxteam.divinemc.configuration.DivineConfig; import it.unimi.dsi.fastutil.ints.Int2ObjectMap.Entry; import it.unimi.dsi.fastutil.ints.Int2ObjectMaps; import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; @@ -2312,6 +2313,8 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl this.disconnect(Component.translatable("multiplayer.disconnect.out_of_order_chat"), org.bukkit.event.player.PlayerKickEvent.Cause.OUT_OF_ORDER_CHAT); // Paper - kick event causes }); // Paper - push to main return Optional.empty(); + } else if (player.joining && DivineConfig.doNotProcessChatCommands) { // DivineMC - EMC - do not handle chat messages before they joined + return Optional.empty(); } else { Optional optional = this.unpackAndApplyLastSeen(acknowledgment);