Updates and rework to use CScript
This commit is contained in:
@ -10,12 +10,15 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.events.GameTick;
|
||||
import net.runelite.client.config.ConfigManager;
|
||||
import net.runelite.client.eventbus.Subscribe;
|
||||
import net.runelite.client.input.KeyListener;
|
||||
import net.runelite.client.plugins.PluginDependency;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
import net.runelite.client.plugins.iutils.iUtils;
|
||||
import net.runelite.client.plugins.iutils.scene.Position;
|
||||
import org.pf4j.Extension;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.HashMap;
|
||||
@ -30,7 +33,10 @@ import java.util.Map;
|
||||
enabledByDefault = false
|
||||
)
|
||||
@Slf4j
|
||||
public class Birdhouse extends CScript {
|
||||
public class Birdhouse extends CScript implements KeyListener {
|
||||
@Inject
|
||||
private Config config;
|
||||
|
||||
@Provides
|
||||
Config provideConfig(ConfigManager configManager) {
|
||||
return configManager.getConfig(Config.class);
|
||||
@ -87,17 +93,34 @@ public class Birdhouse extends CScript {
|
||||
@SuppressWarnings("unused")
|
||||
@Subscribe
|
||||
private void onGameTick(GameTick event) {
|
||||
if (isLoggedIn()
|
||||
&& game.localPlayer().position().regionID() == 14908) {
|
||||
if (!active && game.localPlayer().position().distanceTo(hillHousePosition) < 10 && game.inventory().withNamePart("logs").count() == 4) {
|
||||
execute();
|
||||
} else if (active && game.inventory().all().isEmpty() && !bank.isOpen() && game.localPlayer().position().distanceTo(islandPosition) < 10) {
|
||||
execute();
|
||||
}
|
||||
}
|
||||
// if (isLoggedIn()
|
||||
// && game.localPlayer().position().regionID() == 14908) {
|
||||
// if (!active && game.localPlayer().position().distanceTo(hillHousePosition) < 10 && game.inventory().withNamePart("logs").count() == 4) {
|
||||
// execute();
|
||||
// } else if (active && game.inventory().all().isEmpty() && !bank.isOpen() && game.localPlayer().position().distanceTo(islandPosition) < 10) {
|
||||
// execute();
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
public boolean hasRecentlyBeenEmptied(BirdhouseSpace space) {
|
||||
return Duration.between(getBirdhouseTimers().get(space), Instant.now()).getSeconds() < 2000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(KeyEvent e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyPressed(KeyEvent e) {
|
||||
if (config.birdhouseHotkey().matches(e)) {
|
||||
execute();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyReleased(KeyEvent e) {
|
||||
|
||||
}
|
||||
}
|
@ -1,10 +1,11 @@
|
||||
package io.reisub.openosrs.birdhouse;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import net.runelite.api.ItemID;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum BirdhouseType {
|
||||
|
@ -27,15 +27,29 @@ package io.reisub.openosrs.birdhouse;
|
||||
import net.runelite.client.config.Button;
|
||||
import net.runelite.client.config.ConfigGroup;
|
||||
import net.runelite.client.config.ConfigItem;
|
||||
import net.runelite.client.config.Keybind;
|
||||
|
||||
import java.awt.event.InputEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
@ConfigGroup("chaosbirdhouse")
|
||||
|
||||
public interface Config extends net.runelite.client.config.Config {
|
||||
@ConfigItem(
|
||||
keyName = "birdhouseHotkey",
|
||||
name = "Hotkey",
|
||||
description = "Press this key to start a birdhouse run.",
|
||||
position = 0
|
||||
)
|
||||
default Keybind birdhouseHotkey() {
|
||||
return new Keybind(KeyEvent.VK_F12, InputEvent.CTRL_DOWN_MASK);
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "farmSeaweed",
|
||||
name = "Farm seaweed",
|
||||
description = "Harvest and plant seaweed after a birdhouse run.",
|
||||
position = 0
|
||||
position = 1
|
||||
)
|
||||
default boolean farmSeaweed() { return true; }
|
||||
|
||||
|
@ -42,7 +42,9 @@ public class BankSpores extends Task {
|
||||
bank.depositInventory();
|
||||
game.tick();
|
||||
|
||||
bank.withdraw(ItemID.SEAWEED_SPORE, 2, false);
|
||||
bank.withdraw(ItemID.SEAWEED_SPORE, 1, false);
|
||||
game.sleepDelay();
|
||||
bank.withdraw(ItemID.SEAWEED_SPORE, 1, false);
|
||||
game.tick();
|
||||
|
||||
bank.withdraw(ItemID.FISHBOWL_HELMET, 1, false);
|
||||
@ -51,6 +53,9 @@ public class BankSpores extends Task {
|
||||
bank.withdraw(ItemID.DIVING_APPARATUS, 1, false);
|
||||
game.tick();
|
||||
|
||||
bank.withdraw(ItemID.FLIPPERS, 1, false);
|
||||
game.tick();
|
||||
|
||||
bank.close();
|
||||
game.waitUntil(() -> !bank.isOpen(), 5);
|
||||
|
||||
@ -59,6 +64,9 @@ public class BankSpores extends Task {
|
||||
|
||||
game.inventory().withId(ItemID.DIVING_APPARATUS).findFirst().ifPresent((apparatus) -> apparatus.interact("Wear"));
|
||||
game.tick();
|
||||
|
||||
game.inventory().withId(ItemID.FLIPPERS).findFirst().ifPresent((flippers) -> flippers.interact("Wear"));
|
||||
game.tick();
|
||||
iObject rowboat = game.objects().withName("Rowboat").nearest();
|
||||
if (rowboat == null) return;
|
||||
|
||||
|
@ -7,7 +7,6 @@ import io.reisub.openosrs.util.Task;
|
||||
import net.runelite.client.plugins.iutils.game.iObject;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
|
||||
public class EmptyBirdhouse extends Task {
|
||||
|
@ -23,7 +23,7 @@ public class GetTools extends Task {
|
||||
if (leprechaun == null) return;
|
||||
|
||||
leprechaun.interact("Exchange");
|
||||
game.waitUntil(() -> game.widget(125, 0) != null, 30);
|
||||
game.waitUntil(() -> game.widget(125, 0) != null && !game.widget(125, 0).hidden(), 30);
|
||||
game.tick();
|
||||
|
||||
iWidget dibber = game.widget(125, 9);
|
||||
|
Reference in New Issue
Block a user