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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
)
@Slf4j
public class WinePlugin extends Plugin {
public final static String version = "1.1.1";
public final static String version = "1.2.0";

@Inject
private Client client;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.microbot.Microbot;
import net.runelite.client.plugins.microbot.Script;
import net.runelite.client.plugins.microbot.util.antiban.Rs2Antiban;
import net.runelite.client.plugins.microbot.util.antiban.Rs2AntibanSettings;
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;
Expand All @@ -14,14 +16,30 @@
public class WineScript extends Script {

public boolean run(WineConfig config) {
// Apply the cooking template as a baseline, then overlay the user's saved
// antiban panel settings so anything toggled there wins over the template.
Rs2Antiban.resetAntibanSettings();
Rs2Antiban.antibanSetupTemplates.applyCookingSetup();
Rs2AntibanSettings.moveMouseRandomly = true;
Rs2AntibanSettings.loadFromProfile();
mainScheduledFuture = scheduledExecutorService.scheduleWithFixedDelay(() -> {
try {
if (!super.run()) return;
if (!Microbot.isLoggedIn()) return;
if (Rs2AntibanSettings.actionCooldownActive) return;
if (Rs2AntibanSettings.microBreakActive) return;
if (Rs2Inventory.count("grapes") > 0 && (Rs2Inventory.count("jug of water") > 0)) {
Rs2Inventory.combine("jug of water", "grapes");
sleepUntil(() -> Rs2Widget.getWidget(17694734) != null);
Rs2Keyboard.keyPress('1');
// Trigger the cooldown (incl. mouse off screen / random moves) as soon as
// the batch starts crafting, like a human looking away mid-batch, rather
// than after the last wine finishes.
Rs2Inventory.waitForInventoryChanges(3000);
Rs2Antiban.actionCooldown();
if (Rs2AntibanSettings.takeMicroBreaks) {
Rs2Antiban.takeMicroBreakByChance();
}
sleepUntil(() -> !Rs2Inventory.hasItem("jug of water"),25000);
} else {
bank();
Expand All @@ -37,21 +55,30 @@ private void bank(){
Rs2Bank.openBank();
if(Rs2Bank.isOpen()){
Rs2Bank.depositAll();
if(Rs2Bank.hasBankItem("jug of water",14) && Rs2Bank.hasBankItem("grapes",14)) {
Rs2Bank.withdrawDeficit("jug of water", 14);
int jugsInBank = Rs2Bank.count("jug of water");
int grapesInBank = Rs2Bank.count("grapes");
if(jugsInBank > 0 && grapesInBank > 0) {
// Withdraw up to 14 of each, or whatever is left for a final partial batch
int amount = Math.min(14, Math.min(jugsInBank, grapesInBank));
Rs2Bank.withdrawDeficit("jug of water", amount);
sleepUntil(() -> Rs2Inventory.hasItem("jug of water"));
Rs2Bank.withdrawDeficit("grapes", 14);
Rs2Bank.withdrawDeficit("grapes", amount);
sleepUntil(() -> Rs2Inventory.hasItem("grapes"));
} else {
// Out of grapes or jugs of water: log out and stop the plugin
Microbot.getNotifier().notify("Run out of Materials");
Microbot.status = "[Shutting down] - Reason: out of grapes or jugs of water.";
Rs2Bank.closeBank();
sleepUntil(() -> !Rs2Bank.isOpen());
Rs2Player.logout();
sleepUntil(() -> !Microbot.isLoggedIn(), 10000);
Plugin wineMakerPlugin = Microbot.getPluginManager().getPlugins().stream()
.filter(x -> x.getClass().getName().equals(WinePlugin.class.getName()))
.findFirst()
.orElse(null);
Microbot.stopPlugin(wineMakerPlugin);
shutdown();
return;
}
}
Rs2Bank.closeBank();
Expand All @@ -60,6 +87,7 @@ private void bank(){

@Override
public void shutdown() {
Rs2Antiban.resetAntibanSettings();
super.shutdown();
}
}
Loading