first commit
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
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
This commit is contained in:
commit
bbccd4a815
454 files changed
+45050
No files matched your search
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.mojang.brigadier.arguments.ArgumentType
|
||||
* javax.annotation.Nullable
|
||||
* org.bukkit.Bukkit
|
||||
* org.bukkit.entity.Player
|
||||
*/
|
||||
package de.maxhenkel.voicechat.compatibility;
|
||||
|
||||
import com.mojang.brigadier.arguments.ArgumentType;
|
||||
import de.maxhenkel.voicechat.compatibility.FallbackCompatibility;
|
||||
import de.maxhenkel.voicechat.compatibility.ReflectionUtils;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Method;
|
||||
import javax.annotation.Nullable;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class SpigotCompatibility
|
||||
extends FallbackCompatibility {
|
||||
public static final SpigotCompatibility INSTANCE = new SpigotCompatibility();
|
||||
private MessageSender messageSender;
|
||||
|
||||
@Override
|
||||
public void init() throws Exception {
|
||||
super.init();
|
||||
Class<?> playerSpigotClass = ReflectionUtils.getClazz("org.bukkit.entity.Player$Spigot");
|
||||
Class<?> baseComponentClass = ReflectionUtils.getClazz("net.md_5.bungee.api.chat.BaseComponent");
|
||||
Class<?> chatMessageTypeClass = ReflectionUtils.getClazz("net.md_5.bungee.api.ChatMessageType");
|
||||
Object systemType = ReflectionUtils.getField(chatMessageTypeClass, "SYSTEM");
|
||||
Object actionBarType = ReflectionUtils.getField(chatMessageTypeClass, "ACTION_BAR");
|
||||
Method playerSpigot = ReflectionUtils.getMethod(Player.class, "spigot");
|
||||
Method sendMessage = ReflectionUtils.getMethod(playerSpigotClass, new String[]{"sendMessage"}, new Class[]{chatMessageTypeClass, baseComponentClass});
|
||||
Class<?> translatableComponentClass = ReflectionUtils.getClazz("net.md_5.bungee.api.chat.TranslatableComponent");
|
||||
Constructor<?> translatableComponentConstructor = ReflectionUtils.getConstructor(translatableComponentClass, String.class, Object[].class);
|
||||
this.messageSender = (player, actionBar, key, args) -> {
|
||||
Object messageType = actionBar ? actionBarType : systemType;
|
||||
ReflectionUtils.call(sendMessage, ReflectionUtils.call(playerSpigot, player, new Object[0]), messageType, ReflectionUtils.newInstance(translatableComponentConstructor, key, args));
|
||||
};
|
||||
}
|
||||
|
||||
public static boolean isSpigotCompatible() {
|
||||
return ReflectionUtils.doesMethodExist(Bukkit.class, "spigot", new Class[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendTranslationMessage(Player player, String key, String ... args) {
|
||||
this.messageSender.send(player, false, key, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendStatusMessage(Player player, String key, String ... args) {
|
||||
this.messageSender.send(player, true, key, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public ArgumentType<?> playerArgument() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public ArgumentType<?> uuidArgument() {
|
||||
return null;
|
||||
}
|
||||
|
||||
private static interface MessageSender {
|
||||
public void send(Player var1, boolean var2, String var3, String ... var4);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user