use of com.djrapitops.plan.gathering.domain.ActiveSession in project Plan by plan-player-analytics.
the class PlayerKillProcessor method run.
@Override
public void run() {
Optional<ActiveSession> cachedSession = SessionCache.getCachedSession(killer.getUuid());
if (!cachedSession.isPresent()) {
return;
}
ActiveSession session = cachedSession.get();
session.addPlayerKill(new PlayerKill(killer, victim, server, weaponName, time));
}
use of com.djrapitops.plan.gathering.domain.ActiveSession in project Plan by plan-player-analytics.
the class SpongeGMChangeListener method actOnGMChangeEvent.
private void actOnGMChangeEvent(ChangeGameModeEvent.TargetPlayer event) {
Player player = event.getTargetEntity();
UUID uuid = player.getUniqueId();
long time = System.currentTimeMillis();
String gameMode = event.getGameMode().getName().toUpperCase();
String worldName = player.getWorld().getName();
dbSystem.getDatabase().executeTransaction(new WorldNameStoreTransaction(serverInfo.getServerUUID(), worldName));
worldAliasSettings.addWorld(worldName);
Optional<ActiveSession> cachedSession = SessionCache.getCachedSession(uuid);
cachedSession.ifPresent(session -> session.changeState(worldName, gameMode, time));
}
use of com.djrapitops.plan.gathering.domain.ActiveSession in project Plan by plan-player-analytics.
the class PlayerOnlineListener method actOnJoinEvent.
private void actOnJoinEvent(ServerPlayerEntity player) {
UUID playerUUID = player.getUuid();
ServerUUID serverUUID = serverInfo.getServerUUID();
long time = System.currentTimeMillis();
FabricAFKListener.afkTracker.performedAction(playerUUID, time);
String world = player.getServerWorld().getRegistryKey().getValue().toString();
String gm = player.interactionManager.getGameMode().name();
Database database = dbSystem.getDatabase();
database.executeTransaction(new WorldNameStoreTransaction(serverUUID, world));
InetSocketAddress socketAddress = (InetSocketAddress) player.networkHandler.connection.getAddress();
InetAddress address = InetAddresses.forString(socketAddress.getAddress().toString().replace("/", ""));
Supplier<String> getHostName = () -> getHostname(player);
String playerName = player.getEntityName();
String displayName = player.getDisplayName().asString();
boolean gatheringGeolocations = config.isTrue(DataGatheringSettings.GEOLOCATIONS);
if (gatheringGeolocations) {
database.executeTransaction(new GeoInfoStoreTransaction(playerUUID, address, time, geolocationCache::getCountry));
}
database.executeTransaction(new PlayerServerRegisterTransaction(playerUUID, System::currentTimeMillis, playerName, serverUUID, getHostName));
database.executeTransaction(new OperatorStatusTransaction(playerUUID, serverUUID, server.getPlayerManager().getOpList().isOp(player.getGameProfile())));
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.gathering.domain.ActiveSession in project Plan by plan-player-analytics.
the class SpongeDeathListener method onEntityDeath.
@Listener
public void onEntityDeath(DestructEntityEvent.Death event) {
long time = System.currentTimeMillis();
Living dead = event.getTargetEntity();
if (dead instanceof Player) {
// Process Death
SessionCache.getCachedSession(dead.getUniqueId()).ifPresent(ActiveSession::addDeath);
}
try {
List<EntityDamageSource> causes = event.getCause().allOf(EntityDamageSource.class);
Optional<Player> foundKiller = findKiller(causes, 0);
if (!foundKiller.isPresent()) {
return;
}
Player killer = foundKiller.get();
Runnable processor = dead instanceof Player ? new PlayerKillProcessor(getKiller(killer), getVictim((Player) dead), serverInfo.getServerIdentifier(), findWeapon(event), time) : new MobKillProcessor(killer.getUniqueId());
processing.submitCritical(processor);
} catch (Exception e) {
errorLogger.error(e, ErrorContext.builder().related(event, dead).build());
}
}
use of com.djrapitops.plan.gathering.domain.ActiveSession in project Plan by plan-player-analytics.
the class GameModeChangeListener method actOnEvent.
private void actOnEvent(PlayerGameModeChangeEvent event) {
Player player = event.getPlayer();
UUID uuid = player.getUniqueId();
long time = System.currentTimeMillis();
String gameMode = GMTimes.magicNumberToGMName(event.getNewGamemode());
String worldName = player.getLevel().getName();
dbSystem.getDatabase().executeTransaction(new WorldNameStoreTransaction(serverInfo.getServerUUID(), worldName));
worldAliasSettings.addWorld(worldName);
Optional<ActiveSession> cachedSession = SessionCache.getCachedSession(uuid);
cachedSession.ifPresent(session -> session.changeState(worldName, gameMode, time));
}
Aggregations