Search in sources :

Example 21 with ServerUUID

use of com.djrapitops.plan.identification.ServerUUID in project Plan by plan-player-analytics.

the class DatabaseTest method testRemovalSingleUser.

@Test
default void testRemovalSingleUser() {
    saveUserTwo();
    db().executeTransaction(new PlayerServerRegisterTransaction(playerUUID, RandomData::randomTime, TestConstants.PLAYER_ONE_NAME, serverUUID(), TestConstants.GET_PLAYER_HOSTNAME));
    saveTwoWorlds();
    FinishedSession session = RandomData.randomSession(serverUUID(), worlds, playerUUID, player2UUID);
    execute(DataStoreQueries.storeSession(session));
    db().executeTransaction(new NicknameStoreTransaction(playerUUID, new Nickname("TestNick", RandomData.randomTime(), serverUUID()), (uuid, name) -> false));
    db().executeTransaction(new GeoInfoStoreTransaction(playerUUID, new GeoInfo("TestLoc", RandomData.randomTime())));
    assertTrue(db().query(PlayerFetchQueries.isPlayerRegistered(playerUUID)));
    db().executeTransaction(new RemovePlayerTransaction(playerUUID));
    assertFalse(db().query(PlayerFetchQueries.isPlayerRegistered(playerUUID)));
    assertFalse(db().query(PlayerFetchQueries.isPlayerRegisteredOnServer(playerUUID, serverUUID())));
    assertTrue(db().query(NicknameQueries.fetchNicknameDataOfPlayer(playerUUID)).isEmpty());
    assertTrue(db().query(GeoInfoQueries.fetchPlayerGeoInformation(playerUUID)).isEmpty());
    assertQueryIsEmpty(db(), SessionQueries.fetchSessionsOfPlayer(playerUUID));
}
Also used : SELECT(com.djrapitops.plan.storage.database.sql.building.Sql.SELECT) java.util(java.util) PlanConfig(com.djrapitops.plan.settings.config.PlanConfig) ServerTablePlayersQuery(com.djrapitops.plan.storage.database.queries.objects.playertable.ServerTablePlayersQuery) UserInfoTable(com.djrapitops.plan.storage.database.sql.tables.UserInfoTable) ServerUUID(com.djrapitops.plan.identification.ServerUUID) TablePlayer(com.djrapitops.plan.delivery.domain.TablePlayer) Disabled(org.junit.jupiter.api.Disabled) utilities(utilities) GeoInfo(com.djrapitops.plan.gathering.domain.GeoInfo) com.djrapitops.plan.storage.database.queries(com.djrapitops.plan.storage.database.queries) SQLException(java.sql.SQLException) NetworkTablePlayersQuery(com.djrapitops.plan.storage.database.queries.objects.playertable.NetworkTablePlayersQuery) ResultSet(java.sql.ResultSet) BaseUser(com.djrapitops.plan.gathering.domain.BaseUser) PlayerKeys(com.djrapitops.plan.delivery.domain.keys.PlayerKeys) ActiveSession(com.djrapitops.plan.gathering.domain.ActiveSession) StoreConfigTransaction(com.djrapitops.plan.storage.database.transactions.StoreConfigTransaction) Transaction(com.djrapitops.plan.storage.database.transactions.Transaction) ContainerFetchQueries(com.djrapitops.plan.storage.database.queries.containers.ContainerFetchQueries) FinishedSession(com.djrapitops.plan.gathering.domain.FinishedSession) WHERE(com.djrapitops.plan.storage.database.sql.building.Sql.WHERE) ServerPlayerContainersQuery(com.djrapitops.plan.storage.database.queries.containers.ServerPlayerContainersQuery) QuerySvc(com.djrapitops.plan.query.QuerySvc) Sql(com.djrapitops.plan.storage.database.sql.building.Sql) Collectors(java.util.stream.Collectors) Test(org.junit.jupiter.api.Test) TimeUnit(java.util.concurrent.TimeUnit) Key(com.djrapitops.plan.delivery.domain.keys.Key) DBCleanTask(com.djrapitops.plan.storage.upkeep.DBCleanTask) Locale(com.djrapitops.plan.settings.locale.Locale) com.djrapitops.plan.storage.database.transactions.events(com.djrapitops.plan.storage.database.transactions.events) Assertions(org.junit.jupiter.api.Assertions) PlayerContainer(com.djrapitops.plan.delivery.domain.container.PlayerContainer) com.djrapitops.plan.storage.database.queries.objects(com.djrapitops.plan.storage.database.queries.objects) RemovePlayerTransaction(com.djrapitops.plan.storage.database.transactions.commands.RemovePlayerTransaction) CreateIndexTransaction(com.djrapitops.plan.storage.database.transactions.init.CreateIndexTransaction) RegisterDateMinimizationPatch(com.djrapitops.plan.storage.database.transactions.patches.RegisterDateMinimizationPatch) Nickname(com.djrapitops.plan.delivery.domain.Nickname) Config(com.djrapitops.plan.settings.config.Config) FinishedSession(com.djrapitops.plan.gathering.domain.FinishedSession) GeoInfo(com.djrapitops.plan.gathering.domain.GeoInfo) RemovePlayerTransaction(com.djrapitops.plan.storage.database.transactions.commands.RemovePlayerTransaction) Nickname(com.djrapitops.plan.delivery.domain.Nickname) Test(org.junit.jupiter.api.Test)

Example 22 with ServerUUID

use of com.djrapitops.plan.identification.ServerUUID in project Plan by plan-player-analytics.

