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)));
}
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));
}
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)));
}
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)));
}
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)));
}
Aggregations