Search in sources :

Example 16 with MetricsWrapper

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();
        }
    }
}
Also used : MetricsWrapper(com.earth2me.essentials.metrics.MetricsWrapper)

Aggregations

MetricsWrapper (com.earth2me.essentials.metrics.MetricsWrapper)16 PluginManager (org.bukkit.plugin.PluginManager)14 Plugin (org.bukkit.plugin.Plugin)6 JavaPlugin (org.bukkit.plugin.java.JavaPlugin)6 EventPriority (org.bukkit.event.EventPriority)4 PlayerJoinEvent (org.bukkit.event.player.PlayerJoinEvent)4 I18n.tl (com.earth2me.essentials.I18n.tl)2 EssentialsCommand (com.earth2me.essentials.commands.EssentialsCommand)2 IEssentialsCommand (com.earth2me.essentials.commands.IEssentialsCommand)2 NoChargeException (com.earth2me.essentials.commands.NoChargeException)2 NotEnoughArgumentsException (com.earth2me.essentials.commands.NotEnoughArgumentsException)2 PlayerNotFoundException (com.earth2me.essentials.commands.PlayerNotFoundException)2 QuietAbortException (com.earth2me.essentials.commands.QuietAbortException)2 EconomyLayers (com.earth2me.essentials.economy.EconomyLayers)2 VaultEconomyProvider (com.earth2me.essentials.economy.vault.VaultEconomyProvider)2 AbstractItemDb (com.earth2me.essentials.items.AbstractItemDb)2 CustomItemResolver (com.earth2me.essentials.items.CustomItemResolver)2 FlatItemDb (com.earth2me.essentials.items.FlatItemDb)2 LegacyItemDb (com.earth2me.essentials.items.LegacyItemDb)2 PermissionsDefaults (com.earth2me.essentials.perm.PermissionsDefaults)2