From 39e56151b7a1a1a97d17e20e9efd2875063e27fc Mon Sep 17 00:00:00 2001 From: Jordan Atwood Date: Tue, 17 Jul 2018 10:19:07 -0700 Subject: [PATCH] timers plugin: Use constants for checked strings --- .../client/plugins/timers/TimersPlugin.java | 73 +++++++++++++------ 1 file changed, 49 insertions(+), 24 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/timers/TimersPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/timers/TimersPlugin.java index 6f46c0baef..fa16b99793 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/timers/TimersPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/timers/TimersPlugin.java @@ -99,6 +99,31 @@ import net.runelite.client.ui.overlay.infobox.InfoBoxManager; ) public class TimersPlugin extends Plugin { + private static final String ANTIFIRE_DRINK_MESSAGE = "You drink some of your antifire potion."; + private static final String ANTIFIRE_EXPIRED_MESSAGE = "Your antifire potion has expired."; + private static final String ANTIVENOM_DRINK_MESSAGE = "You drink some of your antivenom potion"; + private static final String CANNON_FURNACE_MESSAGE = "You add the furnace."; + private static final String CANNON_PICKUP_MESSAGE = "You pick up the cannon. It's really heavy."; + private static final String CANNON_REPAIR_MESSAGE = "You repair your cannon, restoring it to working order."; + private static final String CHARGE_EXPIRED_MESSAGE = "Your magical charge fades away."; + private static final String CHARGE_MESSAGE = "You feel charged with magic power."; + private static final String EXTENDED_ANTIFIRE_DRINK_MESSAGE = "You drink some of your extended antifire potion."; + private static final String EXTENDED_SUPER_ANTIFIRE_DRINK_MESSAGE = "You drink some of your extended super antifire potion."; + private static final String FULL_TELEBLOCK_MESSAGE = "A teleblock spell has been cast on you. It will expire in 5 minutes, 0 seconds."; + private static final String GOD_WARS_ALTAR_MESSAGE = "you recharge your prayer."; + private static final String HALF_TELEBLOCK_MESSAGE = "A teleblock spell has been cast on you. It will expire in 2 minutes, 30 seconds."; + private static final String IMBUED_HEART_READY_MESSAGE = "Your imbued heart has regained its magical power."; + private static final String MAGIC_IMBUE_EXPIRED_MESSAGE = "Your Magic Imbue charge has ended."; + private static final String MAGIC_IMBUE_MESSAGE = "You are charged to combine runes!"; + private static final String SANFEW_SERUM_DRINK_MESSAGE = "You drink some of your Sanfew Serum."; + private static final String STAFF_OF_THE_DEAD_SPEC_EXPIRED_MESSAGE = "Your protection fades away"; + private static final String STAFF_OF_THE_DEAD_SPEC_MESSAGE = "Spirits of deceased evildoers offer you their protection"; + private static final String STAMINA_DRINK_MESSAGE = "You drink some of your stamina potion."; + private static final String STAMINA_EXPIRED_MESSAGE = "Your stamina potion has expired."; + private static final String SUPER_ANTIFIRE_DRINK_MESSAGE = "You drink some of your super antifire potion"; + private static final String SUPER_ANTIFIRE_EXPIRED_MESSAGE = "Your super antifire potion has expired."; + private static final String SUPER_ANTIVENOM_DRINK_MESSAGE = "You drink some of your super antivenom potion"; + private int lastRaidVarb; @Inject @@ -324,37 +349,37 @@ public class TimersPlugin extends Plugin return; } - if (config.showStamina() && event.getMessage().equals("You drink some of your stamina potion.")) + if (config.showStamina() && event.getMessage().equals(STAMINA_DRINK_MESSAGE)) { createGameTimer(STAMINA); } - if (event.getMessage().equals("Your stamina potion has expired.")) + if (event.getMessage().equals(STAMINA_EXPIRED_MESSAGE)) { removeGameTimer(STAMINA); } - if (config.showAntiFire() && event.getMessage().equals("You drink some of your antifire potion.")) + if (config.showAntiFire() && event.getMessage().equals(ANTIFIRE_DRINK_MESSAGE)) { createGameTimer(ANTIFIRE); } - if (config.showExAntiFire() && event.getMessage().equals("You drink some of your extended antifire potion.")) + if (config.showExAntiFire() && event.getMessage().equals(EXTENDED_ANTIFIRE_DRINK_MESSAGE)) { createGameTimer(EXANTIFIRE); } - if (config.showGodWarsAltar() && event.getMessage().equalsIgnoreCase("you recharge your prayer."))//Normal altars are "You recharge your Prayer points." while gwd is "You recharge your Prayer." + if (config.showGodWarsAltar() && event.getMessage().equalsIgnoreCase(GOD_WARS_ALTAR_MESSAGE))//Normal altars are "You recharge your Prayer points." while gwd is "You recharge your Prayer." { createGameTimer(GOD_WARS_ALTAR); } - if (config.showExSuperAntifire() && event.getMessage().equals("You drink some of your extended super antifire potion.")) + if (config.showExSuperAntifire() && event.getMessage().equals(EXTENDED_SUPER_ANTIFIRE_DRINK_MESSAGE)) { createGameTimer(EXSUPERANTIFIRE); } - if (event.getMessage().equals("Your antifire potion has expired.")) + if (event.getMessage().equals(ANTIFIRE_EXPIRED_MESSAGE)) { //they have the same expired message removeGameTimer(ANTIFIRE); @@ -374,62 +399,62 @@ public class TimersPlugin extends Plugin } - if (config.showCannon() && (event.getMessage().equals("You add the furnace.") || event.getMessage().contains("You repair your cannon, restoring it to working order."))) + if (config.showCannon() && (event.getMessage().equals(CANNON_FURNACE_MESSAGE) || event.getMessage().contains(CANNON_REPAIR_MESSAGE))) { createGameTimer(CANNON); } - if (event.getMessage().equals("You pick up the cannon. It's really heavy.")) + if (event.getMessage().equals(CANNON_PICKUP_MESSAGE)) { removeGameTimer(CANNON); } - if (config.showAntiVenomPlus() && event.getMessage().contains("You drink some of your super antivenom potion")) + if (config.showAntiVenomPlus() && event.getMessage().contains(SUPER_ANTIVENOM_DRINK_MESSAGE)) { createGameTimer(ANTIVENOMPLUS); } - if (config.showMagicImbue() && event.getMessage().equals("You are charged to combine runes!")) + if (config.showMagicImbue() && event.getMessage().equals(MAGIC_IMBUE_MESSAGE)) { createGameTimer(MAGICIMBUE); } - if (event.getMessage().equals("Your Magic Imbue charge has ended.")) + if (event.getMessage().equals(MAGIC_IMBUE_EXPIRED_MESSAGE)) { removeGameTimer(MAGICIMBUE); } - if (config.showTeleblock() && event.getMessage().equals("A teleblock spell has been cast on you. It will expire in 5 minutes, 0 seconds.")) + if (config.showTeleblock() && event.getMessage().equals(FULL_TELEBLOCK_MESSAGE)) { createGameTimer(FULLTB); } - if (config.showTeleblock() && event.getMessage().equals("A teleblock spell has been cast on you. It will expire in 2 minutes, 30 seconds.")) + if (config.showTeleblock() && event.getMessage().equals(HALF_TELEBLOCK_MESSAGE)) { createGameTimer(HALFTB); } - if (config.showSuperAntiFire() && event.getMessage().contains("You drink some of your super antifire potion")) + if (config.showSuperAntiFire() && event.getMessage().contains(SUPER_ANTIFIRE_DRINK_MESSAGE)) { createGameTimer(SUPERANTIFIRE); } - if (event.getMessage().equals("Your super antifire potion has expired.")) + if (event.getMessage().equals(SUPER_ANTIFIRE_EXPIRED_MESSAGE)) { removeGameTimer(SUPERANTIFIRE); } - if (event.getMessage().equals("Your imbued heart has regained its magical power.")) + if (event.getMessage().equals(IMBUED_HEART_READY_MESSAGE)) { removeGameTimer(IMBUEDHEART); } - if (config.showAntiVenom() && event.getMessage().contains("You drink some of your antivenom potion")) + if (config.showAntiVenom() && event.getMessage().contains(ANTIVENOM_DRINK_MESSAGE)) { createGameTimer(ANTIVENOM); } - if (config.showSanfew() && event.getMessage().contains("You drink some of your Sanfew Serum.")) + if (config.showSanfew() && event.getMessage().contains(SANFEW_SERUM_DRINK_MESSAGE)) { createGameTimer(SANFEW); } @@ -439,22 +464,22 @@ public class TimersPlugin extends Plugin createGameTimer(PRAYER_ENHANCE); } - if (config.showCharge() && event.getMessage().equals("You feel charged with magic power.")) + if (config.showCharge() && event.getMessage().equals(CHARGE_MESSAGE)) { createGameTimer(CHARGE); } - if (config.showCharge() && event.getMessage().equals("Your magical charge fades away.")) + if (config.showCharge() && event.getMessage().equals(CHARGE_EXPIRED_MESSAGE)) { removeGameTimer(CHARGE); } - if (config.showStaffOfTheDead() && event.getMessage().contains("Spirits of deceased evildoers offer you their protection")) + if (config.showStaffOfTheDead() && event.getMessage().contains(STAFF_OF_THE_DEAD_SPEC_MESSAGE)) { createGameTimer(STAFF_OF_THE_DEAD); } - if (config.showStaffOfTheDead() && event.getMessage().contains("Your protection fades away")) + if (config.showStaffOfTheDead() && event.getMessage().contains(STAFF_OF_THE_DEAD_SPEC_EXPIRED_MESSAGE)) { removeGameTimer(STAFF_OF_THE_DEAD); } @@ -618,7 +643,7 @@ public class TimersPlugin extends Plugin case ItemID.TOXIC_STAFF_OF_THE_DEAD: case ItemID.STAFF_OF_LIGHT: case ItemID.TOXIC_STAFF_UNCHARGED: - // don't reset timer if still weilding staff + // don't reset timer if still wielding staff return; default: removeGameTimer(STAFF_OF_THE_DEAD);