use of com.djrapitops.plan.delivery.domain.container.DataContainer in project Plan by plan-player-analytics.
the class SupplierDataContainerTest method safeUnsafeKeyRawNull.
@Test
void safeUnsafeKeyRawNull() {
DataContainer container = new SupplierDataContainer();
container.putRawData(TEST_KEY, null);
assertTrue(container.supports(TEST_KEY));
assertNull(container.getUnsafe(TEST_KEY));
}
use of com.djrapitops.plan.delivery.domain.container.DataContainer in project Plan by plan-player-analytics.
the class PerServerMutator method flatMapWorldTimes.
public WorldTimes flatMapWorldTimes() {
WorldTimes total = new WorldTimes();
for (DataContainer container : data.values()) {
if (container.supports(PerServerKeys.WORLD_TIMES)) {
WorldTimes worldTimes = container.getUnsafe(PerServerKeys.WORLD_TIMES);
total.add(worldTimes);
}
}
return total;
}
use of com.djrapitops.plan.delivery.domain.container.DataContainer in project Plan by plan-player-analytics.
the class PerServerMutator method worldTimesPerServer.
public Map<ServerUUID, WorldTimes> worldTimesPerServer() {
Map<ServerUUID, WorldTimes> timesMap = new HashMap<>();
for (Map.Entry<ServerUUID, DataContainer> entry : data.entrySet()) {
DataContainer container = entry.getValue();
timesMap.put(entry.getKey(), container.getValue(PerServerKeys.WORLD_TIMES).orElse(new WorldTimes()));
}
return timesMap;
}
use of com.djrapitops.plan.delivery.domain.container.DataContainer in project Plan by plan-player-analytics.
the class ServerAccordion method asMaps.
public List<Map<String, Object>> asMaps() {
List<Map<String, Object>> servers = new ArrayList<>();
for (Map.Entry<ServerUUID, DataContainer> entry : perServer.entrySet()) {
ServerUUID serverUUID = entry.getKey();
DataContainer ofServer = entry.getValue();
Map<String, Object> server = new HashMap<>();
String serverName = serverNames.getOrDefault(serverUUID, unknown);
WorldTimes worldTimes = ofServer.getValue(PerServerKeys.WORLD_TIMES).orElse(new WorldTimes());
SessionsMutator sessionsMutator = SessionsMutator.forContainer(ofServer);
server.put("server_name", serverName);
server.put("banned", ofServer.getValue(PerServerKeys.BANNED).orElse(false));
server.put("operator", ofServer.getValue(PerServerKeys.OPERATOR).orElse(false));
server.put("registered", year.apply(ofServer.getValue(PerServerKeys.REGISTERED).orElse(0L)));
server.put("last_seen", year.apply(sessionsMutator.toLastSeen()));
server.put("join_address", ofServer.getValue(PerServerKeys.JOIN_ADDRESS).orElse("-"));
server.put("session_count", sessionsMutator.count());
server.put("playtime", timeAmount.apply(sessionsMutator.toPlaytime()));
server.put("afk_time", timeAmount.apply(sessionsMutator.toAfkTime()));
server.put("session_median", timeAmount.apply(sessionsMutator.toMedianSessionLength()));
server.put("longest_session_length", timeAmount.apply(sessionsMutator.toLongestSessionLength()));
server.put("mob_kills", sessionsMutator.toMobKillCount());
server.put("player_kills", sessionsMutator.toPlayerKillCount());
server.put("deaths", sessionsMutator.toDeathCount());
WorldPie worldPie = graphs.pie().worldPie(worldTimes);
server.put("world_pie_series", worldPie.getSlices());
server.put("gm_series", worldPie.toHighChartsDrillDownMaps());
servers.add(server);
}
return servers;
}
use of com.djrapitops.plan.delivery.domain.container.DataContainer in project Plan by plan-player-analytics.
the class SupplierDataContainerTest method safeUnsafeKeyNullSupplier.
@Test
void safeUnsafeKeyNullSupplier() {
DataContainer container = new SupplierDataContainer();
container.putSupplier(TEST_KEY, null);
assertFalse(container.supports(TEST_KEY));
}
Aggregations