/* * Decompiled with CFR 0.152. * * Could not load the following classes: * com.mojang.brigadier.arguments.ArgumentType * org.bukkit.entity.Player */ package de.maxhenkel.voicechat.compatibility; import com.mojang.brigadier.arguments.ArgumentType; import de.maxhenkel.voicechat.BukkitVersion; import de.maxhenkel.voicechat.compatibility.Compatibility1_19_1; import de.maxhenkel.voicechat.compatibility.Compatibility1_8; import de.maxhenkel.voicechat.compatibility.JsonMessageBaseCompatibility; import de.maxhenkel.voicechat.compatibility.ReflectionUtils; import org.bukkit.entity.Player; public class Compatibility1_19 extends JsonMessageBaseCompatibility { public static final BukkitVersion VERSION_1_19 = BukkitVersion.parseBukkitVersion("1.19-R0.1"); public static final Compatibility1_19 INSTANCE = new Compatibility1_19(); @Override public void sendJsonMessage(Player player, String json) { this.send(player, json, false); } @Override public void sendJsonStatusMessage(Player player, String json) { this.send(player, json, true); } @Override public String createTranslationMessage(String key, String ... args) { return Compatibility1_8.constructTranslationMessage(key, args); } @Override public void sendInviteMessage(Player player, Player commandSender, String groupName, String joinCommand) { this.sendJsonMessage(player, Compatibility1_8.constructInviteMessage(commandSender, groupName, joinCommand)); } @Override public void sendIncompatibleMessage(Player player, String pluginVersion, String pluginName) { this.sendJsonMessage(player, Compatibility1_8.constructIncompatibleMessage(pluginVersion, pluginName)); } @Override public ArgumentType playerArgument() { return Compatibility1_19_1.INSTANCE.playerArgument(); } @Override public ArgumentType uuidArgument() { return Compatibility1_19_1.INSTANCE.uuidArgument(); } private void send(Player player, String json, boolean status) { Object entityPlayer = ReflectionUtils.callMethod((Object)player, "getHandle"); Object playerConnection = ReflectionUtils.getField(entityPlayer, "b"); Class packet = ReflectionUtils.getClazz("net.minecraft.network.protocol.Packet"); Class craftChatMessage = this.getBukkitClass("util.CraftChatMessage"); Class iChatBaseComponentClass = ReflectionUtils.getClazz("net.minecraft.network.chat.IChatBaseComponent"); Object iChatBaseComponent = ReflectionUtils.callMethod(craftChatMessage, "fromJSON", new Class[]{String.class}, json); Class clientboundSystemChatPacketClass = ReflectionUtils.getClazz("net.minecraft.network.protocol.game.ClientboundSystemChatPacket"); Object clientboundSystemChatPacket = ReflectionUtils.callConstructor(clientboundSystemChatPacketClass, new Class[]{iChatBaseComponentClass, Integer.TYPE}, iChatBaseComponent, this.getId(player, status)); ReflectionUtils.callMethod(playerConnection, "a", new Class[]{packet}, clientboundSystemChatPacket); } private int getId(Player player, boolean status) { Object world = ReflectionUtils.callMethod((Object)player.getWorld(), "getHandle"); Class iRegistryCustomClass = ReflectionUtils.getClazz("net.minecraft.core.IRegistryCustom"); Object iRegistryCustom = ReflectionUtils.callMethod(world, "s"); Class resourceKeyClass = ReflectionUtils.getClazz("net.minecraft.resources.ResourceKey"); Class iRegistry = ReflectionUtils.getClazz("net.minecraft.core.IRegistry"); Object resourceKey = ReflectionUtils.getField(iRegistry, "bI"); Object registry = ReflectionUtils.callMethod(iRegistryCustomClass, iRegistryCustom, "d", new Class[]{resourceKeyClass}, resourceKey); Class chatMessageTypeClass = ReflectionUtils.getClazz("net.minecraft.network.chat.ChatMessageType"); Object chatMessageType = status ? ReflectionUtils.getField(chatMessageTypeClass, "d") : ReflectionUtils.getField(chatMessageTypeClass, "c"); Object messageType = ReflectionUtils.callMethod(registry, "a", new Class[]{resourceKeyClass}, chatMessageType); return (Integer)ReflectionUtils.callMethod(registry, "a", new Class[]{Object.class}, messageType); } }