Skip to content

Commit

Permalink
project: Merge upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
Owain94 committed May 1, 2020
1 parent 5a1f206 commit 2d17cf6
Show file tree
Hide file tree
Showing 21 changed files with 157 additions and 52 deletions.
2 changes: 1 addition & 1 deletion chatnotifications/chatnotifications.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

version = "0.0.4"
version = "0.0.5"

project.extra["PluginName"] = "Chat Notifications"
project.extra["PluginDescription"] = "Highlight and notify you of chat messages"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Strings;
import com.google.inject.Provides;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
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;
Expand Down Expand Up @@ -227,7 +227,10 @@ void onChatMessage(ChatMessage chatMessage)
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 = "<col" + ChatColorType.HIGHLIGHT.name() + "><u>" + username + "</u><col" + ChatColorType.NORMAL.name() + ">";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
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.api.util.Text;
import net.runelite.client.Notifier;
Expand Down Expand Up @@ -231,4 +232,39 @@ public void testStripColor()
{
assertEquals("you. It", ChatNotificationsPlugin.stripColor("you. <col=ff0000>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("<col=005f00>Logic Knot received a drop: Adamant longsword</col>");
ChatMessage chatMessage = new ChatMessage(messageNode, ChatMessageType.GAMEMESSAGE, "", "", "", 0);
chatNotificationsPlugin.onChatMessage(chatMessage);

verify(messageNode).setValue("<col=005f00><colHIGHLIGHT><u>Logic Knot</u><colNORMAL> received a drop: Adamant longsword</col>");
}

@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("<col=005f00>Logic\u00a0Knot received a drop: Adamant longsword</col>");
ChatMessage chatMessage = new ChatMessage(messageNode, ChatMessageType.GAMEMESSAGE, "", "", "", 0);
chatNotificationsPlugin.onChatMessage(chatMessage);

// set value uses our player name, which has nbsp replaced
verify(messageNode).setValue("<col=005f00><colHIGHLIGHT><u>Logic Knot</u><colNORMAL> received a drop: Adamant longsword</col>");
}
}
2 changes: 1 addition & 1 deletion itemidentification/itemidentification.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

version = "0.0.6"
version = "0.0.7"

project.extra["PluginName"] = "Item Identification"
project.extra["PluginDescription"] = "Show identifying text over items with difficult to distinguish sprites"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion itemstats/itemstats.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

version = "0.0.8"
version = "0.0.9"

project.extra["PluginName"] = "Item Stats"
project.extra["PluginDescription"] = "Show information about food and potion effects"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ private void init()
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);
Expand Down
2 changes: 1 addition & 1 deletion opponentinfo/opponentinfo.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

version = "0.0.8"
version = "0.0.9"

project.extra["PluginName"] = "Opponent Information"
project.extra["PluginDescription"] = "Show name and hitpoints information about the NPC you are fighting"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ public Dimension render(Graphics2D graphics)
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 = opponentInfoPlugin.getMaxHp(opponent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ private boolean modify(MenuEntry entry)
}

if (showHitpoints &&
actor.getHealth() > 0)
actor.getHealthScale() > 0)
{
int lvlIndex = target.lastIndexOf("(level-");
if (lvlIndex != -1)
Expand Down Expand Up @@ -371,7 +371,7 @@ private boolean fixup(MenuEntry entry)
boolean hasAggro = actor.getRSInteracting() - 32768 == client.getLocalPlayerIndex();
boolean hadAggro = target.charAt(0) == '*';
boolean isTarget = client.getLocalPlayer().getRSInteracting() == index;
boolean hasHp = showHitpoints && actor instanceof NPC && actor.getHealth() > 0;
boolean hasHp = showHitpoints && actor instanceof NPC && actor.getHealthScale() > 0;

boolean aggroChanged = showAttackers && hasAggro != hadAggro;
boolean targetChanged = showAttacking && isTarget != target.startsWith(attackingColTag, aggroChanged ? 1 : 0);
Expand Down Expand Up @@ -441,7 +441,7 @@ private boolean isNotAttackEntry(MenuEntry entry)
private String getHpString(Actor actor, boolean withColorTag)
{
int maxHp = getMaxHp(actor);
int health = actor.getHealth();
int health = actor.getHealthScale();
int ratio = actor.getHealthRatio();

final String result;
Expand Down
2 changes: 1 addition & 1 deletion prayer/prayer.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

version = "0.0.3"
version = "0.0.4"

project.extra["PluginName"] = "Prayer"
project.extra["PluginDescription"] = "Show various information related to prayer"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ void onTick()
return;
}

if (config.hideIfOutOfCombat() && localPlayer.getHealth() == -1)
if (config.hideIfOutOfCombat() && localPlayer.getHealthScale() == -1)
{
showingPrayerBar = false;
}
Expand Down
2 changes: 1 addition & 1 deletion slayer/slayer.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

version = "0.0.11"
version = "0.0.12"

project.extra["PluginName"] = "Slayer"
project.extra["PluginDescription"] = "Show additional slayer task related information"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ private int calculateHealth(NPC target)
return -1;
}

final int healthScale = target.getHealth();
final int healthScale = target.getHealthScale();
final int healthRatio = target.getHealthRatio();
final int maxHealth = npcManager.getHealth(target.getId());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ enum GameTimer
DIVINE_SUPER_DEFENCE(ItemID.DIVINE_SUPER_DEFENCE_POTION4, GameTimerImageType.ITEM, "Divine Super Defence", 5, ChronoUnit.MINUTES),
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_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);

private final Duration duration;
private final Integer graphicId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,14 @@ else if (event.getMessage().startsWith(KILLED_TELEBLOCK_OPPONENT_TEXT))
case "magic":
createGameTimer(DIVINE_MAGIC);
break;

case "bastion":
createGameTimer(DIVINE_BASTION);
break;

case "battlemage":
createGameTimer(DIVINE_BATTLEMAGE);
break;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,30 @@ public void testDmmFullTb()
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<InfoBox> 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<InfoBox> captor = ArgumentCaptor.forClass(InfoBox.class);
verify(infoBoxManager).addInfoBox(captor.capture());
TimerTimer infoBox = (TimerTimer) captor.getValue();
assertEquals(GameTimer.DIVINE_BATTLEMAGE, infoBox.getTimer());
}
}
2 changes: 1 addition & 1 deletion timers/timers.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

version = "0.0.5"
version = "0.0.6"

project.extra["PluginName"] = "Timers"
project.extra["PluginDescription"] = "Show various timers in an infobox"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,15 @@ default boolean templeosrs()
{
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;
}
}
Loading

0 comments on commit 2d17cf6

Please sign in to comment.