From 8867189b65e4bf38064d90ea8aa116424e0dbdbf Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Wed, 8 Aug 2018 11:28:13 +0300 Subject: [PATCH] Added "Given" row to Server page litebans table #643 --- .../plan/litebans/LiteBansDBObj.java | 8 ++++- .../plan/litebans/LiteBansData.java | 36 +++++++++---------- .../litebans/LiteBansDatabaseQueries.java | 7 ++-- 3 files changed, 27 insertions(+), 24 deletions(-) diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/litebans/LiteBansDBObj.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/litebans/LiteBansDBObj.java index 25a377ff9..2693c1ef1 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/litebans/LiteBansDBObj.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/litebans/LiteBansDBObj.java @@ -13,13 +13,15 @@ public class LiteBansDBObj { private final String bannedBy; private final long expiry; private final boolean active; + private final long time; - public LiteBansDBObj(UUID uuid, String reason, String bannedBy, long expiry, boolean active) { + public LiteBansDBObj(UUID uuid, String reason, String bannedBy, long expiry, boolean active, long time) { this.uuid = uuid; this.reason = reason; this.bannedBy = bannedBy; this.expiry = expiry; this.active = active; + this.time = time; } public UUID getUuid() { @@ -41,4 +43,8 @@ public class LiteBansDBObj { public boolean isActive() { return active; } + + public long getTime() { + return time; + } } diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/litebans/LiteBansData.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/litebans/LiteBansData.java index 213383f6a..48cde675c 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/litebans/LiteBansData.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/litebans/LiteBansData.java @@ -133,11 +133,7 @@ public class LiteBansData extends PluginData implements BanData { private TableContainer getBanTable() { String banned = getWithIcon("Banned", Icon.called("ban")); String by = getWithIcon("Banned By", Icon.called("gavel")); - String reason = getWithIcon("Reason", Icon.called("balance-scale")); - String date = getWithIcon("Expires", Icon.called("calendar-times").of(Family.REGULAR)); - String active = getWithIcon("Active", Icon.called("hourglass")); - - TableContainer banTable = new TableContainer(banned, by, reason, date, active); + TableContainer banTable = createTableContainer(banned, by); banTable.useJqueryDataTables(); addRows(banTable, db.getBans()); return banTable; @@ -146,11 +142,7 @@ public class LiteBansData extends PluginData implements BanData { private TableContainer getMuteTable() { String muted = getWithIcon("Muted", Icon.called("bell-slash").of(Family.REGULAR)); String by = getWithIcon("Muted By", Icon.called("gavel")); - String reason = getWithIcon("Reason", Icon.called("balance-scale")); - String date = getWithIcon("Expires", Icon.called("calendar-times").of(Family.REGULAR)); - String active = getWithIcon("Active", Icon.called("hourglass")); - - TableContainer muteTable = new TableContainer(muted, by, reason, date, active); + TableContainer muteTable = createTableContainer(muted, by); muteTable.useJqueryDataTables(); addRows(muteTable, db.getMutes()); return muteTable; @@ -159,11 +151,7 @@ public class LiteBansData extends PluginData implements BanData { private TableContainer getWarningTable() { String warned = getWithIcon("Warned", Icon.called("exclamation-triangle")); String by = getWithIcon("Warned By", Icon.called("gavel")); - String reason = getWithIcon("Reason", Icon.called("balance-scale")); - String date = getWithIcon("Expires", Icon.called("calendar-times").of(Family.REGULAR)); - String active = getWithIcon("Active", Icon.called("hourglass")); - - TableContainer warnTable = new TableContainer(warned, by, reason, date, active); + TableContainer warnTable = createTableContainer(warned, by); warnTable.useJqueryDataTables(); addRows(warnTable, db.getWarnings()); return warnTable; @@ -172,16 +160,21 @@ public class LiteBansData extends PluginData implements BanData { private TableContainer getKickTable() { String kicked = getWithIcon("Kicked", Icon.called("user-times")); String by = getWithIcon("Kicked By", Icon.called("gavel")); - String reason = getWithIcon("Reason", Icon.called("balance-scale")); - String date = getWithIcon("Expires", Icon.called("calendar-times").of(Family.REGULAR)); - String active = getWithIcon("Active", Icon.called("hourglass")); - - TableContainer kickTable = new TableContainer(kicked, by, reason, date, active); + TableContainer kickTable = createTableContainer(kicked, by); kickTable.useJqueryDataTables(); addRows(kickTable, db.getKicks()); return kickTable; } + private TableContainer createTableContainer(String who, String by) { + String reason = getWithIcon("Reason", Icon.called("balance-scale")); + String given = getWithIcon("Given", Icon.called("clock").of(Family.REGULAR)); + String expiry = getWithIcon("Expires", Icon.called("calendar-times").of(Family.REGULAR)); + String active = getWithIcon("Active", Icon.called("hourglass")); + + return new TableContainer(who, by, reason, given, expiry, active); + } + private void addRows(TableContainer table, List objects) { if (objects.isEmpty()) { table.addRow("No Data"); @@ -192,11 +185,14 @@ public class LiteBansData extends PluginData implements BanData { String name = playerNames.getOrDefault(uuid, uuid.toString()); long expiry = object.getExpiry(); String expires = expiry <= 0 ? "Never" : FormatUtils.formatTimeStampSecond(expiry); + long time = object.getTime(); + String given = time <= 0 ? "Unknown" : FormatUtils.formatTimeStampSecond(time); table.addRow( Html.LINK.parse(PlanAPI.getInstance().getPlayerInspectPageLink(name), name), Html.LINK.parse(PlanAPI.getInstance().getPlayerInspectPageLink(object.getBannedBy()), object.getBannedBy()), object.getReason(), + given, expires, object.isActive() ? "Yes" : "No" ); diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/litebans/LiteBansDatabaseQueries.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/litebans/LiteBansDatabaseQueries.java index dd791a8de..3c9f90332 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/litebans/LiteBansDatabaseQueries.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/litebans/LiteBansDatabaseQueries.java @@ -38,7 +38,7 @@ public class LiteBansDatabaseQueries extends Table { mutesTable = tablePrefix + "mutes"; warningsTable = tablePrefix + "warnings"; kicksTable = tablePrefix + "kicks"; - selectSQL = "SELECT uuid, reason, banned_by_name, until, active FROM "; + selectSQL = "SELECT uuid, reason, banned_by_name, until, active, time FROM "; } @Override @@ -92,9 +92,10 @@ public class LiteBansDatabaseQueries extends Table { } String reason = set.getString("reason"); String bannedBy = set.getString("banned_by_name"); - long time = set.getLong("until"); + long until = set.getLong("until"); + long time = set.getLong("time"); boolean active = set.getBoolean("active"); - objs.add(new LiteBansDBObj(uuid, reason, bannedBy, time, active)); + objs.add(new LiteBansDBObj(uuid, reason, bannedBy, until, active, time)); } return objs; }