Files
AsminVoicechat/source/decompiled/de/maxhenkel/voicechat/compatibility/Compatibility1_18.java
T
asminme bbccd4a815
Build AsminVoicechat / prepare-release (push) Successful in 14s
Build AsminVoicechat / build-and-test (17) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (18) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (19) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (20) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (21) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (22) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (23) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (24) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (25) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (26) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (27-ea) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (16) (push) Canceled after 38s
first commit
2026-10-24 15:18:03 +02:00

80 lines
3.8 KiB
Java

/*
* 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;
import de.maxhenkel.voicechat.compatibility.Compatibility1_8;
import de.maxhenkel.voicechat.compatibility.JsonMessageBaseCompatibility;
import de.maxhenkel.voicechat.compatibility.ReflectionUtils;
import java.util.UUID;
import org.bukkit.entity.Player;
public class Compatibility1_18
extends JsonMessageBaseCompatibility {
public static final BukkitVersion VERSION_1_18_2 = BukkitVersion.parseBukkitVersion("1.18.2-R0.1");
public static final BukkitVersion VERSION_1_18_1 = BukkitVersion.parseBukkitVersion("1.18.1-R0.1");
public static final BukkitVersion VERSION_1_18 = BukkitVersion.parseBukkitVersion("1.18-R0.1");
public static final Compatibility1_18 INSTANCE = new Compatibility1_18();
private static final UUID NUL_UUID = new UUID(0L, 0L);
@Override
public void sendJsonMessage(Player player, String json) {
Class<?> chatMessageTypeClass = ReflectionUtils.getClazz("net.minecraft.network.chat.ChatMessageType");
Object b = ReflectionUtils.getField(chatMessageTypeClass, "b");
this.send(player, json, b);
}
@Override
public void sendJsonStatusMessage(Player player, String json) {
Class<?> chatMessageTypeClass = ReflectionUtils.getClazz("net.minecraft.network.chat.ChatMessageType");
Object b = ReflectionUtils.getField(chatMessageTypeClass, "c");
this.send(player, json, b);
}
@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.INSTANCE.playerArgument();
}
@Override
public ArgumentType<?> uuidArgument() {
return Compatibility1_19.INSTANCE.uuidArgument();
}
private void send(Player player, String json, Object chatMessageType) {
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<?> packetPlayOutChatClass = ReflectionUtils.getClazz("net.minecraft.network.protocol.game.PacketPlayOutChat");
Class<?> chatMessageTypeClass = ReflectionUtils.getClazz("net.minecraft.network.chat.ChatMessageType");
Object clientboundSystemChatPacket = ReflectionUtils.callConstructor(packetPlayOutChatClass, new Class[]{iChatBaseComponentClass, chatMessageTypeClass, UUID.class}, iChatBaseComponent, chatMessageType, NUL_UUID);
ReflectionUtils.callMethod(playerConnection, "a", new Class[]{packet}, clientboundSystemChatPacket);
}
}