use of com.djrapitops.plan.identification.ServerUUID in project Plan by plan-player-analytics.
the class ServerPreferencePie method turnToSlices.
private static List<PieSlice> turnToSlices(Map<ServerUUID, String> serverNames, Map<ServerUUID, WorldTimes> serverWorldTimes, String unknown) {
List<PieSlice> slices = new ArrayList<>();
for (Map.Entry<ServerUUID, WorldTimes> server : serverWorldTimes.entrySet()) {
ServerUUID serverUUID = server.getKey();
WorldTimes worldTimes = server.getValue();
String serverName = serverNames.getOrDefault(serverUUID, unknown);
long num = worldTimes.getTotal();
slices.add(new PieSlice(serverName, num));
}
return slices;
}
use of com.djrapitops.plan.identification.ServerUUID in project Plan by plan-player-analytics.
the class DataValueGatherer method storeExtensionInformation.
public void storeExtensionInformation() {
String pluginName = extension.getPluginName();
Icon pluginIcon = extension.getPluginIcon();
long time = System.currentTimeMillis();
ServerUUID serverUUID = serverInfo.getServerUUID();
Database database = dbSystem.getDatabase();
database.executeTransaction(new StoreIconTransaction(pluginIcon));
database.executeTransaction(new StorePluginTransaction(pluginName, time, serverUUID, pluginIcon));
for (TabInformation tab : extension.getPluginTabs()) {
database.executeTransaction(new StoreIconTransaction(tab.getTabIcon()));
database.executeTransaction(new StoreTabInformationTransaction(pluginName, serverUUID, tab));
}
database.executeTransaction(new RemoveInvalidResultsTransaction(pluginName, serverUUID, extension.getInvalidatedMethods()));
}
use of com.djrapitops.plan.identification.ServerUUID 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.identification.ServerUUID in project Plan by plan-player-analytics.
the class GraphsJSONResolver method getGraphJSON.
private JSONStorage.StoredJSON getGraphJSON(Request request, DataID dataID) {
Optional<Long> timestamp = Identifiers.getTimestamp(request);
JSONStorage.StoredJSON storedJSON;
if (request.getQuery().get("server").isPresent()) {
// Can throw BadRequestException
ServerUUID serverUUID = identifiers.getServerUUID(request);
storedJSON = jsonResolverService.resolve(timestamp, dataID, serverUUID, theServerUUID -> generateGraphDataJSONOfType(dataID, theServerUUID, request.getQuery()));
} else {
// Assume network
storedJSON = jsonResolverService.resolve(timestamp, dataID, () -> generateGraphDataJSONOfType(dataID));
}
return storedJSON;
}
use of com.djrapitops.plan.identification.ServerUUID in project Plan by plan-player-analytics.
the class PlayersTableJSONResolver method getStoredJSON.
private JSONStorage.StoredJSON getStoredJSON(Request request) {
Optional<Long> timestamp = Identifiers.getTimestamp(request);
JSONStorage.StoredJSON storedJSON;
if (request.getQuery().get("server").isPresent()) {
// Can throw BadRequestException
ServerUUID serverUUID = identifiers.getServerUUID(request);
storedJSON = jsonResolverService.resolve(timestamp, DataID.PLAYERS, serverUUID, jsonFactory::serverPlayersTableJSON);
} else {
// Assume players page
storedJSON = jsonResolverService.resolve(timestamp, DataID.PLAYERS, jsonFactory::networkPlayersTableJSON);
}
return storedJSON;
}
Aggregations