Search in sources :

Example 1 with Nickname

use of com.djrapitops.plan.delivery.domain.Nickname in project Plan by plan-player-analytics.

the class PlayerOnlineListener method actOnJoinEvent.

private void actOnJoinEvent(PlayerJoinEvent event) {
    Player player = event.getPlayer();
    UUID playerUUID = player.getUniqueId();
    ServerUUID serverUUID = serverInfo.getServerUUID();
    long time = System.currentTimeMillis();
    BukkitAFKListener.afkTracker.performedAction(playerUUID, time);
    String world = player.getWorld().getName();
    String gm = Optional.ofNullable(player.getGameMode()).map(gameMode -> gameMode.name()).orElse("Unknown");
    Database database = dbSystem.getDatabase();
    database.executeTransaction(new WorldNameStoreTransaction(serverUUID, world));
    InetAddress address = player.getAddress().getAddress();
    Supplier<String> getHostName = () -> getHostname(player);
    String playerName = player.getName();
    String displayName = player.getDisplayName();
    boolean gatheringGeolocations = config.isTrue(DataGatheringSettings.GEOLOCATIONS);
    if (gatheringGeolocations) {
        database.executeTransaction(new GeoInfoStoreTransaction(playerUUID, address, time, geolocationCache::getCountry));
    }
    database.executeTransaction(new PlayerServerRegisterTransaction(playerUUID, player::getFirstPlayed, playerName, serverUUID, getHostName));
    database.executeTransaction(new OperatorStatusTransaction(playerUUID, serverUUID, player.isOp()));
    ActiveSession session = new ActiveSession(playerUUID, serverUUID, time, world, gm);
    session.getExtraData().put(PlayerName.class, new PlayerName(playerName));
    session.getExtraData().put(ServerName.class, new ServerName(serverInfo.getServer().getIdentifiableName()));
    sessionCache.cacheSession(playerUUID, session).ifPresent(previousSession -> database.executeTransaction(new SessionEndTransaction(previousSession)));
    database.executeTransaction(new NicknameStoreTransaction(playerUUID, new Nickname(displayName, time, serverUUID), (uuid, name) -> nicknameCache.getDisplayName(playerUUID).map(name::equals).orElse(false)));
    processing.submitNonCritical(() -> extensionService.updatePlayerValues(playerUUID, playerName, CallEvents.PLAYER_JOIN));
    if (config.isTrue(ExportSettings.EXPORT_ON_ONLINE_STATUS_CHANGE)) {
        processing.submitNonCritical(() -> exporter.exportPlayerPage(playerUUID, playerName));
    }
}
Also used : PlanConfig(com.djrapitops.plan.settings.config.PlanConfig) NicknameCache(com.djrapitops.plan.gathering.cache.NicknameCache) Exporter(com.djrapitops.plan.delivery.export.Exporter) PlayerName(com.djrapitops.plan.delivery.domain.PlayerName) ServerUUID(com.djrapitops.plan.identification.ServerUUID) DataGatheringSettings(com.djrapitops.plan.settings.config.paths.DataGatheringSettings) HashMap(java.util.HashMap) Player(org.bukkit.entity.Player) Supplier(java.util.function.Supplier) Database(com.djrapitops.plan.storage.database.Database) DBSystem(com.djrapitops.plan.storage.database.DBSystem) EventHandler(org.bukkit.event.EventHandler) Inject(javax.inject.Inject) InetAddress(java.net.InetAddress) ExtensionSvc(com.djrapitops.plan.extension.ExtensionSvc) SessionCache(com.djrapitops.plan.gathering.cache.SessionCache) Map(java.util.Map) ActiveSession(com.djrapitops.plan.gathering.domain.ActiveSession) ErrorContext(com.djrapitops.plan.utilities.logging.ErrorContext) Listener(org.bukkit.event.Listener) PlayerJoinEvent(org.bukkit.event.player.PlayerJoinEvent) ServerName(com.djrapitops.plan.delivery.domain.ServerName) PlayerLoginEvent(org.bukkit.event.player.PlayerLoginEvent) ServerInfo(com.djrapitops.plan.identification.ServerInfo) ExportSettings(com.djrapitops.plan.settings.config.paths.ExportSettings) UUID(java.util.UUID) Status(com.djrapitops.plan.gathering.listeners.Status) ErrorLogger(com.djrapitops.plan.utilities.logging.ErrorLogger) EventPriority(org.bukkit.event.EventPriority) com.djrapitops.plan.storage.database.transactions.events(com.djrapitops.plan.storage.database.transactions.events) PlayerKickEvent(org.bukkit.event.player.PlayerKickEvent) PlayerQuitEvent(org.bukkit.event.player.PlayerQuitEvent) CallEvents(com.djrapitops.plan.extension.CallEvents) Optional(java.util.Optional) Processing(com.djrapitops.plan.processing.Processing) GeolocationCache(com.djrapitops.plan.gathering.geolocation.GeolocationCache) Nickname(com.djrapitops.plan.delivery.domain.Nickname) Player(org.bukkit.entity.Player) ServerUUID(com.djrapitops.plan.identification.ServerUUID) ActiveSession(com.djrapitops.plan.gathering.domain.ActiveSession) PlayerName(com.djrapitops.plan.delivery.domain.PlayerName) ServerName(com.djrapitops.plan.delivery.domain.ServerName) Database(com.djrapitops.plan.storage.database.Database) ServerUUID(com.djrapitops.plan.identification.ServerUUID) UUID(java.util.UUID) InetAddress(java.net.InetAddress) Nickname(com.djrapitops.plan.delivery.domain.Nickname)

