9
0
mirror of https://github.com/BX-Team/DivineMC.git synced 2025-12-19 14:59:25 +00:00
Files
DivineMC/patches/server/0023-Do-not-process-chat-commands-before-player-has-joine.patch
NONPLAYT 30d749a8f0 Updated Upstream (Purpur)
Upstream has released updates that appear to apply and compile correctly

Purpur Changes:
PurpurMC/Purpur@bcd90f7 Updated Upstream (Paper)
2024-02-19 01:45:21 +03:00

42 lines
2.5 KiB
Diff

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/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index b7803d6753d28f174b8a6e5b31eccfa44b94c6be..45ff1a20630e4d72036cb0c900c06a785b1c3f24 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 space.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;
@@ -2338,6 +2339,8 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
if (this.player.isRemoved() || this.player.getChatVisibility() == ChatVisiblity.HIDDEN) { // CraftBukkit - dead men tell no tales
this.send(new ClientboundSystemChatPacket(Component.translatable("chat.disabled.options").withStyle(ChatFormatting.RED), false));
return Optional.empty();
+ } else if (player.joining && DivineConfig.doNotProcessChatCommands) { // DivineMC - EMC - do not handle chat messages before they joined
+ return Optional.empty();
} else {
this.player.resetLastActionTime();
return optional;
diff --git a/src/main/java/space/bxteam/divinemc/configuration/DivineConfig.java b/src/main/java/space/bxteam/divinemc/configuration/DivineConfig.java
index c10403d781d25e4bb9e43d3f064fb1aebde00bfb..ef7983863da3b4febef3da2fab93fe581fbd65af 100644
--- a/src/main/java/space/bxteam/divinemc/configuration/DivineConfig.java
+++ b/src/main/java/space/bxteam/divinemc/configuration/DivineConfig.java
@@ -152,4 +152,9 @@ public class DivineConfig {
}
return builder.build();
}
+
+ public static boolean doNotProcessChatCommands = true;
+ private static void doNotProcessChatCommands() {
+ doNotProcessChatCommands = getBoolean("settings.do-not-process-chat-commands", doNotProcessChatCommands);
+ }
}