mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-06 15:44:49 +08:00
[Debt] ActivityIndex#getFormattedValue(Formatter)
This commit is contained in:
parent
062ecc86a7
commit
eb91fbc990
@ -7,8 +7,6 @@ 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.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;
|
||||
@ -19,6 +17,8 @@ import com.djrapitops.plan.system.locale.lang.GenericLang;
|
||||
import com.djrapitops.plan.system.processing.Processing;
|
||||
import com.djrapitops.plan.system.settings.Permissions;
|
||||
import com.djrapitops.plan.utilities.MiscUtils;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatter;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatters;
|
||||
import com.djrapitops.plan.utilities.uuid.UUIDUtility;
|
||||
import com.djrapitops.plugin.command.CommandNode;
|
||||
import com.djrapitops.plugin.command.CommandType;
|
||||
@ -125,7 +125,7 @@ public class QInspectCommand extends CommandNode {
|
||||
|
||||
String[] messages = new String[]{
|
||||
locale.getString(CommandLang.HEADER_INSPECT, playerName),
|
||||
locale.getString(CommandLang.QINSPECT_ACTIVITY_INDEX, activityIndex.getFormattedValue(), activityIndex.getGroup()),
|
||||
locale.getString(CommandLang.QINSPECT_ACTIVITY_INDEX, activityIndex.getFormattedValue(formatters.decimals()), activityIndex.getGroup()),
|
||||
locale.getString(CommandLang.QINSPECT_REGISTERED, timestamp.apply(() -> registered)),
|
||||
locale.getString(CommandLang.QINSPECT_LAST_SEEN, timestamp.apply(() -> lastSeen)),
|
||||
locale.getString(CommandLang.QINSPECT_GEOLOCATION, geolocation),
|
||||
|
@ -110,9 +110,8 @@ public class ActivityIndex {
|
||||
return value;
|
||||
}
|
||||
|
||||
public String getFormattedValue() {
|
||||
Formatter<Double> decimalFormatter = null; // TODO Add as method parameter
|
||||
return decimalFormatter.apply(value);
|
||||
public String getFormattedValue(Formatter<Double> formatter) {
|
||||
return formatter.apply(value);
|
||||
}
|
||||
|
||||
public String getGroup() {
|
||||
|
@ -209,7 +209,7 @@ public class InspectPage implements Page {
|
||||
|
||||
ActivityIndex activityIndex = player.getActivityIndex(now);
|
||||
|
||||
replacer.put("activityIndexNumber", activityIndex.getFormattedValue());
|
||||
replacer.put("activityIndexNumber", activityIndex.getFormattedValue(decimalFormatter));
|
||||
replacer.put("activityIndexColor", activityIndex.getColor());
|
||||
replacer.put("activityIndex", activityIndex.getGroup());
|
||||
|
||||
|
@ -137,7 +137,7 @@ public class HtmlTables {
|
||||
public TableContainer playerTableForServerPage(List<PlayerContainer> players) {
|
||||
return new PlayersTable(
|
||||
players, config.getNumber(Settings.MAX_PLAYERS),
|
||||
formatters.timeAmount(), formatters.yearLong()
|
||||
formatters.timeAmount(), formatters.yearLong(), formatters.decimals()
|
||||
);
|
||||
}
|
||||
|
||||
@ -150,7 +150,7 @@ public class HtmlTables {
|
||||
public TableContainer playerTableForPlayersPage(List<PlayerContainer> players) {
|
||||
return new PlayersTable(
|
||||
players, config.getNumber(Settings.MAX_PLAYERS_PLAYERS_PAGE),
|
||||
formatters.timeAmount(), formatters.yearLong()
|
||||
formatters.timeAmount(), formatters.yearLong(), formatters.decimals()
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -25,11 +25,14 @@ class PlayersTable extends TableContainer {
|
||||
|
||||
private final List<PlayerContainer> players;
|
||||
private final int maxPlayers;
|
||||
private final Formatter<Double> decimalFormatter;
|
||||
|
||||
PlayersTable(List<PlayerContainer> players,
|
||||
PlayersTable(
|
||||
List<PlayerContainer> players,
|
||||
int maxPlayers,
|
||||
Formatter<Long> timeAmountFormatter,
|
||||
Formatter<Long> yearLongFormatter
|
||||
Formatter<Long> yearLongFormatter,
|
||||
Formatter<Double> decimalFormatter
|
||||
) {
|
||||
super(
|
||||
Icon.called("user") + " Name",
|
||||
@ -42,6 +45,7 @@ class PlayersTable extends TableContainer {
|
||||
);
|
||||
this.players = players;
|
||||
this.maxPlayers = maxPlayers;
|
||||
this.decimalFormatter = decimalFormatter;
|
||||
useJqueryDataTables("player-table");
|
||||
|
||||
setFormatter(2, timeAmountFormatter);
|
||||
@ -72,7 +76,7 @@ class PlayersTable extends TableContainer {
|
||||
|
||||
ActivityIndex activityIndex = player.getActivityIndex(now);
|
||||
boolean isBanned = player.getValue(PlayerKeys.BANNED).orElse(false);
|
||||
String activityString = activityIndex.getFormattedValue()
|
||||
String activityString = activityIndex.getFormattedValue(decimalFormatter)
|
||||
+ (isBanned ? " (<b>Banned</b>)" : " (" + activityIndex.getGroup() + ")");
|
||||
|
||||
String geolocation = GeoInfoMutator.forContainer(player).mostRecent().map(GeoInfo::getGeolocation).orElse("-");
|
||||
|
@ -36,7 +36,7 @@ public class PlayersTableTest {
|
||||
PlayerContainer container = new PlayerContainer();
|
||||
container.putRawData(PlayerKeys.SESSIONS, new ArrayList<>());
|
||||
List<PlayerContainer> players = Collections.singletonList(container);
|
||||
String html = new PlayersTable(players, 50, l -> "", l -> "").parseHtml();
|
||||
String html = new PlayersTable(players, 50, l -> "", l -> "", d -> "").parseHtml();
|
||||
|
||||
testHtmlValidity(html);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user