the class PlayerOnlineListener method onPlayerLogin.

public void onPlayerLogin(SocketAddress address, GameProfile profile, boolean banned) {
    try {
        UUID playerUUID = profile.getId();
        ServerUUID serverUUID = serverInfo.getServerUUID();
        String joinAddress = address.toString();
        if (!joinAddress.isEmpty()) {
            joinAddresses.put(playerUUID, joinAddress.substring(0, joinAddress.lastIndexOf(':')));
        }
        dbSystem.getDatabase().executeTransaction(new BanStatusTransaction(playerUUID, serverUUID, () -> banned));
    } catch (Exception e) {
        errorLogger.error(e, ErrorContext.builder().related(getClass(), address, profile, banned).build());
    }
}
Also used : ServerUUID(com.djrapitops.plan.identification.ServerUUID) ServerUUID(com.djrapitops.plan.identification.ServerUUID) UUID(java.util.UUID)

Example 23 with ServerUUID

use of com.djrapitops.plan.identification.ServerUUID in project Plan by plan-player-analytics.

the class ServerQueriesTest method bungeeInformationIsStored.

@Test
default void bungeeInformationIsStored() {
    Optional<Server> bungeeInfo = db().query(ServerQueries.fetchProxyServerInformation());
    assertFalse(bungeeInfo.isPresent());
    ServerUUID bungeeUUID = ServerUUID.randomUUID();
    Server bungeeCord = new Server(bungeeUUID, "BungeeCord", "Random:1234");
    bungeeCord.setProxy(true);
    db().executeTransaction(new StoreServerInformationTransaction(bungeeCord));
    forcePersistenceCheck();
    bungeeCord.setId(2);
    bungeeInfo = db().query(ServerQueries.fetchProxyServerInformation());
    assertTrue(bungeeInfo.isPresent());
    assertEquals(bungeeCord, bungeeInfo.get());
    Optional<Server> found = db().query(ServerQueries.fetchServerMatchingIdentifier(bungeeUUID));
    OptionalAssert.equals(bungeeCord.getWebAddress(), found.map(Server::getWebAddress));
}
Also used : ServerUUID(com.djrapitops.plan.identification.ServerUUID) Server(com.djrapitops.plan.identification.Server) StoreServerInformationTransaction(com.djrapitops.plan.storage.database.transactions.StoreServerInformationTransaction) Test(org.junit.jupiter.api.Test)

Example 24 with ServerUUID

use of com.djrapitops.plan.identification.ServerUUID in project Plan by plan-player-analytics.

the class ProxyServerInfo method createServerObject.

private Server createServerObject() {
    ServerUUID serverUUID = generateNewUUID();
    String accessAddress = addresses.getAccessAddress().orElseThrow(() -> new EnableException("Velocity can not have '0.0.0.0' or '' as an address. Set up 'Server.IP' setting."));
    return new Server(-1, serverUUID, "BungeeCord", accessAddress, true);
}
Also used : ServerUUID(com.djrapitops.plan.identification.ServerUUID) EnableException(com.djrapitops.plan.exceptions.EnableException) Server(com.djrapitops.plan.identification.Server)

Example 25 with ServerUUID

use of com.djrapitops.plan.identification.ServerUUID in project Plan by plan-player-analytics.

the class ServerFileLoader method load.

@Override
public Optional<Server> load(ServerUUID loaded) {
    try {
        if (!prepared)
            prepare();
        String serverUUIDString = getString("Server.UUID");
        if (serverUUIDString == null)
            return Optional.empty();
        Integer id = getInteger("Server.ID");
        ServerUUID serverUUID = ServerUUID.fromString(serverUUIDString);
        String name = config.getNode(PluginSettings.SERVER_NAME.getPath()).map(ConfigNode::getString).orElse("Proxy");
        String address = getString("Server.Web_address");
        return Optional.of(new Server(id, serverUUID, name, address, false));
    } catch (IOException e) {
        throw new EnableException("Failed to read ServerInfoFile.yml: " + e.getMessage());
    }
}
Also used : ServerUUID(com.djrapitops.plan.identification.ServerUUID) EnableException(com.djrapitops.plan.exceptions.EnableException) Server(com.djrapitops.plan.identification.Server) IOException(java.io.IOException)

Aggregations

ServerUUID (com.djrapitops.plan.identification.ServerUUID)105 UUID (java.util.UUID)26 ResultSet (java.sql.ResultSet)23 PreparedStatement (java.sql.PreparedStatement)21 Database (com.djrapitops.plan.storage.database.Database)17 Test (org.junit.jupiter.api.Test)17 FinishedSession (com.djrapitops.plan.gathering.domain.FinishedSession)14 WorldTimes (com.djrapitops.plan.gathering.domain.WorldTimes)12 Nickname (com.djrapitops.plan.delivery.domain.Nickname)11 ActiveSession (com.djrapitops.plan.gathering.domain.ActiveSession)11 Server (com.djrapitops.plan.identification.Server)11 HashMap (java.util.HashMap)11 ExtensionSvc (com.djrapitops.plan.extension.ExtensionSvc)9 PlanConfig (com.djrapitops.plan.settings.config.PlanConfig)9 QueryStatement (com.djrapitops.plan.storage.database.queries.QueryStatement)9 WorldNameStoreTransaction (com.djrapitops.plan.storage.database.transactions.events.WorldNameStoreTransaction)9 Lists (com.djrapitops.plan.utilities.java.Lists)9 CallEvents (com.djrapitops.plan.extension.CallEvents)8 List (java.util.List)8 Map (java.util.Map)8