Search in sources :

Example 66 with PluginManager

use of org.bukkit.plugin.PluginManager in project TotalFreedomMod by TotalFreedom.

the class Command_plugincontrol method run.

@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) {
    if (args.length == 0 || args.length > 2) {
        return false;
    }
    final PluginManager pm = server.getPluginManager();
    if (args.length == 1) {
        if (args[0].equalsIgnoreCase("list")) {
            for (Plugin serverPlugin : pm.getPlugins()) {
                final String version = serverPlugin.getDescription().getVersion();
                msg(ChatColor.GRAY + "- " + (serverPlugin.isEnabled() ? ChatColor.GREEN : ChatColor.RED) + serverPlugin.getName() + ChatColor.GOLD + (version != null && !version.isEmpty() ? " v" + version : "") + " by " + StringUtils.join(serverPlugin.getDescription().getAuthors(), ", "));
            }
            return true;
        }
        return false;
    }
    if ("enable".equals(args[0])) {
        final Plugin target = getPlugin(args[1]);
        if (target == null) {
            msg("Plugin not found!");
            return true;
        }
        if (target.isEnabled()) {
            msg("Plugin is already enabled.");
            return true;
        }
        pm.enablePlugin(target);
        if (!pm.isPluginEnabled(target)) {
            msg("Error enabling plugin " + target.getName());
            return true;
        }
        msg(target.getName() + " is now enabled.");
        return true;
    }
    if ("disable".equals(args[0])) {
        final Plugin target = getPlugin(args[1]);
        if (target == null) {
            msg("Plugin not found!");
            return true;
        }
        if (!target.isEnabled()) {
            msg("Plugin is already disabled.");
            return true;
        }
        if (target.getName().equals(plugin.getName())) {
            msg("You cannot disable " + plugin.getName());
            return true;
        }
        pm.disablePlugin(target);
        if (pm.isPluginEnabled(target)) {
            msg("Error disabling plugin " + target.getName());
            return true;
        }
        msg(target.getName() + " is now disabled.");
        return true;
    }
    if ("reload".equals(args[0])) {
        final Plugin target = getPlugin(args[1]);
        if (target == null) {
            msg("Plugin not found!");
            return true;
        }
        if (target.getName().equals(plugin.getName())) {
            msg("Use /tfm reload to reload instead.");
            return true;
        }
        pm.disablePlugin(target);
        pm.enablePlugin(target);
        msg(target.getName() + " reloaded.");
        return true;
    }
    return false;
}
Also used : PluginManager(org.bukkit.plugin.PluginManager) Plugin(org.bukkit.plugin.Plugin)

Example 67 with PluginManager

use of org.bukkit.plugin.PluginManager in project Essentials by EssentialsX.

the class Essentials method onEnable.

