From 53cd34978b7b47a0db2e395a7ed8b68c767955da Mon Sep 17 00:00:00 2001 From: Fuzzlemann Date: Tue, 1 Aug 2017 22:28:58 +0200 Subject: [PATCH] Adds a KillDataComparator to list the KillData correctly and in the right order --- .../plan/ui/html/tables/KillsTableCreator.java | 6 ++++++ .../comparators/KillDataComparator.java | 17 +++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 Plan/src/main/java/com/djrapitops/plan/utilities/comparators/KillDataComparator.java diff --git a/Plan/src/main/java/com/djrapitops/plan/ui/html/tables/KillsTableCreator.java b/Plan/src/main/java/com/djrapitops/plan/ui/html/tables/KillsTableCreator.java index 8cc79dbeb..c3a7ca489 100644 --- a/Plan/src/main/java/com/djrapitops/plan/ui/html/tables/KillsTableCreator.java +++ b/Plan/src/main/java/com/djrapitops/plan/ui/html/tables/KillsTableCreator.java @@ -6,7 +6,9 @@ import main.java.com.djrapitops.plan.data.KillData; import main.java.com.djrapitops.plan.ui.html.Html; import main.java.com.djrapitops.plan.utilities.FormatUtils; import main.java.com.djrapitops.plan.utilities.HtmlUtils; +import main.java.com.djrapitops.plan.utilities.comparators.KillDataComparator; +import java.util.Collections; import java.util.List; /** @@ -32,6 +34,10 @@ public class KillsTableCreator { html.append(Html.TABLELINE_3.parse(Html.KILLDATA_NONE.parse(), "", "")); } else { int i = 0; + + killData.sort(new KillDataComparator()); + Collections.reverse(killData); + for (KillData kill : killData) { if (i >= 20) { break; diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/comparators/KillDataComparator.java b/Plan/src/main/java/com/djrapitops/plan/utilities/comparators/KillDataComparator.java new file mode 100644 index 000000000..42bb5c877 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/comparators/KillDataComparator.java @@ -0,0 +1,17 @@ +package main.java.com.djrapitops.plan.utilities.comparators; + +import main.java.com.djrapitops.plan.data.KillData; + +import java.util.Comparator; + +/** + * @author Fuzzlemann + */ +public class KillDataComparator implements Comparator { + + @Override + public int compare(KillData o1, KillData o2) { + return Long.compare(o1.getDate(), o2.getDate()); + } + +}