use of com.djrapitops.plan.identification.ServerUUID in project Plan by plan-player-analytics.
the class PlayerOnlineListener method actOnJoinEvent.
private void actOnJoinEvent(ClientConnectionEvent.Join event) {
Player player = event.getTargetEntity();
UUID playerUUID = player.getUniqueId();
ServerUUID serverUUID = serverInfo.getServerUUID();
long time = System.currentTimeMillis();
SpongeAFKListener.afkTracker.performedAction(playerUUID, time);
String world = player.getWorld().getName();
Optional<GameMode> gameMode = player.getGameModeData().get(Keys.GAME_MODE);
String gm = gameMode.map(mode -> mode.getName().toUpperCase()).orElse("ADVENTURE");
Database database = dbSystem.getDatabase();
database.executeTransaction(new WorldNameStoreTransaction(serverUUID, world));
InetAddress address = player.getConnection().getAddress().getAddress();
Supplier<String> getHostName = () -> player.getConnection().getVirtualHost().getHostString();
String playerName = player.getName();
String displayName = player.getDisplayNameData().displayName().get().toPlain();
boolean gatheringGeolocations = config.isTrue(DataGatheringSettings.GEOLOCATIONS);
if (gatheringGeolocations) {
database.executeTransaction(new GeoInfoStoreTransaction(playerUUID, address, time, geolocationCache::getCountry));
}
database.executeTransaction(new PlayerServerRegisterTransaction(playerUUID, () -> time, playerName, serverUUID, getHostName));
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));
}
}
use of com.djrapitops.plan.identification.ServerUUID in project Plan by plan-player-analytics.
the class PlayerOnlineListener method actOnQuitEvent.
private void actOnQuitEvent(ServerPlayerEntity player) {
long time = System.currentTimeMillis();
String playerName = player.getEntityName();
UUID playerUUID = player.getUuid();
ServerUUID serverUUID = serverInfo.getServerUUID();
FabricAFKListener.afkTracker.loggedOut(playerUUID, time);
joinAddresses.remove(playerUUID);
nicknameCache.removeDisplayName(playerUUID);
dbSystem.getDatabase().executeTransaction(new BanStatusTransaction(playerUUID, serverUUID, () -> server.getPlayerManager().getUserBanList().contains(player.getGameProfile())));
sessionCache.endSession(playerUUID, time).ifPresent(endedSession -> dbSystem.getDatabase().executeTransaction(new SessionEndTransaction(endedSession)));
if (config.isTrue(ExportSettings.EXPORT_ON_ONLINE_STATUS_CHANGE)) {
processing.submitNonCritical(() -> exporter.exportPlayerPage(playerUUID, playerName));
}
}
use of com.djrapitops.plan.identification.ServerUUID in project Plan by plan-player-analytics.
the class PerServerMutator method favoriteServer.
public Optional<ServerUUID> favoriteServer() {
long max = 0;
ServerUUID maxServer = null;
for (Map.Entry<ServerUUID, DataContainer> entry : data.entrySet()) {
long total = SessionsMutator.forContainer(entry.getValue()).toPlaytime();
if (total > max) {
max = total;
maxServer = entry.getKey();
}
}
return Optional.ofNullable(maxServer);
}
use of com.djrapitops.plan.identification.ServerUUID in project Plan by plan-player-analytics.
the class PerServerContainer method putPing.
private void putPing(Ping ping) {
if (ping == null) {
return;
}
ServerUUID serverUUID = ping.getServerUUID();
DataContainer container = getOrDefault(serverUUID, new DynamicDataContainer());
if (!container.supports(PerServerKeys.PING)) {
container.putRawData(PerServerKeys.PING, new ArrayList<>());
}
container.getUnsafe(PerServerKeys.PING).add(ping);
put(serverUUID, container);
}
use of com.djrapitops.plan.identification.ServerUUID in project Plan by plan-player-analytics.
the class PerServerContainer method putUserInfo.
public void putUserInfo(UserInfo userInfo) {
ServerUUID serverUUID = userInfo.getServerUUID();
putToContainerOfServer(serverUUID, PerServerKeys.REGISTERED, userInfo.getRegistered());
putToContainerOfServer(serverUUID, PerServerKeys.BANNED, userInfo.isBanned());
putToContainerOfServer(serverUUID, PerServerKeys.OPERATOR, userInfo.isOperator());
putToContainerOfServer(serverUUID, PerServerKeys.JOIN_ADDRESS, userInfo.getJoinAddress());
}
Aggregations