Example 2 with Nickname

use of com.djrapitops.plan.delivery.domain.Nickname in project Plan by plan-player-analytics.

the class ChatListener method actOnChatEvent.

private void actOnChatEvent(AsyncPlayerChatEvent event) {
    long time = System.currentTimeMillis();
    Player player = event.getPlayer();
    UUID uuid = player.getUniqueId();
    String displayName = player.getDisplayName();
    dbSystem.getDatabase().executeTransaction(new NicknameStoreTransaction(uuid, new Nickname(displayName, time, serverInfo.getServerUUID()), (playerUUID, name) -> nicknameCache.getDisplayName(playerUUID).map(name::equals).orElse(false)));
}
Also used : NicknameCache(com.djrapitops.plan.gathering.cache.NicknameCache) ServerInfo(com.djrapitops.plan.identification.ServerInfo) Player(org.bukkit.entity.Player) UUID(java.util.UUID) DBSystem(com.djrapitops.plan.storage.database.DBSystem) EventHandler(org.bukkit.event.EventHandler) Inject(javax.inject.Inject) ErrorLogger(com.djrapitops.plan.utilities.logging.ErrorLogger) EventPriority(org.bukkit.event.EventPriority) NicknameStoreTransaction(com.djrapitops.plan.storage.database.transactions.events.NicknameStoreTransaction) ErrorContext(com.djrapitops.plan.utilities.logging.ErrorContext) AsyncPlayerChatEvent(org.bukkit.event.player.AsyncPlayerChatEvent) Nickname(com.djrapitops.plan.delivery.domain.Nickname) Listener(org.bukkit.event.Listener) Player(org.bukkit.entity.Player) NicknameStoreTransaction(com.djrapitops.plan.storage.database.transactions.events.NicknameStoreTransaction) UUID(java.util.UUID) Nickname(com.djrapitops.plan.delivery.domain.Nickname)

Example 3 with Nickname

use of com.djrapitops.plan.delivery.domain.Nickname in project Plan by plan-player-analytics.

the class NicknameQueriesTest method nicknameMatchingFindsNicknames.

@Test
default void nicknameMatchingFindsNicknames() {
    UUID uuid = UUID.randomUUID();
    String userName = RandomData.randomString(10);
    db().executeTransaction(new PlayerRegisterTransaction(uuid, () -> 0L, userName));
    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));
    db().executeTransaction(new NicknameStoreTransaction(playerUUID, new Nickname("No nick", System.currentTimeMillis(), serverUUID()), (u, name) -> true));
    String searchFor = "2";
    List<String> result = db().query(UserIdentifierQueries.fetchMatchingPlayerNames(searchFor));
    assertNotNull(result);
    assertEquals(1, result.size());
    assertEquals(userName, result.get(0));
}
Also used : PlayerServerRegisterTransaction(com.djrapitops.plan.storage.database.transactions.events.PlayerServerRegisterTransaction) RemoveEverythingTransaction(com.djrapitops.plan.storage.database.transactions.commands.RemoveEverythingTransaction) UUID(java.util.UUID) PlayerRegisterTransaction(com.djrapitops.plan.storage.database.transactions.events.PlayerRegisterTransaction) Test(org.junit.jupiter.api.Test) List(java.util.List) NicknameQueries(com.djrapitops.plan.storage.database.queries.objects.NicknameQueries) DatabaseTestPreparer(com.djrapitops.plan.storage.database.DatabaseTestPreparer) UserIdentifierQueries(com.djrapitops.plan.storage.database.queries.objects.UserIdentifierQueries) Assertions(org.junit.jupiter.api.Assertions) NicknameStoreTransaction(com.djrapitops.plan.storage.database.transactions.events.NicknameStoreTransaction) RandomData(utilities.RandomData) TestConstants(utilities.TestConstants) Nickname(com.djrapitops.plan.delivery.domain.Nickname) NicknameStoreTransaction(com.djrapitops.plan.storage.database.transactions.events.NicknameStoreTransaction) PlayerRegisterTransaction(com.djrapitops.plan.storage.database.transactions.events.PlayerRegisterTransaction) UUID(java.util.UUID) Nickname(com.djrapitops.plan.delivery.domain.Nickname) Test(org.junit.jupiter.api.Test)

