Search in sources :

Example 1 with GlobalServerPlaceholderResolver

use of codecrafter47.bungeetablistplus.placeholder.GlobalServerPlaceholderResolver in project BungeeTabListPlus by CodeCrafter47.

the class BungeeTabListPlus method onEnable.

public void onEnable() {
    ConfigTabOverlayManager.Options options = ConfigTabOverlayManager.Options.createBuilderWithDefaults().playerIconDataKey(BTLPBungeeDataKeys.DATA_KEY_ICON).playerPingDataKey(BungeeData.BungeeCord_Ping).playerInvisibleDataKey(BTLPBungeeDataKeys.DATA_KEY_IS_HIDDEN).playerCanSeeInvisibleDataKey(MinecraftData.permission("bungeetablistplus.seevanished")).component(new ComponentSpec("!players_by_server", PlayersByServerComponentConfiguration.class)).sortingRulePreprocessor(new SortingRuleAliasProcessor()).build();
    yaml = ConfigTabOverlayManager.constructYamlInstance(options);
    if (readMainConfig())
        return;
    bungeePlayerProvider = new BungeePlayerProvider(mainThreadExecutor);
    hiddenPlayersManager = new HiddenPlayersManager();
    hiddenPlayersManager.addVanishProvider("/btlp hide", BTLPBungeeDataKeys.DATA_KEY_IS_HIDDEN_PLAYER_COMMAND);
    hiddenPlayersManager.addVanishProvider("config.yml (hiddenPlayers)", BTLPBungeeDataKeys.DATA_KEY_IS_HIDDEN_PLAYER_CONFIG);
    hiddenPlayersManager.addVanishProvider("config.yml (hiddenServers)", BTLPBungeeDataKeys.DATA_KEY_IS_HIDDEN_SERVER_CONFIG);
    hiddenPlayersManager.addVanishProvider("VanishNoPacket", BukkitData.VanishNoPacket_IsVanished);
    hiddenPlayersManager.addVanishProvider("SuperVanish", BukkitData.SuperVanish_IsVanished);
    hiddenPlayersManager.addVanishProvider("PremiumVanish (Bungee)", BungeeData.PremiumVanish_IsHidden);
    hiddenPlayersManager.addVanishProvider("CMI", BukkitData.CMI_IsVanished);
    hiddenPlayersManager.addVanishProvider("Essentials", BukkitData.Essentials_IsVanished);
    hiddenPlayersManager.addVanishProvider("ProxySuite", BungeeData.ProxyCore_IsHidden);
    hiddenPlayersManager.addVanishProvider("ProtocolVanish", BukkitData.ProtocolVanish_IsVanished);
    hiddenPlayersManager.addVanishProvider("Bukkit Player Metadata `vanished`", BukkitData.BukkitPlayerMetadataVanished);
    hiddenPlayersManager.addVanishProvider("Sponge VANISH", SpongeData.Sponge_IsVanished);
    hiddenPlayersManager.enable();
    fakePlayerManagerImpl = new FakePlayerManagerImpl(plugin, iconManager, mainThreadExecutor);
    List<PlayerProvider> playerProviders = new ArrayList<>();
    if (plugin.getProxy().getPluginManager().getPlugin("RedisBungee") != null) {
        redisPlayerManager = new RedisPlayerManager(bungeePlayerProvider, this, getLogger());
        playerProviders.add(redisPlayerManager);
        plugin.getLogger().info("Hooked RedisBungee");
    }
    playerProviders.add(bungeePlayerProvider);
    playerProviders.add(fakePlayerManagerImpl);
    this.playerProvider = new JoinedPlayerProvider(playerProviders);
    plugin.getProxy().registerChannel(BridgeProtocolConstants.CHANNEL);
    bukkitBridge = new BukkitBridge(asyncExecutor, mainThreadExecutor, playerPlaceholderResolver, serverPlaceholderResolver, getPlugin(), getLogger(), bungeePlayerProvider, this, cache);
    serverStateManager = new ServerStateManager(config, plugin);
    dataManager = new DataManager(api, this.getPlugin(), this.getLogger(), bungeePlayerProvider, mainThreadExecutor, hiddenPlayersManager, serverStateManager, bukkitBridge);
    updateExcludedAndHiddenServerLists();
    // register commands and update Notifier
    ProxyServer.getInstance().getPluginManager().registerCommand(plugin, new CommandBungeeTabListPlus());
    ProxyServer.getInstance().getScheduler().schedule(plugin, new UpdateNotifier(this), 15, 15, TimeUnit.MINUTES);
    // Start metrics
    Metrics metrics = new Metrics(plugin);
    // Load updateCheck thread
    if (config.checkForUpdates) {
        updateChecker = new UpdateChecker(plugin);
        plugin.getLogger().info("Starting UpdateChecker Task");
        plugin.getProxy().getScheduler().schedule(plugin, updateChecker, 0, UpdateChecker.interval, TimeUnit.MINUTES).getId();
    }
    int[] serversHash = { getProxy().getServers().hashCode() };
    getProxy().getScheduler().schedule(plugin, () -> {
        int hash = getProxy().getServers().hashCode();
        if (hash != serversHash[0]) {
            serversHash[0] = hash;
            scheduleSoftReload();
        }
    }, 1, 1, TimeUnit.MINUTES);
    MyPlatform platform = new MyPlatform();
    configTabOverlayManager = new ConfigTabOverlayManager(platform, playerProvider, playerPlaceholderResolver, ImmutableList.of(new ServerCountPlaceholderResolver(dataManager), new GlobalServerPlaceholderResolver(dataManager, serverPlaceholderResolver)), yaml, options, getLogger(), mainThreadExecutor, iconManager);
    spectatorPassthroughTabOverlayManager = new SpectatorPassthroughTabOverlayManager(platform, mainThreadExecutor, BTLPBungeeDataKeys.DATA_KEY_GAMEMODE);
    if (config.disableCustomTabListForSpectators) {
        spectatorPassthroughTabOverlayManager.enable();
    } else {
        spectatorPassthroughTabOverlayManager.disable();
    }
    updateTimeZoneAndGlobalCustomPlaceholders();
    Path tabLists = getPlugin().getDataFolder().toPath().resolve("tabLists");
    if (!Files.exists(tabLists)) {
        try {
            Files.createDirectories(tabLists);
        } catch (IOException e) {
            getLogger().log(Level.SEVERE, "Failed to create tabLists directory", e);
            return;
        }
        try {
            Files.copy(getClass().getClassLoader().getResourceAsStream("default.yml"), tabLists.resolve("default.yml"));
        } catch (IOException e) {
            plugin.getLogger().log(Level.WARNING, "Failed to save default config.", e);
        }
    }
    configTabOverlayManager.reloadConfigs(ImmutableSet.of(tabLists));
    ProxyServer.getInstance().getPluginManager().registerListener(plugin, new TabListListener(this));
}
Also used : BukkitBridge(codecrafter47.bungeetablistplus.bridge.BukkitBridge) ArrayList(java.util.ArrayList) CommandBungeeTabListPlus(codecrafter47.bungeetablistplus.command.CommandBungeeTabListPlus) UpdateNotifier(codecrafter47.bungeetablistplus.updater.UpdateNotifier) Metrics(org.bstats.bungeecord.Metrics) TabListListener(codecrafter47.bungeetablistplus.listener.TabListListener) JoinedPlayerProvider(de.codecrafter47.taboverlay.config.player.JoinedPlayerProvider) SortingRuleAliasProcessor(codecrafter47.bungeetablistplus.compat.SortingRuleAliasProcessor) PlayersByServerComponentConfiguration(codecrafter47.bungeetablistplus.config.PlayersByServerComponentConfiguration) ServerCountPlaceholderResolver(codecrafter47.bungeetablistplus.placeholder.ServerCountPlaceholderResolver) FakePlayerManagerImpl(codecrafter47.bungeetablistplus.player.FakePlayerManagerImpl) Path(java.nio.file.Path) ComponentSpec(de.codecrafter47.taboverlay.config.ComponentSpec) ConfigTabOverlayManager(de.codecrafter47.taboverlay.config.ConfigTabOverlayManager) GlobalServerPlaceholderResolver(codecrafter47.bungeetablistplus.placeholder.GlobalServerPlaceholderResolver) JoinedPlayerProvider(de.codecrafter47.taboverlay.config.player.JoinedPlayerProvider) PlayerProvider(de.codecrafter47.taboverlay.config.player.PlayerProvider) UpdateChecker(codecrafter47.bungeetablistplus.updater.UpdateChecker) SpectatorPassthroughTabOverlayManager(de.codecrafter47.taboverlay.spectator.SpectatorPassthroughTabOverlayManager)

