Search in sources :

Example 6 with Lists

use of com.djrapitops.plan.utilities.java.Lists in project Plan by plan-player-analytics.

the class PlayersMutator method getPingPerCountry.

public Map<String, List<Ping>> getPingPerCountry(ServerUUID serverUUID) {
    Map<String, List<Ping>> pingPerCountry = new HashMap<>();
    for (PlayerContainer player : players) {
        Optional<GeoInfo> mostRecent = GeoInfoMutator.forContainer(player).mostRecent();
        if (!mostRecent.isPresent()) {
            continue;
        }
        List<Ping> pings = player.getValue(PlayerKeys.PING).orElse(new ArrayList<>());
        String country = mostRecent.get().getGeolocation();
        List<Ping> countryPings = pingPerCountry.computeIfAbsent(country, Lists::create);
        countryPings.addAll(new PingMutator(pings).filterByServer(serverUUID).all());
    }
    return pingPerCountry;
}
Also used : PlayerContainer(com.djrapitops.plan.delivery.domain.container.PlayerContainer) Lists(com.djrapitops.plan.utilities.java.Lists) Ping(com.djrapitops.plan.gathering.domain.Ping) GeoInfo(com.djrapitops.plan.gathering.domain.GeoInfo)

Example 7 with Lists

use of com.djrapitops.plan.utilities.java.Lists in project Plan by plan-player-analytics.

the class UserInfoQueries method fetchAllUserInformation.

/**
 * Query database for user information.
 * <p>
 * The user information does not contain player names.
 *
 * @return Map: Server UUID - List of user information
 */
public static Query<Map<ServerUUID, List<UserInfo>>> fetchAllUserInformation() {
    String sql = SELECT + "ux." + UserInfoTable.REGISTERED + ',' + UserInfoTable.BANNED + ',' + UserInfoTable.OP + ',' + "u." + UsersTable.USER_UUID + ',' + "s." + ServerTable.SERVER_UUID + " as server_uuid," + UserInfoTable.JOIN_ADDRESS + FROM + UserInfoTable.TABLE_NAME + " ux" + INNER_JOIN + UsersTable.TABLE_NAME + " u on u." + UsersTable.ID + '=' + "ux." + UserInfoTable.USER_ID + INNER_JOIN + ServerTable.TABLE_NAME + " s on s." + ServerTable.ID + '=' + "ux." + UserInfoTable.SERVER_ID;
    return new QueryAllStatement<Map<ServerUUID, List<UserInfo>>>(sql, 50000) {

        @Override
        public Map<ServerUUID, List<UserInfo>> processResults(ResultSet set) throws SQLException {
            Map<ServerUUID, List<UserInfo>> serverMap = new HashMap<>();
            while (set.next()) {
                ServerUUID serverUUID = ServerUUID.fromString(set.getString("server_uuid"));
                UUID uuid = UUID.fromString(set.getString(UsersTable.USER_UUID));
                List<UserInfo> userInfos = serverMap.computeIfAbsent(serverUUID, Lists::create);
                long registered = set.getLong(UserInfoTable.REGISTERED);
                boolean banned = set.getBoolean(UserInfoTable.BANNED);
                boolean op = set.getBoolean(UserInfoTable.OP);
                String joinAddress = set.getString(UserInfoTable.JOIN_ADDRESS);
                userInfos.add(new UserInfo(uuid, serverUUID, registered, op, joinAddress, banned));
            }
            return serverMap;
        }
    };
}
Also used : ServerUUID(com.djrapitops.plan.identification.ServerUUID) UserInfo(com.djrapitops.plan.gathering.domain.UserInfo) QueryAllStatement(com.djrapitops.plan.storage.database.queries.QueryAllStatement) Lists(com.djrapitops.plan.utilities.java.Lists) ResultSet(java.sql.ResultSet) ServerUUID(com.djrapitops.plan.identification.ServerUUID)

Example 8 with Lists

use of com.djrapitops.plan.utilities.java.Lists in project Plan by plan-player-analytics.

the class ExtensionInformationQueries method allExtensions.