@Override
public void onEnable() {
    try {
        if (LOGGER != this.getLogger()) {
            LOGGER.setParent(this.getLogger());
        }
        execTimer = new ExecuteTimer();
        execTimer.start();
        i18n = new I18n(this);
        i18n.onEnable();
        execTimer.mark("I18n1");
        Console.setInstance(this);
        switch(VersionUtil.getServerSupportStatus()) {
            case NMS_CLEANROOM:
                getLogger().severe(tl("serverUnsupportedCleanroom"));
                break;
            case DANGEROUS_FORK:
                getLogger().severe(tl("serverUnsupportedDangerous"));
                break;
            case UNSTABLE:
                getLogger().severe(tl("serverUnsupportedMods"));
                break;
            case OUTDATED:
                getLogger().severe(tl("serverUnsupported"));
                break;
            case LIMITED:
                getLogger().info(tl("serverUnsupportedLimitedApi"));
                break;
        }
        if (VersionUtil.getSupportStatusClass() != null) {
            getLogger().info(tl("serverUnsupportedClass", VersionUtil.getSupportStatusClass()));
        }
        final PluginManager pm = getServer().getPluginManager();
        for (final Plugin plugin : pm.getPlugins()) {
            if (plugin.getDescription().getName().startsWith("Essentials") && !plugin.getDescription().getVersion().equals(this.getDescription().getVersion()) && !plugin.getDescription().getName().equals("EssentialsAntiCheat")) {
                getLogger().warning(tl("versionMismatch", plugin.getDescription().getName()));
            }
        }
        final EssentialsUpgrade upgrade = new EssentialsUpgrade(this);
        upgrade.beforeSettings();
        execTimer.mark("Upgrade");
        confList = new ArrayList<>();
        settings = new Settings(this);
        confList.add(settings);
        execTimer.mark("Settings");
        mail = new MailServiceImpl(this);
        execTimer.mark("Init(Mail)");
        userMap = new UserMap(this);
        confList.add(userMap);
        execTimer.mark("Init(Usermap)");
        balanceTop = new BalanceTopImpl(this);
        execTimer.mark("Init(BalanceTop)");
        kits = new Kits(this);
        confList.add(kits);
        upgrade.convertKits();
        execTimer.mark("Kits");
        upgrade.afterSettings();
        execTimer.mark("Upgrade2");
        warps = new Warps(this.getDataFolder());
        confList.add(warps);
        execTimer.mark("Init(Warp)");
        worth = new Worth(this.getDataFolder());
        confList.add(worth);
        execTimer.mark("Init(Worth)");
        itemDb = getItemDbFromConfig();
        confList.add(itemDb);
        execTimer.mark("Init(ItemDB)");
        randomTeleport = new RandomTeleport(this);
        if (randomTeleport.getPreCache()) {
            randomTeleport.cacheRandomLocations(randomTeleport.getCenter(), randomTeleport.getMinRange(), randomTeleport.getMaxRange());
        }
        confList.add(randomTeleport);
        execTimer.mark("Init(RandomTeleport)");
        customItemResolver = new CustomItemResolver(this);
        try {
            itemDb.registerResolver(this, "custom_items", customItemResolver);
            confList.add(customItemResolver);
        } catch (final Exception e) {
            e.printStackTrace();
            customItemResolver = null;
        }
        execTimer.mark("Init(CustomItemResolver)");
        jails = new Jails(this);
        confList.add(jails);
        execTimer.mark("Init(Jails)");
        EconomyLayers.onEnable(this);
        // Spawner item provider only uses one but it's here for legacy...
        spawnerItemProvider = new BlockMetaSpawnerItemProvider();
        // Spawner block providers
        if (VersionUtil.getServerBukkitVersion().isLowerThan(VersionUtil.v1_12_0_R01)) {
            spawnerBlockProvider = new ReflSpawnerBlockProvider();
        } else {
            spawnerBlockProvider = new BukkitSpawnerBlockProvider();
        }
        // Spawn Egg Providers
        if (VersionUtil.getServerBukkitVersion().isLowerThan(VersionUtil.v1_9_R01)) {
            spawnEggProvider = new LegacySpawnEggProvider();
        } else if (VersionUtil.getServerBukkitVersion().isLowerThanOrEqualTo(VersionUtil.v1_12_2_R01)) {
            spawnEggProvider = new ReflSpawnEggProvider();
        } else {
            spawnEggProvider = new FlatSpawnEggProvider();
        }
        // Potion Meta Provider
        if (VersionUtil.getServerBukkitVersion().isLowerThan(VersionUtil.v1_9_R01)) {
            potionMetaProvider = new LegacyPotionMetaProvider();
        } else {
            potionMetaProvider = new BasePotionDataProvider();
        }
        // Container Provider
        if (PaperLib.isPaper() && VersionUtil.getServerBukkitVersion().isHigherThanOrEqualTo(VersionUtil.v1_15_2_R01)) {
            serverStateProvider = new PaperServerStateProvider();
            containerProvider = new PaperContainerProvider();
            serializationProvider = new PaperSerializationProvider();
        } else {
            serverStateProvider = new ReflServerStateProvider();
        }
        // Event Providers
        if (PaperLib.isPaper()) {
            try {
                Class.forName("com.destroystokyo.paper.event.player.PlayerRecipeBookClickEvent");
                recipeBookEventProvider = new PaperRecipeBookListener(event -> {
                    if (this.getUser(((PlayerEvent) event).getPlayer()).isRecipeSee()) {
                        ((Cancellable) event).setCancelled(true);
                    }
                });
            } catch (final ClassNotFoundException ignored) {
            }
        }
        // Known Commands Provider
        if (PaperLib.isPaper() && VersionUtil.getServerBukkitVersion().isHigherThanOrEqualTo(VersionUtil.v1_11_2_R01)) {
            knownCommandsProvider = new PaperKnownCommandsProvider();
        } else {
            knownCommandsProvider = new ReflKnownCommandsProvider();
        }
        // Command aliases provider
        formattedCommandAliasProvider = new ReflFormattedCommandAliasProvider(PaperLib.isPaper());
        // Material Tag Providers
        if (VersionUtil.getServerBukkitVersion().isHigherThanOrEqualTo(VersionUtil.v1_13_0_R01)) {
            materialTagProvider = PaperLib.isPaper() ? new PaperMaterialTagProvider() : new BukkitMaterialTagProvider();
        }
        // Sync Commands Provider
        syncCommandsProvider = new ReflSyncCommandsProvider();
        if (VersionUtil.getServerBukkitVersion().isHigherThanOrEqualTo(VersionUtil.v1_14_4_R01)) {
            persistentDataProvider = new ModernPersistentDataProvider(this);
        } else {
            persistentDataProvider = new ReflPersistentDataProvider(this);
        }
        onlineModeProvider = new ReflOnlineModeProvider();
        if (VersionUtil.getServerBukkitVersion().isHigherThanOrEqualTo(VersionUtil.v1_11_2_R01)) {
            unbreakableProvider = new ModernItemUnbreakableProvider();
        } else {
            unbreakableProvider = new LegacyItemUnbreakableProvider();
        }
        if (VersionUtil.getServerBukkitVersion().isHigherThanOrEqualTo(VersionUtil.v1_17_1_R01)) {
            worldInfoProvider = new ModernDataWorldInfoProvider();
        } else if (VersionUtil.getServerBukkitVersion().isHigherThanOrEqualTo(VersionUtil.v1_16_5_R01)) {
            worldInfoProvider = new ReflDataWorldInfoProvider();
        } else {
            worldInfoProvider = new FixedHeightWorldInfoProvider();
        }
        if (VersionUtil.getServerBukkitVersion().isHigherThanOrEqualTo(VersionUtil.v1_14_4_R01)) {
            signDataProvider = new ModernSignDataProvider(this);
        }
        execTimer.mark("Init(Providers)");
        reload();
        // The item spawn blacklist is loaded with all other settings, before the item
        // DB, but it depends on the item DB, so we need to reload it again here:
        ((Settings) settings)._lateLoadItemSpawnBlacklist();
        backup = new Backup(this);
        permissionsHandler = new PermissionsHandler(this, settings.useBukkitPermissions());
        alternativeCommandsHandler = new AlternativeCommandsHandler(this);
        timer = new EssentialsTimer(this);
        scheduleSyncRepeatingTask(timer, 1000, 50);
        Economy.setEss(this);
        execTimer.mark("RegHandler");
        // Register /hat and /back default permissions
        PermissionsDefaults.registerAllBackDefaults();
        PermissionsDefaults.registerAllHatDefaults();
        updateChecker = new UpdateChecker(this);
        runTaskAsynchronously(() -> {
            getLogger().log(Level.INFO, tl("versionFetching"));
            for (String str : updateChecker.getVersionMessages(false, true)) {
                getLogger().log(getSettings().isUpdateCheckEnabled() ? Level.WARNING : Level.INFO, str);
            }
        });
        metrics = new MetricsWrapper(this, 858, true);
        execTimer.mark("Init(External)");
        final String timeroutput = execTimer.end();
        if (getSettings().isDebug()) {
            LOGGER.log(Level.INFO, "Essentials load {0}", timeroutput);
        }
    } catch (final NumberFormatException ex) {
        handleCrash(ex);
    } catch (final Error ex) {
        handleCrash(ex);
        throw ex;
    }
    getBackup().setPendingShutdown(false);
}
Also used : LegacyPotionMetaProvider(net.ess3.provider.providers.LegacyPotionMetaProvider) PaperKnownCommandsProvider(net.ess3.provider.providers.PaperKnownCommandsProvider) TabCompleter(org.bukkit.command.TabCompleter) ServerStateProvider(net.ess3.provider.ServerStateProvider) VersionUtil(com.earth2me.essentials.utils.VersionUtil) IItemDb(net.ess3.api.IItemDb) BalanceTop(net.essentialsx.api.v2.services.BalanceTop) FlatItemDb(com.earth2me.essentials.items.FlatItemDb) World(org.bukkit.World) Map(java.util.Map) MetricsWrapper(com.earth2me.essentials.metrics.MetricsWrapper) NotEnoughArgumentsException(com.earth2me.essentials.commands.NotEnoughArgumentsException) PersistentDataProvider(net.ess3.provider.PersistentDataProvider) Economy(net.ess3.api.Economy) CommandSender(org.bukkit.command.CommandSender) ReflSpawnEggProvider(net.ess3.nms.refl.providers.ReflSpawnEggProvider) SerializationProvider(net.ess3.provider.SerializationProvider) PermissionsHandler(com.earth2me.essentials.perm.PermissionsHandler) PlayerNotFoundException(com.earth2me.essentials.commands.PlayerNotFoundException) Set(java.util.Set) BasePotionDataProvider(net.ess3.provider.providers.BasePotionDataProvider) CustomItemResolver(com.earth2me.essentials.items.CustomItemResolver) SignBlockListener(com.earth2me.essentials.signs.SignBlockListener) JavaPluginLoader(org.bukkit.plugin.java.JavaPluginLoader) PaperServerStateProvider(net.ess3.provider.providers.PaperServerStateProvider) MaterialTagProvider(net.ess3.provider.MaterialTagProvider) FormatUtil(com.earth2me.essentials.utils.FormatUtil) SpawnerBlockProvider(net.ess3.provider.SpawnerBlockProvider) IJails(net.ess3.api.IJails) FormattedCommandAliasProvider(net.ess3.provider.FormattedCommandAliasProvider) HandlerList(org.bukkit.event.HandlerList) EconomyLayers(com.earth2me.essentials.economy.EconomyLayers) SpawnerItemProvider(net.ess3.provider.SpawnerItemProvider) ReflServerStateProvider(net.ess3.nms.refl.providers.ReflServerStateProvider) PaperContainerProvider(net.ess3.provider.providers.PaperContainerProvider) ArrayList(java.util.ArrayList) SimpleTextInput(com.earth2me.essentials.textreader.SimpleTextInput) SignPlayerListener(com.earth2me.essentials.signs.SignPlayerListener) ModernSignDataProvider(net.ess3.provider.providers.ModernSignDataProvider) IText(com.earth2me.essentials.textreader.IText) Server(org.bukkit.Server) ReflSpawnerBlockProvider(net.ess3.nms.refl.providers.ReflSpawnerBlockProvider) ReflOnlineModeProvider(net.ess3.nms.refl.providers.ReflOnlineModeProvider) LinkedHashSet(java.util.LinkedHashSet) IEssentialsCommand(com.earth2me.essentials.commands.IEssentialsCommand) QuietAbortException(com.earth2me.essentials.commands.QuietAbortException) BukkitScheduler(org.bukkit.scheduler.BukkitScheduler) LegacyItemDb(com.earth2me.essentials.items.LegacyItemDb) WorldInfoProvider(net.ess3.provider.WorldInfoProvider) IOException(java.io.IOException) BukkitMaterialTagProvider(net.ess3.provider.providers.BukkitMaterialTagProvider) ReflKnownCommandsProvider(net.ess3.nms.refl.providers.ReflKnownCommandsProvider) FlatSpawnEggProvider(net.ess3.provider.providers.FlatSpawnEggProvider) IEssentials(net.ess3.api.IEssentials) File(java.io.File) BlockMetaSpawnerItemProvider(net.ess3.provider.providers.BlockMetaSpawnerItemProvider) EssentialsCommand(com.earth2me.essentials.commands.EssentialsCommand) BlockCommandSender(org.bukkit.command.BlockCommandSender) EventPriority(org.bukkit.event.EventPriority) SignDataProvider(net.ess3.provider.SignDataProvider) KeywordReplacer(com.earth2me.essentials.textreader.KeywordReplacer) ReflDataWorldInfoProvider(net.ess3.nms.refl.providers.ReflDataWorldInfoProvider) PluginDescriptionFile(org.bukkit.plugin.PluginDescriptionFile) PluginManager(org.bukkit.plugin.PluginManager) Plugin(org.bukkit.plugin.Plugin) ItemUnbreakableProvider(net.ess3.provider.ItemUnbreakableProvider) LegacyItemUnbreakableProvider(net.ess3.provider.providers.LegacyItemUnbreakableProvider) Player(org.bukkit.entity.Player) PaperLib(io.papermc.lib.PaperLib) EventHandler(org.bukkit.event.EventHandler) SpawnEggProvider(net.ess3.provider.SpawnEggProvider) LegacySpawnEggProvider(net.ess3.provider.providers.LegacySpawnEggProvider) Block(org.bukkit.block.Block) Locale(java.util.Locale) KnownCommandsProvider(net.ess3.provider.KnownCommandsProvider) Bukkit(org.bukkit.Bukkit) I18n.tl(com.earth2me.essentials.I18n.tl) PlayerJoinEvent(org.bukkit.event.player.PlayerJoinEvent) ServicePriority(org.bukkit.plugin.ServicePriority) ReflSyncCommandsProvider(net.ess3.nms.refl.providers.ReflSyncCommandsProvider) LegacyPotionMetaProvider(net.ess3.provider.providers.LegacyPotionMetaProvider) Predicate(java.util.function.Predicate) Collection(java.util.Collection) ReflFormattedCommandAliasProvider(net.ess3.nms.refl.providers.ReflFormattedCommandAliasProvider) PaperSerializationProvider(net.ess3.provider.providers.PaperSerializationProvider) UUID(java.util.UUID) Logger(java.util.logging.Logger) UpdateChecker(com.earth2me.essentials.updatecheck.UpdateChecker) PluginCommand(org.bukkit.command.PluginCommand) BukkitSpawnerBlockProvider(net.ess3.provider.providers.BukkitSpawnerBlockProvider) JavaPlugin(org.bukkit.plugin.java.JavaPlugin) ModernDataWorldInfoProvider(net.ess3.provider.providers.ModernDataWorldInfoProvider) List(java.util.List) BukkitTask(org.bukkit.scheduler.BukkitTask) Command(org.bukkit.command.Command) PotionMetaProvider(net.ess3.provider.PotionMetaProvider) SyncCommandsProvider(net.ess3.provider.SyncCommandsProvider) AbstractItemDb(com.earth2me.essentials.items.AbstractItemDb) Cancellable(org.bukkit.event.Cancellable) SignEntityListener(com.earth2me.essentials.signs.SignEntityListener) ModernItemUnbreakableProvider(net.ess3.provider.providers.ModernItemUnbreakableProvider) WorldLoadEvent(org.bukkit.event.world.WorldLoadEvent) HashMap(java.util.HashMap) ReflPersistentDataProvider(net.ess3.nms.refl.providers.ReflPersistentDataProvider) Level(java.util.logging.Level) FixedHeightWorldInfoProvider(net.ess3.provider.providers.FixedHeightWorldInfoProvider) NoChargeException(com.earth2me.essentials.commands.NoChargeException) ProviderListener(net.ess3.provider.ProviderListener) InvalidDescriptionException(org.bukkit.plugin.InvalidDescriptionException) Listener(org.bukkit.event.Listener) VaultEconomyProvider(com.earth2me.essentials.economy.vault.VaultEconomyProvider) PermissionsDefaults(com.earth2me.essentials.perm.PermissionsDefaults) PluginIdentifiableCommand(org.bukkit.command.PluginIdentifiableCommand) ModernPersistentDataProvider(net.ess3.provider.providers.ModernPersistentDataProvider) PaperRecipeBookListener(net.ess3.provider.providers.PaperRecipeBookListener) ContainerProvider(net.ess3.provider.ContainerProvider) PaperMaterialTagProvider(net.ess3.provider.providers.PaperMaterialTagProvider) MailService(net.essentialsx.api.v2.services.mail.MailService) PlayerEvent(org.bukkit.event.player.PlayerEvent) ISettings(net.ess3.api.ISettings) Collections(java.util.Collections) PaperSerializationProvider(net.ess3.provider.providers.PaperSerializationProvider) ReflSyncCommandsProvider(net.ess3.nms.refl.providers.ReflSyncCommandsProvider) ReflSpawnerBlockProvider(net.ess3.nms.refl.providers.ReflSpawnerBlockProvider) FixedHeightWorldInfoProvider(net.ess3.provider.providers.FixedHeightWorldInfoProvider) BlockMetaSpawnerItemProvider(net.ess3.provider.providers.BlockMetaSpawnerItemProvider) BasePotionDataProvider(net.ess3.provider.providers.BasePotionDataProvider) PaperServerStateProvider(net.ess3.provider.providers.PaperServerStateProvider) PluginManager(org.bukkit.plugin.PluginManager) LegacySpawnEggProvider(net.ess3.provider.providers.LegacySpawnEggProvider) PaperMaterialTagProvider(net.ess3.provider.providers.PaperMaterialTagProvider) PermissionsHandler(com.earth2me.essentials.perm.PermissionsHandler) ReflFormattedCommandAliasProvider(net.ess3.nms.refl.providers.ReflFormattedCommandAliasProvider) ISettings(net.ess3.api.ISettings) ModernPersistentDataProvider(net.ess3.provider.providers.ModernPersistentDataProvider) ModernItemUnbreakableProvider(net.ess3.provider.providers.ModernItemUnbreakableProvider) ReflSpawnEggProvider(net.ess3.nms.refl.providers.ReflSpawnEggProvider) ModernDataWorldInfoProvider(net.ess3.provider.providers.ModernDataWorldInfoProvider) LegacyItemUnbreakableProvider(net.ess3.provider.providers.LegacyItemUnbreakableProvider) BukkitMaterialTagProvider(net.ess3.provider.providers.BukkitMaterialTagProvider) IJails(net.ess3.api.IJails) ReflOnlineModeProvider(net.ess3.nms.refl.providers.ReflOnlineModeProvider) ModernSignDataProvider(net.ess3.provider.providers.ModernSignDataProvider) MetricsWrapper(com.earth2me.essentials.metrics.MetricsWrapper) UpdateChecker(com.earth2me.essentials.updatecheck.UpdateChecker) ReflServerStateProvider(net.ess3.nms.refl.providers.ReflServerStateProvider) PaperRecipeBookListener(net.ess3.provider.providers.PaperRecipeBookListener) ReflPersistentDataProvider(net.ess3.nms.refl.providers.ReflPersistentDataProvider) PaperKnownCommandsProvider(net.ess3.provider.providers.PaperKnownCommandsProvider) NotEnoughArgumentsException(com.earth2me.essentials.commands.NotEnoughArgumentsException) PlayerNotFoundException(com.earth2me.essentials.commands.PlayerNotFoundException) QuietAbortException(com.earth2me.essentials.commands.QuietAbortException) IOException(java.io.IOException) NoChargeException(com.earth2me.essentials.commands.NoChargeException) InvalidDescriptionException(org.bukkit.plugin.InvalidDescriptionException) CustomItemResolver(com.earth2me.essentials.items.CustomItemResolver) ReflDataWorldInfoProvider(net.ess3.nms.refl.providers.ReflDataWorldInfoProvider) PaperContainerProvider(net.ess3.provider.providers.PaperContainerProvider) ReflKnownCommandsProvider(net.ess3.nms.refl.providers.ReflKnownCommandsProvider) FlatSpawnEggProvider(net.ess3.provider.providers.FlatSpawnEggProvider) BukkitSpawnerBlockProvider(net.ess3.provider.providers.BukkitSpawnerBlockProvider) Plugin(org.bukkit.plugin.Plugin) JavaPlugin(org.bukkit.plugin.java.JavaPlugin)

