From ea15ff1b4f862542175232e0355f64f29e0e7465 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Wed, 8 Aug 2018 11:17:23 +0300 Subject: [PATCH] Fixed Litebans errors #647 --- .../plan/litebans/LiteBansData.java | 34 +++++++++++-------- .../litebans/LiteBansDatabaseQueries.java | 3 ++ 2 files changed, 23 insertions(+), 14 deletions(-) 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 01dd71d96..45e719b0a 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 @@ -18,6 +18,7 @@ import com.djrapitops.plan.utilities.html.Html; import com.djrapitops.plan.utilities.html.icon.Color; import com.djrapitops.plan.utilities.html.icon.Family; import com.djrapitops.plan.utilities.html.icon.Icon; +import com.djrapitops.plan.utilities.html.icon.Icons; import com.djrapitops.plan.utilities.html.structure.TabsElement; import com.djrapitops.plugin.api.utility.log.Log; @@ -99,28 +100,33 @@ public class LiteBansData extends PluginData implements BanData { } catch (DBOpException ex) { Log.toLog(this.getClass().getName(), ex); table.addRow("Error: " + ex); + } catch (IllegalStateException e) { + inspectContainer.addValue(getWithIcon("Error", Icons.RED_WARN), "Database connection is not available"); + return inspectContainer; } inspectContainer.addTable("table", table); - return inspectContainer; } @Override public AnalysisContainer getServerData(Collection collection, AnalysisContainer analysisContainer) { - TableContainer banTable = getBanTable(); - TableContainer muteTable = getMuteTable(); - TableContainer warningTable = getWarningTable(); - TableContainer kickTable = getKickTable(); - - Html spacing = Html.PANEL_BODY; - String[] navAndHtml = new TabsElement( - new TabsElement.Tab(getWithIcon("Bans", Icon.called("ban")), spacing.parse(banTable.parseHtml())), - new TabsElement.Tab(getWithIcon("Mutes", Icon.called("bell-slash").of(Family.REGULAR)), spacing.parse(muteTable.parseHtml())), - new TabsElement.Tab(getWithIcon("Warnings", Icon.called("exclamation-triangle")), spacing.parse(warningTable.parseHtml())), - new TabsElement.Tab(getWithIcon("Kicks", Icon.called("user-times")), spacing.parse(kickTable.parseHtml())) - ).toHtml(); - analysisContainer.addHtml("Tables", navAndHtml[0] + navAndHtml[1]); + try { + TableContainer banTable = getBanTable(); + TableContainer muteTable = getMuteTable(); + TableContainer warningTable = getWarningTable(); + TableContainer kickTable = getKickTable(); + Html spacing = Html.PANEL_BODY; + String[] navAndHtml = new TabsElement( + new TabsElement.Tab(getWithIcon("Bans", Icon.called("ban")), spacing.parse(banTable.parseHtml())), + new TabsElement.Tab(getWithIcon("Mutes", Icon.called("bell-slash").of(Family.REGULAR)), spacing.parse(muteTable.parseHtml())), + new TabsElement.Tab(getWithIcon("Warnings", Icon.called("exclamation-triangle")), spacing.parse(warningTable.parseHtml())), + new TabsElement.Tab(getWithIcon("Kicks", Icon.called("user-times")), spacing.parse(kickTable.parseHtml())) + ).toHtml(); + analysisContainer.addHtml("Tables", navAndHtml[0] + navAndHtml[1]); + } catch (IllegalStateException e) { + analysisContainer.addValue(getWithIcon("Error", Icons.RED_WARN), "Database connection is not available"); + } return analysisContainer; } 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 ef1fb183a..dd791a8de 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 @@ -81,6 +81,9 @@ public class LiteBansDatabaseQueries extends Table { List objs = new ArrayList<>(); while (set.next()) { String uuidS = set.getString("uuid"); + if (uuidS == null) { + continue; + } UUID uuid; try { uuid = UUID.fromString(uuidS);