automatically switch to chat if player is deopped or not in creative

This commit is contained in:
Chayapak 2023-05-10 12:37:57 +07:00
parent a7045c4b15
commit 46a3cbbb33

View file

@ -10,6 +10,7 @@ import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientPlayNetworkHandler; import net.minecraft.client.network.ClientPlayNetworkHandler;
import net.minecraft.client.network.ClientPlayerEntity;
public class CustomChat { public class CustomChat {
private final MinecraftClient client; private final MinecraftClient client;
@ -30,7 +31,8 @@ public class CustomChat {
} }
public void chat (String message) { public void chat (String message) {
if (!enabled) { final ClientPlayerEntity player = client.player;
if (!enabled || !player.hasPermissionLevel(2) || !player.isCreative()) {
final ClientPlayNetworkHandler networkHandler = client.getNetworkHandler(); final ClientPlayNetworkHandler networkHandler = client.getNetworkHandler();
networkHandler.sendChatMessage(message); networkHandler.sendChatMessage(message);
return; return;