From 5cd483b457f44da41d5b275babbef26f2348a4b9 Mon Sep 17 00:00:00 2001 From: lhndl93 <61633800+lhndl93@users.noreply.github.com> Date: Thu, 21 Nov 2024 09:54:42 +0000 Subject: [PATCH 01/45] Fixed the shutDown not being called correctly, so not correctly stopping on plugin being diabled. Changed the way the storeFindsInCrate works, so we aren't using widgets. Checks inventory for the rareItems now, makes it easier. --- .../varrockcleaner/VarrockCleanerPlugin.java | 5 +++ .../varrockcleaner/VarrockCleanerScript.java | 33 +++++++++++++++---- 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/zerozero/varrockcleaner/VarrockCleanerPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/microbot/zerozero/varrockcleaner/VarrockCleanerPlugin.java index 1249a734e6..df409c667f 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/zerozero/varrockcleaner/VarrockCleanerPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/microbot/zerozero/varrockcleaner/VarrockCleanerPlugin.java @@ -27,6 +27,11 @@ protected void startUp() { script.run(config); } + @Override + protected void shutDown() { + script.stop(); + } + @Provides VarrockCleanerConfig provideConfig(ConfigManager configManager) { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/zerozero/varrockcleaner/VarrockCleanerScript.java b/runelite-client/src/main/java/net/runelite/client/plugins/microbot/zerozero/varrockcleaner/VarrockCleanerScript.java index 0ac080210e..f1b4f0391a 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/zerozero/varrockcleaner/VarrockCleanerScript.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/microbot/zerozero/varrockcleaner/VarrockCleanerScript.java @@ -8,7 +8,6 @@ import net.runelite.client.plugins.microbot.util.gameobject.Rs2GameObject; import net.runelite.client.plugins.microbot.util.keyboard.Rs2Keyboard; import net.runelite.client.plugins.microbot.util.inventory.Rs2Inventory; -import net.runelite.client.plugins.microbot.util.widget.Rs2Widget; import java.util.concurrent.TimeUnit; @@ -77,11 +76,31 @@ private void cleanFinds() { } private void storeFindsInCrate() { + String[] rareItems = { + "Old symbol", + "Ancient symbol", + "Old coin", + "Ancient coin", + "Clean necklace", + "Pottery", + "Jewellery", + "Old chipped vase", + "Arrowheads" + }; + if (!Rs2Inventory.contains("Uncleaned find") && Rs2GameObject.interact(ObjectID.STORAGE_CRATE, "Add finds")) { Rs2Keyboard.keyPress('2'); - boolean widgetVisible = Rs2Widget.sleepUntilHasWidget("Thanks for helping us out") || - Rs2Widget.isWidgetVisible(15138822, 0); - if (widgetVisible) { + sleep(1000); + + boolean hasRareItems = false; + for (String rareItem : rareItems) { + if (Rs2Inventory.contains(rareItem)) { + hasRareItems = true; + break; + } + } + + if (!hasRareItems) { currentState = State.DROP_ITEMS; } } @@ -94,9 +113,9 @@ private void dropUnwantedItems() { } } - @Override - public void shutdown() { + public void stop() { + Microbot.log("Varrack Cleaner plugin stopped."); + currentState = VarrockCleanerScript.State.TAKE_UNCLEANED; super.shutdown(); - currentState = State.TAKE_UNCLEANED; } } From a2482031ea64c004b84d8d978302e17fd66a0f34 Mon Sep 17 00:00:00 2001 From: g-mason0 <19415334+g-mason0@users.noreply.github.com> Date: Thu, 21 Nov 2024 07:50:30 -0500 Subject: [PATCH 02/45] fix: display info for enchanted lyre & add generic play option to handleInventoryTeleports --- .../plugins/microbot/util/walker/Rs2Walker.java | 2 +- .../microbot/shortestpath/teleportation_items.tsv | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/walker/Rs2Walker.java b/runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/walker/Rs2Walker.java index b9bcc903f8..495387476e 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/walker/Rs2Walker.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/walker/Rs2Walker.java @@ -1076,7 +1076,7 @@ public static boolean handleInventoryTeleports(Transport transport, int itemId) List locationKeyWords = Arrays.asList("farm", "monastery", "lletya", "prifddinas", "rellekka", "waterbirth island", "neitiznot", "jatiszo", "ver sinhaza", "darkmeyer", "slepe", "troll stronghold", "weiss", "ecto", "burgh", "duradel", "gem mine", "nardah", "kalphite cave", "kourend woodland", "mount karuulm"); - List genericKeyWords = Arrays.asList("invoke", "empty", "consume", "rub", "break", "teleport", "reminisce", "signal"); + List genericKeyWords = Arrays.asList("invoke", "empty", "consume", "rub", "break", "teleport", "reminisce", "signal", "play"); boolean hasMultipleDestination = transport.getDisplayInfo().contains(":"); String destination = hasMultipleDestination diff --git a/runelite-client/src/main/resources/net/runelite/client/plugins/microbot/shortestpath/teleportation_items.tsv b/runelite-client/src/main/resources/net/runelite/client/plugins/microbot/shortestpath/teleportation_items.tsv index 28da83d918..48862e6aae 100644 --- a/runelite-client/src/main/resources/net/runelite/client/plugins/microbot/shortestpath/teleportation_items.tsv +++ b/runelite-client/src/main/resources/net/runelite/client/plugins/microbot/shortestpath/teleportation_items.tsv @@ -11,7 +11,8 @@ 3683 9888 0 13113;13114;13115 4 Morytania legs: Slime Pit F 20 3482 3230 0 13114;13115 4 Morytania legs: Burgh de Rott F 20 # Fremennik sea boots (1,2,3 have 1 teleport per day, 4 is unlimited) -2643 3675 0 13129;13130;13131;13132 4 Fremennik sea boots F 20 +2643 3675 0 13129;13130;13131 4 Fremennik sea boots F 20 5005=0 +2643 3675 0 13132 4 Fremennik sea boots F 20 # Kandarin headgear (3 has 1 teleport per day, 4 is unlimited) 2729 3409 0 13137;13138;13139;13140 4 Kandarin headgear F 20 # Wilderness Sword (3 has 1 teleport per day, 4 is unlimited) @@ -278,10 +279,10 @@ 2551 3755 0 3691;6125;6126;6127;13079 4 Enchanted lyre: Waterbirth Island T 20 4493=1 2409 3809 0 3691;6125;6126;6127;13079 4 Enchanted lyre: Jatizso T 20 4494=1 2336 3802 0 3691;6125;6126;6127;13079 4 Enchanted lyre: Neitiznot T 20 4494=1 -2662 3644 0 23458 4 Enchanted lyre (i): Rellekka F 20 -2551 3755 0 23458 4 Enchanted lyre (i): Waterbirth Island F 20 4493=1 -2409 3809 0 23458 4 Enchanted lyre (i): Jatizso F 20 4494=1 -2336 3802 0 23458 4 Enchanted lyre (i): Neitiznot F 20 4494=1 +2662 3644 0 23458 4 Enchanted lyre(i): Rellekka F 20 +2551 3755 0 23458 4 Enchanted lyre(i): Waterbirth Island F 20 4493=1 +2409 3809 0 23458 4 Enchanted lyre(i): Jatizso F 20 4494=1 +2336 3802 0 23458 4 Enchanted lyre(i): Neitiznot F 20 4494=1 3105 9315 0 6707 4 Camulet: Enakhra's Temple F 20 3191 2924 0 6707 4 Camulet: Bandit Camp Quarry F 20 1713 3612 0 21760;25818 The Depths of Despair 4 Kharedst's memoirs: Lunch by the Lancalliums T 20 6035>1 From ae1deedca9ce2e9216b6ebf387adf0878149fe4f Mon Sep 17 00:00:00 2001 From: lhndl93 <61633800+lhndl93@users.noreply.github.com> Date: Thu, 21 Nov 2024 15:38:30 +0000 Subject: [PATCH 03/45] Added Piscatoris Hunting Area fence --- .../client/plugins/microbot/shortestpath/transports.tsv | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/runelite-client/src/main/resources/net/runelite/client/plugins/microbot/shortestpath/transports.tsv b/runelite-client/src/main/resources/net/runelite/client/plugins/microbot/shortestpath/transports.tsv index 8caaa45db6..2cd1994956 100644 --- a/runelite-client/src/main/resources/net/runelite/client/plugins/microbot/shortestpath/transports.tsv +++ b/runelite-client/src/main/resources/net/runelite/client/plugins/microbot/shortestpath/transports.tsv @@ -4505,4 +4505,7 @@ 1799 9506 0 1795 3107 0 Exit;Stairs;50750 8 # Hunter Guild 1558 3047 0 1558 9451 0 Climb-down;Stairs;51641 8 -1558 9451 0 1558 3047 0 Climb-up;Stairs;51642 8 \ No newline at end of file +1558 9451 0 1558 3047 0 Climb-up;Stairs;51642 8 +# Piscatoris Hunting Area +2371 3622 0 2371 3620 0 Climb-over;Stile;19222 8 +2371 3620 0 2371 3622 0 Climb-over;Stile;19222 8 \ No newline at end of file From 19c3ccab8d25eb8e04648be338c63d72785790e8 Mon Sep 17 00:00:00 2001 From: chsami Date: Thu, 21 Nov 2024 20:33:23 +0100 Subject: [PATCH 04/45] removed clue hunter script --- .../misc/cluehunter/ClueConfig.java | 11 -- .../misc/cluehunter/ClueOverlay.java | 42 ------- .../misc/cluehunter/CluePlugin.java | 67 ---------- .../misc/cluehunter/ClueScript.java | 116 ------------------ .../nateplugins/misc/cluehunter/State.java | 5 - 5 files changed, 241 deletions(-) delete mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/microbot/nateplugins/misc/cluehunter/ClueConfig.java delete mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/microbot/nateplugins/misc/cluehunter/ClueOverlay.java delete mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/microbot/nateplugins/misc/cluehunter/CluePlugin.java delete mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/microbot/nateplugins/misc/cluehunter/ClueScript.java delete mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/microbot/nateplugins/misc/cluehunter/State.java diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/nateplugins/misc/cluehunter/ClueConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/microbot/nateplugins/misc/cluehunter/ClueConfig.java deleted file mode 100644 index 242e68a962..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/nateplugins/misc/cluehunter/ClueConfig.java +++ /dev/null @@ -1,11 +0,0 @@ -package net.runelite.client.plugins.microbot.nateplugins.misc.cluehunter; - -import net.runelite.client.config.Config; -import net.runelite.client.config.ConfigGroup; - - - -@ConfigGroup("General") -public interface ClueConfig extends Config { - -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/nateplugins/misc/cluehunter/ClueOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/microbot/nateplugins/misc/cluehunter/ClueOverlay.java deleted file mode 100644 index 159cf1d990..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/nateplugins/misc/cluehunter/ClueOverlay.java +++ /dev/null @@ -1,42 +0,0 @@ -package net.runelite.client.plugins.microbot.nateplugins.misc.cluehunter; - -import net.runelite.client.plugins.microbot.Microbot; -import net.runelite.client.ui.overlay.OverlayPanel; -import net.runelite.client.ui.overlay.OverlayPosition; -import net.runelite.client.ui.overlay.components.LineComponent; -import net.runelite.client.ui.overlay.components.TitleComponent; - -import javax.inject.Inject; -import java.awt.*; - - - -public class ClueOverlay extends OverlayPanel { - - @Inject - ClueOverlay(CluePlugin plugin) - { - super(plugin); - setPosition(OverlayPosition.TOP_LEFT); - setNaughty(); - } - @Override - public Dimension render(Graphics2D graphics) { - try { - - panelComponent.setPreferredSize(new Dimension(275, 500)); - panelComponent.getChildren().add(TitleComponent.builder() - .text("Nate's Clue Hunter Grabber") - .color(Color.magenta) - .build()); - - panelComponent.getChildren().add(LineComponent.builder() - .left(Microbot.status) - .build()); - - } catch(Exception ex) { - System.out.println(ex.getMessage()); - } - return super.render(graphics); - } -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/nateplugins/misc/cluehunter/CluePlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/microbot/nateplugins/misc/cluehunter/CluePlugin.java deleted file mode 100644 index 2057b6a15c..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/nateplugins/misc/cluehunter/CluePlugin.java +++ /dev/null @@ -1,67 +0,0 @@ -package net.runelite.client.plugins.microbot.nateplugins.misc.cluehunter; - -import com.google.inject.Provides; -import lombok.extern.slf4j.Slf4j; -import net.runelite.api.Client; -import net.runelite.client.Notifier; -import net.runelite.client.callback.ClientThread; -import net.runelite.client.config.ConfigManager; -import net.runelite.client.plugins.Plugin; -import net.runelite.client.plugins.PluginDescriptor; -import net.runelite.client.plugins.microbot.Microbot; -import net.runelite.client.plugins.microbot.util.mouse.VirtualMouse; -import net.runelite.client.ui.overlay.OverlayManager; - -import javax.inject.Inject; -import java.awt.*; - - -@PluginDescriptor( - name = PluginDescriptor.Nate +"Cluehunter", - description = "Nate's Cluehunter - Make sure you have all the required items- Spade,Nature Runes, Leather Boots, SuperAntiPoison (1)", - tags = {"magic", "nate", "Cluehunter","misc"}, - enabledByDefault = false -) -@Slf4j -public class CluePlugin extends Plugin { - @Inject - private Client client; - @Inject - private ClueConfig config; - @Inject - private ClientThread clientThread; - @Inject - Notifier notifier; - - @Inject - private OverlayManager overlayManager; - @Inject - private ClueOverlay clueOverlay; - - @Inject - ClueScript clueScript; - - @Provides - ClueConfig provideConfig(ConfigManager configManager) { - return configManager.getConfig(ClueConfig.class); - } - - - @Override - protected void startUp() throws AWTException { - Microbot.pauseAllScripts = false; - Microbot.setClient(client); - Microbot.setClientThread(clientThread); - Microbot.setNotifier(notifier); - Microbot.setMouse(new VirtualMouse()); - if (overlayManager != null) { - overlayManager.add(clueOverlay); - } - clueScript.run(config); - } - - protected void shutDown() { - clueScript.shutdown(); - overlayManager.remove(clueOverlay); - } -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/nateplugins/misc/cluehunter/ClueScript.java b/runelite-client/src/main/java/net/runelite/client/plugins/microbot/nateplugins/misc/cluehunter/ClueScript.java deleted file mode 100644 index 842e20e30f..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/nateplugins/misc/cluehunter/ClueScript.java +++ /dev/null @@ -1,116 +0,0 @@ -package net.runelite.client.plugins.microbot.nateplugins.misc.cluehunter; - -import net.runelite.api.coords.WorldArea; -import net.runelite.api.coords.WorldPoint; -import net.runelite.client.plugins.microbot.Microbot; -import net.runelite.client.plugins.microbot.Script; -import net.runelite.client.plugins.microbot.util.gameobject.Rs2GameObject; -import net.runelite.client.plugins.microbot.util.inventory.Rs2Inventory; -import net.runelite.client.plugins.microbot.util.npc.Rs2Npc; -import net.runelite.client.plugins.microbot.util.walker.Rs2Walker; - -import java.util.concurrent.TimeUnit; - -public class ClueScript extends Script { - - public static double version = 1.1; - - WorldPoint ClueAreaGloves = new WorldPoint(2579, 3378, 0); - WorldPoint ClueAreaCloak = new WorldPoint(2614, 3064, 0); - WorldPoint ClueAreaHelm = new WorldPoint(2590, 3231, 0); - WorldPoint ClueAreaGarb = new WorldPoint(1595, 3628, 0); - WorldPoint PortSarim = new WorldPoint(3055, 3245, 0); - WorldPoint KourendBoat = new WorldPoint(1824, 3695, 1); - WorldArea Kourend = new WorldArea(1385, 3398, 465, 417, 0); - - private State getState() { - if (!Rs2Inventory.contains("Spade") && !Rs2Inventory.contains("Nature rune") && !Rs2Inventory.contains("leather boots") && !Rs2Inventory.contains("Superantipoison (1)")) - return State.ERROR; - if (!Rs2Inventory.contains("Clue hunter gloves") && !Rs2Inventory.contains("Clue hunter boots")) - return State.CLUE1; - if (!Rs2Inventory.contains("Clue hunter cloak")) - return State.CLUE2; - if (!Rs2Inventory.contains("Helm of raedwald")) - return State.CLUE3; - if (!Rs2Inventory.contains("Clue hunter garb") && !Kourend.contains(Microbot.getClient().getLocalPlayer().getWorldLocation())) - return State.CLUE4; - if (!Rs2Inventory.contains("Clue hunter garb") && Kourend.contains(Microbot.getClient().getLocalPlayer().getWorldLocation())) - return State.CLUE5; - return State.DONE; - } - - public boolean run(ClueConfig config) { - mainScheduledFuture = scheduledExecutorService.scheduleWithFixedDelay(() -> { - if (!super.run()) return; - try { - if (Microbot.pauseAllScripts) return; - - switch (getState()) { - case ERROR: - System.out.println("Error - Make sure you have all the required items- Spade,Nature Runes, Leather Boots, SuperAntiPoison (1)"); - break; - case CLUE1: - Microbot.status = "collecting Gloves and boots"; - if (Microbot.getClient().getLocalPlayer().getWorldLocation().equals(ClueAreaGloves)) { - Rs2Inventory.interact("Spade", "Dig"); - sleep(1000, 2000); - } else { - Rs2Walker.walkTo(ClueAreaGloves); - } - break; - case CLUE2: - Microbot.status = "collecting cloak"; - if (Microbot.getClient().getLocalPlayer().getWorldLocation().equals(ClueAreaCloak)) { - Rs2Inventory.interact("Spade", "Dig"); - sleep(1000, 2000); - } else { - Rs2Walker.walkTo(ClueAreaCloak); - } - break; - case CLUE3: - Microbot.status = "collecting Helm"; - if (Microbot.getClient().getLocalPlayer().getWorldLocation().equals(ClueAreaHelm)) { - Rs2Inventory.interact("Spade", "Dig"); - sleep(1000, 2000); - } else { - Rs2Walker.walkTo(ClueAreaHelm); - } - break; - case CLUE4: - if (Microbot.getClient().getLocalPlayer().getWorldLocation().equals(KourendBoat)) { - Microbot.status = "Crossing to Kourend"; - Rs2GameObject.interact(27778, "Cross"); - sleep(2500, 3500); - } else { - Microbot.status = "Walking to Port Sarim"; - if (Microbot.getClient().getLocalPlayer().getWorldLocation().equals(PortSarim)) { - Rs2Npc.interact("Veos", "Port Piscarilius"); - sleep(4000, 5000); - } else { - Rs2Walker.walkTo(PortSarim); - } - } - break; - case CLUE5: - Microbot.status = "collecting garb"; - if (Microbot.getClient().getLocalPlayer().getWorldLocation().equals(ClueAreaGarb)) { - Rs2Inventory.interact("Spade", "Dig"); - sleep(1000, 2000); - } else { - Rs2Walker.walkTo(ClueAreaGarb); - } - break; - case DONE: - Microbot.status = "Got the pieces all done"; - System.out.println("Got 5 pieces of warm gear"); - shutdown(); - break; - } - } catch (Exception ex) { - System.out.println(ex.getMessage()); - } - }, 0, 1000, TimeUnit.MILLISECONDS); - return true; - } - -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/nateplugins/misc/cluehunter/State.java b/runelite-client/src/main/java/net/runelite/client/plugins/microbot/nateplugins/misc/cluehunter/State.java deleted file mode 100644 index 6c532555ba..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/nateplugins/misc/cluehunter/State.java +++ /dev/null @@ -1,5 +0,0 @@ -package net.runelite.client.plugins.microbot.nateplugins.misc.cluehunter; - -public enum State { - ERROR, CLUE1, CLUE2, CLUE3, CLUE4, CLUE5, DONE -} From 2c99a140e455275975961c8ed8707dfc019d98c3 Mon Sep 17 00:00:00 2001 From: chsami Date: Thu, 21 Nov 2024 20:33:56 +0100 Subject: [PATCH 05/45] removed leviathan autoprayer --- .../bosses/leviathan/LeviathanConfig.java | 8 -- .../bosses/leviathan/LeviathanOverlay.java | 40 -------- .../bosses/leviathan/LeviathanPlugin.java | 96 ------------------- .../bosses/leviathan/LeviathanScript.java | 20 ---- 4 files changed, 164 deletions(-) delete mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/microbot/deserttreasure2/bosses/leviathan/LeviathanConfig.java delete mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/microbot/deserttreasure2/bosses/leviathan/LeviathanOverlay.java delete mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/microbot/deserttreasure2/bosses/leviathan/LeviathanPlugin.java delete mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/microbot/deserttreasure2/bosses/leviathan/LeviathanScript.java diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/deserttreasure2/bosses/leviathan/LeviathanConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/microbot/deserttreasure2/bosses/leviathan/LeviathanConfig.java deleted file mode 100644 index 71dfe814a2..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/deserttreasure2/bosses/leviathan/LeviathanConfig.java +++ /dev/null @@ -1,8 +0,0 @@ -package net.runelite.client.plugins.microbot.deserttreasure2.bosses.leviathan; - -import net.runelite.client.config.Config; -import net.runelite.client.config.ConfigGroup; - -@ConfigGroup("leviathanConfig") -public interface LeviathanConfig extends Config { -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/deserttreasure2/bosses/leviathan/LeviathanOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/microbot/deserttreasure2/bosses/leviathan/LeviathanOverlay.java deleted file mode 100644 index 4752dd90aa..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/deserttreasure2/bosses/leviathan/LeviathanOverlay.java +++ /dev/null @@ -1,40 +0,0 @@ -package net.runelite.client.plugins.microbot.deserttreasure2.bosses.leviathan; - -import net.runelite.client.plugins.microbot.Microbot; -import net.runelite.client.ui.overlay.OverlayPanel; -import net.runelite.client.ui.overlay.OverlayPosition; -import net.runelite.client.ui.overlay.components.LineComponent; -import net.runelite.client.ui.overlay.components.TitleComponent; - -import javax.inject.Inject; -import java.awt.*; - -public class LeviathanOverlay extends OverlayPanel { - @Inject - LeviathanOverlay(LeviathanPlugin plugin) - { - super(plugin); - setPosition(OverlayPosition.TOP_LEFT); - setNaughty(); - } - @Override - public Dimension render(Graphics2D graphics) { - try { - panelComponent.setPreferredSize(new Dimension(200, 300)); - panelComponent.getChildren().add(TitleComponent.builder() - .text("Micro Example V1.0.0") - .color(Color.GREEN) - .build()); - - panelComponent.getChildren().add(LineComponent.builder().build()); - - panelComponent.getChildren().add(LineComponent.builder() - .left(Microbot.status) - .build()); - - } catch(Exception ex) { - System.out.println(ex.getMessage()); - } - return super.render(graphics); - } -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/deserttreasure2/bosses/leviathan/LeviathanPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/microbot/deserttreasure2/bosses/leviathan/LeviathanPlugin.java deleted file mode 100644 index f7a47cc342..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/deserttreasure2/bosses/leviathan/LeviathanPlugin.java +++ /dev/null @@ -1,96 +0,0 @@ -package net.runelite.client.plugins.microbot.deserttreasure2.bosses.leviathan; - -import com.google.inject.Provides; -import lombok.extern.slf4j.Slf4j; -import net.runelite.api.NpcID; -import net.runelite.api.Projectile; -import net.runelite.api.events.GraphicsObjectCreated; -import net.runelite.api.events.NpcSpawned; -import net.runelite.api.events.ProjectileMoved; -import net.runelite.client.config.ConfigManager; -import net.runelite.client.eventbus.Subscribe; -import net.runelite.client.plugins.Plugin; -import net.runelite.client.plugins.PluginDescriptor; -import net.runelite.client.plugins.microbot.util.prayer.Rs2Prayer; -import net.runelite.client.plugins.microbot.util.prayer.Rs2PrayerEnum; -import net.runelite.client.ui.overlay.OverlayManager; - -import javax.inject.Inject; -import java.awt.*; - -@PluginDescriptor( - name = PluginDescriptor.Mocrosoft + "Leviathan", - description = "Microbot Leviathan plugin", - tags = {"Leviathan", "microbot", "boss"}, - enabledByDefault = false, - hidden = true -) -@Slf4j -public class LeviathanPlugin extends Plugin { - - int meleeProjectile = 2488; - int mageProjectile = 2489; - int rangeProjectile = 2487; - - @Inject - private LeviathanConfig config; - @Provides - LeviathanConfig provideConfig(ConfigManager configManager) { - return configManager.getConfig(LeviathanConfig.class); - } - - @Inject - private OverlayManager overlayManager; - @Inject - private LeviathanOverlay exampleOverlay; - - @Inject - LeviathanScript LeviathanScript; - - - @Override - protected void startUp() throws AWTException { - if (overlayManager != null) { - overlayManager.add(exampleOverlay); - } - LeviathanScript.run(config); - } - - protected void shutDown() { - LeviathanScript.shutdown(); - overlayManager.remove(exampleOverlay); - } - - @Subscribe - public void onGraphicsObjectCreated(GraphicsObjectCreated event) - { - System.out.println("Graphics object created"); - System.out.println(event.getGraphicsObject().getId()); - } - @Subscribe - public void onProjectileMoved(ProjectileMoved event) - { - final Projectile projectile = event.getProjectile(); - - if (event.getProjectile().getRemainingCycles() < 10) { - if (projectile.getId() == meleeProjectile) - { - Rs2Prayer.toggle(Rs2PrayerEnum.PROTECT_MELEE, true); - } else if (projectile.getId() == mageProjectile) { - Rs2Prayer.toggle(Rs2PrayerEnum.PROTECT_MAGIC, true); - } else if (projectile.getId() == rangeProjectile) { - Rs2Prayer.toggle(Rs2PrayerEnum.PROTECT_RANGE, true); - } - } - } - - @Subscribe - public void onNpcSpawned(NpcSpawned event) - { - System.out.println("npc spawned created"); - System.out.println(event.getNpc().getId()); - if (event.getNpc().getId() == NpcID.ABYSSAL_PATHFINDER) { - System.out.println("pathfinder found!"); - } - } -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/deserttreasure2/bosses/leviathan/LeviathanScript.java b/runelite-client/src/main/java/net/runelite/client/plugins/microbot/deserttreasure2/bosses/leviathan/LeviathanScript.java deleted file mode 100644 index 6a2fa033e9..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/deserttreasure2/bosses/leviathan/LeviathanScript.java +++ /dev/null @@ -1,20 +0,0 @@ -package net.runelite.client.plugins.microbot.deserttreasure2.bosses.leviathan; - -import net.runelite.client.plugins.microbot.Script; - -import java.util.concurrent.TimeUnit; - -public class LeviathanScript extends Script { - public boolean run(LeviathanConfig config) { - mainScheduledFuture = scheduledExecutorService.scheduleWithFixedDelay(() -> { - if (!super.run()) return; - - try { - //write your code here - } catch (Exception ex) { - System.out.println(ex.getMessage()); - } - }, 0, 1000, TimeUnit.MILLISECONDS); - return true; - } -} From d14b671712375abeae9fa58a25fbab6ac51346d9 Mon Sep 17 00:00:00 2001 From: chsami Date: Thu, 21 Nov 2024 20:34:29 +0100 Subject: [PATCH 06/45] removed autobanker --- .../microbot/autobanker/AutoBankerConfig.java | 18 ------- .../autobanker/AutoBankerOverlay.java | 41 ---------------- .../microbot/autobanker/AutoBankerPlugin.java | 49 ------------------- .../microbot/autobanker/AutoBankerScript.java | 43 ---------------- 4 files changed, 151 deletions(-) delete mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/microbot/autobanker/AutoBankerConfig.java delete mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/microbot/autobanker/AutoBankerOverlay.java delete mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/microbot/autobanker/AutoBankerPlugin.java delete mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/microbot/autobanker/AutoBankerScript.java diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/autobanker/AutoBankerConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/microbot/autobanker/AutoBankerConfig.java deleted file mode 100644 index c66de83f93..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/autobanker/AutoBankerConfig.java +++ /dev/null @@ -1,18 +0,0 @@ -package net.runelite.client.plugins.microbot.autobanker; - -import net.runelite.client.config.Config; -import net.runelite.client.config.ConfigGroup; -import net.runelite.client.config.ConfigItem; - -@ConfigGroup("autobanker") -public interface AutoBankerConfig extends Config { - @ConfigItem( - position = 1, - keyName = "ItemsToBank", - name = "Items to bank", - description = "Items to bank" - ) - default String itemsToBank() { - return "item1,item2,item3"; - } -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/autobanker/AutoBankerOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/microbot/autobanker/AutoBankerOverlay.java deleted file mode 100644 index cf120cf945..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/autobanker/AutoBankerOverlay.java +++ /dev/null @@ -1,41 +0,0 @@ -package net.runelite.client.plugins.microbot.autobanker; - -import net.runelite.client.plugins.microbot.Microbot; -import net.runelite.client.ui.overlay.OverlayPanel; -import net.runelite.client.ui.overlay.OverlayPosition; -import net.runelite.client.ui.overlay.components.LineComponent; -import net.runelite.client.ui.overlay.components.TitleComponent; - -import javax.inject.Inject; -import java.awt.*; - -public class AutoBankerOverlay extends OverlayPanel { - @Inject - AutoBankerOverlay(AutoBankerPlugin plugin) - { - super(plugin); - setPosition(OverlayPosition.TOP_LEFT); - setNaughty(); - } - @Override - public Dimension render(Graphics2D graphics) { - try { - panelComponent.setPreferredSize(new Dimension(200, 300)); - panelComponent.getChildren().add(TitleComponent.builder() - .text("Micro Example V" + AutoBankerScript.version) - .color(Color.GREEN) - .build()); - - panelComponent.getChildren().add(LineComponent.builder().build()); - - panelComponent.getChildren().add(LineComponent.builder() - .left(Microbot.status) - .build()); - - - } catch(Exception ex) { - System.out.println(ex.getMessage()); - } - return super.render(graphics); - } -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/autobanker/AutoBankerPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/microbot/autobanker/AutoBankerPlugin.java deleted file mode 100644 index 69d113fa4f..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/autobanker/AutoBankerPlugin.java +++ /dev/null @@ -1,49 +0,0 @@ -package net.runelite.client.plugins.microbot.autobanker; - -import com.google.inject.Provides; -import lombok.extern.slf4j.Slf4j; -import net.runelite.client.config.ConfigManager; -import net.runelite.client.plugins.Plugin; -import net.runelite.client.plugins.PluginDescriptor; -import net.runelite.client.ui.overlay.OverlayManager; - -import javax.inject.Inject; -import java.awt.*; - -@PluginDescriptor( - name = PluginDescriptor.Mocrosoft + "AutoBanker", - description = "Automatically banks items and walks back to the original location", - tags = {"banking", "microbot"}, - enabledByDefault = false -) -@Slf4j -public class AutoBankerPlugin extends Plugin { - @Inject - private AutoBankerConfig config; - @Provides - AutoBankerConfig provideConfig(ConfigManager configManager) { - return configManager.getConfig(AutoBankerConfig.class); - } - - @Inject - private OverlayManager overlayManager; - @Inject - private AutoBankerOverlay autoBankerOverlay; - - @Inject - AutoBankerScript autoBankerScript; - - - @Override - protected void startUp() throws AWTException { - if (overlayManager != null) { - overlayManager.add(autoBankerOverlay); - } - autoBankerScript.run(config); - } - - protected void shutDown() { - autoBankerScript.shutdown(); - overlayManager.remove(autoBankerOverlay); - } -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/autobanker/AutoBankerScript.java b/runelite-client/src/main/java/net/runelite/client/plugins/microbot/autobanker/AutoBankerScript.java deleted file mode 100644 index f77cd18cf2..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/autobanker/AutoBankerScript.java +++ /dev/null @@ -1,43 +0,0 @@ -package net.runelite.client.plugins.microbot.autobanker; - -import net.runelite.client.plugins.microbot.Microbot; -import net.runelite.client.plugins.microbot.Script; -import net.runelite.client.plugins.microbot.util.bank.Rs2Bank; - -import java.util.Arrays; -import java.util.List; -import java.util.concurrent.TimeUnit; -import java.util.stream.Collectors; - - -public class AutoBankerScript extends Script { - public static String version = "1.0.0"; - - public boolean run(AutoBankerConfig config) { - Microbot.enableAutoRunOn = false; - mainScheduledFuture = scheduledExecutorService.scheduleWithFixedDelay(() -> { - try { - if (!Microbot.isLoggedIn()) return; - if (!super.run()) return; - - long startTime = System.currentTimeMillis(); - List itemNames = Arrays.stream(config.itemsToBank().split(",")).map(String::toLowerCase).collect(Collectors.toList()); - - Rs2Bank.bankItemsAndWalkBackToOriginalPosition(itemNames, initialPlayerLocation); - - long endTime = System.currentTimeMillis(); - long totalTime = endTime - startTime; - System.out.println("Total time for loop " + totalTime); - - } catch (Exception ex) { - System.out.println(ex.getMessage()); - } - }, 0, 1000, TimeUnit.MILLISECONDS); - return true; - } - - @Override - public void shutdown() { - super.shutdown(); - } -} From 9278ca9ed4aa7b398670bcb1604cecdfe0bc1ff9 Mon Sep 17 00:00:00 2001 From: chsami Date: Thu, 21 Nov 2024 20:36:41 +0100 Subject: [PATCH 07/45] removed farming runner --- .../microbot/farming/FarmingConfig.java | 54 ---- .../microbot/farming/FarmingOverlay.java | 68 ----- .../microbot/farming/FarmingPlugin.java | 75 ----- .../microbot/farming/FarmingScript.java | 264 ------------------ .../farming/enums/FarmingMaterial.java | 34 --- .../microbot/farming/enums/FarmingState.java | 11 - 6 files changed, 506 deletions(-) delete mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/microbot/farming/FarmingConfig.java delete mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/microbot/farming/FarmingOverlay.java delete mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/microbot/farming/FarmingPlugin.java delete mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/microbot/farming/FarmingScript.java delete mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/microbot/farming/enums/FarmingMaterial.java delete mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/microbot/farming/enums/FarmingState.java diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/farming/FarmingConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/microbot/farming/FarmingConfig.java deleted file mode 100644 index 4a30e9f247..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/farming/FarmingConfig.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2023, Mocrosoft - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.client.plugins.microbot.farming; - -import net.runelite.client.config.Config; -import net.runelite.client.config.ConfigGroup; -import net.runelite.client.config.ConfigItem; -import net.runelite.client.config.ConfigSection; -import net.runelite.client.plugins.microbot.farming.enums.FarmingMaterial; - -@ConfigGroup("farming") -public interface FarmingConfig extends Config { - @ConfigSection( - name = "General", - description = "General", - position = 0, - closedByDefault = false - ) - String generalSection = "general"; - - @ConfigItem( - keyName = "Tree", - name = "Tree", - description = "Choose your tree", - position = 0, - section = generalSection - ) - default FarmingMaterial farmingMaterial() - { - return FarmingMaterial.OAK_TREE; - } -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/farming/FarmingOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/microbot/farming/FarmingOverlay.java deleted file mode 100644 index 1b0182b0d6..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/farming/FarmingOverlay.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2023, Mocrosoft - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.client.plugins.microbot.farming; - -import net.runelite.client.plugins.microbot.Microbot; -import net.runelite.client.ui.overlay.OverlayPanel; -import net.runelite.client.ui.overlay.OverlayPosition; -import net.runelite.client.ui.overlay.components.LineComponent; -import net.runelite.client.ui.overlay.components.TitleComponent; - -import javax.inject.Inject; -import java.awt.*; - -public class FarmingOverlay extends OverlayPanel { - @Inject - FarmingOverlay(FarmingPlugin plugin) { - super(plugin); - setPosition(OverlayPosition.TOP_LEFT); - } - - @Override - public Dimension render(Graphics2D graphics) { - try { - panelComponent.setPreferredSize(new Dimension(200, 300)); - panelComponent.getChildren().add(TitleComponent.builder() - .text("Micro Farming V" + FarmingScript.version) - .color(Color.GREEN) - .build()); - - panelComponent.getChildren().add(LineComponent.builder().build()); - - panelComponent.getChildren().add(LineComponent.builder() - .left("Farming state") - .right(FarmingScript.state.toString()) - .build()); - - panelComponent.getChildren().add(LineComponent.builder() - .left(Microbot.status) - .build()); - - } catch (Exception ex) { - System.out.println(ex.getMessage()); - } - return super.render(graphics); - } -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/farming/FarmingPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/microbot/farming/FarmingPlugin.java deleted file mode 100644 index c13628ff01..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/farming/FarmingPlugin.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2023, Mocrosoft - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.client.plugins.microbot.farming; - -import com.google.inject.Provides; -import lombok.extern.slf4j.Slf4j; -import net.runelite.client.config.ConfigManager; -import net.runelite.client.plugins.Plugin; -import net.runelite.client.plugins.PluginDescriptor; -import net.runelite.client.ui.overlay.OverlayManager; - -import javax.inject.Inject; -import java.awt.*; - -@PluginDescriptor( - name = PluginDescriptor.Mocrosoft + "Tree runner", - description = "Microbot farming plugin", - tags = {"farming", "microbot"}, - enabledByDefault = false, - hidden = true -) -@Slf4j -public class FarmingPlugin extends Plugin { - @Inject - private FarmingConfig config; - - @Provides - FarmingConfig provideConfig(ConfigManager configManager) { - return configManager.getConfig(FarmingConfig.class); - } - - @Inject - private OverlayManager overlayManager; - @Inject - private FarmingOverlay exampleOverlay; - - @Inject - FarmingScript farmingScript; - - - @Override - protected void startUp() throws AWTException { - if (overlayManager != null) { - overlayManager.add(exampleOverlay); - } - farmingScript.run(config); - } - - protected void shutDown() { - farmingScript.shutdown(); - overlayManager.remove(exampleOverlay); - } -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/farming/FarmingScript.java b/runelite-client/src/main/java/net/runelite/client/plugins/microbot/farming/FarmingScript.java deleted file mode 100644 index 103120363c..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/farming/FarmingScript.java +++ /dev/null @@ -1,264 +0,0 @@ -/* - * Copyright (c) 2023, Mocrosoft - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package net.runelite.client.plugins.microbot.farming; - -import net.runelite.api.*; -import net.runelite.api.coords.WorldArea; -import net.runelite.api.coords.WorldPoint; -import net.runelite.client.plugins.microbot.Microbot; -import net.runelite.client.plugins.microbot.Script; -import net.runelite.client.plugins.microbot.farming.enums.FarmingState; -import net.runelite.client.plugins.microbot.util.bank.enums.BankLocation; -import net.runelite.client.plugins.microbot.util.gameobject.Rs2GameObject; -import net.runelite.client.plugins.microbot.util.inventory.Rs2Inventory; -import net.runelite.client.plugins.microbot.util.keyboard.Rs2Keyboard; -import net.runelite.client.plugins.microbot.util.npc.Rs2Npc; -import net.runelite.client.plugins.microbot.util.player.Rs2Player; -import net.runelite.client.plugins.microbot.util.walker.Rs2Walker; -import net.runelite.client.plugins.microbot.util.widget.Rs2Widget; -import net.runelite.client.plugins.microbot.questhelper.requirements.item.ItemRequirement; - -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.TimeUnit; -import java.util.function.BooleanSupplier; - -public class FarmingScript extends Script { - - public static double version = 1.0; - - public List itemsRequired = new ArrayList(); - - public static FarmingState state = FarmingState.RESET; - - WorldPoint TREE_RUN_GNOME_STRONDHOLD = new WorldPoint(2437, 3418, 0); - WorldPoint SPIRIT_TREE_GRAND_EXCHANGE = new WorldPoint(3185, 3507, 0); - WorldPoint SPIRIT_TREE_GNOME_STRONGHOLD = new WorldPoint(2461, 3443, 0); - - WorldPoint TREE_RUN_VARROCK = new WorldPoint(3226, 3458, 0); - - WorldPoint TREE_RUN_LUMBRIDGE = new WorldPoint(3193, 3228, 0); - WorldPoint TREE_RUN_FALADOR = new WorldPoint(3003, 3376, 0); - - WorldArea grandExchange = new WorldArea(3142, 3470, 50, 50, 0); - BooleanSupplier isInGrandExchange = () -> grandExchange.contains(Microbot.getClient().getLocalPlayer().getWorldLocation()); - - int sleepBetweenTeleports = 4000; - - public boolean run(FarmingConfig config) { - mainScheduledFuture = scheduledExecutorService.scheduleWithFixedDelay(() -> { - try { - if (!Microbot.isLoggedIn()) return; - if (!super.run()) return; - - if (state == FarmingState.RESET) { - if (!isInGrandExchange.getAsBoolean()) { - Microbot.getNotifier().notify("Start the script in the grand exchange."); - shutdown(); - } - /*itemsRequired = new ArrayList<>(Arrays.asList(new ItemRequirement("falador teleport", ItemID.FALADOR_TELEPORT, 1), - new ItemRequirement("lumbridge teleport", ItemID.LUMBRIDGE_TELEPORT, 1), - new ItemRequirement("spade", ItemID.SPADE, 1), - new ItemRequirement("rake", ItemID.RAKE, 1), - new ItemRequirement("stamina potion(4)", ItemID.STAMINA_POTION4, 1), - new ItemRequirement("varrock teleport", ItemID.VARROCK_TELEPORT, 2), - new ItemRequirement("oak sapling", ItemID.OAK_SAPLING, 4), - new ItemRequirement("tomatoes(5)", ItemID.TOMATOES5, 4), - new ItemRequirement("coins", ItemID.COINS_995, 10000))); - if (!hasItems(itemsRequired)) { - openBank(); - depositAll(); - state = FarmingState.BANKING; - } else { - state = FarmingState.FARMING_GNOME_STRONHOLD; - }*/ - } else if (state == FarmingState.BANKING) { - - /* boolean hasItems = Rs2Bank.withdrawItemsRequired(itemsRequired); - - if (!hasItems) - return;*/ - - state = FarmingState.FARMING_GNOME_STRONHOLD; - - } else if (state == FarmingState.FARMING_GNOME_STRONHOLD) { - if (isInGrandExchange.getAsBoolean()) { - boolean isNearSpiritTreeGrandExchange = Rs2Walker.walkTo(SPIRIT_TREE_GRAND_EXCHANGE); - - if (!isNearSpiritTreeGrandExchange) - return; - - //extract this to a general spirit tree teleport option - - Rs2GameObject.interact(1295, "travel"); - - sleepUntil(() -> Rs2Widget.hasWidget("spirit tree locations")); - - Rs2Keyboard.typeString("2"); - - sleepUntil(() -> !isInGrandExchange.getAsBoolean()); - - //extract this to a general spirit tree teleport option - - - } else { - boolean isNearTreePatchGnomeStronghold = Rs2Walker.walkTo(TREE_RUN_GNOME_STRONDHOLD); - if (!isNearTreePatchGnomeStronghold) - return; - - if (plantTree(config, 19147, NpcID.PRISSY_SCILLA, 3, FarmingState.FARMING_VARROCK)) { - } - } - } else if (state == FarmingState.FARMING_VARROCK) { - if (Rs2Inventory.hasItemAmount("varrock teleport", 2, true)) { - Rs2Inventory.interact(ItemID.VARROCK_TELEPORT, "break"); - sleep(sleepBetweenTeleports); - return; - } - boolean isNearVarrockPatch = Rs2Walker.walkTo(TREE_RUN_VARROCK); - - if (!isNearVarrockPatch) - return; - - if (plantTree(config, 8390, NpcID.TREZNOR_11957, 2, FarmingState.FARMING_FALADOR)) { - } - } else if (state == FarmingState.FARMING_FALADOR) { - if (Rs2Inventory.hasItem(ItemID.FALADOR_TELEPORT)) { - Rs2Inventory.interact(ItemID.FALADOR_TELEPORT, "break"); - sleep(sleepBetweenTeleports); - return; - } - boolean isNearFaladorPatch = Rs2Walker.walkTo(TREE_RUN_FALADOR); - - if (!isNearFaladorPatch) - return; - - if (plantTree(config, 8389, NpcID.HESKEL, 1, FarmingState.FARMING_LUMBRIDGE)) { - } - - } else if (state == FarmingState.FARMING_LUMBRIDGE) { - if (Rs2Inventory.hasItem(ItemID.LUMBRIDGE_TELEPORT)) { - Rs2Inventory.interact(ItemID.LUMBRIDGE_TELEPORT, "break"); - sleep(sleepBetweenTeleports); - return; - } - - boolean isNearLumbridgePatch = Rs2Walker.walkTo(TREE_RUN_LUMBRIDGE); - - if (!isNearLumbridgePatch) - return; - - if (plantTree(config, 8391, NpcID.FAYETH, 0, FarmingState.FINISHED)) { - } - } else if (state == FarmingState.FINISHED) { - if (Rs2Inventory.hasItem(ItemID.VARROCK_TELEPORT)) { - Rs2Inventory.interact(ItemID.VARROCK_TELEPORT, "break"); - sleep(sleepBetweenTeleports); - return; - } - - boolean isNearGeBank = Rs2Walker.walkTo(BankLocation.GRAND_EXCHANGE.getWorldPoint()); //walk to ge bank - - if (isNearGeBank) { - shutdown(); - } - - } - } catch (Exception ex) { - System.out.println(ex.getMessage()); - } - }, 0, 1000, TimeUnit.MILLISECONDS); - return true; - } - - private boolean plantTree(FarmingConfig config, int objectId, int npcId, int totalItemsForNextStep, FarmingState nextState) { - try { - final ObjectComposition tree = Rs2GameObject.findObjectComposition(objectId); - if (tree != null && tree.getImpostor().getName().equalsIgnoreCase(config.farmingMaterial().getName())) { - if (Rs2GameObject.hasAction(tree, "check-health")) { - Rs2GameObject.interact(objectId, "check-health"); - int currentFarmingExp = Microbot.getClient().getSkillExperience(Skill.FARMING); - sleepUntilOnClientThread(() -> currentFarmingExp != Microbot.getClient().getSkillExperience(Skill.FARMING)); - } else if (Rs2GameObject.hasAction(tree, "chop down")) { - Rs2Npc.interact(npcId, "pay"); - sleepUntil(() -> Rs2Widget.hasWidget("pay 200 coins")); - Rs2Keyboard.typeString("1"); - // sleepUntil(() -> !Rs2GameObject.hasAction(tree, "chop down")); -> this crashes the client for some reason - } else { - //pay protect tree - - if (tree != null - && !Rs2GameObject.hasAction(tree, "chop down") - && !Rs2GameObject.hasAction(tree, "check-health") - && tree.getImpostor().getName().equalsIgnoreCase(config.farmingMaterial().getName())) { - Rs2Npc.interact(npcId, "pay"); - sleepUntil(() -> Rs2Inventory.hasItemAmount(config.farmingMaterial().getProtectionItem(), totalItemsForNextStep, true)); - } - } - } else { - //rake patch & plant tree - if (!RakeAndPlantTree(objectId, config.farmingMaterial().getItemName(), tree)) return true; - } - - if (Rs2Inventory.hasItemAmount(config.farmingMaterial().getItemName(), totalItemsForNextStep, false, true) && - Rs2Inventory.hasItemAmount(config.farmingMaterial().getProtectionItem(), totalItemsForNextStep, false, true)) { - //new state - state = nextState; - } - return false; - } catch (Exception ex) { - System.out.println(ex.getMessage()); - } - - return false; - } - - private boolean RakeAndPlantTree(int patchId, String treeToPlant, ObjectComposition tree) { - - if (Rs2Player.isAnimating()) return false; - - GameObject farmingPatch = Rs2GameObject.findObjectByImposter(patchId, "rake"); - if (farmingPatch != null) { - Rs2GameObject.interact(farmingPatch, "rake"); - sleep(2000); - sleepUntil(() -> !Rs2Player.isAnimating()); - } else { - Rs2Inventory.use(treeToPlant); - boolean success = Rs2GameObject.interact(patchId); - if (success) { - sleepUntil(() -> tree != null); - } - } - Rs2Inventory.dropAll("weeds"); - return true; - } - - @Override - public void shutdown() { - super.shutdown(); - state = FarmingState.RESET; - } -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/farming/enums/FarmingMaterial.java b/runelite-client/src/main/java/net/runelite/client/plugins/microbot/farming/enums/FarmingMaterial.java deleted file mode 100644 index d9c46b7804..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/farming/enums/FarmingMaterial.java +++ /dev/null @@ -1,34 +0,0 @@ -package net.runelite.client.plugins.microbot.farming.enums; - -import lombok.Getter; -import lombok.RequiredArgsConstructor; - -@Getter -@RequiredArgsConstructor -public enum FarmingMaterial { - OAK_TREE("Oak", "oak sapling", "tomatoes(5)", 1, 15), - WILLOW_TREE("Willow", "willow sapling", "apples(5)", 1, 30), - MAPLE_TREE("Maple", "maple sapling", "oranges(5)", 1, 45), - YEW_TREE("Yew", "yew sapling", "cactus spine", 10, 60), - MAGIC_TREE("Magic", "magic sapling", "coconut", 25, 75), - APPLE_TREE("Apple", "apple sapling", "sweetcorn", 9, 27), - BANANA_TREE("Banana", "banana sapling", "apples(5)", 4, 33), - ORANGE_TREE("Orange", "orange sapling", "strawberries(5)", 3, 39), - CURRY_TREE("Curry", "curry sapling", "bananas(5)", 5, 42), - PINEAPPLE_TREE("Pineapple", "pineapple sapling", "watermelon", 10, 51), - PAPAYA_TREE("Papaya", "papaya sapling", "pineapple", 10, 57), - PALM_TREE("Palm", "palm sapling", "papaya fruit", 15, 68), - DRAGONFRUIT_TREE("Dragonfruit", "dragonfruit sapling", "coconut", 15, 81); - - - private final String name; - private final String itemName; - private final String protectionItem; - private final int protectionItemAmount; - private final int levelRequired; - - @Override - public String toString() { - return name; - } -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/farming/enums/FarmingState.java b/runelite-client/src/main/java/net/runelite/client/plugins/microbot/farming/enums/FarmingState.java deleted file mode 100644 index 6be3f51f80..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/farming/enums/FarmingState.java +++ /dev/null @@ -1,11 +0,0 @@ -package net.runelite.client.plugins.microbot.farming.enums; - -public enum FarmingState { - RESET, - BANKING, - FARMING_GNOME_STRONHOLD, - FARMING_VARROCK, - FARMING_FALADOR, - FARMING_LUMBRIDGE, - FINISHED -} From 3239ce8067f5902cf583750765ef1905e29ff98a Mon Sep 17 00:00:00 2001 From: chsami Date: Thu, 21 Nov 2024 20:37:25 +0100 Subject: [PATCH 08/45] removed farming runner --- .../client/plugins/microbot/construction/ConstructionConfig.java | 1 - 1 file changed, 1 deletion(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/construction/ConstructionConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/microbot/construction/ConstructionConfig.java index e69f69d2e2..06942a3ce3 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/construction/ConstructionConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/microbot/construction/ConstructionConfig.java @@ -3,7 +3,6 @@ import net.runelite.client.config.Config; import net.runelite.client.config.ConfigGroup; import net.runelite.client.config.ConfigItem; -import net.runelite.client.plugins.microbot.farming.enums.FarmingMaterial; @ConfigGroup(ConstructionConfig.GROUP) public interface ConstructionConfig extends Config { From e3435b8c565e5eb3571307d4e322412ce789c292 Mon Sep 17 00:00:00 2001 From: chsami Date: Thu, 21 Nov 2024 20:37:42 +0100 Subject: [PATCH 09/45] removed farming runner --- .../client/plugins/microbot/looter/AutoLooterOverlay.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/looter/AutoLooterOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/microbot/looter/AutoLooterOverlay.java index e60959011d..5712f7a016 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/looter/AutoLooterOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/microbot/looter/AutoLooterOverlay.java @@ -1,8 +1,6 @@ package net.runelite.client.plugins.microbot.looter; import net.runelite.client.plugins.microbot.Microbot; -import net.runelite.client.plugins.microbot.farming.FarmingPlugin; -import net.runelite.client.plugins.microbot.farming.FarmingScript; import net.runelite.client.ui.overlay.OverlayPanel; import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.components.LineComponent; From 2eb1f9977e5c9ce9efa4301e76da6c938edf1224 Mon Sep 17 00:00:00 2001 From: chsami Date: Thu, 21 Nov 2024 20:39:08 +0100 Subject: [PATCH 10/45] MixologyScript avoid getting stuck on deposit hopper --- .../client/plugins/microbot/mixology/MixologyScript.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/mixology/MixologyScript.java b/runelite-client/src/main/java/net/runelite/client/plugins/microbot/mixology/MixologyScript.java index 19c0d0ee9c..6a3a318c44 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/mixology/MixologyScript.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/microbot/mixology/MixologyScript.java @@ -194,10 +194,8 @@ public boolean run(MixologyConfig config) { case DEPOSIT_HOPPER: if (Rs2GameObject.interact(ObjectID.HOPPER_54903)) { Rs2Player.waitForWalking(); - boolean success = Rs2Inventory.waitForInventoryChanges(10000); - if (success) { - mixologyState = MixologyState.MIX_POTION_STAGE_1; - } + Rs2Inventory.waitForInventoryChanges(10000); + mixologyState = MixologyState.MIX_POTION_STAGE_1; } break; case MIX_POTION_STAGE_1: From a6fbc0a5b5b72c1dc1320f47f8f1b5567c16dc4e Mon Sep 17 00:00:00 2001 From: chsami Date: Thu, 21 Nov 2024 20:39:32 +0100 Subject: [PATCH 11/45] mixology 1,0,2 --- .../client/plugins/microbot/mixology/MixologyScript.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/mixology/MixologyScript.java b/runelite-client/src/main/java/net/runelite/client/plugins/microbot/mixology/MixologyScript.java index 6a3a318c44..85a77baf2c 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/mixology/MixologyScript.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/microbot/mixology/MixologyScript.java @@ -27,7 +27,7 @@ public class MixologyScript extends Script { - public final static String version = "1.0.1-beta"; + public final static String version = "1.0.2-beta"; public java.util.List potionOrders = Collections.emptyList(); From 7aac76118a011000590743679238ff67713eb9fc Mon Sep 17 00:00:00 2001 From: chsami Date: Thu, 21 Nov 2024 20:48:16 +0100 Subject: [PATCH 12/45] cleanup --- .../client/plugins/microbot/Microbot.java | 29 ----- .../microbot/crafting/scripts/GemsScript.java | 5 +- .../summergarden/SummerGardenScript.java | 9 +- .../zeah/hosidius/HosidiusConfig.java | 10 -- .../zeah/hosidius/HosidiusOverlay.java | 12 -- .../zeah/hosidius/HosidiusPlugin.java | 66 ---------- .../zeah/hosidius/HosidiusScript.java | 121 ------------------ 7 files changed, 8 insertions(+), 244 deletions(-) delete mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/microbot/zeah/hosidius/HosidiusConfig.java delete mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/microbot/zeah/hosidius/HosidiusOverlay.java delete mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/microbot/zeah/hosidius/HosidiusPlugin.java delete mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/microbot/zeah/hosidius/HosidiusScript.java diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/Microbot.java b/runelite-client/src/main/java/net/runelite/client/plugins/microbot/Microbot.java index cdbea333d7..c71468f99f 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/Microbot.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/microbot/Microbot.java @@ -41,7 +41,6 @@ import javax.inject.Inject; import javax.swing.*; import java.awt.*; -import java.awt.event.MouseEvent; import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; @@ -151,23 +150,6 @@ public static boolean isDebug() { getInputArguments().toString().contains("-agentlib:jdwp"); } - @Deprecated(since = "Use isMoving", forRemoval = true) - public static boolean isWalking() { - return Microbot.getClientThread().runOnClientThread(() -> Microbot.getClient().getLocalPlayer().getPoseAnimation() - != Microbot.getClient().getLocalPlayer().getIdlePoseAnimation()); - } - - @Deprecated(since = "1.2.4 - use Rs2Player variant", forRemoval = true) - public static boolean isMoving() { - return Microbot.getClientThread().runOnClientThread(() -> Microbot.getClient().getLocalPlayer().getPoseAnimation() - != Microbot.getClient().getLocalPlayer().getIdlePoseAnimation()); - } - - @Deprecated(since = "1.2.4 - use Rs2Player variant", forRemoval = true) - public static boolean isAnimating() { - return Microbot.getClientThread().runOnClientThread(() -> getClient().getLocalPlayer().getAnimation() != -1); - } - public static int getVarbitValue(int varbit) { return getClientThread().runOnClientThread(() -> getClient().getVarbitValue(varbit)); } @@ -209,11 +191,6 @@ public static boolean isHopping() { return idx == GameState.HOPPING; } - @Deprecated(since = "1.4.0 - use Rs2Player variant", forRemoval = true) - public static boolean hasLevel(int levelRequired, Skill skill) { - return Microbot.getClient().getRealSkillLevel(skill) >= levelRequired; - } - public static boolean hopToWorld(int worldNumber) { if (!Microbot.isLoggedIn()) return false; if (Microbot.isHopping()) return true; @@ -349,12 +326,6 @@ public static void click(Rectangle rectangle) { } } - @Deprecated(since = "1.3.8 - use Mouse class", forRemoval = true) - private static void mouseEvent(int id, Point point) { - MouseEvent e = new MouseEvent(client.getCanvas(), id, System.currentTimeMillis(), 0, point.getX(), point.getY(), 1, false, 1); - client.getCanvas().dispatchEvent(e); - } - public static List getAggregateLootRecords() { return LootTrackerPlugin.panel.aggregateRecords; } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/crafting/scripts/GemsScript.java b/runelite-client/src/main/java/net/runelite/client/plugins/microbot/crafting/scripts/GemsScript.java index 52d0e6ffec..83532e6721 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/crafting/scripts/GemsScript.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/microbot/crafting/scripts/GemsScript.java @@ -8,6 +8,7 @@ import net.runelite.client.plugins.microbot.util.bank.Rs2Bank; import net.runelite.client.plugins.microbot.util.inventory.Rs2Inventory; import net.runelite.client.plugins.microbot.util.keyboard.Rs2Keyboard; +import net.runelite.client.plugins.microbot.util.player.Rs2Player; import java.awt.event.KeyEvent; import java.util.concurrent.TimeUnit; @@ -21,7 +22,7 @@ public boolean run(CraftingConfig config) { try { if (!Microbot.isLoggedIn()) return; if (!super.run()) return; - if (!Microbot.hasLevel(config.gemType().getLevelRequired(), Skill.CRAFTING)) { + if (!Rs2Player.getSkillRequirement(Skill.CRAFTING, config.gemType().getLevelRequired())) { Microbot.showMessage("Crafting level too low to craft " + config.gemType().getName()); shutdown(); return; @@ -56,7 +57,7 @@ public boolean run(CraftingConfig config) { if (config.fletchIntoBoltTips()) { Microbot.status = "FLETCHING BOLT TIPS"; BoltTips boltTip = BoltTips.valueOf(config.gemType().name()); - if (Microbot.hasLevel(boltTip.getFletchingLevelRequired(), Skill.FLETCHING) && + if (Rs2Player.getSkillRequirement(Skill.FLETCHING, boltTip.getFletchingLevelRequired()) && Rs2Inventory.hasItem(config.gemType().getName()) && Rs2Inventory.hasItem("chisel")) { Rs2Inventory.use("chisel"); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/thieving/summergarden/SummerGardenScript.java b/runelite-client/src/main/java/net/runelite/client/plugins/microbot/thieving/summergarden/SummerGardenScript.java index f8ecaf8c76..0084866455 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/thieving/summergarden/SummerGardenScript.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/microbot/thieving/summergarden/SummerGardenScript.java @@ -17,6 +17,7 @@ import net.runelite.client.plugins.microbot.util.inventory.Rs2Inventory; import net.runelite.client.plugins.microbot.util.keyboard.Rs2Keyboard; import net.runelite.client.plugins.microbot.util.npc.Rs2Npc; +import net.runelite.client.plugins.microbot.util.player.Rs2Player; import net.runelite.client.plugins.microbot.util.walker.Rs2Walker; import net.runelite.client.plugins.microbot.util.widget.Rs2Widget; @@ -236,8 +237,8 @@ private void doMaze(SummerGardenConfig config) { if (Microbot.getClient().getLocalPlayer().getWorldLocation().equals(WORLD_POINT_MAZE_STARTING_LOCATION)) { if (config.waitForOneClick() || ElementalCollisionDetector.getTicksUntilStart() == 0) { Rs2GameObject.interact(OBJECT_SUMMER_TREE); - sleepUntil(() -> Microbot.isMoving()); - sleepUntil(() -> !Microbot.isMoving(), 30000); + sleepUntil(() -> Rs2Player.isMoving()); + sleepUntil(() -> !Rs2Player.isMoving(), 30000); sleepUntilOnClientThread(() -> Microbot.getClient().getLocalPlayer().getWorldLocation().getY() < 5481); sleep(1500);//caught or success timeout } @@ -253,8 +254,8 @@ private void doMaze(SummerGardenConfig config) { TileObject gate = Rs2GameObject.findObjectById(ObjectID.GATE_11987); if (gate != null) { Rs2GameObject.interact(gate); - sleepUntil(Microbot::isMoving); - sleepUntil(() -> !Microbot.isMoving()); + sleepUntil(Rs2Player::isMoving); + sleepUntil(() -> !Rs2Player.isMoving()); sleepUntilOnClientThread(() -> Microbot.getClient().getLocalPlayer().getWorldLocation().equals(WORLD_POINT_MAZE_STARTING_LOCATION)); } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/zeah/hosidius/HosidiusConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/microbot/zeah/hosidius/HosidiusConfig.java deleted file mode 100644 index 48a1b01a38..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/zeah/hosidius/HosidiusConfig.java +++ /dev/null @@ -1,10 +0,0 @@ -package net.runelite.client.plugins.microbot.zeah.hosidius; - -import net.runelite.client.config.Config; -import net.runelite.client.config.ConfigGroup; - -@ConfigGroup(net.runelite.client.plugins.microbot.zeah.hosidius.HosidiusConfig.GROUP) -public interface HosidiusConfig extends Config { - - String GROUP = "Hosidius Favour"; -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/zeah/hosidius/HosidiusOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/microbot/zeah/hosidius/HosidiusOverlay.java deleted file mode 100644 index e8e833e0c9..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/zeah/hosidius/HosidiusOverlay.java +++ /dev/null @@ -1,12 +0,0 @@ -package net.runelite.client.plugins.microbot.zeah.hosidius; - -import net.runelite.client.ui.overlay.Overlay; - -import java.awt.*; - -public class HosidiusOverlay extends Overlay { - @Override - public Dimension render(Graphics2D graphics) { - return null; - } -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/zeah/hosidius/HosidiusPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/microbot/zeah/hosidius/HosidiusPlugin.java deleted file mode 100644 index 9d6773b164..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/zeah/hosidius/HosidiusPlugin.java +++ /dev/null @@ -1,66 +0,0 @@ -package net.runelite.client.plugins.microbot.zeah.hosidius; - -import com.google.inject.Provides; -import lombok.extern.slf4j.Slf4j; -import net.runelite.api.Client; -import net.runelite.client.Notifier; -import net.runelite.client.callback.ClientThread; -import net.runelite.client.config.ConfigManager; -import net.runelite.client.plugins.Plugin; -import net.runelite.client.plugins.PluginDescriptor; -import net.runelite.client.plugins.microbot.Microbot; -import net.runelite.client.plugins.microbot.util.mouse.VirtualMouse; -import net.runelite.client.ui.overlay.OverlayManager; - -import javax.inject.Inject; -import java.awt.*; - -@PluginDescriptor( - name = PluginDescriptor.Mocrosoft + "Hosidius", - description = "Microbot hosidius favour plugin", - tags = {"microbot", "minigame", "hosidius", "favour", "zeah"}, - enabledByDefault = false, - hidden = true -) -@Slf4j -public class HosidiusPlugin extends Plugin { - - @Inject - private HosidiusConfig config; - - @Provides - HosidiusConfig provideConfig(ConfigManager configManager) { - return configManager.getConfig(HosidiusConfig.class); - } - - @Inject - private Client client; - @Inject - private ClientThread clientThread; - @Inject - private Notifier notifier; - @Inject - private OverlayManager overlayManager; - @Inject - private HosidiusOverlay hosidiusOverlay; - - private final HosidiusScript hosidiusScript = new HosidiusScript(); - - @Override - protected void startUp() throws AWTException { - Microbot.pauseAllScripts = false; - Microbot.setClient(client); - Microbot.setClientThread(clientThread); - Microbot.setNotifier(notifier); - Microbot.setMouse(new VirtualMouse()); - if (overlayManager != null) { - overlayManager.add(hosidiusOverlay); - } - hosidiusScript.run(config); - } - - protected void shutDown() { - hosidiusScript.shutdown(); - overlayManager.remove(hosidiusOverlay); - } -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/zeah/hosidius/HosidiusScript.java b/runelite-client/src/main/java/net/runelite/client/plugins/microbot/zeah/hosidius/HosidiusScript.java deleted file mode 100644 index a557f40caf..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/zeah/hosidius/HosidiusScript.java +++ /dev/null @@ -1,121 +0,0 @@ -package net.runelite.client.plugins.microbot.zeah.hosidius; - -import net.runelite.api.GameObject; -import net.runelite.api.Perspective; -import net.runelite.api.coords.LocalPoint; -import net.runelite.api.coords.WorldPoint; -import net.runelite.client.plugins.microbot.Microbot; -import net.runelite.client.plugins.microbot.Script; -import net.runelite.client.plugins.microbot.util.bank.Rs2Bank; -import net.runelite.client.plugins.microbot.util.gameobject.Rs2GameObject; -import net.runelite.client.plugins.microbot.util.inventory.Rs2Inventory; -import net.runelite.client.plugins.microbot.util.inventory.Rs2Item; - -import java.awt.*; -import java.util.concurrent.TimeUnit; - -public class HosidiusScript extends Script { - int repairCounter = 0; - final int hosidiousFavour = 4895; - - public boolean run(HosidiusConfig config) { - mainScheduledFuture = scheduledExecutorService.scheduleWithFixedDelay(() -> { - try { - if (!Microbot.isLoggedIn()) return; - if (!super.run()) return; - if (Microbot.getVarbitValue(hosidiousFavour) < 50) { - plough(); //south east field the middle plough - } else { - fertiliser(); - } - } catch (Exception ex) { - System.out.println(ex.getMessage()); - } - }, 0, 600, TimeUnit.MILLISECONDS); - return true; - } - - - public void plough() { - GameObject plough = Rs2GameObject.findObjectById(27437, 1774); - - if (plough == null) return; - - WorldPoint standLocation1 = new WorldPoint(1774, 3521, 0); - WorldPoint standLocation2 = new WorldPoint(1774, 3539, 0); - - if (plough.getWorldLocation().equals(new WorldPoint(1774, 3523, 0)) && !Microbot.getClient().getLocalPlayer().getWorldLocation().equals(standLocation1)) { - sleep(1000, 1800); - Polygon poly = Perspective - .getCanvasTilePoly(Microbot.getClient(), - LocalPoint.fromWorld(Microbot.getClient(), standLocation1)); - Microbot.getMouse().click(poly.getBounds()); - sleep(2000); - sleepUntil(() -> Microbot.getClient().getLocalPlayer().getWorldLocation().equals(standLocation1), 5000); - Rs2GameObject.interact(plough); - repairCounter = 0; - return; - } - if (plough.getWorldLocation().equals(new WorldPoint(1774, 3537, 0)) && !Microbot.getClient().getLocalPlayer().getWorldLocation().equals(standLocation2)) { - sleep(1000, 1800); - Polygon poly = Perspective - .getCanvasTilePoly(Microbot.getClient(), - LocalPoint.fromWorld(Microbot.getClient(), standLocation2)); - Microbot.getMouse().click(poly.getBounds()); - sleep(2000); - sleepUntil(() -> Microbot.getClient().getLocalPlayer().getWorldLocation().equals(standLocation2), 5000); - Rs2GameObject.interact(plough); - repairCounter = 0; - return; - } - - if (Microbot.getClient().getLocalPlayer().getAnimation() != 3065 && !Microbot.isMoving()) { - //looks like we are frozen - repairCounter++; - } else { - repairCounter = 0; - } - - if (repairCounter >= 5 && !Microbot.isMoving()) { - Rs2GameObject.interact(plough); - sleep(3000, 4000); - Rs2GameObject.interact(plough); - repairCounter = 0; - } - } - - public void fertiliser() { - String saltpetre = "saltpetre"; - String compost = "compost"; - if (!Rs2Inventory.hasItem(saltpetre) || !Rs2Inventory.hasItem(compost)) { - Rs2Bank.openBank(); - if (Rs2Bank.isOpen()) { - Rs2Bank.depositAll(); - Rs2Bank.withdrawX(false, "saltpetre", 14); - Rs2Bank.withdrawX(false, "compost", 14); - Rs2Bank.closeBank(); - } - } else { - if (!Rs2Inventory.isFull()) { - Microbot.getNotifier().notify("Hosidius script has finished"); - shutDown(); - return; - } - if (!Rs2Bank.isOpen()) { - while (Rs2Inventory.hasItem(saltpetre) && Rs2Inventory.hasItem(compost)) { - for (int i = 0; i < 14; i++) { - Rs2Item rs2Item1 = Rs2Inventory.getItemInSlot(i); - Rs2Item rs2Item2 = Rs2Inventory.getItemInSlot(i + 14); - Rs2Inventory.combine(rs2Item1, rs2Item2); - sleep(400, 600); - } - sleep(1000); - } - } - } - } - - public void shutDown() { - super.shutdown(); - } -} From 1582e8c14ce647ff10639a93e53c42fbdafe683a Mon Sep 17 00:00:00 2001 From: lVidStorm <@> Date: Fri, 22 Nov 2024 08:11:53 +1100 Subject: [PATCH 13/45] When did that happen o_O --- .../bankjs/BanksBankStander/BanksBankStanderScript.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/bankjs/BanksBankStander/BanksBankStanderScript.java b/runelite-client/src/main/java/net/runelite/client/plugins/microbot/bankjs/BanksBankStander/BanksBankStanderScript.java index 201a24327e..5ff9177ae0 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/bankjs/BanksBankStander/BanksBankStanderScript.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/microbot/bankjs/BanksBankStander/BanksBankStanderScript.java @@ -21,7 +21,7 @@ public class BanksBankStanderScript extends Script { @Inject private BanksBankStanderConfig config; - public static double version = 1.6; + public static double version = 1.7; int MAX_TRIES = 4; public static long previousItemChange; @@ -474,7 +474,7 @@ public String checkItemSums(){ //System.out.println("Attempting to check fourth item"); if (fourthItemId != null && ((Rs2Bank.bankItems.stream().filter(item -> item.id == fourthItemId).mapToInt(item -> item.quantity).sum() + Rs2Inventory.count(fourthItemId))) < config.fourthItemQuantity()) { return fourthItemId.toString(); - } else if (fourthItemId != null || (Rs2Bank.count(fourthItemIdentifier) + Rs2Inventory.count(fourthItemIdentifier)) >= config.fourthItemQuantity()) { + } else if (fourthItemId == null || (Rs2Bank.count(fourthItemIdentifier) + Rs2Inventory.count(fourthItemIdentifier)) >= config.fourthItemQuantity()) { return fourthItemIdentifier; } } From b666e3a3d54612a2c51af8e0d6c38d9024f8252f Mon Sep 17 00:00:00 2001 From: lVidStorm <@> Date: Fri, 22 Nov 2024 08:24:46 +1100 Subject: [PATCH 14/45] When did that happen o_O(2) --- .../bankjs/BanksBankStander/BanksBankStanderScript.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/bankjs/BanksBankStander/BanksBankStanderScript.java b/runelite-client/src/main/java/net/runelite/client/plugins/microbot/bankjs/BanksBankStander/BanksBankStanderScript.java index 5ff9177ae0..ea29ddc74c 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/bankjs/BanksBankStander/BanksBankStanderScript.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/microbot/bankjs/BanksBankStander/BanksBankStanderScript.java @@ -474,7 +474,7 @@ public String checkItemSums(){ //System.out.println("Attempting to check fourth item"); if (fourthItemId != null && ((Rs2Bank.bankItems.stream().filter(item -> item.id == fourthItemId).mapToInt(item -> item.quantity).sum() + Rs2Inventory.count(fourthItemId))) < config.fourthItemQuantity()) { return fourthItemId.toString(); - } else if (fourthItemId == null || (Rs2Bank.count(fourthItemIdentifier) + Rs2Inventory.count(fourthItemIdentifier)) >= config.fourthItemQuantity()) { + } else if (fourthItemId == null && (Rs2Bank.count(fourthItemIdentifier) + Rs2Inventory.count(fourthItemIdentifier)) >= config.fourthItemQuantity()) { return fourthItemIdentifier; } } From d437411bf15069c2cfdd5c2ecf0f3651bc5571aa Mon Sep 17 00:00:00 2001 From: lVidStorm <@> Date: Fri, 22 Nov 2024 08:25:51 +1100 Subject: [PATCH 15/45] When did that happen o_O(3) --- .../bankjs/BanksBankStander/BanksBankStanderScript.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/bankjs/BanksBankStander/BanksBankStanderScript.java b/runelite-client/src/main/java/net/runelite/client/plugins/microbot/bankjs/BanksBankStander/BanksBankStanderScript.java index ea29ddc74c..dcf15d8beb 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/bankjs/BanksBankStander/BanksBankStanderScript.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/microbot/bankjs/BanksBankStander/BanksBankStanderScript.java @@ -474,7 +474,7 @@ public String checkItemSums(){ //System.out.println("Attempting to check fourth item"); if (fourthItemId != null && ((Rs2Bank.bankItems.stream().filter(item -> item.id == fourthItemId).mapToInt(item -> item.quantity).sum() + Rs2Inventory.count(fourthItemId))) < config.fourthItemQuantity()) { return fourthItemId.toString(); - } else if (fourthItemId == null && (Rs2Bank.count(fourthItemIdentifier) + Rs2Inventory.count(fourthItemIdentifier)) >= config.fourthItemQuantity()) { + } else if (fourthItemId == null && (Rs2Bank.count(fourthItemIdentifier) + Rs2Inventory.count(fourthItemIdentifier)) < config.fourthItemQuantity()) { return fourthItemIdentifier; } } From 47a4a05801006458e67c1e1f17984af6418135d5 Mon Sep 17 00:00:00 2001 From: g-mason0 <19415334+g-mason0@users.noreply.github.com> Date: Thu, 21 Nov 2024 21:38:25 -0500 Subject: [PATCH 16/45] fix: correct display info for Ardougne Farm on Ardougne Cloak --- .../plugins/microbot/shortestpath/teleportation_items.tsv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runelite-client/src/main/resources/net/runelite/client/plugins/microbot/shortestpath/teleportation_items.tsv b/runelite-client/src/main/resources/net/runelite/client/plugins/microbot/shortestpath/teleportation_items.tsv index 48862e6aae..c2dc9d35be 100644 --- a/runelite-client/src/main/resources/net/runelite/client/plugins/microbot/shortestpath/teleportation_items.tsv +++ b/runelite-client/src/main/resources/net/runelite/client/plugins/microbot/shortestpath/teleportation_items.tsv @@ -1,7 +1,7 @@ # Destination Skills Item IDs Quests Duration Display info Consumable Wilderness level Varbits # Ardougne Cloaks (2-4's farm teleport is limited to 3,5, or infinite times - can this be validated?) 2606 3221 0 13121;13122;13123;13124;20760 4 Ardougne cloak: Kandarin Monastery F 20 -2664 3374 0 13122;13123;13124;20760 4 Ardougne cloak: Farm F 20 +2664 3374 0 13122;13123;13124;20760 4 Ardougne cloak: Ardougne Farm F 20 # Karamja Gloves 2840 9387 0 11140;13103 4 Karamja gloves F 20 # Desert Amulets (2 and 3 have one teleport per day, 4 is unlimited) From 32455f6cab0150dbfa0ee9fad847e5b20d217edf Mon Sep 17 00:00:00 2001 From: g-mason0 <19415334+g-mason0@users.noreply.github.com> Date: Thu, 21 Nov 2024 22:11:54 -0500 Subject: [PATCH 17/45] fix: create validateAndSetBreakDurations to ensure that microBreakDurationLow & microBreakDurationHigh fit within the constraints of the Panel --- .../microbot/util/antiban/AntibanPlugin.java | 57 ++++++++++++++++++- .../util/antiban/Rs2AntibanSettings.java | 4 +- 2 files changed, 58 insertions(+), 3 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/antiban/AntibanPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/antiban/AntibanPlugin.java index a2b784d7f9..e863a878e8 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/antiban/AntibanPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/antiban/AntibanPlugin.java @@ -80,7 +80,6 @@ hidden = true ) - public class AntibanPlugin extends Plugin { private static final int COOK_TIMEOUT = 3; @@ -94,6 +93,12 @@ public class AntibanPlugin extends Plugin { private boolean ready; private Skill lastSkillChanged; private NavigationButton navButton; + public static final int MICRO_BREAK_DURATION_LOW_DEFAULT = 3; + public static final int MICRO_BREAK_DURATION_HIGH_DEFAULT = 15; + private static final int MICRO_BREAK_DURATION_LOW_MIN = 1; + private static final int MICRO_BREAK_DURATION_LOW_MAX = 10; + private static final int MICRO_BREAK_DURATION_HIGH_MIN = 1; + private static final int MICRO_BREAK_DURATION_HIGH_MAX = 30; @Inject private OverlayManager overlayManager; @@ -153,6 +158,8 @@ protected void startUp() throws AWTException { .priority(1) .panel(panel) .build(); + + validateAndSetBreakDurations(); Timer timer = new Timer(); timer.scheduleAtFixedRate(new TimerTask() { @@ -224,6 +231,8 @@ public void onGameTick(GameTick event) { idleTicks = 0; } + validateAndSetBreakDurations(); + if (Rs2AntibanSettings.takeMicroBreaks && !Microbot.isPluginEnabled(BreakHandlerPlugin.class)) { if (Rs2AntibanSettings.devDebug) Microbot.showMessage("Micro breaks depend on the BreakHandlerPlugin, enabling it now."); @@ -305,5 +314,51 @@ private void updateAntibanSettings(Skill skill) { } } + /** + * Validates and ensures the micro break duration settings are within acceptable thresholds. + * + *

