Updates based on Reviewer Suggestions

- COMBAT_TIMEOUT renamed to combatTimeout since it's not a constant
- Created hideStatusBar() method for code cleanliness
- Renamed Config option to remove capitalization on some words
This commit is contained in:
ErmalSh
2019-01-19 14:53:25 -05:00
parent 2d394a24a3
commit bca45c5d4c
2 changed files with 23 additions and 18 deletions

View File

@@ -67,7 +67,7 @@ public interface StatusBarsConfig extends Config
@ConfigItem( @ConfigItem(
position = 4, position = 4,
keyName = "toggleRestorationBars", keyName = "toggleRestorationBars",
name = "Toggle to Hide when not in Combat", name = "Toggle to hide when not in combat",
description = "Visually hides the Status Bars when player is out of combat." description = "Visually hides the Status Bars when player is out of combat."
) )
default boolean toggleRestorationBars() default boolean toggleRestorationBars()

View File

@@ -87,10 +87,16 @@ public class StatusBarsPlugin extends Plugin
return; return;
} }
else else
{
hideStatusBar();
}
}
private void hideStatusBar()
{ {
final Actor interacting = client.getLocalPlayer().getInteracting(); final Actor interacting = client.getLocalPlayer().getInteracting();
final boolean isNpc = interacting instanceof NPC; final boolean isNpc = interacting instanceof NPC;
final int COMBAT_TIMEOUT = config.hideStatusBarDelay(); final int combatTimeout = config.hideStatusBarDelay();
if (isNpc) if (isNpc)
{ {
@@ -105,13 +111,12 @@ public class StatusBarsPlugin extends Plugin
} }
else if (lastCombatAction != null) else if (lastCombatAction != null)
{ {
if (Duration.between(getLastCombatAction(), Instant.now()).getSeconds() > COMBAT_TIMEOUT) if (Duration.between(getLastCombatAction(), Instant.now()).getSeconds() > combatTimeout)
{ {
overlayManager.remove(overlay); overlayManager.remove(overlay);
} }
} }
} }
}
@Override @Override
protected void shutDown() throws Exception protected void shutDown() throws Exception