use of com.djrapitops.plan.extension.implementation.results.ExtensionInformation in project Plan by plan-player-analytics.
the class ExtensionInformationQueries method extractExtensionInformationFromQuery.
private static ExtensionInformation extractExtensionInformationFromQuery(ResultSet set) throws SQLException {
int id = set.getInt("id");
String pluginName = set.getString("plugin_name");
String iconName = set.getString("icon_name");
Family iconFamily = Family.getByName(set.getString(ExtensionIconTable.FAMILY)).orElse(Family.SOLID);
Color color = Color.getByName(set.getString(ExtensionIconTable.COLOR)).orElse(Color.NONE);
Icon icon = new Icon(iconFamily, iconName, color);
return new ExtensionInformation(id, pluginName, icon);
}
use of com.djrapitops.plan.extension.implementation.results.ExtensionInformation 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;
}
};
}
Aggregations