Search in sources :

Example 11 with WorldNameStoreTransaction

use of com.djrapitops.plan.storage.database.transactions.events.WorldNameStoreTransaction in project Plan by plan-player-analytics.

the class JSErrorRegressionTest method savePlayerData.

private static void savePlayerData() {
    DBSystem dbSystem = planSystem.getDatabaseSystem();
    Database database = dbSystem.getDatabase();
    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 StoreSessionTransaction(session));
}
Also used : StoreSessionTransaction(com.djrapitops.plan.storage.database.transactions.events.StoreSessionTransaction) DBSystem(com.djrapitops.plan.storage.database.DBSystem) FinishedSession(com.djrapitops.plan.gathering.domain.FinishedSession) Database(com.djrapitops.plan.storage.database.Database) WorldNameStoreTransaction(com.djrapitops.plan.storage.database.transactions.events.WorldNameStoreTransaction) PlayerRegisterTransaction(com.djrapitops.plan.storage.database.transactions.events.PlayerRegisterTransaction) ServerUUID(com.djrapitops.plan.identification.ServerUUID) DataMap(com.djrapitops.plan.gathering.domain.DataMap)

Example 12 with WorldNameStoreTransaction

use of com.djrapitops.plan.storage.database.transactions.events.WorldNameStoreTransaction in project Plan by plan-player-analytics.

the class GameModeChangeListener method actOnEvent.

private void actOnEvent(PlayerGameModeChangeEvent event) {
    Player player = event.getPlayer();
    UUID uuid = player.getUniqueId();
    long time = System.currentTimeMillis();
    String gameMode = event.getNewGameMode().name();
    String worldName = player.getWorld().getName();
    dbSystem.getDatabase().executeTransaction(new WorldNameStoreTransaction(serverInfo.getServerUUID(), worldName));
    worldAliasSettings.addWorld(worldName);
    Optional<ActiveSession> cachedSession = SessionCache.getCachedSession(uuid);
    cachedSession.ifPresent(session -> session.changeState(worldName, gameMode, time));
}
Also used : Player(org.bukkit.entity.Player) ActiveSession(com.djrapitops.plan.gathering.domain.ActiveSession) WorldNameStoreTransaction(com.djrapitops.plan.storage.database.transactions.events.WorldNameStoreTransaction) UUID(java.util.UUID)

Example 13 with WorldNameStoreTransaction

use of com.djrapitops.plan.storage.database.transactions.events.WorldNameStoreTransaction in project Plan by plan-player-analytics.

the class WorldChangeListener method actOnEvent.

private void actOnEvent(PlayerChangedWorldEvent event) {
    long time = System.currentTimeMillis();
    Player player = event.getPlayer();
    UUID uuid = player.getUniqueId();
    String worldName = player.getWorld().getName();
    String gameMode = player.getGameMode().name();
    dbSystem.getDatabase().executeTransaction(new WorldNameStoreTransaction(serverInfo.getServerUUID(), worldName));
    worldAliasSettings.addWorld(worldName);
    Optional<ActiveSession> cachedSession = SessionCache.getCachedSession(uuid);
    cachedSession.ifPresent(session -> session.changeState(worldName, gameMode, time));
}
Also used : Player(org.bukkit.entity.Player) ActiveSession(com.djrapitops.plan.gathering.domain.ActiveSession) WorldNameStoreTransaction(com.djrapitops.plan.storage.database.transactions.events.WorldNameStoreTransaction) UUID(java.util.UUID)

Example 14 with WorldNameStoreTransaction

use of com.djrapitops.plan.storage.database.transactions.events.WorldNameStoreTransaction in project Plan by plan-player-analytics.

the class WorldChangeListener method actOnEvent.

private void actOnEvent(EntityLevelChangeEvent event) {
    long time = System.currentTimeMillis();
    // Checked earlier
    Player player = (Player) event.getEntity();
    UUID uuid = player.getUniqueId();
    String worldName = player.getLevel().getName();
    String gameMode = GMTimes.magicNumberToGMName(player.getGamemode());
    dbSystem.getDatabase().executeTransaction(new WorldNameStoreTransaction(serverInfo.getServerUUID(), worldName));
    worldAliasSettings.addWorld(worldName);
    Optional<ActiveSession> cachedSession = SessionCache.getCachedSession(uuid);
    cachedSession.ifPresent(session -> session.changeState(worldName, gameMode, time));
}
Also used : Player(cn.nukkit.Player) ActiveSession(com.djrapitops.plan.gathering.domain.ActiveSession) WorldNameStoreTransaction(com.djrapitops.plan.storage.database.transactions.events.WorldNameStoreTransaction) UUID(java.util.UUID)

Example 15 with WorldNameStoreTransaction

use of com.djrapitops.plan.storage.database.transactions.events.WorldNameStoreTransaction in project Plan by plan-player-analytics.

the class SpongeWorldChangeListener method actOnEvent.

private void actOnEvent(MoveEntityEvent.Teleport event, Player player) {
    long time = System.currentTimeMillis();
    UUID uuid = player.getUniqueId();
    String worldName = event.getToTransform().getExtent().getName();
    String gameMode = getGameMode(player);
    dbSystem.getDatabase().executeTransaction(new WorldNameStoreTransaction(serverInfo.getServerUUID(), worldName));
    worldAliasSettings.addWorld(worldName);
    Optional<ActiveSession> cachedSession = SessionCache.getCachedSession(uuid);
    cachedSession.ifPresent(session -> session.changeState(worldName, gameMode, time));
}
Also used : ActiveSession(com.djrapitops.plan.gathering.domain.ActiveSession) WorldNameStoreTransaction(com.djrapitops.plan.storage.database.transactions.events.WorldNameStoreTransaction) UUID(java.util.UUID)

Aggregations

WorldNameStoreTransaction (com.djrapitops.plan.storage.database.transactions.events.WorldNameStoreTransaction)18 UUID (java.util.UUID)10 ActiveSession (com.djrapitops.plan.gathering.domain.ActiveSession)9 StoreSessionTransaction (com.djrapitops.plan.storage.database.transactions.events.StoreSessionTransaction)7 FinishedSession (com.djrapitops.plan.gathering.domain.FinishedSession)5 PlayerRegisterTransaction (com.djrapitops.plan.storage.database.transactions.events.PlayerRegisterTransaction)5 ServerUUID (com.djrapitops.plan.identification.ServerUUID)4 Test (org.junit.jupiter.api.Test)4 Database (com.djrapitops.plan.storage.database.Database)3 PlayerServerRegisterTransaction (com.djrapitops.plan.storage.database.transactions.events.PlayerServerRegisterTransaction)3 Player (cn.nukkit.Player)2 DataMap (com.djrapitops.plan.gathering.domain.DataMap)2 DBSystem (com.djrapitops.plan.storage.database.DBSystem)2 RemoveEverythingTransaction (com.djrapitops.plan.storage.database.transactions.commands.RemoveEverythingTransaction)2 Player (org.bukkit.entity.Player)2 HtmlTable (com.djrapitops.plan.delivery.rendering.html.structure.HtmlTable)1 CallEvents (com.djrapitops.plan.extension.CallEvents)1 DataExtension (com.djrapitops.plan.extension.DataExtension)1 ExtensionSvc (com.djrapitops.plan.extension.ExtensionSvc)1 NotReadyException (com.djrapitops.plan.extension.NotReadyException)1