diff options
10 files changed, 89 insertions, 109 deletions
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/api/LeaderboardGetter.java b/src/main/java/com/thatgravyboat/skyblockhud/api/LeaderboardGetter.java index ca73b66..3c59360 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/api/LeaderboardGetter.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/api/LeaderboardGetter.java @@ -45,13 +45,11 @@ public class LeaderboardGetter { Map<Integer, String> scores = scoreList.stream().collect(Collectors.toMap(Score::getScorePoints, this::getLine, (s1, s2) -> s1)); if (!cachedScores.equals(scores)) { - scores.forEach( - (score, name) -> { - if (cachedScores.get(score) == null || !cachedScores.get(score).equals(name)) { - MinecraftForge.EVENT_BUS.post(new SidebarLineUpdateEvent(name, SCOREBOARD_CHARACTERS.matcher(name).replaceAll("").trim(), score, scores.size(), scoreboard, sidebarObjective)); - } + scores.forEach((score, name) -> { + if (cachedScores.get(score) == null || !cachedScores.get(score).equals(name)) { + MinecraftForge.EVENT_BUS.post(new SidebarLineUpdateEvent(name, SCOREBOARD_CHARACTERS.matcher(name).replaceAll("").trim(), score, scores.size(), scoreboard, sidebarObjective)); } - ); + }); cachedScores = scores; cachedScoresList = scores.values().stream().map(name -> SCOREBOARD_CHARACTERS.matcher(name).replaceAll("").trim()).collect(Collectors.toList()); } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/handlers/CooldownHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/handlers/CooldownHandler.java index 8704bdb..7f382d5 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/handlers/CooldownHandler.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/handlers/CooldownHandler.java @@ -25,11 +25,10 @@ public class CooldownHandler { private static final Set<String> CUSTOM_HANDLED_COOLDOWNS = Sets.newHashSet("Mining Speed Boost"); - public static Matcher getAbility(NBTTagCompound nbt) { - if (nbt != null && nbt.hasKey("ExtraAttributes") && nbt.getCompoundTag("ExtraAttributes").hasKey("uuid") && nbt.hasKey("display")){ + if (nbt != null && nbt.hasKey("ExtraAttributes") && nbt.getCompoundTag("ExtraAttributes").hasKey("uuid") && nbt.hasKey("display")) { NBTTagCompound display = nbt.getCompoundTag("display"); - if (display != null && display.hasKey("Lore")){ + if (display != null && display.hasKey("Lore")) { NBTTagList lore = display.getTagList("Lore", 8); List<String> loreList = new ArrayList<>(); for (int i = 0; i < lore.tagCount(); i++) { @@ -37,7 +36,7 @@ public class CooldownHandler { if (!loreLine.isEmpty()) loreList.add(loreLine); } Matcher abilityMatcher = ABILITY_REGEX.matcher(String.join(" ", loreList)); - if (abilityMatcher.find()){ + if (abilityMatcher.find()) { return abilityMatcher; } } @@ -46,7 +45,7 @@ public class CooldownHandler { } private static void addCooldown(String id, int time) { - COOLDOWNS.putIfAbsent(id, new Cooldown(time*20)); + COOLDOWNS.putIfAbsent(id, new Cooldown(time * 20)); } private static void addCooldown(IAbility ability, boolean isForced) { @@ -56,9 +55,9 @@ public class CooldownHandler { } @SubscribeEvent(priority = EventPriority.HIGHEST) - public void onChat(ClientChatReceivedEvent event){ + public void onChat(ClientChatReceivedEvent event) { String message = Utils.removeColor(event.message.getUnformattedText()); - if (event.type != 2 && message.equals("You used your Mining Speed Boost Pickaxe Ability!")){ + if (event.type != 2 && message.equals("You used your Mining Speed Boost Pickaxe Ability!")) { if (Minecraft.getMinecraft().thePlayer.getHeldItem() != null) { IAbility ability = (IAbility) (Object) Minecraft.getMinecraft().thePlayer.getHeldItem(); if (ability.getAbility().equals("Mining Speed Boost")) { @@ -69,7 +68,7 @@ public class CooldownHandler { } @SubscribeEvent - public void tick(TickEvent.ClientTickEvent event){ + public void tick(TickEvent.ClientTickEvent event) { if (SkyblockHud.config.misc.hideItemCooldowns) return; if (event.phase.equals(TickEvent.Phase.END)) { COOLDOWNS.values().forEach(Cooldown::tick); @@ -80,9 +79,9 @@ public class CooldownHandler { @SubscribeEvent public void onPlayerInteract(PlayerInteractEvent event) { if (SkyblockHud.config.misc.hideItemCooldowns) return; - if (event.action.equals(PlayerInteractEvent.Action.RIGHT_CLICK_AIR) || event.action.equals(PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK)){ + if (event.action.equals(PlayerInteractEvent.Action.RIGHT_CLICK_AIR) || event.action.equals(PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK)) { if (event.entityPlayer.getHeldItem() != null) { - IAbility ability = (IAbility)((Object) event.entityPlayer.getHeldItem()); + IAbility ability = (IAbility) ((Object) event.entityPlayer.getHeldItem()); if (ability.getAbility() != null) { addCooldown(ability, false); } @@ -90,8 +89,8 @@ public class CooldownHandler { } } - public static float getAbilityTime(ItemStack stack){ - IAbility ability = (IAbility)((Object) stack); + public static float getAbilityTime(ItemStack stack) { + IAbility ability = (IAbility) ((Object) stack); if (ability.getAbility() != null) { return COOLDOWNS.containsKey(ability.getAbility()) ? COOLDOWNS.get(ability.getAbility()).getTime() : -1f; } @@ -99,10 +98,11 @@ public class CooldownHandler { } private static class Cooldown { + public int current; public final int end; - Cooldown(int end){ + Cooldown(int end) { this.end = end; } @@ -115,8 +115,7 @@ public class CooldownHandler { } public float getTime() { - return current/(float)end; + return current / (float) end; } } - } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/handlers/NpcDialogue.java b/src/main/java/com/thatgravyboat/skyblockhud/handlers/NpcDialogue.java index a1764bd..9a7679f 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/handlers/NpcDialogue.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/handlers/NpcDialogue.java @@ -65,8 +65,7 @@ public class NpcDialogue implements IResourceManagerReloadListener { event.setCanceled(true); Dialogue dialogue = new Dialogue(matcher.group(1), matcher.group(2)); - if (currentDialogue == null) currentDialogue = dialogue; - else DIALOGUE.add(dialogue); + if (currentDialogue == null) currentDialogue = dialogue; else DIALOGUE.add(dialogue); } } } @@ -119,7 +118,6 @@ public class NpcDialogue implements IResourceManagerReloadListener { } catch (Exception ignored) {} } - static class Dialogue { public List<String> dialogue; @@ -129,6 +127,5 @@ public class NpcDialogue implements IResourceManagerReloadListener { this.dialogue = Minecraft.getMinecraft().fontRendererObj.listFormattedStringToWidth(dialogue, 160); this.name = name; } - } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/handlers/WarpHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/handlers/WarpHandler.java index 9eaa421..77a4199 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/handlers/WarpHandler.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/handlers/WarpHandler.java @@ -86,16 +86,14 @@ public class WarpHandler { JsonArray array = new JsonArray(); PLAYER_WARPS .asMap() - .forEach( - (profile, warps) -> { - JsonObject profileObject = new JsonObject(); - profileObject.addProperty("profile", profile); - JsonArray warpArray = new JsonArray(); - warps.forEach(warp -> warpArray.add(new JsonPrimitive(warp.name()))); - profileObject.add("warps", warpArray); - array.add(profileObject); - } - ); + .forEach((profile, warps) -> { + JsonObject profileObject = new JsonObject(); + profileObject.addProperty("profile", profile); + JsonArray warpArray = new JsonArray(); + warps.forEach(warp -> warpArray.add(new JsonPrimitive(warp.name()))); + profileObject.add("warps", warpArray); + array.add(profileObject); + }); json.add("profileWarps", array); warpConfig = new File(SkyblockHud.configDirectory, "sbh-warps.json"); @@ -118,22 +116,18 @@ public class WarpHandler { json .get("profileWarps") .getAsJsonArray() - .forEach( - jsonElement -> { - JsonObject profileObject = jsonElement.getAsJsonObject(); - List<Warp> warps = new ArrayList<>(); - profileObject - .get("warps") - .getAsJsonArray() - .forEach( - warpId -> { - Warp warp = Warp.safeValueOf(warpId.getAsString()); - if (warp != null) warps.add(warp); - } - ); - PLAYER_WARPS.putAll(profileObject.get("profile").getAsString(), warps); - } - ); + .forEach(jsonElement -> { + JsonObject profileObject = jsonElement.getAsJsonObject(); + List<Warp> warps = new ArrayList<>(); + profileObject + .get("warps") + .getAsJsonArray() + .forEach(warpId -> { + Warp warp = Warp.safeValueOf(warpId.getAsString()); + if (warp != null) warps.add(warp); + }); + PLAYER_WARPS.putAll(profileObject.get("profile").getAsString(), warps); + }); } } catch (Exception ignored) {} return false; diff --git a/src/main/java/com/thatgravyboat/skyblockhud/location/MinesHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/location/MinesHandler.java index e7dacd4..ebde7db 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/location/MinesHandler.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/location/MinesHandler.java @@ -168,16 +168,16 @@ public class MinesHandler { if (walked < 4000) { progress.currentColor = 0xffffff; progress.progress = walked / 4000f; - }else if (walked < 10000) { + } else if (walked < 10000) { progress.currentColor = 0x55FF55; progress.progress = (walked - 4000f) / 6000f; - }else if (walked < 20000) { + } else if (walked < 20000) { progress.currentColor = 0x5555FF; progress.progress = (walked - 10000f) / 10000f; - }else if (walked < 40000) { + } else if (walked < 40000) { progress.currentColor = 0xAA00AA; progress.progress = (walked - 20000f) / 20000f; - }else if (walked < 100000) { + } else if (walked < 100000) { progress.currentColor = 0xFFAA00; progress.progress = (walked - 40000f) / 60000f; } @@ -185,6 +185,7 @@ public class MinesHandler { } public static class PrehistoricEggProgress { + public float progress; public int currentColor; } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinRenderItem.java b/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinRenderItem.java index 951b549..ae7d5bf 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinRenderItem.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinRenderItem.java @@ -18,11 +18,12 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(RenderItem.class) public abstract class MixinRenderItem { - @Shadow protected abstract void draw(WorldRenderer renderer, int x, int y, int width, int height, int red, int green, int blue, int alpha); + @Shadow + protected abstract void draw(WorldRenderer renderer, int x, int y, int width, int height, int red, int green, int blue, int alpha); - @Inject(method="renderItemOverlayIntoGUI", at=@At("RETURN")) + @Inject(method = "renderItemOverlayIntoGUI", at = @At("RETURN")) public void renderItemOverlayIntoGUI(FontRenderer fr, ItemStack stack, int xPosition, int yPosition, String text, CallbackInfo ci) { - if(stack == null) return; + if (stack == null) return; float cooldown = CooldownHandler.getAbilityTime(stack); WeakReference<MinesHandler.PrehistoricEggProgress> weakProgress = MinesHandler.getEggColorAndProgress(stack); @@ -37,14 +38,14 @@ public abstract class MixinRenderItem { GlStateManager.disableBlend(); WorldRenderer worldrenderer = Tessellator.getInstance().getWorldRenderer(); this.draw(worldrenderer, xPosition + 2, yPosition + 13, 13, 2, 0, 0, 0, 255); - this.draw(worldrenderer, xPosition + 2, yPosition + 13, Math.round(progress.progress * 13f), 1, (progress.currentColor >> 16) & 0xFF, (progress.currentColor >> 8) & 0xFF, progress.currentColor & 0xFF, 255); + this.draw(worldrenderer, xPosition + 2, yPosition + 13, Math.round(progress.progress * 13f), 1, (progress.currentColor >> 16) & 0xFF, (progress.currentColor >> 8) & 0xFF, progress.currentColor & 0xFF, 255); GlStateManager.enableAlpha(); GlStateManager.enableTexture2D(); GlStateManager.enableLighting(); GlStateManager.enableDepth(); } - if (cooldown > -1){ + if (cooldown > -1) { GlStateManager.disableLighting(); GlStateManager.disableDepth(); GlStateManager.disableTexture2D(); @@ -52,7 +53,7 @@ public abstract class MixinRenderItem { GlStateManager.disableBlend(); WorldRenderer worldrenderer = Tessellator.getInstance().getWorldRenderer(); this.draw(worldrenderer, xPosition + 2, yPosition + 13, 13, 2, 0, 0, 0, 255); - this.draw(worldrenderer, xPosition + 2, yPosition + 13, Math.round(cooldown * 13f), 1, 102, 102, 255, 255); + this.draw(worldrenderer, xPosition + 2, yPosition + 13, Math.round(cooldown * 13f), 1, 102, 102, 255, 255); GlStateManager.enableAlpha(); GlStateManager.enableTexture2D(); GlStateManager.enableLighting(); diff --git a/src/main/java/com/thatgravyboat/skyblockhud/overlay/OverlayHud.java b/src/main/java/com/thatgravyboat/skyblockhud/overlay/OverlayHud.java index 015572d..70cb153 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/overlay/OverlayHud.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/overlay/OverlayHud.java @@ -280,7 +280,7 @@ public class OverlayHud extends Gui { mc.renderEngine.bindTexture(Textures.texture.stats); drawTexturedModalRect((width / 2) - 15, offset + (bossBarVisible ? 51 : 34), 0, 52, 30, 14); drawTexturedModalRect((width / 2) - 10, offset + (bossBarVisible ? 53 : 36), MinesHandler.currentEvent.x, 0, 8, 8); - drawString(mc.fontRendererObj, MinesHandler.eventProgress +"", (width / 2), offset + (bossBarVisible ? 53 : 36), 0xffffff); + drawString(mc.fontRendererObj, MinesHandler.eventProgress + "", (width / 2), offset + (bossBarVisible ? 53 : 36), 0xffffff); } public void drawFarmHouseMedals(int width, int offset, Minecraft mc) { diff --git a/src/main/java/com/thatgravyboat/skyblockhud/textures/TextureObject.java b/src/main/java/com/thatgravyboat/skyblockhud/textures/TextureObject.java index 3af2ac1..6403e18 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/textures/TextureObject.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/textures/TextureObject.java @@ -23,13 +23,11 @@ public class TextureObject { Arrays .stream(textureObject.getClass().getDeclaredFields()) .filter(field -> field.getType().equals(ResourceLocation.class)) - .forEach( - field -> { - try { - field.set(textureObject, new ResourceLocation(json.get(field.getName()).getAsString())); - } catch (Exception ignored) {} - } - ); + .forEach(field -> { + try { + field.set(textureObject, new ResourceLocation(json.get(field.getName()).getAsString())); + } catch (Exception ignored) {} + }); return textureObject; } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerFileLoader.java b/src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerFileLoader.java index 1e7d64e..7401dd8 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerFileLoader.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerFileLoader.java @@ -22,14 +22,12 @@ public class TrackerFileLoader { tracker .get("location") .getAsJsonArray() - .forEach( - l -> { - Locations location = Locations.get(l.getAsString().toUpperCase(Locale.ENGLISH)); - if (location != Locations.DEFAULT) { - locations.add(location); - } + .forEach(l -> { + Locations location = Locations.get(l.getAsString().toUpperCase(Locale.ENGLISH)); + if (location != Locations.DEFAULT) { + locations.add(location); } - ); + }); if (tracker.has("drops")) { for (JsonElement drop : tracker.get("drops").getAsJsonArray()) { TrackerHandler.trackerObjects.add(new TrackerObject(drop.getAsJsonObject(), locations)); @@ -70,19 +68,17 @@ public class TrackerFileLoader { private static JsonElement getTrackerFile() { JsonArray stats = new JsonArray(); - TrackerHandler.trackerObjects.forEach( - trackerObject -> { - if (trackerObject.getCount() > 0) { - JsonObject jsonObject = new JsonObject(); - JsonArray locations = new JsonArray(); - trackerObject.getLocations().forEach(l -> locations.add(new JsonPrimitive(l.toString().toUpperCase(Locale.ENGLISH)))); - jsonObject.add("id", new JsonPrimitive(trackerObject.getInternalId())); - jsonObject.add("locations", locations); - jsonObject.add("count", new JsonPrimitive(trackerObject.getCount())); - stats.add(jsonObject); - } + TrackerHandler.trackerObjects.forEach(trackerObject -> { + if (trackerObject.getCount() > 0) { + JsonObject jsonObject = new JsonObject(); + JsonArray locations = new JsonArray(); + trackerObject.getLocations().forEach(l -> locations.add(new JsonPrimitive(l.toString().toUpperCase(Locale.ENGLISH)))); + jsonObject.add("id", new JsonPrimitive(trackerObject.getInternalId())); + jsonObject.add("locations", locations); + jsonObject.add("count", new JsonPrimitive(trackerObject.getCount())); + stats.add(jsonObject); } - ); + }); return stats; } @@ -99,29 +95,25 @@ public class TrackerFileLoader { if (json.has("trackerStats")) { json .getAsJsonArray("trackerStats") - .forEach( - element -> { - if (element.isJsonObject()) { - JsonObject object = element.getAsJsonObject(); - JsonArray locations = object.get("locations").getAsJsonArray(); - Locations firstLocation = null; - for (JsonElement location : locations) { - firstLocation = Locations.get(location.getAsString()); - if (!firstLocation.equals(Locations.DEFAULT)) break; - } - - if (firstLocation != null && !firstLocation.equals(Locations.DEFAULT)) { - TrackerHandler.trackers.get(firstLocation).get(object.get("id").getAsString()).setCount(object.get("count").getAsInt()); - } + .forEach(element -> { + if (element.isJsonObject()) { + JsonObject object = element.getAsJsonObject(); + JsonArray locations = object.get("locations").getAsJsonArray(); + Locations firstLocation = null; + for (JsonElement location : locations) { + firstLocation = Locations.get(location.getAsString()); + if (!firstLocation.equals(Locations.DEFAULT)) break; + } + + if (firstLocation != null && !firstLocation.equals(Locations.DEFAULT)) { + TrackerHandler.trackers.get(firstLocation).get(object.get("id").getAsString()).setCount(object.get("count").getAsInt()); } } - ); + }); - TrackerHandler.trackers.forEach( - (location, map) -> { - TrackerHandler.trackers.put(location, TrackerHandler.sortTrackers(map, (entry1, entry2) -> Integer.compare(entry2.getValue().getCount(), entry1.getValue().getCount()))); - } - ); + TrackerHandler.trackers.forEach((location, map) -> { + TrackerHandler.trackers.put(location, TrackerHandler.sortTrackers(map, (entry1, entry2) -> Integer.compare(entry2.getValue().getCount(), entry1.getValue().getCount()))); + }); } } } catch (Exception ignored) {} diff --git a/src/main/java/com/thatgravyboat/skyblockhud/utils/Utils.java b/src/main/java/com/thatgravyboat/skyblockhud/utils/Utils.java index 10f4599..3135b9b 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/utils/Utils.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/utils/Utils.java @@ -370,7 +370,7 @@ public class Utils { return false; } - public static String getItemCustomId(ItemStack stack){ + public static String getItemCustomId(ItemStack stack) { if (stack == null) return null; if (!stack.hasTagCompound()) return null; if (!stack.getTagCompound().hasKey("ExtraAttributes")) return null; |