Fixed Litebans errors #647

This commit is contained in:
Rsl1122 2018-08-08 11:17:23 +03:00
parent 5b4ae5ba36
commit ea15ff1b4f
2 changed files with 23 additions and 14 deletions

View File

@ -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<UUID> 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;
}

View File

@ -81,6 +81,9 @@ public class LiteBansDatabaseQueries extends Table {
List<LiteBansDBObj> objs = new ArrayList<>();
while (set.next()) {
String uuidS = set.getString("uuid");
if (uuidS == null) {
continue;
}
UUID uuid;
try {
uuid = UUID.fromString(uuidS);