Example 68 with PluginManager

use of org.bukkit.plugin.PluginManager in project Essentials by EssentialsX.

the class EssentialsSpawn method onEnable.

@Override
public void onEnable() {
    final PluginManager pluginManager = getServer().getPluginManager();
    ess = (IEssentials) pluginManager.getPlugin("Essentials");
    if (!this.getDescription().getVersion().equals(ess.getDescription().getVersion())) {
        getLogger().log(Level.WARNING, tl("versionMismatchAll"));
    }
    if (!ess.isEnabled()) {
        this.setEnabled(false);
        return;
    }
    spawns = new SpawnStorage(ess);
    ess.addReloadListener(spawns);
    final EssentialsSpawnPlayerListener playerListener = new EssentialsSpawnPlayerListener(ess, spawns);
    final EventPriority respawnPriority = ess.getSettings().getRespawnPriority();
    if (respawnPriority != null) {
        pluginManager.registerEvent(PlayerRespawnEvent.class, playerListener, respawnPriority, (ll, event) -> ((EssentialsSpawnPlayerListener) ll).onPlayerRespawn((PlayerRespawnEvent) event), this);
    }
    final EventPriority joinPriority = ess.getSettings().getSpawnJoinPriority();
    if (joinPriority != null) {
        pluginManager.registerEvent(PlayerJoinEvent.class, playerListener, joinPriority, (ll, event) -> ((EssentialsSpawnPlayerListener) ll).onPlayerJoin((PlayerJoinEvent) event), this);
    }
    if (metrics == null) {
        metrics = new MetricsWrapper(this, 3817, true);
    }
}
Also used : PluginManager(org.bukkit.plugin.PluginManager) PlayerJoinEvent(org.bukkit.event.player.PlayerJoinEvent) PlayerRespawnEvent(org.bukkit.event.player.PlayerRespawnEvent) MetricsWrapper(com.earth2me.essentials.metrics.MetricsWrapper) EventPriority(org.bukkit.event.EventPriority)

