Fixed Smells, Level Minor (SonarCloud):

- Function<String, String> in GeoInfoStoreTransaction
- Unused throws clause in Version10Patch
- Bad variable name in UsersTable

- Fixed WorldTimesQueries again
This commit is contained in:
Rsl1122 2019-02-14 22:47:19 +02:00
parent 32f3cae7c4
commit 2e9f6148d6
4 changed files with 18 additions and 24 deletions

View File

@ -45,7 +45,7 @@ public class WorldTimesQueries {
"SUM(" + WorldTimesTable.CREATIVE + ") as creative, " +
"SUM(" + WorldTimesTable.ADVENTURE + ") as adventure, " +
"SUM(" + WorldTimesTable.SPECTATOR + ") as spectator, " +
WorldTimesTable.SERVER_UUID + ", " +
WorldTimesTable.TABLE_NAME + "." + WorldTimesTable.SERVER_UUID + ", " +
WorldTable.TABLE_NAME + "." + WorldTable.NAME + " as " + worldColumn +
FROM + WorldTimesTable.TABLE_NAME +
" INNER JOIN " + WorldTable.TABLE_NAME + " on " + WorldTable.TABLE_NAME + "." + WorldTable.ID + "=" + WorldTimesTable.WORLD_ID;

View File

@ -23,7 +23,7 @@ import com.djrapitops.plan.db.access.transactions.Transaction;
import java.net.InetAddress;
import java.security.NoSuchAlgorithmException;
import java.util.UUID;
import java.util.function.Function;
import java.util.function.UnaryOperator;
/**
* Transaction to update Geo information of a player in the database.
@ -37,7 +37,7 @@ public class GeoInfoStoreTransaction extends Transaction {
private final UUID playerUUID;
private InetAddress ip;
private long time;
private Function<String, String> geolocationFunction;
private UnaryOperator<String> geolocationFunction;
private GeoInfo geoInfo;
@ -45,7 +45,7 @@ public class GeoInfoStoreTransaction extends Transaction {
UUID playerUUID,
InetAddress ip,
long time,
Function<String, String> geolocationFunction
UnaryOperator<String> geolocationFunction
) {
this.playerUUID = playerUUID;
this.ip = ip;

View File

@ -16,8 +16,6 @@
*/
package com.djrapitops.plan.db.patches;
import com.djrapitops.plan.api.exceptions.database.DBInitException;
import com.djrapitops.plan.api.exceptions.database.DBOpException;
import com.djrapitops.plan.db.SQLDB;
import com.djrapitops.plan.db.sql.tables.*;
@ -40,19 +38,15 @@ public class Version10Patch extends Patch {
@Override
protected void applyPatch() {
try {
Optional<Integer> fetchedServerID = db.getServerTable().getServerID(getServerUUID());
if (!fetchedServerID.isPresent()) {
throw new IllegalStateException("Server UUID was not registered, try rebooting the plugin.");
}
serverID = fetchedServerID.get();
alterTablesToV10();
} catch (DBInitException e) {
throw new DBOpException(e.getMessage(), e);
Optional<Integer> fetchedServerID = db.getServerTable().getServerID(getServerUUID());
if (!fetchedServerID.isPresent()) {
throw new IllegalStateException("Server UUID was not registered, try rebooting the plugin.");
}
serverID = fetchedServerID.get();
alterTablesToV10();
}
public void alterTablesToV10() throws DBInitException {
public void alterTablesToV10() {
copyCommandUsage();
copyTPS();
@ -73,7 +67,7 @@ public class Version10Patch extends Patch {
dropTable("temp_users");
}
private void copyUsers() throws DBInitException {
private void copyUsers() {
String tempTableName = "temp_users";
renameTable(UsersTable.TABLE_NAME, tempTableName);
@ -113,7 +107,7 @@ public class Version10Patch extends Patch {
execute(statement);
}
private void copyCommandUsage() throws DBInitException {
private void copyCommandUsage() {
String tempTableName = "temp_cmdusg";
renameTable("plan_commandusages", tempTableName);
@ -129,7 +123,7 @@ public class Version10Patch extends Patch {
dropTable(tempTableName);
}
private void copyTPS() throws DBInitException {
private void copyTPS() {
String tempTableName = "temp_tps";
TPSTable tpsTable = db.getTpsTable();

View File

@ -289,14 +289,14 @@ public class UsersTable extends Table {
}
public DataContainer getUserInformation(UUID uuid) {
Key<DataContainer> user_data = new Key<>(DataContainer.class, "plan_users_data");
Key<DataContainer> key = new Key<>(DataContainer.class, "plan_users_data");
DataContainer returnValue = new SupplierDataContainer();
returnValue.putSupplier(user_data, () -> getUserInformationDataContainer(uuid));
returnValue.putSupplier(key, () -> getUserInformationDataContainer(uuid));
returnValue.putRawData(PlayerKeys.UUID, uuid);
returnValue.putSupplier(PlayerKeys.REGISTERED, () -> returnValue.getUnsafe(user_data).getValue(PlayerKeys.REGISTERED).orElse(null));
returnValue.putSupplier(PlayerKeys.NAME, () -> returnValue.getUnsafe(user_data).getValue(PlayerKeys.NAME).orElse(null));
returnValue.putSupplier(PlayerKeys.KICK_COUNT, () -> returnValue.getUnsafe(user_data).getValue(PlayerKeys.KICK_COUNT).orElse(null));
returnValue.putSupplier(PlayerKeys.REGISTERED, () -> returnValue.getUnsafe(key).getValue(PlayerKeys.REGISTERED).orElse(null));
returnValue.putSupplier(PlayerKeys.NAME, () -> returnValue.getUnsafe(key).getValue(PlayerKeys.NAME).orElse(null));
returnValue.putSupplier(PlayerKeys.KICK_COUNT, () -> returnValue.getUnsafe(key).getValue(PlayerKeys.KICK_COUNT).orElse(null));
return returnValue;
}