From d6bb219c790b0f23b5ae54a3ab30967e67a8edc2 Mon Sep 17 00:00:00 2001 From: Max Weber Date: Tue, 28 Apr 2020 23:14:09 -0600 Subject: [PATCH 01/12] rl-api, rl-client: rename getHealth to getHealthScale --- .../src/main/java/net/runelite/api/Actor.java | 17 +++++++++-------- .../opponentinfo/OpponentInfoOverlay.java | 4 ++-- .../client/plugins/prayer/PrayerBarOverlay.java | 2 +- .../plugins/slayer/TargetWeaknessOverlay.java | 2 +- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/runelite-api/src/main/java/net/runelite/api/Actor.java b/runelite-api/src/main/java/net/runelite/api/Actor.java index a523555648..c469343004 100644 --- a/runelite-api/src/main/java/net/runelite/api/Actor.java +++ b/runelite-api/src/main/java/net/runelite/api/Actor.java @@ -69,21 +69,22 @@ public interface Actor extends Renderable Actor getInteracting(); /** - * Gets the health ratio of the actor. - *

- * The ratio is the number of green bars in the overhead - * HP display. + * Gets the health of the actor in {@link #getHealthScale()} units. * - * @return the health ratio + * The server does not transmit actors' real health, only this value + * between zero and {@link #getHealthScale()}. Some actors may be + * missing this info, in which case -1 is returned. */ int getHealthRatio(); /** - * Gets the health of the actor. + * Gets the maximum value {@link #getHealthRatio()} can return * - * @return the health + * For actors with the default size health bar this is 30, but + * for bosses with a larger health bar this can be a larger number. + * Some actors may be missing this info, in which case -1 is returned. */ - int getHealth(); + int getHealthScale(); /** * Gets the server-side location of the actor. diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/opponentinfo/OpponentInfoOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/opponentinfo/OpponentInfoOverlay.java index 2ec7b192ab..5dc68a3bf1 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/opponentinfo/OpponentInfoOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/opponentinfo/OpponentInfoOverlay.java @@ -100,10 +100,10 @@ class OpponentInfoOverlay extends OverlayPanel return null; } - if (opponent.getName() != null && opponent.getHealth() > 0) + if (opponent.getName() != null && opponent.getHealthScale() > 0) { lastRatio = opponent.getHealthRatio(); - lastHealthScale = opponent.getHealth(); + lastHealthScale = opponent.getHealthScale(); opponentName = Text.removeTags(opponent.getName()); lastMaxHealth = null; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/prayer/PrayerBarOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/prayer/PrayerBarOverlay.java index df4da38850..522c1aa754 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/prayer/PrayerBarOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/prayer/PrayerBarOverlay.java @@ -165,7 +165,7 @@ class PrayerBarOverlay extends Overlay return; } - if (config.hideIfOutOfCombat() && localPlayer.getHealth() == -1) + if (config.hideIfOutOfCombat() && localPlayer.getHealthScale() == -1) { showingPrayerBar = false; } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/slayer/TargetWeaknessOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/slayer/TargetWeaknessOverlay.java index 8a036eff83..91f331d06b 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/slayer/TargetWeaknessOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/slayer/TargetWeaknessOverlay.java @@ -106,7 +106,7 @@ class TargetWeaknessOverlay extends Overlay return -1; } - final int healthScale = target.getHealth(); + final int healthScale = target.getHealthScale(); final int healthRatio = target.getHealthRatio(); final Integer maxHealth = npcManager.getHealth(target.getId()); From 27286ea1d7465b99f3a27ff78d922c5888383b58 Mon Sep 17 00:00:00 2001 From: RuneLite Cache-Code Autoupdater Date: Thu, 30 Apr 2020 10:32:17 +0000 Subject: [PATCH 02/12] Update Item IDs to 2020-04-30-rev182 --- .../src/main/java/net/runelite/api/ItemID.java | 11 ++++++++++- .../main/java/net/runelite/api/NullItemID.java | 17 +++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/runelite-api/src/main/java/net/runelite/api/ItemID.java b/runelite-api/src/main/java/net/runelite/api/ItemID.java index 003ee5ed8f..2d24ccac23 100644 --- a/runelite-api/src/main/java/net/runelite/api/ItemID.java +++ b/runelite-api/src/main/java/net/runelite/api/ItemID.java @@ -11451,12 +11451,21 @@ public final class ItemID public static final int BLIGHTED_SUPER_RESTORE3 = 24601; public static final int BLIGHTED_SUPER_RESTORE2 = 24603; public static final int BLIGHTED_SUPER_RESTORE1 = 24605; - public static final int BLIGHTED_ICE_BARRAGE_SACK = 24607; + public static final int BLIGHTED_ANCIENT_ICE_SACK = 24607; public static final int BLIGHTED_BIND_SACK = 24609; public static final int BLIGHTED_SNARE_SACK = 24611; public static final int BLIGHTED_ENTANGLE_SACK = 24613; public static final int BLIGHTED_TELEBLOCK_SACK = 24615; public static final int VESTAS_BLIGHTED_LONGSWORD = 24617; public static final int VESTAS_LONGSWORD_INACTIVE = 24619; + public static final int BLIGHTED_VENGEANCE_SACK = 24621; + public static final int DIVINE_BATTLEMAGE_POTION4 = 24623; + public static final int DIVINE_BATTLEMAGE_POTION3 = 24626; + public static final int DIVINE_BATTLEMAGE_POTION2 = 24629; + public static final int DIVINE_BATTLEMAGE_POTION1 = 24632; + public static final int DIVINE_BASTION_POTION4 = 24635; + public static final int DIVINE_BASTION_POTION3 = 24638; + public static final int DIVINE_BASTION_POTION2 = 24641; + public static final int DIVINE_BASTION_POTION1 = 24644; /* This file is automatically generated. Do not edit. */ } diff --git a/runelite-api/src/main/java/net/runelite/api/NullItemID.java b/runelite-api/src/main/java/net/runelite/api/NullItemID.java index f72aec5012..da17d51fb3 100644 --- a/runelite-api/src/main/java/net/runelite/api/NullItemID.java +++ b/runelite-api/src/main/java/net/runelite/api/NullItemID.java @@ -12952,5 +12952,22 @@ public final class NullItemID public static final int NULL_24616 = 24616; public static final int NULL_24618 = 24618; public static final int NULL_24620 = 24620; + public static final int NULL_24622 = 24622; + public static final int NULL_24624 = 24624; + public static final int NULL_24625 = 24625; + public static final int NULL_24627 = 24627; + public static final int NULL_24628 = 24628; + public static final int NULL_24630 = 24630; + public static final int NULL_24631 = 24631; + public static final int NULL_24633 = 24633; + public static final int NULL_24634 = 24634; + public static final int NULL_24636 = 24636; + public static final int NULL_24637 = 24637; + public static final int NULL_24639 = 24639; + public static final int NULL_24640 = 24640; + public static final int NULL_24642 = 24642; + public static final int NULL_24643 = 24643; + public static final int NULL_24645 = 24645; + public static final int NULL_24646 = 24646; /* This file is automatically generated. Do not edit. */ } From bcfe840019704653cf29a618e9cfdefc17861ea6 Mon Sep 17 00:00:00 2001 From: RuneLite Cache-Code Autoupdater Date: Thu, 30 Apr 2020 10:32:17 +0000 Subject: [PATCH 03/12] Update Item variations to 2020-04-30-rev182 --- .../src/main/resources/item_variations.json | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/runelite-client/src/main/resources/item_variations.json b/runelite-client/src/main/resources/item_variations.json index a520c584e7..d347c95b77 100644 --- a/runelite-client/src/main/resources/item_variations.json +++ b/runelite-client/src/main/resources/item_variations.json @@ -9749,5 +9749,17 @@ 24601, 24603, 24605 + ], + "divine battlemage potion": [ + 24623, + 24626, + 24629, + 24632 + ], + "divine bastion potion": [ + 24635, + 24638, + 24641, + 24644 ] } \ No newline at end of file From 79da7996f17dad293428d2d0e704101dcc15a4ac Mon Sep 17 00:00:00 2001 From: RuneLite Cache-Code Autoupdater Date: Thu, 30 Apr 2020 10:32:18 +0000 Subject: [PATCH 04/12] Update Object IDs to 2020-04-30-rev182 --- runelite-api/src/main/java/net/runelite/api/NullObjectID.java | 2 ++ runelite-api/src/main/java/net/runelite/api/ObjectID.java | 2 ++ 2 files changed, 4 insertions(+) diff --git a/runelite-api/src/main/java/net/runelite/api/NullObjectID.java b/runelite-api/src/main/java/net/runelite/api/NullObjectID.java index 83135cc4af..54d95aa6c2 100644 --- a/runelite-api/src/main/java/net/runelite/api/NullObjectID.java +++ b/runelite-api/src/main/java/net/runelite/api/NullObjectID.java @@ -13896,6 +13896,7 @@ public final class NullObjectID public static final int NULL_29704 = 29704; public static final int NULL_29709 = 29709; public static final int NULL_29710 = 29710; + public static final int NULL_29712 = 29712; public static final int NULL_29713 = 29713; public static final int NULL_29714 = 29714; public static final int NULL_29715 = 29715; @@ -14123,6 +14124,7 @@ public final class NullObjectID public static final int NULL_30144 = 30144; public static final int NULL_30156 = 30156; public static final int NULL_30159 = 30159; + public static final int NULL_30161 = 30161; public static final int NULL_30171 = 30171; public static final int NULL_30181 = 30181; public static final int NULL_30182 = 30182; diff --git a/runelite-api/src/main/java/net/runelite/api/ObjectID.java b/runelite-api/src/main/java/net/runelite/api/ObjectID.java index d6b44f591e..1f4d0d3aec 100644 --- a/runelite-api/src/main/java/net/runelite/api/ObjectID.java +++ b/runelite-api/src/main/java/net/runelite/api/ObjectID.java @@ -15803,6 +15803,7 @@ public final class ObjectID public static final int POOL_OF_NIGHTMARES = 29706; public static final int POOL_OF_NIGHTMARES_29707 = 29707; public static final int SCOREBOARD_29708 = 29708; + public static final int HAMMER_29711 = 29711; public static final int NOTICEBOARD_29718 = 29718; public static final int BALLISTA_29719 = 29719; public static final int STAIRCASE_29720 = 29720; @@ -16023,6 +16024,7 @@ public final class ObjectID public static final int PAINTING_30155 = 30155; public static final int FURNACE_30157 = 30157; public static final int FURNACE_30158 = 30158; + public static final int RETURN_ORB = 30160; public static final int CRACK_30169 = 30169; public static final int ROOT_30170 = 30170; public static final int PORTAL_30172 = 30172; From 5bf3d953e36e4f86c3f408da652c7d74fc6ea8ac Mon Sep 17 00:00:00 2001 From: RuneLite Cache-Code Autoupdater Date: Thu, 30 Apr 2020 10:32:18 +0000 Subject: [PATCH 05/12] Update Script arguments to 2020-04-30-rev182 --- runelite-api/src/main/java/net/runelite/api/ScriptID.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runelite-api/src/main/java/net/runelite/api/ScriptID.java b/runelite-api/src/main/java/net/runelite/api/ScriptID.java index 9e8468687b..c5f167343d 100644 --- a/runelite-api/src/main/java/net/runelite/api/ScriptID.java +++ b/runelite-api/src/main/java/net/runelite/api/ScriptID.java @@ -278,6 +278,6 @@ public final class ScriptID /** * Called to update the PVP widget (wilderness level/protection) */ - @ScriptArguments(integer = 3) + @ScriptArguments(integer = 1) public static final int PVP_WIDGET_BUILDER = 388; } From e930283176e9f433ab55a56c231375fb0760d820 Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 30 Apr 2020 11:23:29 -0400 Subject: [PATCH 06/12] timers: add divine bastion and battlemage potions --- .../client/plugins/timers/GameTimer.java | 2 ++ .../client/plugins/timers/TimersPlugin.java | 8 ++++++ .../plugins/timers/TimersPluginTest.java | 26 +++++++++++++++++++ 3 files changed, 36 insertions(+) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/timers/GameTimer.java b/runelite-client/src/main/java/net/runelite/client/plugins/timers/GameTimer.java index a1aa1f5f21..98701e880c 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/timers/GameTimer.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/timers/GameTimer.java @@ -76,6 +76,8 @@ enum GameTimer DIVINE_SUPER_COMBAT(ItemID.DIVINE_SUPER_COMBAT_POTION4, GameTimerImageType.ITEM, "Divine Super Combat", 5, ChronoUnit.MINUTES), DIVINE_RANGING(ItemID.DIVINE_RANGING_POTION4, GameTimerImageType.ITEM, "Divine Ranging", 5, ChronoUnit.MINUTES), DIVINE_MAGIC(ItemID.DIVINE_MAGIC_POTION4, GameTimerImageType.ITEM, "Divine Magic", 5, ChronoUnit.MINUTES), + DIVINE_BASTION(ItemID.DIVINE_BASTION_POTION4, GameTimerImageType.ITEM, "Divine Bastion", 5, ChronoUnit.MINUTES), + DIVINE_BATTLEMAGE(ItemID.DIVINE_BATTLEMAGE_POTION4, GameTimerImageType.ITEM, "Divine Battlemage", 5, ChronoUnit.MINUTES), ANTIPOISON(ItemID.ANTIPOISON4, GameTimerImageType.ITEM, "Antipoison"), ANTIVENOM(ItemID.ANTIVENOM4, GameTimerImageType.ITEM, "Anti-venom"); 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 a28a3fac5f..34fd1de61a 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 @@ -615,6 +615,14 @@ public class TimersPlugin extends Plugin case "magic": createGameTimer(DIVINE_MAGIC); break; + + case "bastion": + createGameTimer(DIVINE_BASTION); + break; + + case "battlemage": + createGameTimer(DIVINE_BATTLEMAGE); + break; } } } diff --git a/runelite-client/src/test/java/net/runelite/client/plugins/timers/TimersPluginTest.java b/runelite-client/src/test/java/net/runelite/client/plugins/timers/TimersPluginTest.java index 976b0e2970..3531a82c29 100644 --- a/runelite-client/src/test/java/net/runelite/client/plugins/timers/TimersPluginTest.java +++ b/runelite-client/src/test/java/net/runelite/client/plugins/timers/TimersPluginTest.java @@ -136,4 +136,30 @@ public class TimersPluginTest TimerTimer infoBox = (TimerTimer) captor.getValue(); assertEquals(GameTimer.DMM_FULLTB, infoBox.getTimer()); } + + @Test + public void testDivineBastion() + { + when(timersConfig.showDivine()).thenReturn(true); + ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.SPAM, "", "You drink some of your divine bastion potion.", "", 0); + timersPlugin.onChatMessage(chatMessage); + + ArgumentCaptor captor = ArgumentCaptor.forClass(InfoBox.class); + verify(infoBoxManager).addInfoBox(captor.capture()); + TimerTimer infoBox = (TimerTimer) captor.getValue(); + assertEquals(GameTimer.DIVINE_BASTION, infoBox.getTimer()); + } + + @Test + public void testDivineBattlemage() + { + when(timersConfig.showDivine()).thenReturn(true); + ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.SPAM, "", "You drink some of your divine battlemage potion.", "", 0); + timersPlugin.onChatMessage(chatMessage); + + ArgumentCaptor captor = ArgumentCaptor.forClass(InfoBox.class); + verify(infoBoxManager).addInfoBox(captor.capture()); + TimerTimer infoBox = (TimerTimer) captor.getValue(); + assertEquals(GameTimer.DIVINE_BATTLEMAGE, infoBox.getTimer()); + } } \ No newline at end of file From b48936eec1b2a20e1fc88b97a54603f353b3101a Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 30 Apr 2020 12:00:11 -0400 Subject: [PATCH 07/12] itemstats: add divine bastion and battlemage potions --- .../net/runelite/client/plugins/itemstats/ItemStatChanges.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/ItemStatChanges.java b/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/ItemStatChanges.java index bfafe09c25..1f8a2557dc 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/ItemStatChanges.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/ItemStatChanges.java @@ -142,6 +142,8 @@ public class ItemStatChanges add(combo(boost(STRENGTH, perc(.15, 5)), heal(HITPOINTS, -10)), DIVINE_SUPER_STRENGTH_POTION1, DIVINE_SUPER_STRENGTH_POTION2, DIVINE_SUPER_STRENGTH_POTION3, DIVINE_SUPER_STRENGTH_POTION4); add(combo(boost(DEFENCE, perc(.15, 5)), heal(HITPOINTS, -10)), DIVINE_SUPER_DEFENCE_POTION1, DIVINE_SUPER_DEFENCE_POTION2, DIVINE_SUPER_DEFENCE_POTION3, DIVINE_SUPER_DEFENCE_POTION4); add(combo(3, boost(ATTACK, perc(.15, 5)), boost(STRENGTH, perc(.15, 5)), boost(DEFENCE, perc(.15, 5)), heal(HITPOINTS, -10)), DIVINE_SUPER_COMBAT_POTION1, DIVINE_SUPER_COMBAT_POTION2, DIVINE_SUPER_COMBAT_POTION3, DIVINE_SUPER_COMBAT_POTION4); + add(combo(2, boost(RANGED, perc(0.1, 4)), boost(DEFENCE, perc(0.15, 5)), heal(HITPOINTS, -10)), DIVINE_BASTION_POTION1, DIVINE_BASTION_POTION2, DIVINE_BASTION_POTION3, DIVINE_BASTION_POTION4); + add(combo(2, boost(MAGIC, 4), boost(DEFENCE, perc(0.15, 5)), heal(HITPOINTS, -10)), DIVINE_BATTLEMAGE_POTION1, DIVINE_BATTLEMAGE_POTION2, DIVINE_BATTLEMAGE_POTION3, DIVINE_BATTLEMAGE_POTION4); // Regular overload (NMZ) add(combo(5, boost(ATTACK, perc(.15, 5)), boost(STRENGTH, perc(.15, 5)), boost(DEFENCE, perc(.15, 5)), boost(RANGED, perc(.15, 5)), boost(MAGIC, perc(.15, 5)), heal(HITPOINTS, -50)), OVERLOAD_1, OVERLOAD_2, OVERLOAD_3, OVERLOAD_4); From f9ad57625c52297f7e6292839b18acf86789f5c6 Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 30 Apr 2020 12:01:54 -0400 Subject: [PATCH 08/12] item identification: add divine bastion and battlemage potions --- .../client/plugins/itemidentification/ItemIdentification.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/itemidentification/ItemIdentification.java b/runelite-client/src/main/java/net/runelite/client/plugins/itemidentification/ItemIdentification.java index 01b7a48583..98f38605eb 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/itemidentification/ItemIdentification.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/itemidentification/ItemIdentification.java @@ -145,6 +145,8 @@ enum ItemIdentification DIVINE_SUPER_COMBAT(Type.POTION, "S.Com", "S.C", ItemID.DIVINE_SUPER_COMBAT_POTION4, ItemID.DIVINE_SUPER_COMBAT_POTION3, ItemID.DIVINE_SUPER_COMBAT_POTION2, ItemID.DIVINE_SUPER_COMBAT_POTION1), DIVINE_RANGING(Type.POTION, "Range", "R", ItemID.DIVINE_RANGING_POTION4, ItemID.DIVINE_RANGING_POTION3, ItemID.DIVINE_RANGING_POTION2, ItemID.DIVINE_RANGING_POTION1), DIVINE_MAGIC(Type.POTION, "Magic", "M", ItemID.DIVINE_MAGIC_POTION4, ItemID.DIVINE_MAGIC_POTION3, ItemID.DIVINE_MAGIC_POTION2, ItemID.DIVINE_MAGIC_POTION1), + DIVINE_BASTION(Type.POTION, "Bastion", "B", ItemID.DIVINE_BASTION_POTION4, ItemID.DIVINE_BASTION_POTION3, ItemID.DIVINE_BASTION_POTION2, ItemID.DIVINE_BASTION_POTION1), + DIVINE_BATTLEMAGE(Type.POTION, "BatMage", "B.M", ItemID.DIVINE_BATTLEMAGE_POTION4, ItemID.DIVINE_BATTLEMAGE_POTION3, ItemID.DIVINE_BATTLEMAGE_POTION2, ItemID.DIVINE_BATTLEMAGE_POTION1), RESTORE(Type.POTION, "Restore", "Re", ItemID.RESTORE_POTION4, ItemID.RESTORE_POTION3, ItemID.RESTORE_POTION2, ItemID.RESTORE_POTION1), GUTHIX_BALANCE(Type.POTION, "GuthBal", "G.B.", ItemID.GUTHIX_BALANCE4, ItemID.GUTHIX_BALANCE3, ItemID.GUTHIX_BALANCE2, ItemID.GUTHIX_BALANCE1), From f60d818558bbc319a58ef9a985328bc83c8605fa Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 30 Apr 2020 14:57:53 -0400 Subject: [PATCH 09/12] chat notifier: fix highlight own name matching player names with spaces We internally rewrite nbsp to space in Player.getName(), but the in-game drop messages which include players names still have nbsp. Modify the generated username matcher pattern to match either nbsp or space. --- .../ChatNotificationsPlugin.java | 9 +++-- .../ChatNotificationsPluginTest.java | 36 +++++++++++++++++++ 2 files changed, 42 insertions(+), 3 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/chatnotifications/ChatNotificationsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/chatnotifications/ChatNotificationsPlugin.java index f6305427ae..f4dcab1ea5 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/chatnotifications/ChatNotificationsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/chatnotifications/ChatNotificationsPlugin.java @@ -28,16 +28,15 @@ package net.runelite.client.plugins.chatnotifications; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Strings; import com.google.inject.Provides; +import java.util.Arrays; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; -import static java.util.regex.Pattern.quote; import java.util.stream.Collectors; import javax.inject.Inject; import net.runelite.api.Client; import net.runelite.api.MessageNode; import net.runelite.api.events.ChatMessage; -import net.runelite.client.events.ConfigChanged; import net.runelite.api.events.GameStateChanged; import net.runelite.client.Notifier; import net.runelite.client.RuneLiteProperties; @@ -45,6 +44,7 @@ import net.runelite.client.chat.ChatColorType; import net.runelite.client.chat.ChatMessageManager; import net.runelite.client.config.ConfigManager; import net.runelite.client.eventbus.Subscribe; +import net.runelite.client.events.ConfigChanged; import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.util.Text; @@ -156,7 +156,10 @@ public class ChatNotificationsPlugin extends Plugin if (usernameMatcher == null && client.getLocalPlayer() != null && client.getLocalPlayer().getName() != null) { String username = client.getLocalPlayer().getName(); - usernameMatcher = Pattern.compile("\\b(" + quote(username) + ")\\b", Pattern.CASE_INSENSITIVE); + String pattern = Arrays.stream(username.split(" ")) + .map(s -> s.isEmpty() ? "" : Pattern.quote(s)) + .collect(Collectors.joining("[\u00a0\u0020]")); // space or nbsp + usernameMatcher = Pattern.compile("\\b" + pattern + "\\b", Pattern.CASE_INSENSITIVE); usernameReplacer = "" + username + ""; } diff --git a/runelite-client/src/test/java/net/runelite/client/plugins/chatnotifications/ChatNotificationsPluginTest.java b/runelite-client/src/test/java/net/runelite/client/plugins/chatnotifications/ChatNotificationsPluginTest.java index de7bbc6e26..7fc7f2aad6 100644 --- a/runelite-client/src/test/java/net/runelite/client/plugins/chatnotifications/ChatNotificationsPluginTest.java +++ b/runelite-client/src/test/java/net/runelite/client/plugins/chatnotifications/ChatNotificationsPluginTest.java @@ -33,6 +33,7 @@ import javax.inject.Inject; import net.runelite.api.ChatMessageType; import net.runelite.api.Client; import net.runelite.api.MessageNode; +import net.runelite.api.Player; import net.runelite.api.events.ChatMessage; import net.runelite.client.Notifier; import net.runelite.client.chat.ChatMessageManager; @@ -226,4 +227,39 @@ public class ChatNotificationsPluginTest { assertEquals("you. It", ChatNotificationsPlugin.stripColor("you. It")); } + + @Test + public void testHighlightOwnName() + { + Player player = mock(Player.class); + when(player.getName()).thenReturn("Logic Knot"); + when(client.getLocalPlayer()).thenReturn(player); + + when(config.highlightOwnName()).thenReturn(true); + + MessageNode messageNode = mock(MessageNode.class); + when(messageNode.getValue()).thenReturn("Logic Knot received a drop: Adamant longsword"); + ChatMessage chatMessage = new ChatMessage(messageNode, ChatMessageType.GAMEMESSAGE, "", "", "", 0); + chatNotificationsPlugin.onChatMessage(chatMessage); + + verify(messageNode).setValue("Logic Knot received a drop: Adamant longsword"); + } + + @Test + public void testHighlightOwnNameNbsp() + { + Player player = mock(Player.class); + when(player.getName()).thenReturn("Logic Knot"); + when(client.getLocalPlayer()).thenReturn(player); + + when(config.highlightOwnName()).thenReturn(true); + + MessageNode messageNode = mock(MessageNode.class); + when(messageNode.getValue()).thenReturn("Logic\u00a0Knot received a drop: Adamant longsword"); + ChatMessage chatMessage = new ChatMessage(messageNode, ChatMessageType.GAMEMESSAGE, "", "", "", 0); + chatNotificationsPlugin.onChatMessage(chatMessage); + + // set value uses our player name, which has nbsp replaced + verify(messageNode).setValue("Logic Knot received a drop: Adamant longsword"); + } } \ No newline at end of file From 1778d5d79bd912dac55517ae65b7b71f9cb70c48 Mon Sep 17 00:00:00 2001 From: Psikoi Date: Tue, 28 Apr 2020 17:52:26 +0100 Subject: [PATCH 10/12] Refactor xp updater requests to use generic request sender method --- .../plugins/xpupdater/XpUpdaterPlugin.java | 55 ++++++++----------- 1 file changed, 23 insertions(+), 32 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/xpupdater/XpUpdaterPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/xpupdater/XpUpdaterPlugin.java index 8e45584edf..5af93e1aaa 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/xpupdater/XpUpdaterPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/xpupdater/XpUpdaterPlugin.java @@ -1,6 +1,7 @@ /* * Copyright (c) 2018, Adam * Copyright (c) 2020, Alexsuperfly + * Copyright (c) 2020, Psikoi * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -43,7 +44,6 @@ import net.runelite.http.api.RuneLiteAPI; import okhttp3.Call; import okhttp3.Callback; import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.Response; @@ -108,7 +108,7 @@ public class XpUpdaterPlugin extends Plugin if (Math.abs(totalXp - lastXp) > XP_THRESHOLD) { log.debug("Submitting update for {}", local.getName()); - sendUpdateRequest(local.getName()); + update(local.getName()); lastXp = totalXp; } } @@ -124,10 +124,9 @@ public class XpUpdaterPlugin extends Plugin } } - private void sendUpdateRequest(String username) + private void update(String username) { String reformedUsername = username.replace(" ", "_"); - OkHttpClient httpClient = RuneLiteAPI.CLIENT; if (config.cml()) { @@ -145,20 +144,7 @@ public class XpUpdaterPlugin extends Plugin .url(url) .build(); - httpClient.newCall(request).enqueue(new Callback() - { - @Override - public void onFailure(Call call, IOException e) - { - log.warn("Error submitting CML update, caused by {}.", e.getMessage()); - } - - @Override - public void onResponse(Call call, Response response) - { - response.close(); - } - }); + sendRequest("CrystalMathLabs", request); } if (config.templeosrs()) @@ -176,20 +162,25 @@ public class XpUpdaterPlugin extends Plugin .url(url) .build(); - httpClient.newCall(request).enqueue(new Callback() - { - @Override - public void onFailure(Call call, IOException e) - { - log.warn("Error submitting TempleOSRS update, caused by {}.", e.getMessage()); - } - - @Override - public void onResponse(Call call, Response response) - { - response.close(); - } - }); + sendRequest("TempleOSRS", request); } } + + private static void sendRequest(String platform, Request request) + { + RuneLiteAPI.CLIENT.newCall(request).enqueue(new Callback() + { + @Override + public void onFailure(Call call, IOException e) + { + log.warn("Error submitting {} update, caused by {}.", platform, e.getMessage()); + } + + @Override + public void onResponse(Call call, Response response) + { + response.close(); + } + }); + } } From 07b8798cac35241328d36b1de76b04cb7f6e3a3e Mon Sep 17 00:00:00 2001 From: Psikoi Date: Tue, 28 Apr 2020 17:54:38 +0100 Subject: [PATCH 11/12] Add Wise Old Man to XP Updater plugin --- .../plugins/xpupdater/XpUpdaterConfig.java | 11 ++++++++ .../plugins/xpupdater/XpUpdaterPlugin.java | 27 ++++++++++++++++++- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/xpupdater/XpUpdaterConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/xpupdater/XpUpdaterConfig.java index fa513c24ac..8b68300fec 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/xpupdater/XpUpdaterConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/xpupdater/XpUpdaterConfig.java @@ -52,4 +52,15 @@ public interface XpUpdaterConfig extends Config { return false; } + + @ConfigItem( + position = 3, + keyName = "wiseoldman", + name = "Wise Old Man", + description = "Automatically updates your stats on wiseoldman.net when you log out" + ) + default boolean wiseoldman() + { + return false; + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/xpupdater/XpUpdaterPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/xpupdater/XpUpdaterPlugin.java index 5af93e1aaa..30b2c12dc1 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/xpupdater/XpUpdaterPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/xpupdater/XpUpdaterPlugin.java @@ -43,14 +43,16 @@ import net.runelite.client.plugins.PluginDescriptor; import net.runelite.http.api.RuneLiteAPI; import okhttp3.Call; import okhttp3.Callback; +import okhttp3.FormBody; import okhttp3.HttpUrl; import okhttp3.Request; +import okhttp3.RequestBody; import okhttp3.Response; @PluginDescriptor( name = "XP Updater", description = "Automatically updates your stats on external xptrackers when you log out", - tags = {"cml", "templeosrs", "temple", "external", "integration"}, + tags = {"cml", "crystalmathlabs", "templeosrs", "temple", "wom", "wiseoldman", "wise old man", "external", "integration"}, enabledByDefault = false ) @Slf4j @@ -164,6 +166,29 @@ public class XpUpdaterPlugin extends Plugin sendRequest("TempleOSRS", request); } + + if (config.wiseoldman()) + { + HttpUrl url = new HttpUrl.Builder() + .scheme("https") + .host("wiseoldman.net") + .addPathSegment("api") + .addPathSegment("players") + .addPathSegment("track") + .build(); + + RequestBody formBody = new FormBody.Builder() + .add("username", username) + .build(); + + Request request = new Request.Builder() + .header("User-Agent", "RuneLite") + .url(url) + .post(formBody) + .build(); + + sendRequest("Wise Old Man", request); + } } private static void sendRequest(String platform, Request request) From 1c272bb649f70cc77d2a0a21224e47fceab7246e Mon Sep 17 00:00:00 2001 From: 15987632 Date: Sat, 16 Nov 2019 22:27:18 -0500 Subject: [PATCH 12/12] cache: add spotanim dump test --- .../runelite/cache/SpotanimDumperTest.java | 89 +++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 cache/src/test/java/net/runelite/cache/SpotanimDumperTest.java diff --git a/cache/src/test/java/net/runelite/cache/SpotanimDumperTest.java b/cache/src/test/java/net/runelite/cache/SpotanimDumperTest.java new file mode 100644 index 0000000000..93de3d66f4 --- /dev/null +++ b/cache/src/test/java/net/runelite/cache/SpotanimDumperTest.java @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2019, Trevor + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * 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. + * 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 SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.cache; + +import com.google.common.io.Files; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import java.io.File; +import java.io.IOException; +import java.nio.charset.Charset; +import lombok.extern.slf4j.Slf4j; +import net.runelite.cache.definitions.SpotAnimDefinition; +import net.runelite.cache.definitions.loaders.SpotAnimLoader; +import net.runelite.cache.fs.Archive; +import net.runelite.cache.fs.ArchiveFiles; +import net.runelite.cache.fs.FSFile; +import net.runelite.cache.fs.Index; +import net.runelite.cache.fs.Storage; +import net.runelite.cache.fs.Store; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TemporaryFolder; + +@Slf4j +public class SpotanimDumperTest +{ + private final Gson gson = new GsonBuilder().setPrettyPrinting().create(); + + @Rule + public TemporaryFolder folder = StoreLocation.getTemporaryFolder(); + + @Test + public void test() throws IOException + { + File dumpDir = folder.newFolder("spotanims"); + int count = 0; + + try (Store store = new Store(StoreLocation.LOCATION)) + { + store.load(); + + Storage storage = store.getStorage(); + Index index = store.getIndex(IndexType.CONFIGS); + Archive archive = index.getArchive(ConfigType.SPOTANIM.getId()); + + byte[] archiveData = storage.loadArchive(archive); + ArchiveFiles files = archive.getFiles(archiveData); + + SpotAnimLoader loader = new SpotAnimLoader(); + + for (FSFile file : files.getFiles()) + { + byte[] b = file.getContents(); + + SpotAnimDefinition def = loader.load(file.getFileId(), b); + + if (def != null) + { + Files.asCharSink(new File(dumpDir, file.getFileId() + ".json"), Charset.defaultCharset()).write(gson.toJson(def)); + ++count; + } + } + } + + log.info("Dumped {} spotanims to {}", count, dumpDir); + } +}