Example 69 with PluginManager

use of org.bukkit.plugin.PluginManager in project Essentials by EssentialsX.

the class EssentialsXMPP method onEnable.

@Override
public void onEnable() {
    instance = this;
    final PluginManager pluginManager = getServer().getPluginManager();
    ess = (IEssentials) pluginManager.getPlugin("Essentials");
    if (!this.getDescription().getVersion().equals(ess.getDescription().getVersion())) {
        getLogger().log(Level.WARNING, tl("versionMismatchAll"));
    }
    if (!ess.isEnabled()) {
        this.setEnabled(false);
        return;
    }
    final EssentialsXMPPPlayerListener playerListener = new EssentialsXMPPPlayerListener(ess);
    pluginManager.registerEvents(playerListener, this);
    users = new UserManager(this.getDataFolder());
    xmpp = new XMPPManager(this);
    ess.addReloadListener(users);
    ess.addReloadListener(xmpp);
    if (metrics == null) {
        metrics = new MetricsWrapper(this, 3818, true);
        metrics.addCustomChart(new SimplePie("config-valid", () -> xmpp.isConfigValid() ? "yes" : "no"));
    }
}
Also used : PluginManager(org.bukkit.plugin.PluginManager) SimplePie(org.bstats.charts.SimplePie) MetricsWrapper(com.earth2me.essentials.metrics.MetricsWrapper)

