From 46a3cbbb3343c03f4630ae49d0709374fa9f4434 Mon Sep 17 00:00:00 2001 From: ChomeNS <95471003+ChomeNS@users.noreply.github.com> Date: Wed, 10 May 2023 12:37:57 +0700 Subject: [PATCH] automatically switch to chat if player is deopped or not in creative --- .../java/land/chipmunk/chipmunkmod/modules/CustomChat.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/land/chipmunk/chipmunkmod/modules/CustomChat.java b/src/main/java/land/chipmunk/chipmunkmod/modules/CustomChat.java index ddf94ab..0e8440e 100644 --- a/src/main/java/land/chipmunk/chipmunkmod/modules/CustomChat.java +++ b/src/main/java/land/chipmunk/chipmunkmod/modules/CustomChat.java @@ -10,6 +10,7 @@ import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer; import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; import net.minecraft.client.MinecraftClient; import net.minecraft.client.network.ClientPlayNetworkHandler; +import net.minecraft.client.network.ClientPlayerEntity; public class CustomChat { private final MinecraftClient client; @@ -30,7 +31,8 @@ public class CustomChat { } public void chat (String message) { - if (!enabled) { + final ClientPlayerEntity player = client.player; + if (!enabled || !player.hasPermissionLevel(2) || !player.isCreative()) { final ClientPlayNetworkHandler networkHandler = client.getNetworkHandler(); networkHandler.sendChatMessage(message); return;