Removed ServerTable#getServerUUIDs()

This commit is contained in:
Rsl1122 2019-02-02 12:51:57 +02:00
parent 427971267e
commit 5776215c1e
6 changed files with 18 additions and 24 deletions

View File

@ -20,11 +20,13 @@ import com.djrapitops.plan.api.data.PlayerContainer;
import com.djrapitops.plan.api.data.ServerContainer;
import com.djrapitops.plan.api.exceptions.database.DBOpException;
import com.djrapitops.plan.db.access.Query;
import com.djrapitops.plan.db.access.queries.LargeFetchQueries;
import com.djrapitops.plan.db.access.queries.containers.ContainerFetchQueries;
import com.djrapitops.plan.utilities.uuid.UUIDUtility;
import com.djrapitops.plugin.logging.L;
import com.djrapitops.plugin.logging.error.ErrorHandler;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
@ -81,4 +83,9 @@ public abstract class CommonAPI implements PlanAPI {
public ServerContainer fetchServerContainer(UUID serverUUID) {
return new ServerContainer(queryDB(ContainerFetchQueries.fetchServerContainer(serverUUID)));
}
@Override
public Collection<UUID> fetchServerUUIDs() {
return queryDB(LargeFetchQueries.fetchPlanServerInformation()).keySet();
}
}

View File

@ -96,7 +96,5 @@ public interface PlanAPI {
*
* @return All Plan server UUIDs.
*/
default Collection<UUID> fetchServerUUIDs() {
return fetchFromPlanDB().getServerUUIDs();
}
Collection<UUID> fetchServerUUIDs();
}

View File

@ -20,6 +20,7 @@ import com.djrapitops.plan.db.SQLDB;
import com.djrapitops.plan.db.access.ExecBatchStatement;
import com.djrapitops.plan.db.access.QueryAllStatement;
import com.djrapitops.plan.db.access.QueryStatement;
import com.djrapitops.plan.db.access.queries.LargeFetchQueries;
import com.djrapitops.plan.db.access.queries.LargeStoreQueries;
import com.djrapitops.plan.db.sql.tables.SessionsTable;
import com.djrapitops.plan.db.sql.tables.WorldTable;
@ -66,7 +67,7 @@ public class WorldsServerIDPatch extends Patch {
@Override
protected void applyPatch() {
List<UUID> serverUUIDs = db.getServerTable().getServerUUIDs();
Collection<UUID> serverUUIDs = db.query(LargeFetchQueries.fetchPlanServerInformation()).keySet();
Map<UUID, Collection<String>> worldsPerServer = new HashMap<>();
for (UUID serverUUID : serverUUIDs) {

View File

@ -28,7 +28,10 @@ import com.djrapitops.plugin.utilities.Verify;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.*;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.UUID;
/**
* Table for managing multiple server's data in the database.
@ -178,22 +181,6 @@ public class ServerTable extends Table {
});
}
public List<UUID> getServerUUIDs() {
String sql = Select.from(tableName, SERVER_UUID)
.toString();
return query(new QueryAllStatement<List<UUID>>(sql) {
@Override
public List<UUID> processResults(ResultSet set) throws SQLException {
List<UUID> uuids = new ArrayList<>();
while (set.next()) {
uuids.add(UUID.fromString(set.getString(SERVER_UUID)));
}
return uuids;
}
});
}
public Optional<UUID> getServerUUID(String serverName) {
String sql = Select.from(tableName,
SERVER_UUID)

View File

@ -169,7 +169,7 @@ public class SQLFetchOps extends SQLOps implements FetchOperations {
@Override
public List<UUID> getServerUUIDs() {
return serverTable.getServerUUIDs();
return new ArrayList<>(db.query(LargeFetchQueries.fetchPlanServerInformation()).keySet());
}
@Override

View File

@ -18,6 +18,7 @@ package com.djrapitops.plan.system.settings.network;
import com.djrapitops.plan.api.exceptions.EnableException;
import com.djrapitops.plan.db.Database;
import com.djrapitops.plan.db.access.queries.LargeFetchQueries;
import com.djrapitops.plan.system.SubSystem;
import com.djrapitops.plan.system.database.DBSystem;
import com.djrapitops.plan.system.file.PlanFiles;
@ -39,8 +40,8 @@ import java.io.File;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.nio.file.Files;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
@ -166,7 +167,7 @@ public class NetworkSettingManager implements SubSystem {
private void updateConfigFromDBIfUpdated() {
Database database = dbSystem.getDatabase();
List<UUID> serverUUIDs = database.fetch().getServerUUIDs();
Set<UUID> serverUUIDs = database.query(LargeFetchQueries.fetchPlanServerInformation()).keySet();
// Remove the proxy server from the list
serverUUIDs.remove(serverInfo.getServerUUID());