From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Martijn Muijsers Date: Tue, 29 Nov 2022 15:33:32 +0100 Subject: [PATCH] Do not process chat/commands before player has joined License: MIT (https://opensource.org/licenses/MIT) Gale - https://galemc.org This patch is based on the following patch: "Do not process chat/commands before player has joined" By: chickeneer As part of: EmpireCraft (https://github.com/starlis/empirecraft) Licensed under: MIT (https://opensource.org/licenses/MIT) diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java index ffae3e45ba88e8b733e77b87a45cc27b9ecf8c19..684a15babe984c84703e2c6af7a461f75959312d 100644 --- a/net/minecraft/server/level/ServerPlayer.java +++ b/net/minecraft/server/level/ServerPlayer.java @@ -425,6 +425,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc public boolean sentListPacket = false; public boolean supressTrackerForLogin = false; // Paper - Fire PlayerJoinEvent when Player is actually ready // CraftBukkit end + public boolean didPlayerJoinEvent = false; // Gale - EMC - do not process chat/commands before player has joined public boolean isRealPlayer; // Paper public @Nullable com.destroystokyo.paper.event.entity.PlayerNaturallySpawnCreaturesEvent playerNaturallySpawnedEvent; // Paper - PlayerNaturallySpawnCreaturesEvent public @Nullable String clientBrandName = null; // Paper - Brand support diff --git a/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/net/minecraft/server/network/ServerGamePacketListenerImpl.java index 383652f0bd32fca3551db85fb6ac42a0e326836e..29466047936ed44f57cb4bcb8f1bff0bdad81827 100644 --- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java @@ -2433,7 +2433,7 @@ public class ServerGamePacketListenerImpl this.disconnectAsync(Component.translatable("multiplayer.disconnect.illegal_characters"), org.bukkit.event.player.PlayerKickEvent.Cause.ILLEGAL_CHARACTERS); // Paper - add proper async disconnect } else 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)); - } else { + } else if (player.didPlayerJoinEvent) { // Gale - EMC - do not process chat/commands before player has joined this.player.resetLastActionTime(); // CraftBukkit start if (sync) { diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java index 898d9ab963a6cf1db8edf4657a65335d15f271c4..77dbd115d99d8f8e2c01ea69ca297ced06b19c12 100644 --- a/net/minecraft/server/players/PlayerList.java +++ b/net/minecraft/server/players/PlayerList.java @@ -335,6 +335,8 @@ public abstract class PlayerList { return; } + player.didPlayerJoinEvent = true; // Gale - EMC - do not process chat/commands before player has joined + final net.kyori.adventure.text.Component jm = playerJoinEvent.joinMessage(); if (jm != null && !jm.equals(net.kyori.adventure.text.Component.empty())) { // Paper - Adventure