Search in sources :

Example 1 with StaffSettings

use of cc.hyperium.utils.staff.StaffSettings in project Hyperium by HyperiumClient.

the class StaffUtils method getBoosters.

private static HashMap<UUID, StaffSettings> getBoosters() throws IOException {
    HashMap<UUID, StaffSettings> boosters = new HashMap<>();
    String raw = HttpUtil.get(new URL("https://api.github.com/gists/b070e7f75a9083d2e211caffa0c772cc"));
    String content = new JsonHolder(raw).optJSONObject("files").optJSONObject("boosters.json").optString("content");
    JsonParser parser = new JsonParser();
    JsonArray array = parser.parse(content).getAsJsonArray();
    int bound = array.size();
    for (int i = 0; i < bound; i++) {
        JsonObject item = array.get(i).getAsJsonObject();
        UUID uuid = UUID.fromString(item.get("uuid").getAsString());
        String colourStr = item.get("color").getAsString().toUpperCase();
        DotColour colour = colourStr.equals("CHROMA") ? new DotColour(true, ChatColor.WHITE) : new DotColour(false, ChatColor.valueOf(colourStr));
        boosters.put(uuid, new StaffSettings(colour));
    }
    return boosters;
}
Also used : JsonHolder(cc.hyperium.utils.JsonHolder) JsonArray(com.google.gson.JsonArray) StaffSettings(cc.hyperium.utils.staff.StaffSettings) HashMap(java.util.HashMap) JsonObject(com.google.gson.JsonObject) UUID(java.util.UUID) URL(java.net.URL) JsonParser(com.google.gson.JsonParser)

Example 2 with StaffSettings

use of cc.hyperium.utils.staff.StaffSettings in project Hyperium by HyperiumClient.

the class StaffUtils method getStaff.

private static HashMap<UUID, StaffSettings> getStaff() throws IOException {
    HashMap<UUID, StaffSettings> staff = new HashMap<>();
    String content = HttpUtil.get(new URL("https://raw.githubusercontent.com/HyperiumClient/Hyperium-Repo/master/files/staff.json"));
    JsonParser parser = new JsonParser();
    JsonArray array = parser.parse(content).getAsJsonArray();
    int bound = array.size();
    for (int i = 0; i < bound; i++) {
        JsonObject item = array.get(i).getAsJsonObject();
        UUID uuid = UUID.fromString(item.get("uuid").getAsString());
        String colourStr = item.get("color").getAsString().toUpperCase();
        DotColour colour = colourStr.equals("CHROMA") ? new DotColour(true, ChatColor.WHITE) : new DotColour(false, ChatColor.valueOf(colourStr));
        staff.put(uuid, new StaffSettings(colour));
    }
    return staff;
}
Also used : JsonArray(com.google.gson.JsonArray) StaffSettings(cc.hyperium.utils.staff.StaffSettings) HashMap(java.util.HashMap) JsonObject(com.google.gson.JsonObject) UUID(java.util.UUID) URL(java.net.URL) JsonParser(com.google.gson.JsonParser)

Aggregations

StaffSettings (cc.hyperium.utils.staff.StaffSettings)2 JsonArray (com.google.gson.JsonArray)2 JsonObject (com.google.gson.JsonObject)2 JsonParser (com.google.gson.JsonParser)2 URL (java.net.URL)2 HashMap (java.util.HashMap)2 UUID (java.util.UUID)2 JsonHolder (cc.hyperium.utils.JsonHolder)1