mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-08-26 22:49:51 +02:00
Turned Formatters class non static, usages still exist
This commit is contained in:
parent
273050f1b2
commit
abc1bc3bc4
|
@ -1,7 +1,7 @@
|
|||
package com.djrapitops.plan.command.commands;
|
||||
|
||||
import com.djrapitops.plan.api.exceptions.database.DBOpException;
|
||||
import com.djrapitops.plan.data.store.mutators.formatting.Formatter;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatter;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.info.server.Server;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
|
|
|
@ -7,8 +7,8 @@ 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.data.store.mutators.formatting.Formatter;
|
||||
import com.djrapitops.plan.data.store.mutators.formatting.Formatters;
|
||||
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.database.databases.Database;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
|
@ -45,6 +45,7 @@ public class QInspectCommand extends CommandNode {
|
|||
private final Locale locale;
|
||||
private final Database database;
|
||||
private final Processing processing;
|
||||
private final Formatters formatters;
|
||||
private final UUIDUtility uuidUtility;
|
||||
private final ErrorHandler errorHandler;
|
||||
|
||||
|
@ -54,10 +55,12 @@ public class QInspectCommand extends CommandNode {
|
|||
Processing processing,
|
||||
Database database,
|
||||
UUIDUtility uuidUtility,
|
||||
Formatters formatters,
|
||||
ErrorHandler errorHandler
|
||||
) {
|
||||
super("qinspect", Permissions.QUICK_INSPECT.getPermission(), CommandType.PLAYER_OR_ARGS);
|
||||
this.processing = processing;
|
||||
this.formatters = formatters;
|
||||
setArguments("<player>");
|
||||
|
||||
this.locale = locale;
|
||||
|
@ -107,8 +110,8 @@ public class QInspectCommand extends CommandNode {
|
|||
private void sendMessages(ISender sender, PlayerContainer player) {
|
||||
long now = System.currentTimeMillis();
|
||||
|
||||
Formatter<DateHolder> timestamp = Formatters.year();
|
||||
Formatter<Long> length = Formatters.timeAmount();
|
||||
Formatter<DateHolder> timestamp = formatters.year();
|
||||
Formatter<Long> length = formatters.timeAmount();
|
||||
|
||||
String playerName = player.getValue(PlayerKeys.NAME).orElse(locale.getString(GenericLang.UNKNOWN));
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ 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.data.store.mutators.formatting.Formatters;
|
||||
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;
|
||||
|
@ -105,7 +105,7 @@ public class ManageBackupCommand extends CommandNode {
|
|||
private void createNewBackup(String dbName, Database copyFromDB) {
|
||||
SQLiteDB backupDB = null;
|
||||
try {
|
||||
String timeStamp = Formatters.iso8601NoClock().apply(System::currentTimeMillis);
|
||||
String timeStamp = Formatters.iso8601NoClock_Old().apply(System::currentTimeMillis);
|
||||
String fileName = dbName + "-backup-" + timeStamp;
|
||||
backupDB = sqliteFactory.usingFileCalled(fileName);
|
||||
Collection<UUID> uuids = copyFromDB.fetch().getSavedUUIDs();
|
||||
|
|
|
@ -2,7 +2,7 @@ package com.djrapitops.plan.data.container;
|
|||
|
||||
import com.djrapitops.plan.data.store.containers.DataContainer;
|
||||
import com.djrapitops.plan.data.store.keys.SessionKeys;
|
||||
import com.djrapitops.plan.data.store.mutators.formatting.Formatters;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatters;
|
||||
import com.djrapitops.plan.data.store.objects.DateHolder;
|
||||
import com.djrapitops.plan.data.time.WorldTimes;
|
||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
|
@ -246,6 +246,6 @@ public class Session extends DataContainer implements DateHolder {
|
|||
|
||||
double quotient = longest * 1.0 / total;
|
||||
|
||||
return theWorld + " (" + Formatters.percentage().apply(quotient) + ")";
|
||||
return theWorld + " (" + Formatters.percentage_Old().apply(quotient) + ")";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*/
|
||||
package com.djrapitops.plan.data.element;
|
||||
|
||||
import com.djrapitops.plan.data.store.mutators.formatting.Formatter;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatter;
|
||||
import com.djrapitops.plan.utilities.html.Html;
|
||||
import com.djrapitops.plan.utilities.html.icon.Icon;
|
||||
import com.djrapitops.plugin.utilities.ArrayUtil;
|
||||
|
|
|
@ -7,7 +7,7 @@ import com.djrapitops.plan.data.store.keys.PlayerKeys;
|
|||
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.formatting.Formatters;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatters;
|
||||
import com.djrapitops.plan.data.store.mutators.health.HealthInformation;
|
||||
import com.djrapitops.plan.data.time.WorldTimes;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
|
@ -93,7 +93,7 @@ public class AnalysisContainer extends DataContainer {
|
|||
putRawData(AnalysisKeys.ANALYSIS_TIME_DAY_AGO, now - TimeAmount.DAY.ms());
|
||||
putRawData(AnalysisKeys.ANALYSIS_TIME_WEEK_AGO, now - TimeAmount.WEEK.ms());
|
||||
putRawData(AnalysisKeys.ANALYSIS_TIME_MONTH_AGO, now - TimeAmount.MONTH.ms());
|
||||
putSupplier(AnalysisKeys.REFRESH_TIME_F, () -> Formatters.second().apply(() -> getUnsafe(AnalysisKeys.ANALYSIS_TIME)));
|
||||
putSupplier(AnalysisKeys.REFRESH_TIME_F, () -> Formatters.second_Old().apply(() -> getUnsafe(AnalysisKeys.ANALYSIS_TIME)));
|
||||
|
||||
putRawData(AnalysisKeys.VERSION, version);
|
||||
putSupplier(AnalysisKeys.TIME_ZONE, MiscUtils::getTimeZoneOffsetHours);
|
||||
|
@ -146,11 +146,11 @@ public class AnalysisContainer extends DataContainer {
|
|||
);
|
||||
putSupplier(AnalysisKeys.LAST_PEAK_TIME_F, () ->
|
||||
serverContainer.getValue(ServerKeys.RECENT_PEAK_PLAYERS)
|
||||
.map(dateObj -> Formatters.year().apply(dateObj)).orElse("-")
|
||||
.map(dateObj -> Formatters.year_Old().apply(dateObj)).orElse("-")
|
||||
);
|
||||
putSupplier(AnalysisKeys.ALL_TIME_PEAK_TIME_F, () ->
|
||||
serverContainer.getValue(ServerKeys.ALL_TIME_PEAK_PLAYERS)
|
||||
.map(dateObj -> Formatters.year().apply(dateObj)).orElse("-")
|
||||
.map(dateObj -> Formatters.year_Old().apply(dateObj)).orElse("-")
|
||||
);
|
||||
putSupplier(AnalysisKeys.OPERATORS, () -> serverContainer.getValue(ServerKeys.OPERATORS).map(List::size).orElse(0));
|
||||
putSupplier(AnalysisKeys.PLAYERS_TABLE, () ->
|
||||
|
@ -243,20 +243,20 @@ public class AnalysisContainer extends DataContainer {
|
|||
putSupplier(AnalysisKeys.PLAYERS_RETAINED_DAY_PERC, () -> {
|
||||
try {
|
||||
Integer playersNewDay = getUnsafe(AnalysisKeys.PLAYERS_NEW_DAY);
|
||||
return playersNewDay != 0 ? Formatters.percentage().apply(1.0 * getUnsafe(retentionDay) / playersNewDay) : "-";
|
||||
return playersNewDay != 0 ? Formatters.percentage_Old().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().apply(
|
||||
return playersNewWeek != 0 ? Formatters.percentage_Old().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().apply(
|
||||
return playersNewMonth != 0 ? Formatters.percentage_Old().apply(
|
||||
1.0 * getUnsafe(AnalysisKeys.PLAYERS_RETAINED_MONTH) / playersNewMonth) : "-";
|
||||
}
|
||||
);
|
||||
|
@ -281,7 +281,7 @@ public class AnalysisContainer extends DataContainer {
|
|||
getUnsafe(AnalysisKeys.PLAYER_NAMES), getUnsafe(AnalysisKeys.SESSIONS_MUTATOR).all()).parseHtml()
|
||||
);
|
||||
|
||||
putSupplier(AnalysisKeys.AVERAGE_SESSION_LENGTH_F, () -> Formatters.timeAmount()
|
||||
putSupplier(AnalysisKeys.AVERAGE_SESSION_LENGTH_F, () -> Formatters.timeAmount_Old()
|
||||
.apply(getUnsafe(AnalysisKeys.SESSIONS_MUTATOR).toAverageSessionLength())
|
||||
);
|
||||
putSupplier(AnalysisKeys.SESSION_COUNT, () -> getUnsafe(AnalysisKeys.SESSIONS_MUTATOR).count());
|
||||
|
@ -289,16 +289,16 @@ public class AnalysisContainer extends DataContainer {
|
|||
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()
|
||||
putSupplier(AnalysisKeys.PLAYTIME_F, () -> Formatters.timeAmount_Old()
|
||||
.apply(getUnsafe(AnalysisKeys.PLAYTIME_TOTAL))
|
||||
);
|
||||
putSupplier(AnalysisKeys.AVERAGE_PLAYTIME_F, () -> {
|
||||
long players = getUnsafe(AnalysisKeys.PLAYERS_TOTAL);
|
||||
return players != 0 ? Formatters.timeAmount()
|
||||
return players != 0 ? Formatters.timeAmount_Old()
|
||||
.apply(getUnsafe(AnalysisKeys.PLAYTIME_TOTAL) / players) : "-";
|
||||
}
|
||||
);
|
||||
putSupplier(AnalysisKeys.AVERAGE_SESSION_LENGTH_F, () -> Formatters.timeAmount()
|
||||
putSupplier(AnalysisKeys.AVERAGE_SESSION_LENGTH_F, () -> Formatters.timeAmount_Old()
|
||||
.apply(getUnsafe(AnalysisKeys.SESSIONS_MUTATOR).toAverageSessionLength())
|
||||
);
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ package com.djrapitops.plan.data.store.containers;
|
|||
|
||||
import com.djrapitops.plan.data.store.CachingSupplier;
|
||||
import com.djrapitops.plan.data.store.Key;
|
||||
import com.djrapitops.plan.data.store.mutators.formatting.Formatter;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatter;
|
||||
import com.djrapitops.plugin.api.TimeAmount;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
|
|
@ -6,7 +6,7 @@ import com.djrapitops.plan.data.store.keys.NetworkKeys;
|
|||
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.formatting.Formatters;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatters;
|
||||
import com.djrapitops.plan.data.store.mutators.health.NetworkHealthInformation;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
|
@ -80,7 +80,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().apply(() -> getUnsafe(NetworkKeys.REFRESH_TIME)));
|
||||
putSupplier(NetworkKeys.REFRESH_TIME_F, () -> Formatters.second_Old().apply(() -> getUnsafe(NetworkKeys.REFRESH_TIME)));
|
||||
|
||||
putRawData(NetworkKeys.VERSION, PlanPlugin.getInstance().getVersion());
|
||||
putSupplier(NetworkKeys.TIME_ZONE, MiscUtils::getTimeZoneOffsetHours);
|
||||
|
@ -119,10 +119,10 @@ public class NetworkContainer extends DataContainer {
|
|||
);
|
||||
|
||||
putSupplier(NetworkKeys.ALL_TIME_PEAK_TIME_F, () ->
|
||||
bungeeContainer.getValue(ServerKeys.ALL_TIME_PEAK_PLAYERS).map(Formatters.year()::apply).orElse("No data")
|
||||
bungeeContainer.getValue(ServerKeys.ALL_TIME_PEAK_PLAYERS).map(Formatters.year_Old()::apply).orElse("No data")
|
||||
);
|
||||
putSupplier(NetworkKeys.RECENT_PEAK_TIME_F, () ->
|
||||
bungeeContainer.getValue(ServerKeys.RECENT_PEAK_PLAYERS).map(Formatters.year()::apply).orElse("No data")
|
||||
bungeeContainer.getValue(ServerKeys.RECENT_PEAK_PLAYERS).map(Formatters.year_Old()::apply).orElse("No data")
|
||||
);
|
||||
putSupplier(NetworkKeys.PLAYERS_ALL_TIME_PEAK, () ->
|
||||
bungeeContainer.getValue(ServerKeys.ALL_TIME_PEAK_PLAYERS).map(dateObj -> "" + dateObj.getValue()).orElse("-")
|
||||
|
|
|
@ -1,98 +0,0 @@
|
|||
package com.djrapitops.plan.data.store.mutators.formatting;
|
||||
|
||||
import com.djrapitops.plan.data.store.objects.DateHolder;
|
||||
import com.djrapitops.plan.utilities.FormatUtils;
|
||||
import com.djrapitops.plugin.api.TimeAmount;
|
||||
import com.djrapitops.plugin.utilities.Format;
|
||||
import org.apache.commons.text.TextStringBuilder;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* Class that holds static methods for getting new instances of different {@link Formatter}s.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class Formatters {
|
||||
|
||||
private Formatters() {
|
||||
/* Static method class */
|
||||
}
|
||||
|
||||
public static Formatter<DateHolder> year() {
|
||||
return dateHolder -> {
|
||||
long date = dateHolder.getDate();
|
||||
return date > 0 ? FormatUtils.formatTimeStampYear(date) : "-";
|
||||
};
|
||||
}
|
||||
|
||||
public static Formatter<Long> yearLongValue() {
|
||||
return date -> date > 0 ? FormatUtils.formatTimeStampYear(date) : "-";
|
||||
}
|
||||
|
||||
public static Formatter<DateHolder> day() {
|
||||
return dateHolder -> {
|
||||
long date = dateHolder.getDate();
|
||||
return date > 0 ? FormatUtils.formatTimeStampDay(date) : "-";
|
||||
};
|
||||
}
|
||||
|
||||
public static Formatter<DateHolder> second() {
|
||||
return dateHolder -> {
|
||||
long date = dateHolder.getDate();
|
||||
return date > 0 ? FormatUtils.formatTimeStampSecond(date) : "-";
|
||||
};
|
||||
}
|
||||
|
||||
public static Formatter<DateHolder> clock() {
|
||||
return dateHolder -> {
|
||||
long date = dateHolder.getDate();
|
||||
return date > 0 ? FormatUtils.formatTimeStampClock(date) : "-";
|
||||
};
|
||||
}
|
||||
|
||||
public static Formatter<DateHolder> iso8601NoClock() {
|
||||
return dateHolder -> FormatUtils.formatTimeStampISO8601NoClock(dateHolder.getDate());
|
||||
}
|
||||
|
||||
public static Formatter<Long> timeAmount() {
|
||||
return new TimeAmountFormatter();
|
||||
}
|
||||
|
||||
public static Function<Long, Integer> dayOfYear() {
|
||||
return date -> {
|
||||
Calendar day = Calendar.getInstance();
|
||||
day.setTimeInMillis(date);
|
||||
return day.get(Calendar.DAY_OF_YEAR);
|
||||
};
|
||||
}
|
||||
|
||||
public static Formatter<Double> percentage() {
|
||||
return value -> value >= 0 ? FormatUtils.cutDecimals(value * 100.0) + "%" : "-";
|
||||
}
|
||||
|
||||
public static Formatter<Long> benchmark() {
|
||||
return ns -> {
|
||||
if (ns > TimeAmount.MILLISECOND.ns() * 5L) {
|
||||
return (ns / TimeAmount.MILLISECOND.ns()) + "ms";
|
||||
} else {
|
||||
return 1.0 * ns / TimeAmount.MILLISECOND.ns() + "ms";
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static Formatter<String> itemName() {
|
||||
return name -> {
|
||||
String[] parts = name.split("_");
|
||||
TextStringBuilder builder = new TextStringBuilder();
|
||||
builder.appendWithSeparators(Arrays.stream(parts).map(part -> new Format(part).capitalize()).iterator(), " ");
|
||||
return builder.toString();
|
||||
};
|
||||
}
|
||||
|
||||
public static Formatter<String> entityName() {
|
||||
return name -> new Format(name).removeNumbers().removeSymbols().capitalize().toString();
|
||||
}
|
||||
}
|
|
@ -3,7 +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.data.store.mutators.formatting.Formatters;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatters;
|
||||
import com.djrapitops.plan.utilities.FormatUtils;
|
||||
import com.djrapitops.plan.utilities.html.icon.Icons;
|
||||
import com.djrapitops.plugin.api.TimeAmount;
|
||||
|
@ -113,8 +113,8 @@ public abstract class AbstractHealthInfo {
|
|||
if (activeCount != 0) {
|
||||
long avgFourToTwoWeeks = totalFourToTwoWeeks / (long) activeCount;
|
||||
long avgLastTwoWeeks = totalLastTwoWeeks / (long) activeCount;
|
||||
String avgLastTwoWeeksString = Formatters.timeAmount().apply(avgLastTwoWeeks);
|
||||
String avgFourToTwoWeeksString = Formatters.timeAmount().apply(avgFourToTwoWeeks);
|
||||
String avgLastTwoWeeksString = Formatters.timeAmount_Old().apply(avgLastTwoWeeks);
|
||||
String avgFourToTwoWeeksString = Formatters.timeAmount_Old().apply(avgFourToTwoWeeks);
|
||||
if (avgFourToTwoWeeks >= avgLastTwoWeeks) {
|
||||
addNote(Icons.GREEN_THUMB + " Active players seem to have things to do (Played "
|
||||
+ avgLastTwoWeeksString + " vs " + avgFourToTwoWeeksString
|
||||
|
|
|
@ -10,8 +10,8 @@ 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.data.store.mutators.formatting.Formatter;
|
||||
import com.djrapitops.plan.data.store.mutators.formatting.Formatters;
|
||||
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;
|
||||
|
@ -80,10 +80,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().apply(retainPercentage)
|
||||
addNote(Icons.GREEN_THUMB + " " + Formatters.percentage_Old().apply(retainPercentage)
|
||||
+ " of new players have stuck around (" + playersRetainedMonth + "/" + playersNewMonth + ")");
|
||||
} else {
|
||||
addNote(Icons.YELLOW_FLAG + " " + Formatters.percentage().apply(retainPercentage)
|
||||
addNote(Icons.YELLOW_FLAG + " " + Formatters.percentage_Old().apply(retainPercentage)
|
||||
+ " of new players have stuck around (" + playersRetainedMonth + "/" + playersNewMonth + ")");
|
||||
}
|
||||
}
|
||||
|
@ -126,7 +126,7 @@ public class HealthInformation extends AbstractHealthInfo {
|
|||
serverHealth *= 0.8;
|
||||
}
|
||||
|
||||
Formatter<Long> formatter = Formatters.timeAmount();
|
||||
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()) {
|
||||
|
|
|
@ -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/server on average.";
|
||||
String uniquePlayersNote = " players visit on servers per day_Old/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/server on average.";
|
||||
String newPlayersNote = " players register on servers per day_Old/server on average.";
|
||||
double average = perServerContainers.stream()
|
||||
.mapToInt(c -> c.getUnsafe(AnalysisKeys.AVG_PLAYERS_NEW_MONTH))
|
||||
.average().orElse(0.0);
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
package com.djrapitops.plan.system.listeners.bukkit;
|
||||
|
||||
import com.djrapitops.plan.data.container.Session;
|
||||
import com.djrapitops.plan.data.store.mutators.formatting.Formatters;
|
||||
import com.djrapitops.plan.system.cache.SessionCache;
|
||||
import com.djrapitops.plan.system.processing.Processing;
|
||||
import com.djrapitops.plan.system.processing.processors.player.MobKillProcessor;
|
||||
import com.djrapitops.plan.system.processing.processors.player.PlayerKillProcessor;
|
||||
import com.djrapitops.plan.utilities.formatting.EntityNameFormatter;
|
||||
import com.djrapitops.plan.utilities.formatting.ItemNameFormatter;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
import org.bukkit.Material;
|
||||
|
@ -93,7 +94,7 @@ public class DeathEventListener implements Listener {
|
|||
}
|
||||
}
|
||||
|
||||
String weaponName = Formatters.itemName().apply(itemInHand.name());
|
||||
String weaponName = new ItemNameFormatter().apply(itemInHand.name());
|
||||
|
||||
return victimUUID != null
|
||||
? new PlayerKillProcessor(killer.getUniqueId(), time, victimUUID, weaponName)
|
||||
|
@ -119,7 +120,7 @@ public class DeathEventListener implements Listener {
|
|||
}
|
||||
|
||||
return victimUUID != null
|
||||
? new PlayerKillProcessor(owner.getUniqueId(), time, victimUUID, Formatters.entityName().apply(name))
|
||||
? new PlayerKillProcessor(owner.getUniqueId(), time, victimUUID, new EntityNameFormatter().apply(name))
|
||||
: new MobKillProcessor(owner.getUniqueId());
|
||||
}
|
||||
|
||||
|
@ -130,7 +131,7 @@ public class DeathEventListener implements Listener {
|
|||
}
|
||||
|
||||
Player player = (Player) source;
|
||||
String projectileName = Formatters.entityName().apply(projectile.getType().name());
|
||||
String projectileName = new EntityNameFormatter().apply(projectile.getType().name());
|
||||
|
||||
return victimUUID != null
|
||||
? new PlayerKillProcessor(player.getUniqueId(), time, victimUUID, projectileName)
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
package com.djrapitops.plan.system.listeners.sponge;
|
||||
|
||||
import com.djrapitops.plan.data.container.Session;
|
||||
import com.djrapitops.plan.data.store.mutators.formatting.Formatters;
|
||||
import com.djrapitops.plan.system.cache.SessionCache;
|
||||
import com.djrapitops.plan.system.processing.Processing;
|
||||
import com.djrapitops.plan.system.processing.processors.player.MobKillProcessor;
|
||||
import com.djrapitops.plan.system.processing.processors.player.PlayerKillProcessor;
|
||||
import com.djrapitops.plan.utilities.formatting.EntityNameFormatter;
|
||||
import com.djrapitops.plan.utilities.formatting.ItemNameFormatter;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
import org.spongepowered.api.data.key.Keys;
|
||||
|
@ -90,7 +91,7 @@ public class SpongeDeathListener {
|
|||
ItemType type = inHand.isEmpty() ? ItemTypes.AIR : inHand.getType();
|
||||
|
||||
return victimUUID != null
|
||||
? new PlayerKillProcessor(killer.getUniqueId(), time, victimUUID, Formatters.itemName().apply(type.getName()))
|
||||
? new PlayerKillProcessor(killer.getUniqueId(), time, victimUUID, new ItemNameFormatter().apply(type.getName()))
|
||||
: new MobKillProcessor(killer.getUniqueId());
|
||||
}
|
||||
|
||||
|
@ -123,7 +124,7 @@ public class SpongeDeathListener {
|
|||
}
|
||||
|
||||
Player player = (Player) source;
|
||||
String projectileName = Formatters.entityName().apply(projectile.getType().getName());
|
||||
String projectileName = new EntityNameFormatter().apply(projectile.getType().getName());
|
||||
|
||||
return victimUUID != null
|
||||
? new PlayerKillProcessor(player.getUniqueId(), time, victimUUID, projectileName)
|
||||
|
|
|
@ -24,12 +24,14 @@ public class FormatUtils {
|
|||
throw new IllegalStateException("Utility class");
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static String formatTimeStampISO8601NoClock(long epochMs) {
|
||||
String format = "yyyy-MM-dd";
|
||||
|
||||
return format(epochMs, format);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static String formatTimeStampDay(long epochMs) {
|
||||
String format = "MMMMM d";
|
||||
|
||||
|
@ -40,6 +42,7 @@ public class FormatUtils {
|
|||
return format(epochMs, format);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static String formatTimeStampClock(long epochMs) {
|
||||
String format = Settings.FORMAT_DATE_CLOCK.toString();
|
||||
|
||||
|
@ -56,6 +59,7 @@ public class FormatUtils {
|
|||
return dateFormat.format(epochMs);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static String formatTimeStampSecond(long epochMs) {
|
||||
String format = Settings.FORMAT_DATE_FULL.toString();
|
||||
|
||||
|
@ -84,6 +88,7 @@ public class FormatUtils {
|
|||
return format;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static String formatTimeStampYear(long epochMs) {
|
||||
String format = Settings.FORMAT_DATE_NO_SECONDS.toString();
|
||||
|
||||
|
@ -99,6 +104,7 @@ public class FormatUtils {
|
|||
* @param d Double.
|
||||
* @return String format of the double.
|
||||
*/
|
||||
@Deprecated
|
||||
public static String cutDecimals(double d) {
|
||||
return new DecimalFormat(Settings.FORMAT_DECIMALS.toString()).format(d);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
package com.djrapitops.plan.utilities.formatting;
|
||||
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
/**
|
||||
* //TODO Class Javadoc Comment
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class DecimalFormatter implements Formatter<Double> {
|
||||
|
||||
private final PlanConfig config;
|
||||
|
||||
public DecimalFormatter(PlanConfig config) {
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String apply(Double value) {
|
||||
return new DecimalFormat(config.getString(Settings.FORMAT_DECIMALS)).format(value);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package com.djrapitops.plan.utilities.formatting;
|
||||
|
||||
import com.djrapitops.plugin.utilities.Format;
|
||||
|
||||
/**
|
||||
* //TODO Class Javadoc Comment
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class EntityNameFormatter implements Formatter<String> {
|
||||
|
||||
@Override
|
||||
public String apply(String name) {
|
||||
return new Format(name).removeNumbers().removeSymbols().capitalize().toString();
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package com.djrapitops.plan.data.store.mutators.formatting;
|
||||
package com.djrapitops.plan.utilities.formatting;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
|
@ -0,0 +1,125 @@
|
|||
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;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
/**
|
||||
* Factory for new instances of different {@link Formatter}s.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
@Singleton
|
||||
public class Formatters {
|
||||
|
||||
private PlanConfig config;
|
||||
|
||||
@Inject
|
||||
public Formatters(PlanConfig config) {
|
||||
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());
|
||||
}
|
||||
|
||||
public Formatter<Long> dayLong() {
|
||||
return new DayFormatter(config);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static Formatter<DateHolder> second_Old() {
|
||||
return nop();
|
||||
}
|
||||
|
||||
public Formatter<DateHolder> second() {
|
||||
return new DateHolderFormatter(secondLong());
|
||||
}
|
||||
|
||||
public Formatter<Long> secondLong() {
|
||||
return new SecondFormatter(config);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static Formatter<DateHolder> clock_Old() {
|
||||
return nop();
|
||||
}
|
||||
|
||||
public Formatter<DateHolder> clock() {
|
||||
return new DateHolderFormatter(clockLong());
|
||||
}
|
||||
|
||||
public Formatter<Long> clockLong() {
|
||||
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());
|
||||
}
|
||||
|
||||
public Formatter<Long> iso8601NoClockLong() {
|
||||
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() {
|
||||
return new DecimalFormatter(config);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package com.djrapitops.plan.utilities.formatting;
|
||||
|
||||
import com.djrapitops.plugin.utilities.Format;
|
||||
import org.apache.commons.text.TextStringBuilder;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* //TODO Class Javadoc Comment
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class ItemNameFormatter implements Formatter<String> {
|
||||
|
||||
@Override
|
||||
public String apply(String name) {
|
||||
String[] parts = name.split("_");
|
||||
TextStringBuilder builder = new TextStringBuilder();
|
||||
builder.appendWithSeparators(Arrays.stream(parts).map(part -> new Format(part).capitalize()).iterator(), " ");
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package com.djrapitops.plan.utilities.formatting;
|
||||
|
||||
/**
|
||||
* //TODO Class Javadoc Comment
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class PercentageFormatter implements Formatter<Double> {
|
||||
|
||||
private final Formatter<Double> formatter;
|
||||
|
||||
public PercentageFormatter(Formatter<Double> formatter) {
|
||||
this.formatter = formatter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String apply(Double value) {
|
||||
return value >= 0 ? formatter.apply(value * 100.0) + "%" : "-";
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package com.djrapitops.plan.data.store.mutators.formatting;
|
||||
package com.djrapitops.plan.utilities.formatting;
|
||||
|
||||
import com.djrapitops.plan.data.store.PlaceholderKey;
|
||||
import com.djrapitops.plan.data.store.containers.DataContainer;
|
|
@ -0,0 +1,27 @@
|
|||
package com.djrapitops.plan.utilities.formatting.time;
|
||||
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
|
||||
/**
|
||||
* //TODO Class Javadoc Comment
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class ClockFormatter extends DateFormatter {
|
||||
|
||||
public ClockFormatter(PlanConfig config) {
|
||||
super(config);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String apply(Long date) {
|
||||
return date > 0 ? format(date) : "-";
|
||||
}
|
||||
|
||||
private String format(Long date) {
|
||||
String format = config.getString(Settings.FORMAT_DATE_CLOCK);
|
||||
|
||||
return format(date, format);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
package com.djrapitops.plan.utilities.formatting.time;
|
||||
|
||||
import com.djrapitops.plan.utilities.formatting.Formatter;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plugin.api.TimeAmount;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Locale;
|
||||
import java.util.TimeZone;
|
||||
|
||||
/**
|
||||
* //TODO Class Javadoc Comment
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public abstract class DateFormatter implements Formatter<Long> {
|
||||
|
||||
protected final PlanConfig config;
|
||||
|
||||
public DateFormatter(PlanConfig config) {
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract String apply(Long value);
|
||||
|
||||
protected String format(long epochMs, String format) {
|
||||
boolean useServerTime = config.isTrue(Settings.USE_SERVER_TIME);
|
||||
String locale = config.getString(Settings.LOCALE);
|
||||
Locale usedLocale = locale.equalsIgnoreCase("default") ? Locale.ENGLISH : Locale.forLanguageTag(locale);
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat(format, usedLocale);
|
||||
TimeZone timeZone = useServerTime ? TimeZone.getDefault() : TimeZone.getTimeZone("GMT");
|
||||
dateFormat.setTimeZone(timeZone);
|
||||
return dateFormat.format(epochMs);
|
||||
}
|
||||
|
||||
protected String replaceRecentDays(long epochMs, String format) {
|
||||
return replaceRecentDays(epochMs, format, config.getString(Settings.FORMAT_DATE_RECENT_DAYS_PATTERN));
|
||||
}
|
||||
|
||||
protected String replaceRecentDays(long epochMs, String format, String pattern) {
|
||||
long now = System.currentTimeMillis();
|
||||
|
||||
long fromStartOfDay = now % TimeAmount.DAY.ms();
|
||||
if (epochMs > now - fromStartOfDay) {
|
||||
format = format.replace(pattern, "'Today'");
|
||||
} else if (epochMs > now - TimeAmount.DAY.ms() - fromStartOfDay) {
|
||||
format = format.replace(pattern, "'Yesterday'");
|
||||
} else if (epochMs > now - TimeAmount.DAY.ms() * 5L) {
|
||||
format = format.replace(pattern, "EEEE");
|
||||
}
|
||||
return format;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package com.djrapitops.plan.utilities.formatting.time;
|
||||
|
||||
import com.djrapitops.plan.utilities.formatting.Formatter;
|
||||
import com.djrapitops.plan.data.store.objects.DateHolder;
|
||||
|
||||
/**
|
||||
* //TODO Class Javadoc Comment
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class DateHolderFormatter implements Formatter<DateHolder> {
|
||||
|
||||
private final Formatter<Long> formatter;
|
||||
|
||||
public DateHolderFormatter(Formatter<Long> formatter) {
|
||||
this.formatter = formatter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String apply(DateHolder dateHolder) {
|
||||
return formatter.apply(dateHolder.getDate());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package com.djrapitops.plan.utilities.formatting.time;
|
||||
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
|
||||
/**
|
||||
* //TODO Class Javadoc Comment
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class DayFormatter extends DateFormatter {
|
||||
|
||||
public DayFormatter(PlanConfig config) {
|
||||
super(config);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String apply(Long date) {
|
||||
return date > 0 ? format(date) : "-";
|
||||
}
|
||||
|
||||
private String format(Long date) {
|
||||
String format = "MMMMM d";
|
||||
|
||||
if (config.isTrue(Settings.FORMAT_DATE_RECENT_DAYS)) {
|
||||
format = replaceRecentDays(date, format, "MMMMM");
|
||||
}
|
||||
|
||||
return format(date, format);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package com.djrapitops.plan.utilities.formatting.time;
|
||||
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
|
||||
/**
|
||||
* //TODO Class Javadoc Comment
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class ISO8601NoClockFormatter extends DateFormatter {
|
||||
|
||||
public ISO8601NoClockFormatter(PlanConfig config) {
|
||||
super(config);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String apply(Long date) {
|
||||
return date > 0 ? format(date) : "-";
|
||||
}
|
||||
|
||||
private String format(Long date) {
|
||||
String format = "yyyy-MM-dd";
|
||||
|
||||
return format(date, format);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package com.djrapitops.plan.utilities.formatting.time;
|
||||
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
|
||||
/**
|
||||
* //TODO Class Javadoc Comment
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class SecondFormatter extends DateFormatter {
|
||||
|
||||
public SecondFormatter(PlanConfig config) {
|
||||
super(config);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String apply(Long date) {
|
||||
return date > 0 ? format(date) : "-";
|
||||
}
|
||||
|
||||
private String format(Long date) {
|
||||
String format = config.getString(Settings.FORMAT_DATE_FULL);
|
||||
|
||||
if (config.isTrue(Settings.FORMAT_DATE_RECENT_DAYS)) {
|
||||
format = replaceRecentDays(date, format);
|
||||
}
|
||||
|
||||
return format(date, format);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,139 @@
|
|||
package com.djrapitops.plan.utilities.formatting.time;
|
||||
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatter;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
/**
|
||||
* Formatter for time amount in milliseconds.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class TimeAmountFormatter implements Formatter<Long> {
|
||||
|
||||
// Placeholders for the config settings
|
||||
private static final String ZERO_PH = "%zero%";
|
||||
private static final String SECONDS_PH = "%seconds%";
|
||||
private static final String MINUTES_PH = "%minutes%";
|
||||
private static final String HOURS_PH = "%hours%";
|
||||
private static final String DAYS_PH = "%days%";
|
||||
private static final String MONTHS_PH = "%months%";
|
||||
private static final String YEARS_PH = "%years%";
|
||||
|
||||
private final PlanConfig config;
|
||||
|
||||
public TimeAmountFormatter(PlanConfig config) {
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String apply(Long ms) {
|
||||
if (ms <= 0) {
|
||||
return "-";
|
||||
}
|
||||
StringBuilder builder = new StringBuilder();
|
||||
long x = ms / 1000;
|
||||
long seconds = x % 60;
|
||||
x /= 60;
|
||||
long minutes = x % 60;
|
||||
x /= 60;
|
||||
long hours = x % 24;
|
||||
x /= 24;
|
||||
long days = x % 365;
|
||||
long months = (days - days % 30) / 30;
|
||||
days -= months * 30;
|
||||
x /= 365;
|
||||
long years = x;
|
||||
|
||||
appendYears(builder, years);
|
||||
appendMonths(builder, months);
|
||||
appendDays(builder, days);
|
||||
|
||||
String hourFormat = config.getString(Settings.FORMAT_HOURS);
|
||||
String minuteFormat = config.getString(Settings.FORMAT_MINUTES);
|
||||
String secondFormat = config.getString(Settings.FORMAT_SECONDS);
|
||||
|
||||
appendHours(builder, hours, hourFormat);
|
||||
appendMinutes(builder, minutes, hours, hourFormat, minuteFormat);
|
||||
appendSeconds(builder, seconds, minutes, hours, hourFormat, minuteFormat, secondFormat);
|
||||
|
||||
String formattedTime = StringUtils.remove(builder.toString(), ZERO_PH);
|
||||
if (formattedTime.isEmpty()) {
|
||||
return config.getString(Settings.FORMAT_ZERO_SECONDS);
|
||||
}
|
||||
return formattedTime;
|
||||
}
|
||||
|
||||
private void appendSeconds(StringBuilder builder, long seconds, long minutes, long hours, String fHours, String fMinutes, String fSeconds) {
|
||||
if (seconds != 0) {
|
||||
String s = fSeconds.replace(SECONDS_PH, String.valueOf(seconds));
|
||||
if (minutes == 0 && s.contains(MINUTES_PH)) {
|
||||
if (hours == 0 && fMinutes.contains(HOURS_PH)) {
|
||||
builder.append(fHours.replace(ZERO_PH, "0").replace(HOURS_PH, "0"));
|
||||
}
|
||||
builder.append(fMinutes.replace(HOURS_PH, "").replace(ZERO_PH, "0").replace(MINUTES_PH, "0"));
|
||||
}
|
||||
s = s.replace(MINUTES_PH, "");
|
||||
if (s.contains(ZERO_PH) && String.valueOf(seconds).length() == 1) {
|
||||
builder.append('0');
|
||||
}
|
||||
builder.append(s);
|
||||
}
|
||||
}
|
||||
|
||||
private void appendMinutes(StringBuilder builder, long minutes, long hours, String fHours, String fMinutes) {
|
||||
if (minutes != 0) {
|
||||
String m = fMinutes.replace(MINUTES_PH, String.valueOf(minutes));
|
||||
if (hours == 0 && m.contains(HOURS_PH)) {
|
||||
builder.append(fHours.replace(ZERO_PH, "0").replace(HOURS_PH, "0"));
|
||||
m = m.replace(HOURS_PH, "");
|
||||
}
|
||||
m = m.replace(HOURS_PH, "");
|
||||
if (m.contains(ZERO_PH) && String.valueOf(minutes).length() == 1) {
|
||||
builder.append('0');
|
||||
}
|
||||
builder.append(m);
|
||||
}
|
||||
}
|
||||
|
||||
private void appendHours(StringBuilder builder, long hours, String fHours) {
|
||||
if (hours != 0) {
|
||||
String h = fHours.replace(HOURS_PH, String.valueOf(hours));
|
||||
if (h.contains(ZERO_PH) && String.valueOf(hours).length() == 1) {
|
||||
builder.append('0');
|
||||
}
|
||||
builder.append(h);
|
||||
}
|
||||
}
|
||||
|
||||
private void appendDays(StringBuilder builder, long days) {
|
||||
String singular = config.getString(Settings.FORMAT_DAY);
|
||||
String plural = config.getString(Settings.FORMAT_DAYS);
|
||||
appendValue(builder, days, singular, plural, DAYS_PH);
|
||||
}
|
||||
|
||||
private void appendMonths(StringBuilder builder, long months) {
|
||||
String singular = config.getString(Settings.FORMAT_MONTH);
|
||||
String plural = config.getString(Settings.FORMAT_MONTHS);
|
||||
|
||||
appendValue(builder, months, singular, plural, MONTHS_PH);
|
||||
}
|
||||
|
||||
private void appendYears(StringBuilder builder, long years) {
|
||||
String singular = config.getString(Settings.FORMAT_YEAR);
|
||||
String plural = config.getString(Settings.FORMAT_YEARS);
|
||||
|
||||
appendValue(builder, years, singular, plural, YEARS_PH);
|
||||
}
|
||||
|
||||
private void appendValue(StringBuilder builder, long amount, String singular, String plural, String replace) {
|
||||
if (amount != 0) {
|
||||
if (amount == 1) {
|
||||
builder.append(singular);
|
||||
} else {
|
||||
builder.append(plural.replace(replace, String.valueOf(amount)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package com.djrapitops.plan.utilities.formatting.time;
|
||||
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
|
||||
/**
|
||||
* //TODO Class Javadoc Comment
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class YearFormatter extends DateFormatter {
|
||||
|
||||
public YearFormatter(PlanConfig config) {
|
||||
super(config);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String apply(Long date) {
|
||||
return date > 0 ? format(date) : "-";
|
||||
}
|
||||
|
||||
private String format(Long date) {
|
||||
String format = config.getString(Settings.FORMAT_DATE_NO_SECONDS);
|
||||
|
||||
if (config.isTrue(Settings.FORMAT_DATE_RECENT_DAYS)) {
|
||||
format = replaceRecentDays(date, format);
|
||||
}
|
||||
return format(date, format);
|
||||
}
|
||||
}
|
|
@ -111,7 +111,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\"></i> Last Updated" +
|
||||
"<p><i class=\"far fa-clock_Old\"></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\">" +
|
||||
|
|
|
@ -9,8 +9,8 @@ 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.mutators.formatting.Formatter;
|
||||
import com.djrapitops.plan.data.store.mutators.formatting.Formatters;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatter;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatters;
|
||||
import com.djrapitops.plan.system.settings.theme.Theme;
|
||||
import com.djrapitops.plan.system.settings.theme.ThemeVal;
|
||||
import com.djrapitops.plan.utilities.FormatUtils;
|
||||
|
@ -63,7 +63,7 @@ public class PlayerCalendar {
|
|||
int sessionCount = sessions.size();
|
||||
long playtime = sessions.stream().mapToLong(Session::getLength).sum();
|
||||
|
||||
series.append(",{title: 'Playtime: ").append(Formatters.timeAmount().apply(playtime))
|
||||
series.append(",{title: 'Playtime: ").append(Formatters.timeAmount_Old().apply(playtime))
|
||||
.append("',start:'").append(day)
|
||||
.append("',color: '").append(Theme.getValue_Old(ThemeVal.GREEN)).append("'")
|
||||
.append("}");
|
||||
|
@ -77,7 +77,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().apply(session);
|
||||
String day = Formatters.iso8601NoClock_Old().apply(session);
|
||||
|
||||
List<Session> sessionsOfDay = sessionsByDay.getOrDefault(day, new ArrayList<>());
|
||||
sessionsOfDay.add(session);
|
||||
|
@ -89,7 +89,7 @@ public class PlayerCalendar {
|
|||
private void appendSessionsAndKills(StringBuilder series) {
|
||||
long fiveMinutes = TimeAmount.MINUTE.ms() * 5L;
|
||||
|
||||
Formatter<Long> timeFormatter = Formatters.timeAmount();
|
||||
Formatter<Long> timeFormatter = Formatters.timeAmount_Old();
|
||||
for (Session session : allSessions) {
|
||||
String length = timeFormatter.apply(session.getLength());
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ package com.djrapitops.plan.utilities.html.graphs.calendar;
|
|||
import com.djrapitops.plan.data.container.Session;
|
||||
import com.djrapitops.plan.data.store.mutators.PlayersMutator;
|
||||
import com.djrapitops.plan.data.store.mutators.SessionsMutator;
|
||||
import com.djrapitops.plan.data.store.mutators.formatting.Formatters;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatters;
|
||||
import com.djrapitops.plan.system.settings.theme.Theme;
|
||||
import com.djrapitops.plan.system.settings.theme.ThemeVal;
|
||||
import com.djrapitops.plan.utilities.FormatUtils;
|
||||
|
@ -80,7 +80,7 @@ public class ServerCalendar {
|
|||
long playtime = dayMutator.toPlaytime();
|
||||
long uniquePlayers = entry.getValue();
|
||||
|
||||
series.append(",{title: 'Playtime: ").append(Formatters.timeAmount().apply(playtime))
|
||||
series.append(",{title: 'Playtime: ").append(Formatters.timeAmount_Old().apply(playtime))
|
||||
.append("',start:'").append(day)
|
||||
.append("',color: '").append(Theme.getValue_Old(ThemeVal.GREEN)).append("'")
|
||||
.append("}");
|
||||
|
|
|
@ -7,9 +7,9 @@ package com.djrapitops.plan.utilities.html.icon;
|
|||
*/
|
||||
public class Icons {
|
||||
|
||||
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 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 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();
|
||||
|
|
|
@ -6,7 +6,7 @@ package com.djrapitops.plan.utilities.html.pages;
|
|||
|
||||
import com.djrapitops.plan.api.exceptions.ParseException;
|
||||
import com.djrapitops.plan.data.store.containers.AnalysisContainer;
|
||||
import com.djrapitops.plan.data.store.mutators.formatting.PlaceholderReplacer;
|
||||
import com.djrapitops.plan.utilities.formatting.PlaceholderReplacer;
|
||||
import com.djrapitops.plan.system.webserver.response.errors.ErrorResponse;
|
||||
import com.djrapitops.plan.utilities.FormatUtils;
|
||||
import com.djrapitops.plan.utilities.file.FileUtil;
|
||||
|
|
|
@ -2,8 +2,8 @@ package com.djrapitops.plan.utilities.html.pages;
|
|||
|
||||
import com.djrapitops.plan.data.container.Session;
|
||||
import com.djrapitops.plan.data.store.keys.SessionKeys;
|
||||
import com.djrapitops.plan.data.store.mutators.formatting.Formatter;
|
||||
import com.djrapitops.plan.data.store.mutators.formatting.Formatters;
|
||||
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.cache.SessionCache;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
|
@ -116,7 +116,7 @@ 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();
|
||||
Formatter<Long> timeStamp = Formatters.yearLongValue_Old();
|
||||
Set<Map.Entry<UUID, Session>> sessions = SessionCache.getActiveSessions().entrySet();
|
||||
if (sessions.isEmpty()) {
|
||||
content.append("Empty");
|
||||
|
@ -162,7 +162,7 @@ public class DebugPage implements Page {
|
|||
content.append("Server Address | Request Type | Response | Sent<br>")
|
||||
.append("-- | -- | -- | --<br>");
|
||||
|
||||
Formatter<DateHolder> formatter = Formatters.second();
|
||||
Formatter<DateHolder> formatter = Formatters.second_Old();
|
||||
|
||||
if (logEntries.isEmpty()) {
|
||||
content.append("**No Connections Logged**<br>");
|
||||
|
|
|
@ -10,9 +10,9 @@ import com.djrapitops.plan.data.store.containers.PerServerContainer;
|
|||
import com.djrapitops.plan.data.store.containers.PlayerContainer;
|
||||
import com.djrapitops.plan.data.store.keys.PlayerKeys;
|
||||
import com.djrapitops.plan.data.store.mutators.*;
|
||||
import com.djrapitops.plan.data.store.mutators.formatting.Formatter;
|
||||
import com.djrapitops.plan.data.store.mutators.formatting.Formatters;
|
||||
import com.djrapitops.plan.data.store.mutators.formatting.PlaceholderReplacer;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatter;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatters;
|
||||
import com.djrapitops.plan.utilities.formatting.PlaceholderReplacer;
|
||||
import com.djrapitops.plan.data.time.WorldTimes;
|
||||
import com.djrapitops.plan.system.cache.SessionCache;
|
||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
|
@ -104,7 +104,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(),
|
||||
replacer.addAllPlaceholdersFrom(player, Formatters.yearLongValue_Old(),
|
||||
PlayerKeys.REGISTERED, PlayerKeys.LAST_SEEN
|
||||
);
|
||||
|
||||
|
@ -239,7 +239,7 @@ public class InspectPage implements Page {
|
|||
long sessionAverageWeek = weekSessionsMutator.toAverageSessionLength();
|
||||
long sessionAverageMonth = monthSessionsMutator.toAverageSessionLength();
|
||||
|
||||
Formatter<Long> formatter = Formatters.timeAmount();
|
||||
Formatter<Long> formatter = Formatters.timeAmount_Old();
|
||||
replacer.put("playtimeTotal", formatter.apply(playtime));
|
||||
replacer.put("playtimeDay", formatter.apply(playtimeDay));
|
||||
replacer.put("playtimeWeek", formatter.apply(playtimeWeek));
|
||||
|
|
|
@ -7,7 +7,7 @@ package com.djrapitops.plan.utilities.html.pages;
|
|||
import com.djrapitops.plan.api.exceptions.ParseException;
|
||||
import com.djrapitops.plan.data.store.containers.NetworkContainer;
|
||||
import com.djrapitops.plan.data.store.keys.NetworkKeys;
|
||||
import com.djrapitops.plan.data.store.mutators.formatting.PlaceholderReplacer;
|
||||
import com.djrapitops.plan.utilities.formatting.PlaceholderReplacer;
|
||||
import com.djrapitops.plan.system.info.server.properties.ServerProperties;
|
||||
import com.djrapitops.plan.system.webserver.cache.PageId;
|
||||
import com.djrapitops.plan.system.webserver.cache.ResponseCache;
|
||||
|
|
|
@ -2,7 +2,7 @@ package com.djrapitops.plan.utilities.html.pages;
|
|||
|
||||
import com.djrapitops.plan.api.exceptions.ParseException;
|
||||
import com.djrapitops.plan.data.store.containers.PlayerContainer;
|
||||
import com.djrapitops.plan.data.store.mutators.formatting.PlaceholderReplacer;
|
||||
import com.djrapitops.plan.utilities.formatting.PlaceholderReplacer;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
|
|
|
@ -5,8 +5,8 @@ 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.mutators.formatting.Formatter;
|
||||
import com.djrapitops.plan.data.store.mutators.formatting.Formatters;
|
||||
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.utilities.comparators.SessionStartComparator;
|
||||
import com.djrapitops.plugin.api.TimeAmount;
|
||||
|
@ -33,7 +33,7 @@ public class RecentLoginList {
|
|||
public String toHtml() {
|
||||
List<RecentLogin> recentLogins = getMostRecentLogins();
|
||||
|
||||
Formatter<DateHolder> formatter = Formatters.second();
|
||||
Formatter<DateHolder> formatter = Formatters.second_Old();
|
||||
|
||||
if (recentLogins.isEmpty()) {
|
||||
return "<li>No Recent Logins</li>";
|
||||
|
|
|
@ -10,8 +10,8 @@ import com.djrapitops.plan.data.store.containers.PlayerContainer;
|
|||
import com.djrapitops.plan.data.store.keys.PerServerKeys;
|
||||
import com.djrapitops.plan.data.store.keys.PlayerKeys;
|
||||
import com.djrapitops.plan.data.store.mutators.SessionsMutator;
|
||||
import com.djrapitops.plan.data.store.mutators.formatting.Formatter;
|
||||
import com.djrapitops.plan.data.store.mutators.formatting.Formatters;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatter;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatters;
|
||||
import com.djrapitops.plan.data.time.WorldTimes;
|
||||
import com.djrapitops.plan.system.settings.theme.Theme;
|
||||
import com.djrapitops.plan.system.settings.theme.ThemeVal;
|
||||
|
@ -61,7 +61,7 @@ public class ServerAccordion extends AbstractAccordion {
|
|||
private void addElements() {
|
||||
int i = 0;
|
||||
|
||||
Formatter<Long> timeFormatter = Formatters.timeAmount();
|
||||
Formatter<Long> timeFormatter = Formatters.timeAmount_Old();
|
||||
|
||||
for (Map.Entry<UUID, DataContainer> entry : perServer.entrySet()) {
|
||||
UUID serverUUID = entry.getKey();
|
||||
|
@ -103,7 +103,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().apply(() -> registered))
|
||||
.addRowBold(Icon.called("user-plus").of(Color.LIGHT_GREEN), "Registered", Formatters.year_Old().apply(() -> registered))
|
||||
.addBreak()
|
||||
.addRowBold(Icons.SESSION_COUNT, "Sessions", sessionCount)
|
||||
.addRowBold(Icons.PLAYTIME, "Server Playtime", play)
|
||||
|
|
|
@ -3,8 +3,8 @@ package com.djrapitops.plan.utilities.html.structure;
|
|||
import com.djrapitops.plan.api.PlanAPI;
|
||||
import com.djrapitops.plan.data.container.Session;
|
||||
import com.djrapitops.plan.data.store.keys.SessionKeys;
|
||||
import com.djrapitops.plan.data.store.mutators.formatting.Formatter;
|
||||
import com.djrapitops.plan.data.store.mutators.formatting.Formatters;
|
||||
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.time.WorldTimes;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
|
@ -81,8 +81,8 @@ 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();
|
||||
Formatter<DateHolder> timeStampFormatter = Formatters.year();
|
||||
Formatter<Long> timeFormatter = Formatters.timeAmount_Old();
|
||||
Formatter<DateHolder> timeStampFormatter = Formatters.year_Old();
|
||||
sessions.sort(new DateHolderRecentComparator());
|
||||
|
||||
int i = 0;
|
||||
|
@ -155,8 +155,8 @@ public class SessionAccordion extends AbstractAccordion {
|
|||
|
||||
private void addElementsForPlayer() {
|
||||
Map<UUID, String> serverNames = serverNamesSupplier.get();
|
||||
Formatter<Long> timeFormatter = Formatters.timeAmount();
|
||||
Formatter<DateHolder> timeStampFormatter = Formatters.year();
|
||||
Formatter<Long> timeFormatter = Formatters.timeAmount_Old();
|
||||
Formatter<DateHolder> timeStampFormatter = Formatters.year_Old();
|
||||
sessions.sort(new DateHolderRecentComparator());
|
||||
|
||||
int i = 0;
|
||||
|
|
|
@ -3,8 +3,8 @@ package com.djrapitops.plan.utilities.html.tables;
|
|||
import com.djrapitops.plan.api.PlanAPI;
|
||||
import com.djrapitops.plan.data.container.PlayerDeath;
|
||||
import com.djrapitops.plan.data.element.TableContainer;
|
||||
import com.djrapitops.plan.data.store.mutators.formatting.Formatter;
|
||||
import com.djrapitops.plan.data.store.mutators.formatting.Formatters;
|
||||
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.cache.DataCache;
|
||||
import com.djrapitops.plan.utilities.comparators.DateHolderRecentComparator;
|
||||
|
@ -20,7 +20,7 @@ import java.util.List;
|
|||
public class DeathsTable extends TableContainer {
|
||||
|
||||
public DeathsTable(List<PlayerDeath> playerPlayerDeaths) {
|
||||
super(Icon.called("clock").of(Family.REGULAR) + " Time", "Killed by", "With");
|
||||
super(Icon.called("clock_Old").of(Family.REGULAR) + " Time", "Killed by", "With");
|
||||
setColor("red");
|
||||
|
||||
if (playerPlayerDeaths.isEmpty()) {
|
||||
|
@ -32,7 +32,7 @@ public class DeathsTable extends TableContainer {
|
|||
|
||||
private void addValues(List<PlayerDeath> playerPlayerDeaths) {
|
||||
playerPlayerDeaths.sort(new DateHolderRecentComparator());
|
||||
Formatter<DateHolder> timestamp = Formatters.year();
|
||||
Formatter<DateHolder> timestamp = Formatters.year_Old();
|
||||
|
||||
int i = 0;
|
||||
DataCache dataCache = DataCache.getInstance();
|
||||
|
|
|
@ -6,8 +6,8 @@ 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.data.store.mutators.formatting.Formatter;
|
||||
import com.djrapitops.plan.data.store.mutators.formatting.Formatters;
|
||||
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;
|
||||
|
@ -35,7 +35,7 @@ public class GeoInfoTable extends TableContainer {
|
|||
geoInfo.sort(new DateHolderRecentComparator());
|
||||
|
||||
boolean displayIP = Settings.DISPLAY_PLAYER_IPS.isTrue();
|
||||
Formatter<DateHolder> formatter = Formatters.year();
|
||||
Formatter<DateHolder> formatter = Formatters.year_Old();
|
||||
|
||||
for (GeoInfo info : geoInfo) {
|
||||
addRow(
|
||||
|
|
|
@ -3,8 +3,8 @@ package com.djrapitops.plan.utilities.html.tables;
|
|||
import com.djrapitops.plan.api.PlanAPI;
|
||||
import com.djrapitops.plan.data.container.PlayerKill;
|
||||
import com.djrapitops.plan.data.element.TableContainer;
|
||||
import com.djrapitops.plan.data.store.mutators.formatting.Formatter;
|
||||
import com.djrapitops.plan.data.store.mutators.formatting.Formatters;
|
||||
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.cache.DataCache;
|
||||
import com.djrapitops.plan.utilities.comparators.DateHolderRecentComparator;
|
||||
|
@ -24,7 +24,7 @@ public class KillsTable extends TableContainer {
|
|||
}
|
||||
|
||||
public KillsTable(List<PlayerKill> playerKills, String color) {
|
||||
super(Icon.called("clock").of(Family.REGULAR) + " Time", "Killed", "With");
|
||||
super(Icon.called("clock_Old").of(Family.REGULAR) + " Time", "Killed", "With");
|
||||
setColor(color);
|
||||
|
||||
if (playerKills.isEmpty()) {
|
||||
|
@ -36,7 +36,7 @@ public class KillsTable extends TableContainer {
|
|||
|
||||
private void addValues(List<PlayerKill> playerKills) {
|
||||
playerKills.sort(new DateHolderRecentComparator());
|
||||
Formatter<DateHolder> timestamp = Formatters.year();
|
||||
Formatter<DateHolder> timestamp = Formatters.year_Old();
|
||||
|
||||
int i = 0;
|
||||
DataCache dataCache = DataCache.getInstance();
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
package com.djrapitops.plan.utilities.html.tables;
|
||||
|
||||
import com.djrapitops.plan.data.element.TableContainer;
|
||||
import com.djrapitops.plan.data.store.mutators.formatting.Formatter;
|
||||
import com.djrapitops.plan.data.store.mutators.formatting.Formatters;
|
||||
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;
|
||||
|
@ -36,7 +36,7 @@ public class NicknameTable extends TableContainer {
|
|||
private void addValues(List<Nickname> nicknames, Map<UUID, String> serverNames) {
|
||||
nicknames.sort(new DateHolderRecentComparator());
|
||||
|
||||
Formatter<DateHolder> formatter = Formatters.year();
|
||||
Formatter<DateHolder> formatter = Formatters.year_Old();
|
||||
for (Nickname nickname : nicknames) {
|
||||
UUID serverUUID = nickname.getServerUUID();
|
||||
String serverName = serverNames.getOrDefault(serverUUID, "Unknown");
|
||||
|
|
|
@ -6,7 +6,7 @@ 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.data.store.mutators.formatting.Formatters;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatters;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.utilities.html.Html;
|
||||
|
||||
|
@ -52,9 +52,9 @@ public class PlayerSessionTable extends TableContainer {
|
|||
break;
|
||||
}
|
||||
|
||||
String start = Formatters.year().apply(session);
|
||||
String start = Formatters.year_Old().apply(session);
|
||||
String length = session.supports(SessionKeys.END)
|
||||
? Formatters.timeAmount().apply(session.getValue(SessionKeys.LENGTH).orElse(0L))
|
||||
? Formatters.timeAmount_Old().apply(session.getValue(SessionKeys.LENGTH).orElse(0L))
|
||||
: "Online";
|
||||
String world = session.getValue(SessionKeys.LONGEST_WORLD_PLAYED).orElse("Unknown");
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ 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.data.store.mutators.formatting.Formatters;
|
||||
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.html.Html;
|
||||
|
@ -31,7 +31,7 @@ public class PlayersTable extends TableContainer {
|
|||
super(
|
||||
Icon.called("user") + " Name",
|
||||
Icon.called("check") + " Activity Index",
|
||||
Icon.called("clock").of(Family.REGULAR) + " Playtime",
|
||||
Icon.called("clock_Old").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,9 +41,9 @@ public class PlayersTable extends TableContainer {
|
|||
this.maxPlayers = maxPlayers;
|
||||
useJqueryDataTables("player-table");
|
||||
|
||||
setFormatter(2, Formatters.timeAmount());
|
||||
setFormatter(4, Formatters.yearLongValue());
|
||||
setFormatter(5, Formatters.yearLongValue());
|
||||
setFormatter(2, Formatters.timeAmount_Old());
|
||||
setFormatter(4, Formatters.yearLongValue_Old());
|
||||
setFormatter(5, Formatters.yearLongValue_Old());
|
||||
addRows();
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ 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.data.store.mutators.formatting.Formatters;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatters;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.utilities.html.Html;
|
||||
|
||||
|
@ -42,9 +42,9 @@ public class ServerSessionTable extends TableContainer {
|
|||
break;
|
||||
}
|
||||
|
||||
String start = Formatters.year().apply(session);
|
||||
String start = Formatters.year_Old().apply(session);
|
||||
String length = session.supports(SessionKeys.END)
|
||||
? Formatters.timeAmount().apply(session.getValue(SessionKeys.LENGTH).orElse(0L))
|
||||
? Formatters.timeAmount_Old().apply(session.getValue(SessionKeys.LENGTH).orElse(0L))
|
||||
: "Online";
|
||||
String world = session.getValue(SessionKeys.LONGEST_WORLD_PLAYED).orElse("Unknown");
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.djrapitops.plan.data.store.mutators;
|
||||
|
||||
import com.djrapitops.plan.data.store.mutators.formatting.Formatters;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatters;
|
||||
import com.djrapitops.plugin.api.TimeAmount;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.ClassRule;
|
||||
|
@ -30,7 +30,7 @@ public class FormattersTest {
|
|||
@Test
|
||||
public void formatTimeAmount() {
|
||||
String expResult = "1s";
|
||||
String result = Formatters.timeAmount().apply(TimeAmount.SECOND.ms());
|
||||
String result = Formatters.timeAmount_Old().apply(TimeAmount.SECOND.ms());
|
||||
|
||||
assertEquals(expResult, result);
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ public class FormattersTest {
|
|||
@Test
|
||||
public void formatTimeAmountMonths() {
|
||||
long time = TimeAmount.DAY.ms() * 40L;
|
||||
assertEquals("1 month, 10d ", Formatters.timeAmount().apply(time));
|
||||
assertEquals("1 month, 10d ", Formatters.timeAmount_Old().apply(time));
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user