This method checks the values of {@code Rs2AntibanSettings.microBreakDurationLow} and + * {@code Rs2AntibanSettings.microBreakDurationHigh} to ensure they fall within their + * respective minimum and maximum bounds. If a value is outside the allowed range, + * it is reset to its default value. Additionally, it ensures that the low duration + * does not exceed the high duration, resetting both to their defaults if necessary.

+ * + *

Validation Rules:

+ *
    + *
  • {@code microBreakDurationLow} must be between {@code MICRO_BREAK_DURATION_LOW_MIN} and {@code MICRO_BREAK_DURATION_LOW_MAX}.
  • + *
  • {@code microBreakDurationHigh} must be between {@code MICRO_BREAK_DURATION_HIGH_MIN} and {@code MICRO_BREAK_DURATION_HIGH_MAX}.
  • + *
  • {@code microBreakDurationLow} must not exceed {@code microBreakDurationHigh}.
  • + *
+ * + *

Behavior:

+ *
    + *
  • If {@code microBreakDurationLow} is out of bounds, it is reset to {@code MICRO_BREAK_DURATION_LOW_DEFAULT}.
  • + *
  • If {@code microBreakDurationHigh} is out of bounds, it is reset to {@code MICRO_BREAK_DURATION_HIGH_DEFAULT}.
  • + *
  • If {@code microBreakDurationLow} exceeds {@code microBreakDurationHigh}, both are reset to their defaults.
  • + *
