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));
}
Aggregations