diff --git a/Plan/common/src/main/java/com/djrapitops/plan/db/sql/tables/NicknamesTable.java b/Plan/common/src/main/java/com/djrapitops/plan/db/sql/tables/NicknamesTable.java index e2bdf2486..6c115e698 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/db/sql/tables/NicknamesTable.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/db/sql/tables/NicknamesTable.java @@ -82,52 +82,6 @@ public class NicknamesTable extends Table { .toString(); } - /** - * Get nicknames of the user on a server. - * - * @param uuid UUID of the Player - * @param serverUUID UUID of the server - * @return The nicknames of the User - */ - public List getNicknames(UUID uuid, UUID serverUUID) { - String sql = "SELECT " + NICKNAME + " FROM " + tableName + - " WHERE (" + USER_UUID + "=?)" + - " AND " + SERVER_UUID + "=?"; - - return query(new QueryStatement>(sql, 1000) { - @Override - public void prepare(PreparedStatement statement) throws SQLException { - statement.setString(1, uuid.toString()); - statement.setString(2, serverUUID.toString()); - } - - @Override - public List processResults(ResultSet set) throws SQLException { - List nicknames = new ArrayList<>(); - while (set.next()) { - String nickname = set.getString(NICKNAME); - if (nickname.isEmpty()) { - continue; - } - if (!nicknames.contains(nickname)) { - nicknames.add(nickname); - } - } - return nicknames; - } - }); - } - - /** - * Get nicknames of the user on THIS server. - * - * @param uuid UUID of the Player - * @return The nicknames of the User - */ - public List getNicknames(UUID uuid) { - return getNicknames(uuid, getServerUUID()); - } - public void saveUserName(UUID uuid, Nickname name) { List saved = getNicknameInformation(uuid); if (saved.contains(name)) { @@ -166,7 +120,7 @@ public class NicknamesTable extends Table { NICKNAME + ", " + LAST_USED + ", " + SERVER_UUID + - " FROM " + tableName + + " FROM " + TABLE_NAME + " WHERE (" + USER_UUID + "=?)"; return query(new QueryStatement>(sql, 5000) { diff --git a/Plan/common/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLFetchOps.java b/Plan/common/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLFetchOps.java index 319750427..b81264ff9 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLFetchOps.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLFetchOps.java @@ -24,6 +24,7 @@ import com.djrapitops.plan.data.container.UserInfo; import com.djrapitops.plan.data.store.containers.NetworkContainer; import com.djrapitops.plan.data.store.containers.PlayerContainer; import com.djrapitops.plan.data.store.containers.ServerContainer; +import com.djrapitops.plan.data.store.objects.Nickname; import com.djrapitops.plan.db.SQLDB; import com.djrapitops.plan.db.access.queries.LargeFetchQueries; import com.djrapitops.plan.db.access.queries.OptionalFetchQueries; @@ -134,7 +135,7 @@ public class SQLFetchOps extends SQLOps implements FetchOperations { @Override public List getNicknames(UUID uuid) { - return nicknamesTable.getNicknames(uuid); + return nicknamesTable.getNicknameInformation(uuid).stream().map(Nickname::getName).collect(Collectors.toList()); } @Override diff --git a/Plan/common/src/test/java/com/djrapitops/plan/db/CommonDBTest.java b/Plan/common/src/test/java/com/djrapitops/plan/db/CommonDBTest.java index e2fd8b803..d9b6c6aa3 100644 --- a/Plan/common/src/test/java/com/djrapitops/plan/db/CommonDBTest.java +++ b/Plan/common/src/test/java/com/djrapitops/plan/db/CommonDBTest.java @@ -488,7 +488,7 @@ public abstract class CommonDBTest { assertFalse(db.query(PlayerFetchQueries.isPlayerRegistered(playerUUID))); assertFalse(db.query(PlayerFetchQueries.isPlayerRegisteredOnServer(playerUUID, serverUUID))); - assertTrue(nicknamesTable.getNicknames(playerUUID).isEmpty()); + assertTrue(nicknamesTable.getNicknameInformation(playerUUID).isEmpty()); assertTrue(db.query(PlayerFetchQueries.playerGeoInfo(playerUUID)).isEmpty()); assertTrue(sessionsTable.getSessions(playerUUID).isEmpty()); }