mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-20 07:02:21 +01:00
Translated dynamic content on Java side
This commit is contained in:
parent
ab124f155e
commit
2fa7689088
@ -20,6 +20,8 @@ import com.djrapitops.plan.delivery.domain.container.DataContainer;
|
||||
import com.djrapitops.plan.delivery.domain.keys.PlayerKeys;
|
||||
import com.djrapitops.plan.delivery.formatting.Formatter;
|
||||
import com.djrapitops.plan.gathering.domain.Session;
|
||||
import com.djrapitops.plan.settings.locale.Locale;
|
||||
import com.djrapitops.plan.settings.locale.lang.HtmlLang;
|
||||
import com.djrapitops.plugin.api.TimeAmount;
|
||||
|
||||
import java.util.List;
|
||||
@ -86,8 +88,27 @@ public class ActivityIndex {
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
public static String[] getGroups() {
|
||||
return new String[]{"Very Active", "Active", "Regular", "Irregular", "Inactive"};
|
||||
public static String[] getDefaultGroups() {
|
||||
return getGroups(null);
|
||||
}
|
||||
|
||||
public static String[] getGroups(Locale locale) {
|
||||
if (locale == null) {
|
||||
return new String[]{
|
||||
HtmlLang.INDEX_VERY_ACTIVE.getDefault(),
|
||||
HtmlLang.INDEX_ACTIVE.getDefault(),
|
||||
HtmlLang.INDEX_REGULAR.getDefault(),
|
||||
HtmlLang.INDEX_IRREGULAR.getDefault(),
|
||||
HtmlLang.INDEX_INACTIVE.getDefault()
|
||||
};
|
||||
}
|
||||
return new String[]{
|
||||
locale.get(HtmlLang.INDEX_VERY_ACTIVE).toString(),
|
||||
locale.get(HtmlLang.INDEX_ACTIVE).toString(),
|
||||
locale.get(HtmlLang.INDEX_REGULAR).toString(),
|
||||
locale.get(HtmlLang.INDEX_IRREGULAR).toString(),
|
||||
locale.get(HtmlLang.INDEX_INACTIVE).toString()
|
||||
};
|
||||
}
|
||||
|
||||
private double calculate(DataContainer container) {
|
||||
|
@ -34,6 +34,8 @@ import com.djrapitops.plan.identification.ServerInfo;
|
||||
import com.djrapitops.plan.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.settings.config.paths.DisplaySettings;
|
||||
import com.djrapitops.plan.settings.config.paths.TimeSettings;
|
||||
import com.djrapitops.plan.settings.locale.Locale;
|
||||
import com.djrapitops.plan.settings.locale.lang.HtmlLang;
|
||||
import com.djrapitops.plan.storage.database.DBSystem;
|
||||
import com.djrapitops.plan.storage.database.Database;
|
||||
import com.djrapitops.plan.storage.database.queries.analysis.PlayerCountQueries;
|
||||
@ -54,6 +56,7 @@ import java.util.concurrent.TimeUnit;
|
||||
public class JSONFactory {
|
||||
|
||||
private final PlanConfig config;
|
||||
private final Locale locale;
|
||||
private final DBSystem dbSystem;
|
||||
private final ServerInfo serverInfo;
|
||||
private final Graphs graphs;
|
||||
@ -62,12 +65,14 @@ public class JSONFactory {
|
||||
@Inject
|
||||
public JSONFactory(
|
||||
PlanConfig config,
|
||||
Locale locale,
|
||||
DBSystem dbSystem,
|
||||
ServerInfo serverInfo,
|
||||
Graphs graphs,
|
||||
Formatters formatters
|
||||
) {
|
||||
this.config = config;
|
||||
this.locale = locale;
|
||||
this.dbSystem = dbSystem;
|
||||
this.serverInfo = serverInfo;
|
||||
this.graphs = graphs;
|
||||
@ -85,7 +90,7 @@ public class JSONFactory {
|
||||
database.query(new ServerTablePlayersQuery(serverUUID, System.currentTimeMillis(), playtimeThreshold, xMostRecentPlayers)),
|
||||
database.query(new ExtensionServerPlayerDataTableQuery(serverUUID, xMostRecentPlayers)),
|
||||
openPlayerLinksInNewTab,
|
||||
formatters
|
||||
formatters, locale
|
||||
).toJSONString();
|
||||
}
|
||||
|
||||
@ -100,7 +105,7 @@ public class JSONFactory {
|
||||
database.query(new NetworkTablePlayersQuery(System.currentTimeMillis(), playtimeThreshold, xMostRecentPlayers)),
|
||||
Collections.emptyMap(),
|
||||
openPlayerLinksInNewTab,
|
||||
formatters
|
||||
formatters, locale
|
||||
).toJSONString();
|
||||
}
|
||||
|
||||
@ -200,7 +205,7 @@ public class JSONFactory {
|
||||
server.put("unique_players", uniquePlayerCounts.getOrDefault(serverUUID, 0));
|
||||
TPSMutator tpsWeek = tpsMonth.filterDataBetween(weekAgo, now);
|
||||
double averageTPS = tpsWeek.averageTPS();
|
||||
server.put("avg_tps", averageTPS != -1 ? decimals.apply(averageTPS) : "No data");
|
||||
server.put("avg_tps", averageTPS != -1 ? decimals.apply(averageTPS) : locale.get(HtmlLang.UNIT_NO_DATA).toString());
|
||||
server.put("low_tps_spikes", tpsWeek.lowTpsSpikeCount(config.getNumber(DisplaySettings.GRAPH_TPS_THRESHOLD_MED)));
|
||||
server.put("downtime", timeAmount.apply(tpsWeek.serverDownTime()));
|
||||
|
||||
@ -208,7 +213,7 @@ public class JSONFactory {
|
||||
server.put("online", online.isPresent() ?
|
||||
online.get().getDate() >= now - TimeUnit.MINUTES.toMillis(3L) ?
|
||||
online.get().getPlayers() : "Possibly offline"
|
||||
: "No data");
|
||||
: locale.get(HtmlLang.UNIT_NO_DATA).toString());
|
||||
servers.add(server);
|
||||
});
|
||||
return servers;
|
||||
|
@ -22,6 +22,9 @@ import com.djrapitops.plan.delivery.formatting.Formatters;
|
||||
import com.djrapitops.plan.gathering.domain.TPS;
|
||||
import com.djrapitops.plan.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.settings.config.paths.DisplaySettings;
|
||||
import com.djrapitops.plan.settings.locale.Locale;
|
||||
import com.djrapitops.plan.settings.locale.lang.GenericLang;
|
||||
import com.djrapitops.plan.settings.locale.lang.HtmlLang;
|
||||
import com.djrapitops.plan.storage.database.DBSystem;
|
||||
import com.djrapitops.plan.storage.database.Database;
|
||||
import com.djrapitops.plan.storage.database.queries.objects.TPSQueries;
|
||||
@ -43,6 +46,7 @@ import java.util.concurrent.TimeUnit;
|
||||
public class PerformanceJSONParser implements ServerTabJSONParser<Map<String, Object>> {
|
||||
|
||||
private final PlanConfig config;
|
||||
private final Locale locale;
|
||||
private final DBSystem dbSystem;
|
||||
|
||||
private final Formatter<Double> decimals;
|
||||
@ -52,10 +56,12 @@ public class PerformanceJSONParser implements ServerTabJSONParser<Map<String, Ob
|
||||
@Inject
|
||||
public PerformanceJSONParser(
|
||||
PlanConfig config,
|
||||
Locale locale,
|
||||
DBSystem dbSystem,
|
||||
Formatters formatters
|
||||
) {
|
||||
this.config = config;
|
||||
this.locale = locale;
|
||||
this.dbSystem = dbSystem;
|
||||
|
||||
decimals = formatters.decimals();
|
||||
@ -98,9 +104,9 @@ public class PerformanceJSONParser implements ServerTabJSONParser<Map<String, Ob
|
||||
numbers.put("tps_30d", format(tpsDataMonth.averageTPS()));
|
||||
numbers.put("tps_7d", format(tpsDataWeek.averageTPS()));
|
||||
numbers.put("tps_24h", format(tpsDataDay.averageTPS()));
|
||||
numbers.put("cpu_30d", percentageFormatter.apply(tpsDataMonth.averageCPU() / 100.0));
|
||||
numbers.put("cpu_7d", percentageFormatter.apply(tpsDataWeek.averageCPU() / 100.0));
|
||||
numbers.put("cpu_24h", percentageFormatter.apply(tpsDataDay.averageCPU() / 100.0));
|
||||
numbers.put("cpu_30d", formatPerc(tpsDataMonth.averageCPU()));
|
||||
numbers.put("cpu_7d", formatPerc(tpsDataWeek.averageCPU()));
|
||||
numbers.put("cpu_24h", formatPerc(tpsDataDay.averageCPU()));
|
||||
numbers.put("ram_30d", format(tpsDataMonth.averageRAM(), " MB"));
|
||||
numbers.put("ram_7d", format(tpsDataWeek.averageRAM(), " MB"));
|
||||
numbers.put("ram_24h", format(tpsDataDay.averageRAM(), " MB"));
|
||||
@ -111,22 +117,26 @@ public class PerformanceJSONParser implements ServerTabJSONParser<Map<String, Ob
|
||||
numbers.put("chunks_7d", format((int) tpsDataWeek.averageChunks()));
|
||||
numbers.put("chunks_24h", format((int) tpsDataDay.averageChunks()));
|
||||
|
||||
numbers.put("max_disk_30d", format(tpsDataMonth.maxFreeDisk(), " Mb"));
|
||||
numbers.put("max_disk_7d", format(tpsDataWeek.maxFreeDisk(), " Mb"));
|
||||
numbers.put("max_disk_24h", format(tpsDataDay.maxFreeDisk(), " Mb"));
|
||||
numbers.put("min_disk_30d", format(tpsDataMonth.minFreeDisk(), " Mb"));
|
||||
numbers.put("min_disk_7d", format(tpsDataWeek.minFreeDisk(), " Mb"));
|
||||
numbers.put("min_disk_24h", format(tpsDataDay.minFreeDisk(), " Mb"));
|
||||
numbers.put("max_disk_30d", format(tpsDataMonth.maxFreeDisk(), " MB"));
|
||||
numbers.put("max_disk_7d", format(tpsDataWeek.maxFreeDisk(), " MB"));
|
||||
numbers.put("max_disk_24h", format(tpsDataDay.maxFreeDisk(), " MB"));
|
||||
numbers.put("min_disk_30d", format(tpsDataMonth.minFreeDisk(), " MB"));
|
||||
numbers.put("min_disk_7d", format(tpsDataWeek.minFreeDisk(), " MB"));
|
||||
numbers.put("min_disk_24h", format(tpsDataDay.minFreeDisk(), " MB"));
|
||||
|
||||
return numbers;
|
||||
}
|
||||
|
||||
private String format(double value) {
|
||||
return value != -1 ? decimals.apply(value) : "Unavailable";
|
||||
return value != -1 ? decimals.apply(value) : locale.get(GenericLang.UNAVAILABLE).toString();
|
||||
}
|
||||
|
||||
private String format(double value, String suffix) {
|
||||
return value != -1 ? decimals.apply(value) + suffix : "Unavailable";
|
||||
return value != -1 ? decimals.apply(value) + suffix : locale.get(GenericLang.UNAVAILABLE).toString();
|
||||
}
|
||||
|
||||
private String formatPerc(double value) {
|
||||
return value != -1 ? percentageFormatter.apply(value / 100.0) : locale.get(GenericLang.UNAVAILABLE).toString();
|
||||
}
|
||||
|
||||
private Map<String, Object> createInsightsMap(List<TPS> tpsData) {
|
||||
@ -140,7 +150,7 @@ public class PerformanceJSONParser implements ServerTabJSONParser<Map<String, Ob
|
||||
double averageCPU = lowTPS.averageCPU();
|
||||
double averageEntities = lowTPS.averageEntities();
|
||||
double averageChunks = lowTPS.averageChunks();
|
||||
insights.put("low_tps_players", avgPlayersOnline != -1 ? decimals.apply(avgPlayersOnline) : "No low tps spikes");
|
||||
insights.put("low_tps_players", avgPlayersOnline != -1 ? decimals.apply(avgPlayersOnline) : locale.get(HtmlLang.TEXT_NO_LOW_TPS).toString());
|
||||
insights.put("low_tps_cpu", averageCPU != -1 ? decimals.apply(averageCPU) : "-");
|
||||
insights.put("low_tps_entities", averageEntities != -1 ? decimals.apply(averageEntities) : "-");
|
||||
insights.put("low_tps_chunks", averageChunks != -1 ? decimals.apply(averageChunks) : "-");
|
||||
|
@ -22,7 +22,6 @@ import com.djrapitops.plan.delivery.domain.mutators.*;
|
||||
import com.djrapitops.plan.delivery.formatting.Formatter;
|
||||
import com.djrapitops.plan.delivery.formatting.Formatters;
|
||||
import com.djrapitops.plan.delivery.rendering.html.Html;
|
||||
import com.djrapitops.plan.delivery.rendering.html.structure.ServerAccordion;
|
||||
import com.djrapitops.plan.delivery.rendering.json.graphs.Graphs;
|
||||
import com.djrapitops.plan.delivery.rendering.json.graphs.pie.WorldPie;
|
||||
import com.djrapitops.plan.gathering.cache.SessionCache;
|
||||
@ -32,6 +31,8 @@ import com.djrapitops.plan.gathering.domain.WorldTimes;
|
||||
import com.djrapitops.plan.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.settings.config.paths.DisplaySettings;
|
||||
import com.djrapitops.plan.settings.config.paths.TimeSettings;
|
||||
import com.djrapitops.plan.settings.locale.Locale;
|
||||
import com.djrapitops.plan.settings.locale.lang.GenericLang;
|
||||
import com.djrapitops.plan.settings.theme.Theme;
|
||||
import com.djrapitops.plan.settings.theme.ThemeVal;
|
||||
import com.djrapitops.plan.storage.database.DBSystem;
|
||||
@ -51,6 +52,7 @@ import java.util.stream.Collectors;
|
||||
public class PlayerJSONParser {
|
||||
|
||||
private final PlanConfig config;
|
||||
private final Locale locale;
|
||||
private final Theme theme;
|
||||
private final DBSystem dbSystem;
|
||||
private final Graphs graphs;
|
||||
@ -63,12 +65,14 @@ public class PlayerJSONParser {
|
||||
@Inject
|
||||
public PlayerJSONParser(
|
||||
PlanConfig config,
|
||||
Locale locale,
|
||||
Theme theme,
|
||||
DBSystem dbSystem,
|
||||
Formatters formatters,
|
||||
Graphs graphs
|
||||
) {
|
||||
this.config = config;
|
||||
this.locale = locale;
|
||||
this.theme = theme;
|
||||
this.dbSystem = dbSystem;
|
||||
|
||||
@ -88,7 +92,7 @@ public class PlayerJSONParser {
|
||||
PlayerContainer player = db.query(new PlayerContainerQuery(playerUUID));
|
||||
SessionsMutator sessionsMutator = SessionsMutator.forContainer(player);
|
||||
Map<UUID, WorldTimes> worldTimesPerServer = PerServerMutator.forContainer(player).worldTimesPerServer();
|
||||
List<Map<String, Object>> serverAccordion = new ServerAccordion(player, serverNames, graphs, year, timeAmount).asMaps();
|
||||
List<Map<String, Object>> serverAccordion = new ServerAccordion(player, serverNames, graphs, year, timeAmount, locale.get(GenericLang.UNKNOWN).toString()).asMaps();
|
||||
List<PlayerKill> kills = player.getValue(PlayerKeys.PLAYER_KILLS).orElse(Collections.emptyList());
|
||||
List<PlayerKill> deaths = player.getValue(PlayerKeys.PLAYER_DEATHS_KILLS).orElse(Collections.emptyList());
|
||||
|
||||
@ -178,7 +182,7 @@ public class PlayerJSONParser {
|
||||
int worstPing = ping.max();
|
||||
int bestPing = ping.min();
|
||||
|
||||
String unavailable = "Unavailable";
|
||||
String unavailable = locale.get(GenericLang.UNAVAILABLE).toString();
|
||||
info.put("average_ping", averagePing != -1.0 ? decimals.apply(averagePing) + " ms" : unavailable);
|
||||
info.put("worst_ping", worstPing != -1.0 ? worstPing + " ms" : unavailable);
|
||||
info.put("best_ping", bestPing != -1.0 ? bestPing + " ms" : unavailable);
|
||||
|
@ -26,6 +26,8 @@ import com.djrapitops.plan.delivery.rendering.html.icon.Icon;
|
||||
import com.djrapitops.plan.extension.FormatType;
|
||||
import com.djrapitops.plan.extension.icon.Color;
|
||||
import com.djrapitops.plan.extension.implementation.results.*;
|
||||
import com.djrapitops.plan.settings.locale.Locale;
|
||||
import com.djrapitops.plan.settings.locale.lang.HtmlLang;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@ -41,6 +43,7 @@ public class PlayersTableJSONParser {
|
||||
private final List<TablePlayer> players;
|
||||
private final List<ExtensionDescriptive> extensionDescriptives;
|
||||
private final Map<UUID, ExtensionTabData> extensionData;
|
||||
private final Locale locale;
|
||||
|
||||
private final boolean openPlayerPageInNewTab;
|
||||
|
||||
@ -49,17 +52,17 @@ public class PlayersTableJSONParser {
|
||||
private Formatter<Double> decimalFormatter;
|
||||
|
||||
public PlayersTableJSONParser(
|
||||
// Data
|
||||
List<TablePlayer> players,
|
||||
Map<UUID, ExtensionTabData> extensionData,
|
||||
// Settings
|
||||
boolean openPlayerPageInNewTab,
|
||||
// Formatters
|
||||
Formatters formatters
|
||||
Formatters formatters,
|
||||
Locale locale
|
||||
) {
|
||||
// Data
|
||||
this.players = players;
|
||||
this.extensionData = extensionData;
|
||||
this.locale = locale;
|
||||
|
||||
extensionDescriptives = new ArrayList<>();
|
||||
addExtensionDescriptives(extensionData);
|
||||
@ -132,7 +135,7 @@ public class PlayersTableJSONParser {
|
||||
ActivityIndex activityIndex = player.getCurrentActivityIndex().orElseGet(() -> new ActivityIndex(0.0, 0));
|
||||
boolean isBanned = player.isBanned();
|
||||
String activityString = activityIndex.getFormattedValue(decimalFormatter)
|
||||
+ (isBanned ? " (<b>Banned</b>)" : " (" + activityIndex.getGroup() + ")");
|
||||
+ (isBanned ? " (<b>" + locale.get(HtmlLang.LABEL_BANNED) + "</b>)" : " (" + activityIndex.getGroup() + ")");
|
||||
|
||||
String geolocation = player.getGeolocation().orElse("-");
|
||||
|
||||
@ -190,13 +193,13 @@ public class PlayersTableJSONParser {
|
||||
// Is the data for the column formatted
|
||||
|
||||
columnHeaders
|
||||
.append(makeColumnHeader(Icon.called("user") + " Name", "name")).append(',')
|
||||
.append(makeFColumnHeader(Icon.called("check") + " Activity Index", "index")).append(',')
|
||||
.append(makeFColumnHeader(Icon.called("clock").of(Family.REGULAR) + " Playtime", "playtime")).append(',')
|
||||
.append(makeColumnHeader(Icon.called("calendar-plus").of(Family.REGULAR) + " Sessions", "sessions")).append(',')
|
||||
.append(makeFColumnHeader(Icon.called("user-plus") + " Registered", "registered")).append(',')
|
||||
.append(makeFColumnHeader(Icon.called("calendar-check").of(Family.REGULAR) + " Last Seen", "seen")).append(',')
|
||||
.append(makeColumnHeader(Icon.called("globe") + " Geolocation", "geolocation"));
|
||||
.append(makeColumnHeader(Icon.called("user") + " " + locale.get(HtmlLang.LABEL_NAME), "name")).append(',')
|
||||
.append(makeFColumnHeader(Icon.called("check") + " " + locale.get(HtmlLang.LABEL_ACTIVITY_INDEX), "index")).append(',')
|
||||
.append(makeFColumnHeader(Icon.called("clock").of(Family.REGULAR) + " " + locale.get(HtmlLang.LABEL_PLAYTIME), "playtime")).append(',')
|
||||
.append(makeColumnHeader(Icon.called("calendar-plus").of(Family.REGULAR) + " " + locale.get(HtmlLang.SIDE_SESSIONS), "sessions")).append(',')
|
||||
.append(makeFColumnHeader(Icon.called("user-plus") + " " + locale.get(HtmlLang.LABEL_REGISTERED), "registered")).append(',')
|
||||
.append(makeFColumnHeader(Icon.called("calendar-check").of(Family.REGULAR) + " " + locale.get(HtmlLang.LABEL_LAST_SEEN), "seen")).append(',')
|
||||
.append(makeColumnHeader(Icon.called("globe") + " " + locale.get(HtmlLang.TITLE_COUNTRY), "geolocation"));
|
||||
|
||||
appendExtensionHeaders(columnHeaders);
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.djrapitops.plan.delivery.rendering.html.structure;
|
||||
package com.djrapitops.plan.delivery.rendering.json;
|
||||
|
||||
import com.djrapitops.plan.delivery.domain.container.DataContainer;
|
||||
import com.djrapitops.plan.delivery.domain.container.PerServerContainer;
|
||||
@ -30,7 +30,7 @@ import com.djrapitops.plan.gathering.domain.WorldTimes;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* HTML utility class for creating a Server Accordion.
|
||||
* Utility for creating JSON for Server Accordion
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
@ -38,6 +38,7 @@ public class ServerAccordion {
|
||||
|
||||
private final Map<UUID, String> serverNames;
|
||||
private final PerServerContainer perServer;
|
||||
private final String unknown;
|
||||
|
||||
private final Graphs graphs;
|
||||
private final Formatter<Long> year;
|
||||
@ -47,7 +48,8 @@ public class ServerAccordion {
|
||||
PlayerContainer container, Map<UUID, String> serverNames,
|
||||
Graphs graphs,
|
||||
Formatter<Long> year,
|
||||
Formatter<Long> timeAmount
|
||||
Formatter<Long> timeAmount,
|
||||
String unknown
|
||||
) {
|
||||
this.graphs = graphs;
|
||||
this.year = year;
|
||||
@ -56,6 +58,7 @@ public class ServerAccordion {
|
||||
this.serverNames = serverNames;
|
||||
perServer = container.getValue(PlayerKeys.PER_SERVER)
|
||||
.orElse(new PerServerContainer());
|
||||
this.unknown = unknown;
|
||||
}
|
||||
|
||||
public List<Map<String, Object>> asMaps() {
|
||||
@ -66,7 +69,7 @@ public class ServerAccordion {
|
||||
DataContainer perServer = entry.getValue();
|
||||
Map<String, Object> server = new HashMap<>();
|
||||
|
||||
String serverName = serverNames.getOrDefault(serverUUID, "Unknown");
|
||||
String serverName = serverNames.getOrDefault(serverUUID, unknown);
|
||||
WorldTimes worldTimes = perServer.getValue(PerServerKeys.WORLD_TIMES).orElse(new WorldTimes());
|
||||
SessionsMutator sessionsMutator = SessionsMutator.forContainer(perServer);
|
||||
|
@ -26,6 +26,8 @@ import com.djrapitops.plan.identification.ServerInfo;
|
||||
import com.djrapitops.plan.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.settings.config.paths.DisplaySettings;
|
||||
import com.djrapitops.plan.settings.config.paths.TimeSettings;
|
||||
import com.djrapitops.plan.settings.locale.Locale;
|
||||
import com.djrapitops.plan.settings.locale.lang.GenericLang;
|
||||
import com.djrapitops.plan.storage.database.DBSystem;
|
||||
import com.djrapitops.plan.storage.database.Database;
|
||||
import com.djrapitops.plan.storage.database.queries.ServerAggregateQueries;
|
||||
@ -49,24 +51,27 @@ import java.util.concurrent.TimeUnit;
|
||||
public class ServerOverviewJSONParser implements ServerTabJSONParser<Map<String, Object>> {
|
||||
|
||||
private final Formatter<Long> day;
|
||||
private PlanConfig config;
|
||||
private DBSystem dbSystem;
|
||||
private ServerInfo serverInfo;
|
||||
private final PlanConfig config;
|
||||
private final Locale locale;
|
||||
private final DBSystem dbSystem;
|
||||
private final ServerInfo serverInfo;
|
||||
|
||||
private Formatter<Long> timeAmount;
|
||||
private Formatter<Double> decimals;
|
||||
private Formatter<Double> percentage;
|
||||
private Formatter<DateHolder> year;
|
||||
private final Formatter<Long> timeAmount;
|
||||
private final Formatter<Double> decimals;
|
||||
private final Formatter<Double> percentage;
|
||||
private final Formatter<DateHolder> year;
|
||||
private final TimeZone timeZone;
|
||||
|
||||
@Inject
|
||||
public ServerOverviewJSONParser(
|
||||
PlanConfig config,
|
||||
Locale locale,
|
||||
DBSystem dbSystem,
|
||||
ServerInfo serverInfo,
|
||||
Formatters formatters
|
||||
) {
|
||||
this.config = config;
|
||||
this.locale = locale;
|
||||
this.dbSystem = dbSystem;
|
||||
this.serverInfo = serverInfo;
|
||||
|
||||
@ -105,7 +110,7 @@ public class ServerOverviewJSONParser implements ServerTabJSONParser<Map<String,
|
||||
sevenDays.put("new_players_retention_perc", percentage.apply(retentionPerc7d));
|
||||
TPSMutator tpsMutator = new TPSMutator(db.query(TPSQueries.fetchTPSDataOfServer(weekAgo, now, serverUUID)));
|
||||
double averageTPS = tpsMutator.averageTPS();
|
||||
sevenDays.put("average_tps", averageTPS != -1 ? decimals.apply(averageTPS) : "Unavailable");
|
||||
sevenDays.put("average_tps", averageTPS != -1 ? decimals.apply(averageTPS) : locale.get(GenericLang.UNAVAILABLE).toString());
|
||||
sevenDays.put("low_tps_spikes", tpsMutator.lowTpsSpikeCount(config.getNumber(DisplaySettings.GRAPH_TPS_THRESHOLD_MED)));
|
||||
sevenDays.put("downtime", timeAmount.apply(tpsMutator.serverDownTime()));
|
||||
|
||||
@ -146,7 +151,7 @@ public class ServerOverviewJSONParser implements ServerTabJSONParser<Map<String,
|
||||
? serverInfo.getServerProperties().getOnlinePlayers()
|
||||
: db.query(TPSQueries.fetchLatestTPSEntryForServer(serverUUID))
|
||||
.map(TPS::getPlayers).map(Object::toString)
|
||||
.orElse("Unknown");
|
||||
.orElse(locale.get(GenericLang.UNKNOWN).toString());
|
||||
}
|
||||
|
||||
private Map<String, Object> createWeeksMap(UUID serverUUID) {
|
||||
|
@ -30,22 +30,22 @@ import java.util.Map;
|
||||
*/
|
||||
public class ActivityPie extends Pie {
|
||||
|
||||
ActivityPie(Map<String, Integer> activityData, String[] colors) {
|
||||
super(turnToSlices(activityData, colors));
|
||||
ActivityPie(Map<String, Integer> activityData, String[] colors, String[] groups) {
|
||||
super(turnToSlices(activityData, colors, groups));
|
||||
}
|
||||
|
||||
private static List<PieSlice> turnToSlices(Map<String, Integer> activityData, String[] colors) {
|
||||
private static List<PieSlice> turnToSlices(Map<String, Integer> activityData, String[] colors, String[] groups) {
|
||||
int maxCol = colors.length;
|
||||
String[] defaultGroups = ActivityIndex.getDefaultGroups();
|
||||
|
||||
List<PieSlice> slices = new ArrayList<>();
|
||||
int i = 0;
|
||||
for (String group : ActivityIndex.getGroups()) {
|
||||
int num = activityData.getOrDefault(group, 0);
|
||||
for (int j = 0; j < groups.length; j++) {
|
||||
int num = activityData.getOrDefault(defaultGroups[j], 0);
|
||||
|
||||
slices.add(new PieSlice(group, num, colors[i % maxCol], false));
|
||||
slices.add(new PieSlice(groups[j], num, colors[i % maxCol], false));
|
||||
i++;
|
||||
}
|
||||
|
||||
return slices;
|
||||
}
|
||||
}
|
||||
|
@ -16,11 +16,14 @@
|
||||
*/
|
||||
package com.djrapitops.plan.delivery.rendering.json.graphs.pie;
|
||||
|
||||
import com.djrapitops.plan.delivery.domain.mutators.ActivityIndex;
|
||||
import com.djrapitops.plan.gathering.domain.GMTimes;
|
||||
import com.djrapitops.plan.gathering.domain.WorldTimes;
|
||||
import com.djrapitops.plan.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.settings.config.WorldAliasSettings;
|
||||
import com.djrapitops.plan.settings.config.paths.DisplaySettings;
|
||||
import com.djrapitops.plan.settings.locale.Locale;
|
||||
import com.djrapitops.plan.settings.locale.lang.GenericLang;
|
||||
import com.djrapitops.plan.settings.theme.Theme;
|
||||
import com.djrapitops.plan.settings.theme.ThemeVal;
|
||||
|
||||
@ -38,24 +41,27 @@ import java.util.UUID;
|
||||
public class PieGraphFactory {
|
||||
|
||||
private final PlanConfig config;
|
||||
private final Locale locale;
|
||||
private final Theme theme;
|
||||
|
||||
@Inject
|
||||
public PieGraphFactory(
|
||||
PlanConfig config,
|
||||
Locale locale,
|
||||
Theme theme
|
||||
) {
|
||||
this.config = config;
|
||||
this.locale = locale;
|
||||
this.theme = theme;
|
||||
}
|
||||
|
||||
public Pie activityPie(Map<String, Integer> activityData) {
|
||||
String[] colors = theme.getPieColors(ThemeVal.GRAPH_ACTIVITY_PIE);
|
||||
return new ActivityPie(activityData, colors);
|
||||
return new ActivityPie(activityData, colors, ActivityIndex.getGroups(locale));
|
||||
}
|
||||
|
||||
public Pie serverPreferencePie(Map<UUID, String> serverNames, Map<UUID, WorldTimes> serverWorldTimes) {
|
||||
return new ServerPreferencePie(serverNames, serverWorldTimes);
|
||||
return new ServerPreferencePie(serverNames, serverWorldTimes, locale.get(GenericLang.UNKNOWN).toString());
|
||||
}
|
||||
|
||||
public Pie serverPreferencePie(Map<String, Long> serverPlaytimes) {
|
||||
|
@ -25,22 +25,22 @@ import java.util.UUID;
|
||||
|
||||
public class ServerPreferencePie extends Pie {
|
||||
|
||||
ServerPreferencePie(Map<UUID, String> serverNames, Map<UUID, WorldTimes> serverWorldTimes) {
|
||||
super(turnToSlices(serverNames, serverWorldTimes));
|
||||
ServerPreferencePie(Map<UUID, String> serverNames, Map<UUID, WorldTimes> serverWorldTimes, String unknown) {
|
||||
super(turnToSlices(serverNames, serverWorldTimes, unknown));
|
||||
}
|
||||
|
||||
ServerPreferencePie(Map<String, Long> serverPlaytimes) {
|
||||
super(turnToSlices(serverPlaytimes));
|
||||
}
|
||||
|
||||
private static List<PieSlice> turnToSlices(Map<UUID, String> serverNames, Map<UUID, WorldTimes> serverWorldTimes) {
|
||||
private static List<PieSlice> turnToSlices(Map<UUID, String> serverNames, Map<UUID, WorldTimes> serverWorldTimes, String unknown) {
|
||||
List<PieSlice> slices = new ArrayList<>();
|
||||
|
||||
for (Map.Entry<UUID, WorldTimes> server : serverWorldTimes.entrySet()) {
|
||||
UUID serverUUID = server.getKey();
|
||||
WorldTimes worldTimes = server.getValue();
|
||||
|
||||
String serverName = serverNames.getOrDefault(serverUUID, "Unknown");
|
||||
String serverName = serverNames.getOrDefault(serverUUID, unknown);
|
||||
long num = worldTimes.getTotal();
|
||||
|
||||
slices.add(new PieSlice(serverName, num));
|
||||
|
@ -20,7 +20,9 @@ import com.djrapitops.plan.delivery.domain.DateMap;
|
||||
import com.djrapitops.plan.delivery.domain.mutators.ActivityIndex;
|
||||
import com.djrapitops.plan.delivery.formatting.Formatter;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Stack Graph that represents evolution of the PlayerBase in terms of ActivityIndex Groups.
|
||||
@ -30,12 +32,8 @@ import java.util.*;
|
||||
*/
|
||||
class ActivityStackGraph extends StackGraph {
|
||||
|
||||
ActivityStackGraph(TreeMap<Long, Map<String, Set<UUID>>> activityData, String[] colors, Formatter<Long> dayFormatter) {
|
||||
super(getLabels(activityData.navigableKeySet(), dayFormatter), getDataSets(activityData, colors));
|
||||
}
|
||||
|
||||
ActivityStackGraph(DateMap<Map<String, Integer>> activityData, String[] colors, Formatter<Long> dayFormatter) {
|
||||
super(getLabels(activityData.navigableKeySet(), dayFormatter), getDataSets(activityData, colors));
|
||||
ActivityStackGraph(DateMap<Map<String, Integer>> activityData, String[] colors, Formatter<Long> dayFormatter, String[] groups) {
|
||||
super(getLabels(activityData.navigableKeySet(), dayFormatter), getDataSets(activityData, colors, groups));
|
||||
}
|
||||
|
||||
private static String[] getLabels(Collection<Long> dates, Formatter<Long> dayFormatter) {
|
||||
@ -55,27 +53,13 @@ class ActivityStackGraph extends StackGraph {
|
||||
return dataSets;
|
||||
}
|
||||
|
||||
private static StackDataSet[] getDataSets(TreeMap<Long, Map<String, Set<UUID>>> activityData, String[] colors) {
|
||||
String[] groups = ActivityIndex.getGroups();
|
||||
StackDataSet[] dataSets = initializeDataSet(groups, colors);
|
||||
|
||||
for (Map<String, Set<UUID>> data : activityData.values()) {
|
||||
for (int j = 0; j < groups.length; j++) {
|
||||
Set<UUID> players = data.get(groups[j]);
|
||||
dataSets[j].add(players != null ? players.size() : 0);
|
||||
}
|
||||
}
|
||||
|
||||
return dataSets;
|
||||
}
|
||||
|
||||
private static StackDataSet[] getDataSets(DateMap<Map<String, Integer>> activityData, String[] colors) {
|
||||
String[] groups = ActivityIndex.getGroups();
|
||||
private static StackDataSet[] getDataSets(DateMap<Map<String, Integer>> activityData, String[] colors, String[] groups) {
|
||||
StackDataSet[] dataSets = initializeDataSet(groups, colors);
|
||||
String[] defaultGroups = ActivityIndex.getDefaultGroups();
|
||||
|
||||
for (Map<String, Integer> data : activityData.values()) {
|
||||
for (int j = 0; j < groups.length; j++) {
|
||||
dataSets[j].add((double) data.getOrDefault(groups[j], 0));
|
||||
dataSets[j].add((double) data.getOrDefault(defaultGroups[j], 0));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -17,8 +17,10 @@
|
||||
package com.djrapitops.plan.delivery.rendering.json.graphs.stack;
|
||||
|
||||
import com.djrapitops.plan.delivery.domain.DateMap;
|
||||
import com.djrapitops.plan.delivery.domain.mutators.ActivityIndex;
|
||||
import com.djrapitops.plan.delivery.formatting.Formatter;
|
||||
import com.djrapitops.plan.delivery.formatting.Formatters;
|
||||
import com.djrapitops.plan.settings.locale.Locale;
|
||||
import com.djrapitops.plan.settings.theme.Theme;
|
||||
import com.djrapitops.plan.settings.theme.ThemeVal;
|
||||
|
||||
@ -34,20 +36,23 @@ import java.util.Map;
|
||||
@Singleton
|
||||
public class StackGraphFactory {
|
||||
|
||||
private final Locale locale;
|
||||
private final Theme theme;
|
||||
private final Formatter<Long> dayFormatter;
|
||||
|
||||
@Inject
|
||||
public StackGraphFactory(
|
||||
Locale locale,
|
||||
Formatters formatters,
|
||||
Theme theme
|
||||
) {
|
||||
this.locale = locale;
|
||||
this.theme = theme;
|
||||
this.dayFormatter = formatters.dayLong();
|
||||
}
|
||||
|
||||
public StackGraph activityStackGraph(DateMap<Map<String, Integer>> activityData) {
|
||||
String[] colors = theme.getPieColors(ThemeVal.GRAPH_ACTIVITY_PIE);
|
||||
return new ActivityStackGraph(activityData, colors, dayFormatter);
|
||||
return new ActivityStackGraph(activityData, colors, dayFormatter, ActivityIndex.getGroups(locale));
|
||||
}
|
||||
}
|
@ -24,6 +24,9 @@ import com.djrapitops.plan.gathering.domain.Session;
|
||||
import com.djrapitops.plan.gathering.domain.WorldTimes;
|
||||
import com.djrapitops.plan.processing.Processing;
|
||||
import com.djrapitops.plan.settings.config.paths.DisplaySettings;
|
||||
import com.djrapitops.plan.settings.locale.Locale;
|
||||
import com.djrapitops.plan.settings.locale.lang.GenericLang;
|
||||
import com.djrapitops.plan.settings.locale.lang.HtmlLang;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
@ -47,17 +50,20 @@ public class WorldAliasSettings {
|
||||
|
||||
private final Lazy<PlanConfig> config;
|
||||
private final Supplier<Formatter<Double>> percentageFormatter;
|
||||
private final Locale locale;
|
||||
private final Processing processing;
|
||||
private final ErrorHandler errorHandler;
|
||||
|
||||
@Inject
|
||||
public WorldAliasSettings(
|
||||
Lazy<PlanConfig> config,
|
||||
Locale locale,
|
||||
Lazy<Formatters> formatters,
|
||||
Processing processing,
|
||||
ErrorHandler errorHandler
|
||||
) {
|
||||
this.config = config;
|
||||
this.locale = locale;
|
||||
this.processing = processing;
|
||||
this.errorHandler = errorHandler;
|
||||
|
||||
@ -153,13 +159,13 @@ public class WorldAliasSettings {
|
||||
ConfigNode aliases = getAliasSection();
|
||||
|
||||
if (!session.supports(SessionKeys.WORLD_TIMES)) {
|
||||
return "No World Time Data";
|
||||
return locale.get(HtmlLang.UNIT_NO_DATA).toString();
|
||||
}
|
||||
WorldTimes worldTimes = session.getValue(SessionKeys.WORLD_TIMES).orElse(new WorldTimes());
|
||||
if (!session.supports(SessionKeys.END)) {
|
||||
return worldTimes.getCurrentWorld()
|
||||
.map(currentWorld -> "Current: " + (aliases.contains(currentWorld) ? aliases.getString(currentWorld) : currentWorld))
|
||||
.orElse("Current: Unavailable");
|
||||
.orElse("Current: " + locale.get(GenericLang.UNAVAILABLE));
|
||||
}
|
||||
|
||||
Map<String, Long> playtimePerAlias = getPlaytimePerAlias(worldTimes);
|
||||
|
@ -25,6 +25,7 @@ public enum GenericLang implements Lang {
|
||||
YES("Positive", "Yes"),
|
||||
NO("Negative", "No"),
|
||||
UNKNOWN("Unknown", "Unknown"),
|
||||
UNAVAILABLE("Unavailable", "Unavailable"),
|
||||
TODAY("Today", "'Today'"),
|
||||
YESTERDAY("Yesterday", "'Yesterday'");
|
||||
|
||||
|
@ -177,6 +177,7 @@ public enum HtmlLang implements Lang {
|
||||
LABEL_REGISTERED("Registered"),
|
||||
TITLE_TITLE_PLAYER_PUNCHCARD("Punchcard"),
|
||||
TITLE_ALL_TIME("All Time"),
|
||||
LABEL_NAME("Name"),
|
||||
// ----------------------------------
|
||||
// OLD
|
||||
// ----------------------------------
|
||||
|
@ -341,3 +341,4 @@ WebServer FAIL - Port Bind || 未成功初始化网页服
|
||||
WebServer FAIL - SSL Context || 网页服务器:SSL 环境初始化失败。
|
||||
WebServer FAIL - Store Load || 网页服务器:SSL 证书载入失败。
|
||||
Yesterday || '昨天'
|
||||
HTML - LABEL_NAME || 名称
|
@ -341,3 +341,4 @@ WebServer FAIL - Port Bind || WebServer wurde nicht erfolgr
|
||||
WebServer FAIL - SSL Context || WebServer: SSL Context Initialisierung fehlgeschlagen.
|
||||
WebServer FAIL - Store Load || WebServer: SSL Zertifikat konnte nicht geladen werden.
|
||||
Yesterday || 'Gestern'
|
||||
HTML - LABEL_NAME || Name
|
@ -341,3 +341,4 @@ WebServer FAIL - Port Bind || WebServer was not initialized
|
||||
WebServer FAIL - SSL Context || WebServer: SSL Context Initialization Failed.
|
||||
WebServer FAIL - Store Load || WebServer: SSL Certificate loading Failed.
|
||||
Yesterday || 'Yesterday'
|
||||
HTML - LABEL_NAME || Name
|
@ -341,3 +341,4 @@ WebServer FAIL - Port Bind || Web Palvelin ei käynnistynyt
|
||||
WebServer FAIL - SSL Context || Web Palvelin: SSL Kontekstin käynnistys ei onnistunut.
|
||||
WebServer FAIL - Store Load || Web Palvelin: SSL Sertifikaatin lataus ei onnistunut.
|
||||
Yesterday || 'Eilen'
|
||||
HTML - LABEL_NAME || Nimi
|
@ -341,3 +341,4 @@ WebServer FAIL - Port Bind || Webサーバーの初期化
|
||||
WebServer FAIL - SSL Context || Webサーバー: SSLコンテキストの初期化に失敗しました。
|
||||
WebServer FAIL - Store Load || Webサーバー: SSL証明書のロードに失敗しました
|
||||
Yesterday || '昨日'
|
||||
HTML - LABEL_NAME || 名前
|
@ -341,3 +341,4 @@ WebServer FAIL - Port Bind || O servidor web não foi inici
|
||||
WebServer FAIL - SSL Context || Servidor Web: Falha ao inicializar certificado SSL.
|
||||
WebServer FAIL - Store Load || Servidor Web: Falha ao carregar certificado SSL.
|
||||
Yesterday || 'Ontem'
|
||||
HTML - LABEL_NAME || Nome
|
@ -57,7 +57,7 @@ function diskChart(id, series) {
|
||||
yAxis: {
|
||||
labels: {
|
||||
formatter: function () {
|
||||
return this.value + ' Mb';
|
||||
return this.value + ' MB';
|
||||
}
|
||||
},
|
||||
softMax: 2,
|
||||
@ -317,7 +317,7 @@ function resourceChart(id, cpuSeries, ramSeries, playersOnlineSeries) {
|
||||
}, {
|
||||
labels: {
|
||||
formatter: function () {
|
||||
return this.value + ' Mb';
|
||||
return this.value + ' MB';
|
||||
}
|
||||
}
|
||||
}],
|
||||
|
@ -9,7 +9,7 @@ function loadPingTable(json, error) {
|
||||
var countries = json;
|
||||
|
||||
if (!countries.length) {
|
||||
pingTable.append('<tr><td>No Ping Data</td><td>-</td><td>-</td><td>-</td></tr>');
|
||||
pingTable.append('<tr><td>No Data</td><td>-</td><td>-</td><td>-</td></tr>');
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -154,7 +154,7 @@ function loadServerAccordion(json, error) {
|
||||
var servers = json.servers;
|
||||
|
||||
if (!servers.length) {
|
||||
serverTable.append('<tr><td>No Sessions</td><td>-</td><td>-</td><td>-</td></tr>')
|
||||
serverTable.append('<tr><td>No Data</td><td>-</td><td>-</td><td>-</td></tr>')
|
||||
}
|
||||
|
||||
var serversHtml = '';
|
||||
|
@ -9,7 +9,7 @@ function loadSessionAccordion(json, error) {
|
||||
var sessions = json.sessions;
|
||||
|
||||
if (!sessions.length) {
|
||||
sessionTable.append('<tr><td>No Sessions</td><td>-</td><td>-</td><td>-</td></tr>');
|
||||
sessionTable.append('<tr><td>No Data</td><td>-</td><td>-</td><td>-</td></tr>');
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1348,13 +1348,13 @@
|
||||
newPlayers: 'New Players',
|
||||
tps: 'TPS',
|
||||
cpu: 'CPU Usage (%)',
|
||||
ram: 'RAM Usage (Mb)',
|
||||
ram: 'RAM Usage (MB)',
|
||||
entities: 'Loaded Entities',
|
||||
chunks: 'Loaded Chunks',
|
||||
maxPing: 'Worst Ping',
|
||||
minPing: 'Best Ping',
|
||||
avgPing: 'Average Ping',
|
||||
disk: 'Free Disk Space (Mb)'
|
||||
disk: 'Free Disk Space (MB)'
|
||||
},
|
||||
tooltip: {
|
||||
twoDecimals: {
|
||||
|
Loading…
Reference in New Issue
Block a user