Search in sources :

Example 1 with DataHolder

use of de.codecrafter47.data.api.DataHolder in project BungeeTabListPlus by CodeCrafter47.

the class PlayersByServerComponentView method onDeactivation.

@Override
protected void onDeactivation() {
    super.onDeactivation();
    if (showServers == PlayersByServerComponentConfiguration.ServerOptions.ONLINE) {
        for (String serverName : servers) {
            if (hiddenServers.contains(serverName)) {
                continue;
            }
            DataHolder serverDataHolder = BungeeTabListPlus.getInstance().getDataManager().getServerDataHolder(serverName);
            serverDataHolder.removeDataChangeListener(BTLPBungeeDataKeys.DATA_KEY_SERVER_ONLINE, onlineStateUpdateListener);
        }
    }
}
Also used : DataHolder(de.codecrafter47.data.api.DataHolder)

Example 2 with DataHolder

use of de.codecrafter47.data.api.DataHolder in project BungeeTabListPlus by CodeCrafter47.

the class PlayersByServerComponentView method updateOnlineServers.

private void updateOnlineServers() {
    for (String serverName : servers) {
        serverName = mergeSections.apply(serverName);
        if (hiddenServers.contains(serverName)) {
            continue;
        }
        DataHolder serverDataHolder = BungeeTabListPlus.getInstance().getDataManager().getServerDataHolder(serverName);
        serverDataHolder.addDataChangeListener(BTLPBungeeDataKeys.DATA_KEY_SERVER_ONLINE, onlineStateUpdateListener);
        Boolean online = serverDataHolder.get(BTLPBungeeDataKeys.DATA_KEY_SERVER_ONLINE);
        if (online == null) {
            online = true;
        }
        if (online && !persistentSections.contains(serverName)) {
            addPersistentSection(serverName, true);
        } else if (!online && persistentSections.contains(serverName)) {
            removePersistentSection(serverName, true);
        }
    }
}
Also used : DataHolder(de.codecrafter47.data.api.DataHolder)

Example 3 with DataHolder

use of de.codecrafter47.data.api.DataHolder 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."));
}
Also used : BukkitBridge(codecrafter47.bungeetablistplus.bridge.BukkitBridge) ServerInfo(net.md_5.bungee.api.config.ServerInfo) DataHolder(de.codecrafter47.data.api.DataHolder) ArrayList(java.util.ArrayList) UpdateChecker(codecrafter47.bungeetablistplus.updater.UpdateChecker)

Example 4 with DataHolder

use of de.codecrafter47.data.api.DataHolder in project BungeeTabListPlus by CodeCrafter47.

the class GlobalServerPlaceholderResolver method resolve.

@Nonnull
@Override
public PlaceholderBuilder<?, ?> resolve(PlaceholderBuilder<Context, ?> builder, List<PlaceholderArg> args, TemplateCreationContext tcc) throws UnknownPlaceholderException, PlaceholderException {
    if (args.size() >= 1 && args.get(0) instanceof PlaceholderArg.Text && args.get(0).getText().startsWith("server:")) {
        String serverName = args.remove(0).getText().substring(7);
        DataHolder serverDataHolder = dataManager.getServerDataHolder(serverName);
        return serverPlaceholderResolver.resolve(builder.transformContext(context -> serverDataHolder), args, tcc);
    }
    throw new UnknownPlaceholderException();
}
Also used : de.codecrafter47.taboverlay.config.placeholder(de.codecrafter47.taboverlay.config.placeholder) List(java.util.List) TemplateCreationContext(de.codecrafter47.taboverlay.config.template.TemplateCreationContext) DataManager(codecrafter47.bungeetablistplus.managers.DataManager) DataHolder(de.codecrafter47.data.api.DataHolder) Context(de.codecrafter47.taboverlay.config.context.Context) Nonnull(javax.annotation.Nonnull) DataHolder(de.codecrafter47.data.api.DataHolder) Nonnull(javax.annotation.Nonnull)

Aggregations

DataHolder (de.codecrafter47.data.api.DataHolder)4 BukkitBridge (codecrafter47.bungeetablistplus.bridge.BukkitBridge)1 DataManager (codecrafter47.bungeetablistplus.managers.DataManager)1 UpdateChecker (codecrafter47.bungeetablistplus.updater.UpdateChecker)1 Context (de.codecrafter47.taboverlay.config.context.Context)1 de.codecrafter47.taboverlay.config.placeholder (de.codecrafter47.taboverlay.config.placeholder)1 TemplateCreationContext (de.codecrafter47.taboverlay.config.template.TemplateCreationContext)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Nonnull (javax.annotation.Nonnull)1 ServerInfo (net.md_5.bungee.api.config.ServerInfo)1