Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
isExternal = PluginConstants.IS_EXTERNAL
)
public class MahoganyHomesPlugin extends Plugin {
public static final String version = "0.0.8";
public static final String version = "0.0.9";
private static final List<Integer> PLANKS = Arrays.asList(ItemID.PLANK, ItemID.OAK_PLANK, ItemID.TEAK_PLANK, ItemID.MAHOGANY_PLANK);
private static final List<String> PLANK_NAMES = Arrays.asList("Plank", "Oak plank", "Teak plank", "Mahogany plank");
private static final Map<Integer, Integer> MAHOGANY_HOMES_REPAIRS = new HashMap<>();
Expand Down Expand Up @@ -271,6 +271,7 @@ public void shutDown() {
mapArrow = null;
lastChanged = null;
lastCompletedCount = -1;
plankCount = -1;
contractTier = 0;
script.shutdown();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import lombok.extern.slf4j.Slf4j;
import net.runelite.api.*;
import net.runelite.api.coords.WorldPoint;
import net.runelite.api.gameval.InterfaceID;
import net.runelite.client.plugins.microbot.Microbot;
import net.runelite.client.plugins.microbot.Script;
import net.runelite.client.plugins.microbot.shortestpath.ShortestPathPlugin;
Expand All @@ -23,6 +24,7 @@
import net.runelite.client.plugins.microbot.util.tile.Rs2Tile;
import net.runelite.client.plugins.microbot.util.walker.Rs2Walker;
import net.runelite.client.plugins.microbot.util.walker.WalkerState;
import net.runelite.client.plugins.microbot.util.widget.Rs2Widget;

import java.util.*;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -124,6 +126,13 @@ private void fix() {
return;
}

if (Rs2Widget.isWidgetVisible(InterfaceID.PohFurnitureCreation.FRAME)){
Microbot.log("Out of plank and furniture creation widget pop up");
Rs2Bank.walkToBank();
bank();
return;
}

Rs2WorldPoint playerLocation = Rs2Player.getRs2WorldPoint();
MahoganyHomesOverlay.setFixableObjects(getFixableObjects());

Expand Down Expand Up @@ -278,12 +287,26 @@ private void finish() {
var npc = Rs2Npc.getNpc(plugin.getCurrentHome().getNpcId());
if (npc == null && Rs2Player.getWorldLocation().getPlane() > 0) {
log("We are on the wrong floor, Trying to find ladder to go down");
TileObject closestLadder = Rs2GameObject.findObject(plugin.getCurrentHome().getLadders());
if (Rs2GameObject.interact(closestLadder))
sleepUntil(
() -> Rs2Player.getWorldLocation().getPlane() == 0
, 5000);
return;
int playerPlane = Rs2Player.getWorldLocation().getPlane();

List<GameObject> ladders = Rs2GameObject.getGameObjects(
obj -> Arrays.stream(plugin.getCurrentHome().getLadders())
.anyMatch(id -> id == obj.getId())
&& obj.getWorldLocation().getPlane() == playerPlane
);
GameObject closestLadder = ladders.stream()
.min(Comparator.comparingInt(obj ->
obj.getWorldLocation().distanceTo(Rs2Player.getWorldLocation())))
.orElse(null);
Rs2WorldPoint objectLocation = Rs2Tile.getNearestWalkableTile(closestLadder);
if (!openDoorToObject(closestLadder, objectLocation)) {
if (Rs2GameObject.interact(closestLadder)) {
sleepUntil(
() -> Rs2Player.getWorldLocation().getPlane() == 0
, 5000);
return;
}
}
}
if (npc != null) {
Rs2WorldPoint npcLocation = new Rs2WorldPoint(npc.getWorldLocation());
Expand Down