mirror of
https://github.com/FabricMC/fabric.git
synced 2025-04-08 21:14:41 -04:00
Fix: broadcast message headers when chat event is cancelled (#2426)
This resolves an issue where the chat signing chains for players would be broken when the server cancels a signed player message. This could lead to clients disconnecting after receiving any following message due to the broken chain.
This commit is contained in:
parent
308233144b
commit
4e0178f48a
1 changed files with 13 additions and 1 deletions
|
@ -16,6 +16,7 @@
|
|||
|
||||
package net.fabricmc.fabric.mixin.message;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
|
@ -36,14 +37,21 @@ import net.minecraft.text.Text;
|
|||
import net.fabricmc.fabric.api.message.v1.ServerMessageEvents;
|
||||
|
||||
@Mixin(PlayerManager.class)
|
||||
public class PlayerManagerMixin {
|
||||
public abstract class PlayerManagerMixin {
|
||||
@Shadow
|
||||
@Final
|
||||
private MinecraftServer server;
|
||||
|
||||
@Shadow
|
||||
public abstract void sendMessageHeader(SignedMessage message, Set<ServerPlayerEntity> except);
|
||||
|
||||
@Inject(method = "broadcast(Lnet/minecraft/network/message/SignedMessage;Lnet/minecraft/server/network/ServerPlayerEntity;Lnet/minecraft/network/message/MessageType$Parameters;)V", at = @At("HEAD"), cancellable = true)
|
||||
private void onSendChatMessage(SignedMessage message, ServerPlayerEntity sender, MessageType.Parameters params, CallbackInfo ci) {
|
||||
if (!ServerMessageEvents.ALLOW_CHAT_MESSAGE.invoker().allowChatMessage(message, sender, params)) {
|
||||
if (!message.headerSignature().isEmpty()) {
|
||||
sendMessageHeader(message, Set.of());
|
||||
}
|
||||
|
||||
ci.cancel();
|
||||
return;
|
||||
}
|
||||
|
@ -64,6 +72,10 @@ public class PlayerManagerMixin {
|
|||
@Inject(method = "broadcast(Lnet/minecraft/network/message/SignedMessage;Lnet/minecraft/server/command/ServerCommandSource;Lnet/minecraft/network/message/MessageType$Parameters;)V", at = @At("HEAD"), cancellable = true)
|
||||
private void onSendCommandMessage(SignedMessage message, ServerCommandSource source, MessageType.Parameters params, CallbackInfo ci) {
|
||||
if (!ServerMessageEvents.ALLOW_COMMAND_MESSAGE.invoker().allowCommandMessage(message, source, params)) {
|
||||
if (!message.headerSignature().isEmpty()) {
|
||||
sendMessageHeader(message, Set.of());
|
||||
}
|
||||
|
||||
ci.cancel();
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue