Merge remote-tracking branch 'upstream/master' into depsdepsdeps

This commit is contained in:
Owain van Brakel
2019-09-05 10:15:33 +02:00
15 changed files with 225 additions and 138 deletions

View File

@@ -43,6 +43,7 @@ ext {
httpcore = '4.4.12' httpcore = '4.4.12'
httpmime = '4.5.9' httpmime = '4.5.9'
javassist = '3.25.0-GA' javassist = '3.25.0-GA'
javax = '1.3.2'
javaxInject = '1' javaxInject = '1'
jbsdiff = '1.0' jbsdiff = '1.0'
jclCore = '2.8' jclCore = '2.8'

View File

@@ -11,6 +11,7 @@ description = 'RuneLite Client'
dependencies { dependencies {
annotationProcessor group: 'org.projectlombok', name: 'lombok', version: lombok annotationProcessor group: 'org.projectlombok', name: 'lombok', version: lombok
compileOnly group: 'javax.annotation', name: 'javax.annotation-api', version: javax
compileOnly group: 'net.runelite', name: 'orange-extensions', version: orangeExtensions compileOnly group: 'net.runelite', name: 'orange-extensions', version: orangeExtensions
compileOnly group: 'org.projectlombok', name: 'lombok', version: lombok compileOnly group: 'org.projectlombok', name: 'lombok', version: lombok

View File

@@ -290,7 +290,7 @@ public class EquipmentInspectorPlugin extends Plugin
StringPrice = NumberFormat.getIntegerInstance().format(TotalPrice); StringPrice = NumberFormat.getIntegerInstance().format(TotalPrice);
} }
chatMessageManager.queue(QueuedMessage.builder() chatMessageManager.queue(QueuedMessage.builder()
.type(ChatMessageType.FRIENDSCHATNOTIFICATION) .type(ChatMessageType.CONSOLE)
.runeLiteFormattedMessage(new ChatMessageBuilder() .runeLiteFormattedMessage(new ChatMessageBuilder()
.append(ChatColorType.HIGHLIGHT) .append(ChatColorType.HIGHLIGHT)
.append("Risked Value: ") .append("Risked Value: ")

View File

@@ -31,9 +31,9 @@ import lombok.Getter;
@AllArgsConstructor @AllArgsConstructor
public enum PlayerSpellEffect public enum PlayerSpellEffect
{ {
BIND("Bind", 181, 4800, true, 0, TimerType.FREEZE), BIND("Bind", 181, 4800, false, 0, TimerType.FREEZE),
SNARE("Snare", 180, 9600, true, 1, TimerType.FREEZE), SNARE("Snare", 180, 9600, false, 1, TimerType.FREEZE),
ENTANGLE("Entangle", 179, 14400, true, 2, TimerType.FREEZE), ENTANGLE("Entangle", 179, 14400, false, 2, TimerType.FREEZE),
RUSH("Ice Rush", 361, 4800, false, 3, TimerType.FREEZE), RUSH("Ice Rush", 361, 4800, false, 3, TimerType.FREEZE),
BURST("Ice Burst", 363, 9600, false, 4, TimerType.FREEZE), BURST("Ice Burst", 363, 9600, false, 4, TimerType.FREEZE),
BLITZ("Ice Blitz", 367, 14400, false, 5, TimerType.FREEZE), BLITZ("Ice Blitz", 367, 14400, false, 5, TimerType.FREEZE),

View File

@@ -223,7 +223,7 @@ class GauntletTimer extends Overlay
.append(elapsedTime); .append(elapsedTime);
chatMessageManager.queue(QueuedMessage.builder() chatMessageManager.queue(QueuedMessage.builder()
.type(ChatMessageType.FRIENDSCHATNOTIFICATION) .type(ChatMessageType.CONSOLE)
.runeLiteFormattedMessage(prepmessage.build()) .runeLiteFormattedMessage(prepmessage.build())
.build()); .build());
} }
@@ -246,7 +246,7 @@ class GauntletTimer extends Overlay
.append(elapsedTotalTime); .append(elapsedTotalTime);
chatMessageManager.queue(QueuedMessage.builder() chatMessageManager.queue(QueuedMessage.builder()
.type(ChatMessageType.FRIENDSCHATNOTIFICATION) .type(ChatMessageType.CONSOLE)
.runeLiteFormattedMessage(challengedurationmessage.build()) .runeLiteFormattedMessage(challengedurationmessage.build())
.build()); .build());
@@ -261,7 +261,7 @@ class GauntletTimer extends Overlay
.append(elapsedBossTime); .append(elapsedBossTime);
chatMessageManager.queue(QueuedMessage.builder() chatMessageManager.queue(QueuedMessage.builder()
.type(ChatMessageType.FRIENDSCHATNOTIFICATION) .type(ChatMessageType.CONSOLE)
.runeLiteFormattedMessage(prepdeathmessage.build()) .runeLiteFormattedMessage(prepdeathmessage.build())
.build()); .build());
} }

View File

@@ -47,7 +47,11 @@ public interface GroundMarkerConfig extends Config
FIVE("5"), FIVE("5"),
SIX("6"), SIX("6"),
SEVEN("7"), SEVEN("7"),
EIGHT("8"); EIGHT("8"),
NINE("9"),
TEN("10"),
ELEVEN("11"),
TWELVE("12");
private final String name; private final String name;
@@ -78,11 +82,11 @@ public interface GroundMarkerConfig extends Config
@ConfigItem( @ConfigItem(
position = 1, position = 1,
keyName = "markerColor", keyName = "markerColor",
name = "Default Marked tile Color", name = "Default tile Color",
description = "Configures the default color of marked tiles", description = "Configures the default color of marked tiles",
hidden = true, hidden = true,
unhide = "amount", unhide = "amount",
unhideValue = "1 || 2 || 3 || 4 || 5 || 6 || 7 || 8" unhideValue = "1 || 2 || 3 || 4 || 5 || 6 || 7 || 8 || 9 || 10 || 11 || 12"
) )
default Color markerColor() default Color markerColor()
{ {
@@ -97,7 +101,7 @@ public interface GroundMarkerConfig extends Config
description = "Configures the color of the 2nd group of marked tiles", description = "Configures the color of the 2nd group of marked tiles",
hidden = true, hidden = true,
unhide = "amount", unhide = "amount",
unhideValue = "2 || 3 || 4 || 5 || 6 || 7 || 8" unhideValue = "2 || 3 || 4 || 5 || 6 || 7 || 8 || 9 || 10 || 11 || 12"
) )
default Color markerColor2() default Color markerColor2()
{ {
@@ -112,7 +116,7 @@ public interface GroundMarkerConfig extends Config
description = "Configures the color of the 3rd group of marked tiles", description = "Configures the color of the 3rd group of marked tiles",
hidden = true, hidden = true,
unhide = "amount", unhide = "amount",
unhideValue = "3 || 4 || 5 || 6 || 7 || 8" unhideValue = "3 || 4 || 5 || 6 || 7 || 8 || 9 || 10 || 11 || 12"
) )
default Color markerColor3() default Color markerColor3()
{ {
@@ -127,7 +131,7 @@ public interface GroundMarkerConfig extends Config
description = "Configures the color of the 4th group of marked tiles", description = "Configures the color of the 4th group of marked tiles",
hidden = true, hidden = true,
unhide = "amount", unhide = "amount",
unhideValue = "4 || 5 || 6 || 7 || 8" unhideValue = "4 || 5 || 6 || 7 || 8 || 9 || 10 || 11 || 12"
) )
default Color markerColor4() default Color markerColor4()
{ {
@@ -142,7 +146,7 @@ public interface GroundMarkerConfig extends Config
description = "Configures the color of the 5th group of marked tiles", description = "Configures the color of the 5th group of marked tiles",
hidden = true, hidden = true,
unhide = "amount", unhide = "amount",
unhideValue = "5 || 6 || 7 || 8" unhideValue = "5 || 6 || 7 || 8 || 9 || 10 || 11 || 12"
) )
default Color markerColor5() default Color markerColor5()
{ {
@@ -157,7 +161,7 @@ public interface GroundMarkerConfig extends Config
description = "Configures the color of the 6th group of marked tiles", description = "Configures the color of the 6th group of marked tiles",
hidden = true, hidden = true,
unhide = "amount", unhide = "amount",
unhideValue = "6 || 7 || 8" unhideValue = "6 || 7 || 8 || 9 || 10 || 11 || 12"
) )
default Color markerColor6() default Color markerColor6()
{ {
@@ -172,7 +176,7 @@ public interface GroundMarkerConfig extends Config
description = "Configures the color of the 7th group of marked tiles", description = "Configures the color of the 7th group of marked tiles",
hidden = true, hidden = true,
unhide = "amount", unhide = "amount",
unhideValue = "7 || 8" unhideValue = "7 || 8 || 9 || 10 || 11 || 12"
) )
default Color markerColor7() default Color markerColor7()
{ {
@@ -187,15 +191,75 @@ public interface GroundMarkerConfig extends Config
description = "Configures the color of the 8th group of marked tiles", description = "Configures the color of the 8th group of marked tiles",
hidden = true, hidden = true,
unhide = "amount", unhide = "amount",
unhideValue = "8" unhideValue = "8 || 9 || 10 || 11 || 12"
) )
default Color markerColor8() default Color markerColor8()
{ {
return Color.MAGENTA; return Color.MAGENTA;
} }
@Alpha
@ConfigItem( @ConfigItem(
position = 10, position = 10,
keyName = "markerColor9",
name = "Group 9 tile color",
description = "Configures the color of the 9th group of marked tiles",
hidden = true,
unhide = "amount",
unhideValue = "9 || 10 || 11 || 12"
)
default Color markerColor9()
{
return Color.CYAN;
}
@Alpha
@ConfigItem(
position = 11,
keyName = "markerColor10",
name = "Group 10 tile color",
description = "Configures the color of the 10th group of marked tiles",
hidden = true,
unhide = "amount",
unhideValue = "10 || 11 || 12"
)
default Color markerColor10()
{
return Color.ORANGE;
}
@Alpha
@ConfigItem(
position = 12,
keyName = "markerColor11",
name = "Group 11 tile color",
description = "Configures the color of the 11th group of marked tiles",
hidden = true,
unhide = "amount",
unhideValue = "11 || 12"
)
default Color markerColor11()
{
return Color.PINK;
}
@Alpha
@ConfigItem(
position = 13,
keyName = "markerColor12",
name = "Group 12 tile color",
description = "Configures the color of the 12th group of marked tiles",
hidden = true,
unhide = "amount",
unhideValue = "12"
)
default Color markerColor12()
{
return Color.LIGHT_GRAY;
}
@ConfigItem(
position = 14,
keyName = "showMinimap", keyName = "showMinimap",
name = "Show on minimap", name = "Show on minimap",
description = "Shows marked tiles on the minimap" description = "Shows marked tiles on the minimap"
@@ -210,7 +274,7 @@ public interface GroundMarkerConfig extends Config
max = 100 max = 100
) )
@ConfigItem( @ConfigItem(
position = 11, position = 15,
keyName = "minimapOpacity", keyName = "minimapOpacity",
name = "Minimap opacity", name = "Minimap opacity",
description = "The opacity of the minimap markers" description = "The opacity of the minimap markers"

View File

@@ -101,6 +101,18 @@ class GroundMarkerMinimapOverlay extends Overlay
break; break;
case 8: case 8:
color = plugin.getMarkerColor8(); color = plugin.getMarkerColor8();
break;
case 9:
color = plugin.getMarkerColor9();
break;
case 10:
color = plugin.getMarkerColor10();
break;
case 11:
color = plugin.getMarkerColor11();
break;
case 12:
color = plugin.getMarkerColor12();
} }
int opacity = (int) floor(plugin.getMinimapOverlayOpacity() * 2.55); int opacity = (int) floor(plugin.getMinimapOverlayOpacity() * 2.55);
@@ -129,4 +141,4 @@ class GroundMarkerMinimapOverlay extends Overlay
OverlayUtil.renderMinimapRect(client, graphics, posOnMinimap, TILE_WIDTH, TILE_HEIGHT, color); OverlayUtil.renderMinimapRect(client, graphics, posOnMinimap, TILE_WIDTH, TILE_HEIGHT, color);
} }
} }

View File

@@ -113,7 +113,19 @@ public class GroundMarkerOverlay extends Overlay
break; break;
case 8: case 8:
color = plugin.getMarkerColor8(); color = plugin.getMarkerColor8();
break;
case 9:
color = plugin.getMarkerColor9();
break;
case 10:
color = plugin.getMarkerColor10();
break;
case 11:
color = plugin.getMarkerColor11();
break;
case 12:
color = plugin.getMarkerColor12();
} }
OverlayUtil.renderPolygon(graphics, poly, color); OverlayUtil.renderPolygon(graphics, poly, color);
} }
} }

View File

@@ -162,6 +162,14 @@ public class GroundMarkerPlugin extends Plugin
@Getter(AccessLevel.PACKAGE) @Getter(AccessLevel.PACKAGE)
private Color markerColor8; private Color markerColor8;
@Getter(AccessLevel.PACKAGE) @Getter(AccessLevel.PACKAGE)
private Color markerColor9;
@Getter(AccessLevel.PACKAGE)
private Color markerColor10;
@Getter(AccessLevel.PACKAGE)
private Color markerColor11;
@Getter(AccessLevel.PACKAGE)
private Color markerColor12;
@Getter(AccessLevel.PACKAGE)
private boolean showMinimap; private boolean showMinimap;
@Getter(AccessLevel.PACKAGE) @Getter(AccessLevel.PACKAGE)
private int minimapOverlayOpacity; private int minimapOverlayOpacity;
@@ -459,6 +467,18 @@ public class GroundMarkerPlugin extends Plugin
break; break;
case 8: case 8:
color = this.markerColor8; color = this.markerColor8;
break;
case 9:
color = this.markerColor9;
break;
case 10:
color = this.markerColor10;
break;
case 11:
color = this.markerColor11;
break;
case 12:
color = this.markerColor12;
} }
return color; return color;
@@ -483,7 +503,11 @@ public class GroundMarkerPlugin extends Plugin
this.markerColor6 = config.markerColor6(); this.markerColor6 = config.markerColor6();
this.markerColor7 = config.markerColor7(); this.markerColor7 = config.markerColor7();
this.markerColor8 = config.markerColor8(); this.markerColor8 = config.markerColor8();
this.markerColor9 = config.markerColor9();
this.markerColor10 = config.markerColor10();
this.markerColor11 = config.markerColor11();
this.markerColor12 = config.markerColor12();
this.showMinimap = config.showMinimap(); this.showMinimap = config.showMinimap();
this.minimapOverlayOpacity = config.minimapOverlayOpacity(); this.minimapOverlayOpacity = config.minimapOverlayOpacity();
} }
} }

View File

@@ -160,7 +160,10 @@ public class PlayerIndicatorsOverlay extends Overlay
if (plugin.getAgilityFormat() == PlayerIndicatorsPlugin.AgilityFormats.ICONS) if (plugin.getAgilityFormat() == PlayerIndicatorsPlugin.AgilityFormats.ICONS)
{ {
final int width = graphics.getFontMetrics().stringWidth(name);
final int width = plugin.isShowCombatLevel() ? graphics.getFontMetrics().stringWidth(name)
+ ACTOR_HORIZONTAL_TEXT_MARGIN : graphics.getFontMetrics().stringWidth(name);
final int height = graphics.getFontMetrics().getHeight(); final int height = graphics.getFontMetrics().getHeight();
if (level >= plugin.getAgilityFirstThreshold()) if (level >= plugin.getAgilityFirstThreshold())
{ {

View File

@@ -60,25 +60,26 @@ public class PlayerIndicatorsService
self = (player) -> Objects.equals(client.getLocalPlayer(), player); self = (player) -> Objects.equals(client.getLocalPlayer(), player);
friend = (player) -> (!player.equals(client.getLocalPlayer()) && client.isFriended(player.getName(), false)); friend = (player) -> (!player.equals(client.getLocalPlayer()) && client.isFriended(player.getName(), false));
clan = Player::isClanMember; clan = (player) -> (player.isClanMember() && !client.isFriended(player.getName(), false));
team = (player) -> (Objects.requireNonNull(client.getLocalPlayer()).getTeam() != 0 && team = (player) -> (Objects.requireNonNull(client.getLocalPlayer()).getTeam() != 0 &&
client.getLocalPlayer().getTeam() == player.getTeam()); client.getLocalPlayer().getTeam() == player.getTeam());
target = (player) -> PvPUtil.isAttackable(client, player); target = (player ->
{
if (nonFriendly(player))
{
return false;
}
return plugin.isHighlightTargets() && PvPUtil.isAttackable(client, player);
});
caller = plugin::isCaller; caller = plugin::isCaller;
callerTarget = piles::contains; callerTarget = piles::contains;
other = (player -> other = (player ->
{ {
if (player == null if (nonFriendly(player))
|| (plugin.isHighlightClan() && player.isClanMember())
|| (plugin.isHighlightFriends() && client.isFriended(player.getName(), false))
|| (plugin.isHighlightCallers() && plugin.isCaller(player))
|| (plugin.isHighlightCallerTargets() && piles.contains(player))
|| (plugin.isHighlightTeam() && Objects.requireNonNull(client.getLocalPlayer()).getTeam() != 0
&& client.getLocalPlayer().getTeam() == player.getTeam()))
{ {
return false; return false;
} }
return !plugin.isHighlightTargets() || PvPUtil.isAttackable(client, player); return true;
}); });
} }
@@ -141,4 +142,15 @@ public class PlayerIndicatorsService
|| plugin.isHighlightFriends() || plugin.isHighlightOther() || plugin.isHighlightTargets() || plugin.isHighlightFriends() || plugin.isHighlightOther() || plugin.isHighlightTargets()
|| plugin.isHighlightCallers() || plugin.isHighlightTeam() || plugin.isHighlightCallerTargets(); || plugin.isHighlightCallers() || plugin.isHighlightTeam() || plugin.isHighlightCallerTargets();
} }
private boolean nonFriendly(Player player)
{
return player == null
|| (plugin.isHighlightClan() && player.isClanMember())
|| (plugin.isHighlightFriends() && client.isFriended(player.getName(), false))
|| (plugin.isHighlightCallers() && plugin.isCaller(player))
|| (plugin.isHighlightCallerTargets() && piles.contains(player))
|| (plugin.isHighlightTeam() && Objects.requireNonNull(client.getLocalPlayer()).getTeam() != 0
&& client.getLocalPlayer().getTeam() == player.getTeam());
}
} }

