Search in sources :

Example 1 with GeoInfoStoreTransaction

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

the class PlayerOnlineListener method actOnLogin.

public void actOnLogin(PostLoginEvent event) {
    Player player = event.getPlayer();
    UUID playerUUID = player.getUniqueId();
    String playerName = player.getUsername();
    InetAddress address = player.getRemoteAddress().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();
    boolean gatheringGeolocations = config.isTrue(DataGatheringSettings.GEOLOCATIONS);
    if (gatheringGeolocations) {
        database.executeTransaction(new GeoInfoStoreTransaction(playerUUID, address, time, geolocationCache::getCountry));
    }
    database.executeTransaction(new PlayerRegisterTransaction(playerUUID, () -> time, playerName));
    processing.submitNonCritical(() -> extensionService.updatePlayerValues(playerUUID, playerName, CallEvents.PLAYER_JOIN));
    if (config.isTrue(ExportSettings.EXPORT_ON_ONLINE_STATUS_CHANGE)) {
        processing.submitNonCritical(() -> exporter.exportPlayerPage(playerUUID, playerName));
    }
}
Also used : Player(com.velocitypowered.api.proxy.Player) ActiveSession(com.djrapitops.plan.gathering.domain.ActiveSession) PlayerName(com.djrapitops.plan.delivery.domain.PlayerName) ServerName(com.djrapitops.plan.delivery.domain.ServerName) Database(com.djrapitops.plan.storage.database.Database) GeoInfoStoreTransaction(com.djrapitops.plan.storage.database.transactions.events.GeoInfoStoreTransaction) PlayerRegisterTransaction(com.djrapitops.plan.storage.database.transactions.events.PlayerRegisterTransaction) UUID(java.util.UUID) InetAddress(java.net.InetAddress)

Example 2 with GeoInfoStoreTransaction

use of com.djrapitops.plan.storage.database.transactions.events.GeoInfoStoreTransaction 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();
    boolean gatheringGeolocations = config.isTrue(DataGatheringSettings.GEOLOCATIONS);
    if (gatheringGeolocations) {
        database.executeTransaction(new GeoInfoStoreTransaction(playerUUID, address, time, geolocationCache::getCountry));
    }
    database.executeTransaction(new PlayerRegisterTransaction(playerUUID, () -> time, playerName));
    processing.submitNonCritical(() -> extensionService.updatePlayerValues(playerUUID, playerName, CallEvents.PLAYER_JOIN));
    if (config.isTrue(ExportSettings.EXPORT_ON_ONLINE_STATUS_CHANGE)) {
        processing.submitNonCritical(() -> exporter.exportPlayerPage(playerUUID, playerName));
    }
}
Also used : ProxiedPlayer(net.md_5.bungee.api.connection.ProxiedPlayer) ActiveSession(com.djrapitops.plan.gathering.domain.ActiveSession) PlayerName(com.djrapitops.plan.delivery.domain.PlayerName) ServerName(com.djrapitops.plan.delivery.domain.ServerName) Database(com.djrapitops.plan.storage.database.Database) GeoInfoStoreTransaction(com.djrapitops.plan.storage.database.transactions.events.GeoInfoStoreTransaction) PlayerRegisterTransaction(com.djrapitops.plan.storage.database.transactions.events.PlayerRegisterTransaction) UUID(java.util.UUID) InetAddress(java.net.InetAddress)

Aggregations

PlayerName (com.djrapitops.plan.delivery.domain.PlayerName)2 ServerName (com.djrapitops.plan.delivery.domain.ServerName)2 ActiveSession (com.djrapitops.plan.gathering.domain.ActiveSession)2 Database (com.djrapitops.plan.storage.database.Database)2 GeoInfoStoreTransaction (com.djrapitops.plan.storage.database.transactions.events.GeoInfoStoreTransaction)2 PlayerRegisterTransaction (com.djrapitops.plan.storage.database.transactions.events.PlayerRegisterTransaction)2 InetAddress (java.net.InetAddress)2 UUID (java.util.UUID)2 Player (com.velocitypowered.api.proxy.Player)1 ProxiedPlayer (net.md_5.bungee.api.connection.ProxiedPlayer)1