mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-10-31 07:50:09 +01:00
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:
parent
32f3cae7c4
commit
2e9f6148d6
@ -45,7 +45,7 @@ public class WorldTimesQueries {
|
|||||||
"SUM(" + WorldTimesTable.CREATIVE + ") as creative, " +
|
"SUM(" + WorldTimesTable.CREATIVE + ") as creative, " +
|
||||||
"SUM(" + WorldTimesTable.ADVENTURE + ") as adventure, " +
|
"SUM(" + WorldTimesTable.ADVENTURE + ") as adventure, " +
|
||||||
"SUM(" + WorldTimesTable.SPECTATOR + ") as spectator, " +
|
"SUM(" + WorldTimesTable.SPECTATOR + ") as spectator, " +
|
||||||
WorldTimesTable.SERVER_UUID + ", " +
|
WorldTimesTable.TABLE_NAME + "." + WorldTimesTable.SERVER_UUID + ", " +
|
||||||
WorldTable.TABLE_NAME + "." + WorldTable.NAME + " as " + worldColumn +
|
WorldTable.TABLE_NAME + "." + WorldTable.NAME + " as " + worldColumn +
|
||||||
FROM + WorldTimesTable.TABLE_NAME +
|
FROM + WorldTimesTable.TABLE_NAME +
|
||||||
" INNER JOIN " + WorldTable.TABLE_NAME + " on " + WorldTable.TABLE_NAME + "." + WorldTable.ID + "=" + WorldTimesTable.WORLD_ID;
|
" INNER JOIN " + WorldTable.TABLE_NAME + " on " + WorldTable.TABLE_NAME + "." + WorldTable.ID + "=" + WorldTimesTable.WORLD_ID;
|
||||||
|
@ -23,7 +23,7 @@ import com.djrapitops.plan.db.access.transactions.Transaction;
|
|||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
import java.util.UUID;
|
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.
|
* 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 final UUID playerUUID;
|
||||||
private InetAddress ip;
|
private InetAddress ip;
|
||||||
private long time;
|
private long time;
|
||||||
private Function<String, String> geolocationFunction;
|
private UnaryOperator<String> geolocationFunction;
|
||||||
|
|
||||||
private GeoInfo geoInfo;
|
private GeoInfo geoInfo;
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ public class GeoInfoStoreTransaction extends Transaction {
|
|||||||
UUID playerUUID,
|
UUID playerUUID,
|
||||||
InetAddress ip,
|
InetAddress ip,
|
||||||
long time,
|
long time,
|
||||||
Function<String, String> geolocationFunction
|
UnaryOperator<String> geolocationFunction
|
||||||
) {
|
) {
|
||||||
this.playerUUID = playerUUID;
|
this.playerUUID = playerUUID;
|
||||||
this.ip = ip;
|
this.ip = ip;
|
||||||
|
@ -16,8 +16,6 @@
|
|||||||
*/
|
*/
|
||||||
package com.djrapitops.plan.db.patches;
|
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.SQLDB;
|
||||||
import com.djrapitops.plan.db.sql.tables.*;
|
import com.djrapitops.plan.db.sql.tables.*;
|
||||||
|
|
||||||
@ -40,19 +38,15 @@ public class Version10Patch extends Patch {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void applyPatch() {
|
protected void applyPatch() {
|
||||||
try {
|
|
||||||
Optional<Integer> fetchedServerID = db.getServerTable().getServerID(getServerUUID());
|
Optional<Integer> fetchedServerID = db.getServerTable().getServerID(getServerUUID());
|
||||||
if (!fetchedServerID.isPresent()) {
|
if (!fetchedServerID.isPresent()) {
|
||||||
throw new IllegalStateException("Server UUID was not registered, try rebooting the plugin.");
|
throw new IllegalStateException("Server UUID was not registered, try rebooting the plugin.");
|
||||||
}
|
}
|
||||||
serverID = fetchedServerID.get();
|
serverID = fetchedServerID.get();
|
||||||
alterTablesToV10();
|
alterTablesToV10();
|
||||||
} catch (DBInitException e) {
|
|
||||||
throw new DBOpException(e.getMessage(), e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void alterTablesToV10() throws DBInitException {
|
public void alterTablesToV10() {
|
||||||
copyCommandUsage();
|
copyCommandUsage();
|
||||||
|
|
||||||
copyTPS();
|
copyTPS();
|
||||||
@ -73,7 +67,7 @@ public class Version10Patch extends Patch {
|
|||||||
dropTable("temp_users");
|
dropTable("temp_users");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void copyUsers() throws DBInitException {
|
private void copyUsers() {
|
||||||
String tempTableName = "temp_users";
|
String tempTableName = "temp_users";
|
||||||
renameTable(UsersTable.TABLE_NAME, tempTableName);
|
renameTable(UsersTable.TABLE_NAME, tempTableName);
|
||||||
|
|
||||||
@ -113,7 +107,7 @@ public class Version10Patch extends Patch {
|
|||||||
execute(statement);
|
execute(statement);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void copyCommandUsage() throws DBInitException {
|
private void copyCommandUsage() {
|
||||||
String tempTableName = "temp_cmdusg";
|
String tempTableName = "temp_cmdusg";
|
||||||
|
|
||||||
renameTable("plan_commandusages", tempTableName);
|
renameTable("plan_commandusages", tempTableName);
|
||||||
@ -129,7 +123,7 @@ public class Version10Patch extends Patch {
|
|||||||
dropTable(tempTableName);
|
dropTable(tempTableName);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void copyTPS() throws DBInitException {
|
private void copyTPS() {
|
||||||
String tempTableName = "temp_tps";
|
String tempTableName = "temp_tps";
|
||||||
TPSTable tpsTable = db.getTpsTable();
|
TPSTable tpsTable = db.getTpsTable();
|
||||||
|
|
||||||
|
@ -289,14 +289,14 @@ public class UsersTable extends Table {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public DataContainer getUserInformation(UUID uuid) {
|
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();
|
DataContainer returnValue = new SupplierDataContainer();
|
||||||
|
|
||||||
returnValue.putSupplier(user_data, () -> getUserInformationDataContainer(uuid));
|
returnValue.putSupplier(key, () -> getUserInformationDataContainer(uuid));
|
||||||
returnValue.putRawData(PlayerKeys.UUID, uuid);
|
returnValue.putRawData(PlayerKeys.UUID, uuid);
|
||||||
returnValue.putSupplier(PlayerKeys.REGISTERED, () -> returnValue.getUnsafe(user_data).getValue(PlayerKeys.REGISTERED).orElse(null));
|
returnValue.putSupplier(PlayerKeys.REGISTERED, () -> returnValue.getUnsafe(key).getValue(PlayerKeys.REGISTERED).orElse(null));
|
||||||
returnValue.putSupplier(PlayerKeys.NAME, () -> returnValue.getUnsafe(user_data).getValue(PlayerKeys.NAME).orElse(null));
|
returnValue.putSupplier(PlayerKeys.NAME, () -> returnValue.getUnsafe(key).getValue(PlayerKeys.NAME).orElse(null));
|
||||||
returnValue.putSupplier(PlayerKeys.KICK_COUNT, () -> returnValue.getUnsafe(user_data).getValue(PlayerKeys.KICK_COUNT).orElse(null));
|
returnValue.putSupplier(PlayerKeys.KICK_COUNT, () -> returnValue.getUnsafe(key).getValue(PlayerKeys.KICK_COUNT).orElse(null));
|
||||||
return returnValue;
|
return returnValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user