use of codecrafter47.bungeetablistplus.updater.UpdateChecker 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));
}
use of codecrafter47.bungeetablistplus.updater.UpdateChecker in project BungeeTabListPlus by CodeCrafter47.
the class CommandBungeeTabListPlus method commandStatus.
private void commandStatus(CommandSender sender) {
// Version
String version = BungeeTabListPlus.getInstance().getPlugin().getDescription().getVersion();
sender.sendMessage(ChatUtil.parseBBCode("&eYou are running BungeeTabListPlus version " + version));
// Update?
sender.sendMessage(ChatUtil.parseBBCode("&eLooking for an update..."));
UpdateChecker updateChecker = new UpdateChecker(BungeeTabListPlus.getInstance().getPlugin());
updateChecker.run();
if (updateChecker.isUpdateAvailable()) {
sender.sendMessage(ChatUtil.parseBBCode("&aAn update is available at [url]http://www.spigotmc.org/resources/bungeetablistplus.313/[/url]"));
} else if (updateChecker.isNewDevBuildAvailable()) {
sender.sendMessage(ChatUtil.parseBBCode("&aA new dev-build is available at [url]https://ci.codecrafter47.de/job/BungeeTabListPlus/[/url]"));
} else {
sender.sendMessage(ChatUtil.parseBBCode("&aYou are already running the latest version."));
}
// Bridge plugin status
BukkitBridge bridge = BungeeTabListPlus.getInstance().getBridge();
List<ServerInfo> servers = new ArrayList<>(ProxyServer.getInstance().getServers().values());
List<String> withBridge = new ArrayList<>();
List<ServerInfo> withoutBridge = new ArrayList<>();
List<String> maybeBridge = new ArrayList<>();
for (ServerInfo server : servers) {
DataHolder dataHolder = bridge.getServerDataHolder(server.getName());
if (dataHolder != null && dataHolder.get(BTLPDataKeys.REGISTERED_THIRD_PARTY_VARIABLES) != null) {
withBridge.add(server.getName());
} else {
if (server.getPlayers().isEmpty()) {
maybeBridge.add(server.getName());
} else {
withoutBridge.add(server);
}
}
}
List<String> withPAPI = servers.stream().filter(server -> {
DataHolder dataHolder = bridge.getServerDataHolder(server.getName());
Boolean b;
return dataHolder != null && (b = dataHolder.get(BTLPDataKeys.PLACEHOLDERAPI_PRESENT)) != null && b;
}).map(ServerInfo::getName).collect(Collectors.toList());
sender.sendMessage(ChatUtil.parseBBCode("&eBridge plugin status:"));
if (!withBridge.isEmpty()) {
sender.sendMessage(ChatUtil.parseBBCode("&fInstalled on: &a" + Joiner.on("&f,&a ").join(withBridge)));
}
if (!withPAPI.isEmpty()) {
sender.sendMessage(ChatUtil.parseBBCode("&fServers with PlaceholderAPI: &a" + Joiner.on("&f, &a").join(withPAPI)));
}
for (ServerInfo server : withoutBridge) {
sender.sendMessage(ChatUtil.parseBBCode("&c" + server.getName() + "&f: " + bridge.getStatus(server)));
}
if (!maybeBridge.isEmpty()) {
sender.sendMessage(ChatUtil.parseBBCode("&eBridge status is not available for servers without players."));
}
// That's it
sender.sendMessage(ChatUtil.parseBBCode("&aThank you for using BungeeTabListPlus."));
}
Aggregations