Fixed compile issues in PluginBridge

This commit is contained in:
Rsl1122 2018-06-02 08:07:06 +03:00
parent 0cccb6dedf
commit d677fb816e
5 changed files with 38 additions and 35 deletions

View File

@ -5,6 +5,7 @@
package com.djrapitops.pluginbridge.plan.litebans;
import com.djrapitops.plan.api.PlanAPI;
import com.djrapitops.plan.api.exceptions.database.DBOpException;
import com.djrapitops.plan.data.element.AnalysisContainer;
import com.djrapitops.plan.data.element.InspectContainer;
import com.djrapitops.plan.data.element.TableContainer;
@ -17,7 +18,6 @@ import com.djrapitops.plan.utilities.html.Html;
import com.djrapitops.plan.utilities.html.structure.TabsElement;
import com.djrapitops.plugin.api.utility.log.Log;
import java.sql.SQLException;
import java.util.*;
import java.util.stream.Collectors;
@ -96,7 +96,7 @@ public class LiteBansData extends PluginData implements BanData {
);
}
}
} catch (SQLException ex) {
} catch (DBOpException ex) {
Log.toLog(this.getClass().getName(), ex);
table.addRow("Error: " + ex);
}
@ -124,7 +124,7 @@ public class LiteBansData extends PluginData implements BanData {
return analysisContainer;
}
private TableContainer getBanTable() throws SQLException {
private TableContainer getBanTable() {
String banned = getWithIcon("Banned", "ban");
String by = getWithIcon("Banned By", "gavel");
String reason = getWithIcon("Reason", "balance-scale");
@ -137,7 +137,7 @@ public class LiteBansData extends PluginData implements BanData {
return banTable;
}
private TableContainer getMuteTable() throws SQLException {
private TableContainer getMuteTable() {
String muted = getWithIcon("Muted", "bell-slash-o");
String by = getWithIcon("Muted By", "gavel");
String reason = getWithIcon("Reason", "balance-scale");
@ -150,7 +150,7 @@ public class LiteBansData extends PluginData implements BanData {
return muteTable;
}
private TableContainer getWarningTable() throws SQLException {
private TableContainer getWarningTable() {
String warned = getWithIcon("Warned", "exclamation-triangle");
String by = getWithIcon("Warned By", "gavel");
String reason = getWithIcon("Reason", "balance-scale");
@ -163,7 +163,7 @@ public class LiteBansData extends PluginData implements BanData {
return warnTable;
}
private TableContainer getKickTable() throws SQLException {
private TableContainer getKickTable() {
String kicked = getWithIcon("Kicked", "user-times");
String by = getWithIcon("Kicked By", "gavel");
String reason = getWithIcon("Reason", "balance-scale");
@ -201,8 +201,8 @@ public class LiteBansData extends PluginData implements BanData {
public boolean isBanned(UUID uuid) {
try {
return !db.getBans(uuid).isEmpty();
} catch (SQLException e) {
Log.toLog(this.getClass().getName(), e);
} catch (DBOpException e) {
Log.toLog(this.getClass(), e);
}
return false;
}
@ -217,8 +217,8 @@ public class LiteBansData extends PluginData implements BanData {
}
return collection.stream().filter(banned::contains).collect(Collectors.toSet());
} catch (SQLException e) {
Log.toLog(this.getClass().getName(), e);
} catch (DBOpException e) {
Log.toLog(this.getClass(), e);
}
return new HashSet<>();
}

View File

@ -1,5 +1,6 @@
package com.djrapitops.pluginbridge.plan.litebans;
import com.djrapitops.plan.api.exceptions.database.DBOpException;
import com.djrapitops.plan.system.database.databases.sql.processing.QueryAllStatement;
import com.djrapitops.plan.system.database.databases.sql.processing.QueryStatement;
import com.djrapitops.plan.system.database.databases.sql.tables.Table;
@ -41,13 +42,15 @@ public class LiteBansDatabaseQueries extends Table {
}
@Override
protected <T> T query(QueryStatement<T> statement) throws SQLException {
protected <T> T query(QueryStatement<T> statement) {
try (PreparedStatement preparedStatement = database.prepareStatement(statement.getSql())) {
return statement.executeQuery(preparedStatement);
} catch (SQLException e) {
throw DBOpException.forCause(statement.getSql(), e);
}
}
private List<LiteBansDBObj> getObjs(String table) throws SQLException {
private List<LiteBansDBObj> getObjs(String table) {
String sql = selectSQL + table + " LIMIT 5000";
return query(new QueryAllStatement<List<LiteBansDBObj>>(sql, 2000) {
@ -58,19 +61,19 @@ public class LiteBansDatabaseQueries extends Table {
});
}
public List<LiteBansDBObj> getBans() throws SQLException {
public List<LiteBansDBObj> getBans() {
return getObjs(banTable);
}
public List<LiteBansDBObj> getMutes() throws SQLException {
public List<LiteBansDBObj> getMutes() {
return getObjs(mutesTable);
}
public List<LiteBansDBObj> getWarnings() throws SQLException {
public List<LiteBansDBObj> getWarnings() {
return getObjs(warningsTable);
}
public List<LiteBansDBObj> getKicks() throws SQLException {
public List<LiteBansDBObj> getKicks() {
return getObjs(kicksTable);
}
@ -93,23 +96,23 @@ public class LiteBansDatabaseQueries extends Table {
return objs;
}
public List<LiteBansDBObj> getBans(UUID playerUUID) throws SQLException {
public List<LiteBansDBObj> getBans(UUID playerUUID) {
return getObjs(playerUUID, banTable);
}
public List<LiteBansDBObj> getMutes(UUID playerUUID) throws SQLException {
public List<LiteBansDBObj> getMutes(UUID playerUUID) {
return getObjs(playerUUID, mutesTable);
}
public List<LiteBansDBObj> getWarnings(UUID playerUUID) throws SQLException {
public List<LiteBansDBObj> getWarnings(UUID playerUUID) {
return getObjs(playerUUID, warningsTable);
}
public List<LiteBansDBObj> getKicks(UUID playerUUID) throws SQLException {
public List<LiteBansDBObj> getKicks(UUID playerUUID) {
return getObjs(playerUUID, kicksTable);
}
private List<LiteBansDBObj> getObjs(UUID playerUUID, String table) throws SQLException {
private List<LiteBansDBObj> getObjs(UUID playerUUID, String table) {
String sql = selectSQL + table + " WHERE uuid=?";
return query(new QueryStatement<List<LiteBansDBObj>>(sql, 2000) {

View File

@ -4,6 +4,7 @@
*/
package com.djrapitops.pluginbridge.plan.protocolsupport;
import com.djrapitops.plan.api.exceptions.database.DBOpException;
import com.djrapitops.plan.data.element.AnalysisContainer;
import com.djrapitops.plan.data.element.InspectContainer;
import com.djrapitops.plan.data.element.TableContainer;
@ -13,7 +14,6 @@ import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.pluginbridge.plan.viaversion.Protocol;
import com.djrapitops.pluginbridge.plan.viaversion.ProtocolTable;
import java.sql.SQLException;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
@ -43,7 +43,7 @@ public class ProtocolSupportData extends PluginData {
inspectContainer.addValue(getWithIcon("Last Join Version", "signal", "light-green"),
protocolVersion != -1 ? Protocol.getMCVersion(protocolVersion) : "Not Yet Known");
} catch (SQLException ex) {
} catch (DBOpException ex) {
Log.toLog(this.getClass().getName(), ex);
}
@ -56,7 +56,7 @@ public class ProtocolSupportData extends PluginData {
try {
versions = table.getProtocolVersions();
} catch (SQLException ex) {
} catch (DBOpException ex) {
Log.toLog(this.getClass().getName(), ex);
return analysisContainer;
}

View File

@ -46,7 +46,7 @@ public class ProtocolTable extends Table {
);
}
public void saveProtocolVersion(UUID uuid, int version) throws SQLException {
public void saveProtocolVersion(UUID uuid, int version) {
if (exists(uuid)) {
updateProtocolVersion(uuid, version);
} else {
@ -54,7 +54,7 @@ public class ProtocolTable extends Table {
}
}
public int getProtocolVersion(UUID uuid) throws SQLException {
public int getProtocolVersion(UUID uuid) {
String sql = "SELECT " + columnProtocolVersion + " FROM " + tableName + " WHERE " + columnUUID + "=?";
return query(new QueryStatement<Integer>(sql) {
@ -74,7 +74,7 @@ public class ProtocolTable extends Table {
});
}
public Map<UUID, Integer> getProtocolVersions() throws SQLException {
public Map<UUID, Integer> getProtocolVersions() {
return query(new QueryAllStatement<Map<UUID, Integer>>(Select.all(tableName).toString(), 5000) {
@Override
public Map<UUID, Integer> processResults(ResultSet set) throws SQLException {
@ -89,11 +89,11 @@ public class ProtocolTable extends Table {
});
}
private boolean exists(UUID uuid) throws SQLException {
private boolean exists(UUID uuid) {
return getProtocolVersion(uuid) != -1;
}
private void updateProtocolVersion(UUID uuid, int version) throws SQLException {
private void updateProtocolVersion(UUID uuid, int version) {
String sql = "UPDATE " + tableName + " SET "
+ columnProtocolVersion + "=? "
+ " WHERE (" + columnUUID + "=?)";
@ -107,7 +107,7 @@ public class ProtocolTable extends Table {
});
}
private void insertProtocolVersion(UUID uuid, int version) throws SQLException {
private void insertProtocolVersion(UUID uuid, int version) {
String sql = "INSERT INTO " + tableName + " ("
+ columnUUID + ", "
+ columnProtocolVersion

View File

@ -4,6 +4,7 @@
*/
package com.djrapitops.pluginbridge.plan.viaversion;
import com.djrapitops.plan.api.exceptions.database.DBOpException;
import com.djrapitops.plan.data.element.AnalysisContainer;
import com.djrapitops.plan.data.element.InspectContainer;
import com.djrapitops.plan.data.element.TableContainer;
@ -11,7 +12,6 @@ import com.djrapitops.plan.data.plugin.ContainerSize;
import com.djrapitops.plan.data.plugin.PluginData;
import com.djrapitops.plugin.api.utility.log.Log;
import java.sql.SQLException;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
@ -41,8 +41,8 @@ public class ViaVersionData extends PluginData {
inspectContainer.addValue(getWithIcon("Last Join Version", "signal", "light-green"),
protocolVersion != -1 ? Protocol.getMCVersion(protocolVersion) : "Not Yet Known");
} catch (SQLException ex) {
Log.toLog(this.getClass().getName(), ex);
} catch (DBOpException ex) {
Log.toLog(this.getClass(), ex);
}
return inspectContainer;
@ -54,8 +54,8 @@ public class ViaVersionData extends PluginData {
try {
versions = table.getProtocolVersions();
} catch (SQLException ex) {
Log.toLog(this.getClass().getName(), ex);
} catch (DBOpException ex) {
Log.toLog(this.getClass(), ex);
return analysisContainer;
}