use of com.earth2me.essentials.metrics.MetricsWrapper in project Essentials by drtshock.
the class EssentialsDiscord method onEnable.
@Override
public void onEnable() {
ess = (IEssentials) getServer().getPluginManager().getPlugin("Essentials");
if (ess == null || !ess.isEnabled()) {
setEnabled(false);
return;
}
if (!getDescription().getVersion().equals(ess.getDescription().getVersion())) {
getLogger().log(Level.WARNING, tl("versionMismatchAll"));
}
// JDK-8274349 - Mitigation for a regression in Java 17 on 1 core systems which was fixed in 17.0.2
final String[] javaVersion = System.getProperty("java.version").split("\\.");
if (Runtime.getRuntime().availableProcessors() <= 1 && javaVersion[0].startsWith("17") && (javaVersion.length < 2 || (javaVersion[1].equals("0") && javaVersion[2].startsWith("1")))) {
logger.log(Level.INFO, "Essentials is mitigating JDK-8274349");
System.setProperty("java.util.concurrent.ForkJoinPool.common.parallelism", "1");
}
isPAPI = getServer().getPluginManager().getPlugin("PlaceholderAPI") != null;
settings = new DiscordSettings(this);
ess.addReloadListener(settings);
if (metrics == null) {
metrics = new MetricsWrapper(this, 9824, false);
}
if (jda == null) {
jda = new JDADiscordService(this);
try {
jda.startup();
ess.scheduleSyncDelayedTask(() -> ((InteractionControllerImpl) jda.getInteractionController()).processBatchRegistration());
} catch (Exception e) {
logger.log(Level.SEVERE, tl("discordErrorLogin", e.getMessage()));
if (ess.getSettings().isDebug()) {
e.printStackTrace();
}
jda.shutdown();
}
}
}
Aggregations