View File

@@ -120,6 +120,9 @@ class ProfilesPanel extends PluginPanel
txtDecryptPassword.setEchoChar((char) 0); txtDecryptPassword.setEchoChar((char) 0);
txtDecryptPassword.setForeground(ColorScheme.LIGHT_GRAY_COLOR); txtDecryptPassword.setForeground(ColorScheme.LIGHT_GRAY_COLOR);
txtDecryptPassword.setToolTipText(UNLOCK_PASSWORD); txtDecryptPassword.setToolTipText(UNLOCK_PASSWORD);
txtDecryptPassword.addActionListener(e -> decryptAccounts());
txtDecryptPassword.addFocusListener(new FocusListener() txtDecryptPassword.addFocusListener(new FocusListener()
{ {
@Override @Override
@@ -156,27 +159,7 @@ class ProfilesPanel extends PluginPanel
@Override @Override
public void mousePressed(MouseEvent e) public void mousePressed(MouseEvent e)
{ {
boolean error = false; decryptAccounts();
try
{
redrawProfiles();
}
catch (InvalidKeySpecException | NoSuchAlgorithmException | IllegalBlockSizeException | InvalidKeyException | BadPaddingException | NoSuchPaddingException ex)
{
error = true;
showErrorMessage("Unable to load data", "Incorrect password!");
}
if (error)
{
return;
}
remove(loginPanel);
add(accountPanel, BorderLayout.CENTER);
profilesPanel.setLayout(new DynamicGridLayout(0, 1, 0, 3));
add(profilesPanel, BorderLayout.SOUTH);
} }
@Override @Override
@@ -386,6 +369,38 @@ class ProfilesPanel extends PluginPanel
// addAccounts(config.profilesData()); // addAccounts(config.profilesData());
} }
private void decryptAccounts()
{
if (txtDecryptPassword.getPassword().length == 0 || String.valueOf(txtDecryptPassword.getPassword()).equals(UNLOCK_PASSWORD))
{
showErrorMessage("Unable to load data", "Please enter a password!");
return;
}
boolean error = false;
try
{
redrawProfiles();
}
catch (InvalidKeySpecException | NoSuchAlgorithmException | IllegalBlockSizeException | InvalidKeyException | BadPaddingException | NoSuchPaddingException ex)
{
error = true;
showErrorMessage("Unable to load data", "Incorrect password!");
txtDecryptPassword.setText("");
}
if (error)
{
return;
}
remove(loginPanel);
add(accountPanel, BorderLayout.CENTER);
profilesPanel.setLayout(new DynamicGridLayout(0, 1, 0, 3));
add(profilesPanel, BorderLayout.SOUTH);
}
private void redrawProfiles() throws InvalidKeySpecException, NoSuchAlgorithmException, IllegalBlockSizeException, InvalidKeyException, BadPaddingException, NoSuchPaddingException private void redrawProfiles() throws InvalidKeySpecException, NoSuchAlgorithmException, IllegalBlockSizeException, InvalidKeyException, BadPaddingException, NoSuchPaddingException
{ {
profilesPanel.removeAll(); profilesPanel.removeAll();
@@ -462,11 +477,6 @@ class ProfilesPanel extends PluginPanel
String tmp = profilesConfig.profilesData(); String tmp = profilesConfig.profilesData();
if (tmp.startsWith("¬")) if (tmp.startsWith("¬"))
{ {
if (txtDecryptPassword.getPassword().length == 0 || String.valueOf(txtDecryptPassword.getPassword()).equals(UNLOCK_PASSWORD))
{
showErrorMessage("Unable to load data", "Please enter a password!");
return tmp;
}
tmp = tmp.substring(1); tmp = tmp.substring(1);
return decryptText(base64Decode(tmp), getAesKey()); return decryptText(base64Decode(tmp), getAesKey());
} }

View File

@@ -19,17 +19,6 @@ public interface SafeSpotConfig extends Config
{ {
@ConfigItem( @ConfigItem(
position = 1, position = 1,
keyName = "playerSafeSpots",
name = "Render for Players",
description = "Renders 1 way safe spots vs other players"
)
default boolean playerSafeSpots()
{
return true;
}
@ConfigItem(
position = 2,
keyName = "npcSafeSpots", keyName = "npcSafeSpots",
name = "Render for NPCs", name = "Render for NPCs",
description = "Renders 1 way safe spots vs NPCs" description = "Renders 1 way safe spots vs NPCs"
@@ -40,7 +29,7 @@ public interface SafeSpotConfig extends Config
} }
@ConfigItem( @ConfigItem(
position = 3, position = 2,
keyName = "tileColor", keyName = "tileColor",
name = "Tile Color", name = "Tile Color",
description = "Color of safe spot tile" description = "Color of safe spot tile"

View File

@@ -21,7 +21,6 @@ import net.runelite.api.Actor;
import net.runelite.api.Client; import net.runelite.api.Client;
import net.runelite.api.CollisionDataFlag; import net.runelite.api.CollisionDataFlag;
import net.runelite.api.NPC; import net.runelite.api.NPC;
import net.runelite.api.Player;
import net.runelite.api.Tile; import net.runelite.api.Tile;
import net.runelite.api.coords.LocalPoint; import net.runelite.api.coords.LocalPoint;
import net.runelite.api.coords.WorldArea; import net.runelite.api.coords.WorldArea;
@@ -38,10 +37,10 @@ import net.runelite.client.plugins.PluginType;
import net.runelite.client.ui.overlay.OverlayManager; import net.runelite.client.ui.overlay.OverlayManager;
@PluginDescriptor( @PluginDescriptor(
name = "1 Way Safe Spots", name = "NPC Safe Spots",
description = "Renders tile overlays for one way safe spots", description = "Renders tile overlays for one way safe spots",
tags = {"safe spot", "pvp", "safespots", "pklite"}, tags = {"safe spot", "safespots", "pvm"},
type = PluginType.UTILITY, type = PluginType.PVM,
enabledByDefault = false enabledByDefault = false
) )
@Singleton @Singleton
@@ -71,7 +70,6 @@ public class SafeSpotPlugin extends Plugin
private SafeSpotOverlay safeSpotOverlay; private SafeSpotOverlay safeSpotOverlay;
private int tickCount = 0; private int tickCount = 0;
private boolean playerSafeSpots;
private boolean npcSafeSpots; private boolean npcSafeSpots;
@Getter(AccessLevel.PACKAGE) @Getter(AccessLevel.PACKAGE)
private Color tileColor; private Color tileColor;
@@ -113,7 +111,7 @@ public class SafeSpotPlugin extends Plugin
{ {
return; return;
} }
if (event.getTarget() == null && (this.npcSafeSpots || this.playerSafeSpots)) if (event.getTarget() == null && this.npcSafeSpots)
{ {
tickCount = 10; tickCount = 10;
} }
@@ -123,11 +121,6 @@ public class SafeSpotPlugin extends Plugin
{ {
if (client.getLocalPlayer().getInteracting() != null) if (client.getLocalPlayer().getInteracting() != null)
{ {
if (client.getLocalPlayer().getInteracting() instanceof Player && this.playerSafeSpots)
{
safeSpotsRenderable = true;
updateSafeSpots();
}
if (client.getLocalPlayer().getInteracting() instanceof NPC && this.npcSafeSpots) if (client.getLocalPlayer().getInteracting() instanceof NPC && this.npcSafeSpots)
{ {
if (npcManager.getStats(((NPC) client.getLocalPlayer().getInteracting()).getId()) != null) if (npcManager.getStats(((NPC) client.getLocalPlayer().getInteracting()).getId()) != null)
@@ -215,7 +208,6 @@ public class SafeSpotPlugin extends Plugin
private void updateConfig() private void updateConfig()
{ {
this.playerSafeSpots = config.playerSafeSpots();
this.npcSafeSpots = config.npcSafeSpots(); this.npcSafeSpots = config.npcSafeSpots();
this.tileColor = config.tileColor(); this.tileColor = config.tileColor();
} }

View File

@@ -37,7 +37,6 @@ import lombok.extern.slf4j.Slf4j;
import static net.runelite.api.AnimationID.*; import static net.runelite.api.AnimationID.*;
import net.runelite.api.ChatMessageType; import net.runelite.api.ChatMessageType;
import net.runelite.api.Client; import net.runelite.api.Client;
import static net.runelite.api.GameState.LOADING;
import net.runelite.api.InventoryID; import net.runelite.api.InventoryID;
import net.runelite.api.Item; import net.runelite.api.Item;
import net.runelite.api.ItemContainer; import net.runelite.api.ItemContainer;
@@ -50,7 +49,6 @@ import net.runelite.api.events.AnimationChanged;
import net.runelite.api.events.ChatMessage; import net.runelite.api.events.ChatMessage;
import net.runelite.api.events.ConfigChanged; import net.runelite.api.events.ConfigChanged;
import net.runelite.api.events.GameTick; import net.runelite.api.events.GameTick;
import net.runelite.api.events.GameStateChanged;
import net.runelite.api.events.ItemContainerChanged; import net.runelite.api.events.ItemContainerChanged;
import net.runelite.api.events.VarbitChanged; import net.runelite.api.events.VarbitChanged;
import net.runelite.client.Notifier; import net.runelite.client.Notifier;
@@ -116,8 +114,6 @@ public class WintertodtPlugin extends Plugin
private WintertodtNotifyMode notifyCondition; private WintertodtNotifyMode notifyCondition;
private Color damageNotificationColor; private Color damageNotificationColor;
private boolean subscribed;
@Provides @Provides
WintertodtConfig getConfig(ConfigManager configManager) WintertodtConfig getConfig(ConfigManager configManager)
{ {
@@ -134,15 +130,12 @@ public class WintertodtPlugin extends Plugin
reset(); reset();
overlayManager.add(overlay); overlayManager.add(overlay);
handleWintertodtRegion();
} }
@Override @Override
protected void shutDown() throws Exception protected void shutDown() throws Exception
{ {
eventBus.unregister(this); super.shutDown();
eventBus.unregister("inside-wintertodt");
overlayManager.remove(overlay); overlayManager.remove(overlay);
reset(); reset();
@@ -151,23 +144,11 @@ public class WintertodtPlugin extends Plugin
private void addSubscriptions() private void addSubscriptions()
{ {
eventBus.subscribe(ConfigChanged.class, this, this::onConfigChanged); eventBus.subscribe(ConfigChanged.class, this, this::onConfigChanged);
eventBus.subscribe(GameStateChanged.class, this, this::onGameStateChanged); eventBus.subscribe(GameTick.class, this, this::onGameTick);
eventBus.subscribe(VarbitChanged.class, this, this::onVarbitChanged); eventBus.subscribe(VarbitChanged.class, this, this::onVarbitChanged);
} eventBus.subscribe(ChatMessage.class, this, this::onChatMessage);
eventBus.subscribe(AnimationChanged.class, this, this::onAnimationChanged);
private void wintertodtSubscriptions(boolean subscribe) eventBus.subscribe(ItemContainerChanged.class, this, this::onItemContainerChanged);
{
if (subscribe)
{
eventBus.subscribe(GameTick.class, "inside-wintertodt", this::onGameTick);
eventBus.subscribe(ChatMessage.class, "inside-wintertodt", this::onChatMessage);
eventBus.subscribe(AnimationChanged.class, "inside-wintertodt", this::onAnimationChanged);
eventBus.subscribe(ItemContainerChanged.class, "inside-wintertodt", this::onItemContainerChanged);
}
else
{
eventBus.unregister("inside-wintertodt");
}
} }
private void onConfigChanged(ConfigChanged event) private void onConfigChanged(ConfigChanged event)
@@ -199,24 +180,9 @@ public class WintertodtPlugin extends Plugin
return false; return false;
} }
private void handleWintertodtRegion() private void onGameTick(GameTick gameTick)
{ {
if (isInWintertodtRegion()) if (!isInWintertodtRegion())
{
if (!isInWintertodt)
{
reset();
log.debug("Entered Wintertodt!");
}
isInWintertodt = true;
if (!subscribed)
{
wintertodtSubscriptions(true);
subscribed = true;
}
}
else
{ {
if (isInWintertodt) if (isInWintertodt)
{ {
@@ -225,25 +191,16 @@ public class WintertodtPlugin extends Plugin
} }
isInWintertodt = false; isInWintertodt = false;
return;
if (subscribed)
{
wintertodtSubscriptions(false);
subscribed = false;
}
} }
}
private void onGameStateChanged(GameStateChanged event) if (!isInWintertodt)
{
if (event.getGameState() == LOADING)
{ {
handleWintertodtRegion(); reset();
log.debug("Entered Wintertodt!");
} }
} isInWintertodt = true;
private void onGameTick(GameTick gameTick)
{
checkActionTimeout(); checkActionTimeout();
} }
@@ -295,6 +252,11 @@ public class WintertodtPlugin extends Plugin
private void onChatMessage(ChatMessage chatMessage) private void onChatMessage(ChatMessage chatMessage)
{ {
if (!isInWintertodt)
{
return;
}
ChatMessageType chatMessageType = chatMessage.getType(); ChatMessageType chatMessageType = chatMessage.getType();
if (chatMessageType != ChatMessageType.GAMEMESSAGE && chatMessageType != ChatMessageType.SPAM) if (chatMessageType != ChatMessageType.GAMEMESSAGE && chatMessageType != ChatMessageType.SPAM)
@@ -433,6 +395,11 @@ public class WintertodtPlugin extends Plugin
private void onAnimationChanged(final AnimationChanged event) private void onAnimationChanged(final AnimationChanged event)
{ {
if (!isInWintertodt)
{
return;
}
final Player local = client.getLocalPlayer(); final Player local = client.getLocalPlayer();
if (event.getActor() != local) if (event.getActor() != local)
@@ -479,7 +446,7 @@ public class WintertodtPlugin extends Plugin
{ {
final ItemContainer container = event.getItemContainer(); final ItemContainer container = event.getItemContainer();
if (container != client.getItemContainer(InventoryID.INVENTORY)) if (!isInWintertodt || container != client.getItemContainer(InventoryID.INVENTORY))
{ {
return; return;
} }