Search in sources :

Example 1 with ExtensionData

use of com.djrapitops.plan.extension.implementation.results.ExtensionData in project Plan by plan-player-analytics.

the class PageFactory method inspectPluginTabs.

public PlayerPluginTab inspectPluginTabs(UUID playerUUID) {
    Database database = dbSystem.get().getDatabase();
    Map<ServerUUID, List<ExtensionData>> extensionPlayerData = database.query(new ExtensionPlayerDataQuery(playerUUID));
    if (extensionPlayerData.isEmpty()) {
        return new PlayerPluginTab("", Collections.emptyList(), formatters.get());
    }
    List<PlayerPluginTab> playerPluginTabs = new ArrayList<>();
    for (Map.Entry<ServerUUID, Server> entry : database.query(ServerQueries.fetchPlanServerInformation()).entrySet()) {
        ServerUUID serverUUID = entry.getKey();
        String serverName = entry.getValue().getIdentifiableName();
        List<ExtensionData> ofServer = extensionPlayerData.get(serverUUID);
        if (ofServer == null) {
            continue;
        }
        playerPluginTabs.add(new PlayerPluginTab(serverName, ofServer, formatters.get()));
    }
    StringBuilder navs = new StringBuilder();
    StringBuilder tabs = new StringBuilder();
    playerPluginTabs.stream().sorted().forEach(tab -> {
        navs.append(tab.getNav());
        tabs.append(tab.getTab());
    });
    return new PlayerPluginTab(navs.toString(), tabs.toString());
}
Also used : ServerUUID(com.djrapitops.plan.identification.ServerUUID) Server(com.djrapitops.plan.identification.Server) ExtensionData(com.djrapitops.plan.extension.implementation.results.ExtensionData) ExtensionPlayerDataQuery(com.djrapitops.plan.extension.implementation.storage.queries.ExtensionPlayerDataQuery) Database(com.djrapitops.plan.storage.database.Database)

Example 2 with ExtensionData

use of com.djrapitops.plan.extension.implementation.results.ExtensionData in project Plan by plan-player-analytics.

the class ServerPage method toHtml.

@Override
public String toHtml() {
    PlaceholderReplacer placeholders = new PlaceholderReplacer();
    ServerUUID serverUUID = server.getUuid();
    placeholders.put("serverUUID", serverUUID.toString());
    placeholders.put("serverName", server.getIdentifiableName());
    placeholders.put("serverDisplayName", server.getName());
    placeholders.put("refreshBarrier", config.get(WebserverSettings.REDUCED_REFRESH_BARRIER));
    placeholders.put("timeZone", config.getTimeZoneOffsetHours());
    placeholders.put("gmPieColors", theme.getValue(ThemeVal.GRAPH_GM_PIE));
    placeholders.put("contributors", Contributors.generateContributorHtml());
    placeholders.put("versionButton", versionChecker.getUpdateButton().orElse(versionChecker.getCurrentVersionButton()));
    placeholders.put("version", versionChecker.getCurrentVersion());
    placeholders.put("updateModal", versionChecker.getUpdateModal());
    CachingSupplier<ServerPluginTabs> pluginTabs = new CachingSupplier<>(() -> {
        List<ExtensionData> extensionData = dbSystem.getDatabase().query(new ExtensionServerDataQuery(serverUUID));
        return new ServerPluginTabs(extensionData, formatters);
    });
    long after = System.currentTimeMillis() - config.get(WebserverSettings.REDUCED_REFRESH_BARRIER);
    String navIdentifier = DataID.EXTENSION_NAV.of(serverUUID);
    String tabIdentifier = DataID.EXTENSION_TABS.of(serverUUID);
    String nav = jsonStorage.fetchJsonMadeAfter(navIdentifier, after).orElseGet(() -> {
        jsonStorage.invalidateOlder(navIdentifier, after);
        return jsonStorage.storeJson(navIdentifier, pluginTabs.get().getNav());
    }).json;
    String tabs = jsonStorage.fetchJsonMadeAfter(tabIdentifier, after).orElseGet(() -> {
        jsonStorage.invalidateOlder(tabIdentifier, after);
        return jsonStorage.storeJson(tabIdentifier, pluginTabs.get().getTabs());
    }).json;
    PlaceholderReplacer pluginPlaceholders = new PlaceholderReplacer();
    pluginPlaceholders.put("serverUUID", serverUUID.toString());
    pluginPlaceholders.put("serverName", server.getIdentifiableName());
    pluginPlaceholders.put("serverDisplayName", server.getName());
    pluginPlaceholders.put("backButton", serverInfo.getServer().isProxy() ? Html.BACK_BUTTON_NETWORK.create() : "");
    pluginPlaceholders.put("navPluginsTabs", nav);
    pluginPlaceholders.put("tabsPlugins", tabs);
    return UnaryChain.of(templateHtml).chain(theme::replaceThemeColors).chain(placeholders::apply).chain(pluginPlaceholders::apply).chain(locale::replaceLanguageInHtml).apply();
}
Also used : ExtensionServerDataQuery(com.djrapitops.plan.extension.implementation.storage.queries.ExtensionServerDataQuery) ServerUUID(com.djrapitops.plan.identification.ServerUUID) PlaceholderReplacer(com.djrapitops.plan.delivery.formatting.PlaceholderReplacer) CachingSupplier(com.djrapitops.plan.delivery.domain.container.CachingSupplier) ExtensionData(com.djrapitops.plan.extension.implementation.results.ExtensionData)

