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