Search in sources :

Example 66 with ServerUUID

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));
    }
}
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) 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) InetAddress(java.net.InetAddress) Nickname(com.djrapitops.plan.delivery.domain.Nickname)

Example 67 with ServerUUID

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));
    }
}
Also used : ServerUUID(com.djrapitops.plan.identification.ServerUUID) ServerUUID(com.djrapitops.plan.identification.ServerUUID) UUID(java.util.UUID)

Example 68 with ServerUUID

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);
}
Also used : ServerUUID(com.djrapitops.plan.identification.ServerUUID) DataContainer(com.djrapitops.plan.delivery.domain.container.DataContainer)

Example 69 with ServerUUID

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);
}
Also used : ServerUUID(com.djrapitops.plan.identification.ServerUUID)

Example 70 with ServerUUID

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());
}
Also used : ServerUUID(com.djrapitops.plan.identification.ServerUUID)

Aggregations

ServerUUID (com.djrapitops.plan.identification.ServerUUID)105 UUID (java.util.UUID)26 ResultSet (java.sql.ResultSet)23 PreparedStatement (java.sql.PreparedStatement)21 Database (com.djrapitops.plan.storage.database.Database)17 Test (org.junit.jupiter.api.Test)17 FinishedSession (com.djrapitops.plan.gathering.domain.FinishedSession)14 WorldTimes (com.djrapitops.plan.gathering.domain.WorldTimes)12 Nickname (com.djrapitops.plan.delivery.domain.Nickname)11 ActiveSession (com.djrapitops.plan.gathering.domain.ActiveSession)11 Server (com.djrapitops.plan.identification.Server)11 HashMap (java.util.HashMap)11 ExtensionSvc (com.djrapitops.plan.extension.ExtensionSvc)9 PlanConfig (com.djrapitops.plan.settings.config.PlanConfig)9 QueryStatement (com.djrapitops.plan.storage.database.queries.QueryStatement)9 WorldNameStoreTransaction (com.djrapitops.plan.storage.database.transactions.events.WorldNameStoreTransaction)9 Lists (com.djrapitops.plan.utilities.java.Lists)9 CallEvents (com.djrapitops.plan.extension.CallEvents)8 List (java.util.List)8 Map (java.util.Map)8