Search in sources :

Example 1 with ExtensionInformation

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);
}
Also used : Color(com.djrapitops.plan.extension.icon.Color) Family(com.djrapitops.plan.extension.icon.Family) Icon(com.djrapitops.plan.extension.icon.Icon) ExtensionInformation(com.djrapitops.plan.extension.implementation.results.ExtensionInformation)

Example 2 with ExtensionInformation

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

Aggregations

ExtensionInformation (com.djrapitops.plan.extension.implementation.results.ExtensionInformation)2 Color (com.djrapitops.plan.extension.icon.Color)1 Family (com.djrapitops.plan.extension.icon.Family)1 Icon (com.djrapitops.plan.extension.icon.Icon)1 ServerUUID (com.djrapitops.plan.identification.ServerUUID)1 QueryAllStatement (com.djrapitops.plan.storage.database.queries.QueryAllStatement)1 Lists (com.djrapitops.plan.utilities.java.Lists)1 ResultSet (java.sql.ResultSet)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1