package io.reisub.dreambot.cplanker.tasks; import io.reisub.dreambot.util.Constants; import io.reisub.dreambot.util.Util; import org.dreambot.api.methods.Calculations; import org.dreambot.api.methods.MethodProvider; import org.dreambot.api.methods.container.impl.Inventory; import org.dreambot.api.methods.container.impl.bank.Bank; import org.dreambot.api.methods.filter.Filter; import org.dreambot.api.methods.interactive.GameObjects; import org.dreambot.api.methods.interactive.Players; import org.dreambot.api.methods.map.Tile; import org.dreambot.api.methods.walking.impl.Walking; import org.dreambot.api.methods.widget.Widgets; import org.dreambot.api.script.TaskNode; import org.dreambot.api.wrappers.interactive.GameObject; import org.dreambot.api.wrappers.items.Item; import org.dreambot.api.wrappers.widgets.WidgetChild; public class GoToSawmill extends TaskNode { private final Tile NEAR_BALLOON = new Tile(2457, 3106, 0); @Override public boolean accept() { return Inventory.onlyContains(item -> item.getName().equals("Coins") || item.getName().startsWith("Ring of dueling")) && NEAR_BALLOON.distance() < 50; } @Override public int execute() { GameObject basket = GameObjects.closest("Basket"); if (basket == null || basket.distance() > Calculations.random(6, 9)) { if (Walking.shouldWalk(Calculations.random(4, 6))) { Walking.walk(NEAR_BALLOON); } Filter ringFilter = item -> item.getName().startsWith("Ring of dueling"); if (Inventory.contains(ringFilter) && !Bank.isOpen()) { Inventory.interact(ringFilter, "Wear"); MethodProvider.sleepUntil(() -> !Inventory.contains(ringFilter), Calculations.random(2000, 3000)); } Util.sleepUntilMoving(); } else { basket.interactForceLeft(Constants.USE); if (Util.sleepUntilMoving()) { MethodProvider.sleepWhile(() -> Players.localPlayer().isMoving(), Calculations.random(4000, 4500)); } else { return Calculations.random(250, 400); } MethodProvider.sleepUntil(() -> { WidgetChild w = Widgets.getChildWidget(469, 18); return w != null && w.isVisible(); }, Calculations.random(4000, 4500)); } WidgetChild w = Widgets.getChildWidget(469, 18); if (w != null && w.isVisible()) { w.interact(); MethodProvider.sleepUntil(() -> NEAR_BALLOON.distance() > 50, Calculations.random(5000, 5500)); MethodProvider.sleep(800, 1200); } return Calculations.random(250, 400); } }