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

69 lines
2.1 KiB
Java

/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* org.bukkit.plugin.Plugin
*/
package de.maxhenkel.voicechat.commodore;
import de.maxhenkel.voicechat.commodore.BrigadierUnsupportedException;
import de.maxhenkel.voicechat.commodore.Commodore;
import de.maxhenkel.voicechat.commodore.PaperCommodore;
import de.maxhenkel.voicechat.commodore.ReflectionCommodore;
import java.util.Objects;
import java.util.function.Function;
import org.bukkit.plugin.Plugin;
public final class CommodoreProvider {
private static final Function<Plugin, Commodore> PROVIDER = CommodoreProvider.checkSupported();
private CommodoreProvider() {
throw new AssertionError();
}
private static Function<Plugin, Commodore> checkSupported() {
try {
Class.forName("com.mojang.brigadier.CommandDispatcher");
}
catch (Throwable e) {
CommodoreProvider.printDebugInfo(e);
return null;
}
try {
PaperCommodore.ensureSetup();
return PaperCommodore::new;
}
catch (Throwable e) {
CommodoreProvider.printDebugInfo(e);
try {
ReflectionCommodore.ensureSetup();
return ReflectionCommodore::new;
}
catch (Throwable e2) {
CommodoreProvider.printDebugInfo(e2);
return null;
}
}
}
private static void printDebugInfo(Throwable e) {
if (System.getProperty("commodore.debug") != null) {
System.err.println("Exception while initialising commodore:");
e.printStackTrace(System.err);
}
}
public static boolean isSupported() {
return PROVIDER != null;
}
public static Commodore getCommodore(Plugin plugin) throws BrigadierUnsupportedException {
Objects.requireNonNull(plugin, "plugin");
if (PROVIDER == null) {
throw new BrigadierUnsupportedException("Brigadier is not supported by the server. Set -Dcommodore.debug=true for debug info.");
}
return PROVIDER.apply(plugin);
}
}