Search in sources :

Example 1 with NicknameStoreTransaction

use of com.djrapitops.plan.storage.database.transactions.events.NicknameStoreTransaction 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 2 with NicknameStoreTransaction

use of com.djrapitops.plan.storage.database.transactions.events.NicknameStoreTransaction 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 3 with NicknameStoreTransaction

use of com.djrapitops.plan.storage.database.transactions.events.NicknameStoreTransaction 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)

Example 4 with NicknameStoreTransaction

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

the class SpongeChatListener method actOnChatEvent.

private void actOnChatEvent(@First Player player) {
    long time = System.currentTimeMillis();
    UUID uuid = player.getUniqueId();
    String displayName = player.getDisplayNameData().displayName().get().toPlain();
    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) UUID(java.util.UUID) DBSystem(com.djrapitops.plan.storage.database.DBSystem) Inject(javax.inject.Inject) MessageChannelEvent(org.spongepowered.api.event.message.MessageChannelEvent) ErrorLogger(com.djrapitops.plan.utilities.logging.ErrorLogger) Order(org.spongepowered.api.event.Order) NicknameStoreTransaction(com.djrapitops.plan.storage.database.transactions.events.NicknameStoreTransaction) ErrorContext(com.djrapitops.plan.utilities.logging.ErrorContext) Player(org.spongepowered.api.entity.living.player.Player) Listener(org.spongepowered.api.event.Listener) Nickname(com.djrapitops.plan.delivery.domain.Nickname) First(org.spongepowered.api.event.filter.cause.First) NicknameStoreTransaction(com.djrapitops.plan.storage.database.transactions.events.NicknameStoreTransaction) UUID(java.util.UUID) Nickname(com.djrapitops.plan.delivery.domain.Nickname)

Example 5 with NicknameStoreTransaction

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

the class ChatListener method actOnChatEvent.

private void actOnChatEvent(PlayerChatEvent 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) UUID(java.util.UUID) EventHandler(cn.nukkit.event.EventHandler) Listener(cn.nukkit.event.Listener) DBSystem(com.djrapitops.plan.storage.database.DBSystem) Inject(javax.inject.Inject) ErrorLogger(com.djrapitops.plan.utilities.logging.ErrorLogger) Player(cn.nukkit.Player) NicknameStoreTransaction(com.djrapitops.plan.storage.database.transactions.events.NicknameStoreTransaction) EventPriority(cn.nukkit.event.EventPriority) ErrorContext(com.djrapitops.plan.utilities.logging.ErrorContext) Nickname(com.djrapitops.plan.delivery.domain.Nickname) PlayerChatEvent(cn.nukkit.event.player.PlayerChatEvent) Player(cn.nukkit.Player) NicknameStoreTransaction(com.djrapitops.plan.storage.database.transactions.events.NicknameStoreTransaction) UUID(java.util.UUID) Nickname(com.djrapitops.plan.delivery.domain.Nickname)

Aggregations

Nickname (com.djrapitops.plan.delivery.domain.Nickname)6 NicknameStoreTransaction (com.djrapitops.plan.storage.database.transactions.events.NicknameStoreTransaction)6 UUID (java.util.UUID)6 NicknameCache (com.djrapitops.plan.gathering.cache.NicknameCache)4 ServerInfo (com.djrapitops.plan.identification.ServerInfo)4 DBSystem (com.djrapitops.plan.storage.database.DBSystem)4 ErrorContext (com.djrapitops.plan.utilities.logging.ErrorContext)4 ErrorLogger (com.djrapitops.plan.utilities.logging.ErrorLogger)4 Inject (javax.inject.Inject)4 DatabaseTestPreparer (com.djrapitops.plan.storage.database.DatabaseTestPreparer)2 NicknameQueries (com.djrapitops.plan.storage.database.queries.objects.NicknameQueries)2 UserIdentifierQueries (com.djrapitops.plan.storage.database.queries.objects.UserIdentifierQueries)2 RemoveEverythingTransaction (com.djrapitops.plan.storage.database.transactions.commands.RemoveEverythingTransaction)2 PlayerRegisterTransaction (com.djrapitops.plan.storage.database.transactions.events.PlayerRegisterTransaction)2 PlayerServerRegisterTransaction (com.djrapitops.plan.storage.database.transactions.events.PlayerServerRegisterTransaction)2 List (java.util.List)2 Assertions (org.junit.jupiter.api.Assertions)2 Test (org.junit.jupiter.api.Test)2 RandomData (utilities.RandomData)2 TestConstants (utilities.TestConstants)2