Example 3 with ExtensionData

use of com.djrapitops.plan.extension.implementation.results.ExtensionData in project Plan by plan-player-analytics.

the class NetworkPage method toHtml.

@Override
public String toHtml() {
    PlaceholderReplacer placeholders = new PlaceholderReplacer();
    ServerUUID serverUUID = serverInfo.getServerUUID();
    placeholders.put("networkDisplayName", config.get(ProxySettings.NETWORK_NAME));
    placeholders.put("serverName", config.get(ProxySettings.NETWORK_NAME));
    placeholders.put("serverUUID", serverUUID.toString());
    placeholders.put("refreshBarrier", config.get(WebserverSettings.REDUCED_REFRESH_BARRIER));
    placeholders.put("gmPieColors", theme.getValue(ThemeVal.GRAPH_GM_PIE));
    placeholders.put("playersGraphColor", theme.getValue(ThemeVal.GRAPH_PLAYERS_ONLINE));
    placeholders.put("worldMapColLow", theme.getValue(ThemeVal.WORLD_MAP_LOW));
    placeholders.put("worldMapColHigh", theme.getValue(ThemeVal.WORLD_MAP_HIGH));
    placeholders.put("maxPingColor", theme.getValue(ThemeVal.GRAPH_MAX_PING));
    placeholders.put("minPingColor", theme.getValue(ThemeVal.GRAPH_MIN_PING));
    placeholders.put("avgPingColor", theme.getValue(ThemeVal.GRAPH_AVG_PING));
    placeholders.put("timeZone", config.getTimeZoneOffsetHours());
    placeholders.put("versionButton", versionChecker.getUpdateButton().orElse(versionChecker.getCurrentVersionButton()));
    placeholders.put("version", versionChecker.getCurrentVersion());
    placeholders.put("updateModal", versionChecker.getUpdateModal());
    placeholders.put("contributors", Contributors.generateContributorHtml());
    CachingSupplier<ServerPluginTabs> pluginTabs = new CachingSupplier<>(() -> {
        List<ExtensionData> extensionData = dbSystem.getDatabase().query(new ExtensionServerDataQuery(serverUUID));
        return new ServerPluginTabs(extensionData, formatters);
    });
    long after = System.currentTimeMillis() - config.get(WebserverSettings.REDUCED_REFRESH_BARRIER);
    String navIdentifier = DataID.EXTENSION_NAV.of(serverUUID);
    String tabIdentifier = DataID.EXTENSION_TABS.of(serverUUID);
    String nav = jsonStorage.fetchJsonMadeAfter(navIdentifier, after).orElseGet(() -> {
        jsonStorage.invalidateOlder(navIdentifier, after);
        return jsonStorage.storeJson(navIdentifier, pluginTabs.get().getNav());
    }).json;
    String tabs = jsonStorage.fetchJsonMadeAfter(tabIdentifier, after).orElseGet(() -> {
        jsonStorage.invalidateOlder(tabIdentifier, after);
        return jsonStorage.storeJson(tabIdentifier, pluginTabs.get().getTabs());
    }).json;
    PlaceholderReplacer pluginPlaceholders = new PlaceholderReplacer();
    pluginPlaceholders.put("networkDisplayName", config.get(ProxySettings.NETWORK_NAME));
    pluginPlaceholders.put("serverName", config.get(ProxySettings.NETWORK_NAME));
    pluginPlaceholders.put("serverUUID", serverUUID.toString());
    pluginPlaceholders.put("navPluginsTabs", nav);
    pluginPlaceholders.put("tabsPlugins", StringUtils.remove(tabs, "${backButton}"));
    return UnaryChain.of(templateHtml).chain(theme::replaceThemeColors).chain(placeholders::apply).chain(pluginPlaceholders::apply).chain(locale::replaceLanguageInHtml).apply();
}
Also used : ExtensionServerDataQuery(com.djrapitops.plan.extension.implementation.storage.queries.ExtensionServerDataQuery) ServerUUID(com.djrapitops.plan.identification.ServerUUID) PlaceholderReplacer(com.djrapitops.plan.delivery.formatting.PlaceholderReplacer) CachingSupplier(com.djrapitops.plan.delivery.domain.container.CachingSupplier) ExtensionData(com.djrapitops.plan.extension.implementation.results.ExtensionData)

Aggregations

ExtensionData (com.djrapitops.plan.extension.implementation.results.ExtensionData)3 ServerUUID (com.djrapitops.plan.identification.ServerUUID)3 CachingSupplier (com.djrapitops.plan.delivery.domain.container.CachingSupplier)2 PlaceholderReplacer (com.djrapitops.plan.delivery.formatting.PlaceholderReplacer)2 ExtensionServerDataQuery (com.djrapitops.plan.extension.implementation.storage.queries.ExtensionServerDataQuery)2 ExtensionPlayerDataQuery (com.djrapitops.plan.extension.implementation.storage.queries.ExtensionPlayerDataQuery)1 Server (com.djrapitops.plan.identification.Server)1 Database (com.djrapitops.plan.storage.database.Database)1