public static Query<Map<ServerUUID, List<ExtensionInformation>>> allExtensions() {
    String sql = SELECT + ExtensionPluginTable.TABLE_NAME + '.' + ExtensionPluginTable.ID + " as id," + ExtensionPluginTable.TABLE_NAME + '.' + ExtensionPluginTable.PLUGIN_NAME + " as plugin_name," + ExtensionPluginTable.SERVER_UUID + ',' + ExtensionIconTable.TABLE_NAME + '.' + ExtensionIconTable.ICON_NAME + " as icon_name," + ExtensionIconTable.COLOR + ',' + ExtensionIconTable.FAMILY + FROM + ExtensionPluginTable.TABLE_NAME + INNER_JOIN + ExtensionIconTable.TABLE_NAME + " on " + ExtensionPluginTable.ICON_ID + "=" + ExtensionIconTable.TABLE_NAME + '.' + ExtensionIconTable.ID;
    return new QueryAllStatement<Map<ServerUUID, List<ExtensionInformation>>>(sql, 100) {

        @Override
        public Map<ServerUUID, List<ExtensionInformation>> processResults(ResultSet set) throws SQLException {
            Map<ServerUUID, List<ExtensionInformation>> byServerUUID = new HashMap<>();
            while (set.next()) {
                ServerUUID serverUUID = ServerUUID.fromString(set.getString(ExtensionPluginTable.SERVER_UUID));
                List<ExtensionInformation> information = byServerUUID.computeIfAbsent(serverUUID, Lists::create);
                information.add(extractExtensionInformationFromQuery(set));
            }
            return byServerUUID;
        }
    };
}
Also used : QueryAllStatement(com.djrapitops.plan.storage.database.queries.QueryAllStatement) ServerUUID(com.djrapitops.plan.identification.ServerUUID) HashMap(java.util.HashMap) Lists(com.djrapitops.plan.utilities.java.Lists) ResultSet(java.sql.ResultSet) ArrayList(java.util.ArrayList) List(java.util.List) ExtensionInformation(com.djrapitops.plan.extension.implementation.results.ExtensionInformation)

Example 9 with Lists

use of com.djrapitops.plan.utilities.java.Lists in project Plan by plan-player-analytics.

the class ExtensionPlayerDataQuery method flatMapByServerUUID.

private Map<ServerUUID, List<ExtensionData>> flatMapByServerUUID(Map<ServerUUID, List<ExtensionInformation>> extensionsByServerUUID, Map<Integer, ExtensionData.Builder> extensionDataByPluginID) {
    Map<ServerUUID, List<ExtensionData>> extensionDataByServerUUID = new HashMap<>();
    for (Map.Entry<ServerUUID, List<ExtensionInformation>> entry : extensionsByServerUUID.entrySet()) {
        ServerUUID serverUUID = entry.getKey();
        for (ExtensionInformation extensionInformation : entry.getValue()) {
            ExtensionData.Builder data = extensionDataByPluginID.get(extensionInformation.getId());
            if (data == null) {
                continue;
            }
            List<ExtensionData> list = extensionDataByServerUUID.computeIfAbsent(serverUUID, Lists::create);
            list.add(data.setInformation(extensionInformation).build());
        }
    }
    return extensionDataByServerUUID;
}
Also used : ServerUUID(com.djrapitops.plan.identification.ServerUUID) Lists(com.djrapitops.plan.utilities.java.Lists)

Example 10 with Lists

use of com.djrapitops.plan.utilities.java.Lists in project Plan by plan-player-analytics.

the class SessionsMutator method sortByPlayers.

public static Map<UUID, List<FinishedSession>> sortByPlayers(List<FinishedSession> sessions) {
    Map<UUID, List<FinishedSession>> sorted = new HashMap<>();
    for (FinishedSession session : sessions) {
        UUID playerUUID = session.getPlayerUUID();
        List<FinishedSession> playerSessions = sorted.computeIfAbsent(playerUUID, Lists::create);
        playerSessions.add(session);
        sorted.put(playerUUID, playerSessions);
    }
    return sorted;
}
Also used : Lists(com.djrapitops.plan.utilities.java.Lists) ServerUUID(com.djrapitops.plan.identification.ServerUUID)

Aggregations

Lists (com.djrapitops.plan.utilities.java.Lists)13 ServerUUID (com.djrapitops.plan.identification.ServerUUID)11 ResultSet (java.sql.ResultSet)6 QueryAllStatement (com.djrapitops.plan.storage.database.queries.QueryAllStatement)3 Nickname (com.djrapitops.plan.delivery.domain.Nickname)2 GeoInfo (com.djrapitops.plan.gathering.domain.GeoInfo)2 Ping (com.djrapitops.plan.gathering.domain.Ping)2 TPS (com.djrapitops.plan.gathering.domain.TPS)2 QueryStatement (com.djrapitops.plan.storage.database.queries.QueryStatement)2 PreparedStatement (java.sql.PreparedStatement)2 HashMap (java.util.HashMap)2 List (java.util.List)2 PlayerContainer (com.djrapitops.plan.delivery.domain.container.PlayerContainer)1 ExtensionInformation (com.djrapitops.plan.extension.implementation.results.ExtensionInformation)1 FinishedSession (com.djrapitops.plan.gathering.domain.FinishedSession)1 UserInfo (com.djrapitops.plan.gathering.domain.UserInfo)1 Maps (com.djrapitops.plan.utilities.java.Maps)1 ArrayList (java.util.ArrayList)1