Fixed some table sorting issues #624

This commit is contained in:
Rsl1122 2018-07-12 10:39:30 +03:00
parent b6fc279649
commit d29f6079bd
5 changed files with 20 additions and 10 deletions

View File

@ -12,7 +12,6 @@ import com.djrapitops.plan.utilities.html.Html;
import com.djrapitops.plan.utilities.html.icon.Family;
import com.djrapitops.plan.utilities.html.icon.Icon;
import java.util.Collections;
import java.util.List;
/**
@ -33,14 +32,12 @@ public class DeathsTable extends TableContainer {
private void addValues(List<PlayerDeath> playerPlayerDeaths) {
playerPlayerDeaths.sort(new DateHolderRecentComparator());
Collections.reverse(playerPlayerDeaths);
Formatter<DateHolder> timestamp = Formatters.year();
int i = 0;
DataCache dataCache = DataCache.getInstance();
for (PlayerDeath death : playerPlayerDeaths) {
if (i >= 20) {
if (i >= 40) {
break;
}

View File

@ -10,6 +10,7 @@ import com.djrapitops.plan.data.store.mutators.formatting.Formatter;
import com.djrapitops.plan.data.store.mutators.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 java.util.List;
@ -31,6 +32,8 @@ 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();

View File

@ -7,12 +7,11 @@ import com.djrapitops.plan.data.store.mutators.formatting.Formatter;
import com.djrapitops.plan.data.store.mutators.formatting.Formatters;
import com.djrapitops.plan.data.store.objects.DateHolder;
import com.djrapitops.plan.system.cache.DataCache;
import com.djrapitops.plan.utilities.comparators.PlayerKillComparator;
import com.djrapitops.plan.utilities.comparators.DateHolderRecentComparator;
import com.djrapitops.plan.utilities.html.Html;
import com.djrapitops.plan.utilities.html.icon.Family;
import com.djrapitops.plan.utilities.html.icon.Icon;
import java.util.Collections;
import java.util.List;
/**
@ -32,15 +31,13 @@ public class KillsTable extends TableContainer {
}
private void addValues(List<PlayerKill> playerKills) {
playerKills.sort(new PlayerKillComparator());
Collections.reverse(playerKills);
playerKills.sort(new DateHolderRecentComparator());
Formatter<DateHolder> timestamp = Formatters.year();
int i = 0;
DataCache dataCache = DataCache.getInstance();
for (PlayerKill kill : playerKills) {
if (i >= 20) {
if (i >= 40) {
break;
}

View File

@ -9,6 +9,7 @@ import com.djrapitops.plan.data.store.mutators.formatting.Formatter;
import com.djrapitops.plan.data.store.mutators.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.html.HtmlUtils;
import java.util.List;
@ -33,6 +34,8 @@ public class NicknameTable extends TableContainer {
}
private void addValues(List<Nickname> nicknames, Map<UUID, String> serverNames) {
nicknames.sort(new DateHolderRecentComparator());
Formatter<DateHolder> formatter = Formatters.year();
for (Nickname nickname : nicknames) {
UUID serverUUID = nickname.getServerUUID();

View File

@ -3,12 +3,15 @@ package com.djrapitops.plan.utilities.html.tables;
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.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.system.settings.Settings;
import com.djrapitops.plan.utilities.analysis.AnalysisUtils;
import com.djrapitops.plan.utilities.html.Html;
import java.util.ArrayList;
import java.util.List;
/**
@ -21,6 +24,13 @@ public class PlayerSessionTable extends TableContainer {
private final String playerName;
private final List<Session> sessions;
public static PlayerSessionTable forContainer(DataContainer container) {
return new PlayerSessionTable(
container.getValue(PlayerKeys.NAME).orElse("Unknown"),
container.getValue(PlayerKeys.SESSIONS).orElse(new ArrayList<>())
);
}
public PlayerSessionTable(String playerName, List<Session> sessions) {
super("Player", "Start", "Length", "World");
this.playerName = playerName;