Search in sources :

Example 6 with ServerName

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));
        }
    });
}
Also used : ProxiedPlayer(net.md_5.bungee.api.connection.ProxiedPlayer) ActiveSession(com.djrapitops.plan.gathering.domain.ActiveSession) StoreGeoInfoTransaction(com.djrapitops.plan.storage.database.transactions.events.StoreGeoInfoTransaction) PlayerName(com.djrapitops.plan.delivery.domain.PlayerName) ServerName(com.djrapitops.plan.delivery.domain.ServerName) Database(com.djrapitops.plan.storage.database.Database) PlayerRegisterTransaction(com.djrapitops.plan.storage.database.transactions.events.PlayerRegisterTransaction) UUID(java.util.UUID) InetAddress(java.net.InetAddress)

Example 7 with ServerName

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));
    }
}
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) UUID(java.util.UUID)

Example 8 with ServerName

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));
        }
    });
}
Also used : PlayerLoginEvent(cn.nukkit.event.player.PlayerLoginEvent) PlanConfig(com.djrapitops.plan.settings.config.PlanConfig) NicknameCache(com.djrapitops.plan.gathering.cache.NicknameCache) Exporter(com.djrapitops.plan.delivery.export.Exporter) PlayerName(com.djrapitops.plan.delivery.domain.PlayerName) ServerUUID(com.djrapitops.plan.identification.ServerUUID) DataGatheringSettings(com.djrapitops.plan.settings.config.paths.DataGatheringSettings) Supplier(java.util.function.Supplier) Database(com.djrapitops.plan.storage.database.Database) DBSystem(com.djrapitops.plan.storage.database.DBSystem) Inject(javax.inject.Inject) InetAddress(java.net.InetAddress) GMTimes(com.djrapitops.plan.gathering.domain.GMTimes) PlayerJoinEvent(cn.nukkit.event.player.PlayerJoinEvent) ExtensionSvc(com.djrapitops.plan.extension.ExtensionSvc) SessionCache(com.djrapitops.plan.gathering.cache.SessionCache) ActiveSession(com.djrapitops.plan.gathering.domain.ActiveSession) EventPriority(cn.nukkit.event.EventPriority) ErrorContext(com.djrapitops.plan.utilities.logging.ErrorContext) PlayerKickEvent(cn.nukkit.event.player.PlayerKickEvent) ServerName(com.djrapitops.plan.delivery.domain.ServerName) ServerInfo(com.djrapitops.plan.identification.ServerInfo) ExportSettings(com.djrapitops.plan.settings.config.paths.ExportSettings) UUID(java.util.UUID) EventHandler(cn.nukkit.event.EventHandler) Listener(cn.nukkit.event.Listener) TimeUnit(java.util.concurrent.TimeUnit) Status(com.djrapitops.plan.gathering.listeners.Status) ErrorLogger(com.djrapitops.plan.utilities.logging.ErrorLogger) com.djrapitops.plan.storage.database.transactions.events(com.djrapitops.plan.storage.database.transactions.events) Player(cn.nukkit.Player) PlayerQuitEvent(cn.nukkit.event.player.PlayerQuitEvent) CallEvents(com.djrapitops.plan.extension.CallEvents) Processing(com.djrapitops.plan.processing.Processing) GeolocationCache(com.djrapitops.plan.gathering.geolocation.GeolocationCache) Nickname(com.djrapitops.plan.delivery.domain.Nickname) Player(cn.nukkit.Player) ServerUUID(com.djrapitops.plan.identification.ServerUUID) 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) ServerUUID(com.djrapitops.plan.identification.ServerUUID) UUID(java.util.UUID) InetAddress(java.net.InetAddress) Nickname(com.djrapitops.plan.delivery.domain.Nickname)

