Search in sources :

Example 11 with Lists

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

the class SessionsMutator method sortByServers.

public static Map<ServerUUID, List<FinishedSession>> sortByServers(List<FinishedSession> sessions) {
    Map<ServerUUID, List<FinishedSession>> sorted = new HashMap<>();
    for (FinishedSession session : sessions) {
        ServerUUID serverUUID = session.getServerUUID();
        List<FinishedSession> serverSessions = sorted.computeIfAbsent(serverUUID, Lists::create);
        serverSessions.add(session);
    }
    return sorted;
}
Also used : ServerUUID(com.djrapitops.plan.identification.ServerUUID) Lists(com.djrapitops.plan.utilities.java.Lists)

Example 12 with Lists

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

the class PlayerCalendar method getSessionsByDay.

private Map<String, List<FinishedSession>> getSessionsByDay() {
    Map<String, List<FinishedSession>> sessionsByDay = new HashMap<>();
    for (FinishedSession session : allSessions) {
        String day = iso8601Formatter.apply(session.getDate());
        List<FinishedSession> sessionsOfDay = sessionsByDay.computeIfAbsent(day, Lists::create);
        sessionsOfDay.add(session);
    }
    return sessionsByDay;
}
Also used : FinishedSession(com.djrapitops.plan.gathering.domain.FinishedSession) Lists(com.djrapitops.plan.utilities.java.Lists)

Example 13 with Lists

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

the class NicknameQueries method fetchNicknameDataOfServer.

/**
 * Query database for nickname information of a server.
 *
 * @param serverUUID UUID the the Plan server.
 * @return Map: Player UUID - List of Nicknames on the server.
 */
public static Query<Map<UUID, List<Nickname>>> fetchNicknameDataOfServer(ServerUUID serverUUID) {
    String sql = SELECT + NicknamesTable.NICKNAME + ',' + NicknamesTable.LAST_USED + ',' + NicknamesTable.USER_UUID + FROM + NicknamesTable.TABLE_NAME + WHERE + NicknamesTable.SERVER_UUID + "=?";
    return new QueryStatement<Map<UUID, List<Nickname>>>(sql, 5000) {

        @Override
        public void prepare(PreparedStatement statement) throws SQLException {
            statement.setString(1, serverUUID.toString());
        }

        @Override
        public Map<UUID, List<Nickname>> processResults(ResultSet set) throws SQLException {
            Map<UUID, List<Nickname>> serverMap = new HashMap<>();
            while (set.next()) {
                UUID uuid = UUID.fromString(set.getString(NicknamesTable.USER_UUID));
                List<Nickname> nicknames = serverMap.computeIfAbsent(uuid, Lists::create);
                nicknames.add(new Nickname(set.getString(NicknamesTable.NICKNAME), set.getLong(NicknamesTable.LAST_USED), serverUUID));
            }
            return serverMap;
        }
    };
}
Also used : Lists(com.djrapitops.plan.utilities.java.Lists) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) QueryStatement(com.djrapitops.plan.storage.database.queries.QueryStatement) ServerUUID(com.djrapitops.plan.identification.ServerUUID) Nickname(com.djrapitops.plan.delivery.domain.Nickname)

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