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;
}
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;
}
};
}
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;
}
};
}
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;
}
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;
}
Aggregations