Files
AsminVoicechat/source/decompiled/de/maxhenkel/voicechat/compatibility/Compatibility1_20.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

73 lines
3.3 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_8;
import de.maxhenkel.voicechat.compatibility.JsonMessageBaseCompatibility;
import de.maxhenkel.voicechat.compatibility.ReflectionUtils;
import org.bukkit.entity.Player;
public class Compatibility1_20
extends JsonMessageBaseCompatibility {
public static final BukkitVersion VERSION_1_20 = BukkitVersion.parseBukkitVersion("1.20-R0.1");
public static final BukkitVersion VERSION_1_20_1 = BukkitVersion.parseBukkitVersion("1.20.1-R0.1");
public static final Compatibility1_20 INSTANCE = new Compatibility1_20();
@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() {
Class<?> argumentEntity = ReflectionUtils.getClazz("net.minecraft.commands.arguments.ArgumentEntity");
return (ArgumentType)ReflectionUtils.callMethod(argumentEntity, "c");
}
@Override
public ArgumentType<?> uuidArgument() {
Class<?> argumentEntity = ReflectionUtils.getClazz("net.minecraft.commands.arguments.ArgumentUUID");
return (ArgumentType)ReflectionUtils.callMethod(argumentEntity, "a");
}
private void send(Player player, String json, boolean status) {
Object entityPlayer = ReflectionUtils.callMethod((Object)player, "getHandle");
Object playerConnection = ReflectionUtils.getField(entityPlayer, "c");
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, Boolean.TYPE}, iChatBaseComponent, status);
ReflectionUtils.callMethod(playerConnection, "a", new Class[]{packet}, clientboundSystemChatPacket);
}
}