use of cc.hyperium.utils.JsonHolder in project Hyperium by HyperiumClient.
the class AddItemsGui method drawScreen.
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
mouseLock = mouseLock && Mouse.isButtonDown(0);
ScaledResolution current = ResolutionUtil.current();
drawRect(0, 0, current.getScaledWidth(), current.getScaledHeight(), new Color(0, 0, 0, 150).getRGB());
super.drawScreen(mouseX, mouseY, partialTicks);
ElementRenderer.startDrawing(target);
if (adding) {
Color defaultColor = new Color(255, 255, 255, 100);
int cursorY = 50 + offset;
drawCenteredString(mc.fontRendererObj, "Click Explore to see examples!", current.getScaledWidth() / 2, cursorY - 30, Color.RED.getRGB());
List<ChromaHUDParser> parsers = ChromaHUDApi.getInstance().getParsers();
for (ChromaHUDParser parser : parsers) {
Map<String, String> names = parser.getNames();
for (Map.Entry<String, String> entry : names.entrySet()) {
String s = entry.getKey();
String text1 = entry.getValue() + "";
drawRect(current.getScaledWidth() / 2 - 80, cursorY, current.getScaledWidth() / 2 + 80, cursorY + 20, defaultColor.getRGB());
int j = Color.RED.getRGB();
int width = 160;
int height = 20;
mc.fontRendererObj.drawString(text1, ((current.getScaledWidth() >> 1) - 80 + (width >> 1) - (mc.fontRendererObj.getStringWidth(text1) >> 1)), cursorY + ((height - 8) >> 1), j, false);
int i = ResolutionUtil.current().getScaledHeight() - (Mouse.getY() / current.getScaleFactor());
if (Mouse.isButtonDown(0) && !mouseLock)
if (i >= cursorY && i <= cursorY + 23) {
int i1 = Mouse.getX() / current.getScaleFactor();
if (i1 >= current.getScaledWidth() / 2 - 80 && i1 <= current.getScaledWidth() / 2 + 80) {
DisplayItem item = ChromaHUDApi.getInstance().parse(s, 0, new JsonHolder().put("type", s));
element.getDisplayItems().add(item);
element.adjustOrdinal();
mc.displayGuiScreen(new EditItemsGui(element, mod));
}
}
cursorY += 23;
}
}
} else {
int cursorY = 50 + offset;
List<ChromaHUDParser> parsers = ChromaHUDApi.getInstance().getParsers();
for (ChromaHUDParser parser : parsers) {
ChromaHUDDescription description = parser.description();
String text = "Items in " + description.getName() + ".";
mc.fontRendererObj.drawString(text, (current.getScaledWidth() - mc.fontRendererObj.getStringWidth(text)) >> 1, cursorY, Color.RED.getRGB(), true);
cursorY += 30;
Map<String, String> names = parser.getNames();
for (Map.Entry<String, String> entry : names.entrySet()) {
String s = entry.getKey();
String text1 = entry.getValue() + ": ";
DisplayElement displayElement = find(s);
if (displayElement == null) {
String text2 = "ERROR LOCATING DISPLAY ELEMENT " + s;
mc.fontRendererObj.drawString(text2, (current.getScaledWidth() - mc.fontRendererObj.getStringWidth(text2)) >> 1, cursorY, Color.RED.getRGB(), true);
cursorY += 15;
continue;
}
Dimension dimensions = displayElement.getDimensions();
int stringWidth = mc.fontRendererObj.getStringWidth(text1);
double totalWidth = dimensions.getWidth() + stringWidth;
double left = (current.getScaledWidth_double() - totalWidth) / 2;
double startDraw = left + stringWidth;
displayElement.setXloc(startDraw / current.getScaledWidth_double());
displayElement.setYloc(((double) cursorY) / current.getScaledHeight_double());
displayElement.drawForConfig();
mc.fontRendererObj.drawString(text1, (float) ((current.getScaledWidth() - totalWidth) / 2), cursorY, Color.RED.getRGB(), true);
cursorY += dimensions.getHeight() + 5;
}
}
}
ElementRenderer.endDrawing(target);
}
use of cc.hyperium.utils.JsonHolder in project Hyperium by HyperiumClient.
the class ChromaHUDApi method post.
/**
* Internal method to setup system once all items have been registered
*
* @param config Config data from file
*/
public void post(JsonHolder config) {
this.config = config;
posted = true;
elements.clear();
JsonArray displayElements = config.optJSONArray("elements");
int bound = displayElements.size();
for (int i = 0; i < bound; i++) {
JsonHolder object = new JsonHolder(displayElements.get(i).getAsJsonObject());
try {
DisplayElement e = new DisplayElement(object);
if (e.getDisplayItems().size() > 0)
elements.add(e);
} catch (Exception e) {
e.printStackTrace();
Logger.getLogger("ChromaHUD").severe("A fatal error occurred while loading the display element " + object);
}
}
if (!config.has("elements")) {
// setup blank
}
}
use of cc.hyperium.utils.JsonHolder in project Hyperium by HyperiumClient.
the class AbstractHypixelStats method process.
public void process(HypixelApiPlayer player, ArrayList<StatsDisplayItem> statsDisplayItems, JsonArray ob) {
for (JsonElement jsonElement : ob) {
JsonHolder quest = new JsonHolder(jsonElement.getAsJsonObject());
String quest_backend = quest.optString("id");
StringBuilder tmp = new StringBuilder(HypixelAPI.INSTANCE.getFrontendNameOfQuest(quest_backend));
// TODO get quest names
JsonHolder playerQuestData = player.getQuests().optJSONObject(HypixelAPI.INSTANCE.getFrontendNameOfQuest(quest_backend));
long last_completed = playerQuestData.optLong("last_completed");
tmp.append(": ");
JsonArray requirements = quest.optJSONArray("requirements");
boolean daily = requirements.size() > 0 && new JsonHolder(requirements.get(0).getAsJsonObject()).optString("type").equalsIgnoreCase("DailyResetQuestRequirement");
boolean completed = daily ? isToday(last_completed) : isWeek(last_completed);
if (completed)
if (daily)
completedDaily++;
else
completedWeekly++;
if (daily)
totalDaily++;
else
totalWeekly++;
tmp.append(completed ? C.GREEN + "Completed" : C.RED + "Not Completed");
statsDisplayItems.add(new DisplayLine(tmp.toString()));
JsonArray tasks = quest.optJSONArray("objectives");
JsonHolder objectives = playerQuestData.optJSONObject("active").optJSONObject("objectives");
for (JsonElement task : tasks) {
JsonHolder task1 = new JsonHolder(task.getAsJsonObject());
String line = task1.optString("text");
if (task1.optString("type").equalsIgnoreCase("IntegerObjective")) {
line += (objectives.optInt(task1.optString("id")) + "/" + task1.optInt("integer"));
}
if (!completed && !line.isEmpty()) {
statsDisplayItems.add(new DisplayLine(" - " + line));
}
}
}
}
use of cc.hyperium.utils.JsonHolder in project Hyperium by HyperiumClient.
the class AbstractHypixelStats method getPreview.
public List<StatsDisplayItem> getPreview(HypixelApiPlayer player) {
ArrayList<StatsDisplayItem> items = new ArrayList<>();
GameType gameType = GameType.fromRealName(getName());
if (gameType == null) {
items.add(new DisplayLine("No default preview for " + getName(), Color.WHITE.getRGB()));
} else {
JsonHolder stats = player.getStats(gameType);
items.add(new DisplayLine(bold("Coins: ", stats.optInt("coins")), Color.WHITE.getRGB()));
items.add(new DisplayLine(bold("Kills: ", stats.optInt("kills")), Color.WHITE.getRGB()));
items.add(new DisplayLine(bold("Deaths: ", stats.optInt("deaths")), Color.WHITE.getRGB()));
items.add(new DisplayLine(bold("Wins: ", stats.optInt("wins")), Color.WHITE.getRGB()));
items.add(new DisplayLine(bold("Losses: ", stats.optInt("losses")), Color.WHITE.getRGB()));
items.add(new DisplayLine(bold("K/D: ", WebsiteUtils.buildRatio(stats.optInt("kills"), stats.optInt("deaths"))), Color.WHITE.getRGB()));
items.add(new DisplayLine(bold("W/L: ", WebsiteUtils.buildRatio(stats.optInt("wins"), stats.optInt("losses"))), Color.WHITE.getRGB()));
}
return items;
}
use of cc.hyperium.utils.JsonHolder in project Hyperium by HyperiumClient.
the class ArenaStats method getPreview.
@Override
public List<StatsDisplayItem> getPreview(HypixelApiPlayer player) {
ArrayList<StatsDisplayItem> items = new ArrayList<>();
JsonHolder arena = player.getStats(GameType.ARENA);
items.add(new DisplayLine(bold("Coins: ", arena.optInt("coins"))));
int kills = arena.optInt("kills_1v1") + arena.optInt("kills_2v2") + arena.optInt("kills_4v4");
items.add(new DisplayLine(bold("Kills: ", kills), Color.WHITE.getRGB()));
int deaths = arena.optInt("deaths_1v1") + arena.optInt("deaths_2v2") + arena.optInt("deaths_4v4");
items.add(new DisplayLine(bold("Deaths: ", deaths), Color.WHITE.getRGB()));
int wins = arena.optInt("wins_1v1") + arena.optInt("wins_2v2") + arena.optInt("wins_4v4");
items.add(new DisplayLine(bold("Wins: ", wins), Color.WHITE.getRGB()));
int losses = arena.optInt("losses_1v1") + arena.optInt("losses_2v2") + arena.optInt("losses_4v4");
items.add(new DisplayLine(bold("Losses: ", losses), Color.WHITE.getRGB()));
items.add(new DisplayLine(bold("K/D: ", WebsiteUtils.buildRatio(kills, deaths)), Color.WHITE.getRGB()));
items.add(new DisplayLine(bold("W/L: ", WebsiteUtils.buildRatio(wins, losses)), Color.WHITE.getRGB()));
return items;
}
Aggregations