use of cc.hyperium.utils.JsonHolder in project Hyperium by HyperiumClient.
the class HypixelApiGuild method getInOrder.
public List<GuildPlayer> getInOrder() {
List<GuildPlayer> players = new ArrayList<>();
for (JsonElement element : getMembers()) {
players.add(new GuildPlayer(new JsonHolder(element.getAsJsonObject())));
}
players.sort(Comparator.comparingInt(o -> getPriorityForRank(o.getRank())));
Collections.reverse(players);
return players;
}
use of cc.hyperium.utils.JsonHolder in project Hyperium by HyperiumClient.
the class PurchaseApi method get.
public JsonHolder get(String url) {
url = url.replace(" ", "%20");
HttpURLConnection connection = null;
try {
URL u = new URL(url);
connection = (HttpURLConnection) u.openConnection();
connection.setRequestMethod("GET");
connection.setUseCaches(true);
connection.addRequestProperty("User-Agent", "Mozilla/4.76 Hyperium ");
connection.setReadTimeout(15000);
connection.setConnectTimeout(15000);
connection.setDoOutput(true);
InputStream is = connection.getInputStream();
return new JsonHolder(IOUtils.toString(is, StandardCharsets.UTF_8));
} catch (Exception ignored) {
} finally {
if (connection != null)
connection.disconnect();
}
JsonObject object = new JsonObject();
object.addProperty("success", false);
object.addProperty("cause", "Exception");
return new JsonHolder(object);
}
use of cc.hyperium.utils.JsonHolder 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;
}
use of cc.hyperium.utils.JsonHolder in project Hyperium by HyperiumClient.
the class GeneralChatHandler method post.
public void post() {
JsonHolder data = new JsonHolder(new JsonParser().parse(new InputStreamReader(GeneralChatHandler.class.getResourceAsStream("/remoteresources/chat_regex.json"))).getAsJsonObject());
HyperiumChatHandler.regexPatterns = new EnumMap<>(HyperiumChatHandler.ChatRegexType.class);
for (HyperiumChatHandler.ChatRegexType type : HyperiumChatHandler.ChatRegexType.values()) {
if (!data.has(type.name().toLowerCase())) {
Hyperium.LOGGER.error("Could not find chat regex type " + type.name().toLowerCase() + " in the remote file.");
continue;
}
HyperiumChatHandler.regexPatterns.put(type, Pattern.compile(data.optString(type.name().toLowerCase())));
}
posted = true;
for (HyperiumChatHandler chatHandler : handlerList) {
chatHandler.callback(data);
}
}
use of cc.hyperium.utils.JsonHolder in project Hyperium by HyperiumClient.
the class HypixelAPI method getFrontendNameOfQuest.
public String getFrontendNameOfQuest(String backendName) {
JsonHolder quests = QUESTS.optJSONObject("quests");
List<JsonArray> arrays = quests.getKeys().stream().map(quests::optJSONArray).collect(Collectors.toList());
for (JsonArray array : arrays) {
for (JsonElement element : array) {
JsonHolder holder = new JsonHolder(element.getAsJsonObject());
if (holder.optString("id").equalsIgnoreCase(backendName))
return holder.optString("name");
}
}
return backendName;
}
Aggregations