Example 70 with PluginManager

use of org.bukkit.plugin.PluginManager in project Essentials by EssentialsX.

the class EssentialsAntiBuild method onEnable.

@Override
public void onEnable() {
    final PluginManager pm = this.getServer().getPluginManager();
    final Plugin essPlugin = pm.getPlugin("Essentials");
    if (essPlugin == null || !essPlugin.isEnabled()) {
        return;
    }
    ess = new EssentialsConnect(essPlugin, this);
    final EssentialsAntiBuildListener blockListener = new EssentialsAntiBuildListener(this);
    pm.registerEvents(blockListener, this);
    if (metrics == null) {
        metrics = new MetricsWrapper(this, 3813, false);
    }
}
Also used : PluginManager(org.bukkit.plugin.PluginManager) MetricsWrapper(com.earth2me.essentials.metrics.MetricsWrapper) Plugin(org.bukkit.plugin.Plugin) JavaPlugin(org.bukkit.plugin.java.JavaPlugin)

Aggregations

PluginManager (org.bukkit.plugin.PluginManager)94 Plugin (org.bukkit.plugin.Plugin)22 MetricsWrapper (com.earth2me.essentials.metrics.MetricsWrapper)14 Permission (org.bukkit.permissions.Permission)13 Test (org.junit.Test)13 SimplePluginManager (org.bukkit.plugin.SimplePluginManager)12 JavaPlugin (org.bukkit.plugin.java.JavaPlugin)12 Map (java.util.Map)10 Player (org.bukkit.entity.Player)10 HashMap (java.util.HashMap)7 World (org.bukkit.World)7 Command (org.bukkit.command.Command)7 PluginCommand (org.bukkit.command.PluginCommand)6 EventHandler (org.bukkit.event.EventHandler)6 Listener (org.bukkit.event.Listener)6 PlayerJoinEvent (org.bukkit.event.player.PlayerJoinEvent)6 PluginDescriptionFile (org.bukkit.plugin.PluginDescriptionFile)6 File (java.io.File)5 Set (java.util.Set)5 Material (org.bukkit.Material)5