Example 4 with Nickname

use of com.djrapitops.plan.delivery.domain.Nickname 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 5 with Nickname

use of com.djrapitops.plan.delivery.domain.Nickname in project Plan by plan-player-analytics.

the class ChatListener method actOnChatEvent.

private void actOnChatEvent(ServerPlayNetworkHandler handler) {
    long time = System.currentTimeMillis();
    ServerPlayerEntity player = handler.player;
    UUID uuid = player.getUuid();
    String displayName = player.getDisplayName().asString();
    dbSystem.getDatabase().executeTransaction(new NicknameStoreTransaction(uuid, new Nickname(displayName, time, serverInfo.getServerUUID()), (playerUUID, name) -> nicknameCache.getDisplayName(playerUUID).map(name::equals).orElse(false)));
}
Also used : NicknameCache(com.djrapitops.plan.gathering.cache.NicknameCache) ServerInfo(com.djrapitops.plan.identification.ServerInfo) FabricListener(net.playeranalytics.plan.gathering.listeners.FabricListener) UUID(java.util.UUID) PlanFabricEvents(net.playeranalytics.plan.gathering.listeners.events.PlanFabricEvents) DBSystem(com.djrapitops.plan.storage.database.DBSystem) Inject(javax.inject.Inject) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) ErrorLogger(com.djrapitops.plan.utilities.logging.ErrorLogger) NicknameStoreTransaction(com.djrapitops.plan.storage.database.transactions.events.NicknameStoreTransaction) ErrorContext(com.djrapitops.plan.utilities.logging.ErrorContext) Nickname(com.djrapitops.plan.delivery.domain.Nickname) ServerPlayNetworkHandler(net.minecraft.server.network.ServerPlayNetworkHandler) NicknameStoreTransaction(com.djrapitops.plan.storage.database.transactions.events.NicknameStoreTransaction) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) UUID(java.util.UUID) Nickname(com.djrapitops.plan.delivery.domain.Nickname)

Aggregations

Nickname (com.djrapitops.plan.delivery.domain.Nickname)18 UUID (java.util.UUID)11 ServerUUID (com.djrapitops.plan.identification.ServerUUID)9 NicknameCache (com.djrapitops.plan.gathering.cache.NicknameCache)8 ServerInfo (com.djrapitops.plan.identification.ServerInfo)8 DBSystem (com.djrapitops.plan.storage.database.DBSystem)8 ErrorContext (com.djrapitops.plan.utilities.logging.ErrorContext)8 ErrorLogger (com.djrapitops.plan.utilities.logging.ErrorLogger)8 Inject (javax.inject.Inject)8 NicknameStoreTransaction (com.djrapitops.plan.storage.database.transactions.events.NicknameStoreTransaction)6 ResultSet (java.sql.ResultSet)6 ActiveSession (com.djrapitops.plan.gathering.domain.ActiveSession)5 PlanConfig (com.djrapitops.plan.settings.config.PlanConfig)5 com.djrapitops.plan.storage.database.transactions.events (com.djrapitops.plan.storage.database.transactions.events)5 PreparedStatement (java.sql.PreparedStatement)5 PlayerName (com.djrapitops.plan.delivery.domain.PlayerName)4 ServerName (com.djrapitops.plan.delivery.domain.ServerName)4 Exporter (com.djrapitops.plan.delivery.export.Exporter)4 CallEvents (com.djrapitops.plan.extension.CallEvents)4 ExtensionSvc (com.djrapitops.plan.extension.ExtensionSvc)4