summaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
authorEvan McCarthy2022-07-10 22:15:59 -0500
committerEvan McCarthy2022-07-10 22:15:59 -0500
commitac77e7603f5a810f89141e38059915591e813e33 (patch)
tree62355ca6fee6b5c32c2b06c6d11a634493c8d752 /src/main/java
parent62026145c890300a47fb994e0bd1359a2926c30c (diff)
use correct decoration for system messages
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/com/aizistral/nochatreports/mixins/MixinServerGamePacketListenerImpl.java9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/main/java/com/aizistral/nochatreports/mixins/MixinServerGamePacketListenerImpl.java b/src/main/java/com/aizistral/nochatreports/mixins/MixinServerGamePacketListenerImpl.java
index 6a87b48..297982b 100644
--- a/src/main/java/com/aizistral/nochatreports/mixins/MixinServerGamePacketListenerImpl.java
+++ b/src/main/java/com/aizistral/nochatreports/mixins/MixinServerGamePacketListenerImpl.java
@@ -1,16 +1,13 @@
package com.aizistral.nochatreports.mixins;
-import com.aizistral.nochatreports.NoChatReports;
import com.aizistral.nochatreports.core.NoReportsConfig;
import net.minecraft.core.Registry;
-import net.minecraft.network.chat.ChatType;
import net.minecraft.network.chat.ChatTypeDecoration;
import net.minecraft.network.chat.Component;
import net.minecraft.network.protocol.Packet;
import net.minecraft.network.protocol.game.ClientboundPlayerChatPacket;
import net.minecraft.network.protocol.game.ClientboundSystemChatPacket;
-import net.minecraft.resources.ResourceKey;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.network.ServerGamePacketListenerImpl;
import net.minecraft.server.network.ServerPlayerConnection;
@@ -19,12 +16,13 @@ import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
-import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(ServerGamePacketListenerImpl.class)
public abstract class MixinServerGamePacketListenerImpl implements ServerPlayerConnection {
+ @Shadow public ServerPlayer player;
+
/**
* @reason Convert player message to system message if mod is configured respectively.
* This allows to circumvent signature check on client, as it only checks player messages.
@@ -37,7 +35,8 @@ public abstract class MixinServerGamePacketListenerImpl implements ServerPlayerC
if (NoReportsConfig.convertToGameMessage()) {
if (packet instanceof ClientboundPlayerChatPacket chat) {
Component component = chat.unsignedContent().orElse(chat.signedContent());
- component = ChatTypeDecoration.withSender("chat.type.text").decorate(component, chat.sender());
+ ChatTypeDecoration decoration = player.level.registryAccess().registryOrThrow(Registry.CHAT_TYPE_REGISTRY).byId(chat.typeId()).chat();
+ component = decoration.decorate(component, chat.sender());
packet = new ClientboundSystemChatPacket(component, false);
info.cancel();