diff options
author | ThatGravyBoat <ThatGravyBoat@users.noreply.github.com> | 2021-09-27 16:50:17 +0000 |
---|---|---|
committer | GitHub Action <actions@github.com> | 2021-09-27 16:50:17 +0000 |
commit | 50885a0b0bd9ad39885b68efb20a1276f16886a3 (patch) | |
tree | 070e35e2bcc8ba551ec7f2517992182911c83859 /src/main/java/com/thatgravyboat/skyblockhud/handlers/CooldownHandler.java | |
parent | 06c495fd067ed5c16b34322d41e9674319e09506 (diff) | |
download | SkyblockHud-Death-Defied-50885a0b0bd9ad39885b68efb20a1276f16886a3.tar.gz SkyblockHud-Death-Defied-50885a0b0bd9ad39885b68efb20a1276f16886a3.tar.bz2 SkyblockHud-Death-Defied-50885a0b0bd9ad39885b68efb20a1276f16886a3.zip |
Prettified Code!
Diffstat (limited to 'src/main/java/com/thatgravyboat/skyblockhud/handlers/CooldownHandler.java')
-rw-r--r-- | src/main/java/com/thatgravyboat/skyblockhud/handlers/CooldownHandler.java | 29 |
1 files changed, 14 insertions, 15 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; } } - } |