Example 9 with ServerName

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));
        }
    });
}
Also used : PlanConfig(com.djrapitops.plan.settings.config.PlanConfig) NicknameCache(com.djrapitops.plan.gathering.cache.NicknameCache) Keys(org.spongepowered.api.data.key.Keys) KickPlayerEvent(org.spongepowered.api.event.entity.living.humanoid.player.KickPlayerEvent) Exporter(com.djrapitops.plan.delivery.export.Exporter) PlayerName(com.djrapitops.plan.delivery.domain.PlayerName) ServerUUID(com.djrapitops.plan.identification.ServerUUID) JoinAddress(com.djrapitops.plan.gathering.domain.event.JoinAddress) DataGatheringSettings(com.djrapitops.plan.settings.config.paths.DataGatheringSettings) Supplier(java.util.function.Supplier) Database(com.djrapitops.plan.storage.database.Database) DBSystem(com.djrapitops.plan.storage.database.DBSystem) Inject(javax.inject.Inject) InetAddress(java.net.InetAddress) ProviderRegistration(org.spongepowered.api.service.ProviderRegistration) Order(org.spongepowered.api.event.Order) ExtensionSvc(com.djrapitops.plan.extension.ExtensionSvc) SessionCache(com.djrapitops.plan.gathering.cache.SessionCache) ActiveSession(com.djrapitops.plan.gathering.domain.ActiveSession) GameProfile(org.spongepowered.api.profile.GameProfile) ErrorContext(com.djrapitops.plan.utilities.logging.ErrorContext) ServerName(com.djrapitops.plan.delivery.domain.ServerName) ServerInfo(com.djrapitops.plan.identification.ServerInfo) ExportSettings(com.djrapitops.plan.settings.config.paths.ExportSettings) Sponge(org.spongepowered.api.Sponge) UUID(java.util.UUID) ClientConnectionEvent(org.spongepowered.api.event.network.ClientConnectionEvent) Status(com.djrapitops.plan.gathering.listeners.Status) ErrorLogger(com.djrapitops.plan.utilities.logging.ErrorLogger) com.djrapitops.plan.storage.database.transactions.events(com.djrapitops.plan.storage.database.transactions.events) GameMode(org.spongepowered.api.entity.living.player.gamemode.GameMode) CallEvents(com.djrapitops.plan.extension.CallEvents) Optional(java.util.Optional) Player(org.spongepowered.api.entity.living.player.Player) Processing(com.djrapitops.plan.processing.Processing) Listener(org.spongepowered.api.event.Listener) GeolocationCache(com.djrapitops.plan.gathering.geolocation.GeolocationCache) Nickname(com.djrapitops.plan.delivery.domain.Nickname) BanService(org.spongepowered.api.service.ban.BanService) Player(org.spongepowered.api.entity.living.player.Player) ServerUUID(com.djrapitops.plan.identification.ServerUUID) GameMode(org.spongepowered.api.entity.living.player.gamemode.GameMode) 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) ServerUUID(com.djrapitops.plan.identification.ServerUUID) UUID(java.util.UUID) JoinAddress(com.djrapitops.plan.gathering.domain.event.JoinAddress) InetAddress(java.net.InetAddress) Nickname(com.djrapitops.plan.delivery.domain.Nickname)

Aggregations

PlayerName (com.djrapitops.plan.delivery.domain.PlayerName)9 ServerName (com.djrapitops.plan.delivery.domain.ServerName)9 ActiveSession (com.djrapitops.plan.gathering.domain.ActiveSession)8 UUID (java.util.UUID)8 Database (com.djrapitops.plan.storage.database.Database)6 InetAddress (java.net.InetAddress)6 ServerUUID (com.djrapitops.plan.identification.ServerUUID)5 Nickname (com.djrapitops.plan.delivery.domain.Nickname)4 Exporter (com.djrapitops.plan.delivery.export.Exporter)4 CallEvents (com.djrapitops.plan.extension.CallEvents)4 ExtensionSvc (com.djrapitops.plan.extension.ExtensionSvc)4 NicknameCache (com.djrapitops.plan.gathering.cache.NicknameCache)4 SessionCache (com.djrapitops.plan.gathering.cache.SessionCache)4 JoinAddress (com.djrapitops.plan.gathering.domain.event.JoinAddress)4 GeolocationCache (com.djrapitops.plan.gathering.geolocation.GeolocationCache)4 ServerInfo (com.djrapitops.plan.identification.ServerInfo)4 Processing (com.djrapitops.plan.processing.Processing)4 PlanConfig (com.djrapitops.plan.settings.config.PlanConfig)4 DataGatheringSettings (com.djrapitops.plan.settings.config.paths.DataGatheringSettings)4 ExportSettings (com.djrapitops.plan.settings.config.paths.ExportSettings)4