Skip to content

Commit

Permalink
More refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
pajlada committed Nov 29, 2023
1 parent fb52ba1 commit 14bd863
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class StealingArtefactsHouseOverlay extends Overlay {
*/
@Override
public Dimension render(Graphics2D graphics) {
if (plugin.taskState == null) {
if (plugin.taskState == null || !plugin.isPlayerInPisc()) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public Dimension render(Graphics2D graphics) {

panelComponent.getChildren().clear();
String title = "Stealing Artefacts";
String targetLine = getTargetMessage(plugin.taskState);
String targetLine = plugin.taskState != null ? plugin.taskState.getTarget() : "None";

// Title
panelComponent.getChildren().add(TitleComponent.builder().text(title).color(Color.YELLOW).build());
Expand Down Expand Up @@ -79,18 +79,4 @@ public Dimension render(Graphics2D graphics) {
panelComponent.setPreferredSize(new Dimension(200, 0));
return panelComponent.render(graphics);
}

/**
* Get the target message based on the state
*
* @param state The current minigame state
* @return The string to display as the target, either 'None' or the target message
*/
private String getTargetMessage(StealingArtefactsState state) {
if (state == null) {
return "None";
}

return state.getTarget();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class StealingArtefactsPatrolOverlay extends Overlay {
*/
@Override
public Dimension render(Graphics2D graphics) {
if (!config.highlightPatrols()) {
if (!config.highlightPatrols() || !plugin.isPlayerInPisc()) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ protected void shutDown() {
}

gameState.lazySet(null);
reset();
}

/**
Expand Down Expand Up @@ -247,13 +248,13 @@ private void updateTaskVarbit(int value) {

var localPlayer = client.getLocalPlayer();
if (localPlayer == null) {
log.debug("local player not loaded yet");
return;
}

switch (newState) {
case NO_TASK:
if (isInPisc(localPlayer.getWorldLocation())) {
// NOTE: This is not technically 100% safe
client.clearHintArrow();
}
reset();
Expand All @@ -266,14 +267,7 @@ private void updateTaskVarbit(int value) {
case WESTERN:
case NORTHWESTERN:
if (isInPisc(localPlayer.getWorldLocation())) {
var hintLocation = newState.getHintLocation();
if (hintLocation != null) {
client.setHintArrow(newState.getHintLocation());
} else {
log.warn("Invalid hint location from {}", newState);
}
} else {
log.debug("Player not in pisc, don't update anything");
client.setHintArrow(newState.getHintLocation());
}
break;

Expand All @@ -285,8 +279,6 @@ private void updateTaskVarbit(int value) {
} else {
client.setHintArrow(CAPTAIN_KHALED_ROUGH_POS);
}
} else {
log.debug("Player not in pisc, don't update anything");
}
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import lombok.RequiredArgsConstructor;
import net.runelite.api.ObjectID;
import net.runelite.api.coords.WorldPoint;
import org.jetbrains.annotations.Nullable;

/**
* Enum representing the current state of the minigame for the player
Expand All @@ -27,8 +28,8 @@ public enum StealingArtefactsState {
private final int drawerId;
private final int ladderId;
private final int drawerPlane;
private final WorldPoint hintLocation;
private final WorldPoint ladderLocation;
private final @Nullable WorldPoint hintLocation;
private final @Nullable WorldPoint ladderLocation;

/**
* Create a state for states that aren't a specific house
Expand Down

0 comments on commit 14bd863

Please sign in to comment.