diff --git a/Plan/src/main/java/com/djrapitops/plan/data/Actions.java b/Plan/src/main/java/com/djrapitops/plan/data/Actions.java index 09d8d1bf2..bc523ba7a 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/Actions.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/Actions.java @@ -11,6 +11,7 @@ import org.apache.commons.text.WordUtils; * * @author Rsl1122 */ +@Deprecated public enum Actions { UNKNOWN(-1), FIRST_SESSION(1), diff --git a/Plan/src/main/java/com/djrapitops/plan/data/PlayerProfile.java b/Plan/src/main/java/com/djrapitops/plan/data/PlayerProfile.java index 2d01a95c9..dd3b908f0 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/PlayerProfile.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/PlayerProfile.java @@ -26,6 +26,7 @@ import java.util.stream.Stream; * * @author Rsl1122 */ +@Deprecated public class PlayerProfile { // Identification diff --git a/Plan/src/main/java/com/djrapitops/plan/data/ServerProfile.java b/Plan/src/main/java/com/djrapitops/plan/data/ServerProfile.java index 48cda8491..cd8e99d12 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/ServerProfile.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/ServerProfile.java @@ -27,6 +27,7 @@ import java.util.stream.Stream; * * @author Rsl1122 */ +@Deprecated public class ServerProfile { private final UUID serverUUID; diff --git a/Plan/src/main/java/com/djrapitops/plan/data/calculation/AnalysisData.java b/Plan/src/main/java/com/djrapitops/plan/data/calculation/AnalysisData.java index 90a333019..3cdcc1a41 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/calculation/AnalysisData.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/calculation/AnalysisData.java @@ -50,6 +50,7 @@ import java.util.stream.Collectors; * @author Rsl1122 * @since 3.5.2 */ +@Deprecated public class AnalysisData extends RawData { private long refreshDate; diff --git a/Plan/src/main/java/com/djrapitops/plan/data/calculation/RawData.java b/Plan/src/main/java/com/djrapitops/plan/data/calculation/RawData.java index 03c57bcd8..99b18119f 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/calculation/RawData.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/calculation/RawData.java @@ -12,6 +12,7 @@ import java.util.Map; * @author Rsl1122 * @since 3.5.2 */ +@Deprecated public abstract class RawData { private final Map replaceMap; diff --git a/Plan/src/main/java/com/djrapitops/plan/data/container/Action.java b/Plan/src/main/java/com/djrapitops/plan/data/container/Action.java index b92b58130..043fc9653 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/container/Action.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/container/Action.java @@ -16,6 +16,7 @@ import java.util.Objects; * * @author Rsl1122 */ +@Deprecated public class Action implements DateHolder { private final long date; private final Actions doneAction; diff --git a/Plan/src/main/java/com/djrapitops/plan/data/element/TableContainer.java b/Plan/src/main/java/com/djrapitops/plan/data/element/TableContainer.java index 6eea624c4..956bdbb90 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/element/TableContainer.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/element/TableContainer.java @@ -67,16 +67,16 @@ public class TableContainer { body.append(""); for (int i = 0; i < header.length; i++) { try { - Serializable value = row[i]; - Formatter formatter = formatters[i]; - body.append("" : ">"); if (i > maxIndex) { - body.append("-"); + body.append("-"); } else { + Serializable value = row[i]; + Formatter formatter = formatters[i]; + body.append("" : ">"); body.append(formatter != null ? formatter.apply(value) : value); } body.append(""); - } catch (ClassCastException e) { + } catch (ClassCastException | ArrayIndexOutOfBoundsException e) { throw new IllegalStateException("Invalid formatter given at index " + i + ": " + e.getMessage(), e); } } diff --git a/Plan/src/main/java/com/djrapitops/plan/data/store/Type.java b/Plan/src/main/java/com/djrapitops/plan/data/store/Type.java index dcbdafb21..dbea50030 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/store/Type.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/store/Type.java @@ -1,5 +1,7 @@ package com.djrapitops.plan.data.store; +import java.util.Objects; + /** * Similar to Google's TypeToken but without requiring whole gson package. *

@@ -9,7 +11,10 @@ package com.djrapitops.plan.data.store; */ public abstract class Type { + private final String genericsSuperClass; + public Type() { + genericsSuperClass = getGenericsClass().getGenericSuperclass().getTypeName(); } public static Type ofClass(Class of) { @@ -23,4 +28,18 @@ public abstract class Type { public Class> getGenericsClass() { return (Class>) getClass(); } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof Type)) return false; + Type type = (Type) o; + return Objects.equals(genericsSuperClass, type.genericsSuperClass); + } + + @Override + public int hashCode() { + + return Objects.hash(genericsSuperClass); + } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/data/store/containers/AnalysisContainer.java b/Plan/src/main/java/com/djrapitops/plan/data/store/containers/AnalysisContainer.java index 05c77fce0..c20a02d01 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/store/containers/AnalysisContainer.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/store/containers/AnalysisContainer.java @@ -184,7 +184,8 @@ public class AnalysisContainer extends DataContainer { }); putSupplier(AnalysisKeys.PLAYERS_RETAINED_DAY_PERC, () -> { try { - return Formatters.percentage().apply(1.0 * getUnsafe(retentionDay) / getUnsafe(AnalysisKeys.PLAYERS_NEW_DAY)); + Integer playersNewDay = getUnsafe(AnalysisKeys.PLAYERS_NEW_DAY); + return playersNewDay != 0 ? Formatters.percentage().apply(1.0 * getUnsafe(retentionDay) / playersNewDay) : "-"; } catch (IllegalStateException e) { return "Not enough data"; } @@ -220,8 +221,11 @@ public class AnalysisContainer extends DataContainer { putSupplier(AnalysisKeys.PLAYTIME_F, () -> Formatters.timeAmount() .apply(getUnsafe(AnalysisKeys.PLAYTIME_TOTAL)) ); - putSupplier(AnalysisKeys.AVERAGE_PLAYTIME_F, () -> Formatters.timeAmount() - .apply(getUnsafe(AnalysisKeys.PLAYTIME_TOTAL) / (long) getUnsafe(AnalysisKeys.PLAYERS_TOTAL)) + putSupplier(AnalysisKeys.AVERAGE_PLAYTIME_F, () -> { + long players = getUnsafe(AnalysisKeys.PLAYERS_TOTAL); + return players != 0 ? Formatters.timeAmount() + .apply(getUnsafe(AnalysisKeys.PLAYTIME_TOTAL) / players) : "-"; + } ); putSupplier(AnalysisKeys.AVERAGE_SESSION_LENGTH_F, () -> Formatters.timeAmount() .apply(getUnsafe(AnalysisKeys.SESSIONS_MUTATOR).toAverageSessionLength()) @@ -257,11 +261,17 @@ public class AnalysisContainer extends DataContainer { getUnsafe(AnalysisKeys.ANALYSIS_TIME) ).count() ); - putSupplier(AnalysisKeys.PLAYERS_RETAINED_WEEK_PERC, () -> Formatters.percentage().apply( - 1.0 * getUnsafe(AnalysisKeys.PLAYERS_RETAINED_WEEK) / getUnsafe(AnalysisKeys.PLAYERS_NEW_WEEK)) + putSupplier(AnalysisKeys.PLAYERS_RETAINED_WEEK_PERC, () -> { + Integer playersNewWeek = getUnsafe(AnalysisKeys.PLAYERS_NEW_WEEK); + return playersNewWeek != 0 ? Formatters.percentage().apply( + 1.0 * getUnsafe(AnalysisKeys.PLAYERS_RETAINED_WEEK) / playersNewWeek) : "-"; + } ); - putSupplier(AnalysisKeys.PLAYERS_RETAINED_MONTH_PERC, () -> Formatters.percentage().apply( - 1.0 * getUnsafe(AnalysisKeys.PLAYERS_RETAINED_MONTH) / getUnsafe(AnalysisKeys.PLAYERS_NEW_MONTH)) + putSupplier(AnalysisKeys.PLAYERS_RETAINED_MONTH_PERC, () -> { + Integer playersNewMonth = getUnsafe(AnalysisKeys.PLAYERS_NEW_MONTH); + return playersNewMonth != 0 ? Formatters.percentage().apply( + 1.0 * getUnsafe(AnalysisKeys.PLAYERS_RETAINED_MONTH) / playersNewMonth) : "-"; + } ); } @@ -292,7 +302,8 @@ public class AnalysisContainer extends DataContainer { new ActivityPie(getUnsafe(AnalysisKeys.ACTIVITY_DATA).get(getUnsafe(AnalysisKeys.ANALYSIS_TIME))).toHighChartsSeries() ); putSupplier(AnalysisKeys.PLAYERS_REGULAR, () -> { - Map> activityNow = getUnsafe(AnalysisKeys.ACTIVITY_DATA).get(getUnsafe(AnalysisKeys.ANALYSIS_TIME)); + Map> activityNow = getUnsafe(AnalysisKeys.ACTIVITY_DATA) + .floorEntry(getUnsafe(AnalysisKeys.ANALYSIS_TIME)).getValue(); Set veryActiveNow = activityNow.getOrDefault("Very Active", new HashSet<>()); Set activeNow = activityNow.getOrDefault("Active", new HashSet<>()); Set regularNow = activityNow.getOrDefault("Regular", new HashSet<>()); diff --git a/Plan/src/main/java/com/djrapitops/plan/data/store/keys/AnalysisKeys.java b/Plan/src/main/java/com/djrapitops/plan/data/store/keys/AnalysisKeys.java index 851f784fe..6416b8da8 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/store/keys/AnalysisKeys.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/store/keys/AnalysisKeys.java @@ -35,7 +35,7 @@ public class AnalysisKeys { public static final PlaceholderKey PLAYERS_TOTAL = new PlaceholderKey<>(Integer.class, "playersTotal"); // public static final PlaceholderKey WORLD_PIE_COLORS = new PlaceholderKey<>(String.class, "worldPieColors"); - public static final PlaceholderKey GM_PIE_COLORS = new PlaceholderKey<>(String.class, "gm_pie_colors"); + public static final PlaceholderKey GM_PIE_COLORS = new PlaceholderKey<>(String.class, "gmPieColors"); public static final PlaceholderKey ACTIVITY_PIE_COLORS = new PlaceholderKey<>(String.class, "activityPieColors"); public static final PlaceholderKey PLAYERS_GRAPH_COLOR = new PlaceholderKey<>(String.class, "playersGraphColor"); public static final PlaceholderKey TPS_HIGH_COLOR = new PlaceholderKey<>(String.class, "tpsHighColor"); diff --git a/Plan/src/main/java/com/djrapitops/plan/data/store/mutators/HealthInformation.java b/Plan/src/main/java/com/djrapitops/plan/data/store/mutators/HealthInformation.java index 9ae2a6d26..9c0551e3b 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/store/mutators/HealthInformation.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/store/mutators/HealthInformation.java @@ -8,7 +8,6 @@ import com.djrapitops.plan.data.store.mutators.formatting.Formatter; import com.djrapitops.plan.data.store.mutators.formatting.Formatters; import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.utilities.FormatUtils; -import com.djrapitops.plan.utilities.analysis.MathUtils; import com.djrapitops.plan.utilities.html.Html; import com.djrapitops.plugin.api.TimeAmount; @@ -142,12 +141,12 @@ public class HealthInformation { long playersRetainedMonth = analysisContainer.getValue(AnalysisKeys.PLAYERS_RETAINED_MONTH).orElse(0); if (playersNewMonth != 0) { - double stuckPerc = MathUtils.averageDouble(playersRetainedMonth, playersNewMonth) * 100; - if (stuckPerc >= 25) { - notes.add("

" + Html.GREEN_THUMB.parse() + " " + FormatUtils.cutDecimals(stuckPerc) - + "% of new players have stuck around (" + playersRetainedMonth + "/" + playersNewMonth + ")

"); + double retainPercentage = playersRetainedMonth / playersNewMonth; + if (retainPercentage >= 0.25) { + notes.add("

" + Html.GREEN_THUMB.parse() + " " + Formatters.percentage().apply(retainPercentage) + + " of new players have stuck around (" + playersRetainedMonth + "/" + playersNewMonth + ")

"); } else { - notes.add("

" + Html.YELLOW_FLAG.parse() + " " + FormatUtils.cutDecimals(stuckPerc) + notes.add("

" + Html.YELLOW_FLAG.parse() + " " + Formatters.percentage().apply(retainPercentage) + "% of new players have stuck around (" + playersRetainedMonth + "/" + playersNewMonth + ")

"); } } @@ -167,8 +166,8 @@ public class HealthInformation { } int activeCount = currentlyActive.count(); if (activeCount != 0) { - long avgFourToTwoWeeks = MathUtils.averageLong(totalFourToTwoWeeks, activeCount); - long avgLastTwoWeeks = MathUtils.averageLong(totalLastTwoWeeks, activeCount); + long avgFourToTwoWeeks = totalFourToTwoWeeks / (long) activeCount; + long avgLastTwoWeeks = totalLastTwoWeeks / (long) activeCount; String avgLastTwoWeeksString = Formatters.timeAmount().apply(avgLastTwoWeeks); String avgFourToTwoWeeksString = Formatters.timeAmount().apply(avgFourToTwoWeeks); if (avgFourToTwoWeeks >= avgLastTwoWeeks) { diff --git a/Plan/src/main/java/com/djrapitops/plan/data/store/mutators/PlayersMutator.java b/Plan/src/main/java/com/djrapitops/plan/data/store/mutators/PlayersMutator.java index 420bd4bd4..2cce31746 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/store/mutators/PlayersMutator.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/store/mutators/PlayersMutator.java @@ -112,6 +112,8 @@ public class PlayersMutator { activityData.put(time, map); } } + } else { + activityData.put(date, Collections.emptyMap()); } return activityData; } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/FetchOperations.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/FetchOperations.java index 40f74eb32..c2307fffe 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/FetchOperations.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/FetchOperations.java @@ -16,8 +16,10 @@ public interface FetchOperations { ServerContainer getServerContainer(UUID serverUUID); + @Deprecated ServerProfile getServerProfile(UUID serverUUID); + @Deprecated List getPlayers(UUID serverUUID); // UUIDs @@ -66,6 +68,7 @@ public interface FetchOperations { List getNicknamesOfPlayerOnServer(UUID uuid, UUID serverUUID); + @Deprecated List getActions(UUID uuid); Map getUsers(); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/TPSInsertProcessor.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/TPSInsertProcessor.java index 215303a40..3badd004b 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/TPSInsertProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/TPSInsertProcessor.java @@ -8,7 +8,6 @@ import com.djrapitops.plan.data.container.TPS; import com.djrapitops.plan.data.container.builders.TPSBuilder; import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.processing.CriticalRunnable; -import com.djrapitops.plan.utilities.analysis.MathUtils; import java.util.List; @@ -29,12 +28,12 @@ public class TPSInsertProcessor implements CriticalRunnable { public void run() { List history = tpsList; final long lastDate = history.get(history.size() - 1).getDate(); - final double averageTPS = MathUtils.round(MathUtils.averageDouble(history.stream().map(TPS::getTicksPerSecond))); + final double averageTPS = history.stream().mapToDouble(TPS::getTicksPerSecond).average().orElse(0); final int peakPlayersOnline = history.stream().mapToInt(TPS::getPlayers).max().orElse(0); - final double averageCPUUsage = MathUtils.round(MathUtils.averageDouble(history.stream().map(TPS::getCPUUsage))); - final long averageUsedMemory = MathUtils.averageLong(history.stream().map(TPS::getUsedMemory)); - final int averageEntityCount = (int) MathUtils.averageInt(history.stream().map(TPS::getEntityCount)); - final int averageChunksLoaded = (int) MathUtils.averageInt(history.stream().map(TPS::getChunksLoaded)); + final double averageCPUUsage = history.stream().mapToDouble(TPS::getCPUUsage).average().orElse(0); + final long averageUsedMemory = (long) history.stream().mapToLong(TPS::getUsedMemory).average().orElse(0); + final int averageEntityCount = (int) history.stream().mapToInt(TPS::getEntityCount).average().orElse(0); + final int averageChunksLoaded = (int) history.stream().mapToInt(TPS::getChunksLoaded).average().orElse(0); TPS tps = TPSBuilder.get() .date(lastDate) diff --git a/Plan/src/main/java/com/djrapitops/plan/system/tasks/server/BukkitTPSCountTimer.java b/Plan/src/main/java/com/djrapitops/plan/system/tasks/server/BukkitTPSCountTimer.java index 0bc8a0b74..7816b6d63 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/tasks/server/BukkitTPSCountTimer.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/tasks/server/BukkitTPSCountTimer.java @@ -3,7 +3,6 @@ package com.djrapitops.plan.system.tasks.server; import com.djrapitops.plan.Plan; import com.djrapitops.plan.data.container.TPS; import com.djrapitops.plan.system.tasks.TPSCountTimer; -import com.djrapitops.plan.utilities.analysis.MathUtils; import com.djrapitops.plugin.api.TimeAmount; import com.djrapitops.plugin.api.utility.log.Log; @@ -43,7 +42,7 @@ public class BukkitTPSCountTimer extends TPSCountTimer { private TPS calculateTPS(long diff, long now) { OperatingSystemMXBean operatingSystemMXBean = ManagementFactory.getOperatingSystemMXBean(); int availableProcessors = operatingSystemMXBean.getAvailableProcessors(); - double averageCPUUsage = MathUtils.round(operatingSystemMXBean.getSystemLoadAverage() / availableProcessors * 100.0); + double averageCPUUsage = operatingSystemMXBean.getSystemLoadAverage() / availableProcessors * 100.0; if (averageCPUUsage < 0) { // If unavailable, getSystemLoadAverage() returns -1 averageCPUUsage = -1; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/tasks/server/PaperTPSCountTimer.java b/Plan/src/main/java/com/djrapitops/plan/system/tasks/server/PaperTPSCountTimer.java index 00b5fd9ce..56930fb94 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/tasks/server/PaperTPSCountTimer.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/tasks/server/PaperTPSCountTimer.java @@ -2,7 +2,6 @@ package com.djrapitops.plan.system.tasks.server; import com.djrapitops.plan.Plan; import com.djrapitops.plan.data.container.TPS; -import com.djrapitops.plan.utilities.analysis.MathUtils; import org.bukkit.World; public class PaperTPSCountTimer extends BukkitTPSCountTimer { @@ -24,8 +23,6 @@ public class PaperTPSCountTimer extends BukkitTPSCountTimer { tps = 20; } - tps = MathUtils.round(tps); - return new TPS(now, tps, playersOnline, cpuUsage, usedMemory, entityCount, chunksLoaded); } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/tasks/server/SpongeTPSCountTimer.java b/Plan/src/main/java/com/djrapitops/plan/system/tasks/server/SpongeTPSCountTimer.java index dea05e183..1ba5cf2ff 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/tasks/server/SpongeTPSCountTimer.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/tasks/server/SpongeTPSCountTimer.java @@ -5,7 +5,6 @@ import com.djrapitops.plan.data.container.TPS; import com.djrapitops.plan.data.container.builders.TPSBuilder; import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plan.system.tasks.TPSCountTimer; -import com.djrapitops.plan.utilities.analysis.MathUtils; import com.djrapitops.plugin.api.utility.log.Log; import org.spongepowered.api.Sponge; import org.spongepowered.api.world.World; @@ -46,7 +45,7 @@ public class SpongeTPSCountTimer extends TPSCountTimer { private TPS calculateTPS(long diff, long now) { OperatingSystemMXBean operatingSystemMXBean = ManagementFactory.getOperatingSystemMXBean(); int availableProcessors = operatingSystemMXBean.getAvailableProcessors(); - double averageCPUUsage = MathUtils.round(operatingSystemMXBean.getSystemLoadAverage() / availableProcessors * 100.0); + double averageCPUUsage = operatingSystemMXBean.getSystemLoadAverage() / availableProcessors * 100.0; if (averageCPUUsage < 0) { // If unavailable, getSystemLoadAverage() returns -1 averageCPUUsage = -1; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/parsing/AnalysisPage.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/parsing/AnalysisPage.java index 9164630a8..3e90f5671 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/parsing/AnalysisPage.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/parsing/AnalysisPage.java @@ -12,6 +12,8 @@ import com.djrapitops.plan.utilities.file.FileUtil; import java.io.IOException; +import static com.djrapitops.plan.data.store.keys.AnalysisKeys.*; + /** * Used for parsing a Html String out of AnalysisData and the html file. * @@ -36,48 +38,48 @@ public class AnalysisPage extends Page { @Override public String toHtml() throws ParseException { PlaceholderReplacer placeholderReplacer = new PlaceholderReplacer(); -// placeholderReplacer.addAllPlaceholdersFrom(analysisContainer, -// VERSION, SERVER_NAME, TIME_ZONE, -// FIRST_DAY, TPS_MEDIUM, TPS_HIGH, -// PLAYERS_MAX, PLAYERS_ONLINE, PLAYERS_TOTAL, -// -// WORLD_PIE_COLORS, GM_PIE_COLORS, ACTIVITY_PIE_COLORS, -// PLAYERS_GRAPH_COLOR, TPS_HIGH_COLOR, TPS_MEDIUM_COLOR, -// TPS_LOW_COLOR, WORLD_MAP_HIGH_COLOR, WORLD_MAP_LOW_COLOR, -// -// PLAYERS_TABLE, SESSION_ACCORDION_HTML, SESSION_ACCORDION_FUNCTIONS, -// SESSION_TABLE, RECENT_LOGINS, COMMAND_USAGE_TABLE, -// HEALTH_NOTES, PLUGINS_TAB, PLUGINS_TAB_NAV, -// -// REFRESH_TIME_F, LAST_PEAK_TIME_F, ALL_TIME_PEAK_TIME_F, -// AVERAGE_SESSION_LENGTH_F, AVERAGE_PLAYTIME_F, PLAYTIME_F, -// -// PLAYERS_LAST_PEAK, PLAYERS_ALL_TIME_PEAK, OPERATORS, -// PLAYERS_REGULAR, SESSION_COUNT, DEATHS, -// MOB_KILL_COUNT, PLAYER_KILL_COUNT, HEALTH_INDEX, -// COMMAND_COUNT, COMMAND_COUNT_UNIQUE, -// -// PLAYERS_DAY, PLAYERS_WEEK, PLAYERS_MONTH, -// PLAYERS_NEW_DAY, PLAYERS_NEW_WEEK, PLAYERS_NEW_MONTH, -// AVG_PLAYERS, AVG_PLAYERS_DAY, AVG_PLAYERS_WEEK, -// AVG_PLAYERS_MONTH, AVG_PLAYERS_NEW, AVG_PLAYERS_NEW_DAY, -// AVG_PLAYERS_NEW_WEEK, AVG_PLAYERS_NEW_MONTH, PLAYERS_STUCK_DAY, -// PLAYERS_STUCK_DAY_PERC, PLAYERS_RETAINED_WEEK, PLAYERS_RETAINED_WEEK_PERC, -// PLAYERS_RETAINED_MONTH, PLAYERS_RETAINED_MONTH_PERC, -// -// TPS_SPIKE_MONTH, TPS_SPIKE_WEEK, TPS_SPIKE_DAY, -// AVG_TPS_MONTH, AVG_TPS_WEEK, AVG_TPS_DAY, -// AVG_CPU_MONTH, AVG_CPU_WEEK, AVG_CPU_DAY, -// AVG_RAM_MONTH, AVG_RAM_WEEK, AVG_RAM_DAY, -// AVG_ENTITY_MONTH, AVG_ENTITY_WEEK, AVG_ENTITY_DAY, -// AVG_CHUNK_MONTH, AVG_CHUNK_WEEK, AVG_CHUNK_DAY, -// -// WORLD_PIE_SERIES, GM_PIE_SERIES, PLAYERS_ONLINE_SERIES, -// TPS_SERIES, CPU_SERIES, RAM_SERIES, -// ENTITY_SERIES, CHUNK_SERIES, PUNCHCARD_SERIES, -// WORLD_MAP_SERIES, ACTIVITY_STACK_SERIES, ACTIVITY_STACK_CATEGORIES, -// ACTIVITY_PIE_SERIES, CALENDAR_SERIES -// ); + placeholderReplacer.addAllPlaceholdersFrom(analysisContainer, + VERSION, SERVER_NAME, TIME_ZONE, + FIRST_DAY, TPS_MEDIUM, TPS_HIGH, + PLAYERS_MAX, PLAYERS_ONLINE, PLAYERS_TOTAL, + + WORLD_PIE_COLORS, GM_PIE_COLORS, ACTIVITY_PIE_COLORS, + PLAYERS_GRAPH_COLOR, TPS_HIGH_COLOR, TPS_MEDIUM_COLOR, + TPS_LOW_COLOR, WORLD_MAP_HIGH_COLOR, WORLD_MAP_LOW_COLOR, + + PLAYERS_TABLE, SESSION_ACCORDION_HTML, SESSION_ACCORDION_FUNCTIONS, + SESSION_TABLE, RECENT_LOGINS, COMMAND_USAGE_TABLE, + HEALTH_NOTES, PLUGINS_TAB, PLUGINS_TAB_NAV, + + REFRESH_TIME_F, LAST_PEAK_TIME_F, ALL_TIME_PEAK_TIME_F, + AVERAGE_SESSION_LENGTH_F, AVERAGE_PLAYTIME_F, PLAYTIME_F, + + PLAYERS_LAST_PEAK, PLAYERS_ALL_TIME_PEAK, OPERATORS, + PLAYERS_REGULAR, SESSION_COUNT, DEATHS, + MOB_KILL_COUNT, PLAYER_KILL_COUNT, HEALTH_INDEX, + COMMAND_COUNT, COMMAND_COUNT_UNIQUE, + + PLAYERS_DAY, PLAYERS_WEEK, PLAYERS_MONTH, + PLAYERS_NEW_DAY, PLAYERS_NEW_WEEK, PLAYERS_NEW_MONTH, + AVG_PLAYERS, AVG_PLAYERS_DAY, AVG_PLAYERS_WEEK, + AVG_PLAYERS_MONTH, AVG_PLAYERS_NEW, AVG_PLAYERS_NEW_DAY, + AVG_PLAYERS_NEW_WEEK, AVG_PLAYERS_NEW_MONTH, PLAYERS_RETAINED_DAY, + PLAYERS_RETAINED_DAY_PERC, PLAYERS_RETAINED_WEEK, PLAYERS_RETAINED_WEEK_PERC, + PLAYERS_RETAINED_MONTH, PLAYERS_RETAINED_MONTH_PERC, + + TPS_SPIKE_MONTH, TPS_SPIKE_WEEK, TPS_SPIKE_DAY, + AVG_TPS_MONTH, AVG_TPS_WEEK, AVG_TPS_DAY, + AVG_CPU_MONTH, AVG_CPU_WEEK, AVG_CPU_DAY, + AVG_RAM_MONTH, AVG_RAM_WEEK, AVG_RAM_DAY, + AVG_ENTITY_MONTH, AVG_ENTITY_WEEK, AVG_ENTITY_DAY, + AVG_CHUNK_MONTH, AVG_CHUNK_WEEK, AVG_CHUNK_DAY, + + WORLD_PIE_SERIES, GM_PIE_SERIES, PLAYERS_ONLINE_SERIES, + TPS_SERIES, CPU_SERIES, RAM_SERIES, + ENTITY_SERIES, CHUNK_SERIES, PUNCHCARD_SERIES, + WORLD_MAP_SERIES, ACTIVITY_STACK_SERIES, ACTIVITY_STACK_CATEGORIES, + ACTIVITY_PIE_SERIES, CALENDAR_SERIES + ); try { return placeholderReplacer.apply(FileUtil.getStringFromResource("web/server.html")); diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java b/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java index b745e1b95..f47167ba2 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java @@ -30,6 +30,7 @@ import java.util.stream.Collectors; /** * @author Rsl1122 */ +@Deprecated public class Analysis implements Callable { private static Long refreshDate; @@ -156,6 +157,7 @@ public class Analysis implements Callable { return containers; } + @Deprecated public static boolean isAnalysisBeingRun() { return serverProfile != null; } @@ -164,7 +166,7 @@ public class Analysis implements Callable { Analysis.serverProfile = serverProfile; } - private AnalysisData analyze() throws Exception { + private AnalysisData analyze() { log(Locale.get(Msg.ANALYSIS_FETCH).toString()); Log.logDebug("Analysis", "Analysis Fetch Phase"); Benchmark.start("Analysis", "Analysis: Fetch Phase"); diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/AnalysisUtils.java b/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/AnalysisUtils.java index ef72220b4..0fce0a481 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/AnalysisUtils.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/AnalysisUtils.java @@ -5,7 +5,6 @@ import com.djrapitops.plan.data.container.Session; import com.djrapitops.plan.data.store.keys.SessionKeys; import com.djrapitops.plan.data.store.mutators.ActivityIndex; import com.djrapitops.plan.data.store.mutators.RetentionData; -import com.djrapitops.plan.data.time.GMTimes; import com.djrapitops.plan.data.time.WorldTimes; import com.djrapitops.plan.system.settings.WorldAliasSettings; import com.djrapitops.plan.utilities.FormatUtils; @@ -15,17 +14,17 @@ import java.util.*; import java.util.stream.Collectors; /** + * Class that contains various methods that are used in analysis. + * * @author Rsl1122 */ public class AnalysisUtils { - /** - * Constructor used to hide the public constructor - */ private AnalysisUtils() { - throw new IllegalStateException("Utility class"); + /* static method class.*/ } + @Deprecated public static long getNewPlayers(List registered, long scale, long now) { long newPlayers = 0; if (!registered.isEmpty()) { @@ -38,6 +37,7 @@ public class AnalysisUtils { return newPlayers; } + @Deprecated public static int getUniquePlayers(Map> sessions, long after) { Set uuids = new HashSet<>(); @@ -71,7 +71,7 @@ public class AnalysisUtils { } }); - int total = MathUtils.sumInt(uniqueJoins.values().stream().map(Set::size)); + int total = uniqueJoins.values().stream().mapToInt(Set::size).sum(); int numberOfDays = uniqueJoins.size(); if (numberOfDays == 0) { @@ -81,6 +81,7 @@ public class AnalysisUtils { return total / numberOfDays; } + @Deprecated public static long getNewUsersPerDay(List registers, long after, long total) { Set days = new HashSet<>(); for (Long date : registers) { @@ -128,7 +129,7 @@ public class AnalysisUtils { } public static int getDayOfYear(Session session) { - return getDayOfYear(session.getSessionStart()); + return getDayOfYear(session.getUnsafe(SessionKeys.START)); } @@ -216,33 +217,6 @@ public class AnalysisUtils { return playtimePerAlias; } - public static Map getGMTimesPerAlias(WorldTimes worldTimes) { - Map aliases = WorldAliasSettings.getAliases(); - - Map gmTimesPerAlias = new HashMap<>(); - - String[] gms = GMTimes.getGMKeyArray(); - - for (Map.Entry entry : worldTimes.getWorldTimes().entrySet()) { - String worldName = entry.getKey(); - GMTimes gmTimes = entry.getValue(); - - if (!aliases.containsKey(worldName)) { - aliases.put(worldName, worldName); - WorldAliasSettings.addWorld(worldName); - } - - String alias = aliases.get(worldName); - - GMTimes aliasGMTimes = gmTimesPerAlias.getOrDefault(alias, new GMTimes()); - for (String gm : gms) { - aliasGMTimes.addTime(gm, gmTimes.getTime(gm)); - } - gmTimesPerAlias.put(alias, aliasGMTimes); - } - return gmTimesPerAlias; - } - public static RetentionData average(Collection stuck) { int size = stuck.size(); diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/MathUtils.java b/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/MathUtils.java index 5078a1433..1df4a374b 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/MathUtils.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/MathUtils.java @@ -11,6 +11,7 @@ import java.util.stream.Stream; /** * @author Rsl1122 */ +@Deprecated public class MathUtils { private static final DecimalFormatSymbols decimalFormatSymbols = new DecimalFormatSymbols(Locale.ENGLISH); diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/comparators/ActionComparator.java b/Plan/src/main/java/com/djrapitops/plan/utilities/comparators/ActionComparator.java index 08ea1e9eb..fc26c4316 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/comparators/ActionComparator.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/comparators/ActionComparator.java @@ -9,6 +9,7 @@ import java.util.Comparator; * * @author Rsl1122 */ +@Deprecated public class ActionComparator implements Comparator { @Override diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/comparators/PlayerProfileLastPlayedComparator.java b/Plan/src/main/java/com/djrapitops/plan/utilities/comparators/PlayerProfileLastPlayedComparator.java index 6b47ef27e..275f18054 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/comparators/PlayerProfileLastPlayedComparator.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/comparators/PlayerProfileLastPlayedComparator.java @@ -14,6 +14,7 @@ import java.util.Comparator; * * @author Rsl1122 */ +@Deprecated public class PlayerProfileLastPlayedComparator implements Comparator { @Override diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/pie/WorldPie.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/pie/WorldPie.java index ec5d3b4b2..e68cd993d 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/pie/WorldPie.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/pie/WorldPie.java @@ -3,15 +3,13 @@ package com.djrapitops.plan.utilities.html.graphs.pie; import com.djrapitops.plan.data.time.GMTimes; import com.djrapitops.plan.data.time.WorldTimes; import com.djrapitops.plan.system.settings.Settings; +import com.djrapitops.plan.system.settings.WorldAliasSettings; import com.djrapitops.plan.system.settings.theme.Theme; import com.djrapitops.plan.system.settings.theme.ThemeVal; import com.djrapitops.plan.utilities.analysis.AnalysisUtils; import com.djrapitops.plan.utilities.comparators.PieSliceComparator; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; +import java.util.*; public class WorldPie extends AbstractPieChartWithDrilldown { @@ -49,12 +47,39 @@ public class WorldPie extends AbstractPieChartWithDrilldown { return slices; } + private Map getGMTimesPerAlias() { + Map aliases = WorldAliasSettings.getAliases(); + + Map gmTimesPerAlias = new HashMap<>(); + + String[] gms = GMTimes.getGMKeyArray(); + + for (Map.Entry entry : worldTimes.getWorldTimes().entrySet()) { + String worldName = entry.getKey(); + GMTimes gmTimes = entry.getValue(); + + if (!aliases.containsKey(worldName)) { + aliases.put(worldName, worldName); + WorldAliasSettings.addWorld(worldName); + } + + String alias = aliases.get(worldName); + + GMTimes aliasGMTimes = gmTimesPerAlias.getOrDefault(alias, new GMTimes()); + for (String gm : gms) { + aliasGMTimes.addTime(gm, gmTimes.getTime(gm)); + } + gmTimesPerAlias.put(alias, aliasGMTimes); + } + return gmTimesPerAlias; + } + @Override public String toHighChartsDrilldown() { StringBuilder drilldownBuilder = new StringBuilder(); int i = 0; - Map gmTimesAliasMap = AnalysisUtils.getGMTimesPerAlias(worldTimes); + Map gmTimesAliasMap = getGMTimesPerAlias(); if (gmTimesAliasMap.isEmpty()) { return "[]"; } diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/ActionsTable.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/ActionsTable.java index 71aa4a7c8..ab48d15d1 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/ActionsTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/ActionsTable.java @@ -18,6 +18,7 @@ import java.util.List; * * @author Rsl1122 */ +@Deprecated public class ActionsTable extends TableContainer { public ActionsTable(List actions) { diff --git a/Plan/src/test/java/com/djrapitops/plan/data/store/KeyTest.java b/Plan/src/test/java/com/djrapitops/plan/data/store/KeyTest.java new file mode 100644 index 000000000..a88abccbb --- /dev/null +++ b/Plan/src/test/java/com/djrapitops/plan/data/store/KeyTest.java @@ -0,0 +1,53 @@ +package com.djrapitops.plan.data.store; + +import org.junit.Test; + +import java.util.ArrayList; +import java.util.List; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; + +/** + * Equals test for Key objects. + * + * @author Rsl1122 + */ +public class KeyTest { + + @Test + public void twoInstancesAreEqual() { + Key testKey = new Key<>(Integer.class, "test"); + Key testKey2 = new Key<>(Integer.class, "test"); + assertEquals(testKey, testKey2); + } + + @Test + public void twoComplexInstancesAreEqual() { + Key> testKey = new Key<>(new Type>() {}, "test"); + Key> testKey2 = new Key<>(new Type>() {}, "test"); + assertEquals(testKey, testKey2); + } + + @Test + public void twoComplexInstancesAreNotEqual() { + Key> testKey = new Key<>(new Type>() {}, "test"); + Key> testKey2 = new Key<>(new Type>() {}, "test"); + assertNotEquals(testKey, testKey2); + } + + @Test + public void twoComplexInstancesAreNotEqual2() { + Key> testKey = new Key<>(new Type>() {}, "test"); + Key> testKey2 = new Key<>(new Type>() {}, "test"); + assertNotEquals(testKey, testKey2); + } + + @Test + public void twoInstancesAreNotEqual() { + Key testKey = new Key<>(Integer.class, "test"); + Key> testKey2 = new Key<>(new Type>() {}, "test"); + assertNotEquals(testKey, testKey2); + } + +} \ No newline at end of file diff --git a/Plan/src/test/java/com/djrapitops/plan/system/database/databases/SQLiteTest.java b/Plan/src/test/java/com/djrapitops/plan/system/database/databases/SQLiteTest.java index ca87bd11b..b5e576f82 100644 --- a/Plan/src/test/java/com/djrapitops/plan/system/database/databases/SQLiteTest.java +++ b/Plan/src/test/java/com/djrapitops/plan/system/database/databases/SQLiteTest.java @@ -24,7 +24,6 @@ import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plan.system.processing.processors.player.RegisterProcessor; import com.djrapitops.plan.utilities.Base64Util; import com.djrapitops.plan.utilities.SHA256Hash; -import com.djrapitops.plan.utilities.analysis.MathUtils; import com.djrapitops.plugin.StaticHolder; import com.djrapitops.plugin.api.TimeAmount; import com.djrapitops.plugin.api.utility.log.Log; @@ -652,7 +651,7 @@ public class SQLiteTest { Random r = new Random(); OperatingSystemMXBean operatingSystemMXBean = ManagementFactory.getOperatingSystemMXBean(); int availableProcessors = ManagementFactory.getOperatingSystemMXBean().getAvailableProcessors(); - final double averageCPUUsage = MathUtils.round(operatingSystemMXBean.getSystemLoadAverage() / availableProcessors * 100.0); + final double averageCPUUsage = operatingSystemMXBean.getSystemLoadAverage() / availableProcessors * 100.0; final long usedMemory = 51231251254L; final int entityCount = 6123; final int chunksLoaded = 2134; diff --git a/Plan/src/test/java/com/djrapitops/plan/utilities/analysis/MathUtilsTest.java b/Plan/src/test/java/com/djrapitops/plan/utilities/analysis/MathUtilsTest.java deleted file mode 100644 index 0039baf53..000000000 --- a/Plan/src/test/java/com/djrapitops/plan/utilities/analysis/MathUtilsTest.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package com.djrapitops.plan.utilities.analysis; - -import org.junit.Test; -import utilities.RandomData; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -import static org.junit.Assert.assertTrue; - -/** - * @author Rsl1122 - */ -public class MathUtilsTest { - - @Test - public void testAverageInt() { - List integers = Arrays.asList(0, 20, 5, 15); - - double exp = 10; - double result = MathUtils.averageInt(integers.stream()); - - assertTrue(Double.compare(exp, result) == 0); - } - - @Test - public void testAverageIntEmpty() { - List integers = Collections.emptyList(); - - double exp = 0; - double result = MathUtils.averageInt(integers.stream()); - - assertTrue(result + "/" + exp, Double.compare(exp, result) == 0); - } - - @Test - public void testAverageLongCollection() { - List longs = Arrays.asList(0L, 20L, 5L, 15L); - - double exp = 10; - double result = MathUtils.averageLong(longs); - - assertTrue(result + "/" + exp, Double.compare(exp, result) == 0); - } - - @Test - public void testAverageDouble() { - List doubles = Arrays.asList(0.0, 20.5, 4.5, 15.0); - - double exp = 10; - double result = MathUtils.averageDouble(doubles.stream()); - - assertTrue(result + "/" + exp, Double.compare(exp, result) == 0); - - } - - @Test - public void testAverage() { - double exp = 10; - double result = MathUtils.average(40, 4); - - assertTrue(result + "/" + exp, Double.compare(exp, result) == 0); - } - - @Test - public void testCountTrueBoolean() { - List booleans = new ArrayList<>(); - - int exp = RandomData.randomInt(0, 1000); - for (int i = 0; i < exp; i++) { - booleans.add(true); - } - - for (int i = exp; i < RandomData.randomInt(100, 1000); i++) { - booleans.add(false); - } - - long result = MathUtils.countTrueBoolean(booleans.stream()); - - assertTrue(result + "/" + exp, Double.compare(exp, result) == 0); - } - - @Test - public void testSumInt() { - List serializable = Arrays.asList(0, 20, 5, 15); - - double exp = 40; - double result = MathUtils.sumInt(serializable.stream()); - - assertTrue(result + "/" + exp, Double.compare(exp, result) == 0); - } - - @Test - public void testSumLong() { - List serializable = Arrays.asList(0L, 20L, 5L, 15L); - - long exp = 40; - long result = MathUtils.sumLong(serializable.stream()); - - assertTrue(result + "/" + exp, Double.compare(exp, result) == 0); - } - - @Test - public void testSumDouble() { - List serializable = Arrays.asList(0.0, 50.4, 45.0, 5.0531541); - - double exp = 100.4531541; - double result = MathUtils.sumDouble(serializable.stream()); - - assertTrue(result + "/" + exp, Double.compare(exp, result) == 0); - } - - @Test - public void testRoundDouble() { - double exp = 412.5123125123; - double result = MathUtils.round(exp); - - assertTrue(result + "/" + exp, Double.compare(412.51, result) == 0); - } -}