Aggregations

BukkitBridge (codecrafter47.bungeetablistplus.bridge.BukkitBridge)1 CommandBungeeTabListPlus (codecrafter47.bungeetablistplus.command.CommandBungeeTabListPlus)1 SortingRuleAliasProcessor (codecrafter47.bungeetablistplus.compat.SortingRuleAliasProcessor)1 PlayersByServerComponentConfiguration (codecrafter47.bungeetablistplus.config.PlayersByServerComponentConfiguration)1 TabListListener (codecrafter47.bungeetablistplus.listener.TabListListener)1 GlobalServerPlaceholderResolver (codecrafter47.bungeetablistplus.placeholder.GlobalServerPlaceholderResolver)1 ServerCountPlaceholderResolver (codecrafter47.bungeetablistplus.placeholder.ServerCountPlaceholderResolver)1 FakePlayerManagerImpl (codecrafter47.bungeetablistplus.player.FakePlayerManagerImpl)1 UpdateChecker (codecrafter47.bungeetablistplus.updater.UpdateChecker)1 UpdateNotifier (codecrafter47.bungeetablistplus.updater.UpdateNotifier)1 ComponentSpec (de.codecrafter47.taboverlay.config.ComponentSpec)1 ConfigTabOverlayManager (de.codecrafter47.taboverlay.config.ConfigTabOverlayManager)1 JoinedPlayerProvider (de.codecrafter47.taboverlay.config.player.JoinedPlayerProvider)1 PlayerProvider (de.codecrafter47.taboverlay.config.player.PlayerProvider)1 SpectatorPassthroughTabOverlayManager (de.codecrafter47.taboverlay.spectator.SpectatorPassthroughTabOverlayManager)1 Path (java.nio.file.Path)1 ArrayList (java.util.ArrayList)1 Metrics (org.bstats.bungeecord.Metrics)1