use of com.djrapitops.plan.delivery.domain.ServerName in project Plan by plan-player-analytics.
the class PlayerOnlineListener method actOnLogin.
private void actOnLogin(PostLoginEvent event) {
ProxiedPlayer player = event.getPlayer();
UUID playerUUID = player.getUniqueId();
String playerName = player.getName();
InetAddress address = player.getAddress().getAddress();
long time = System.currentTimeMillis();
ActiveSession session = new ActiveSession(playerUUID, serverInfo.getServerUUID(), time, null, null);
session.getExtraData().put(PlayerName.class, new PlayerName(playerName));
session.getExtraData().put(ServerName.class, new ServerName("Proxy Server"));
sessionCache.cacheSession(playerUUID, session);
Database database = dbSystem.getDatabase();
database.executeTransaction(new PlayerRegisterTransaction(playerUUID, () -> time, playerName)).thenRunAsync(() -> {
boolean gatheringGeolocations = config.isTrue(DataGatheringSettings.GEOLOCATIONS);
if (gatheringGeolocations) {
database.executeTransaction(new StoreGeoInfoTransaction(playerUUID, address, time, geolocationCache::getCountry));
}
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.delivery.domain.ServerName in project Plan by plan-player-analytics.
the class PlayerOnlineListener method actOnServerSwitch.
private void actOnServerSwitch(ServerSwitchEvent event) {
ProxiedPlayer player = event.getPlayer();
String playerName = player.getName();
UUID playerUUID = player.getUniqueId();
long time = System.currentTimeMillis();
// Replaces the current session in the cache.
ActiveSession session = new ActiveSession(playerUUID, serverInfo.getServerUUID(), time, null, null);
session.getExtraData().put(PlayerName.class, new PlayerName(playerName));
session.getExtraData().put(ServerName.class, new ServerName("Proxy Server"));
sessionCache.cacheSession(playerUUID, session);
if (config.isTrue(ExportSettings.EXPORT_ON_ONLINE_STATUS_CHANGE)) {
processing.submitNonCritical(() -> exporter.exportPlayerPage(playerUUID, playerName));
}
}
use of com.djrapitops.plan.delivery.domain.ServerName 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();
NukkitAFKListener.afkTracker.performedAction(playerUUID, time);
String world = player.getLevel().getName();
String gm = GMTimes.magicNumberToGMName(player.getGamemode());
Database database = dbSystem.getDatabase();
database.executeTransaction(new WorldNameStoreTransaction(serverUUID, world));
InetAddress address = player.getSocketAddress().getAddress();
Supplier<String> getHostName = () -> null;
String playerName = player.getName();
String displayName = player.getDisplayName();
long registerDate = TimeUnit.SECONDS.toMillis(player.getFirstPlayed());
database.executeTransaction(new PlayerServerRegisterTransaction(playerUUID, () -> registerDate, playerName, serverUUID, getHostName)).thenRunAsync(() -> {
boolean gatheringGeolocations = config.isTrue(DataGatheringSettings.GEOLOCATIONS);
if (gatheringGeolocations) {
database.executeTransaction(new StoreGeoInfoTransaction(playerUUID, address, time, geolocationCache::getCountry));
}
dbSystem.getDatabase().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).map(StoreSessionTransaction::new).ifPresent(database::executeTransaction);
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.delivery.domain.ServerName 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();
database.executeTransaction(new PlayerServerRegisterTransaction(playerUUID, () -> time, playerName, serverUUID, getHostName)).thenRunAsync(() -> {
boolean gatheringGeolocations = config.isTrue(DataGatheringSettings.GEOLOCATIONS);
if (gatheringGeolocations) {
database.executeTransaction(new StoreGeoInfoTransaction(playerUUID, address, time, geolocationCache::getCountry));
}
database.executeTransaction(new StoreJoinAddressTransaction(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()));
session.getExtraData().put(JoinAddress.class, new JoinAddress(getHostName));
sessionCache.cacheSession(playerUUID, session).map(StoreSessionTransaction::new).ifPresent(database::executeTransaction);
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));
}
});
}
Aggregations