Search in sources :

Example 1 with BasePotionDataProvider

use of net.ess3.provider.providers.BasePotionDataProvider 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 2 with BasePotionDataProvider

use of net.ess3.provider.providers.BasePotionDataProvider in project Essentials by drtshock.

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)

Aggregations

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 MetricsWrapper (com.earth2me.essentials.metrics.MetricsWrapper)2 PermissionsDefaults (com.earth2me.essentials.perm.PermissionsDefaults)2 PermissionsHandler (com.earth2me.essentials.perm.PermissionsHandler)2 SignBlockListener (com.earth2me.essentials.signs.SignBlockListener)2 SignEntityListener (com.earth2me.essentials.signs.SignEntityListener)2 SignPlayerListener (com.earth2me.essentials.signs.SignPlayerListener)2 IText (com.earth2me.essentials.textreader.IText)2