mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-30 16:19:56 +08:00
Test and fix user move and combination transactions
This commit is contained in:
parent
ea16adb13d
commit
3eff46523d
@ -20,7 +20,7 @@ import com.djrapitops.plan.delivery.domain.Nickname;
|
||||
import com.djrapitops.plan.gathering.cache.NicknameCache;
|
||||
import com.djrapitops.plan.identification.ServerInfo;
|
||||
import com.djrapitops.plan.storage.database.DBSystem;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.NicknameStoreTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.StoreNicknameTransaction;
|
||||
import com.djrapitops.plan.utilities.logging.ErrorContext;
|
||||
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -76,7 +76,7 @@ public class ChatListener implements Listener {
|
||||
UUID uuid = player.getUniqueId();
|
||||
String displayName = player.getDisplayName();
|
||||
|
||||
dbSystem.getDatabase().executeTransaction(new NicknameStoreTransaction(
|
||||
dbSystem.getDatabase().executeTransaction(new StoreNicknameTransaction(
|
||||
uuid, new Nickname(displayName, time, serverInfo.getServerUUID()),
|
||||
(playerUUID, name) -> nicknameCache.getDisplayName(playerUUID).map(name::equals).orElse(false)
|
||||
));
|
||||
|
@ -21,7 +21,7 @@ import com.djrapitops.plan.gathering.domain.ActiveSession;
|
||||
import com.djrapitops.plan.identification.ServerInfo;
|
||||
import com.djrapitops.plan.settings.config.WorldAliasSettings;
|
||||
import com.djrapitops.plan.storage.database.DBSystem;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.WorldNameStoreTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.StoreWorldNameTransaction;
|
||||
import com.djrapitops.plan.utilities.logging.ErrorContext;
|
||||
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -78,7 +78,7 @@ public class GameModeChangeListener implements Listener {
|
||||
String gameMode = event.getNewGameMode().name();
|
||||
String worldName = player.getWorld().getName();
|
||||
|
||||
dbSystem.getDatabase().executeTransaction(new WorldNameStoreTransaction(serverInfo.getServerUUID(), worldName));
|
||||
dbSystem.getDatabase().executeTransaction(new StoreWorldNameTransaction(serverInfo.getServerUUID(), worldName));
|
||||
worldAliasSettings.addWorld(worldName);
|
||||
|
||||
Optional<ActiveSession> cachedSession = SessionCache.getCachedSession(uuid);
|
||||
|
@ -21,7 +21,7 @@ import com.djrapitops.plan.gathering.domain.ActiveSession;
|
||||
import com.djrapitops.plan.identification.ServerInfo;
|
||||
import com.djrapitops.plan.settings.config.WorldAliasSettings;
|
||||
import com.djrapitops.plan.storage.database.DBSystem;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.WorldNameStoreTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.StoreWorldNameTransaction;
|
||||
import com.djrapitops.plan.utilities.logging.ErrorContext;
|
||||
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -72,7 +72,7 @@ public class WorldChangeListener implements Listener {
|
||||
String worldName = player.getWorld().getName();
|
||||
String gameMode = player.getGameMode().name();
|
||||
|
||||
dbSystem.getDatabase().executeTransaction(new WorldNameStoreTransaction(serverInfo.getServerUUID(), worldName));
|
||||
dbSystem.getDatabase().executeTransaction(new StoreWorldNameTransaction(serverInfo.getServerUUID(), worldName));
|
||||
worldAliasSettings.addWorld(worldName);
|
||||
|
||||
Optional<ActiveSession> cachedSession = SessionCache.getCachedSession(uuid);
|
||||
|
@ -31,8 +31,8 @@ import com.djrapitops.plan.settings.locale.lang.HelpLang;
|
||||
import com.djrapitops.plan.storage.database.DBSystem;
|
||||
import com.djrapitops.plan.storage.database.Database;
|
||||
import com.djrapitops.plan.storage.database.queries.objects.WebUserQueries;
|
||||
import com.djrapitops.plan.storage.database.transactions.commands.RegisterWebUserTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.commands.RemoveWebUserTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.commands.StoreWebUserTransaction;
|
||||
import com.djrapitops.plan.utilities.PassEncryptUtil;
|
||||
import com.djrapitops.plan.utilities.logging.ErrorContext;
|
||||
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
||||
@ -158,7 +158,7 @@ public class RegistrationCommands {
|
||||
boolean userExists = database.query(WebUserQueries.fetchUser(username)).isPresent();
|
||||
if (userExists) throw new IllegalArgumentException(locale.getString(CommandLang.FAIL_WEB_USER_EXISTS));
|
||||
|
||||
database.executeTransaction(new RegisterWebUserTransaction(user))
|
||||
database.executeTransaction(new StoreWebUserTransaction(user))
|
||||
.get(); // Wait for completion
|
||||
|
||||
sender.send(locale.getString(CommandLang.WEB_USER_REGISTER_SUCCESS, username));
|
||||
|
@ -123,14 +123,14 @@ public class PlayerJoinEventConsumer {
|
||||
private void storeWorldInformation(PlayerJoin join) {
|
||||
ServerUUID serverUUID = join.getServerUUID();
|
||||
join.getPlayer().getCurrentWorld()
|
||||
.map(world -> new WorldNameStoreTransaction(serverUUID, world))
|
||||
.map(world -> new StoreWorldNameTransaction(serverUUID, world))
|
||||
.ifPresent(dbSystem.getDatabase()::executeTransaction);
|
||||
}
|
||||
|
||||
private CompletableFuture<?> storeGamePlayer(PlayerJoin join) {
|
||||
long registerDate = join.getPlayer().getRegisterDate().orElseGet(join::getTime);
|
||||
String joinAddress = join.getPlayer().getJoinAddress().orElse(JoinAddressTable.DEFAULT_VALUE_FOR_LOOKUP);
|
||||
Transaction transaction = new PlayerServerRegisterTransaction(
|
||||
Transaction transaction = new StoreServerPlayerTransaction(
|
||||
join.getPlayerUUID(), registerDate, join.getPlayer().getName(), join.getServerUUID(), joinAddress
|
||||
);
|
||||
return dbSystem.getDatabase().executeTransaction(transaction);
|
||||
@ -171,7 +171,7 @@ public class PlayerJoinEventConsumer {
|
||||
private void storeNickname(PlayerJoin join) {
|
||||
join.getPlayer().getDisplayName()
|
||||
.map(displayName -> new Nickname(displayName, join.getTime(), join.getServerUUID()))
|
||||
.map(nickname -> new NicknameStoreTransaction(
|
||||
.map(nickname -> new StoreNicknameTransaction(
|
||||
join.getPlayerUUID(), nickname,
|
||||
(uuid, name) -> nicknameCache.getDisplayName(join.getPlayerUUID())
|
||||
.map(name::equals)
|
||||
|
@ -55,6 +55,7 @@ public class CombineUserTransaction extends ChangeUserUUIDTransaction {
|
||||
|
||||
execute(updateUserInfo(newId, oldId));
|
||||
execute(DELETE_FROM + UserInfoTable.TABLE_NAME + WHERE + UserInfoTable.USER_ID + "=" + oldId);
|
||||
execute(DELETE_FROM + UsersTable.TABLE_NAME + WHERE + UsersTable.ID + "=" + oldId);
|
||||
|
||||
super.performOperations(); // Change UUID fields to match where user_id is not used
|
||||
}
|
||||
|
@ -30,11 +30,11 @@ import java.sql.Types;
|
||||
*
|
||||
* @author AuroraLS3
|
||||
*/
|
||||
public class RegisterWebUserTransaction extends Transaction {
|
||||
public class StoreWebUserTransaction extends Transaction {
|
||||
|
||||
private final User user;
|
||||
|
||||
public RegisterWebUserTransaction(User user) {
|
||||
public StoreWebUserTransaction(User user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
@ -28,13 +28,13 @@ import java.util.function.BiPredicate;
|
||||
*
|
||||
* @author AuroraLS3
|
||||
*/
|
||||
public class NicknameStoreTransaction extends ThrowawayTransaction {
|
||||
public class StoreNicknameTransaction extends ThrowawayTransaction {
|
||||
|
||||
private final UUID playerUUID;
|
||||
private final Nickname nickname;
|
||||
private final BiPredicate<UUID, String> isNicknameCachedCheck;
|
||||
|
||||
public NicknameStoreTransaction(UUID playerUUID, Nickname nickname, BiPredicate<UUID, String> isNicknameCachedCheck) {
|
||||
public StoreNicknameTransaction(UUID playerUUID, Nickname nickname, BiPredicate<UUID, String> isNicknameCachedCheck) {
|
||||
this.playerUUID = playerUUID;
|
||||
this.nickname = nickname;
|
||||
this.isNicknameCachedCheck = isNicknameCachedCheck;
|
@ -31,19 +31,19 @@ import java.util.function.Supplier;
|
||||
*
|
||||
* @author AuroraLS3
|
||||
*/
|
||||
public class PlayerServerRegisterTransaction extends PlayerRegisterTransaction {
|
||||
public class StoreServerPlayerTransaction extends PlayerRegisterTransaction {
|
||||
|
||||
private final ServerUUID serverUUID;
|
||||
private final Supplier<String> getJoinAddress;
|
||||
|
||||
public PlayerServerRegisterTransaction(UUID playerUUID, LongSupplier registered,
|
||||
String playerName, ServerUUID serverUUID, Supplier<String> getJoinAddress) {
|
||||
public StoreServerPlayerTransaction(UUID playerUUID, LongSupplier registered,
|
||||
String playerName, ServerUUID serverUUID, Supplier<String> getJoinAddress) {
|
||||
super(playerUUID, registered, playerName);
|
||||
this.serverUUID = serverUUID;
|
||||
this.getJoinAddress = getJoinAddress;
|
||||
}
|
||||
|
||||
public PlayerServerRegisterTransaction(UUID playerUUID, long registerDate, String name, ServerUUID serverUUID, String joinAddress) {
|
||||
public StoreServerPlayerTransaction(UUID playerUUID, long registerDate, String name, ServerUUID serverUUID, String joinAddress) {
|
||||
this(playerUUID, () -> registerDate, name, serverUUID, () -> joinAddress);
|
||||
}
|
||||
|
@ -33,12 +33,12 @@ import static com.djrapitops.plan.storage.database.sql.building.Sql.*;
|
||||
*
|
||||
* @author AuroraLS3
|
||||
*/
|
||||
public class WorldNameStoreTransaction extends Transaction {
|
||||
public class StoreWorldNameTransaction extends Transaction {
|
||||
|
||||
private final ServerUUID serverUUID;
|
||||
private final String worldName;
|
||||
|
||||
public WorldNameStoreTransaction(ServerUUID serverUUID, String worldName) {
|
||||
public StoreWorldNameTransaction(ServerUUID serverUUID, String worldName) {
|
||||
this.serverUUID = serverUUID;
|
||||
this.worldName = worldName;
|
||||
}
|
@ -29,7 +29,7 @@ import com.djrapitops.plan.storage.database.DBSystem;
|
||||
import com.djrapitops.plan.storage.database.Database;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.PlayerRegisterTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.StoreSessionTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.WorldNameStoreTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.StoreWorldNameTransaction;
|
||||
import extension.SeleniumExtension;
|
||||
import org.junit.jupiter.api.*;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
@ -130,7 +130,7 @@ class ExportJSErrorRegressionTest {
|
||||
UUID uuid = TestConstants.PLAYER_ONE_UUID;
|
||||
database.executeTransaction(new PlayerRegisterTransaction(uuid, RandomData::randomTime, TestConstants.PLAYER_ONE_NAME));
|
||||
FinishedSession session = new FinishedSession(uuid, serverUUID, 1000L, 11000L, 500L, new DataMap());
|
||||
database.executeTransaction(new WorldNameStoreTransaction(serverUUID, "world"));
|
||||
database.executeTransaction(new StoreWorldNameTransaction(serverUUID, "world"));
|
||||
database.executeTransaction(new StoreSessionTransaction(session));
|
||||
}
|
||||
|
||||
@ -187,7 +187,7 @@ class ExportJSErrorRegressionTest {
|
||||
List<String> loggedLines = logs.stream()
|
||||
.map(log -> "\n" + log.getLevel().getName() + " " + log.getMessage())
|
||||
.filter(line -> !line.contains("favicon.ico"))
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
assertTrue(loggedLines.isEmpty(), () -> "Browser console included " + loggedLines.size() + " logs: " + loggedLines);
|
||||
}
|
||||
}
|
@ -26,7 +26,7 @@ import com.djrapitops.plan.settings.config.changes.ConfigUpdater;
|
||||
import com.djrapitops.plan.settings.config.paths.WebserverSettings;
|
||||
import com.djrapitops.plan.storage.database.queries.ExtensionsDatabaseTest;
|
||||
import com.djrapitops.plan.storage.database.transactions.StoreServerInformationTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.commands.RegisterWebUserTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.commands.StoreWebUserTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.PlayerRegisterTransaction;
|
||||
import com.djrapitops.plan.utilities.PassEncryptUtil;
|
||||
import org.apache.commons.compress.utils.IOUtils;
|
||||
@ -99,10 +99,10 @@ class AccessControlTest {
|
||||
User userLevel1 = new User("test1", "console", null, PassEncryptUtil.createHash("testPass"), 1, Collections.emptyList());
|
||||
User userLevel2 = new User("test2", TestConstants.PLAYER_ONE_NAME, TestConstants.PLAYER_ONE_UUID, PassEncryptUtil.createHash("testPass"), 2, Collections.emptyList());
|
||||
User userLevel100 = new User("test100", "console", null, PassEncryptUtil.createHash("testPass"), 100, Collections.emptyList());
|
||||
system.getDatabaseSystem().getDatabase().executeTransaction(new RegisterWebUserTransaction(userLevel0));
|
||||
system.getDatabaseSystem().getDatabase().executeTransaction(new RegisterWebUserTransaction(userLevel1));
|
||||
system.getDatabaseSystem().getDatabase().executeTransaction(new RegisterWebUserTransaction(userLevel2));
|
||||
system.getDatabaseSystem().getDatabase().executeTransaction(new RegisterWebUserTransaction(userLevel100));
|
||||
system.getDatabaseSystem().getDatabase().executeTransaction(new StoreWebUserTransaction(userLevel0));
|
||||
system.getDatabaseSystem().getDatabase().executeTransaction(new StoreWebUserTransaction(userLevel1));
|
||||
system.getDatabaseSystem().getDatabase().executeTransaction(new StoreWebUserTransaction(userLevel2));
|
||||
system.getDatabaseSystem().getDatabase().executeTransaction(new StoreWebUserTransaction(userLevel100));
|
||||
|
||||
system.getDatabaseSystem().getDatabase().executeTransaction(new PlayerRegisterTransaction(TestConstants.PLAYER_ONE_UUID, () -> 0L, TestConstants.PLAYER_ONE_NAME));
|
||||
system.getDatabaseSystem().getDatabase().executeTransaction(new StoreServerInformationTransaction(new Server(
|
||||
|
@ -31,7 +31,7 @@ import com.djrapitops.plan.storage.database.DBSystem;
|
||||
import com.djrapitops.plan.storage.database.Database;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.PlayerRegisterTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.StoreSessionTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.WorldNameStoreTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.StoreWorldNameTransaction;
|
||||
import extension.SeleniumExtension;
|
||||
import org.junit.jupiter.api.*;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
@ -100,7 +100,7 @@ class JSErrorRegressionTest {
|
||||
UUID uuid = TestConstants.PLAYER_ONE_UUID;
|
||||
database.executeTransaction(new PlayerRegisterTransaction(uuid, RandomData::randomTime, TestConstants.PLAYER_ONE_NAME));
|
||||
FinishedSession session = new FinishedSession(uuid, serverUUID, 1000L, 11000L, 500L, new DataMap());
|
||||
database.executeTransaction(new WorldNameStoreTransaction(serverUUID, "world"));
|
||||
database.executeTransaction(new StoreWorldNameTransaction(serverUUID, "world"));
|
||||
database.executeTransaction(new StoreSessionTransaction(session));
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ import com.djrapitops.plan.delivery.domain.auth.User;
|
||||
import com.djrapitops.plan.delivery.webserver.http.WebServer;
|
||||
import com.djrapitops.plan.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.settings.config.paths.WebserverSettings;
|
||||
import com.djrapitops.plan.storage.database.transactions.commands.RegisterWebUserTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.commands.StoreWebUserTransaction;
|
||||
import com.djrapitops.plan.utilities.PassEncryptUtil;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
@ -61,7 +61,7 @@ class JksHttpsServerTest implements HttpsServerTest {
|
||||
system.enable();
|
||||
|
||||
User user = new User("test", "console", null, PassEncryptUtil.createHash("testPass"), 0, Collections.emptyList());
|
||||
system.getDatabaseSystem().getDatabase().executeTransaction(new RegisterWebUserTransaction(user));
|
||||
system.getDatabaseSystem().getDatabase().executeTransaction(new StoreWebUserTransaction(user));
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
|
@ -22,7 +22,7 @@ import com.djrapitops.plan.delivery.webserver.http.WebServer;
|
||||
import com.djrapitops.plan.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.settings.config.changes.ConfigUpdater;
|
||||
import com.djrapitops.plan.settings.config.paths.WebserverSettings;
|
||||
import com.djrapitops.plan.storage.database.transactions.commands.RegisterWebUserTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.commands.StoreWebUserTransaction;
|
||||
import com.djrapitops.plan.utilities.PassEncryptUtil;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
@ -66,7 +66,7 @@ class Pkcs12HttpsServerTest implements HttpsServerTest {
|
||||
system.enable();
|
||||
|
||||
User user = new User("test", "console", null, PassEncryptUtil.createHash("testPass"), 0, Collections.emptyList());
|
||||
system.getDatabaseSystem().getDatabase().executeTransaction(new RegisterWebUserTransaction(user));
|
||||
system.getDatabaseSystem().getDatabase().executeTransaction(new StoreWebUserTransaction(user));
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
|
@ -30,7 +30,7 @@ import com.djrapitops.plan.storage.database.queries.objects.SessionQueries;
|
||||
import com.djrapitops.plan.storage.database.transactions.StoreServerInformationTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.commands.RemoveEverythingTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.PlayerRegisterTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.WorldNameStoreTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.StoreWorldNameTransaction;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@ -106,7 +106,7 @@ class ShutdownSaveTest {
|
||||
|
||||
database.executeTransaction(new StoreServerInformationTransaction(new Server(serverUUID, "-", "", TestConstants.VERSION)));
|
||||
database.executeTransaction(new PlayerRegisterTransaction(playerUUID, () -> 0L, TestConstants.PLAYER_ONE_NAME));
|
||||
database.executeTransaction(new WorldNameStoreTransaction(serverUUID, worldName))
|
||||
database.executeTransaction(new StoreWorldNameTransaction(serverUUID, worldName))
|
||||
.get();
|
||||
}
|
||||
|
||||
|
@ -37,8 +37,8 @@ import com.djrapitops.plan.storage.database.queries.objects.UserInfoQueries;
|
||||
import com.djrapitops.plan.storage.database.sql.tables.JoinAddressTable;
|
||||
import com.djrapitops.plan.storage.database.transactions.StoreServerInformationTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.commands.RemoveEverythingTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.PlayerServerRegisterTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.WorldNameStoreTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.StoreServerPlayerTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.StoreWorldNameTransaction;
|
||||
import extension.FullSystemExtension;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
@ -118,7 +118,7 @@ class PlayerLeaveEventConsumerTest {
|
||||
SessionCache sessionCache = system.getCacheSystem().getSessionCache();
|
||||
long sessionStart = System.currentTimeMillis();
|
||||
sessionCache.cacheSession(TestConstants.PLAYER_ONE_UUID, new ActiveSession(TestConstants.PLAYER_ONE_UUID, serverUUID, sessionStart, "World", GMTimes.SURVIVAL));
|
||||
database.executeTransaction(new WorldNameStoreTransaction(serverUUID, "World"));
|
||||
database.executeTransaction(new StoreWorldNameTransaction(serverUUID, "World"));
|
||||
|
||||
PlayerLeave leave = createPlayerLeave(createTestPlayer());
|
||||
|
||||
@ -206,7 +206,7 @@ class PlayerLeaveEventConsumerTest {
|
||||
}
|
||||
|
||||
private void registerPlayer(Database database, ServerUUID serverUUID) {
|
||||
database.executeTransaction(new PlayerServerRegisterTransaction(TestConstants.PLAYER_ONE_UUID, System::currentTimeMillis, TestConstants.PLAYER_ONE_NAME, serverUUID, () -> null))
|
||||
database.executeTransaction(new StoreServerPlayerTransaction(TestConstants.PLAYER_ONE_UUID, System::currentTimeMillis, TestConstants.PLAYER_ONE_NAME, serverUUID, () -> null))
|
||||
.join(); // Wait until complete
|
||||
}
|
||||
|
||||
|
@ -19,9 +19,9 @@ package com.djrapitops.plan.placeholder;
|
||||
import com.djrapitops.plan.PlanSystem;
|
||||
import com.djrapitops.plan.identification.ServerUUID;
|
||||
import com.djrapitops.plan.storage.database.Database;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.PlayerServerRegisterTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.StoreServerPlayerTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.StoreSessionTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.WorldNameStoreTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.StoreWorldNameTransaction;
|
||||
import org.junit.jupiter.api.*;
|
||||
import org.junit.jupiter.api.io.TempDir;
|
||||
import utilities.RandomData;
|
||||
@ -88,14 +88,14 @@ class PlanPlaceholdersTest {
|
||||
|
||||
private static void storeSomeData() {
|
||||
Database database = component.system().getDatabaseSystem().getDatabase();
|
||||
database.executeTransaction(new PlayerServerRegisterTransaction(
|
||||
database.executeTransaction(new StoreServerPlayerTransaction(
|
||||
playerUUID,
|
||||
System::currentTimeMillis,
|
||||
RandomData.randomString(5),
|
||||
serverUUID,
|
||||
() -> RandomData.randomString(5)
|
||||
));
|
||||
database.executeTransaction(new PlayerServerRegisterTransaction(
|
||||
database.executeTransaction(new StoreServerPlayerTransaction(
|
||||
TestConstants.PLAYER_TWO_UUID,
|
||||
System::currentTimeMillis,
|
||||
TestConstants.PLAYER_TWO_NAME,
|
||||
@ -103,7 +103,7 @@ class PlanPlaceholdersTest {
|
||||
() -> RandomData.randomString(5)
|
||||
));
|
||||
String worldName = RandomData.randomString(10);
|
||||
database.executeTransaction(new WorldNameStoreTransaction(serverUUID, worldName));
|
||||
database.executeTransaction(new StoreWorldNameTransaction(serverUUID, worldName));
|
||||
database.executeTransaction(new StoreSessionTransaction(RandomData.randomSession(serverUUID, new String[]{worldName}, playerUUID, TestConstants.PLAYER_TWO_UUID)));
|
||||
}
|
||||
|
||||
|
@ -78,7 +78,7 @@ import static org.junit.jupiter.api.Assertions.*;
|
||||
public interface DatabaseTest extends DatabaseTestPreparer {
|
||||
|
||||
default void saveUserOne() {
|
||||
db().executeTransaction(new PlayerServerRegisterTransaction(playerUUID, RandomData::randomTime,
|
||||
db().executeTransaction(new StoreServerPlayerTransaction(playerUUID, RandomData::randomTime,
|
||||
TestConstants.PLAYER_ONE_NAME, serverUUID(), TestConstants.GET_PLAYER_HOSTNAME));
|
||||
db().executeTransaction(new KickStoreTransaction(playerUUID));
|
||||
}
|
||||
@ -88,7 +88,7 @@ public interface DatabaseTest extends DatabaseTestPreparer {
|
||||
}
|
||||
|
||||
default void saveWorld(String worldName) {
|
||||
db().executeTransaction(new WorldNameStoreTransaction(serverUUID(), worldName));
|
||||
db().executeTransaction(new StoreWorldNameTransaction(serverUUID(), worldName));
|
||||
}
|
||||
|
||||
default void saveWorlds(String... worldNames) {
|
||||
@ -105,14 +105,14 @@ public interface DatabaseTest extends DatabaseTestPreparer {
|
||||
default void testRemovalSingleUser() {
|
||||
saveUserTwo();
|
||||
|
||||
db().executeTransaction(new PlayerServerRegisterTransaction(playerUUID, RandomData::randomTime,
|
||||
db().executeTransaction(new StoreServerPlayerTransaction(playerUUID, RandomData::randomTime,
|
||||
TestConstants.PLAYER_ONE_NAME, serverUUID(), TestConstants.GET_PLAYER_HOSTNAME));
|
||||
saveTwoWorlds();
|
||||
|
||||
FinishedSession session = RandomData.randomSession(serverUUID(), worlds, playerUUID, player2UUID);
|
||||
|
||||
db().executeTransaction(new StoreSessionTransaction(session));
|
||||
db().executeTransaction(new NicknameStoreTransaction(playerUUID, new Nickname("TestNick", RandomData.randomTime(), serverUUID()), (uuid, name) -> false /* Not cached */));
|
||||
db().executeTransaction(new StoreNicknameTransaction(playerUUID, new Nickname("TestNick", RandomData.randomTime(), serverUUID()), (uuid, name) -> false /* Not cached */));
|
||||
db().executeTransaction(new StoreGeoInfoTransaction(playerUUID, new GeoInfo("TestLoc", RandomData.randomTime())));
|
||||
|
||||
assertTrue(db().query(PlayerFetchQueries.isPlayerRegistered(playerUUID)));
|
||||
@ -165,7 +165,7 @@ public interface DatabaseTest extends DatabaseTestPreparer {
|
||||
saveTwoWorlds();
|
||||
FinishedSession session = RandomData.randomSession(serverUUID(), worlds, playerUUID, player2UUID);
|
||||
db().executeTransaction(new StoreSessionTransaction(session));
|
||||
db().executeTransaction(new NicknameStoreTransaction(playerUUID, RandomData.randomNickname(serverUUID()), (uuid, name) -> false /* Not cached */));
|
||||
db().executeTransaction(new StoreNicknameTransaction(playerUUID, RandomData.randomNickname(serverUUID()), (uuid, name) -> false /* Not cached */));
|
||||
saveGeoInfo(playerUUID, new GeoInfo("TestLoc", RandomData.randomTime()));
|
||||
assertTrue(db().query(PlayerFetchQueries.isPlayerRegistered(playerUUID)));
|
||||
db().executeTransaction(new PingStoreTransaction(playerUUID, serverUUID(), RandomData.randomIntDateObjects()));
|
||||
@ -299,7 +299,7 @@ public interface DatabaseTest extends DatabaseTestPreparer {
|
||||
@Test
|
||||
default void registerDateIsMinimized() {
|
||||
executeTransactions(
|
||||
new PlayerServerRegisterTransaction(playerUUID, () -> 1000,
|
||||
new StoreServerPlayerTransaction(playerUUID, () -> 1000,
|
||||
TestConstants.PLAYER_ONE_NAME, serverUUID(), TestConstants.GET_PLAYER_HOSTNAME)
|
||||
, new Transaction() {
|
||||
@Override
|
||||
@ -327,11 +327,11 @@ public interface DatabaseTest extends DatabaseTestPreparer {
|
||||
|
||||
@Test
|
||||
default void serverTablePlayersQueryQueriesAtLeastOnePlayer() {
|
||||
db().executeTransaction(new WorldNameStoreTransaction(serverUUID(), worlds[0]));
|
||||
db().executeTransaction(new WorldNameStoreTransaction(serverUUID(), worlds[1]));
|
||||
db().executeTransaction(new PlayerServerRegisterTransaction(playerUUID, RandomData::randomTime,
|
||||
db().executeTransaction(new StoreWorldNameTransaction(serverUUID(), worlds[0]));
|
||||
db().executeTransaction(new StoreWorldNameTransaction(serverUUID(), worlds[1]));
|
||||
db().executeTransaction(new StoreServerPlayerTransaction(playerUUID, RandomData::randomTime,
|
||||
TestConstants.PLAYER_ONE_NAME, serverUUID(), TestConstants.GET_PLAYER_HOSTNAME));
|
||||
db().executeTransaction(new PlayerServerRegisterTransaction(player2UUID, RandomData::randomTime,
|
||||
db().executeTransaction(new StoreServerPlayerTransaction(player2UUID, RandomData::randomTime,
|
||||
TestConstants.PLAYER_TWO_NAME, serverUUID(), TestConstants.GET_PLAYER_HOSTNAME));
|
||||
db().executeTransaction(new StoreSessionTransaction(RandomData.randomSession(serverUUID(), worlds, playerUUID, player2UUID)));
|
||||
|
||||
@ -342,11 +342,11 @@ public interface DatabaseTest extends DatabaseTestPreparer {
|
||||
|
||||
@Test
|
||||
default void networkTablePlayersQueryQueriesAtLeastOnePlayer() {
|
||||
db().executeTransaction(new WorldNameStoreTransaction(serverUUID(), worlds[0]));
|
||||
db().executeTransaction(new WorldNameStoreTransaction(serverUUID(), worlds[1]));
|
||||
db().executeTransaction(new PlayerServerRegisterTransaction(playerUUID, RandomData::randomTime,
|
||||
db().executeTransaction(new StoreWorldNameTransaction(serverUUID(), worlds[0]));
|
||||
db().executeTransaction(new StoreWorldNameTransaction(serverUUID(), worlds[1]));
|
||||
db().executeTransaction(new StoreServerPlayerTransaction(playerUUID, RandomData::randomTime,
|
||||
TestConstants.PLAYER_ONE_NAME, serverUUID(), TestConstants.GET_PLAYER_HOSTNAME));
|
||||
db().executeTransaction(new PlayerServerRegisterTransaction(player2UUID, RandomData::randomTime,
|
||||
db().executeTransaction(new StoreServerPlayerTransaction(player2UUID, RandomData::randomTime,
|
||||
TestConstants.PLAYER_TWO_NAME, serverUUID(), TestConstants.GET_PLAYER_HOSTNAME));
|
||||
db().executeTransaction(new StoreSessionTransaction(RandomData.randomSession(serverUUID(), worlds, playerUUID, player2UUID)));
|
||||
|
||||
@ -359,8 +359,8 @@ public interface DatabaseTest extends DatabaseTestPreparer {
|
||||
default void badFabricJoinAddressPatchRemovesJoinAddressesOfOneServer() throws ExecutionException, InterruptedException {
|
||||
ServerUUID randomSecondServer = ServerUUID.randomUUID();
|
||||
db().executeTransaction(new StoreServerInformationTransaction(new Server(randomSecondServer, "", "", ""))).get();
|
||||
db().executeTransaction(new WorldNameStoreTransaction(randomSecondServer, "World"));
|
||||
db().executeTransaction(new WorldNameStoreTransaction(serverUUID(), "World"));
|
||||
db().executeTransaction(new StoreWorldNameTransaction(randomSecondServer, "World"));
|
||||
db().executeTransaction(new StoreWorldNameTransaction(serverUUID(), "World"));
|
||||
|
||||
DataMap extraData1 = new DataMap();
|
||||
extraData1.put(JoinAddress.class, new JoinAddress("test1"));
|
||||
@ -405,8 +405,8 @@ public interface DatabaseTest extends DatabaseTestPreparer {
|
||||
db().executeTransaction(new StoreServerInformationTransaction(new Server(randomSecondServer, "", "", "")));
|
||||
|
||||
long time = System.currentTimeMillis();
|
||||
db().executeTransaction(new PlayerServerRegisterTransaction(playerUUID, () -> time, "", serverUUID(), () -> "test1"));
|
||||
db().executeTransaction(new PlayerServerRegisterTransaction(playerUUID, () -> time, "", randomSecondServer, () -> "test2"));
|
||||
db().executeTransaction(new StoreServerPlayerTransaction(playerUUID, () -> time, "", serverUUID(), () -> "test1"));
|
||||
db().executeTransaction(new StoreServerPlayerTransaction(playerUUID, () -> time, "", randomSecondServer, () -> "test2"));
|
||||
|
||||
db().executeTransaction(new BadFabricJoinAddressValuePatch(randomSecondServer));
|
||||
|
||||
|
@ -14,11 +14,14 @@
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.djrapitops.plan.storage.database.queries;
|
||||
package com.djrapitops.plan.storage.database;
|
||||
|
||||
import com.djrapitops.plan.storage.database.queries.*;
|
||||
import com.djrapitops.plan.storage.database.queries.analysis.TopListQueriesTest;
|
||||
import com.djrapitops.plan.storage.database.transactions.commands.ChangeUserUUIDTransactionTest;
|
||||
import com.djrapitops.plan.storage.database.transactions.commands.CombineUserTransactionTest;
|
||||
|
||||
public interface QueriesTestAggregate extends
|
||||
public interface DatabaseTestAggregate extends
|
||||
ActivityIndexQueriesTest,
|
||||
DatabaseBackupTest,
|
||||
ExtensionsDatabaseTest,
|
||||
@ -32,6 +35,8 @@ public interface QueriesTestAggregate extends
|
||||
UserInfoQueriesTest,
|
||||
WebUserQueriesTest,
|
||||
FilterQueryTest,
|
||||
JoinAddressQueriesTest {
|
||||
JoinAddressQueriesTest,
|
||||
ChangeUserUUIDTransactionTest,
|
||||
CombineUserTransactionTest {
|
||||
/* Collects all query tests together so its easier to implement database tests */
|
||||
}
|
@ -24,7 +24,6 @@ import com.djrapitops.plan.identification.ServerInfo;
|
||||
import com.djrapitops.plan.identification.ServerUUID;
|
||||
import com.djrapitops.plan.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.storage.database.queries.ExtensionsDatabaseTest;
|
||||
import com.djrapitops.plan.storage.database.queries.QueriesTestAggregate;
|
||||
import com.djrapitops.plan.storage.database.queries.filter.QueryFilters;
|
||||
import com.djrapitops.plan.storage.database.transactions.StoreServerInformationTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.commands.RemoveEverythingTransaction;
|
||||
@ -60,7 +59,7 @@ import static org.mockito.Mockito.when;
|
||||
* @see utilities.CIProperties for assumed MySQL setup.
|
||||
*/
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class MySQLTest implements DatabaseTest, QueriesTestAggregate {
|
||||
class MySQLTest implements DatabaseTest, DatabaseTestAggregate {
|
||||
|
||||
private static final int TEST_PORT_NUMBER = RandomData.randomInt(9005, 9500);
|
||||
|
||||
|
@ -24,7 +24,6 @@ import com.djrapitops.plan.identification.ServerInfo;
|
||||
import com.djrapitops.plan.identification.ServerUUID;
|
||||
import com.djrapitops.plan.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.storage.database.queries.ExtensionsDatabaseTest;
|
||||
import com.djrapitops.plan.storage.database.queries.QueriesTestAggregate;
|
||||
import com.djrapitops.plan.storage.database.queries.filter.QueryFilters;
|
||||
import com.djrapitops.plan.storage.database.transactions.StoreServerInformationTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.commands.RemoveEverythingTransaction;
|
||||
@ -55,7 +54,7 @@ import static org.mockito.Mockito.when;
|
||||
* @see ExtensionsDatabaseTest
|
||||
*/
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
public class SQLiteTest implements DatabaseTest, QueriesTestAggregate {
|
||||
public class SQLiteTest implements DatabaseTest, DatabaseTestAggregate {
|
||||
|
||||
private static final int TEST_PORT_NUMBER = RandomData.randomInt(9005, 9500);
|
||||
|
||||
|
@ -27,9 +27,9 @@ import com.djrapitops.plan.storage.database.queries.objects.playertable.NetworkT
|
||||
import com.djrapitops.plan.storage.database.queries.objects.playertable.ServerTablePlayersQuery;
|
||||
import com.djrapitops.plan.storage.database.sql.tables.SessionsTable;
|
||||
import com.djrapitops.plan.storage.database.sql.tables.UsersTable;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.PlayerServerRegisterTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.StoreServerPlayerTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.StoreSessionTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.WorldNameStoreTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.StoreWorldNameTransaction;
|
||||
import org.junit.jupiter.api.RepeatedTest;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import utilities.RandomData;
|
||||
@ -51,12 +51,12 @@ import static org.junit.jupiter.api.Assertions.*;
|
||||
public interface ActivityIndexQueriesTest extends DatabaseTestPreparer {
|
||||
|
||||
default void storeSessions(Predicate<FinishedSession> save) {
|
||||
db().executeTransaction(new PlayerServerRegisterTransaction(playerUUID, RandomData::randomTime,
|
||||
db().executeTransaction(new StoreServerPlayerTransaction(playerUUID, RandomData::randomTime,
|
||||
TestConstants.PLAYER_ONE_NAME, serverUUID(), TestConstants.GET_PLAYER_HOSTNAME));
|
||||
db().executeTransaction(new PlayerServerRegisterTransaction(player2UUID, RandomData::randomTime,
|
||||
db().executeTransaction(new StoreServerPlayerTransaction(player2UUID, RandomData::randomTime,
|
||||
TestConstants.PLAYER_TWO_NAME, serverUUID(), TestConstants.GET_PLAYER_HOSTNAME));
|
||||
for (String world : worlds) {
|
||||
db().executeTransaction(new WorldNameStoreTransaction(serverUUID(), world));
|
||||
db().executeTransaction(new StoreWorldNameTransaction(serverUUID(), world));
|
||||
}
|
||||
|
||||
for (FinishedSession session : RandomData.randomSessions(serverUUID(), worlds, playerUUID, player2UUID)) {
|
||||
|
@ -26,7 +26,7 @@ import com.djrapitops.plan.storage.database.DatabaseTestPreparer;
|
||||
import com.djrapitops.plan.storage.database.SQLiteDB;
|
||||
import com.djrapitops.plan.storage.database.queries.objects.*;
|
||||
import com.djrapitops.plan.storage.database.transactions.BackupCopyTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.commands.RegisterWebUserTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.commands.StoreWebUserTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.*;
|
||||
import com.djrapitops.plan.utilities.PassEncryptUtil;
|
||||
import com.google.common.util.concurrent.MoreExecutors;
|
||||
@ -44,18 +44,18 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
public interface DatabaseBackupTest extends DatabaseTestPreparer {
|
||||
|
||||
default void saveDataForBackup() {
|
||||
db().executeTransaction(new WorldNameStoreTransaction(serverUUID(), worlds[0]));
|
||||
db().executeTransaction(new WorldNameStoreTransaction(serverUUID(), worlds[1]));
|
||||
db().executeTransaction(new PlayerServerRegisterTransaction(playerUUID, RandomData::randomTime,
|
||||
db().executeTransaction(new StoreWorldNameTransaction(serverUUID(), worlds[0]));
|
||||
db().executeTransaction(new StoreWorldNameTransaction(serverUUID(), worlds[1]));
|
||||
db().executeTransaction(new StoreServerPlayerTransaction(playerUUID, RandomData::randomTime,
|
||||
TestConstants.PLAYER_ONE_NAME, serverUUID(), TestConstants.GET_PLAYER_HOSTNAME));
|
||||
db().executeTransaction(new PlayerServerRegisterTransaction(player2UUID, RandomData::randomTime,
|
||||
db().executeTransaction(new StoreServerPlayerTransaction(player2UUID, RandomData::randomTime,
|
||||
TestConstants.PLAYER_TWO_NAME, serverUUID(), TestConstants.GET_PLAYER_HOSTNAME));
|
||||
|
||||
FinishedSession session = RandomData.randomSession(serverUUID(), worlds, playerUUID, player2UUID);
|
||||
db().executeTransaction(new StoreSessionTransaction(session));
|
||||
|
||||
db().executeTransaction(
|
||||
new NicknameStoreTransaction(playerUUID, RandomData.randomNickname(serverUUID()), (uuid, name) -> false /* Not cached */)
|
||||
new StoreNicknameTransaction(playerUUID, RandomData.randomNickname(serverUUID()), (uuid, name) -> false /* Not cached */)
|
||||
);
|
||||
db().executeTransaction(new StoreGeoInfoTransaction(playerUUID, new GeoInfo("TestLoc", RandomData.randomTime())));
|
||||
|
||||
@ -70,7 +70,7 @@ public interface DatabaseBackupTest extends DatabaseTestPreparer {
|
||||
);
|
||||
|
||||
User user = new User("test", "console", null, PassEncryptUtil.createHash("testPass"), 0, Collections.emptyList());
|
||||
db().executeTransaction(new RegisterWebUserTransaction(user));
|
||||
db().executeTransaction(new StoreWebUserTransaction(user));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -39,7 +39,7 @@ import com.djrapitops.plan.storage.database.DatabaseTestPreparer;
|
||||
import com.djrapitops.plan.storage.database.transactions.commands.RemoveEverythingTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.PlayerRegisterTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.StoreSessionTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.WorldNameStoreTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.StoreWorldNameTransaction;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@ -117,8 +117,8 @@ public interface ExtensionsDatabaseTest extends DatabaseTestPreparer {
|
||||
@Test
|
||||
default void extensionPlayerValuesCanBeQueriedAsTableData() {
|
||||
extensionPlayerValuesAreStored();
|
||||
db().executeTransaction(new WorldNameStoreTransaction(serverUUID(), worlds[0]));
|
||||
db().executeTransaction(new WorldNameStoreTransaction(serverUUID(), worlds[1]));
|
||||
db().executeTransaction(new StoreWorldNameTransaction(serverUUID(), worlds[0]));
|
||||
db().executeTransaction(new StoreWorldNameTransaction(serverUUID(), worlds[1]));
|
||||
|
||||
// Store a session to check against issue https://github.com/plan-player-analytics/Plan/issues/1039
|
||||
ActiveSession session = new ActiveSession(playerUUID, serverUUID(), 32345L, worlds[0], "SURVIVAL");
|
||||
|
@ -28,8 +28,8 @@ import com.djrapitops.plan.storage.database.queries.objects.PingQueries;
|
||||
import com.djrapitops.plan.storage.database.transactions.commands.RemoveEverythingTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.PingStoreTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.PlayerRegisterTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.PlayerServerRegisterTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.StoreGeoInfoTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.StoreServerPlayerTransaction;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import utilities.RandomData;
|
||||
import utilities.TestConstants;
|
||||
@ -70,7 +70,7 @@ public interface GeolocationQueriesTest extends DatabaseTestPreparer {
|
||||
|
||||
@Test
|
||||
default void geoInformationIsStored() {
|
||||
db().executeTransaction(new PlayerServerRegisterTransaction(playerUUID, RandomData::randomTime,
|
||||
db().executeTransaction(new StoreServerPlayerTransaction(playerUUID, RandomData::randomTime,
|
||||
TestConstants.PLAYER_ONE_NAME, serverUUID(), TestConstants.GET_PLAYER_HOSTNAME));
|
||||
|
||||
List<GeoInfo> expected = RandomData.randomGeoInfo();
|
||||
@ -133,7 +133,7 @@ public interface GeolocationQueriesTest extends DatabaseTestPreparer {
|
||||
|
||||
Database db = db();
|
||||
for (UUID uuid : uuids) {
|
||||
db.executeTransaction(new PlayerServerRegisterTransaction(uuid, () -> 0L, "", serverUUID(),
|
||||
db.executeTransaction(new StoreServerPlayerTransaction(uuid, () -> 0L, "", serverUUID(),
|
||||
TestConstants.GET_PLAYER_HOSTNAME));
|
||||
}
|
||||
|
||||
@ -182,7 +182,7 @@ public interface GeolocationQueriesTest extends DatabaseTestPreparer {
|
||||
|
||||
@Test
|
||||
default void filterOptionGeolocationsAreUnique() {
|
||||
db().executeTransaction(new PlayerServerRegisterTransaction(playerUUID, RandomData::randomTime,
|
||||
db().executeTransaction(new StoreServerPlayerTransaction(playerUUID, RandomData::randomTime,
|
||||
TestConstants.PLAYER_ONE_NAME, serverUUID(), TestConstants.GET_PLAYER_HOSTNAME));
|
||||
|
||||
List<GeoInfo> savedData = RandomData.randomGeoInfo();
|
||||
@ -198,7 +198,7 @@ public interface GeolocationQueriesTest extends DatabaseTestPreparer {
|
||||
|
||||
@Test
|
||||
default void geolocationFilterResultsGetThePlayer() {
|
||||
db().executeTransaction(new PlayerServerRegisterTransaction(playerUUID, RandomData::randomTime,
|
||||
db().executeTransaction(new StoreServerPlayerTransaction(playerUUID, RandomData::randomTime,
|
||||
TestConstants.PLAYER_ONE_NAME, serverUUID(), TestConstants.GET_PLAYER_HOSTNAME));
|
||||
|
||||
List<GeoInfo> savedData = RandomData.randomGeoInfo();
|
||||
|
@ -26,7 +26,7 @@ import com.djrapitops.plan.storage.database.transactions.commands.RemoveEverythi
|
||||
import com.djrapitops.plan.storage.database.transactions.events.PlayerRegisterTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.StoreJoinAddressTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.StoreSessionTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.WorldNameStoreTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.StoreWorldNameTransaction;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import utilities.RandomData;
|
||||
import utilities.TestConstants;
|
||||
@ -63,8 +63,8 @@ public interface JoinAddressQueriesTest extends DatabaseTestPreparer {
|
||||
|
||||
@Test
|
||||
default void joinAddressCanBeUnknown() {
|
||||
db().executeTransaction(new WorldNameStoreTransaction(serverUUID(), worlds[0]));
|
||||
db().executeTransaction(new WorldNameStoreTransaction(serverUUID(), worlds[1]));
|
||||
db().executeTransaction(new StoreWorldNameTransaction(serverUUID(), worlds[0]));
|
||||
db().executeTransaction(new StoreWorldNameTransaction(serverUUID(), worlds[1]));
|
||||
db().executeTransaction(new PlayerRegisterTransaction(playerUUID, System::currentTimeMillis, TestConstants.PLAYER_ONE_NAME));
|
||||
|
||||
FinishedSession session = RandomData.randomSession(serverUUID(), worlds, playerUUID, player2UUID);
|
||||
@ -103,8 +103,8 @@ public interface JoinAddressQueriesTest extends DatabaseTestPreparer {
|
||||
|
||||
db().executeTransaction(TestData.storeServers());
|
||||
|
||||
db().executeTransaction(new WorldNameStoreTransaction(TestConstants.SERVER_TWO_UUID, worlds[0]));
|
||||
db().executeTransaction(new WorldNameStoreTransaction(TestConstants.SERVER_TWO_UUID, worlds[1]));
|
||||
db().executeTransaction(new StoreWorldNameTransaction(TestConstants.SERVER_TWO_UUID, worlds[0]));
|
||||
db().executeTransaction(new StoreWorldNameTransaction(TestConstants.SERVER_TWO_UUID, worlds[1]));
|
||||
FinishedSession session = RandomData.randomSession(TestConstants.SERVER_TWO_UUID, worlds, playerUUID, player2UUID);
|
||||
String expectedAddress = TestConstants.GET_PLAYER_HOSTNAME.get();
|
||||
session.getExtraData().put(JoinAddress.class, new JoinAddress(expectedAddress));
|
||||
|
@ -21,9 +21,9 @@ import com.djrapitops.plan.storage.database.DatabaseTestPreparer;
|
||||
import com.djrapitops.plan.storage.database.queries.objects.NicknameQueries;
|
||||
import com.djrapitops.plan.storage.database.queries.objects.UserIdentifierQueries;
|
||||
import com.djrapitops.plan.storage.database.transactions.commands.RemoveEverythingTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.NicknameStoreTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.PlayerRegisterTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.PlayerServerRegisterTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.StoreNicknameTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.StoreServerPlayerTransaction;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import utilities.RandomData;
|
||||
import utilities.TestConstants;
|
||||
@ -37,13 +37,13 @@ public interface NicknameQueriesTest extends DatabaseTestPreparer {
|
||||
|
||||
@Test
|
||||
default void allNicknamesAreSaved() {
|
||||
db().executeTransaction(new PlayerServerRegisterTransaction(playerUUID, RandomData::randomTime,
|
||||
db().executeTransaction(new StoreServerPlayerTransaction(playerUUID, RandomData::randomTime,
|
||||
TestConstants.PLAYER_ONE_NAME, serverUUID(), TestConstants.GET_PLAYER_HOSTNAME));
|
||||
|
||||
List<Nickname> saved = RandomData.randomNicknames(serverUUID());
|
||||
for (Nickname nickname : saved) {
|
||||
db().executeTransaction(new NicknameStoreTransaction(playerUUID, nickname, (uuid, name) -> false /* Not cached */));
|
||||
db().executeTransaction(new NicknameStoreTransaction(playerUUID, nickname, (uuid, name) -> true /* Cached */));
|
||||
db().executeTransaction(new StoreNicknameTransaction(playerUUID, nickname, (uuid, name) -> false /* Not cached */));
|
||||
db().executeTransaction(new StoreNicknameTransaction(playerUUID, nickname, (uuid, name) -> true /* Cached */));
|
||||
}
|
||||
|
||||
forcePersistenceCheck();
|
||||
@ -61,8 +61,8 @@ public interface NicknameQueriesTest extends DatabaseTestPreparer {
|
||||
db().executeTransaction(new PlayerRegisterTransaction(playerUUID, () -> 1L, "Not random"));
|
||||
|
||||
String nickname = "2" + RandomData.randomString(10);
|
||||
db().executeTransaction(new NicknameStoreTransaction(uuid, new Nickname(nickname, System.currentTimeMillis(), serverUUID()), (u, name) -> false /* Not cached */));
|
||||
db().executeTransaction(new NicknameStoreTransaction(playerUUID, new Nickname("No nick", System.currentTimeMillis(), serverUUID()), (u, name) -> true /* Cached */));
|
||||
db().executeTransaction(new StoreNicknameTransaction(uuid, new Nickname(nickname, System.currentTimeMillis(), serverUUID()), (u, name) -> false /* Not cached */));
|
||||
db().executeTransaction(new StoreNicknameTransaction(playerUUID, new Nickname("No nick", System.currentTimeMillis(), serverUUID()), (u, name) -> true /* Cached */));
|
||||
|
||||
String searchFor = "2";
|
||||
|
||||
|
@ -25,7 +25,7 @@ import com.djrapitops.plan.storage.database.queries.objects.PingQueries;
|
||||
import com.djrapitops.plan.storage.database.transactions.commands.RemoveEverythingTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.PingStoreTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.PlayerRegisterTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.PlayerServerRegisterTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.StoreServerPlayerTransaction;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import utilities.RandomData;
|
||||
import utilities.TestConstants;
|
||||
@ -38,7 +38,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
public interface PingQueriesTest extends DatabaseTestPreparer {
|
||||
|
||||
private void prepareForPingStorage() {
|
||||
db().executeTransaction(new PlayerServerRegisterTransaction(playerUUID, RandomData::randomTime,
|
||||
db().executeTransaction(new StoreServerPlayerTransaction(playerUUID, RandomData::randomTime,
|
||||
TestConstants.PLAYER_ONE_NAME, serverUUID(), TestConstants.GET_PLAYER_HOSTNAME));
|
||||
}
|
||||
|
||||
|
@ -52,9 +52,9 @@ public interface SessionQueriesTest extends DatabaseTestPreparer {
|
||||
|
||||
@Test
|
||||
default void sessionStoreTransactionOutOfOrderDoesNotFailDueToMissingMainUser() {
|
||||
db().executeTransaction(new WorldNameStoreTransaction(serverUUID(), worlds[0]));
|
||||
db().executeTransaction(new WorldNameStoreTransaction(serverUUID(), worlds[1]));
|
||||
db().executeTransaction(new PlayerServerRegisterTransaction(player2UUID, RandomData::randomTime,
|
||||
db().executeTransaction(new StoreWorldNameTransaction(serverUUID(), worlds[0]));
|
||||
db().executeTransaction(new StoreWorldNameTransaction(serverUUID(), worlds[1]));
|
||||
db().executeTransaction(new StoreServerPlayerTransaction(player2UUID, RandomData::randomTime,
|
||||
TestConstants.PLAYER_TWO_NAME, serverUUID(), TestConstants.GET_PLAYER_HOSTNAME));
|
||||
|
||||
FinishedSession session = RandomData.randomSession(serverUUID(), worlds, playerUUID, player2UUID);
|
||||
@ -72,9 +72,9 @@ public interface SessionQueriesTest extends DatabaseTestPreparer {
|
||||
|
||||
@Test
|
||||
default void sessionStoreTransactionOutOfOrderDoesNotFailDueToMissingKilledUser() {
|
||||
db().executeTransaction(new WorldNameStoreTransaction(serverUUID(), worlds[0]));
|
||||
db().executeTransaction(new WorldNameStoreTransaction(serverUUID(), worlds[1]));
|
||||
db().executeTransaction(new PlayerServerRegisterTransaction(playerUUID, RandomData::randomTime,
|
||||
db().executeTransaction(new StoreWorldNameTransaction(serverUUID(), worlds[0]));
|
||||
db().executeTransaction(new StoreWorldNameTransaction(serverUUID(), worlds[1]));
|
||||
db().executeTransaction(new StoreServerPlayerTransaction(playerUUID, RandomData::randomTime,
|
||||
TestConstants.PLAYER_ONE_NAME, serverUUID(), TestConstants.GET_PLAYER_HOSTNAME));
|
||||
|
||||
FinishedSession session = RandomData.randomSession(serverUUID(), worlds, playerUUID, player2UUID);
|
||||
@ -96,9 +96,9 @@ public interface SessionQueriesTest extends DatabaseTestPreparer {
|
||||
|
||||
@Test
|
||||
default void shutdownDataPreservationTransactionOutOfOrderDoesNotFailDueToMissingMainUser() {
|
||||
db().executeTransaction(new WorldNameStoreTransaction(serverUUID(), worlds[0]));
|
||||
db().executeTransaction(new WorldNameStoreTransaction(serverUUID(), worlds[1]));
|
||||
db().executeTransaction(new PlayerServerRegisterTransaction(player2UUID, RandomData::randomTime,
|
||||
db().executeTransaction(new StoreWorldNameTransaction(serverUUID(), worlds[0]));
|
||||
db().executeTransaction(new StoreWorldNameTransaction(serverUUID(), worlds[1]));
|
||||
db().executeTransaction(new StoreServerPlayerTransaction(player2UUID, RandomData::randomTime,
|
||||
TestConstants.PLAYER_TWO_NAME, serverUUID(), TestConstants.GET_PLAYER_HOSTNAME));
|
||||
|
||||
FinishedSession session = RandomData.randomSession(serverUUID(), worlds, playerUUID, player2UUID);
|
||||
@ -116,9 +116,9 @@ public interface SessionQueriesTest extends DatabaseTestPreparer {
|
||||
|
||||
@Test
|
||||
default void shutdownDataPreservationTransactionOutOfOrderDoesNotFailDueToMissingKilledUser() {
|
||||
db().executeTransaction(new WorldNameStoreTransaction(serverUUID(), worlds[0]));
|
||||
db().executeTransaction(new WorldNameStoreTransaction(serverUUID(), worlds[1]));
|
||||
db().executeTransaction(new PlayerServerRegisterTransaction(playerUUID, RandomData::randomTime,
|
||||
db().executeTransaction(new StoreWorldNameTransaction(serverUUID(), worlds[0]));
|
||||
db().executeTransaction(new StoreWorldNameTransaction(serverUUID(), worlds[1]));
|
||||
db().executeTransaction(new StoreServerPlayerTransaction(playerUUID, RandomData::randomTime,
|
||||
TestConstants.PLAYER_ONE_NAME, serverUUID(), TestConstants.GET_PLAYER_HOSTNAME));
|
||||
|
||||
FinishedSession session = RandomData.randomSession(serverUUID(), worlds, playerUUID, player2UUID);
|
||||
@ -135,14 +135,14 @@ public interface SessionQueriesTest extends DatabaseTestPreparer {
|
||||
|
||||
@Test
|
||||
default void killsAreAvailableAfter2ndUserRegisterEvenIfOutOfOrder() {
|
||||
db().executeTransaction(new WorldNameStoreTransaction(serverUUID(), worlds[0]));
|
||||
db().executeTransaction(new WorldNameStoreTransaction(serverUUID(), worlds[1]));
|
||||
db().executeTransaction(new PlayerServerRegisterTransaction(playerUUID, RandomData::randomTime,
|
||||
db().executeTransaction(new StoreWorldNameTransaction(serverUUID(), worlds[0]));
|
||||
db().executeTransaction(new StoreWorldNameTransaction(serverUUID(), worlds[1]));
|
||||
db().executeTransaction(new StoreServerPlayerTransaction(playerUUID, RandomData::randomTime,
|
||||
TestConstants.PLAYER_ONE_NAME, serverUUID(), TestConstants.GET_PLAYER_HOSTNAME));
|
||||
FinishedSession session = RandomData.randomSession(serverUUID(), worlds, playerUUID, player2UUID);
|
||||
db().executeTransaction(new StoreSessionTransaction(session));
|
||||
// killed user is registered after session already ended.
|
||||
db().executeTransaction(new PlayerServerRegisterTransaction(player2UUID, RandomData::randomTime,
|
||||
db().executeTransaction(new StoreServerPlayerTransaction(player2UUID, RandomData::randomTime,
|
||||
TestConstants.PLAYER_TWO_NAME, serverUUID(), TestConstants.GET_PLAYER_HOSTNAME));
|
||||
|
||||
Map<ServerUUID, List<FinishedSession>> sessions = db().query(SessionQueries.fetchSessionsOfPlayer(playerUUID));
|
||||
@ -156,8 +156,8 @@ public interface SessionQueriesTest extends DatabaseTestPreparer {
|
||||
|
||||
@Test
|
||||
default void sessionStoreTransactionOutOfOrderUpdatesUserInformation() {
|
||||
db().executeTransaction(new WorldNameStoreTransaction(serverUUID(), worlds[0]));
|
||||
db().executeTransaction(new WorldNameStoreTransaction(serverUUID(), worlds[1]));
|
||||
db().executeTransaction(new StoreWorldNameTransaction(serverUUID(), worlds[0]));
|
||||
db().executeTransaction(new StoreWorldNameTransaction(serverUUID(), worlds[1]));
|
||||
FinishedSession session = RandomData.randomSession(serverUUID(), worlds, playerUUID, player2UUID);
|
||||
db().executeTransaction(new StoreSessionTransaction(session));
|
||||
|
||||
@ -194,11 +194,11 @@ public interface SessionQueriesTest extends DatabaseTestPreparer {
|
||||
}
|
||||
|
||||
default void prepareForSessionSave() {
|
||||
db().executeTransaction(new WorldNameStoreTransaction(serverUUID(), worlds[0]));
|
||||
db().executeTransaction(new WorldNameStoreTransaction(serverUUID(), worlds[1]));
|
||||
db().executeTransaction(new PlayerServerRegisterTransaction(playerUUID, RandomData::randomTime,
|
||||
db().executeTransaction(new StoreWorldNameTransaction(serverUUID(), worlds[0]));
|
||||
db().executeTransaction(new StoreWorldNameTransaction(serverUUID(), worlds[1]));
|
||||
db().executeTransaction(new StoreServerPlayerTransaction(playerUUID, RandomData::randomTime,
|
||||
TestConstants.PLAYER_ONE_NAME, serverUUID(), TestConstants.GET_PLAYER_HOSTNAME));
|
||||
db().executeTransaction(new PlayerServerRegisterTransaction(player2UUID, RandomData::randomTime,
|
||||
db().executeTransaction(new StoreServerPlayerTransaction(player2UUID, RandomData::randomTime,
|
||||
TestConstants.PLAYER_TWO_NAME, serverUUID(), TestConstants.GET_PLAYER_HOSTNAME));
|
||||
}
|
||||
|
||||
@ -399,7 +399,7 @@ public interface SessionQueriesTest extends DatabaseTestPreparer {
|
||||
default void worldNamesAreStored() {
|
||||
String[] expected = {"Test", "Test2", "Test3"};
|
||||
for (String worldName : expected) {
|
||||
db().executeTransaction(new WorldNameStoreTransaction(serverUUID(), worldName));
|
||||
db().executeTransaction(new StoreWorldNameTransaction(serverUUID(), worldName));
|
||||
}
|
||||
|
||||
forcePersistenceCheck();
|
||||
@ -473,8 +473,8 @@ public interface SessionQueriesTest extends DatabaseTestPreparer {
|
||||
|
||||
ServerUUID serverTwoUuid = TestConstants.SERVER_TWO_UUID;
|
||||
executeTransactions(new StoreServerInformationTransaction(new Server(serverTwoUuid, TestConstants.SERVER_TWO_NAME, "", TestConstants.VERSION)));
|
||||
db().executeTransaction(new WorldNameStoreTransaction(serverTwoUuid, worlds[0]));
|
||||
db().executeTransaction(new WorldNameStoreTransaction(serverTwoUuid, worlds[1]));
|
||||
db().executeTransaction(new StoreWorldNameTransaction(serverTwoUuid, worlds[0]));
|
||||
db().executeTransaction(new StoreWorldNameTransaction(serverTwoUuid, worlds[1]));
|
||||
List<FinishedSession> server2Sessions = RandomData.randomSessions(serverTwoUuid, worlds, playerUUID, player2UUID);
|
||||
server2Sessions.forEach(session -> db().executeTransaction(new StoreSessionTransaction(session)));
|
||||
|
||||
|
@ -41,7 +41,7 @@ public interface UserInfoQueriesTest extends DatabaseTestPreparer {
|
||||
@Test
|
||||
default void userInfoTableStoresCorrectUserInformation() {
|
||||
assertFalse(db().query(BaseUserQueries.fetchBaseUserOfPlayer(playerUUID)).isPresent());
|
||||
db().executeTransaction(new PlayerServerRegisterTransaction(playerUUID, () -> TestConstants.REGISTER_TIME, TestConstants.PLAYER_ONE_NAME, serverUUID(), TestConstants.GET_PLAYER_HOSTNAME));
|
||||
db().executeTransaction(new StoreServerPlayerTransaction(playerUUID, () -> TestConstants.REGISTER_TIME, TestConstants.PLAYER_ONE_NAME, serverUUID(), TestConstants.GET_PLAYER_HOSTNAME));
|
||||
|
||||
Set<UserInfo> userInfo = db().query(UserInfoQueries.fetchUserInformationOfUser(playerUUID));
|
||||
Set<UserInfo> expected = Collections.singleton(new UserInfo(playerUUID, serverUUID(), TestConstants.REGISTER_TIME, false, TestConstants.GET_PLAYER_HOSTNAME.get(), false));
|
||||
@ -52,7 +52,7 @@ public interface UserInfoQueriesTest extends DatabaseTestPreparer {
|
||||
|
||||
@Test
|
||||
default void userInfoTableUpdatesBanStatus() {
|
||||
db().executeTransaction(new PlayerServerRegisterTransaction(playerUUID, () -> TestConstants.REGISTER_TIME,
|
||||
db().executeTransaction(new StoreServerPlayerTransaction(playerUUID, () -> TestConstants.REGISTER_TIME,
|
||||
TestConstants.PLAYER_ONE_NAME, serverUUID(), TestConstants.GET_PLAYER_HOSTNAME));
|
||||
|
||||
db().executeTransaction(new BanStatusTransaction(playerUUID, serverUUID(), () -> true));
|
||||
@ -65,7 +65,7 @@ public interface UserInfoQueriesTest extends DatabaseTestPreparer {
|
||||
|
||||
@Test
|
||||
default void userInfoTableUpdatesOperatorStatus() {
|
||||
db().executeTransaction(new PlayerServerRegisterTransaction(playerUUID, () -> TestConstants.REGISTER_TIME,
|
||||
db().executeTransaction(new StoreServerPlayerTransaction(playerUUID, () -> TestConstants.REGISTER_TIME,
|
||||
TestConstants.PLAYER_ONE_NAME, serverUUID(), TestConstants.GET_PLAYER_HOSTNAME));
|
||||
|
||||
db().executeTransaction(new OperatorStatusTransaction(playerUUID, serverUUID(), true));
|
||||
@ -78,7 +78,7 @@ public interface UserInfoQueriesTest extends DatabaseTestPreparer {
|
||||
|
||||
@Test
|
||||
default void playerNameIsUpdatedWhenPlayerLogsIn() {
|
||||
db().executeTransaction(new PlayerServerRegisterTransaction(playerUUID, () -> TestConstants.REGISTER_TIME,
|
||||
db().executeTransaction(new StoreServerPlayerTransaction(playerUUID, () -> TestConstants.REGISTER_TIME,
|
||||
TestConstants.PLAYER_ONE_NAME, serverUUID(), TestConstants.GET_PLAYER_HOSTNAME));
|
||||
|
||||
OptionalAssert.equals(playerUUID, db().query(UserIdentifierQueries.fetchPlayerUUIDOf(TestConstants.PLAYER_ONE_NAME)));
|
||||
@ -137,7 +137,7 @@ public interface UserInfoQueriesTest extends DatabaseTestPreparer {
|
||||
default void playerIsRegisteredToBothTables() {
|
||||
assertFalse(db().query(PlayerFetchQueries.isPlayerRegistered(playerUUID)));
|
||||
assertFalse(db().query(PlayerFetchQueries.isPlayerRegisteredOnServer(playerUUID, serverUUID())));
|
||||
db().executeTransaction(new PlayerServerRegisterTransaction(playerUUID, () -> TestConstants.REGISTER_TIME,
|
||||
db().executeTransaction(new StoreServerPlayerTransaction(playerUUID, () -> TestConstants.REGISTER_TIME,
|
||||
TestConstants.PLAYER_ONE_NAME, serverUUID(), TestConstants.GET_PLAYER_HOSTNAME));
|
||||
assertTrue(db().query(PlayerFetchQueries.isPlayerRegistered(playerUUID)));
|
||||
assertTrue(db().query(PlayerFetchQueries.isPlayerRegisteredOnServer(playerUUID, serverUUID())));
|
||||
|
@ -24,9 +24,9 @@ import com.djrapitops.plan.processing.Processing;
|
||||
import com.djrapitops.plan.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.storage.database.DatabaseTestPreparer;
|
||||
import com.djrapitops.plan.storage.database.queries.objects.WebUserQueries;
|
||||
import com.djrapitops.plan.storage.database.transactions.commands.RegisterWebUserTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.commands.RemoveEverythingTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.commands.RemoveWebUserTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.commands.StoreWebUserTransaction;
|
||||
import com.djrapitops.plan.utilities.PassEncryptUtil;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.Mockito;
|
||||
@ -46,7 +46,7 @@ public interface WebUserQueriesTest extends DatabaseTestPreparer {
|
||||
@Test
|
||||
default void userIsRegistered() {
|
||||
User expected = new User(WEB_USERNAME, "console", null, PassEncryptUtil.createHash("testPass"), 0, WebUser.getPermissionsForLevel(0));
|
||||
db().executeTransaction(new RegisterWebUserTransaction(expected));
|
||||
db().executeTransaction(new StoreWebUserTransaction(expected));
|
||||
forcePersistenceCheck();
|
||||
|
||||
Optional<User> found = db().query(WebUserQueries.fetchUser(WEB_USERNAME));
|
||||
|
@ -18,9 +18,9 @@ package com.djrapitops.plan.storage.database.queries.analysis;
|
||||
|
||||
import com.djrapitops.plan.gathering.domain.FinishedSession;
|
||||
import com.djrapitops.plan.storage.database.DatabaseTestPreparer;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.PlayerServerRegisterTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.StoreServerPlayerTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.StoreSessionTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.WorldNameStoreTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.StoreWorldNameTransaction;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import utilities.RandomData;
|
||||
import utilities.TestConstants;
|
||||
@ -30,11 +30,11 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
public interface TopListQueriesTest extends DatabaseTestPreparer {
|
||||
|
||||
private void storeSessionForTopListQueries() {
|
||||
db().executeTransaction(new WorldNameStoreTransaction(serverUUID(), worlds[0]));
|
||||
db().executeTransaction(new WorldNameStoreTransaction(serverUUID(), worlds[1]));
|
||||
db().executeTransaction(new PlayerServerRegisterTransaction(playerUUID, RandomData::randomTime,
|
||||
db().executeTransaction(new StoreWorldNameTransaction(serverUUID(), worlds[0]));
|
||||
db().executeTransaction(new StoreWorldNameTransaction(serverUUID(), worlds[1]));
|
||||
db().executeTransaction(new StoreServerPlayerTransaction(playerUUID, RandomData::randomTime,
|
||||
TestConstants.PLAYER_ONE_NAME, serverUUID(), TestConstants.GET_PLAYER_HOSTNAME));
|
||||
db().executeTransaction(new PlayerServerRegisterTransaction(player2UUID, RandomData::randomTime,
|
||||
db().executeTransaction(new StoreServerPlayerTransaction(player2UUID, RandomData::randomTime,
|
||||
TestConstants.PLAYER_TWO_NAME, serverUUID(), TestConstants.GET_PLAYER_HOSTNAME));
|
||||
FinishedSession session = RandomData.randomSession(serverUUID(), worlds, playerUUID, player2UUID);
|
||||
db().executeTransaction(new StoreSessionTransaction(session));
|
||||
|
@ -0,0 +1,100 @@
|
||||
/*
|
||||
* This file is part of Player Analytics (Plan).
|
||||
*
|
||||
* Plan is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License v3 as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Plan is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.djrapitops.plan.storage.database.transactions.commands;
|
||||
|
||||
import com.djrapitops.plan.delivery.domain.Nickname;
|
||||
import com.djrapitops.plan.delivery.domain.ServerIdentifier;
|
||||
import com.djrapitops.plan.gathering.domain.*;
|
||||
import com.djrapitops.plan.storage.database.Database;
|
||||
import com.djrapitops.plan.storage.database.DatabaseTestPreparer;
|
||||
import com.djrapitops.plan.storage.database.queries.objects.BaseUserQueries;
|
||||
import com.djrapitops.plan.storage.database.queries.objects.KillQueries;
|
||||
import com.djrapitops.plan.storage.database.queries.objects.NicknameQueries;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.StoreNicknameTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.StoreServerPlayerTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.StoreSessionTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.StoreWorldNameTransaction;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import utilities.TestConstants;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
/**
|
||||
* @author AuroraLS3
|
||||
*/
|
||||
public interface ChangeUserUUIDTransactionTest extends DatabaseTestPreparer {
|
||||
|
||||
@Test
|
||||
default void uuidChangeMovesUserData() {
|
||||
UUID oldUUID = UUID.randomUUID();
|
||||
UUID newUUID = UUID.randomUUID();
|
||||
UUID player2UUID = TestConstants.PLAYER_TWO_UUID;
|
||||
|
||||
Nickname nickname = new Nickname(TestConstants.PLAYER_ONE_NAME, System.currentTimeMillis(), serverUUID());
|
||||
|
||||
DataMap extraData1 = new DataMap();
|
||||
extraData1.put(WorldTimes.class, new WorldTimes(Map.of(TestConstants.WORLD_ONE_NAME, new GMTimes(Map.of(GMTimes.SURVIVAL, 200L)))));
|
||||
extraData1.put(PlayerKills.class, new PlayerKills(new ArrayList<>(List.of(new PlayerKill(new PlayerKill.Killer(oldUUID, TestConstants.PLAYER_ONE_NAME), new PlayerKill.Victim(player2UUID, TestConstants.PLAYER_TWO_NAME), new ServerIdentifier(serverUUID(), TestConstants.SERVER_NAME), TestConstants.WEAPON_SWORD, System.currentTimeMillis())))));
|
||||
FinishedSession player1Session = new FinishedSession(oldUUID, serverUUID(), System.currentTimeMillis(), System.currentTimeMillis(), 0L, extraData1);
|
||||
|
||||
DataMap extraData2 = new DataMap();
|
||||
extraData2.put(WorldTimes.class, new WorldTimes(Map.of(TestConstants.WORLD_ONE_NAME, new GMTimes(Map.of(GMTimes.SURVIVAL, 200L)))));
|
||||
extraData2.put(PlayerKills.class, new PlayerKills(new ArrayList<>(List.of(new PlayerKill(new PlayerKill.Killer(player2UUID, TestConstants.PLAYER_ONE_NAME), new PlayerKill.Victim(oldUUID, TestConstants.PLAYER_TWO_NAME), new ServerIdentifier(serverUUID(), TestConstants.SERVER_NAME), TestConstants.WEAPON_SWORD, System.currentTimeMillis())))));
|
||||
FinishedSession player2Session = new FinishedSession(player2UUID, serverUUID(), System.currentTimeMillis(), System.currentTimeMillis(), 0L, extraData2);
|
||||
|
||||
Database db = db();
|
||||
db.executeTransaction(new StoreWorldNameTransaction(serverUUID(), TestConstants.WORLD_ONE_NAME));
|
||||
db.executeTransaction(new StoreServerPlayerTransaction(player2UUID, System::currentTimeMillis, TestConstants.PLAYER_TWO_NAME, serverUUID(), TestConstants.GET_PLAYER_HOSTNAME));
|
||||
db.executeTransaction(new StoreServerPlayerTransaction(oldUUID, System::currentTimeMillis, TestConstants.PLAYER_ONE_NAME, serverUUID(), TestConstants.GET_PLAYER_HOSTNAME));
|
||||
db.executeTransaction(new StoreNicknameTransaction(oldUUID, nickname, (uuid, name) -> false));
|
||||
db.executeTransaction(new StoreSessionTransaction(player1Session));
|
||||
db.executeTransaction(new StoreSessionTransaction(player2Session));
|
||||
|
||||
// Assert data was stored with the old UUID
|
||||
List<Nickname> expectedNicknames = List.of(nickname);
|
||||
List<Nickname> nicknames = db.query(NicknameQueries.fetchNicknameDataOfPlayer(oldUUID));
|
||||
assertEquals(expectedNicknames, nicknames);
|
||||
assertEquals(1, db.query(KillQueries.fetchPlayerKillsOfPlayer(oldUUID)).size());
|
||||
assertEquals(1, db.query(KillQueries.fetchPlayerDeathsOfPlayer(oldUUID)).size());
|
||||
assertTrue(db.query(BaseUserQueries.fetchUserId(oldUUID)).isPresent());
|
||||
|
||||
|
||||
db.executeTransaction(new ChangeUserUUIDTransaction(oldUUID, newUUID));
|
||||
|
||||
|
||||
// Assert data exists with the new UUID
|
||||
expectedNicknames = List.of(nickname);
|
||||
nicknames = db.query(NicknameQueries.fetchNicknameDataOfPlayer(newUUID));
|
||||
assertEquals(expectedNicknames, nicknames);
|
||||
assertEquals(1, db.query(KillQueries.fetchPlayerKillsOfPlayer(newUUID)).size());
|
||||
assertEquals(1, db.query(KillQueries.fetchPlayerDeathsOfPlayer(newUUID)).size());
|
||||
assertTrue(db.query(BaseUserQueries.fetchUserId(newUUID)).isPresent());
|
||||
|
||||
// Assert data doesn't exist with the old UUID
|
||||
assertTrue(db.query(NicknameQueries.fetchNicknameDataOfPlayer(oldUUID)).isEmpty());
|
||||
assertTrue(db.query(KillQueries.fetchPlayerKillsOfPlayer(oldUUID)).isEmpty());
|
||||
assertTrue(db.query(KillQueries.fetchPlayerDeathsOfPlayer(oldUUID)).isEmpty());
|
||||
assertTrue(db.query(BaseUserQueries.fetchUserId(oldUUID)).isEmpty());
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,93 @@
|
||||
/*
|
||||
* This file is part of Player Analytics (Plan).
|
||||
*
|
||||
* Plan is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License v3 as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Plan is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.djrapitops.plan.storage.database.transactions.commands;
|
||||
|
||||
import com.djrapitops.plan.delivery.domain.ServerIdentifier;
|
||||
import com.djrapitops.plan.gathering.domain.*;
|
||||
import com.djrapitops.plan.identification.Server;
|
||||
import com.djrapitops.plan.identification.ServerUUID;
|
||||
import com.djrapitops.plan.storage.database.Database;
|
||||
import com.djrapitops.plan.storage.database.DatabaseTestPreparer;
|
||||
import com.djrapitops.plan.storage.database.queries.objects.BaseUserQueries;
|
||||
import com.djrapitops.plan.storage.database.queries.objects.KillQueries;
|
||||
import com.djrapitops.plan.storage.database.queries.objects.SessionQueries;
|
||||
import com.djrapitops.plan.storage.database.queries.objects.UserInfoQueries;
|
||||
import com.djrapitops.plan.storage.database.transactions.StoreServerInformationTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.StoreServerPlayerTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.StoreSessionTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.StoreWorldNameTransaction;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import utilities.TestConstants;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
/**
|
||||
* @author AuroraLS3
|
||||
*/
|
||||
public interface CombineUserTransactionTest extends DatabaseTestPreparer {
|
||||
|
||||
@Test
|
||||
default void uuidChangeCombinesData() {
|
||||
UUID oldUUID = UUID.randomUUID();
|
||||
UUID newUUID = UUID.randomUUID();
|
||||
UUID player2UUID = TestConstants.PLAYER_TWO_UUID;
|
||||
ServerUUID server2UUID = TestConstants.SERVER_TWO_UUID;
|
||||
|
||||
DataMap extraData1 = new DataMap();
|
||||
extraData1.put(WorldTimes.class, new WorldTimes(Map.of(TestConstants.WORLD_ONE_NAME, new GMTimes(Map.of(GMTimes.SURVIVAL, 200L)))));
|
||||
extraData1.put(PlayerKills.class, new PlayerKills(new ArrayList<>(List.of(new PlayerKill(new PlayerKill.Killer(oldUUID, TestConstants.PLAYER_ONE_NAME), new PlayerKill.Victim(player2UUID, TestConstants.PLAYER_TWO_NAME), new ServerIdentifier(serverUUID(), TestConstants.SERVER_NAME), TestConstants.WEAPON_SWORD, System.currentTimeMillis())))));
|
||||
FinishedSession sessionOnOldUUID = new FinishedSession(oldUUID, serverUUID(), System.currentTimeMillis(), System.currentTimeMillis(), 0L, extraData1);
|
||||
|
||||
DataMap extraData2 = new DataMap();
|
||||
extraData2.put(WorldTimes.class, new WorldTimes(Map.of(TestConstants.WORLD_ONE_NAME, new GMTimes(Map.of(GMTimes.SURVIVAL, 200L)))));
|
||||
extraData2.put(PlayerKills.class, new PlayerKills(new ArrayList<>(List.of(new PlayerKill(new PlayerKill.Killer(newUUID, TestConstants.PLAYER_ONE_NAME), new PlayerKill.Victim(player2UUID, TestConstants.PLAYER_TWO_NAME), new ServerIdentifier(server2UUID, TestConstants.SERVER_TWO_NAME), TestConstants.WEAPON_SWORD, System.currentTimeMillis())))));
|
||||
FinishedSession sessionOnNewUUID = new FinishedSession(newUUID, server2UUID, System.currentTimeMillis(), System.currentTimeMillis(), 0L, extraData2);
|
||||
|
||||
Database db = db();
|
||||
db.executeTransaction(new StoreServerInformationTransaction(new Server(server2UUID, TestConstants.SERVER_TWO_NAME, "", TestConstants.VERSION)));
|
||||
db.executeTransaction(new StoreWorldNameTransaction(serverUUID(), TestConstants.WORLD_ONE_NAME));
|
||||
db.executeTransaction(new StoreWorldNameTransaction(server2UUID, TestConstants.WORLD_ONE_NAME));
|
||||
db.executeTransaction(new StoreServerPlayerTransaction(player2UUID, System::currentTimeMillis, TestConstants.PLAYER_TWO_NAME, serverUUID(), TestConstants.GET_PLAYER_HOSTNAME));
|
||||
db.executeTransaction(new StoreServerPlayerTransaction(player2UUID, System::currentTimeMillis, TestConstants.PLAYER_TWO_NAME, server2UUID, TestConstants.GET_PLAYER_HOSTNAME));
|
||||
db.executeTransaction(new StoreServerPlayerTransaction(oldUUID, System::currentTimeMillis, TestConstants.PLAYER_ONE_NAME, serverUUID(), TestConstants.GET_PLAYER_HOSTNAME));
|
||||
db.executeTransaction(new StoreServerPlayerTransaction(newUUID, System::currentTimeMillis, TestConstants.PLAYER_ONE_NAME, server2UUID, TestConstants.GET_PLAYER_HOSTNAME));
|
||||
db.executeTransaction(new StoreSessionTransaction(sessionOnOldUUID));
|
||||
db.executeTransaction(new StoreSessionTransaction(sessionOnNewUUID));
|
||||
|
||||
|
||||
db.executeTransaction(new CombineUserTransaction(oldUUID, newUUID));
|
||||
|
||||
|
||||
// Assert data exists with the new UUID
|
||||
assertTrue(db.query(BaseUserQueries.fetchUserId(newUUID)).isPresent());
|
||||
assertEquals(2, db.query(SessionQueries.fetchSessionsOfPlayer(newUUID)).values().stream().mapToInt(List::size).sum());
|
||||
assertEquals(2, db.query(KillQueries.fetchPlayerKillsOfPlayer(newUUID)).size());
|
||||
assertEquals(2, db.query(UserInfoQueries.fetchUserInformationOfUser(newUUID)).size());
|
||||
|
||||
// Assert data doesn't exist with the old UUID
|
||||
assertTrue(db.query(BaseUserQueries.fetchUserId(oldUUID)).isEmpty());
|
||||
assertTrue(db.query(UserInfoQueries.fetchUserInformationOfUser(oldUUID)).isEmpty());
|
||||
assertTrue(db.query(KillQueries.fetchPlayerKillsOfPlayer(oldUUID)).isEmpty());
|
||||
}
|
||||
|
||||
}
|
@ -51,6 +51,7 @@ public class TestConstants {
|
||||
|
||||
public static final Supplier<String> GET_PLAYER_HOSTNAME = () -> "play.example.com";
|
||||
|
||||
public static final String WEAPON_SWORD = "Diamond Sword";
|
||||
public static final String WORLD_ONE_NAME = "World One";
|
||||
public static final String[] WORLDS = new String[]{WORLD_ONE_NAME};
|
||||
public static final Long REGISTER_TIME = RandomData.randomTime();
|
||||
|
@ -102,10 +102,10 @@ public class TestData {
|
||||
executeOther(new StoreServerInformationTransaction(new Server(server2UUID, "Server 2", "", TestConstants.VERSION)));
|
||||
|
||||
for (String worldName : serverWorldNames) {
|
||||
executeOther(new WorldNameStoreTransaction(serverUUID, worldName));
|
||||
executeOther(new StoreWorldNameTransaction(serverUUID, worldName));
|
||||
}
|
||||
for (String worldName : server2WorldNames) {
|
||||
executeOther(new WorldNameStoreTransaction(server2UUID, worldName));
|
||||
executeOther(new StoreWorldNameTransaction(server2UUID, worldName));
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -117,9 +117,9 @@ public class TestData {
|
||||
new Transaction() {
|
||||
@Override
|
||||
protected void performOperations() {
|
||||
executeOther(new PlayerServerRegisterTransaction(playerUUID, () -> playerFirstJoin,
|
||||
executeOther(new StoreServerPlayerTransaction(playerUUID, () -> playerFirstJoin,
|
||||
playerName, serverUUID, TestConstants.GET_PLAYER_HOSTNAME));
|
||||
executeOther(new PlayerServerRegisterTransaction(playerUUID, () -> playerSecondJoin,
|
||||
executeOther(new StoreServerPlayerTransaction(playerUUID, () -> playerSecondJoin,
|
||||
playerName, server2UUID, TestConstants.GET_PLAYER_HOSTNAME));
|
||||
|
||||
for (GeoInfo geoInfo : playerGeoInfo) {
|
||||
@ -140,9 +140,9 @@ public class TestData {
|
||||
new Transaction() {
|
||||
@Override
|
||||
protected void performOperations() {
|
||||
executeOther(new PlayerServerRegisterTransaction(player2UUID, () -> playerFirstJoin,
|
||||
executeOther(new StoreServerPlayerTransaction(player2UUID, () -> playerFirstJoin,
|
||||
player2Name, serverUUID, TestConstants.GET_PLAYER_HOSTNAME));
|
||||
executeOther(new PlayerServerRegisterTransaction(player2UUID, () -> playerSecondJoin,
|
||||
executeOther(new StoreServerPlayerTransaction(player2UUID, () -> playerSecondJoin,
|
||||
player2Name, server2UUID, TestConstants.GET_PLAYER_HOSTNAME));
|
||||
|
||||
for (GeoInfo geoInfo : playerGeoInfo) {
|
||||
|
@ -14,7 +14,7 @@
|
||||
<property name="checks" value="ClassFanOutComplexity"/>
|
||||
<!-- These files need refactoring. -->
|
||||
<property name="files"
|
||||
value="SQLDB.java|ExtensionRegister.java|DataValueGatherer.java|PlayerOnlineListener.java|.*Test.java"/>
|
||||
value="SQLDB.java|ExtensionRegister.java|DataValueGatherer.java|PlayerOnlineListener.java|DatabaseCommands.java|.*Test.java"/>
|
||||
</module>
|
||||
|
||||
<module name="RegexpHeader"> <!-- License check -->
|
||||
|
@ -20,7 +20,7 @@ import com.djrapitops.plan.delivery.domain.Nickname;
|
||||
import com.djrapitops.plan.gathering.cache.NicknameCache;
|
||||
import com.djrapitops.plan.identification.ServerInfo;
|
||||
import com.djrapitops.plan.storage.database.DBSystem;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.NicknameStoreTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.StoreNicknameTransaction;
|
||||
import com.djrapitops.plan.utilities.logging.ErrorContext;
|
||||
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
||||
import net.fabricmc.fabric.api.message.v1.ServerMessageEvents;
|
||||
@ -72,7 +72,7 @@ public class ChatListener implements FabricListener {
|
||||
UUID uuid = player.getUuid();
|
||||
String displayName = player.getDisplayName().getString();
|
||||
|
||||
dbSystem.getDatabase().executeTransaction(new NicknameStoreTransaction(
|
||||
dbSystem.getDatabase().executeTransaction(new StoreNicknameTransaction(
|
||||
uuid, new Nickname(displayName, time, serverInfo.getServerUUID()),
|
||||
(playerUUID, name) -> nicknameCache.getDisplayName(playerUUID).map(name::equals).orElse(false)
|
||||
));
|
||||
|
@ -21,7 +21,7 @@ import com.djrapitops.plan.gathering.domain.ActiveSession;
|
||||
import com.djrapitops.plan.identification.ServerInfo;
|
||||
import com.djrapitops.plan.settings.config.WorldAliasSettings;
|
||||
import com.djrapitops.plan.storage.database.DBSystem;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.WorldNameStoreTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.StoreWorldNameTransaction;
|
||||
import com.djrapitops.plan.utilities.logging.ErrorContext;
|
||||
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
@ -74,7 +74,7 @@ public class GameModeChangeListener implements FabricListener {
|
||||
String gameMode = newGameMode.name();
|
||||
String worldName = player.getWorld().getRegistryKey().getValue().toString();
|
||||
|
||||
dbSystem.getDatabase().executeTransaction(new WorldNameStoreTransaction(serverInfo.getServerUUID(), worldName));
|
||||
dbSystem.getDatabase().executeTransaction(new StoreWorldNameTransaction(serverInfo.getServerUUID(), worldName));
|
||||
worldAliasSettings.addWorld(worldName);
|
||||
|
||||
Optional<ActiveSession> cachedSession = SessionCache.getCachedSession(uuid);
|
||||
|
@ -21,7 +21,7 @@ import com.djrapitops.plan.gathering.domain.ActiveSession;
|
||||
import com.djrapitops.plan.identification.ServerInfo;
|
||||
import com.djrapitops.plan.settings.config.WorldAliasSettings;
|
||||
import com.djrapitops.plan.storage.database.DBSystem;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.WorldNameStoreTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.StoreWorldNameTransaction;
|
||||
import com.djrapitops.plan.utilities.logging.ErrorContext;
|
||||
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
||||
import net.fabricmc.fabric.api.entity.event.v1.ServerEntityWorldChangeEvents;
|
||||
@ -70,7 +70,7 @@ public class WorldChangeListener implements FabricListener {
|
||||
String worldName = player.getWorld().getRegistryKey().getValue().toString();
|
||||
String gameMode = player.interactionManager.getGameMode().name();
|
||||
|
||||
dbSystem.getDatabase().executeTransaction(new WorldNameStoreTransaction(serverInfo.getServerUUID(), worldName));
|
||||
dbSystem.getDatabase().executeTransaction(new StoreWorldNameTransaction(serverInfo.getServerUUID(), worldName));
|
||||
worldAliasSettings.addWorld(worldName);
|
||||
|
||||
Optional<ActiveSession> cachedSession = SessionCache.getCachedSession(uuid);
|
||||
|
@ -25,7 +25,7 @@ import com.djrapitops.plan.delivery.domain.Nickname;
|
||||
import com.djrapitops.plan.gathering.cache.NicknameCache;
|
||||
import com.djrapitops.plan.identification.ServerInfo;
|
||||
import com.djrapitops.plan.storage.database.DBSystem;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.NicknameStoreTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.StoreNicknameTransaction;
|
||||
import com.djrapitops.plan.utilities.logging.ErrorContext;
|
||||
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
||||
|
||||
@ -76,7 +76,7 @@ public class ChatListener implements Listener {
|
||||
UUID uuid = player.getUniqueId();
|
||||
String displayName = player.getDisplayName();
|
||||
|
||||
dbSystem.getDatabase().executeTransaction(new NicknameStoreTransaction(
|
||||
dbSystem.getDatabase().executeTransaction(new StoreNicknameTransaction(
|
||||
uuid, new Nickname(displayName, time, serverInfo.getServerUUID()),
|
||||
(playerUUID, name) -> nicknameCache.getDisplayName(playerUUID).map(name::equals).orElse(false)
|
||||
));
|
||||
|
@ -27,7 +27,7 @@ import com.djrapitops.plan.gathering.domain.GMTimes;
|
||||
import com.djrapitops.plan.identification.ServerInfo;
|
||||
import com.djrapitops.plan.settings.config.WorldAliasSettings;
|
||||
import com.djrapitops.plan.storage.database.DBSystem;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.WorldNameStoreTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.StoreWorldNameTransaction;
|
||||
import com.djrapitops.plan.utilities.logging.ErrorContext;
|
||||
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
||||
|
||||
@ -79,7 +79,7 @@ public class GameModeChangeListener implements Listener {
|
||||
String gameMode = GMTimes.magicNumberToGMName(event.getNewGamemode());
|
||||
String worldName = player.getLevel().getName();
|
||||
|
||||
dbSystem.getDatabase().executeTransaction(new WorldNameStoreTransaction(serverInfo.getServerUUID(), worldName));
|
||||
dbSystem.getDatabase().executeTransaction(new StoreWorldNameTransaction(serverInfo.getServerUUID(), worldName));
|
||||
worldAliasSettings.addWorld(worldName);
|
||||
|
||||
Optional<ActiveSession> cachedSession = SessionCache.getCachedSession(uuid);
|
||||
|
@ -27,7 +27,7 @@ import com.djrapitops.plan.gathering.domain.GMTimes;
|
||||
import com.djrapitops.plan.identification.ServerInfo;
|
||||
import com.djrapitops.plan.settings.config.WorldAliasSettings;
|
||||
import com.djrapitops.plan.storage.database.DBSystem;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.WorldNameStoreTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.StoreWorldNameTransaction;
|
||||
import com.djrapitops.plan.utilities.logging.ErrorContext;
|
||||
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
||||
|
||||
@ -76,7 +76,7 @@ public class WorldChangeListener implements Listener {
|
||||
String worldName = player.getLevel().getName();
|
||||
String gameMode = GMTimes.magicNumberToGMName(player.getGamemode());
|
||||
|
||||
dbSystem.getDatabase().executeTransaction(new WorldNameStoreTransaction(serverInfo.getServerUUID(), worldName));
|
||||
dbSystem.getDatabase().executeTransaction(new StoreWorldNameTransaction(serverInfo.getServerUUID(), worldName));
|
||||
worldAliasSettings.addWorld(worldName);
|
||||
|
||||
Optional<ActiveSession> cachedSession = SessionCache.getCachedSession(uuid);
|
||||
|
@ -20,7 +20,7 @@ import com.djrapitops.plan.delivery.domain.Nickname;
|
||||
import com.djrapitops.plan.gathering.cache.NicknameCache;
|
||||
import com.djrapitops.plan.identification.ServerInfo;
|
||||
import com.djrapitops.plan.storage.database.DBSystem;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.NicknameStoreTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.StoreNicknameTransaction;
|
||||
import com.djrapitops.plan.utilities.logging.ErrorContext;
|
||||
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
@ -72,7 +72,7 @@ public class SpongeChatListener {
|
||||
UUID uuid = player.uniqueId();
|
||||
String displayName = LegacyComponentSerializer.legacySection().serialize(player.displayName().get());
|
||||
|
||||
dbSystem.getDatabase().executeTransaction(new NicknameStoreTransaction(
|
||||
dbSystem.getDatabase().executeTransaction(new StoreNicknameTransaction(
|
||||
uuid, new Nickname(displayName, time, serverInfo.getServerUUID()),
|
||||
(playerUUID, name) -> nicknameCache.getDisplayName(playerUUID).map(name::equals).orElse(false)
|
||||
));
|
||||
|
@ -21,7 +21,7 @@ import com.djrapitops.plan.gathering.domain.ActiveSession;
|
||||
import com.djrapitops.plan.identification.ServerInfo;
|
||||
import com.djrapitops.plan.settings.config.WorldAliasSettings;
|
||||
import com.djrapitops.plan.storage.database.DBSystem;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.WorldNameStoreTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.StoreWorldNameTransaction;
|
||||
import com.djrapitops.plan.utilities.logging.ErrorContext;
|
||||
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
@ -126,7 +126,7 @@ public class SpongeGMChangeListener {
|
||||
String worldName = Sponge.game().server().worldManager().worldDirectory(player.world().key())
|
||||
.map(path -> path.getFileName().toString()).orElse("Unknown");
|
||||
|
||||
dbSystem.getDatabase().executeTransaction(new WorldNameStoreTransaction(serverInfo.getServerUUID(), worldName));
|
||||
dbSystem.getDatabase().executeTransaction(new StoreWorldNameTransaction(serverInfo.getServerUUID(), worldName));
|
||||
worldAliasSettings.addWorld(worldName);
|
||||
|
||||
Optional<ActiveSession> cachedSession = SessionCache.getCachedSession(uuid);
|
||||
|
@ -21,7 +21,7 @@ import com.djrapitops.plan.gathering.domain.ActiveSession;
|
||||
import com.djrapitops.plan.identification.ServerInfo;
|
||||
import com.djrapitops.plan.settings.config.WorldAliasSettings;
|
||||
import com.djrapitops.plan.storage.database.DBSystem;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.WorldNameStoreTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.StoreWorldNameTransaction;
|
||||
import com.djrapitops.plan.utilities.logging.ErrorContext;
|
||||
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
||||
import org.spongepowered.api.Sponge;
|
||||
@ -80,7 +80,7 @@ public class SpongeWorldChangeListener {
|
||||
.map(path -> path.getFileName().toString()).orElse("Unknown");
|
||||
String gameMode = getGameMode(player);
|
||||
|
||||
dbSystem.getDatabase().executeTransaction(new WorldNameStoreTransaction(serverInfo.getServerUUID(), worldName));
|
||||
dbSystem.getDatabase().executeTransaction(new StoreWorldNameTransaction(serverInfo.getServerUUID(), worldName));
|
||||
worldAliasSettings.addWorld(worldName);
|
||||
|
||||
Optional<ActiveSession> cachedSession = SessionCache.getCachedSession(uuid);
|
||||
|
Loading…
Reference in New Issue
Block a user