diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2cb857e..82ebd1c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,6 +26,9 @@ jobs: - name: Compile Tests run: ./gradlew compileTestJava + - name: Lint & Formatting + run: ./gradlew checkstyleMain checkstyleTest + - name: Run Tests run: ./gradlew test diff --git a/build.gradle b/build.gradle index d530a37..fbad105 100644 --- a/build.gradle +++ b/build.gradle @@ -3,6 +3,11 @@ import org.gradle.api.tasks.testing.logging.TestLogEvent plugins { id 'java' + id 'checkstyle' +} + +checkstyle { + toolVersion = "10.26.1" } repositories { diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml new file mode 100644 index 0000000..14f4622 --- /dev/null +++ b/config/checkstyle/checkstyle.xml @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/attacktimer/AnimationData.java b/src/main/java/com/attacktimer/AnimationData.java index 94bccdc..3fad116 100644 --- a/src/main/java/com/attacktimer/AnimationData.java +++ b/src/main/java/com/attacktimer/AnimationData.java @@ -262,8 +262,8 @@ public enum AnimationData HIGH_ALCH(713, AttackStyle.NON_ATTACK); private static final Map DATA; - private static final Map> spellBookAnimations; - private static final Map notAttacks; + private static final Map> SPELL_BOOK_ANIMATIONS; + private static final Map NOT_ATTACKS; public final int animationId; public final boolean isSpecial; @@ -339,8 +339,8 @@ public enum AnimationData } DATA = builder.build(); - notAttacks = notAttacksBuilder.build(); - spellBookAnimations = spellBookBuilder; + NOT_ATTACKS = notAttacksBuilder.build(); + SPELL_BOOK_ANIMATIONS = spellBookBuilder; } public static AnimationData fromId(int animationId) @@ -350,7 +350,7 @@ public static AnimationData fromId(int animationId) public static Set getAnimationsForSpellbook(Spellbook s) { - return spellBookAnimations.get(s); + return SPELL_BOOK_ANIMATIONS.get(s); } public static boolean isManualCasting(AnimationData animationData) @@ -360,14 +360,14 @@ public static boolean isManualCasting(AnimationData animationData) { // We tell a manual cast by the animation data: return animationData.attackStyle == AttackStyle.MAGIC && - spellBookAnimations.get(animationData.spellbook).contains(animationData); + SPELL_BOOK_ANIMATIONS.get(animationData.spellbook).contains(animationData); } return false; } public static boolean isBlockListAnimation(int animationId) { - return notAttacks.containsKey(animationId); + return NOT_ATTACKS.containsKey(animationId); } @Override diff --git a/src/main/java/com/attacktimer/AttackBarStyle.java b/src/main/java/com/attacktimer/AttackBarStyle.java index ffed85e..317784e 100644 --- a/src/main/java/com/attacktimer/AttackBarStyle.java +++ b/src/main/java/com/attacktimer/AttackBarStyle.java @@ -7,15 +7,15 @@ @AllArgsConstructor public enum AttackBarStyle { - AUTO("Auto"), - STANDARD("Standard"), - HIGH_DETAIL("High Detail"); + AUTO("Auto"), + STANDARD("Standard"), + HIGH_DETAIL("High Detail"); - private final String name; + private final String name; - @Override - public String toString() - { - return name; - } + @Override + public String toString() + { + return name; + } } diff --git a/src/main/java/com/attacktimer/AttackProcedure.java b/src/main/java/com/attacktimer/AttackProcedure.java index 440bc06..12570a6 100644 --- a/src/main/java/com/attacktimer/AttackProcedure.java +++ b/src/main/java/com/attacktimer/AttackProcedure.java @@ -25,7 +25,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -public enum AttackProcedure { +public enum AttackProcedure +{ POWERED_STAVE, MANUAL_AUTO_CAST, MELEE_OR_RANGE diff --git a/src/main/java/com/attacktimer/AttackTimerBarOverlay.java b/src/main/java/com/attacktimer/AttackTimerBarOverlay.java index e6039fa..02ce4f2 100644 --- a/src/main/java/com/attacktimer/AttackTimerBarOverlay.java +++ b/src/main/java/com/attacktimer/AttackTimerBarOverlay.java @@ -13,10 +13,10 @@ * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. + * list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED @@ -40,8 +40,8 @@ import net.runelite.api.Client; import net.runelite.api.Perspective; import net.runelite.api.Point; -import net.runelite.api.coords.LocalPoint; import net.runelite.api.SpriteID; +import net.runelite.api.coords.LocalPoint; import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.OverlayLayer; import net.runelite.client.ui.overlay.OverlayPosition; @@ -65,8 +65,7 @@ class AttackTimerBarOverlay extends Overlay private boolean shouldShowBar = false; @Inject - private AttackTimerBarOverlay(final Client client, final AttackTimerMetronomeConfig config, - final AttackTimerMetronomePlugin plugin) + private AttackTimerBarOverlay(final Client client, final AttackTimerMetronomeConfig config, final AttackTimerMetronomePlugin plugin) { this.client = client; this.config = config; @@ -97,7 +96,8 @@ public Dimension render(Graphics2D graphics) { return null; } - final Point canvasPoint = Perspective.localToCanvas(client, localLocation, client.getTopLevelWorldView().getPlane(), height); + final Point canvasPoint = Perspective.localToCanvas(client, localLocation, + client.getTopLevelWorldView().getPlane(), height); if (canvasPoint == null) { return null; diff --git a/src/main/java/com/attacktimer/AttackTimerMetronomeConfig.java b/src/main/java/com/attacktimer/AttackTimerMetronomeConfig.java index 8ca37d7..3d7112a 100644 --- a/src/main/java/com/attacktimer/AttackTimerMetronomeConfig.java +++ b/src/main/java/com/attacktimer/AttackTimerMetronomeConfig.java @@ -2,7 +2,7 @@ /* * Copyright (c) 2022, Nick Graves - * Copyright (c) 2024, Lexer747 + * Copyright (c) 2024-2026, Lexer747 * Copyright (c) 2024, Richardant * All rights reserved. * @@ -27,242 +27,242 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +import java.awt.Color; import lombok.AllArgsConstructor; import lombok.Getter; import net.runelite.client.config.Config; import net.runelite.client.config.ConfigGroup; import net.runelite.client.config.ConfigItem; -import net.runelite.client.config.Range; import net.runelite.client.config.ConfigSection; -import java.awt.Color; +import net.runelite.client.config.Range; @ConfigGroup("attacktimermetronome") public interface AttackTimerMetronomeConfig extends Config { - @ConfigItem( - position = 0, - keyName = "enableMetronome", - name = "Attack Timer Metronome", - description = "Enable visual metronome" - ) - default boolean enableMetronome() - { - return true; - } + @ConfigItem( + position = 0, + keyName = "enableMetronome", + name = "Attack Timer Metronome", + description = "Enable visual metronome" + ) + default boolean enableMetronome() + { + return true; + } - @ConfigSection( - name = "Attack Cooldown Tick Settings", - description = "Change attack tick cooldown settings", - position = 1 - ) - String TickNumberSettings = "Attack Cooldown Tick Settings"; + @ConfigSection( + name = "Attack Cooldown Tick Settings", + description = "Change attack tick cooldown settings", + position = 1 + ) + final String TICK_NUMBER_SETTINGS = "Attack Cooldown Tick Settings"; - @ConfigItem( - position = 1, - keyName = "showTick", - name = "Show Attack Cooldown Ticks", - description = "Shows number of ticks until next attack", - section = TickNumberSettings - ) - default boolean showTick() - { - return true; - } + @ConfigItem( + position = 1, + keyName = "showTick", + name = "Show Attack Cooldown Ticks", + description = "Shows number of ticks until next attack", + section = TICK_NUMBER_SETTINGS + ) + default boolean showTick() + { + return true; + } - @ConfigItem( - position = 2, - keyName = "disableFontScaling", - name = "Disable Font Size Scaling (Metronome Tick Only)", - description = "Disables font size scaling for metronome tick number", - section = TickNumberSettings - ) - default boolean disableFontScaling() - { - return false; - } + @ConfigItem( + position = 2, + keyName = "disableFontScaling", + name = "Disable Font Size Scaling (Metronome Tick Only)", + description = "Disables font size scaling for metronome tick number", + section = TICK_NUMBER_SETTINGS + ) + default boolean disableFontScaling() + { + return false; + } - @ConfigItem( - position = 3, - keyName = "fontSize", - name = "Font Size (Overhead Tick Only)", - description = "Change the font size of the overhead attack cooldown ticks", - section = TickNumberSettings - ) - @Range(min = 8, max = 50) - default int fontSize() - { - return 15; - } + @ConfigItem( + position = 3, + keyName = "fontSize", + name = "Font Size (Overhead Tick Only)", + description = "Change the font size of the overhead attack cooldown ticks", + section = TICK_NUMBER_SETTINGS + ) + @Range(min = 8, max = 50) + default int fontSize() + { + return 15; + } - @ConfigItem( - position = 4, - keyName = "countColor", - name = "Tick Number Color", - description = "Configures the color of tick number", - section = TickNumberSettings - ) - default Color NumberColor() - { - return Color.CYAN; - } + @ConfigItem( + position = 4, + keyName = "countColor", + name = "Tick Number Color", + description = "Configures the color of tick number", + section = TICK_NUMBER_SETTINGS + ) + default Color NumberColor() + { + return Color.CYAN; + } - @ConfigItem( - position = 5, - keyName = "lastColor", - name = "Last Tick Color", - description = "Configures the color of tick number when it says 1", - section = TickNumberSettings - ) - default Color LastColor() - { - return Color.CYAN; - } + @ConfigItem( + position = 5, + keyName = "lastColor", + name = "Last Tick Color", + description = "Configures the color of tick number when it says 1", + section = TICK_NUMBER_SETTINGS + ) + default Color LastColor() + { + return Color.CYAN; + } - @ConfigItem( - position = 6, - keyName = "fontType", - name = "Font Type", - description = "Change the font of the tick number", - section = TickNumberSettings - ) - default FontTypes fontType() - { - return FontTypes.REGULAR; - } + @ConfigItem( + position = 6, + keyName = "fontType", + name = "Font Type", + description = "Change the font of the tick number", + section = TICK_NUMBER_SETTINGS + ) + default FontTypes fontType() + { + return FontTypes.REGULAR; + } - @ConfigItem( - position = 7, - keyName = "ticksPosition", - name = "Ticks Position", - description = "Position of the tick number respective to the player", - section = TickNumberSettings - ) - default TicksPosition ticksPosition() - { - return TicksPosition.DEFAULT; - } + @ConfigItem( + position = 7, + keyName = "ticksPosition", + name = "Ticks Position", + description = "Position of the tick number respective to the player", + section = TICK_NUMBER_SETTINGS + ) + default TicksPosition ticksPosition() + { + return TicksPosition.DEFAULT; + } - @ConfigItem( - position = 8, - keyName = "tickHeightOffset", - name = "Height Offset", - description = "Height offset for minor adjustments of the tick number", - section = TickNumberSettings - ) - @Range(min = -50, max = 50) - default int heightTickOffset() - { - return 0; - } + @ConfigItem( + position = 8, + keyName = "tickHeightOffset", + name = "Height Offset", + description = "Height offset for minor adjustments of the tick number", + section = TICK_NUMBER_SETTINGS + ) + @Range(min = -50, max = 50) + default int heightTickOffset() + { + return 0; + } @ConfigItem( position = 9, keyName = "useZeroBasedTickCount", name = "Zero-based Tick Count", description = "Count ticks to 0 instead of 1", - section = TickNumberSettings + section = TICK_NUMBER_SETTINGS ) default boolean useZeroBasedTickCount() { return false; } - @ConfigSection( - name = "Attack Bar", - description = "Change the colors and number of colors to cycle through", - position = 2 - ) - String AttackBarSettings = "Attack Cooldown Bar Settings"; + @ConfigSection( + name = "Attack Bar", + description = "Change the colors and number of colors to cycle through", + position = 2 + ) + final String ATTACK_BAR_SETTINGS = "Attack Cooldown Bar Settings"; - @ConfigItem( - position = 1, - keyName = "attackBar", - name = "Show Attack Bar", - description = "Show the attack bar", - section = AttackBarSettings - ) - default boolean showBar() - { - return false; - } + @ConfigItem( + position = 1, + keyName = "attackBar", + name = "Show Attack Bar", + description = "Show the attack bar", + section = ATTACK_BAR_SETTINGS + ) + default boolean showBar() + { + return false; + } - @ConfigItem( - position = 2, - keyName = "attackBarHeightOffset", - name = "Height Offset", - description = "Height offset for the bar from top of player model", - section = AttackBarSettings - ) - @Range(min = -100, max = 100) - default int heightOffset() - { - return 0; - } + @ConfigItem( + position = 2, + keyName = "attackBarHeightOffset", + name = "Height Offset", + description = "Height offset for the bar from top of player model", + section = ATTACK_BAR_SETTINGS + ) + @Range(min = -100, max = 100) + default int heightOffset() + { + return 0; + } - @ConfigItem( - position = 3, - keyName = "attackBarEmpties", - name = "Empties Before Attack", - description = "Controls whether the attack bar will fully empty before a new attack can occur", - section = AttackBarSettings - ) - default boolean barEmpties() - { - return true; - } + @ConfigItem( + position = 3, + keyName = "attackBarEmpties", + name = "Empties Before Attack", + description = "Controls whether the attack bar will fully empty before a new attack can occur", + section = ATTACK_BAR_SETTINGS + ) + default boolean barEmpties() + { + return true; + } - @ConfigItem( - position = 4, - keyName = "attackBarFills", - name = "Fills Before Attack", - description = "Controls whether the attack bar will fill completely after an attack", - section = AttackBarSettings - ) - default boolean barFills() - { - return true; - } + @ConfigItem( + position = 4, + keyName = "attackBarFills", + name = "Fills Before Attack", + description = "Controls whether the attack bar will fill completely after an attack", + section = ATTACK_BAR_SETTINGS + ) + default boolean barFills() + { + return true; + } - @ConfigItem( - position = 5, - keyName = "attackBarDirection", - name = "Attack Bar Fills or Drains", - description = "Controls whether the attack bar will fill or drain as a cooldown", - section = AttackBarSettings - ) - default boolean barDirection() - { - return true; - } + @ConfigItem( + position = 5, + keyName = "attackBarDirection", + name = "Attack Bar Fills or Drains", + description = "Controls whether the attack bar will fill or drain as a cooldown", + section = ATTACK_BAR_SETTINGS + ) + default boolean barDirection() + { + return true; + } - @ConfigItem( - position = 6, - keyName = "attackBarStyle", - name = "Attack Bar Style", - description = "Auto matches HD/SD from Interface Styles plugin. Standard forces the basic bar. High Detail forces the HD bar.", - section = AttackBarSettings - ) - default AttackBarStyle barStyle() - { - return AttackBarStyle.AUTO; - } + @ConfigItem( + position = 6, + keyName = "attackBarStyle", + name = "Attack Bar Style", + description = "Auto matches HD/SD from Interface Styles plugin. Standard forces the basic bar. High Detail forces the HD bar.", + section = ATTACK_BAR_SETTINGS + ) + default AttackBarStyle barStyle() + { + return AttackBarStyle.AUTO; + } - @Getter - @AllArgsConstructor - enum TicksPosition - { - DEFAULT("Default"), - TOP("Top"), - CENTERED("Centered"), - BOTTOM("Bottom"); + @Getter + @AllArgsConstructor + enum TicksPosition + { + DEFAULT("Default"), + TOP("Top"), + CENTERED("Centered"), + BOTTOM("Bottom"); - private final String name; + private final String name; - @Override - public String toString() - { - return name; - } - } + @Override + public String toString() + { + return name; + } + } } diff --git a/src/main/java/com/attacktimer/AttackTimerMetronomePlugin.java b/src/main/java/com/attacktimer/AttackTimerMetronomePlugin.java index 6fe56d6..8428378 100644 --- a/src/main/java/com/attacktimer/AttackTimerMetronomePlugin.java +++ b/src/main/java/com/attacktimer/AttackTimerMetronomePlugin.java @@ -41,7 +41,6 @@ import java.util.Map; import java.util.Set; import java.util.regex.Pattern; - import javax.inject.Inject; import net.runelite.api.Actor; import net.runelite.api.Client; @@ -76,7 +75,8 @@ ) public class AttackTimerMetronomePlugin extends Plugin { - public enum AttackState { + public enum AttackState + { NOT_ATTACKING, DELAYED_FIRST_TICK, DELAYED, @@ -108,7 +108,7 @@ public enum AttackState { public int tickPeriod = 0; - private int uiUnshowDebounceTickCount = 0; + private int uiHideDebounceTickCount = 0; public int attackDelayHoldoffTicks = ATTACK_DELAY_NONE; public AttackState attackState = AttackState.NOT_ATTACKING; @@ -127,7 +127,7 @@ public enum AttackState { public int pendingEatDelayTicks = 0; - private static final int uiUnshowDebounceTicksMax = 1; + private static final int UI_HIDE_DEBOUNCE_TICKS_MAX = 1; private static final int ATTACK_DELAY_NONE = 0; public static final int DEFAULT_SIZE_UNIT_PX = 25; @@ -237,7 +237,8 @@ AttackTimerMetronomeConfig provideConfig(ConfigManager configManager) private int getItemIdFromContainer(ItemContainer container, int slotID) { - if (container == null) { + if (container == null) + { return -1; } final Item item = container.getItem(slotID); @@ -316,7 +317,8 @@ private int getWeaponSpeed(int weaponId, PoweredStaves stave, AnimationData curA } ItemStats weaponStats = getWeaponStats(weaponId); - if (weaponStats == null) { + if (weaponStats == null) + { return VariableSpeed.computeSpeed(client, curAnimation, AttackProcedure.MELEE_OR_RANGE, 4); // Assume barehanded == 4t } // Deadline for next available attack. @@ -384,7 +386,7 @@ private void performAttack() attackState = AttackState.DELAYED_FIRST_TICK; setAttackDelay(); tickPeriod = attackDelayHoldoffTicks; - uiUnshowDebounceTickCount = uiUnshowDebounceTicksMax; + uiHideDebounceTickCount = UI_HIDE_DEBOUNCE_TICKS_MAX; } public int getTicksUntilNextAttack() @@ -401,7 +403,7 @@ public boolean isAttackCooldownPending() { return attackState == AttackState.DELAYED || attackState == AttackState.DELAYED_FIRST_TICK - || uiUnshowDebounceTickCount > 0; + || uiHideDebounceTickCount > 0; } @@ -449,12 +451,15 @@ public void onInteractingChanged(InteractingChanged interactingChanged) Player p = client.getLocalPlayer(); - if (source.equals(p) && (target instanceof NPC)) { - switch (attackState) { + if (source.equals(p) && (target instanceof NPC)) + { + switch (attackState) + { case NOT_ATTACKING: // If not previously attacking, this action can result in a queued attack or // an instant attack. If its queued, don't trigger the cooldown yet. - if (isPlayerAttacking()) { + if (isPlayerAttacking()) + { performAttack(); } break; @@ -469,7 +474,8 @@ public void onInteractingChanged(InteractingChanged interactingChanged) applyAndClearEats(); } - private void applyAndClearEats() { + private void applyAndClearEats() + { int pendingEats = pendingEatDelayTicks; attackDelayHoldoffTicks += pendingEats; pendingEatDelayTicks -= pendingEats; @@ -481,12 +487,16 @@ public void onGameTick(GameTick tick) if (!config.enableMetronome()) return; VariableSpeed.onGameTick(client, tick); boolean isAttacking = isPlayerAttacking(); - switch (attackState) { + switch (attackState) + { case NOT_ATTACKING: - if (isAttacking) { + if (isAttacking) + { performAttack(); // Sets state to DELAYED_FIRST_TICK. - } else { - uiUnshowDebounceTickCount--; + } + else + { + uiHideDebounceTickCount--; } break; case DELAYED_FIRST_TICK: @@ -494,10 +504,14 @@ public void onGameTick(GameTick tick) attackState = AttackState.DELAYED; // fallthrough case DELAYED: - if (attackDelayHoldoffTicks <= 0) { // Eligible for a new attack - if (isAttacking) { + if (attackDelayHoldoffTicks <= 0) + { // Eligible for a new attack + if (isAttacking) + { performAttack(); - } else { + } + else + { attackState = AttackState.NOT_ATTACKING; } } @@ -542,7 +556,7 @@ public void writeState(ByteArrayDataOutput outChannel) StringBuilder sb = new StringBuilder(); // @formatter:off sb.append("tickPeriod: "); sb.append(this.tickPeriod);sb.append(SEPARATOR); - sb.append("uiUnshowDebounceTickCount: "); sb.append(this.uiUnshowDebounceTickCount);sb.append(SEPARATOR); + sb.append("uiHideDebounceTickCount: "); sb.append(this.uiHideDebounceTickCount);sb.append(SEPARATOR); sb.append("attackDelayHoldoffTicks: "); sb.append(this.attackDelayHoldoffTicks);sb.append(SEPARATOR); sb.append("attackState: "); sb.append(this.attackState);sb.append(SEPARATOR); sb.append("renderedState: "); sb.append(this.renderedState);sb.append(SEPARATOR); diff --git a/src/main/java/com/attacktimer/AttackTimerMetronomeTileOverlay.java b/src/main/java/com/attacktimer/AttackTimerMetronomeTileOverlay.java index fd20881..6abbff1 100644 --- a/src/main/java/com/attacktimer/AttackTimerMetronomeTileOverlay.java +++ b/src/main/java/com/attacktimer/AttackTimerMetronomeTileOverlay.java @@ -27,21 +27,21 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +import java.awt.Dimension; +import java.awt.Font; +import java.awt.Graphics2D; +import javax.inject.Inject; import net.runelite.api.Client; import net.runelite.api.Perspective; -import net.runelite.api.Point; import net.runelite.api.Player; +import net.runelite.api.Point; import net.runelite.api.coords.LocalPoint; import net.runelite.client.ui.FontManager; import net.runelite.client.ui.overlay.Overlay; -import net.runelite.client.ui.overlay.OverlayPosition; -import net.runelite.client.ui.overlay.OverlayUtil; -import javax.inject.Inject; -import java.awt.Dimension; -import java.awt.Graphics2D; -import java.awt.Font; import net.runelite.client.ui.overlay.OverlayLayer; +import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.OverlayPriority; +import net.runelite.client.ui.overlay.OverlayUtil; public class AttackTimerMetronomeTileOverlay extends Overlay @@ -70,7 +70,8 @@ public Dimension render(Graphics2D graphics) { player = client.getLocalPlayer(); plugin.renderedState = plugin.attackState; - if (plugin.attackState == AttackTimerMetronomePlugin.AttackState.NOT_ATTACKING) { + if (plugin.attackState == AttackTimerMetronomePlugin.AttackState.NOT_ATTACKING) + { return null; } @@ -96,7 +97,8 @@ else if (config.fontType() == FontTypes.BOLD) final LocalPoint localLocation = client.getLocalPlayer().getLocalLocation(); Point playerPoint = null; - switch (config.ticksPosition()) { + switch (config.ticksPosition()) + { case TOP: playerPoint = Perspective.localToCanvas(client, localLocation, client.getTopLevelWorldView().getPlane(), 214 + config.heightTickOffset()); break; @@ -114,7 +116,8 @@ else if (config.fontType() == FontTypes.BOLD) playerPoint = Perspective.localToCanvas(client, localLocation, client.getTopLevelWorldView().getPlane(), height); break; } - if (playerPoint != null) { + if (playerPoint != null) + { int displayTicksRemaining = config.useZeroBasedTickCount() ? ticksRemaining - 1 : ticksRemaining; OverlayUtil.renderTextLocation(graphics, playerPoint, String.valueOf(displayTicksRemaining), ticksRemaining == 1 ? config.LastColor() : config.NumberColor()); } diff --git a/src/main/java/com/attacktimer/CastingSoundData.java b/src/main/java/com/attacktimer/CastingSoundData.java index 30584e6..a6c2066 100644 --- a/src/main/java/com/attacktimer/CastingSoundData.java +++ b/src/main/java/com/attacktimer/CastingSoundData.java @@ -86,7 +86,7 @@ enum CastingSoundData } - private static final ImmutableMap sounds; + private static final ImmutableMap SOUNDS; static { @@ -97,20 +97,20 @@ enum CastingSoundData builder.put(data.id, data); } - sounds = builder.build(); + SOUNDS = builder.build(); } public static boolean isCastingSound(int id) { - return sounds.containsKey(id); + return SOUNDS.containsKey(id); } public static Spellbook getSpellBookFromId(int id) { - if (!sounds.containsKey(id)) + if (!SOUNDS.containsKey(id)) { return null; } - return sounds.get(id).spellbook; + return SOUNDS.get(id).spellbook; } } diff --git a/src/main/java/com/attacktimer/FontTypes.java b/src/main/java/com/attacktimer/FontTypes.java index 1204096..d8c7ea5 100644 --- a/src/main/java/com/attacktimer/FontTypes.java +++ b/src/main/java/com/attacktimer/FontTypes.java @@ -19,7 +19,8 @@ public enum FontTypes private final String name; @Override - public String toString() { + public String toString() + { return name; } } diff --git a/src/main/java/com/attacktimer/PoweredStaves.java b/src/main/java/com/attacktimer/PoweredStaves.java index 0c602c0..fa9f765 100644 --- a/src/main/java/com/attacktimer/PoweredStaves.java +++ b/src/main/java/com/attacktimer/PoweredStaves.java @@ -25,14 +25,14 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; import java.util.Arrays; import java.util.HashSet; import java.util.Set; import java.util.stream.Collectors; -import org.apache.commons.lang3.StringUtils; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; import lombok.Getter; +import org.apache.commons.lang3.StringUtils; // https://oldschool.runescape.wiki/w/Powered_staff // @@ -128,7 +128,7 @@ private static Set Projectiles(int... id) protected static final boolean LOCAL_DEBUGGING = false; protected static final int UNKNOWN_SPELL = 0xDEADBEEF; - protected static final ImmutableMap> poweredStaves; + protected static final ImmutableMap> POWERED_STAVES; static { @@ -164,12 +164,12 @@ private static Set Projectiles(int... id) builder.put(21006, spellMap.build()); } - poweredStaves = builder.build(); + POWERED_STAVES = builder.build(); } public static PoweredStaves getPoweredStaves(int weaponId, AnimationData animation) { - ImmutableMap weaponMap = poweredStaves.get(weaponId); + ImmutableMap weaponMap = POWERED_STAVES.get(weaponId); if (weaponMap == null || animation == null) { return null; diff --git a/src/main/java/com/attacktimer/Spellbook.java b/src/main/java/com/attacktimer/Spellbook.java index daf0d50..e9f63af 100644 --- a/src/main/java/com/attacktimer/Spellbook.java +++ b/src/main/java/com/attacktimer/Spellbook.java @@ -41,7 +41,7 @@ enum Spellbook this.id = id; } - private static final ImmutableMap books; + private static final ImmutableMap BOOKS; static { @@ -52,11 +52,11 @@ enum Spellbook builder.put(data.id, data); } - books = builder.build(); + BOOKS = builder.build(); } public static Spellbook fromVarbit(int varbit) { - return books.get(varbit); + return BOOKS.get(varbit); } } diff --git a/src/main/java/com/attacktimer/VariableSpeed/BloodMoonSet.java b/src/main/java/com/attacktimer/VariableSpeed/BloodMoonSet.java index c197b71..6c06ec5 100644 --- a/src/main/java/com/attacktimer/VariableSpeed/BloodMoonSet.java +++ b/src/main/java/com/attacktimer/VariableSpeed/BloodMoonSet.java @@ -32,10 +32,10 @@ public class BloodMoonSet implements IVariableSpeed { - private static final int BloodMoonSetAnimId = 2792; + private static final int BLOOD_MOON_SET_ANIM_ID = 2792; public int apply(final Client client, final AnimationData curAnimation, final AttackProcedure atkProcedure, final int baseSpeed, final int curSpeed) { - if (client.getLocalPlayer().hasSpotAnim(BloodMoonSetAnimId)) + if (client.getLocalPlayer().hasSpotAnim(BLOOD_MOON_SET_ANIM_ID)) { return curSpeed-1; } diff --git a/src/main/java/com/attacktimer/VariableSpeed/Leagues4and5.java b/src/main/java/com/attacktimer/VariableSpeed/Leagues4and5.java index 3a4e704..9decc6d 100644 --- a/src/main/java/com/attacktimer/VariableSpeed/Leagues4and5.java +++ b/src/main/java/com/attacktimer/VariableSpeed/Leagues4and5.java @@ -30,7 +30,6 @@ import com.attacktimer.AttackProcedure; import com.attacktimer.AttackStyle; import com.attacktimer.ClientUtils.Utils; - import net.runelite.api.Client; import net.runelite.api.Varbits; import net.runelite.api.WorldType; diff --git a/src/main/java/com/attacktimer/VariableSpeed/RapidAttackStyle.java b/src/main/java/com/attacktimer/VariableSpeed/RapidAttackStyle.java index 0931d5f..3109531 100644 --- a/src/main/java/com/attacktimer/VariableSpeed/RapidAttackStyle.java +++ b/src/main/java/com/attacktimer/VariableSpeed/RapidAttackStyle.java @@ -27,8 +27,8 @@ */ import com.attacktimer.AnimationData; -import com.attacktimer.AttackStyle; import com.attacktimer.AttackProcedure; +import com.attacktimer.AttackStyle; import com.attacktimer.ClientUtils.Utils; import net.runelite.api.Client; import net.runelite.api.VarPlayer; diff --git a/src/main/java/com/attacktimer/VariableSpeed/TormentedDemons.java b/src/main/java/com/attacktimer/VariableSpeed/TormentedDemons.java index 749092c..98ec413 100644 --- a/src/main/java/com/attacktimer/VariableSpeed/TormentedDemons.java +++ b/src/main/java/com/attacktimer/VariableSpeed/TormentedDemons.java @@ -25,15 +25,15 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; -import java.util.Map.Entry; import com.attacktimer.AnimationData; import com.attacktimer.AttackProcedure; import com.attacktimer.AttackType; -import com.attacktimer.WeaponType; import com.attacktimer.ClientUtils.Utils; +import com.attacktimer.WeaponType; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; import net.runelite.api.Client; import net.runelite.api.NPC; import net.runelite.api.events.GameTick; @@ -131,7 +131,10 @@ public void onGameTick(Client client, GameTick tick) tickCount++; for (NPC npc : client.getTopLevelWorldView().npcs()) { - if (!isTormentedDemon(npc.getId())) { continue; } + if (!isTormentedDemon(npc.getId())) + { + continue; + } boolean isVulnerable = npc.hasSpotAnim(TORMENTED_DEMON_VULN_SPOT_ANIM); if (tormentedDemons.containsKey(npc)) { @@ -169,7 +172,7 @@ class DemonData { // VulTicksAfterEnd is just a guess the wiki isn't clear how long this period is, from testing 10 // ticks feels about right. - private static final int VulTicksAfterEnd = 10; + private static final int VULN_TICKS_AFTER_END = 10; private int lastSpotted; private Integer vulnerableStart; private Integer vulnerableFinish; @@ -212,7 +215,7 @@ boolean isVulnerable(int tick) { return false; } - return (this.vulnerableFinish + VulTicksAfterEnd) > tick; + return (this.vulnerableFinish + VULN_TICKS_AFTER_END) > tick; } // isStale returns true if the last time this demon was spotted by the client was too long ago. @@ -235,7 +238,7 @@ boolean vulnConsumed(int tick) this.consumeVuln(tick); return false; } - else if (this.attacked > tick + VulTicksAfterEnd) + else if (this.attacked > tick + VULN_TICKS_AFTER_END) { // already attacked within the window don't consume the vuln again we let update handle this return true; diff --git a/src/main/java/com/attacktimer/VariableSpeed/VariableSpeed.java b/src/main/java/com/attacktimer/VariableSpeed/VariableSpeed.java index f84abaa..21f3ede 100644 --- a/src/main/java/com/attacktimer/VariableSpeed/VariableSpeed.java +++ b/src/main/java/com/attacktimer/VariableSpeed/VariableSpeed.java @@ -25,13 +25,13 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import com.attacktimer.AttackProcedure; import com.attacktimer.AnimationData; +import com.attacktimer.AttackProcedure; import net.runelite.api.Client; import net.runelite.api.events.GameTick; -public class VariableSpeed { - +public class VariableSpeed +{ /** * computeSpeed will forward the client, animation data and current weapon speed to all the known classes * which can affect the base speed of a weapon. See implementations of IVariableSpeed. @@ -44,7 +44,7 @@ public class VariableSpeed { public static int computeSpeed(final Client client, final AnimationData curAnimation, final AttackProcedure atkProcedure, final int baseSpeed) { int newSpeed = baseSpeed; - for (IVariableSpeed i : toApply) + for (IVariableSpeed i : TO_APPLY) { newSpeed = i.apply(client, curAnimation, atkProcedure, baseSpeed, newSpeed); } @@ -53,13 +53,13 @@ public static int computeSpeed(final Client client, final AnimationData curAnima public static void onGameTick(Client client, GameTick tick) { - for (IVariableSpeed i : toApply) + for (IVariableSpeed i : TO_APPLY) { i.onGameTick(client, tick); } } - private static final IVariableSpeed[] toApply = { + private static final IVariableSpeed[] TO_APPLY = { // Order matters, apply leagues first, then any incremental modifications like rapid, or set effects. // Then overriding speeds last, which set a speed. // new Leagues4and5(), diff --git a/src/main/java/com/attacktimer/WeaponType.java b/src/main/java/com/attacktimer/WeaponType.java index 3fc99f4..d76eb3e 100644 --- a/src/main/java/com/attacktimer/WeaponType.java +++ b/src/main/java/com/attacktimer/WeaponType.java @@ -26,9 +26,6 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import com.google.common.collect.ImmutableMap; -import java.util.Map; -import lombok.Getter; import static com.attacktimer.AttackStyle.ACCURATE; import static com.attacktimer.AttackStyle.AGGRESSIVE; import static com.attacktimer.AttackStyle.CASTING; @@ -36,15 +33,18 @@ import static com.attacktimer.AttackStyle.DEFENSIVE_CASTING; import static com.attacktimer.AttackStyle.OTHER; import static com.attacktimer.AttackType.CRUSH; -import static com.attacktimer.AttackType.SLASH; -import static com.attacktimer.AttackType.STAB; -import static com.attacktimer.AttackType.RANGED; import static com.attacktimer.AttackType.MAGIC; import static com.attacktimer.AttackType.NONE; +import static com.attacktimer.AttackType.RANGED; +import static com.attacktimer.AttackType.SLASH; +import static com.attacktimer.AttackType.STAB; +import com.google.common.collect.ImmutableMap; +import java.util.Map; +import lombok.Getter; import net.runelite.api.Client; -import net.runelite.api.ParamID; import net.runelite.api.EnumID; +import net.runelite.api.ParamID; import net.runelite.api.StructComposition; public enum WeaponType @@ -91,7 +91,7 @@ public enum WeaponType PARTISAN(MAGIC, MAGIC, null, MAGIC), PARTISAN_2(STAB, STAB, CRUSH, STAB); - private static final Map weaponTypes; + private static final Map WEAPON_TYPES; @Getter private final AttackType[] attackTypes; @@ -105,7 +105,7 @@ public enum WeaponType builder.put(weaponType.ordinal(), weaponType); } - weaponTypes = builder.build(); + WEAPON_TYPES = builder.build(); } WeaponType(AttackType... attackTypes) @@ -133,7 +133,7 @@ public AttackStyle[] getAttackStyles(Client client) if (weaponType == 22) { return new AttackStyle[]{ - ACCURATE, AGGRESSIVE, null, DEFENSIVE, CASTING, DEFENSIVE_CASTING + ACCURATE, AGGRESSIVE, null, DEFENSIVE, CASTING, DEFENSIVE_CASTING, }; } @@ -141,7 +141,7 @@ public AttackStyle[] getAttackStyles(Client client) { // Partisan return new AttackStyle[]{ - ACCURATE, AGGRESSIVE, AGGRESSIVE, DEFENSIVE + ACCURATE, AGGRESSIVE, AGGRESSIVE, DEFENSIVE, }; } return new AttackStyle[0]; @@ -175,6 +175,6 @@ public AttackStyle[] getAttackStyles(Client client) public static WeaponType getWeaponType(int id) { - return weaponTypes.get(id); + return WEAPON_TYPES.get(id); } } \ No newline at end of file diff --git a/src/test/java/com/attacktimer/AttackTimerPluginTest.java b/src/test/java/com/attacktimer/AttackTimerPluginTest.java index a6374e7..2f3d4e5 100644 --- a/src/test/java/com/attacktimer/AttackTimerPluginTest.java +++ b/src/test/java/com/attacktimer/AttackTimerPluginTest.java @@ -5,9 +5,9 @@ public class AttackTimerPluginTest { - public static void main(String[] args) throws Exception - { - ExternalPluginManager.loadBuiltin(AttackTimerMetronomePlugin.class); - RuneLite.main(args); - } + public static void main(String[] args) throws Exception + { + ExternalPluginManager.loadBuiltin(AttackTimerMetronomePlugin.class); + RuneLite.main(args); + } } \ No newline at end of file diff --git a/src/test/java/com/attacktimer/BasicTests.java b/src/test/java/com/attacktimer/BasicTests.java index 3fbdbf3..adf2161 100644 --- a/src/test/java/com/attacktimer/BasicTests.java +++ b/src/test/java/com/attacktimer/BasicTests.java @@ -25,23 +25,18 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import static org.mockito.Mockito.when; - -import java.nio.file.Paths; - import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; - -import org.junit.Test; +import static org.mockito.Mockito.when; import com.attacktimer.AttackTimerMetronomePlugin.AttackState; - import com.google.common.io.ByteArrayDataOutput; import com.google.common.io.ByteStreams; - +import java.nio.file.Paths; import net.runelite.api.ChatMessageType; import net.runelite.api.Player; import net.runelite.api.events.ChatMessage; +import org.junit.Test; public class BasicTests extends IntegrationTests { @@ -78,7 +73,7 @@ public void basicTest() throws Exception assertSame(atkSpeed, underTest.attackDelayHoldoffTicks); // clear the animation - when(mockedPlayer.getAnimation()).thenReturn(noAnimation); + when(mockedPlayer.getAnimation()).thenReturn(NO_ANIMATION); writeTestMessage("4. Check that the plugin counts down correctly", channel); while (atkSpeed > 0) @@ -104,7 +99,7 @@ public void basicTest() throws Exception assertTrue(underTest.attackDelayHoldoffTicks < 0); // hold off should go negative } - performStateVerificationOrUpdate(channel, Paths.get(testdata + "basicTest.txt")); + performStateVerificationOrUpdate(channel, Paths.get(TESTDATA + "basicTest.txt")); } @Test @@ -131,7 +126,7 @@ public void eatingFoodTest() throws Exception assertSame(AttackState.DELAYED_FIRST_TICK, underTest.attackState); assertSame(atkSpeed, underTest.attackDelayHoldoffTicks); - when(mockedPlayer.getAnimation()).thenReturn(noAnimation); + when(mockedPlayer.getAnimation()).thenReturn(NO_ANIMATION); underTest.writeState(channel); writeTestMessage("Perform an eat", channel); @@ -178,6 +173,6 @@ public void eatingFoodTest() throws Exception assertSame(atkSpeed, underTest.attackDelayHoldoffTicks); } - performStateVerificationOrUpdate(channel, Paths.get(testdata + "eatingFoodTest.txt")); + performStateVerificationOrUpdate(channel, Paths.get(TESTDATA + "eatingFoodTest.txt")); } } diff --git a/src/test/java/com/attacktimer/EatTest.java b/src/test/java/com/attacktimer/EatTest.java index c11c70a..90de1aa 100644 --- a/src/test/java/com/attacktimer/EatTest.java +++ b/src/test/java/com/attacktimer/EatTest.java @@ -25,16 +25,15 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import static org.mockito.Mockito.when; import static org.junit.Assert.assertSame; -import org.junit.Test; +import static org.mockito.Mockito.when; import com.attacktimer.AttackTimerMetronomePlugin.AttackState; - import net.runelite.api.ChatMessageType; import net.runelite.api.Player; import net.runelite.api.events.ChatMessage; import net.runelite.api.events.GameTick; +import org.junit.Test; public class EatTest extends IntegrationTests { @@ -54,7 +53,7 @@ public void ExhaustiveEatTest() throws Exception }; String[] foodsToTest = { "shark", "meat pizza", "A brand new food message", "sunlight antelope", "moonlight antelope", - "purple sweets" + "purple sweets", }; var curEatDelayTicks = underTest.pendingEatDelayTicks; for (String food : foodsToTest) diff --git a/src/test/java/com/attacktimer/EnumTests.java b/src/test/java/com/attacktimer/EnumTests.java index a8fbdcd..c47fc2f 100644 --- a/src/test/java/com/attacktimer/EnumTests.java +++ b/src/test/java/com/attacktimer/EnumTests.java @@ -27,6 +27,7 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.fail; + import org.junit.Ignore; import org.junit.Test; import org.slf4j.helpers.MessageFormatter; @@ -70,7 +71,7 @@ public void missingIdReport() { for (int id : staff.getIds()) { - boolean containsKey = PoweredStaves.poweredStaves.get(id).containsKey(PoweredStaves.UNKNOWN_SPELL); + boolean containsKey = PoweredStaves.POWERED_STAVES.get(id).containsKey(PoweredStaves.UNKNOWN_SPELL); if (containsKey) { failed = true; diff --git a/src/test/java/com/attacktimer/IntegrationTests.java b/src/test/java/com/attacktimer/IntegrationTests.java index c8d75da..ae4e7aa 100644 --- a/src/test/java/com/attacktimer/IntegrationTests.java +++ b/src/test/java/com/attacktimer/IntegrationTests.java @@ -25,9 +25,16 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.fail; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; +import com.google.common.io.ByteArrayDataOutput; +import com.google.inject.Guice; +import com.google.inject.Inject; +import com.google.inject.testing.fieldbinder.Bind; +import com.google.inject.testing.fieldbinder.BoundFieldModule; import java.io.IOException; import java.nio.ByteBuffer; import java.nio.charset.StandardCharsets; @@ -36,22 +43,6 @@ import java.nio.file.StandardOpenOption; import java.util.Collections; import java.util.EnumSet; - -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.fail; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; - -import com.google.common.io.ByteArrayDataOutput; -import com.google.inject.Guice; -import com.google.inject.Inject; -import com.google.inject.testing.fieldbinder.Bind; -import com.google.inject.testing.fieldbinder.BoundFieldModule; - import net.runelite.api.Client; import net.runelite.api.EnumComposition; import net.runelite.api.EnumID; @@ -59,7 +50,6 @@ import net.runelite.api.NPC; import net.runelite.api.NPCComposition; import net.runelite.api.Player; -import net.runelite.api.WorldType; import net.runelite.api.WorldView; import net.runelite.api.coords.LocalPoint; import net.runelite.api.coords.WorldPoint; @@ -68,6 +58,11 @@ import net.runelite.client.game.ItemManager; import net.runelite.client.game.NPCManager; import net.runelite.client.ui.overlay.OverlayManager; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnitRunner; @RunWith(MockitoJUnitRunner.class) public class IntegrationTests @@ -119,7 +114,7 @@ public Player pluginMockSetup() throws Exception when(mockedConfig.enableMetronome()).thenReturn(true); // Create player Player mockedPlayer = mock(Player.class); - when(mockedPlayer.getAnimation()).thenReturn(noAnimation); + when(mockedPlayer.getAnimation()).thenReturn(NO_ANIMATION); // Create the enemy NPC mockedTarget = mock(NPC.class); @@ -128,7 +123,7 @@ public Player pluginMockSetup() throws Exception int mockedNpcId = 0xFFFF; when(mockedTarget.getId()).thenReturn(mockedNpcId); String[] actions = { - "Attack", "Examine" + "Attack", "Examine", }; when(mockedCompositions.getActions()).thenReturn(actions); when(mockedNpcManager.getHealth(mockedNpcId)).thenReturn(1); @@ -180,6 +175,7 @@ protected void performStateVerificationOrUpdate(ByteArrayDataOutput channel, Pat file.write(ByteBuffer.wrap(actualBytes)); file.close(); } + fail("Updated file: " + path); return; default: fail("Unexpected Update enum"); @@ -194,16 +190,16 @@ protected void onGameTick(ByteArrayDataOutput file) protected void writeTestMessage(String message, ByteArrayDataOutput file) { - file.write(testMessagePrefix); + file.write(PREFIX); file.write(message.getBytes(StandardCharsets.UTF_8)); - file.write(testMessageSuffix); + file.write(SUFFIX); } - protected static final int noAnimation = -1; - protected static final String testdata = "src/test/java/com/attacktimer/testdata/"; + protected static final int NO_ANIMATION = -1; + protected static final String TESTDATA = "src/test/java/com/attacktimer/testdata/"; - private static final byte[] testMessagePrefix = "[TEST MESSAGE] ".getBytes(StandardCharsets.UTF_8); - private static final byte[] testMessageSuffix = "\n".getBytes(StandardCharsets.UTF_8); + private static final byte[] PREFIX = "[TEST MESSAGE] ".getBytes(StandardCharsets.UTF_8); + private static final byte[] SUFFIX = "\n".getBytes(StandardCharsets.UTF_8); // This needs at least one public test to keep mockito happy but having real tests in this file would // result in any future test which extends this test class also having to run and make that test pass. diff --git a/src/test/java/com/attacktimer/TormentedDemonsTest.java b/src/test/java/com/attacktimer/TormentedDemonsTest.java index 97c7cd2..e209301 100644 --- a/src/test/java/com/attacktimer/TormentedDemonsTest.java +++ b/src/test/java/com/attacktimer/TormentedDemonsTest.java @@ -25,20 +25,15 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +import static org.junit.Assert.assertSame; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.EnumSet; - -import static org.junit.Assert.assertSame; -import org.junit.Test; - import com.attacktimer.AttackTimerMetronomePlugin.AttackState; import com.google.common.io.ByteArrayDataOutput; import com.google.common.io.ByteStreams; - +import java.nio.file.Paths; +import java.util.ArrayList; import net.runelite.api.EnumComposition; import net.runelite.api.EnumID; import net.runelite.api.IndexedObjectSet; @@ -47,12 +42,12 @@ import net.runelite.api.Player; import net.runelite.api.VarPlayer; import net.runelite.api.Varbits; -import net.runelite.api.WorldType; import net.runelite.api.WorldView; import net.runelite.api.coords.LocalPoint; import net.runelite.api.coords.WorldPoint; import net.runelite.client.game.ItemEquipmentStats; import net.runelite.client.game.ItemStats; +import org.junit.Test; public class TormentedDemonsTest extends IntegrationTests { @@ -107,7 +102,7 @@ private void runTest(String testName, int aspeed, int EQUIPPED_WEAPON_TYPE, int assertSame(AttackState.DELAYED_FIRST_TICK, underTest.attackState); assertSame(expected, underTest.attackDelayHoldoffTicks); - performStateVerificationOrUpdate(channel, Paths.get(testdata + testName + ".txt")); + performStateVerificationOrUpdate(channel, Paths.get(TESTDATA + testName + ".txt")); } @Override @@ -126,7 +121,7 @@ public Player pluginMockSetup() throws Exception int mockedNpcId = 13600; when(td.getId()).thenReturn(mockedNpcId); String[] actions = { - "Attack", "Examine" + "Attack", "Examine", }; when(mockedCompositions.getActions()).thenReturn(actions); when(mockedNpcManager.getHealth(mockedNpcId)).thenReturn(1); diff --git a/src/test/java/com/attacktimer/Update.java b/src/test/java/com/attacktimer/Update.java index 0fe8b44..2e1e70f 100644 --- a/src/test/java/com/attacktimer/Update.java +++ b/src/test/java/com/attacktimer/Update.java @@ -25,9 +25,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import javax.annotation.Nonnull; - import com.google.common.collect.ImmutableMap; +import javax.annotation.Nonnull; public enum Update { @@ -42,7 +41,7 @@ public enum Update this.value = value; } - private static final ImmutableMap updates; + private static final ImmutableMap UPDATES; static { @@ -53,14 +52,14 @@ public enum Update builder.put(data.value, data); } - updates = builder.build(); + UPDATES = builder.build(); } public static Update of(String value) { if (value == null) return NONE; - Update update = updates.get(value.toLowerCase()); + Update update = UPDATES.get(value.toLowerCase()); if (update == null) return NONE; return update; diff --git a/src/test/java/com/attacktimer/testdata/PunishTest.txt b/src/test/java/com/attacktimer/testdata/PunishTest.txt index dda34c4..1489368 100644 --- a/src/test/java/com/attacktimer/testdata/PunishTest.txt +++ b/src/test/java/com/attacktimer/testdata/PunishTest.txt @@ -1,3 +1,3 @@ -tickPeriod: 0, uiUnshowDebounceTickCount: 0, attackDelayHoldoffTicks: 0, attackState: NOT_ATTACKING, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 -tickPeriod: 0, uiUnshowDebounceTickCount: -1, attackDelayHoldoffTicks: -1, attackState: NOT_ATTACKING, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 -tickPeriod: 4, uiUnshowDebounceTickCount: 1, attackDelayHoldoffTicks: 3, attackState: DELAYED_FIRST_TICK, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 +tickPeriod: 0, uiHideDebounceTickCount: 0, attackDelayHoldoffTicks: 0, attackState: NOT_ATTACKING, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 +tickPeriod: 0, uiHideDebounceTickCount: -1, attackDelayHoldoffTicks: -1, attackState: NOT_ATTACKING, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 +tickPeriod: 4, uiHideDebounceTickCount: 1, attackDelayHoldoffTicks: 3, attackState: DELAYED_FIRST_TICK, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 diff --git a/src/test/java/com/attacktimer/testdata/PunishWastedTest.txt b/src/test/java/com/attacktimer/testdata/PunishWastedTest.txt index dda34c4..1489368 100644 --- a/src/test/java/com/attacktimer/testdata/PunishWastedTest.txt +++ b/src/test/java/com/attacktimer/testdata/PunishWastedTest.txt @@ -1,3 +1,3 @@ -tickPeriod: 0, uiUnshowDebounceTickCount: 0, attackDelayHoldoffTicks: 0, attackState: NOT_ATTACKING, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 -tickPeriod: 0, uiUnshowDebounceTickCount: -1, attackDelayHoldoffTicks: -1, attackState: NOT_ATTACKING, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 -tickPeriod: 4, uiUnshowDebounceTickCount: 1, attackDelayHoldoffTicks: 3, attackState: DELAYED_FIRST_TICK, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 +tickPeriod: 0, uiHideDebounceTickCount: 0, attackDelayHoldoffTicks: 0, attackState: NOT_ATTACKING, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 +tickPeriod: 0, uiHideDebounceTickCount: -1, attackDelayHoldoffTicks: -1, attackState: NOT_ATTACKING, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 +tickPeriod: 4, uiHideDebounceTickCount: 1, attackDelayHoldoffTicks: 3, attackState: DELAYED_FIRST_TICK, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 diff --git a/src/test/java/com/attacktimer/testdata/PunishWastedWrongStyleTest.txt b/src/test/java/com/attacktimer/testdata/PunishWastedWrongStyleTest.txt index 4606678..ae5d4f2 100644 --- a/src/test/java/com/attacktimer/testdata/PunishWastedWrongStyleTest.txt +++ b/src/test/java/com/attacktimer/testdata/PunishWastedWrongStyleTest.txt @@ -1,3 +1,3 @@ -tickPeriod: 0, uiUnshowDebounceTickCount: 0, attackDelayHoldoffTicks: 0, attackState: NOT_ATTACKING, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 -tickPeriod: 0, uiUnshowDebounceTickCount: -1, attackDelayHoldoffTicks: -1, attackState: NOT_ATTACKING, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 -tickPeriod: 8, uiUnshowDebounceTickCount: 1, attackDelayHoldoffTicks: 7, attackState: DELAYED_FIRST_TICK, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 +tickPeriod: 0, uiHideDebounceTickCount: 0, attackDelayHoldoffTicks: 0, attackState: NOT_ATTACKING, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 +tickPeriod: 0, uiHideDebounceTickCount: -1, attackDelayHoldoffTicks: -1, attackState: NOT_ATTACKING, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 +tickPeriod: 8, uiHideDebounceTickCount: 1, attackDelayHoldoffTicks: 7, attackState: DELAYED_FIRST_TICK, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 diff --git a/src/test/java/com/attacktimer/testdata/basicTest.txt b/src/test/java/com/attacktimer/testdata/basicTest.txt index eae54c4..e68694b 100644 --- a/src/test/java/com/attacktimer/testdata/basicTest.txt +++ b/src/test/java/com/attacktimer/testdata/basicTest.txt @@ -1,37 +1,37 @@ -tickPeriod: 0, uiUnshowDebounceTickCount: 0, attackDelayHoldoffTicks: 0, attackState: NOT_ATTACKING, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 +tickPeriod: 0, uiHideDebounceTickCount: 0, attackDelayHoldoffTicks: 0, attackState: NOT_ATTACKING, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 [TEST MESSAGE] 1. Start by setting up the player and plugin [TEST MESSAGE] 2. Mock an attack animation -tickPeriod: 4, uiUnshowDebounceTickCount: 1, attackDelayHoldoffTicks: 3, attackState: DELAYED_FIRST_TICK, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 +tickPeriod: 4, uiHideDebounceTickCount: 1, attackDelayHoldoffTicks: 3, attackState: DELAYED_FIRST_TICK, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 [TEST MESSAGE] 3. Check that the plugin has registered the attack [TEST MESSAGE] 4. Check that the plugin counts down correctly -tickPeriod: 4, uiUnshowDebounceTickCount: 1, attackDelayHoldoffTicks: 2, attackState: DELAYED, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 -tickPeriod: 4, uiUnshowDebounceTickCount: 1, attackDelayHoldoffTicks: 1, attackState: DELAYED, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 -tickPeriod: 4, uiUnshowDebounceTickCount: 1, attackDelayHoldoffTicks: 0, attackState: DELAYED, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 +tickPeriod: 4, uiHideDebounceTickCount: 1, attackDelayHoldoffTicks: 2, attackState: DELAYED, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 +tickPeriod: 4, uiHideDebounceTickCount: 1, attackDelayHoldoffTicks: 1, attackState: DELAYED, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 +tickPeriod: 4, uiHideDebounceTickCount: 1, attackDelayHoldoffTicks: 0, attackState: DELAYED, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 [TEST MESSAGE] 5. Check that the plugin is back to a waiting state and it still counts down -tickPeriod: 4, uiUnshowDebounceTickCount: 1, attackDelayHoldoffTicks: -1, attackState: NOT_ATTACKING, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 -tickPeriod: 4, uiUnshowDebounceTickCount: 0, attackDelayHoldoffTicks: -2, attackState: NOT_ATTACKING, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 -tickPeriod: 4, uiUnshowDebounceTickCount: -1, attackDelayHoldoffTicks: -3, attackState: NOT_ATTACKING, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 -tickPeriod: 4, uiUnshowDebounceTickCount: -2, attackDelayHoldoffTicks: -4, attackState: NOT_ATTACKING, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 -tickPeriod: 4, uiUnshowDebounceTickCount: -3, attackDelayHoldoffTicks: -5, attackState: NOT_ATTACKING, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 -tickPeriod: 4, uiUnshowDebounceTickCount: -4, attackDelayHoldoffTicks: -6, attackState: NOT_ATTACKING, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 -tickPeriod: 4, uiUnshowDebounceTickCount: -5, attackDelayHoldoffTicks: -7, attackState: NOT_ATTACKING, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 -tickPeriod: 4, uiUnshowDebounceTickCount: -6, attackDelayHoldoffTicks: -8, attackState: NOT_ATTACKING, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 -tickPeriod: 4, uiUnshowDebounceTickCount: -7, attackDelayHoldoffTicks: -9, attackState: NOT_ATTACKING, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 -tickPeriod: 4, uiUnshowDebounceTickCount: -8, attackDelayHoldoffTicks: -10, attackState: NOT_ATTACKING, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 -tickPeriod: 4, uiUnshowDebounceTickCount: -9, attackDelayHoldoffTicks: -11, attackState: NOT_ATTACKING, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 -tickPeriod: 4, uiUnshowDebounceTickCount: -10, attackDelayHoldoffTicks: -12, attackState: NOT_ATTACKING, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 -tickPeriod: 4, uiUnshowDebounceTickCount: -11, attackDelayHoldoffTicks: -13, attackState: NOT_ATTACKING, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 -tickPeriod: 4, uiUnshowDebounceTickCount: -12, attackDelayHoldoffTicks: -14, attackState: NOT_ATTACKING, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 -tickPeriod: 4, uiUnshowDebounceTickCount: -13, attackDelayHoldoffTicks: -15, attackState: NOT_ATTACKING, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 -tickPeriod: 4, uiUnshowDebounceTickCount: -14, attackDelayHoldoffTicks: -16, attackState: NOT_ATTACKING, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 -tickPeriod: 4, uiUnshowDebounceTickCount: -15, attackDelayHoldoffTicks: -17, attackState: NOT_ATTACKING, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 -tickPeriod: 4, uiUnshowDebounceTickCount: -16, attackDelayHoldoffTicks: -18, attackState: NOT_ATTACKING, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 -tickPeriod: 4, uiUnshowDebounceTickCount: -17, attackDelayHoldoffTicks: -19, attackState: NOT_ATTACKING, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 -tickPeriod: 4, uiUnshowDebounceTickCount: -18, attackDelayHoldoffTicks: -20, attackState: NOT_ATTACKING, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 -tickPeriod: 4, uiUnshowDebounceTickCount: -19, attackDelayHoldoffTicks: -20, attackState: NOT_ATTACKING, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 -tickPeriod: 4, uiUnshowDebounceTickCount: -20, attackDelayHoldoffTicks: -20, attackState: NOT_ATTACKING, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 -tickPeriod: 4, uiUnshowDebounceTickCount: -21, attackDelayHoldoffTicks: -20, attackState: NOT_ATTACKING, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 -tickPeriod: 4, uiUnshowDebounceTickCount: -22, attackDelayHoldoffTicks: -20, attackState: NOT_ATTACKING, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 -tickPeriod: 4, uiUnshowDebounceTickCount: -23, attackDelayHoldoffTicks: -20, attackState: NOT_ATTACKING, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 -tickPeriod: 4, uiUnshowDebounceTickCount: -24, attackDelayHoldoffTicks: -20, attackState: NOT_ATTACKING, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 -tickPeriod: 4, uiUnshowDebounceTickCount: -25, attackDelayHoldoffTicks: -20, attackState: NOT_ATTACKING, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 +tickPeriod: 4, uiHideDebounceTickCount: 1, attackDelayHoldoffTicks: -1, attackState: NOT_ATTACKING, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 +tickPeriod: 4, uiHideDebounceTickCount: 0, attackDelayHoldoffTicks: -2, attackState: NOT_ATTACKING, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 +tickPeriod: 4, uiHideDebounceTickCount: -1, attackDelayHoldoffTicks: -3, attackState: NOT_ATTACKING, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 +tickPeriod: 4, uiHideDebounceTickCount: -2, attackDelayHoldoffTicks: -4, attackState: NOT_ATTACKING, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 +tickPeriod: 4, uiHideDebounceTickCount: -3, attackDelayHoldoffTicks: -5, attackState: NOT_ATTACKING, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 +tickPeriod: 4, uiHideDebounceTickCount: -4, attackDelayHoldoffTicks: -6, attackState: NOT_ATTACKING, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 +tickPeriod: 4, uiHideDebounceTickCount: -5, attackDelayHoldoffTicks: -7, attackState: NOT_ATTACKING, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 +tickPeriod: 4, uiHideDebounceTickCount: -6, attackDelayHoldoffTicks: -8, attackState: NOT_ATTACKING, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 +tickPeriod: 4, uiHideDebounceTickCount: -7, attackDelayHoldoffTicks: -9, attackState: NOT_ATTACKING, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 +tickPeriod: 4, uiHideDebounceTickCount: -8, attackDelayHoldoffTicks: -10, attackState: NOT_ATTACKING, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 +tickPeriod: 4, uiHideDebounceTickCount: -9, attackDelayHoldoffTicks: -11, attackState: NOT_ATTACKING, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 +tickPeriod: 4, uiHideDebounceTickCount: -10, attackDelayHoldoffTicks: -12, attackState: NOT_ATTACKING, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 +tickPeriod: 4, uiHideDebounceTickCount: -11, attackDelayHoldoffTicks: -13, attackState: NOT_ATTACKING, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 +tickPeriod: 4, uiHideDebounceTickCount: -12, attackDelayHoldoffTicks: -14, attackState: NOT_ATTACKING, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 +tickPeriod: 4, uiHideDebounceTickCount: -13, attackDelayHoldoffTicks: -15, attackState: NOT_ATTACKING, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 +tickPeriod: 4, uiHideDebounceTickCount: -14, attackDelayHoldoffTicks: -16, attackState: NOT_ATTACKING, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 +tickPeriod: 4, uiHideDebounceTickCount: -15, attackDelayHoldoffTicks: -17, attackState: NOT_ATTACKING, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 +tickPeriod: 4, uiHideDebounceTickCount: -16, attackDelayHoldoffTicks: -18, attackState: NOT_ATTACKING, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 +tickPeriod: 4, uiHideDebounceTickCount: -17, attackDelayHoldoffTicks: -19, attackState: NOT_ATTACKING, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 +tickPeriod: 4, uiHideDebounceTickCount: -18, attackDelayHoldoffTicks: -20, attackState: NOT_ATTACKING, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 +tickPeriod: 4, uiHideDebounceTickCount: -19, attackDelayHoldoffTicks: -20, attackState: NOT_ATTACKING, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 +tickPeriod: 4, uiHideDebounceTickCount: -20, attackDelayHoldoffTicks: -20, attackState: NOT_ATTACKING, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 +tickPeriod: 4, uiHideDebounceTickCount: -21, attackDelayHoldoffTicks: -20, attackState: NOT_ATTACKING, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 +tickPeriod: 4, uiHideDebounceTickCount: -22, attackDelayHoldoffTicks: -20, attackState: NOT_ATTACKING, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 +tickPeriod: 4, uiHideDebounceTickCount: -23, attackDelayHoldoffTicks: -20, attackState: NOT_ATTACKING, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 +tickPeriod: 4, uiHideDebounceTickCount: -24, attackDelayHoldoffTicks: -20, attackState: NOT_ATTACKING, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 +tickPeriod: 4, uiHideDebounceTickCount: -25, attackDelayHoldoffTicks: -20, attackState: NOT_ATTACKING, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 diff --git a/src/test/java/com/attacktimer/testdata/eatingFoodTest.txt b/src/test/java/com/attacktimer/testdata/eatingFoodTest.txt index 2a633f4..482fff8 100644 --- a/src/test/java/com/attacktimer/testdata/eatingFoodTest.txt +++ b/src/test/java/com/attacktimer/testdata/eatingFoodTest.txt @@ -1,21 +1,21 @@ -tickPeriod: 0, uiUnshowDebounceTickCount: 0, attackDelayHoldoffTicks: 0, attackState: NOT_ATTACKING, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 +tickPeriod: 0, uiHideDebounceTickCount: 0, attackDelayHoldoffTicks: 0, attackState: NOT_ATTACKING, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 [TEST MESSAGE] 1. Start by setting up the player and plugin [TEST MESSAGE] 2. Mock an attack animation -tickPeriod: 4, uiUnshowDebounceTickCount: 1, attackDelayHoldoffTicks: 3, attackState: DELAYED_FIRST_TICK, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 +tickPeriod: 4, uiHideDebounceTickCount: 1, attackDelayHoldoffTicks: 3, attackState: DELAYED_FIRST_TICK, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 [TEST MESSAGE] 3. Check that the plugin has registered the attack -tickPeriod: 4, uiUnshowDebounceTickCount: 1, attackDelayHoldoffTicks: 3, attackState: DELAYED_FIRST_TICK, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 +tickPeriod: 4, uiHideDebounceTickCount: 1, attackDelayHoldoffTicks: 3, attackState: DELAYED_FIRST_TICK, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 [TEST MESSAGE] Perform an eat -tickPeriod: 4, uiUnshowDebounceTickCount: 1, attackDelayHoldoffTicks: 3, attackState: DELAYED_FIRST_TICK, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 3, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 +tickPeriod: 4, uiHideDebounceTickCount: 1, attackDelayHoldoffTicks: 3, attackState: DELAYED_FIRST_TICK, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 3, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 [TEST MESSAGE] Next game tick -tickPeriod: 4, uiUnshowDebounceTickCount: 1, attackDelayHoldoffTicks: 5, attackState: DELAYED, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 +tickPeriod: 4, uiHideDebounceTickCount: 1, attackDelayHoldoffTicks: 5, attackState: DELAYED, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 [TEST MESSAGE] Perform a fast eat -tickPeriod: 4, uiUnshowDebounceTickCount: 1, attackDelayHoldoffTicks: 5, attackState: DELAYED, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 2, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 +tickPeriod: 4, uiHideDebounceTickCount: 1, attackDelayHoldoffTicks: 5, attackState: DELAYED, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 2, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 [TEST MESSAGE] Next game tick -tickPeriod: 4, uiUnshowDebounceTickCount: 1, attackDelayHoldoffTicks: 6, attackState: DELAYED, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 +tickPeriod: 4, uiHideDebounceTickCount: 1, attackDelayHoldoffTicks: 6, attackState: DELAYED, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 [TEST MESSAGE] 4. Check that the plugin counts down correctly -tickPeriod: 4, uiUnshowDebounceTickCount: 1, attackDelayHoldoffTicks: 5, attackState: DELAYED, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 -tickPeriod: 4, uiUnshowDebounceTickCount: 1, attackDelayHoldoffTicks: 4, attackState: DELAYED, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 -tickPeriod: 4, uiUnshowDebounceTickCount: 1, attackDelayHoldoffTicks: 3, attackState: DELAYED, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 -tickPeriod: 4, uiUnshowDebounceTickCount: 1, attackDelayHoldoffTicks: 2, attackState: DELAYED, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 -tickPeriod: 4, uiUnshowDebounceTickCount: 1, attackDelayHoldoffTicks: 1, attackState: DELAYED, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 -tickPeriod: 4, uiUnshowDebounceTickCount: 1, attackDelayHoldoffTicks: 0, attackState: DELAYED, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 +tickPeriod: 4, uiHideDebounceTickCount: 1, attackDelayHoldoffTicks: 5, attackState: DELAYED, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 +tickPeriod: 4, uiHideDebounceTickCount: 1, attackDelayHoldoffTicks: 4, attackState: DELAYED, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 +tickPeriod: 4, uiHideDebounceTickCount: 1, attackDelayHoldoffTicks: 3, attackState: DELAYED, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 +tickPeriod: 4, uiHideDebounceTickCount: 1, attackDelayHoldoffTicks: 2, attackState: DELAYED, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 +tickPeriod: 4, uiHideDebounceTickCount: 1, attackDelayHoldoffTicks: 1, attackState: DELAYED, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1 +tickPeriod: 4, uiHideDebounceTickCount: 1, attackDelayHoldoffTicks: 0, attackState: DELAYED, renderedState: NOT_ATTACKING, pendingEatDelayTicks: 0, currentSpellBook: STANDARD, lastEquippingMonotonicValue: -1, soundEffectTick: -1, soundEffectId: -1