mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-08-26 22:49:51 +02:00
[Debt] Removed static methods in Formatters class.
Added instance variables for different Formatter objects with a TODO to accompany the additions where dagger injection was not yet possible. Affected issues: none
This commit is contained in:
parent
b104e8ca03
commit
8d36b08acb
|
@ -2,7 +2,6 @@ package com.djrapitops.plan.command.commands.manage;
|
|||
|
||||
import com.djrapitops.plan.api.exceptions.database.DBException;
|
||||
import com.djrapitops.plan.api.exceptions.database.DBInitException;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatters;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.database.databases.sql.SQLiteDB;
|
||||
|
@ -13,6 +12,8 @@ import com.djrapitops.plan.system.locale.lang.DeepHelpLang;
|
|||
import com.djrapitops.plan.system.locale.lang.ManageLang;
|
||||
import com.djrapitops.plan.system.processing.Processing;
|
||||
import com.djrapitops.plan.system.settings.Permissions;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatter;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatters;
|
||||
import com.djrapitops.plugin.command.CommandNode;
|
||||
import com.djrapitops.plugin.command.CommandType;
|
||||
import com.djrapitops.plugin.command.ISender;
|
||||
|
@ -41,13 +42,17 @@ public class ManageBackupCommand extends CommandNode {
|
|||
private final SQLiteDB.Factory sqliteFactory;
|
||||
private final ErrorHandler errorHandler;
|
||||
|
||||
private final Formatter<Long> iso8601LongFormatter;
|
||||
|
||||
@Inject
|
||||
public ManageBackupCommand(
|
||||
Locale locale,
|
||||
Processing processing,
|
||||
DBSystem dbSystem,
|
||||
SQLiteDB.Factory sqliteFactory,
|
||||
ErrorHandler errorHandler) {
|
||||
Formatters formatters,
|
||||
ErrorHandler errorHandler
|
||||
) {
|
||||
super("backup", Permissions.MANAGE.getPermission(), CommandType.CONSOLE);
|
||||
|
||||
this.locale = locale;
|
||||
|
@ -56,6 +61,8 @@ public class ManageBackupCommand extends CommandNode {
|
|||
this.sqliteFactory = sqliteFactory;
|
||||
this.errorHandler = errorHandler;
|
||||
|
||||
this.iso8601LongFormatter = formatters.iso8601NoClockLong();
|
||||
|
||||
setShortHelp(locale.getString(CmdHelpLang.MANAGE_BACKUP));
|
||||
setInDepthHelp(locale.getArray(DeepHelpLang.MANAGE_BACKUP));
|
||||
setArguments("<DB>");
|
||||
|
@ -105,7 +112,7 @@ public class ManageBackupCommand extends CommandNode {
|
|||
private void createNewBackup(String dbName, Database copyFromDB) {
|
||||
SQLiteDB backupDB = null;
|
||||
try {
|
||||
String timeStamp = Formatters.iso8601NoClock_Old().apply(System::currentTimeMillis);
|
||||
String timeStamp = iso8601LongFormatter.apply(System.currentTimeMillis());
|
||||
String fileName = dbName + "-backup-" + timeStamp;
|
||||
backupDB = sqliteFactory.usingFileCalled(fileName);
|
||||
Collection<UUID> uuids = copyFromDB.fetch().getSavedUUIDs();
|
||||
|
|
|
@ -6,7 +6,7 @@ import com.djrapitops.plan.data.store.objects.DateHolder;
|
|||
import com.djrapitops.plan.data.time.WorldTimes;
|
||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
import com.djrapitops.plan.system.settings.WorldAliasSettings;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatters;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatter;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
|
@ -221,6 +221,7 @@ public class Session extends DataContainer implements DateHolder {
|
|||
return afkTime;
|
||||
}
|
||||
|
||||
@Deprecated // TODO Move this method elsewhere
|
||||
private String getLongestWorldPlayed() {
|
||||
Map<String, String> aliases = WorldAliasSettings.getAliases_Old();
|
||||
if (worldTimes == null) {
|
||||
|
@ -246,6 +247,7 @@ public class Session extends DataContainer implements DateHolder {
|
|||
|
||||
double quotient = longest * 1.0 / total;
|
||||
|
||||
return theWorld + " (" + Formatters.percentage_Old().apply(quotient) + ")";
|
||||
Formatter<Double> percentageFormatter = null; // TODO
|
||||
return theWorld + " (" + percentageFormatter.apply(quotient) + ")";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import com.djrapitops.plan.data.store.keys.ServerKeys;
|
|||
import com.djrapitops.plan.data.store.mutators.*;
|
||||
import com.djrapitops.plan.data.store.mutators.combiners.MultiBanCombiner;
|
||||
import com.djrapitops.plan.data.store.mutators.health.HealthInformation;
|
||||
import com.djrapitops.plan.data.store.objects.DateHolder;
|
||||
import com.djrapitops.plan.data.time.WorldTimes;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.info.server.properties.ServerProperties;
|
||||
|
@ -17,7 +18,7 @@ import com.djrapitops.plan.system.settings.theme.Theme;
|
|||
import com.djrapitops.plan.system.settings.theme.ThemeVal;
|
||||
import com.djrapitops.plan.utilities.MiscUtils;
|
||||
import com.djrapitops.plan.utilities.analysis.ServerBanDataReader;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatters;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatter;
|
||||
import com.djrapitops.plan.utilities.html.graphs.Graphs;
|
||||
import com.djrapitops.plan.utilities.html.graphs.bar.BarGraph;
|
||||
import com.djrapitops.plan.utilities.html.graphs.line.PingGraph;
|
||||
|
@ -55,6 +56,11 @@ public class AnalysisContainer extends DataContainer {
|
|||
private ServerProperties serverProperties;
|
||||
private Graphs graphs;
|
||||
|
||||
private Formatter<DateHolder> yearFormatter;
|
||||
private Formatter<Long> secondLongFormatter;
|
||||
private Formatter<Long> timeAmountFormatter;
|
||||
private Formatter<Double> percentageFormatter;
|
||||
|
||||
private static final Key<Map<UUID, String>> serverNames = new Key<>(new Type<Map<UUID, String>>() {}, "SERVER_NAMES");
|
||||
|
||||
public AnalysisContainer(ServerContainer serverContainer) {
|
||||
|
@ -93,7 +99,7 @@ public class AnalysisContainer extends DataContainer {
|
|||
putRawData(AnalysisKeys.ANALYSIS_TIME_DAY_AGO, now - TimeUnit.DAYS.toMillis(1L));
|
||||
putRawData(AnalysisKeys.ANALYSIS_TIME_WEEK_AGO, now - TimeAmount.WEEK.toMillis(1L));
|
||||
putRawData(AnalysisKeys.ANALYSIS_TIME_MONTH_AGO, now - TimeAmount.MONTH.toMillis(1L));
|
||||
putSupplier(AnalysisKeys.REFRESH_TIME_F, () -> Formatters.second_Old().apply(() -> getUnsafe(AnalysisKeys.ANALYSIS_TIME)));
|
||||
putSupplier(AnalysisKeys.REFRESH_TIME_F, () -> secondLongFormatter.apply(getUnsafe(AnalysisKeys.ANALYSIS_TIME)));
|
||||
|
||||
putRawData(AnalysisKeys.VERSION, version);
|
||||
putSupplier(AnalysisKeys.TIME_ZONE, MiscUtils::getTimeZoneOffsetHours);
|
||||
|
@ -146,11 +152,11 @@ public class AnalysisContainer extends DataContainer {
|
|||
);
|
||||
putSupplier(AnalysisKeys.LAST_PEAK_TIME_F, () ->
|
||||
serverContainer.getValue(ServerKeys.RECENT_PEAK_PLAYERS)
|
||||
.map(dateObj -> Formatters.year_Old().apply(dateObj)).orElse("-")
|
||||
.map(dateObj -> yearFormatter.apply(dateObj)).orElse("-")
|
||||
);
|
||||
putSupplier(AnalysisKeys.ALL_TIME_PEAK_TIME_F, () ->
|
||||
serverContainer.getValue(ServerKeys.ALL_TIME_PEAK_PLAYERS)
|
||||
.map(dateObj -> Formatters.year_Old().apply(dateObj)).orElse("-")
|
||||
.map(dateObj -> yearFormatter.apply(dateObj)).orElse("-")
|
||||
);
|
||||
putSupplier(AnalysisKeys.OPERATORS, () -> serverContainer.getValue(ServerKeys.OPERATORS).map(List::size).orElse(0));
|
||||
putSupplier(AnalysisKeys.PLAYERS_TABLE, () ->
|
||||
|
@ -241,21 +247,23 @@ public class AnalysisContainer extends DataContainer {
|
|||
putSupplier(AnalysisKeys.PLAYERS_RETAINED_DAY_PERC, () -> {
|
||||
try {
|
||||
Integer playersNewDay = getUnsafe(AnalysisKeys.PLAYERS_NEW_DAY);
|
||||
return playersNewDay != 0 ? Formatters.percentage_Old().apply(1.0 * getUnsafe(retentionDay) / playersNewDay) : "-";
|
||||
return playersNewDay != 0
|
||||
? percentageFormatter.apply(1.0 * getUnsafe(retentionDay) / playersNewDay)
|
||||
: "-";
|
||||
} catch (IllegalStateException noPlayersAfterDateFiltering) {
|
||||
return "Not enough data";
|
||||
}
|
||||
});
|
||||
putSupplier(AnalysisKeys.PLAYERS_RETAINED_WEEK_PERC, () -> {
|
||||
Integer playersNewWeek = getUnsafe(AnalysisKeys.PLAYERS_NEW_WEEK);
|
||||
return playersNewWeek != 0 ? Formatters.percentage_Old().apply(
|
||||
1.0 * getUnsafe(AnalysisKeys.PLAYERS_RETAINED_WEEK) / playersNewWeek) : "-";
|
||||
return playersNewWeek != 0 ? percentageFormatter.apply(1.0 * getUnsafe(AnalysisKeys.PLAYERS_RETAINED_WEEK) / playersNewWeek) : "-";
|
||||
}
|
||||
);
|
||||
putSupplier(AnalysisKeys.PLAYERS_RETAINED_MONTH_PERC, () -> {
|
||||
Integer playersNewMonth = getUnsafe(AnalysisKeys.PLAYERS_NEW_MONTH);
|
||||
return playersNewMonth != 0 ? Formatters.percentage_Old().apply(
|
||||
1.0 * getUnsafe(AnalysisKeys.PLAYERS_RETAINED_MONTH) / playersNewMonth) : "-";
|
||||
return playersNewMonth != 0
|
||||
? percentageFormatter.apply(1.0 * getUnsafe(AnalysisKeys.PLAYERS_RETAINED_MONTH) / playersNewMonth)
|
||||
: "-";
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@ -279,25 +287,26 @@ public class AnalysisContainer extends DataContainer {
|
|||
getUnsafe(AnalysisKeys.PLAYER_NAMES), getUnsafe(AnalysisKeys.SESSIONS_MUTATOR).all()).parseHtml()
|
||||
);
|
||||
|
||||
putSupplier(AnalysisKeys.AVERAGE_SESSION_LENGTH_F, () -> Formatters.timeAmount_Old()
|
||||
.apply(getUnsafe(AnalysisKeys.SESSIONS_MUTATOR).toAverageSessionLength())
|
||||
putSupplier(AnalysisKeys.AVERAGE_SESSION_LENGTH_F,
|
||||
() -> timeAmountFormatter.apply(getUnsafe(AnalysisKeys.SESSIONS_MUTATOR).toAverageSessionLength())
|
||||
);
|
||||
putSupplier(AnalysisKeys.SESSION_COUNT, () -> getUnsafe(AnalysisKeys.SESSIONS_MUTATOR).count());
|
||||
putSupplier(AnalysisKeys.PLAYTIME_TOTAL, () -> getUnsafe(AnalysisKeys.SESSIONS_MUTATOR).toPlaytime());
|
||||
putSupplier(AnalysisKeys.DEATHS, () -> getUnsafe(AnalysisKeys.SESSIONS_MUTATOR).toDeathCount());
|
||||
putSupplier(AnalysisKeys.MOB_KILL_COUNT, () -> getUnsafe(AnalysisKeys.SESSIONS_MUTATOR).toMobKillCount());
|
||||
putSupplier(AnalysisKeys.PLAYER_KILL_COUNT, () -> getUnsafe(AnalysisKeys.SESSIONS_MUTATOR).toPlayerKillCount());
|
||||
putSupplier(AnalysisKeys.PLAYTIME_F, () -> Formatters.timeAmount_Old()
|
||||
.apply(getUnsafe(AnalysisKeys.PLAYTIME_TOTAL))
|
||||
putSupplier(AnalysisKeys.PLAYTIME_F,
|
||||
() -> timeAmountFormatter.apply(getUnsafe(AnalysisKeys.PLAYTIME_TOTAL))
|
||||
);
|
||||
putSupplier(AnalysisKeys.AVERAGE_PLAYTIME_F, () -> {
|
||||
long players = getUnsafe(AnalysisKeys.PLAYERS_TOTAL);
|
||||
return players != 0 ? Formatters.timeAmount_Old()
|
||||
.apply(getUnsafe(AnalysisKeys.PLAYTIME_TOTAL) / players) : "-";
|
||||
return players != 0
|
||||
? timeAmountFormatter.apply(getUnsafe(AnalysisKeys.PLAYTIME_TOTAL) / players)
|
||||
: "-";
|
||||
}
|
||||
);
|
||||
putSupplier(AnalysisKeys.AVERAGE_SESSION_LENGTH_F, () -> Formatters.timeAmount_Old()
|
||||
.apply(getUnsafe(AnalysisKeys.SESSIONS_MUTATOR).toAverageSessionLength())
|
||||
putSupplier(AnalysisKeys.AVERAGE_SESSION_LENGTH_F,
|
||||
() -> timeAmountFormatter.apply(getUnsafe(AnalysisKeys.SESSIONS_MUTATOR).toAverageSessionLength())
|
||||
);
|
||||
|
||||
Key<SessionsMutator> sessionsDay = new Key<>(SessionsMutator.class, "SESSIONS_DAY");
|
||||
|
|
|
@ -7,13 +7,14 @@ import com.djrapitops.plan.data.store.keys.ServerKeys;
|
|||
import com.djrapitops.plan.data.store.mutators.PlayersMutator;
|
||||
import com.djrapitops.plan.data.store.mutators.TPSMutator;
|
||||
import com.djrapitops.plan.data.store.mutators.health.NetworkHealthInformation;
|
||||
import com.djrapitops.plan.data.store.objects.DateHolder;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.settings.theme.Theme;
|
||||
import com.djrapitops.plan.system.settings.theme.ThemeVal;
|
||||
import com.djrapitops.plan.utilities.MiscUtils;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatters;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatter;
|
||||
import com.djrapitops.plan.utilities.html.graphs.Graphs;
|
||||
import com.djrapitops.plan.utilities.html.graphs.bar.BarGraph;
|
||||
import com.djrapitops.plan.utilities.html.graphs.stack.StackGraph;
|
||||
|
@ -40,6 +41,9 @@ public class NetworkContainer extends DataContainer {
|
|||
private Database database;
|
||||
private Graphs graphs;
|
||||
|
||||
private Formatter<DateHolder> yearFormatter;
|
||||
private Formatter<Long> secondLongFormatter;
|
||||
|
||||
private final Map<UUID, AnalysisContainer> serverContainers;
|
||||
|
||||
public NetworkContainer(ServerContainer bungeeContainer) {
|
||||
|
@ -80,7 +84,7 @@ public class NetworkContainer extends DataContainer {
|
|||
putRawData(NetworkKeys.REFRESH_TIME_DAY_AGO, getUnsafe(NetworkKeys.REFRESH_TIME) - TimeAmount.DAY.ms());
|
||||
putRawData(NetworkKeys.REFRESH_TIME_WEEK_AGO, getUnsafe(NetworkKeys.REFRESH_TIME) - TimeAmount.WEEK.ms());
|
||||
putRawData(NetworkKeys.REFRESH_TIME_MONTH_AGO, getUnsafe(NetworkKeys.REFRESH_TIME) - TimeAmount.MONTH.ms());
|
||||
putSupplier(NetworkKeys.REFRESH_TIME_F, () -> Formatters.second_Old().apply(() -> getUnsafe(NetworkKeys.REFRESH_TIME)));
|
||||
putSupplier(NetworkKeys.REFRESH_TIME_F, () -> secondLongFormatter.apply(getUnsafe(NetworkKeys.REFRESH_TIME)));
|
||||
|
||||
putRawData(NetworkKeys.VERSION, PlanPlugin.getInstance().getVersion());
|
||||
putSupplier(NetworkKeys.TIME_ZONE, MiscUtils::getTimeZoneOffsetHours);
|
||||
|
@ -119,10 +123,10 @@ public class NetworkContainer extends DataContainer {
|
|||
);
|
||||
|
||||
putSupplier(NetworkKeys.ALL_TIME_PEAK_TIME_F, () ->
|
||||
bungeeContainer.getValue(ServerKeys.ALL_TIME_PEAK_PLAYERS).map(Formatters.year_Old()::apply).orElse("No data")
|
||||
bungeeContainer.getValue(ServerKeys.ALL_TIME_PEAK_PLAYERS).map(yearFormatter::apply).orElse("No data")
|
||||
);
|
||||
putSupplier(NetworkKeys.RECENT_PEAK_TIME_F, () ->
|
||||
bungeeContainer.getValue(ServerKeys.RECENT_PEAK_PLAYERS).map(Formatters.year_Old()::apply).orElse("No data")
|
||||
bungeeContainer.getValue(ServerKeys.RECENT_PEAK_PLAYERS).map(yearFormatter::apply).orElse("No data")
|
||||
);
|
||||
putSupplier(NetworkKeys.PLAYERS_ALL_TIME_PEAK, () ->
|
||||
bungeeContainer.getValue(ServerKeys.ALL_TIME_PEAK_PLAYERS).map(dateObj -> "" + dateObj.getValue()).orElse("-")
|
||||
|
|
|
@ -32,6 +32,7 @@ public class SessionKeys {
|
|||
public static final Key<Integer> DEATH_COUNT = CommonKeys.DEATH_COUNT;
|
||||
public static final Key<List<PlayerDeath>> PLAYER_DEATHS = CommonKeys.PLAYER_DEATHS;
|
||||
|
||||
@Deprecated
|
||||
public static final Key<String> LONGEST_WORLD_PLAYED = new Key<>(String.class, "longest_world_played");
|
||||
|
||||
private SessionKeys() {
|
||||
|
|
|
@ -3,8 +3,7 @@ package com.djrapitops.plan.data.store.mutators.health;
|
|||
import com.djrapitops.plan.data.store.containers.PlayerContainer;
|
||||
import com.djrapitops.plan.data.store.mutators.PlayersMutator;
|
||||
import com.djrapitops.plan.data.store.mutators.SessionsMutator;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatters;
|
||||
import com.djrapitops.plan.utilities.FormatUtils;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatter;
|
||||
import com.djrapitops.plan.utilities.html.icon.Icons;
|
||||
import com.djrapitops.plugin.api.TimeAmount;
|
||||
|
||||
|
@ -20,6 +19,10 @@ public abstract class AbstractHealthInfo {
|
|||
|
||||
protected double serverHealth;
|
||||
|
||||
// TODO
|
||||
protected Formatter<Long> timeAmountFormatter;
|
||||
protected Formatter<Double> percentageFormatter;
|
||||
|
||||
public AbstractHealthInfo(long now, long monthAgo) {
|
||||
this.now = now;
|
||||
this.monthAgo = monthAgo;
|
||||
|
@ -63,7 +66,7 @@ public abstract class AbstractHealthInfo {
|
|||
regularRemainCompareSet.removeAll(veryActiveNow);
|
||||
int notRegularAnymore = regularRemainCompareSet.size();
|
||||
int remain = activeFWAGNum - notRegularAnymore;
|
||||
double percRemain = activeFWAGNum != 0 ? remain * 100.0 / activeFWAGNum : 100.0;
|
||||
double percRemain = activeFWAGNum != 0 ? remain / activeFWAGNum : 1.0;
|
||||
|
||||
int newActive = getNewActive(veryActiveNow, activeNow, regularNow, veryActiveFWAG, activeFWAG, regularFWAG);
|
||||
|
||||
|
@ -72,16 +75,16 @@ public abstract class AbstractHealthInfo {
|
|||
String remainNote = "";
|
||||
if (activeFWAGNum != 0) {
|
||||
remainNote = "<br> ";
|
||||
if (percRemain > 50) {
|
||||
if (percRemain > 0.5) {
|
||||
remainNote += Icons.GREEN_THUMB;
|
||||
} else if (percRemain > 20) {
|
||||
} else if (percRemain > 0.2) {
|
||||
remainNote += Icons.YELLOW_FLAG;
|
||||
} else {
|
||||
remainNote += Icons.RED_WARN;
|
||||
serverHealth -= 2.5;
|
||||
}
|
||||
|
||||
remainNote += " " + FormatUtils.cutDecimals(percRemain) + "% of regular players have remained active ("
|
||||
remainNote += " " + percentageFormatter.apply(percRemain) + " of regular players have remained active ("
|
||||
+ remain + "/" + activeFWAGNum + ")";
|
||||
}
|
||||
if (change > 0) {
|
||||
|
@ -113,8 +116,8 @@ public abstract class AbstractHealthInfo {
|
|||
if (activeCount != 0) {
|
||||
long avgFourToTwoWeeks = totalFourToTwoWeeks / (long) activeCount;
|
||||
long avgLastTwoWeeks = totalLastTwoWeeks / (long) activeCount;
|
||||
String avgLastTwoWeeksString = Formatters.timeAmount_Old().apply(avgLastTwoWeeks);
|
||||
String avgFourToTwoWeeksString = Formatters.timeAmount_Old().apply(avgFourToTwoWeeks);
|
||||
String avgLastTwoWeeksString = timeAmountFormatter.apply(avgLastTwoWeeks);
|
||||
String avgFourToTwoWeeksString = timeAmountFormatter.apply(avgFourToTwoWeeks);
|
||||
if (avgFourToTwoWeeks >= avgLastTwoWeeks) {
|
||||
addNote(Icons.GREEN_THUMB + " Active players seem to have things to do (Played "
|
||||
+ avgLastTwoWeeksString + " vs " + avgFourToTwoWeeksString
|
||||
|
|
|
@ -10,8 +10,6 @@ import com.djrapitops.plan.data.store.keys.AnalysisKeys;
|
|||
import com.djrapitops.plan.data.store.mutators.PlayersMutator;
|
||||
import com.djrapitops.plan.data.store.mutators.PlayersOnlineResolver;
|
||||
import com.djrapitops.plan.data.store.mutators.TPSMutator;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatter;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatters;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.utilities.FormatUtils;
|
||||
import com.djrapitops.plan.utilities.html.icon.Icons;
|
||||
|
@ -19,6 +17,7 @@ import com.djrapitops.plugin.api.TimeAmount;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* Server Health analysis mutator.
|
||||
|
@ -80,10 +79,10 @@ public class HealthInformation extends AbstractHealthInfo {
|
|||
if (playersNewMonth != 0) {
|
||||
double retainPercentage = playersRetainedMonth * 1.0 / playersNewMonth;
|
||||
if (retainPercentage >= 0.25) {
|
||||
addNote(Icons.GREEN_THUMB + " " + Formatters.percentage_Old().apply(retainPercentage)
|
||||
addNote(Icons.GREEN_THUMB + " " + percentageFormatter.apply(retainPercentage)
|
||||
+ " of new players have stuck around (" + playersRetainedMonth + "/" + playersNewMonth + ")");
|
||||
} else {
|
||||
addNote(Icons.YELLOW_FLAG + " " + Formatters.percentage_Old().apply(retainPercentage)
|
||||
addNote(Icons.YELLOW_FLAG + " " + percentageFormatter.apply(retainPercentage)
|
||||
+ " of new players have stuck around (" + playersRetainedMonth + "/" + playersNewMonth + ")");
|
||||
}
|
||||
}
|
||||
|
@ -126,15 +125,18 @@ public class HealthInformation extends AbstractHealthInfo {
|
|||
serverHealth *= 0.8;
|
||||
}
|
||||
|
||||
Formatter<Long> formatter = Formatters.timeAmount_Old();
|
||||
if (serverDownTime <= TimeAmount.DAY.ms()) {
|
||||
addNote(Icons.GREEN_THUMB + " Total Server downtime (No Data) was " + formatter.apply(serverDownTime));
|
||||
} else if (serverDownTime <= TimeAmount.WEEK.ms()) {
|
||||
addNote(Icons.YELLOW_FLAG + " Total Server downtime (No Data) was " + formatter.apply(serverDownTime));
|
||||
serverHealth *= (TimeAmount.WEEK.ms() - serverDownTime) * 1.0 / TimeAmount.WEEK.ms();
|
||||
if (serverDownTime <= TimeUnit.DAYS.toMillis(1L)) {
|
||||
addNote(Icons.GREEN_THUMB + " Total Server downtime (No Data) was " + timeAmountFormatter.apply(serverDownTime));
|
||||
} else {
|
||||
addNote(Icons.RED_WARN + " Total Server downtime (No Data) was " + formatter.apply(serverDownTime));
|
||||
serverHealth *= (TimeAmount.MONTH.ms() - serverDownTime) * 1.0 / TimeAmount.MONTH.ms();
|
||||
long weekMs = TimeAmount.WEEK.toMillis(1L);
|
||||
if (serverDownTime <= weekMs) {
|
||||
addNote(Icons.YELLOW_FLAG + " Total Server downtime (No Data) was " + timeAmountFormatter.apply(serverDownTime));
|
||||
serverHealth *= (weekMs - serverDownTime) * 1.0 / weekMs;
|
||||
} else {
|
||||
addNote(Icons.RED_WARN + " Total Server downtime (No Data) was " + timeAmountFormatter.apply(serverDownTime));
|
||||
long monthMs = TimeAmount.MONTH.toMillis(1L);
|
||||
serverHealth *= (monthMs - serverDownTime) * 1.0 / monthMs;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ public class NetworkHealthInformation extends AbstractHealthInfo {
|
|||
|
||||
private void uniquePlayersNote(int serverCount, Key<Server> serverKey, List<DataContainer> perServerContainers) {
|
||||
Icon icon;
|
||||
String uniquePlayersNote = " players visit on servers per day_Old/server on average.";
|
||||
String uniquePlayersNote = " players visit on servers per day/server on average.";
|
||||
double average = perServerContainers.stream()
|
||||
.mapToInt(c -> c.getUnsafe(AnalysisKeys.AVG_PLAYERS_MONTH))
|
||||
.average().orElse(0.0);
|
||||
|
@ -87,7 +87,7 @@ public class NetworkHealthInformation extends AbstractHealthInfo {
|
|||
|
||||
private void newPlayersNote(int serverCount, Key<Server> serverKey, List<DataContainer> perServerContainers) {
|
||||
Icon icon;
|
||||
String newPlayersNote = " players register on servers per day_Old/server on average.";
|
||||
String newPlayersNote = " players register on servers per day/server on average.";
|
||||
double average = perServerContainers.stream()
|
||||
.mapToInt(c -> c.getUnsafe(AnalysisKeys.AVG_PLAYERS_NEW_MONTH))
|
||||
.average().orElse(0.0);
|
||||
|
|
|
@ -124,7 +124,7 @@ public class Theme implements SubSystem {
|
|||
return replaced;
|
||||
}
|
||||
|
||||
public String getThemeValue(ThemeVal color) {
|
||||
private String getThemeValue(ThemeVal color) {
|
||||
return config.getString(color.getThemePath());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ package com.djrapitops.plan.utilities.formatting;
|
|||
|
||||
import com.djrapitops.plan.data.store.objects.DateHolder;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.utilities.FormatUtils;
|
||||
import com.djrapitops.plan.utilities.formatting.time.*;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
@ -23,37 +22,14 @@ public class Formatters {
|
|||
this.config = config;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static Formatter<DateHolder> year_Old() {
|
||||
return nop();
|
||||
}
|
||||
|
||||
private static Formatter<DateHolder> nop() {
|
||||
return dateHolder -> "-";
|
||||
}
|
||||
|
||||
private static Formatter<Long> nop2() {
|
||||
return l -> "-";
|
||||
}
|
||||
|
||||
public Formatter<DateHolder> year() {
|
||||
return new DateHolderFormatter(yearLong());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static Formatter<Long> yearLongValue_Old() {
|
||||
return nop2();
|
||||
}
|
||||
|
||||
public Formatter<Long> yearLong() {
|
||||
return new YearFormatter(config);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static Formatter<DateHolder> day_Old() {
|
||||
return nop();
|
||||
}
|
||||
|
||||
public Formatter<DateHolder> day() {
|
||||
return new DateHolderFormatter(dayLong());
|
||||
}
|
||||
|
@ -62,11 +38,6 @@ public class Formatters {
|
|||
return new DayFormatter(config);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static Formatter<DateHolder> second_Old() {
|
||||
return nop();
|
||||
}
|
||||
|
||||
public Formatter<DateHolder> second() {
|
||||
return new DateHolderFormatter(secondLong());
|
||||
}
|
||||
|
@ -75,11 +46,6 @@ public class Formatters {
|
|||
return new SecondFormatter(config);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static Formatter<DateHolder> clock_Old() {
|
||||
return nop();
|
||||
}
|
||||
|
||||
public Formatter<DateHolder> clock() {
|
||||
return new DateHolderFormatter(clockLong());
|
||||
}
|
||||
|
@ -88,11 +54,6 @@ public class Formatters {
|
|||
return new ClockFormatter(config);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static Formatter<DateHolder> iso8601NoClock_Old() {
|
||||
return dateHolder -> FormatUtils.formatTimeStampISO8601NoClock(dateHolder.getDate());
|
||||
}
|
||||
|
||||
public Formatter<DateHolder> iso8601NoClock() {
|
||||
return new DateHolderFormatter(iso8601NoClockLong());
|
||||
}
|
||||
|
@ -101,25 +62,15 @@ public class Formatters {
|
|||
return new ISO8601NoClockFormatter(config);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static Formatter<Long> timeAmount_Old() {
|
||||
return nop2();
|
||||
}
|
||||
|
||||
public Formatter<Long> timeAmount() {
|
||||
return new TimeAmountFormatter(config);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static Formatter<Double> percentage_Old() {
|
||||
return value -> value >= 0 ? FormatUtils.cutDecimals(value * 100.0) + "%" : "-";
|
||||
}
|
||||
|
||||
public Formatter<Double> percentage() {
|
||||
return new PercentageFormatter(decimals());
|
||||
}
|
||||
|
||||
private Formatter<Double> decimals() {
|
||||
public Formatter<Double> decimals() {
|
||||
return new DecimalFormatter(config);
|
||||
}
|
||||
}
|
|
@ -107,7 +107,7 @@ public class HtmlStructure {
|
|||
"<p><i class=\"col-deep-orange far fa-compass\"></i> Type " +
|
||||
"<span class=\"pull-right\">" + serverType + "</span></p></div>" +
|
||||
"<div class=\"col-md-4\">" +
|
||||
"<p><i class=\"far fa-clock_Old\"></i> Last Updated" +
|
||||
"<p><i class=\"far fa-clock\"></i> Last Updated" +
|
||||
"<span class=\"pull-right\"><b>" + refresh + "</b></span></p>" +
|
||||
"<br>" +
|
||||
"<a href=\"" + address + "\"><button href=\"" + address + "\" type=\"button\" class=\"pull-right btn bg-light-green waves-effect\">" +
|
||||
|
|
|
@ -3,7 +3,6 @@ package com.djrapitops.plan.utilities.html.graphs.calendar;
|
|||
import com.djrapitops.plan.data.store.containers.PlayerContainer;
|
||||
import com.djrapitops.plan.data.store.mutators.PlayersMutator;
|
||||
import com.djrapitops.plan.system.settings.theme.Theme;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatter;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatters;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
@ -17,23 +16,23 @@ import java.util.TreeMap;
|
|||
*/
|
||||
@Singleton
|
||||
public class CalendarFactory {
|
||||
|
||||
private final Formatter<Long> iso8601Formatter;
|
||||
private final Formatter<Long> timeAmountFormatter;
|
||||
private final Theme theme;
|
||||
private final Formatters formatters;
|
||||
|
||||
@Inject
|
||||
public CalendarFactory(
|
||||
Formatters formatters,
|
||||
Theme theme
|
||||
) {
|
||||
this.iso8601Formatter = formatters.iso8601NoClockLong();
|
||||
this.timeAmountFormatter = formatters.timeAmount();
|
||||
this.formatters = formatters;
|
||||
this.theme = theme;
|
||||
}
|
||||
|
||||
public PlayerCalendar playerCalendar(PlayerContainer player) {
|
||||
return new PlayerCalendar(player);
|
||||
return new PlayerCalendar(
|
||||
player,
|
||||
formatters.timeAmount(), formatters.yearLong(), formatters.iso8601NoClock(), theme
|
||||
);
|
||||
}
|
||||
|
||||
public ServerCalendar serverCalendar(
|
||||
|
@ -41,6 +40,9 @@ public class CalendarFactory {
|
|||
TreeMap<Long, Integer> uniquePerDay,
|
||||
TreeMap<Long, Integer> newPerDay
|
||||
) {
|
||||
return new ServerCalendar(mutator, uniquePerDay, newPerDay, iso8601Formatter, timeAmountFormatter, theme);
|
||||
return new ServerCalendar(
|
||||
mutator, uniquePerDay, newPerDay,
|
||||
formatters.iso8601NoClockLong(), formatters.timeAmount(), theme
|
||||
);
|
||||
}
|
||||
}
|
|
@ -9,11 +9,10 @@ import com.djrapitops.plan.data.container.Session;
|
|||
import com.djrapitops.plan.data.store.containers.PlayerContainer;
|
||||
import com.djrapitops.plan.data.store.keys.PlayerKeys;
|
||||
import com.djrapitops.plan.data.store.keys.SessionKeys;
|
||||
import com.djrapitops.plan.data.store.objects.DateHolder;
|
||||
import com.djrapitops.plan.system.settings.theme.Theme;
|
||||
import com.djrapitops.plan.system.settings.theme.ThemeVal;
|
||||
import com.djrapitops.plan.utilities.FormatUtils;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatter;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatters;
|
||||
import com.djrapitops.plugin.api.TimeAmount;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -28,19 +27,28 @@ import java.util.Map;
|
|||
*/
|
||||
public class PlayerCalendar {
|
||||
|
||||
private final Formatter<Long> timeAmountFormatter;
|
||||
private final Formatter<Long> yearLongFormatter;
|
||||
private final Formatter<DateHolder> iso8601Formatter;
|
||||
private final Theme theme;
|
||||
|
||||
private final List<Session> allSessions;
|
||||
private final long registered;
|
||||
|
||||
PlayerCalendar(PlayerContainer container) {
|
||||
this(
|
||||
container.getValue(PlayerKeys.SESSIONS).orElse(new ArrayList<>()),
|
||||
container.getValue(PlayerKeys.REGISTERED).orElse(0L)
|
||||
);
|
||||
}
|
||||
PlayerCalendar(
|
||||
PlayerContainer container,
|
||||
Formatter<Long> timeAmountFormatter,
|
||||
Formatter<Long> yearLongFormatter,
|
||||
Formatter<DateHolder> iso8601Formatter,
|
||||
Theme theme
|
||||
) {
|
||||
this.allSessions = container.getValue(PlayerKeys.SESSIONS).orElse(new ArrayList<>());
|
||||
this.registered = container.getValue(PlayerKeys.REGISTERED).orElse(0L);
|
||||
|
||||
private PlayerCalendar(List<Session> allSessions, long registered) {
|
||||
this.allSessions = allSessions;
|
||||
this.registered = registered;
|
||||
this.timeAmountFormatter = timeAmountFormatter;
|
||||
this.yearLongFormatter = yearLongFormatter;
|
||||
this.iso8601Formatter = iso8601Formatter;
|
||||
this.theme = theme;
|
||||
}
|
||||
|
||||
public String toCalendarSeries() {
|
||||
|
@ -63,7 +71,7 @@ public class PlayerCalendar {
|
|||
int sessionCount = sessions.size();
|
||||
long playtime = sessions.stream().mapToLong(Session::getLength).sum();
|
||||
|
||||
series.append(",{title: 'Playtime: ").append(Formatters.timeAmount_Old().apply(playtime))
|
||||
series.append(",{title: 'Playtime: ").append(timeAmountFormatter.apply(playtime))
|
||||
.append("',start:'").append(day)
|
||||
.append("',color: '").append(Theme.getValue_Old(ThemeVal.GREEN)).append("'")
|
||||
.append("}");
|
||||
|
@ -77,7 +85,7 @@ public class PlayerCalendar {
|
|||
private Map<String, List<Session>> getSessionsByDay() {
|
||||
Map<String, List<Session>> sessionsByDay = new HashMap<>();
|
||||
for (Session session : allSessions) {
|
||||
String day = Formatters.iso8601NoClock_Old().apply(session);
|
||||
String day = iso8601Formatter.apply(session);
|
||||
|
||||
List<Session> sessionsOfDay = sessionsByDay.getOrDefault(day, new ArrayList<>());
|
||||
sessionsOfDay.add(session);
|
||||
|
@ -89,9 +97,8 @@ public class PlayerCalendar {
|
|||
private void appendSessionsAndKills(StringBuilder series) {
|
||||
long fiveMinutes = TimeAmount.MINUTE.ms() * 5L;
|
||||
|
||||
Formatter<Long> timeFormatter = Formatters.timeAmount_Old();
|
||||
for (Session session : allSessions) {
|
||||
String length = timeFormatter.apply(session.getLength());
|
||||
String length = timeAmountFormatter.apply(session.getLength());
|
||||
|
||||
series.append(",{title: 'Session: ").append(length)
|
||||
.append("',start:").append(session.getUnsafe(SessionKeys.START))
|
||||
|
@ -105,16 +112,14 @@ public class PlayerCalendar {
|
|||
series.append(",{title: 'Killed: ").append(kill.getVictim())
|
||||
.append("',start:").append(time)
|
||||
.append(",end:").append(time + fiveMinutes)
|
||||
.append(",color: '").append(Theme.getValue_Old(ThemeVal.RED)).append("'")
|
||||
.append(",color: '").append(theme.getValue(ThemeVal.RED)).append("'")
|
||||
.append("}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void appendRegister(StringBuilder series) {
|
||||
String registered = FormatUtils.formatTimeStampYear(this.registered);
|
||||
|
||||
series.append("{title: 'Registered: ").append(registered).append("'," +
|
||||
"start: ").append(this.registered).append(",color: '").append(Theme.getValue_Old(ThemeVal.LIGHT_GREEN)).append("'}");
|
||||
series.append("{title: 'Registered: ").append(yearLongFormatter.apply(registered)).append("'," +
|
||||
"start: ").append(this.registered).append(",color: '").append(theme.getValue(ThemeVal.LIGHT_GREEN)).append("'}");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ public class ServerCalendar {
|
|||
|
||||
series.append(",{title: 'New: ").append(newPlayers)
|
||||
.append("',start:'").append(day)
|
||||
.append("',color: '").append(theme.getThemeValue(ThemeVal.LIGHT_GREEN)).append("'")
|
||||
.append("',color: '").append(theme.getValue(ThemeVal.LIGHT_GREEN)).append("'")
|
||||
.append("}");
|
||||
}
|
||||
|
||||
|
@ -91,12 +91,12 @@ public class ServerCalendar {
|
|||
|
||||
series.append(",{title: 'Playtime: ").append(timeAmountFormatter.apply(playtime))
|
||||
.append("',start:'").append(day)
|
||||
.append("',color: '").append(theme.getThemeValue(ThemeVal.GREEN)).append("'")
|
||||
.append("',color: '").append(theme.getValue(ThemeVal.GREEN)).append("'")
|
||||
.append("}");
|
||||
|
||||
series.append(",{title: 'Sessions: ").append(sessionCount)
|
||||
.append("',start:'").append(day)
|
||||
.append("',color: '").append(theme.getThemeValue(ThemeVal.TEAL)).append("'")
|
||||
.append("',color: '").append(theme.getValue(ThemeVal.TEAL)).append("'")
|
||||
.append("}");
|
||||
|
||||
series.append(",{title: 'Unique: ").append(uniquePlayers)
|
||||
|
|
|
@ -35,7 +35,7 @@ public class PieGraphFactory {
|
|||
}
|
||||
|
||||
public Pie activityPie(Map<String, Set<UUID>> activityData) {
|
||||
String[] colors = theme.getThemeValue(ThemeVal.GRAPH_ACTIVITY_PIE).split(", ");
|
||||
String[] colors = theme.getValue(ThemeVal.GRAPH_ACTIVITY_PIE).split(", ");
|
||||
return new ActivityPie(activityData, colors);
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@ public class PieGraphFactory {
|
|||
WorldAliasSettings worldAliasSettings = config.getWorldAliasSettings();
|
||||
Map<String, Long> playtimePerAlias = worldAliasSettings.getPlaytimePerAlias(worldTimes);
|
||||
Map<String, GMTimes> gmTimesPerAlias = worldAliasSettings.getGMTimesPerAlias(worldTimes);
|
||||
String[] colors = theme.getThemeValue(ThemeVal.GRAPH_WORLD_PIE).split(", ");
|
||||
String[] colors = theme.getValue(ThemeVal.GRAPH_WORLD_PIE).split(", ");
|
||||
boolean orderByPercentage = config.isTrue(Settings.ORDER_WORLD_PIE_BY_PERC);
|
||||
return new WorldPie(playtimePerAlias, gmTimesPerAlias, colors, orderByPercentage);
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ public class StackGraphFactory {
|
|||
}
|
||||
|
||||
public StackGraph activityStackGraph(TreeMap<Long, Map<String, Set<UUID>>> activityData) {
|
||||
String[] colors = theme.getThemeValue(ThemeVal.GRAPH_ACTIVITY_PIE).split(", ");
|
||||
String[] colors = theme.getValue(ThemeVal.GRAPH_ACTIVITY_PIE).split(", ");
|
||||
return new ActivityStackGraph(activityData, colors, dayFormatter);
|
||||
}
|
||||
}
|
|
@ -7,9 +7,9 @@ package com.djrapitops.plan.utilities.html.icon;
|
|||
*/
|
||||
public class Icons {
|
||||
|
||||
public static final Icon PLAYTIME = Icon.called("clock_Old").of(Color.GREEN).of(Family.REGULAR).build();
|
||||
public static final Icon SESSION_LENGTH = Icon.called("clock_Old").of(Color.TEAL).of(Family.REGULAR).build();
|
||||
public static final Icon AFK_LENGTH = Icon.called("clock_Old").of(Color.GREY).of(Family.REGULAR).build();
|
||||
public static final Icon PLAYTIME = Icon.called("clock").of(Color.GREEN).of(Family.REGULAR).build();
|
||||
public static final Icon SESSION_LENGTH = Icon.called("clock").of(Color.TEAL).of(Family.REGULAR).build();
|
||||
public static final Icon AFK_LENGTH = Icon.called("clock").of(Color.GREY).of(Family.REGULAR).build();
|
||||
public static final Icon PLAYER_KILLS = Icon.called("crosshairs").of(Color.RED).build();
|
||||
public static final Icon MOB_KILLS = Icon.called("crosshairs").of(Color.GREEN).build();
|
||||
public static final Icon DEATHS = Icon.called("skull").build();
|
||||
|
|
|
@ -47,11 +47,16 @@ public class DebugPage implements Page {
|
|||
private final Timings timings;
|
||||
private final DefaultErrorHandler errorHandler;
|
||||
|
||||
private final Formatter<DateHolder> secondFormatter;
|
||||
private final Formatter<Long> yearFormatter;
|
||||
|
||||
DebugPage(
|
||||
String version,
|
||||
Database database,
|
||||
ServerInfo serverInfo,
|
||||
ConnectionSystem connectionSystem, DebugLogger debugLogger,
|
||||
ConnectionSystem connectionSystem,
|
||||
Formatters formatters,
|
||||
DebugLogger debugLogger,
|
||||
Timings timings,
|
||||
ErrorHandler errorHandler
|
||||
) {
|
||||
|
@ -62,6 +67,9 @@ public class DebugPage implements Page {
|
|||
this.debugLogger = (CombineDebugLogger) debugLogger;
|
||||
this.timings = timings;
|
||||
this.errorHandler = (DefaultErrorHandler) errorHandler;
|
||||
|
||||
this.secondFormatter = formatters.second();
|
||||
this.yearFormatter = formatters.yearLong();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -115,14 +123,13 @@ public class DebugPage implements Page {
|
|||
content.append("<pre>### Session Cache:<br><br>");
|
||||
content.append("UUID | Session Started <br>")
|
||||
.append("-- | -- <br>");
|
||||
Formatter<Long> timeStamp = Formatters.yearLongValue_Old();
|
||||
Set<Map.Entry<UUID, Session>> sessions = SessionCache.getActiveSessions().entrySet();
|
||||
if (sessions.isEmpty()) {
|
||||
content.append("Empty");
|
||||
}
|
||||
for (Map.Entry<UUID, Session> entry : sessions) {
|
||||
UUID uuid = entry.getKey();
|
||||
String start = entry.getValue().getValue(SessionKeys.START).map(timeStamp).orElse("Unknown");
|
||||
String start = entry.getValue().getValue(SessionKeys.START).map(yearFormatter).orElse("Unknown");
|
||||
content.append(uuid.toString()).append(" | ").append(start).append("<br>");
|
||||
}
|
||||
content.append("</pre>");
|
||||
|
@ -161,8 +168,6 @@ public class DebugPage implements Page {
|
|||
content.append("Server Address | Request Type | Response | Sent<br>")
|
||||
.append("-- | -- | -- | --<br>");
|
||||
|
||||
Formatter<DateHolder> formatter = Formatters.second_Old();
|
||||
|
||||
if (logEntries.isEmpty()) {
|
||||
content.append("**No Connections Logged**<br>");
|
||||
}
|
||||
|
@ -176,7 +181,7 @@ public class DebugPage implements Page {
|
|||
content.append(address).append(" | ")
|
||||
.append(infoRequest).append(" | ")
|
||||
.append(logEntry.getResponseCode()).append(" | ")
|
||||
.append(formatter.apply(logEntry)).append("<br>");
|
||||
.append(secondFormatter.apply(logEntry)).append("<br>");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@ import com.djrapitops.plan.system.settings.Settings;
|
|||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.settings.theme.Theme;
|
||||
import com.djrapitops.plan.system.settings.theme.ThemeVal;
|
||||
import com.djrapitops.plan.utilities.FormatUtils;
|
||||
import com.djrapitops.plan.utilities.MiscUtils;
|
||||
import com.djrapitops.plan.utilities.comparators.SessionStartComparator;
|
||||
import com.djrapitops.plan.utilities.file.FileUtil;
|
||||
|
@ -52,11 +51,16 @@ public class InspectPage implements Page {
|
|||
private final ServerInfo serverInfo;
|
||||
private final Timings timings;
|
||||
|
||||
private final Formatter<Long> timeAmountFormatter;
|
||||
private final Formatter<Long> clockLongFormatter;
|
||||
private final Formatter<Long> yearLongFormatter;
|
||||
private final Formatter<Double> decimalFormatter;
|
||||
|
||||
InspectPage(
|
||||
PlayerContainer player, Map<UUID, String> serverNames,
|
||||
PlanConfig config,
|
||||
Graphs graphs,
|
||||
ServerInfo serverInfo,
|
||||
Formatters formatters, ServerInfo serverInfo,
|
||||
Timings timings
|
||||
) {
|
||||
this.player = player;
|
||||
|
@ -65,6 +69,11 @@ public class InspectPage implements Page {
|
|||
this.graphs = graphs;
|
||||
this.serverInfo = serverInfo;
|
||||
this.timings = timings;
|
||||
|
||||
timeAmountFormatter = formatters.timeAmount();
|
||||
clockLongFormatter = formatters.clockLong();
|
||||
yearLongFormatter = formatters.yearLong();
|
||||
decimalFormatter = formatters.decimals();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -90,7 +99,7 @@ public class InspectPage implements Page {
|
|||
|
||||
PlaceholderReplacer replacer = new PlaceholderReplacer();
|
||||
|
||||
replacer.put("refresh", FormatUtils.formatTimeStampClock(now));
|
||||
replacer.put("refresh", clockLongFormatter.apply(now));
|
||||
replacer.put("version", MiscUtils.getPlanVersion());
|
||||
replacer.put("timeZone", MiscUtils.getTimeZoneOffsetHours());
|
||||
|
||||
|
@ -106,7 +115,7 @@ public class InspectPage implements Page {
|
|||
String playerName = player.getValue(PlayerKeys.NAME).orElse("Unknown");
|
||||
int timesKicked = player.getValue(PlayerKeys.KICK_COUNT).orElse(0);
|
||||
|
||||
replacer.addAllPlaceholdersFrom(player, Formatters.yearLongValue_Old(),
|
||||
replacer.addAllPlaceholdersFrom(player, yearLongFormatter,
|
||||
PlayerKeys.REGISTERED, PlayerKeys.LAST_SEEN
|
||||
);
|
||||
|
||||
|
@ -135,7 +144,7 @@ public class InspectPage implements Page {
|
|||
int minPing = pingMutator.min();
|
||||
int maxPing = pingMutator.max();
|
||||
String unavailable = "Unavailable";
|
||||
replacer.put("avgPing", averagePing != -1 ? FormatUtils.cutDecimals(averagePing) + " ms" : unavailable);
|
||||
replacer.put("avgPing", averagePing != -1 ? decimalFormatter.apply(averagePing) + " ms" : unavailable);
|
||||
replacer.put("minPing", minPing != -1 ? minPing + " ms" : unavailable);
|
||||
replacer.put("maxPing", maxPing != -1 ? maxPing + " ms" : unavailable);
|
||||
|
||||
|
@ -241,7 +250,7 @@ public class InspectPage implements Page {
|
|||
long sessionAverageWeek = weekSessionsMutator.toAverageSessionLength();
|
||||
long sessionAverageMonth = monthSessionsMutator.toAverageSessionLength();
|
||||
|
||||
Formatter<Long> formatter = Formatters.timeAmount_Old();
|
||||
Formatter<Long> formatter = timeAmountFormatter;
|
||||
replacer.put("playtimeTotal", formatter.apply(playtime));
|
||||
replacer.put("playtimeDay", formatter.apply(playtimeDay));
|
||||
replacer.put("playtimeWeek", formatter.apply(playtimeWeek));
|
||||
|
@ -291,23 +300,23 @@ public class InspectPage implements Page {
|
|||
replacer.put("playerDeathCount", pvpInfoMutator.playerCausedDeaths());
|
||||
replacer.put("mobDeathCount", pvpInfoMutator.mobCausedDeaths());
|
||||
replacer.put("deathCount", pvpInfoMutator.deaths());
|
||||
replacer.put("KDR", FormatUtils.cutDecimals(pvpInfoMutator.killDeathRatio()));
|
||||
replacer.put("mobKDR", FormatUtils.cutDecimals(pvpInfoMutator.mobKillDeathRatio()));
|
||||
replacer.put("KDR", decimalFormatter.apply(pvpInfoMutator.killDeathRatio()));
|
||||
replacer.put("mobKDR", decimalFormatter.apply(pvpInfoMutator.mobKillDeathRatio()));
|
||||
|
||||
replacer.put("playerKillCountMonth", pvpInfoMutatorMonth.playerKills());
|
||||
replacer.put("mobKillCountMonth", pvpInfoMutatorMonth.mobKills());
|
||||
replacer.put("playerDeathCountMonth", pvpInfoMutatorMonth.playerCausedDeaths());
|
||||
replacer.put("mobDeathCountMonth", pvpInfoMutatorMonth.mobCausedDeaths());
|
||||
replacer.put("deathCountMonth", pvpInfoMutatorMonth.deaths());
|
||||
replacer.put("KDRMonth", FormatUtils.cutDecimals(pvpInfoMutatorMonth.killDeathRatio()));
|
||||
replacer.put("mobKDRMonth", FormatUtils.cutDecimals(pvpInfoMutatorMonth.mobKillDeathRatio()));
|
||||
replacer.put("KDRMonth", decimalFormatter.apply(pvpInfoMutatorMonth.killDeathRatio()));
|
||||
replacer.put("mobKDRMonth", decimalFormatter.apply(pvpInfoMutatorMonth.mobKillDeathRatio()));
|
||||
|
||||
replacer.put("playerKillCountWeek", pvpInfoMutatorWeek.playerKills());
|
||||
replacer.put("mobKillCountWeek", pvpInfoMutatorWeek.mobKills());
|
||||
replacer.put("playerDeathCountWeek", pvpInfoMutatorWeek.playerCausedDeaths());
|
||||
replacer.put("mobDeathCountWeek", pvpInfoMutatorWeek.mobCausedDeaths());
|
||||
replacer.put("deathCountWeek", pvpInfoMutatorWeek.deaths());
|
||||
replacer.put("KDRWeek", FormatUtils.cutDecimals(pvpInfoMutatorWeek.killDeathRatio()));
|
||||
replacer.put("mobKDRWeek", FormatUtils.cutDecimals(pvpInfoMutatorWeek.mobKillDeathRatio()));
|
||||
replacer.put("KDRWeek", decimalFormatter.apply(pvpInfoMutatorWeek.killDeathRatio()));
|
||||
replacer.put("mobKDRWeek", decimalFormatter.apply(pvpInfoMutatorWeek.mobKillDeathRatio()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import com.djrapitops.plan.system.database.databases.Database;
|
|||
import com.djrapitops.plan.system.info.connection.ConnectionSystem;
|
||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatters;
|
||||
import com.djrapitops.plan.utilities.html.graphs.Graphs;
|
||||
import com.djrapitops.plugin.benchmarking.Timings;
|
||||
import com.djrapitops.plugin.logging.debug.DebugLogger;
|
||||
|
@ -33,6 +34,7 @@ public class PageFactory {
|
|||
private final Lazy<ServerInfo> serverInfo;
|
||||
private final Lazy<ConnectionSystem> connectionSystem;
|
||||
private final Lazy<Graphs> graphs;
|
||||
private final Lazy<Formatters> formatters;
|
||||
private final Lazy<DebugLogger> debugLogger;
|
||||
private final Lazy<Timings> timings;
|
||||
private final Lazy<ErrorHandler> errorHandler;
|
||||
|
@ -44,7 +46,9 @@ public class PageFactory {
|
|||
Lazy<Database> database,
|
||||
Lazy<ServerInfo> serverInfo,
|
||||
Lazy<ConnectionSystem> connectionSystem,
|
||||
Lazy<Graphs> graphs, Lazy<DebugLogger> debugLogger,
|
||||
Lazy<Graphs> graphs,
|
||||
Lazy<Formatters> formatters,
|
||||
Lazy<DebugLogger> debugLogger,
|
||||
Lazy<Timings> timings,
|
||||
Lazy<ErrorHandler> errorHandler
|
||||
) {
|
||||
|
@ -54,15 +58,18 @@ public class PageFactory {
|
|||
this.serverInfo = serverInfo;
|
||||
this.connectionSystem = connectionSystem;
|
||||
this.graphs = graphs;
|
||||
this.formatters = formatters;
|
||||
this.debugLogger = debugLogger;
|
||||
this.timings = timings;
|
||||
this.errorHandler = errorHandler;
|
||||
}
|
||||
|
||||
public DebugPage debugPage() {
|
||||
return new DebugPage(version,
|
||||
database.get(), serverInfo.get(), connectionSystem.get(),
|
||||
debugLogger.get(), timings.get(), errorHandler.get());
|
||||
return new DebugPage(
|
||||
version,
|
||||
database.get(), serverInfo.get(), connectionSystem.get(), formatters.get(),
|
||||
debugLogger.get(), timings.get(), errorHandler.get()
|
||||
);
|
||||
}
|
||||
|
||||
public PlayersPage playersPage() {
|
||||
|
@ -76,7 +83,10 @@ public class PageFactory {
|
|||
public InspectPage inspectPage(UUID uuid) {
|
||||
PlayerContainer player = database.get().fetch().getPlayerContainer(uuid);
|
||||
Map<UUID, String> serverNames = database.get().fetch().getServerNames();
|
||||
return new InspectPage(player, serverNames, config.get(), graphs.get(), serverInfo.get(), timings.get());
|
||||
return new InspectPage(
|
||||
player, serverNames,
|
||||
config.get(), graphs.get(), formatters.get(), serverInfo.get(), timings.get()
|
||||
);
|
||||
}
|
||||
|
||||
public NetworkPage networkPage() {
|
||||
|
|
|
@ -8,7 +8,6 @@ import com.djrapitops.plan.data.store.keys.SessionKeys;
|
|||
import com.djrapitops.plan.data.store.objects.DateHolder;
|
||||
import com.djrapitops.plan.utilities.comparators.SessionStartComparator;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatter;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatters;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -24,6 +23,9 @@ import java.util.concurrent.TimeUnit;
|
|||
*/
|
||||
public class RecentLoginList {
|
||||
|
||||
// TODO
|
||||
private Formatter<DateHolder> secondFormatter;
|
||||
|
||||
private final List<PlayerContainer> players;
|
||||
|
||||
public RecentLoginList(List<PlayerContainer> players) {
|
||||
|
@ -33,8 +35,6 @@ public class RecentLoginList {
|
|||
public String toHtml() {
|
||||
List<RecentLogin> recentLogins = getMostRecentLogins();
|
||||
|
||||
Formatter<DateHolder> formatter = Formatters.second_Old();
|
||||
|
||||
if (recentLogins.isEmpty()) {
|
||||
return "<li>No Recent Logins</li>";
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ public class RecentLoginList {
|
|||
String name = recentLogin.name;
|
||||
String url = PlanAPI.getInstance().getPlayerInspectPageLink(name);
|
||||
boolean isNew = recentLogin.isNew;
|
||||
String start = formatter.apply(recentLogin);
|
||||
String start = secondFormatter.apply(recentLogin);
|
||||
|
||||
html.append("<li><a class=\"col-").append(isNew ? "light-green" : "blue").append(" font-bold\" href=\"").append(url)
|
||||
.append("\">").append(name).append("</a><span class=\"pull-right\">").append(start).append("</span></li>");
|
||||
|
|
|
@ -14,7 +14,6 @@ import com.djrapitops.plan.data.time.WorldTimes;
|
|||
import com.djrapitops.plan.system.settings.theme.Theme;
|
||||
import com.djrapitops.plan.system.settings.theme.ThemeVal;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatter;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatters;
|
||||
import com.djrapitops.plan.utilities.html.graphs.Graphs;
|
||||
import com.djrapitops.plan.utilities.html.graphs.pie.WorldPie;
|
||||
import com.djrapitops.plan.utilities.html.icon.Color;
|
||||
|
@ -39,7 +38,11 @@ public class ServerAccordion extends AbstractAccordion {
|
|||
private final Map<UUID, String> serverNames;
|
||||
private PerServerContainer perServer;
|
||||
|
||||
// TODO
|
||||
private Theme theme;
|
||||
private Graphs graphs;
|
||||
private Formatter<Long> yearLongFormatter;
|
||||
private Formatter<Long> timeAmountFormatter;
|
||||
|
||||
public ServerAccordion(PlayerContainer container, Map<UUID, String> serverNames) {
|
||||
super("server_accordion");
|
||||
|
@ -64,8 +67,6 @@ public class ServerAccordion extends AbstractAccordion {
|
|||
private void addElements() {
|
||||
int i = 0;
|
||||
|
||||
Formatter<Long> timeFormatter = Formatters.timeAmount_Old();
|
||||
|
||||
for (Map.Entry<UUID, DataContainer> entry : perServer.entrySet()) {
|
||||
UUID serverUUID = entry.getKey();
|
||||
DataContainer container = entry.getValue();
|
||||
|
@ -87,10 +88,10 @@ public class ServerAccordion extends AbstractAccordion {
|
|||
long playerKills = sessionsMutator.toPlayerKillCount();
|
||||
long deaths = sessionsMutator.toDeathCount();
|
||||
|
||||
String play = timeFormatter.apply(playtime);
|
||||
String afk = timeFormatter.apply(afkTime);
|
||||
String median = timeFormatter.apply(sessionMedian);
|
||||
String longest = timeFormatter.apply(longestSession);
|
||||
String play = timeAmountFormatter.apply(playtime);
|
||||
String afk = timeAmountFormatter.apply(afkTime);
|
||||
String median = timeAmountFormatter.apply(sessionMedian);
|
||||
String longest = timeAmountFormatter.apply(longestSession);
|
||||
|
||||
String sanitizedServerName = new Format(serverName)
|
||||
.removeSymbols()
|
||||
|
@ -106,7 +107,7 @@ public class ServerAccordion extends AbstractAccordion {
|
|||
String leftSide = new AccordionElementContentBuilder()
|
||||
.addRowBold(Icons.OPERATOR, "Operator", operator ? "Yes" : "No")
|
||||
.addRowBold(Icons.BANNED, "Banned", banned ? "Yes" : "No")
|
||||
.addRowBold(Icon.called("user-plus").of(Color.LIGHT_GREEN), "Registered", Formatters.year_Old().apply(() -> registered))
|
||||
.addRowBold(Icon.called("user-plus").of(Color.LIGHT_GREEN), "Registered", yearLongFormatter.apply(registered))
|
||||
.addBreak()
|
||||
.addRowBold(Icons.SESSION_COUNT, "Sessions", sessionCount)
|
||||
.addRowBold(Icons.PLAYTIME, "Server Playtime", play)
|
||||
|
@ -126,7 +127,7 @@ public class ServerAccordion extends AbstractAccordion {
|
|||
"</script>";
|
||||
|
||||
addElement(new AccordionElement(htmlID, title)
|
||||
.setColor(Theme.getValue_Old(ThemeVal.PARSED_SERVER_ACCORDION))
|
||||
.setColor(theme.getValue(ThemeVal.PARSED_SERVER_ACCORDION))
|
||||
.setLeftSide(leftSide)
|
||||
.setRightSide(rightSide));
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@ import com.djrapitops.plan.system.settings.theme.Theme;
|
|||
import com.djrapitops.plan.system.settings.theme.ThemeVal;
|
||||
import com.djrapitops.plan.utilities.comparators.DateHolderRecentComparator;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatter;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatters;
|
||||
import com.djrapitops.plan.utilities.html.HtmlStructure;
|
||||
import com.djrapitops.plan.utilities.html.graphs.Graphs;
|
||||
import com.djrapitops.plan.utilities.html.graphs.pie.WorldPie;
|
||||
|
@ -37,7 +36,11 @@ public class SessionAccordion extends AbstractAccordion {
|
|||
private final boolean appendWorldPercentage;
|
||||
private int maxSessions;
|
||||
|
||||
// TODO
|
||||
private Theme theme;
|
||||
private Graphs graphs;
|
||||
private Formatter<DateHolder> yearFormatter;
|
||||
private Formatter<Long> timeAmountFormatter;
|
||||
|
||||
private SessionAccordion(boolean forPlayer, List<Session> sessions,
|
||||
Supplier<Map<UUID, String>> serverNamesSupplier,
|
||||
|
@ -84,8 +87,6 @@ public class SessionAccordion extends AbstractAccordion {
|
|||
private void addElementsForServer() {
|
||||
Map<UUID, String> serverNames = serverNamesSupplier.get();
|
||||
Map<UUID, String> playerNames = playerNamesSupplier.get();
|
||||
Formatter<Long> timeFormatter = Formatters.timeAmount_Old();
|
||||
Formatter<DateHolder> timeStampFormatter = Formatters.year_Old();
|
||||
sessions.sort(new DateHolderRecentComparator());
|
||||
|
||||
int i = 0;
|
||||
|
@ -96,17 +97,17 @@ public class SessionAccordion extends AbstractAccordion {
|
|||
|
||||
String serverName = serverNames.getOrDefault(session.getValue(SessionKeys.SERVER_UUID).orElse(null), "Unknown");
|
||||
String playerName = playerNames.getOrDefault(session.getValue(SessionKeys.UUID).orElse(null), "Unknown");
|
||||
String sessionStart = timeStampFormatter.apply(session);
|
||||
String sessionStart = yearFormatter.apply(session);
|
||||
|
||||
WorldTimes worldTimes = session.getValue(SessionKeys.WORLD_TIMES).orElse(new WorldTimes(new HashMap<>()));
|
||||
WorldPie worldPie = graphs.pie().worldPie(worldTimes);
|
||||
String longestWorldPlayed = session.getValue(SessionKeys.LONGEST_WORLD_PLAYED).orElse("Unknown");
|
||||
|
||||
boolean hasEnded = session.supports(SessionKeys.END);
|
||||
String sessionEnd = hasEnded ? timeStampFormatter.apply(() -> session.getUnsafe(SessionKeys.END)) : "Online";
|
||||
String sessionEnd = hasEnded ? yearFormatter.apply(() -> session.getUnsafe(SessionKeys.END)) : "Online";
|
||||
|
||||
String length = (hasEnded ? "" : "(Online) ") + timeFormatter.apply(session.getValue(SessionKeys.LENGTH).orElse(0L));
|
||||
String afk = (hasEnded ? "" : "(Inaccurate) ") + timeFormatter.apply(session.getValue(SessionKeys.AFK_TIME).orElse(0L));
|
||||
String length = (hasEnded ? "" : "(Online) ") + timeAmountFormatter.apply(session.getValue(SessionKeys.LENGTH).orElse(0L));
|
||||
String afk = (hasEnded ? "" : "(Inaccurate) ") + timeAmountFormatter.apply(session.getValue(SessionKeys.AFK_TIME).orElse(0L));
|
||||
|
||||
int playerKillCount = session.getValue(SessionKeys.PLAYER_KILL_COUNT).orElse(0);
|
||||
int mobKillCount = session.getValue(SessionKeys.MOB_KILL_COUNT).orElse(0);
|
||||
|
@ -149,7 +150,7 @@ public class SessionAccordion extends AbstractAccordion {
|
|||
"<i class=\"material-icons\">person</i><span>INSPECT PAGE</span></button></a>";
|
||||
|
||||
addElement(new AccordionElement(htmlID, title)
|
||||
.setColor(Theme.getValue_Old(ThemeVal.PARSED_SESSION_ACCORDION))
|
||||
.setColor(theme.getValue(ThemeVal.PARSED_SESSION_ACCORDION))
|
||||
.setLeftSide(leftSide + leftBottom)
|
||||
.setRightSide(rightSide + rightBottom));
|
||||
i++;
|
||||
|
@ -158,8 +159,6 @@ public class SessionAccordion extends AbstractAccordion {
|
|||
|
||||
private void addElementsForPlayer() {
|
||||
Map<UUID, String> serverNames = serverNamesSupplier.get();
|
||||
Formatter<Long> timeFormatter = Formatters.timeAmount_Old();
|
||||
Formatter<DateHolder> timeStampFormatter = Formatters.year_Old();
|
||||
sessions.sort(new DateHolderRecentComparator());
|
||||
|
||||
int i = 0;
|
||||
|
@ -169,17 +168,17 @@ public class SessionAccordion extends AbstractAccordion {
|
|||
}
|
||||
|
||||
String serverName = serverNames.getOrDefault(session.getValue(SessionKeys.SERVER_UUID).orElse(null), "Unknown");
|
||||
String sessionStart = timeStampFormatter.apply(session);
|
||||
String sessionStart = yearFormatter.apply(session);
|
||||
|
||||
WorldTimes worldTimes = session.getValue(SessionKeys.WORLD_TIMES).orElse(new WorldTimes(new HashMap<>()));
|
||||
WorldPie worldPie = graphs.pie().worldPie(worldTimes);
|
||||
String longestWorldPlayed = session.getValue(SessionKeys.LONGEST_WORLD_PLAYED).orElse("Unknown");
|
||||
|
||||
boolean hasEnded = session.supports(SessionKeys.END);
|
||||
String sessionEnd = hasEnded ? timeStampFormatter.apply(() -> session.getValue(SessionKeys.END).orElse(0L)) : "Online";
|
||||
String sessionEnd = hasEnded ? yearFormatter.apply(() -> session.getValue(SessionKeys.END).orElse(0L)) : "Online";
|
||||
|
||||
String length = (hasEnded ? "" : "(Online) ") + timeFormatter.apply(session.getValue(SessionKeys.LENGTH).orElse(0L));
|
||||
String afk = (hasEnded ? "" : "(Inaccurate) ") + timeFormatter.apply(session.getValue(SessionKeys.AFK_TIME).orElse(0L));
|
||||
String length = (hasEnded ? "" : "(Online) ") + timeAmountFormatter.apply(session.getValue(SessionKeys.LENGTH).orElse(0L));
|
||||
String afk = (hasEnded ? "" : "(Inaccurate) ") + timeAmountFormatter.apply(session.getValue(SessionKeys.AFK_TIME).orElse(0L));
|
||||
|
||||
int playerKillCount = session.getValue(SessionKeys.PLAYER_KILL_COUNT).orElse(0);
|
||||
int mobKillCount = session.getValue(SessionKeys.MOB_KILL_COUNT).orElse(0);
|
||||
|
@ -217,7 +216,7 @@ public class SessionAccordion extends AbstractAccordion {
|
|||
String leftBottom = new KillsTable(session.getValue(SessionKeys.PLAYER_KILLS).orElse(new ArrayList<>()), null).parseHtml();
|
||||
|
||||
addElement(new AccordionElement(htmlID, title)
|
||||
.setColor(Theme.getValue_Old(ThemeVal.PARSED_SESSION_ACCORDION))
|
||||
.setColor(theme.getValue(ThemeVal.PARSED_SESSION_ACCORDION))
|
||||
.setLeftSide(leftSide + leftBottom)
|
||||
.setRightSide(rightSide));
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@ import com.djrapitops.plan.data.element.TableContainer;
|
|||
import com.djrapitops.plan.data.store.objects.DateHolder;
|
||||
import com.djrapitops.plan.utilities.comparators.DateHolderRecentComparator;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatter;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatters;
|
||||
import com.djrapitops.plan.utilities.html.Html;
|
||||
import com.djrapitops.plan.utilities.html.icon.Family;
|
||||
import com.djrapitops.plan.utilities.html.icon.Icon;
|
||||
|
@ -18,8 +17,11 @@ import java.util.List;
|
|||
*/
|
||||
public class DeathsTable extends TableContainer {
|
||||
|
||||
// TODO
|
||||
private Formatter<DateHolder> yearFormatter;
|
||||
|
||||
public DeathsTable(List<PlayerDeath> playerPlayerDeaths) {
|
||||
super(Icon.called("clock_Old").of(Family.REGULAR) + " Time", "Killed by", "With");
|
||||
super(Icon.called("clock").of(Family.REGULAR) + " Time", "Killed by", "With");
|
||||
setColor("red");
|
||||
|
||||
if (playerPlayerDeaths.isEmpty()) {
|
||||
|
@ -31,7 +33,6 @@ public class DeathsTable extends TableContainer {
|
|||
|
||||
private void addValues(List<PlayerDeath> playerPlayerDeaths) {
|
||||
playerPlayerDeaths.sort(new DateHolderRecentComparator());
|
||||
Formatter<DateHolder> timestamp = Formatters.year_Old();
|
||||
|
||||
int i = 0;
|
||||
for (PlayerDeath death : playerPlayerDeaths) {
|
||||
|
@ -41,7 +42,7 @@ public class DeathsTable extends TableContainer {
|
|||
|
||||
String killerName = death.getKillerName();
|
||||
addRow(
|
||||
timestamp.apply(death),
|
||||
yearFormatter.apply(death),
|
||||
Html.LINK.parse(PlanAPI.getInstance().getPlayerInspectPageLink(killerName), killerName),
|
||||
death.getWeapon()
|
||||
);
|
||||
|
|
|
@ -6,11 +6,9 @@ package com.djrapitops.plan.utilities.html.tables;
|
|||
|
||||
import com.djrapitops.plan.data.container.GeoInfo;
|
||||
import com.djrapitops.plan.data.element.TableContainer;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatter;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatters;
|
||||
import com.djrapitops.plan.data.store.objects.DateHolder;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.utilities.comparators.DateHolderRecentComparator;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -21,6 +19,10 @@ import java.util.List;
|
|||
*/
|
||||
public class GeoInfoTable extends TableContainer {
|
||||
|
||||
// TODO
|
||||
private boolean displayIP;
|
||||
private Formatter<DateHolder> yearFormatter;
|
||||
|
||||
public GeoInfoTable(List<GeoInfo> geoInfo) {
|
||||
super("IP", "Geolocation", "Last Used");
|
||||
|
||||
|
@ -33,15 +35,12 @@ public class GeoInfoTable extends TableContainer {
|
|||
|
||||
private void addValues(List<GeoInfo> geoInfo) {
|
||||
geoInfo.sort(new DateHolderRecentComparator());
|
||||
|
||||
boolean displayIP = Settings.DISPLAY_PLAYER_IPS.isTrue();
|
||||
Formatter<DateHolder> formatter = Formatters.year_Old();
|
||||
|
||||
for (GeoInfo info : geoInfo) {
|
||||
addRow(
|
||||
displayIP ? info.getIp() : "Hidden (Config)",
|
||||
info.getGeolocation(),
|
||||
formatter.apply(info)
|
||||
yearFormatter.apply(info)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ import com.djrapitops.plan.data.element.TableContainer;
|
|||
import com.djrapitops.plan.data.store.objects.DateHolder;
|
||||
import com.djrapitops.plan.utilities.comparators.DateHolderRecentComparator;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatter;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatters;
|
||||
import com.djrapitops.plan.utilities.html.Html;
|
||||
import com.djrapitops.plan.utilities.html.icon.Family;
|
||||
import com.djrapitops.plan.utilities.html.icon.Icon;
|
||||
|
@ -18,12 +17,15 @@ import java.util.List;
|
|||
*/
|
||||
public class KillsTable extends TableContainer {
|
||||
|
||||
// TODO
|
||||
private Formatter<DateHolder> yearFormatter;
|
||||
|
||||
public KillsTable(List<PlayerKill> playerKills) {
|
||||
this(playerKills, "red");
|
||||
}
|
||||
|
||||
public KillsTable(List<PlayerKill> playerKills, String color) {
|
||||
super(Icon.called("clock_Old").of(Family.REGULAR) + " Time", "Killed", "With");
|
||||
super(Icon.called("clock").of(Family.REGULAR) + " Time", "Killed", "With");
|
||||
setColor(color);
|
||||
|
||||
if (playerKills.isEmpty()) {
|
||||
|
@ -35,7 +37,6 @@ public class KillsTable extends TableContainer {
|
|||
|
||||
private void addValues(List<PlayerKill> playerKills) {
|
||||
playerKills.sort(new DateHolderRecentComparator());
|
||||
Formatter<DateHolder> timestamp = Formatters.year_Old();
|
||||
|
||||
int i = 0;
|
||||
for (PlayerKill kill : playerKills) {
|
||||
|
@ -45,7 +46,7 @@ public class KillsTable extends TableContainer {
|
|||
|
||||
String victimName = kill.getVictimName().orElse("Unknown");
|
||||
addRow(
|
||||
timestamp.apply(kill),
|
||||
yearFormatter.apply(kill),
|
||||
Html.LINK.parse(PlanAPI.getInstance().getPlayerInspectPageLink(victimName), victimName),
|
||||
kill.getWeapon()
|
||||
);
|
||||
|
|
|
@ -5,11 +5,10 @@
|
|||
package com.djrapitops.plan.utilities.html.tables;
|
||||
|
||||
import com.djrapitops.plan.data.element.TableContainer;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatter;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatters;
|
||||
import com.djrapitops.plan.data.store.objects.DateHolder;
|
||||
import com.djrapitops.plan.data.store.objects.Nickname;
|
||||
import com.djrapitops.plan.utilities.comparators.DateHolderRecentComparator;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatter;
|
||||
import com.djrapitops.plan.utilities.html.HtmlUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -23,6 +22,9 @@ import java.util.UUID;
|
|||
*/
|
||||
public class NicknameTable extends TableContainer {
|
||||
|
||||
// TODO
|
||||
private Formatter<DateHolder> yearFormatter;
|
||||
|
||||
public NicknameTable(List<Nickname> nicknames, Map<UUID, String> serverNames) {
|
||||
super("Nickname", "Server", "Last Seen");
|
||||
|
||||
|
@ -36,14 +38,13 @@ public class NicknameTable extends TableContainer {
|
|||
private void addValues(List<Nickname> nicknames, Map<UUID, String> serverNames) {
|
||||
nicknames.sort(new DateHolderRecentComparator());
|
||||
|
||||
Formatter<DateHolder> formatter = Formatters.year_Old();
|
||||
for (Nickname nickname : nicknames) {
|
||||
UUID serverUUID = nickname.getServerUUID();
|
||||
String serverName = serverNames.getOrDefault(serverUUID, "Unknown");
|
||||
addRow(
|
||||
HtmlUtils.swapColorsToSpan(HtmlUtils.removeXSS(nickname.getName())),
|
||||
serverName,
|
||||
formatter.apply(nickname)
|
||||
yearFormatter.apply(nickname)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,8 +6,8 @@ import com.djrapitops.plan.data.element.TableContainer;
|
|||
import com.djrapitops.plan.data.store.containers.DataContainer;
|
||||
import com.djrapitops.plan.data.store.keys.PlayerKeys;
|
||||
import com.djrapitops.plan.data.store.keys.SessionKeys;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatters;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.data.store.objects.DateHolder;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatter;
|
||||
import com.djrapitops.plan.utilities.html.Html;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -20,6 +20,11 @@ import java.util.List;
|
|||
*/
|
||||
public class PlayerSessionTable extends TableContainer {
|
||||
|
||||
// TODO
|
||||
private int maxSessions; // Should be over 0, default 50
|
||||
private Formatter<DateHolder> yearFormatter;
|
||||
private Formatter<Long> timeAmountFormatter;
|
||||
|
||||
private final String playerName;
|
||||
private final List<Session> sessions;
|
||||
|
||||
|
@ -39,11 +44,6 @@ public class PlayerSessionTable extends TableContainer {
|
|||
}
|
||||
|
||||
private void addRows() {
|
||||
int maxSessions = Settings.MAX_SESSIONS.getNumber();
|
||||
if (maxSessions <= 0) {
|
||||
maxSessions = 50;
|
||||
}
|
||||
|
||||
String inspectUrl = PlanAPI.getInstance().getPlayerInspectPageLink(playerName);
|
||||
|
||||
int i = 0;
|
||||
|
@ -52,9 +52,9 @@ public class PlayerSessionTable extends TableContainer {
|
|||
break;
|
||||
}
|
||||
|
||||
String start = Formatters.year_Old().apply(session);
|
||||
String start = yearFormatter.apply(session);
|
||||
String length = session.supports(SessionKeys.END)
|
||||
? Formatters.timeAmount_Old().apply(session.getValue(SessionKeys.LENGTH).orElse(0L))
|
||||
? timeAmountFormatter.apply(session.getValue(SessionKeys.LENGTH).orElse(0L))
|
||||
: "Online";
|
||||
String world = session.getValue(SessionKeys.LONGEST_WORLD_PLAYED).orElse("Unknown");
|
||||
|
||||
|
|
|
@ -8,9 +8,9 @@ import com.djrapitops.plan.data.store.keys.PlayerKeys;
|
|||
import com.djrapitops.plan.data.store.mutators.ActivityIndex;
|
||||
import com.djrapitops.plan.data.store.mutators.GeoInfoMutator;
|
||||
import com.djrapitops.plan.data.store.mutators.SessionsMutator;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatters;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.utilities.comparators.PlayerContainerLastPlayedComparator;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatter;
|
||||
import com.djrapitops.plan.utilities.html.Html;
|
||||
import com.djrapitops.plan.utilities.html.icon.Family;
|
||||
import com.djrapitops.plan.utilities.html.icon.Icon;
|
||||
|
@ -24,6 +24,10 @@ import java.util.List;
|
|||
*/
|
||||
public class PlayersTable extends TableContainer {
|
||||
|
||||
// TODO
|
||||
private Formatter<Long> timeAmountFormatter;
|
||||
private Formatter<Long> yearLongFormatter;
|
||||
|
||||
private final List<PlayerContainer> players;
|
||||
private final int maxPlayers;
|
||||
|
||||
|
@ -31,7 +35,7 @@ public class PlayersTable extends TableContainer {
|
|||
super(
|
||||
Icon.called("user") + " Name",
|
||||
Icon.called("check") + " Activity Index",
|
||||
Icon.called("clock_Old").of(Family.REGULAR) + " Playtime",
|
||||
Icon.called("clock").of(Family.REGULAR) + " Playtime",
|
||||
Icon.called("calendar-plus").of(Family.REGULAR) + " Sessions",
|
||||
Icon.called("user-plus") + " Registered",
|
||||
Icon.called("calendar-check").of(Family.REGULAR) + " Last Seen",
|
||||
|
@ -41,16 +45,18 @@ public class PlayersTable extends TableContainer {
|
|||
this.maxPlayers = maxPlayers;
|
||||
useJqueryDataTables("player-table");
|
||||
|
||||
setFormatter(2, Formatters.timeAmount_Old());
|
||||
setFormatter(4, Formatters.yearLongValue_Old());
|
||||
setFormatter(5, Formatters.yearLongValue_Old());
|
||||
setFormatter(2, timeAmountFormatter);
|
||||
setFormatter(4, yearLongFormatter);
|
||||
setFormatter(5, yearLongFormatter);
|
||||
addRows();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static PlayersTable forServerPage(List<PlayerContainer> players) {
|
||||
return new PlayersTable(players, Settings.MAX_PLAYERS.getNumber());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static PlayersTable forPlayersPage(List<PlayerContainer> players) {
|
||||
return new PlayersTable(players, Settings.MAX_PLAYERS_PLAYERS_PAGE.getNumber());
|
||||
}
|
||||
|
|
|
@ -4,8 +4,8 @@ import com.djrapitops.plan.api.PlanAPI;
|
|||
import com.djrapitops.plan.data.container.Session;
|
||||
import com.djrapitops.plan.data.element.TableContainer;
|
||||
import com.djrapitops.plan.data.store.keys.SessionKeys;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatters;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.data.store.objects.DateHolder;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatter;
|
||||
import com.djrapitops.plan.utilities.html.Html;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -19,6 +19,11 @@ import java.util.UUID;
|
|||
*/
|
||||
public class ServerSessionTable extends TableContainer {
|
||||
|
||||
// TODO
|
||||
private int maxSessions; // Should be over 0, default 50
|
||||
private Formatter<DateHolder> yearFormatter;
|
||||
private Formatter<Long> timeAmountFormatter;
|
||||
|
||||
private final List<Session> sessions;
|
||||
private Map<UUID, String> playerNames;
|
||||
|
||||
|
@ -31,20 +36,15 @@ public class ServerSessionTable extends TableContainer {
|
|||
}
|
||||
|
||||
private void addRows() {
|
||||
int maxSessions = Settings.MAX_SESSIONS.getNumber();
|
||||
if (maxSessions <= 0) {
|
||||
maxSessions = 50;
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
for (Session session : sessions) {
|
||||
if (i >= maxSessions) {
|
||||
break;
|
||||
}
|
||||
|
||||
String start = Formatters.year_Old().apply(session);
|
||||
String start = yearFormatter.apply(session);
|
||||
String length = session.supports(SessionKeys.END)
|
||||
? Formatters.timeAmount_Old().apply(session.getValue(SessionKeys.LENGTH).orElse(0L))
|
||||
? timeAmountFormatter.apply(session.getValue(SessionKeys.LENGTH).orElse(0L))
|
||||
: "Online";
|
||||
String world = session.getValue(SessionKeys.LONGEST_WORLD_PLAYED).orElse("Unknown");
|
||||
|
||||
|
|
|
@ -1,16 +1,13 @@
|
|||
package com.djrapitops.plan.data.store.mutators;
|
||||
|
||||
import com.djrapitops.plan.utilities.formatting.Formatters;
|
||||
import com.djrapitops.plugin.api.TimeAmount;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import utilities.Teardown;
|
||||
import utilities.mocks.SystemMockUtil;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Test for the Formatters class.
|
||||
*
|
||||
|
@ -28,17 +25,19 @@ public class FormattersTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
@Ignore("Missing Formatter")
|
||||
public void formatTimeAmount() {
|
||||
String expResult = "1s";
|
||||
String result = Formatters.timeAmount_Old().apply(TimeAmount.SECOND.ms());
|
||||
|
||||
assertEquals(expResult, result);
|
||||
// String expResult = "1s";
|
||||
// String result = timeAmountFormatter.apply(TimeAmount.SECOND.ms());
|
||||
//
|
||||
// assertEquals(expResult, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore("Missing Formatter")
|
||||
public void formatTimeAmountMonths() {
|
||||
long time = TimeAmount.DAY.ms() * 40L;
|
||||
assertEquals("1 month, 10d ", Formatters.timeAmount_Old().apply(time));
|
||||
// long time = TimeAmount.DAY.ms() * 40L;
|
||||
// assertEquals("1 month, 10d ", timeAmountFormatter.apply(time));
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user