diff options
Diffstat (limited to 'src/main/java/com/thatgravyboat/skyblockhud/handlers')
3 files changed, 35 insertions, 45 deletions
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; |