+ * + *

Usage:

+ *

This method should be called during plugin initialization or whenever the settings + * are loaded or modified to ensure the durations remain consistent and valid.

+ */ + private void validateAndSetBreakDurations() { + // Validate and correct microBreakDurationLow + if (Rs2AntibanSettings.microBreakDurationLow < MICRO_BREAK_DURATION_LOW_MIN + || Rs2AntibanSettings.microBreakDurationLow > MICRO_BREAK_DURATION_LOW_MAX) { + Rs2AntibanSettings.microBreakDurationLow = MICRO_BREAK_DURATION_LOW_DEFAULT; + } + + // Validate and correct microBreakDurationHigh + if (Rs2AntibanSettings.microBreakDurationHigh < MICRO_BREAK_DURATION_HIGH_MIN + || Rs2AntibanSettings.microBreakDurationHigh > MICRO_BREAK_DURATION_HIGH_MAX) { + Rs2AntibanSettings.microBreakDurationHigh = MICRO_BREAK_DURATION_HIGH_DEFAULT; + } + + // Ensure microBreakDurationLow is not greater than microBreakDurationHigh + if (Rs2AntibanSettings.microBreakDurationLow > Rs2AntibanSettings.microBreakDurationHigh) { + Rs2AntibanSettings.microBreakDurationLow = MICRO_BREAK_DURATION_LOW_DEFAULT; + Rs2AntibanSettings.microBreakDurationHigh = MICRO_BREAK_DURATION_HIGH_DEFAULT; + } + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/antiban/Rs2AntibanSettings.java b/runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/antiban/Rs2AntibanSettings.java index 1fe7b909bc..e2683ee998 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/antiban/Rs2AntibanSettings.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/antiban/Rs2AntibanSettings.java @@ -96,8 +96,8 @@ public class Rs2AntibanSettings { public static boolean takeMicroBreaks = false; // will take micro breaks lasting 3-15 minutes at random intervals by default. public static boolean playSchedule = false; //TODO: Implement this public static boolean universalAntiban = false; // Will attempt to use the same antiban settings for all plugins that has not yet implemented their own antiban settings. - public static int microBreakDurationLow = 3; // 3 minutes - public static int microBreakDurationHigh = 15; // 15 minutes + public static int microBreakDurationLow = AntibanPlugin.MICRO_BREAK_DURATION_LOW_DEFAULT; // 3 minutes + public static int microBreakDurationHigh = AntibanPlugin.MICRO_BREAK_DURATION_HIGH_DEFAULT; // 15 minutes public static double actionCooldownChance = 0.1; // 10% chance of activating the action cooldown by default public static double microBreakChance = 0.1; // 10% chance of taking a micro break by default public static double moveMouseRandomlyChance = 0.1; // 10% chance of moving the mouse randomly by default From be517ca26c870fff7015f1f3af94837fb8483c35 Mon Sep 17 00:00:00 2001 From: chsami Date: Fri, 22 Nov 2024 20:46:44 +0100 Subject: [PATCH 18/45] Random => Rs2Random --- .../microbot/woodcutting/AutoWoodcuttingScript.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/woodcutting/AutoWoodcuttingScript.java b/runelite-client/src/main/java/net/runelite/client/plugins/microbot/woodcutting/AutoWoodcuttingScript.java index 894da9dd93..329367606a 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/woodcutting/AutoWoodcuttingScript.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/microbot/woodcutting/AutoWoodcuttingScript.java @@ -13,7 +13,6 @@ import net.runelite.client.plugins.microbot.util.equipment.Rs2Equipment; import net.runelite.client.plugins.microbot.util.gameobject.Rs2GameObject; import net.runelite.client.plugins.microbot.util.inventory.Rs2Inventory; -import net.runelite.client.plugins.microbot.util.math.Random; import net.runelite.client.plugins.microbot.util.math.Rs2Random; import net.runelite.client.plugins.microbot.util.player.Rs2Player; import net.runelite.client.plugins.microbot.util.tile.Rs2Tile; @@ -164,7 +163,7 @@ private void burnLog(AutoWoodcuttingConfig config) { if (!isFiremake()) { Rs2Inventory.waitForInventoryChanges(() -> { Rs2Inventory.use("tinderbox"); - sleep(Random.random(300, 600)); + sleep(Rs2Random.between(300, 600)); Rs2Inventory.use(config.TREE().getLog()); }); } @@ -193,7 +192,7 @@ private WorldPoint fireSpot(int distance) { // Return a random point from the closest points if (!closestPoints.isEmpty()) { - int randomIndex = Random.random(0, closestPoints.size()); + int randomIndex = Rs2Random.between(0, closestPoints.size()); return closestPoints.get(randomIndex); } } @@ -226,7 +225,7 @@ private WorldPoint calculateReturnPoint(AutoWoodcuttingConfig config) { } private void walkBack(AutoWoodcuttingConfig config) { - Rs2Walker.walkTo(new WorldPoint(calculateReturnPoint(config).getX() - Random.random(-1, 1), calculateReturnPoint(config).getY() - Random.random(-1, 1), calculateReturnPoint(config).getPlane())); + Rs2Walker.walkTo(new WorldPoint(calculateReturnPoint(config).getX() - Rs2Random.between(-1, 1), calculateReturnPoint(config).getY() - Rs2Random.between(-1, 1), calculateReturnPoint(config).getPlane())); sleepUntil(() -> Rs2Player.getWorldLocation().distanceTo(calculateReturnPoint(config)) <= 4); } From f4a7467e6ba465dd914d69a6e473e1327a4df26c Mon Sep 17 00:00:00 2001 From: chsami Date: Fri, 22 Nov 2024 21:09:28 +0100 Subject: [PATCH 19/45] sandcrab fixes --- .../microbot/sandcrabs/SandCrabScript.java | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/sandcrabs/SandCrabScript.java b/runelite-client/src/main/java/net/runelite/client/plugins/microbot/sandcrabs/SandCrabScript.java index 2c10019c85..0095a66a13 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/sandcrabs/SandCrabScript.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/microbot/sandcrabs/SandCrabScript.java @@ -21,6 +21,7 @@ import net.runelite.client.plugins.microbot.util.widget.Rs2Widget; import java.awt.event.KeyEvent; +import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.List; @@ -40,7 +41,7 @@ public class SandCrabScript extends Script { public int timesHopped = 0; - List sandCrabLocations = Arrays.asList(new ScanLocation(new WorldPoint(1843, 3462, 0)), + List initSandCrabLocations = Arrays.asList(new ScanLocation(new WorldPoint(1843, 3462, 0)), new ScanLocation(new WorldPoint(1833, 3458, 0)), new ScanLocation(new WorldPoint(1790, 3468, 0)), new ScanLocation(new WorldPoint(1776, 3468, 0), true), @@ -49,10 +50,14 @@ public class SandCrabScript extends Script { new ScanLocation(new WorldPoint(1749, 3469, 0)), new ScanLocation(new WorldPoint(1738, 3468, 0))); + List sandCrabLocations = new ArrayList<>(); + public boolean run(SandCrabConfig config) { initialPlayerLocation = null; if (config.threeNpcs()) { - sandCrabLocations = sandCrabLocations.stream().filter(x -> x.hasThreeNpcs).collect(Collectors.toList()); + sandCrabLocations = initSandCrabLocations.stream().filter(x -> x.hasThreeNpcs).collect(Collectors.toList()); + } else { + sandCrabLocations = initSandCrabLocations.stream().collect(Collectors.toList()); } mainScheduledFuture = scheduledExecutorService.scheduleWithFixedDelay(() -> { try { @@ -142,20 +147,22 @@ public boolean run(SandCrabConfig config) { case HOP_WORLD: int world = Login.getRandomWorld(true, null); boolean isHopped = Microbot.hopToWorld(world); - if (!isHopped) return; - boolean result = sleepUntil(() -> Rs2Widget.findWidget("Switch World") != null); - if (result) { - Rs2Keyboard.keyPress(KeyEvent.VK_SPACE); - sleepUntil(() -> Microbot.getClient().getGameState() == GameState.HOPPING); - sleepUntil(() -> Microbot.getClient().getGameState() == GameState.LOGGED_IN); + if (isHopped) { + boolean result = sleepUntil(() -> Rs2Widget.findWidget("Switch World") != null); + if (result) { + Rs2Keyboard.keyPress(KeyEvent.VK_SPACE); + sleepUntil(() -> Microbot.getClient().getGameState() == GameState.HOPPING); + sleepUntil(() -> Microbot.getClient().getGameState() == GameState.LOGGED_IN); + } } + if (timesHopped > 10) { timesHopped = 0; state = State.SCAN_LOCATIONS; } else { timesHopped++; hijackTimer = 0; - state = State.FIGHT; + resetAfkTimer(); } resetScanLocations(); break; From 78c6c65eae8f12598e245a0025466e0d3437f1aa Mon Sep 17 00:00:00 2001 From: chsami Date: Fri, 22 Nov 2024 21:09:39 +0100 Subject: [PATCH 20/45] sandcrab fixes --- .../runelite/client/plugins/microbot/util/combat/Rs2Combat.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/combat/Rs2Combat.java b/runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/combat/Rs2Combat.java index 5b0b6374b4..c8f08b685b 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/combat/Rs2Combat.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/combat/Rs2Combat.java @@ -115,7 +115,7 @@ public static boolean enableAutoRetialiate() { if (Microbot.getVarbitPlayerValue(172) == 1) { Rs2Tab.switchToCombatOptionsTab(); sleepUntil(() -> Rs2Tab.getCurrentTab() == InterfaceTab.COMBAT, 2000); - Rs2Widget.clickWidget(38862878); + Rs2Widget.clickWidget(38862879); } return Microbot.getVarbitPlayerValue(172) == 0; From 12115f3b9b9da45ecc5c17313c1ced88ed4cf5b6 Mon Sep 17 00:00:00 2001 From: chsami Date: Sat, 23 Nov 2024 17:28:14 +0100 Subject: [PATCH 21/45] remove obsolete class --- .../client/plugins/microbot/vorkath/VorkathScript.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/vorkath/VorkathScript.java b/runelite-client/src/main/java/net/runelite/client/plugins/microbot/vorkath/VorkathScript.java index 0851a4b2c1..8a1870b56e 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/vorkath/VorkathScript.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/microbot/vorkath/VorkathScript.java @@ -22,7 +22,7 @@ import net.runelite.client.plugins.microbot.util.grounditem.Rs2GroundItem; import net.runelite.client.plugins.microbot.util.inventory.Rs2Inventory; import net.runelite.client.plugins.microbot.util.magic.Rs2Magic; -import net.runelite.client.plugins.microbot.util.math.Random; +import net.runelite.client.plugins.microbot.util.math.Rs2Random; import net.runelite.client.plugins.microbot.util.misc.Rs2Potion; import net.runelite.client.plugins.microbot.util.npc.Rs2Npc; import net.runelite.client.plugins.microbot.util.player.Rs2Player; @@ -83,7 +83,7 @@ private static void walkToCenter() { } private static void drinkPrayer() { - if ((Microbot.getClient().getBoostedSkillLevel(Skill.PRAYER) * 100) / Microbot.getClient().getRealSkillLevel(Skill.PRAYER) < Random.random(25, 30)) { + if ((Microbot.getClient().getBoostedSkillLevel(Skill.PRAYER) * 100) / Microbot.getClient().getRealSkillLevel(Skill.PRAYER) < Rs2Random.between(25, 30)) { Rs2Inventory.interact(Rs2Potion.getPrayerPotionsVariants(), "drink"); } } @@ -531,7 +531,7 @@ private boolean isCloseToRelleka() { private void redBallWalk() { WorldPoint currentPlayerLocation = Microbot.getClient().getLocalPlayer().getWorldLocation(); WorldPoint sideStepLocation = new WorldPoint(currentPlayerLocation.getX() + 2, currentPlayerLocation.getY(), 0); - if (Random.random(0, 2) == 1) { + if (Rs2Random.between(0, 2) == 1) { sideStepLocation = new WorldPoint(currentPlayerLocation.getX() - 2, currentPlayerLocation.getY(), 0); } final WorldPoint _sideStepLocation = sideStepLocation; From e43b76d5434d03245260e36f3afaf8e0cfb5f49d Mon Sep 17 00:00:00 2001 From: chsami Date: Sat, 23 Nov 2024 17:31:27 +0100 Subject: [PATCH 22/45] cleanup --- .../src/main/java/net/runelite/client/plugins/PluginManager.java | 1 - 1 file changed, 1 deletion(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/PluginManager.java b/runelite-client/src/main/java/net/runelite/client/plugins/PluginManager.java index a90be5e68f..444d1f8864 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/PluginManager.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/PluginManager.java @@ -79,7 +79,6 @@ public class PluginManager private final boolean developerMode; private final boolean safeMode; - private final boolean disableWalkerUpdate; private final EventBus eventBus; private final Scheduler scheduler; private final ConfigManager configManager; From 12ae41b59dab7a081daa7722f2e292257075861b Mon Sep 17 00:00:00 2001 From: chsami Date: Sat, 23 Nov 2024 17:31:35 +0100 Subject: [PATCH 23/45] cleanup --- .../src/main/java/net/runelite/client/plugins/PluginManager.java | 1 - 1 file changed, 1 deletion(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/PluginManager.java b/runelite-client/src/main/java/net/runelite/client/plugins/PluginManager.java index 444d1f8864..520fbeb794 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/PluginManager.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/PluginManager.java @@ -106,7 +106,6 @@ public void addPlugin(Plugin plugin) { { this.developerMode = developerMode; this.safeMode = safeMode; - this.disableWalkerUpdate = disableWalkerUpdate; this.eventBus = eventBus; this.scheduler = scheduler; this.configManager = configManager; From bcbdcc64ced3512c26efd83a6ebf397de27fae88 Mon Sep 17 00:00:00 2001 From: chsami Date: Sat, 23 Nov 2024 23:56:43 +0100 Subject: [PATCH 24/45] doesEquipmentMatch fix --- .../client/plugins/microbot/util/Rs2InventorySetup.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/Rs2InventorySetup.java b/runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/Rs2InventorySetup.java index 72ebe179d8..41f6162a65 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/Rs2InventorySetup.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/Rs2InventorySetup.java @@ -257,9 +257,13 @@ public boolean doesEquipmentMatch() { for (InventorySetupsItem inventorySetupsItem : inventorySetup.getEquipment()) { if (inventorySetupsItem.getId() == -1) continue; if (inventorySetupsItem.isFuzzy()) { - return Rs2Equipment.isWearing(inventorySetupsItem.getName(), false); + if (!Rs2Equipment.isWearing(inventorySetupsItem.getName(), false)) { + return false; + } } else { - return Rs2Equipment.isWearing(inventorySetupsItem.getName(), true); + if (!Rs2Equipment.isWearing(inventorySetupsItem.getName(), true)) { + return false; + } } } return true; From 38f578f1d276992f6627655cb5fae6f532c4f0fe Mon Sep 17 00:00:00 2001 From: chsami Date: Sun, 24 Nov 2024 02:18:15 +0100 Subject: [PATCH 25/45] MicrobotApi log script runtime --- .../runelite/client/ClientSessionManager.java | 31 ++++--- .../runelite/client/RuneLiteProperties.java | 7 ++ .../net/runelite/client/SessionClient.java | 34 -------- .../net/runelite/client/plugins/Plugin.java | 1 - .../client/plugins/PluginManager.java | 2 + .../client/plugins/microbot/Microbot.java | 71 ++++++++++++++- .../client/plugins/microbot/Script.java | 86 +++++++++++-------- .../microbot/example/ExamplePlugin.java | 1 + .../microbot/example/ExampleScript.java | 5 +- .../microbot/mixology/MixologyOverlay.java | 6 +- .../microbot/mixology/MixologyPlugin.java | 7 -- .../client/plugins/microbot/util/Global.java | 6 +- 12 files changed, 155 insertions(+), 102 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/ClientSessionManager.java b/runelite-client/src/main/java/net/runelite/client/ClientSessionManager.java index 18ea27198e..d02229f94d 100644 --- a/runelite-client/src/main/java/net/runelite/client/ClientSessionManager.java +++ b/runelite-client/src/main/java/net/runelite/client/ClientSessionManager.java @@ -24,21 +24,23 @@ */ package net.runelite.client; -import java.io.IOException; -import java.util.UUID; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.ScheduledFuture; -import java.util.concurrent.TimeUnit; -import javax.annotation.Nullable; -import javax.inject.Inject; -import javax.inject.Singleton; import lombok.extern.slf4j.Slf4j; import net.runelite.api.Client; import net.runelite.api.GameState; import net.runelite.client.eventbus.Subscribe; import net.runelite.client.events.ClientShutdown; +import net.runelite.client.plugins.microbot.MicrobotApi; import net.runelite.client.util.RunnableExceptionLogger; +import javax.annotation.Nullable; +import javax.inject.Inject; +import javax.inject.Singleton; +import java.io.IOException; +import java.util.UUID; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ScheduledFuture; +import java.util.concurrent.TimeUnit; + @Singleton @Slf4j public class ClientSessionManager @@ -52,15 +54,17 @@ public class ClientSessionManager private UUID sessionId; private UUID microbotSessionId; + private MicrobotApi microbotApi; @Inject ClientSessionManager(ScheduledExecutorService executorService, @Nullable Client client, - SessionClient sessionClient) + SessionClient sessionClient, MicrobotApi microbotApi) { this.executorService = executorService; this.client = client; this.sessionClient = sessionClient; + this.microbotApi = microbotApi; } public void start() @@ -70,7 +74,7 @@ public void start() try { sessionId = sessionClient.open(); - microbotSessionId = sessionClient.microbotOpen(); + microbotSessionId = microbotApi.microbotOpen(); log.debug("Opened session {}", sessionId); } catch (IOException ex) @@ -100,7 +104,8 @@ private void onClientShutdown(ClientShutdown e) UUID localMicrobotUuid = microbotSessionId; if (localMicrobotUuid != null) { - sessionClient.microbotDelete(localMicrobotUuid); + microbotApi.sendScriptStatistics(); + microbotApi.microbotDelete(localMicrobotUuid); } } catch (IOException ex) @@ -151,7 +156,7 @@ private void microbotPing() try { if (microbotSessionId == null) { - microbotSessionId = sessionClient.microbotOpen(); + microbotSessionId = microbotApi.microbotOpen(); return; } } @@ -170,7 +175,7 @@ private void microbotPing() try { - sessionClient.microbotPing(microbotSessionId, loggedIn); + microbotApi.microbotPing(microbotSessionId, loggedIn); } catch (IOException ex) { diff --git a/runelite-client/src/main/java/net/runelite/client/RuneLiteProperties.java b/runelite-client/src/main/java/net/runelite/client/RuneLiteProperties.java index c84d803066..7dd7ff4ca4 100644 --- a/runelite-client/src/main/java/net/runelite/client/RuneLiteProperties.java +++ b/runelite-client/src/main/java/net/runelite/client/RuneLiteProperties.java @@ -49,6 +49,8 @@ public class RuneLiteProperties private static final String API_BASE = "runelite.api.base"; private static final String RUNELITE_CONFIG = "runelite.config"; private static final String OSRS_TWITTER_LINK = "runelite.osrstwitter.link"; + private static final String MICROBOT_VERSION = "microbot.version"; + @Getter(AccessLevel.PACKAGE) private static final Properties properties = new Properties(); @@ -140,4 +142,9 @@ public static String getOSRSTwitterLink() { return properties.getProperty(OSRS_TWITTER_LINK); } + public static String getMicrobotVersion() + { + return properties.getProperty(MICROBOT_VERSION); + } + } \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/SessionClient.java b/runelite-client/src/main/java/net/runelite/client/SessionClient.java index 4b0e7af154..94e60d188e 100644 --- a/runelite-client/src/main/java/net/runelite/client/SessionClient.java +++ b/runelite-client/src/main/java/net/runelite/client/SessionClient.java @@ -41,9 +41,6 @@ class SessionClient { private final HttpUrl sessionUrl; private final Gson gson; - //TODO: put this in the runelite.properties - private final String microbotApiUrl = "https://microbot-api.azurewebsites.net/api"; - @Inject private SessionClient(OkHttpClient client, @Named("runelite.session") HttpUrl sessionUrl, Gson gson) { this.client = client; @@ -51,37 +48,6 @@ private SessionClient(OkHttpClient client, @Named("runelite.session") HttpUrl se this.gson = gson; } - UUID microbotOpen() throws IOException { - try (Response response = client.newCall(new Request.Builder().url(microbotApiUrl + "/session").build()).execute()) { - ResponseBody body = response.body(); - - InputStream in = body.byteStream(); - return gson.fromJson(new InputStreamReader(in, StandardCharsets.UTF_8), UUID.class); - } catch (JsonParseException | IllegalArgumentException ex) // UUID.fromString can throw IllegalArgumentException - { - throw new IOException(ex); - } - } - - void microbotPing(UUID uuid, boolean loggedIn) throws IOException { - try (Response response = client.newCall(new Request.Builder().url(microbotApiUrl + "/session?sessionId=" + uuid.toString() - + "&isLoggedIn=" + loggedIn - + "&version=1.10.26" ).build()).execute()) { - if (!response.isSuccessful()) { - throw new IOException("Unsuccessful ping"); - } - } - } - - void microbotDelete(UUID uuid) throws IOException { - Request request = new Request.Builder() - .delete() - .url(microbotApiUrl + "/session?sessionId=" + uuid) - .build(); - - client.newCall(request).execute().close(); - } - UUID open() throws IOException { HttpUrl url = sessionUrl.newBuilder() .build(); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/Plugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/Plugin.java index c6dca03ef1..9843f51400 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/Plugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/Plugin.java @@ -75,5 +75,4 @@ public void setInjector(Injector injector) { this.injector = injector; } - } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/PluginManager.java b/runelite-client/src/main/java/net/runelite/client/plugins/PluginManager.java index 520fbeb794..c290c67b49 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/PluginManager.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/PluginManager.java @@ -34,6 +34,7 @@ import com.google.common.reflect.ClassPath.ClassInfo; import com.google.inject.Module; import com.google.inject.*; +import lombok.Getter; import lombok.Setter; import lombok.extern.slf4j.Slf4j; import net.runelite.client.RuneLite; @@ -84,6 +85,7 @@ public class PluginManager private final ConfigManager configManager; private final Provider sceneTileManager; private final List plugins = new CopyOnWriteArrayList<>(); + @Getter private final List activePlugins = new CopyOnWriteArrayList<>(); @Setter diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/Microbot.java b/runelite-client/src/main/java/net/runelite/client/plugins/microbot/Microbot.java index c71468f99f..221c54b284 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/microbot/Microbot.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/microbot/Microbot.java @@ -45,12 +45,11 @@ import java.io.File; import java.io.FileWriter; import java.io.IOException; +import java.lang.reflect.Field; import java.time.LocalTime; import java.time.format.DateTimeFormatter; -import java.util.ArrayList; -import java.util.Arrays; +import java.util.*; import java.util.List; -import java.util.Scanner; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledFuture; @@ -145,6 +144,9 @@ public class Microbot { public static int cantReachTargetRetries = 0; + @Getter + public static HashMap scriptRuntimes = new HashMap<>(); + public static boolean isDebug() { return java.lang.management.ManagementFactory.getRuntimeMXBean(). getInputArguments().toString().contains("-agentlib:jdwp"); @@ -419,5 +421,68 @@ public static Injector getInjector() { } return RuneLite.getInjector(); } + + /** + * Retrieves a list of active plugins that are part of the "microbot" package, excluding specific plugins. + * + * This method filters the active plugins managed by the `pluginManager` to include only those whose + * package name contains "microbot" (case-insensitive). It further excludes certain plugins based on + * their class names, such as "QuestHelperPlugin", "MInventorySetupsPlugin", "MicrobotPlugin", + * "MicrobotConfigPlugin", "ShortestPathPlugin", "AntibanPlugin", and "ExamplePlugin". + * + * @return a list of active plugins belonging to the "microbot" package, excluding the specified plugins. + */ + public static List getActiveMicrobotPlugins() { + return pluginManager.getActivePlugins().stream() + .filter(x -> x.getClass().getPackage().getName().toLowerCase().contains("microbot")) + .filter(x -> !x.getClass().getSimpleName().equalsIgnoreCase("QuestHelperPlugin") + && !x.getClass().getSimpleName().equalsIgnoreCase("MInventorySetupsPlugin") + && !x.getClass().getSimpleName().equalsIgnoreCase("MicrobotPlugin") + && !x.getClass().getSimpleName().equalsIgnoreCase("MicrobotConfigPlugin") + && !x.getClass().getSimpleName().equalsIgnoreCase("ShortestPathPlugin") + && !x.getClass().getSimpleName().equalsIgnoreCase("AntibanPlugin") + && !x.getClass().getSimpleName().equalsIgnoreCase("ExamplePlugin")) + .collect(Collectors.toList()); + } + + /** + * Retrieves a list of active `Script` instances from the currently active microbot plugins. + * + * This method iterates through all active microbot plugins and inspects their fields using reflection + * to find fields of type `Script` or its subclasses. The identified `Script` fields are extracted + * and returned as a list. + * + * Key Details: + * - The method uses reflection to access the fields of each plugin class. + * - Only fields that are assignable to the `Script` type are included. + * - Private fields are made accessible via `field.setAccessible(true)` to retrieve their values. + * - Any exceptions encountered during field access (e.g., `IllegalAccessException`) are logged, and + * the corresponding field is skipped. + * - Null values resulting from inaccessible or uninitialized fields are filtered out. + * + * @return a list of active `Script` instances extracted from the microbot plugins. + */ + public static List