iherbcleaner: cleans herbs and deposits/withdraws from the bank.
This commit is contained in:
parent
413b351a2d
commit
d53ca5c2b8
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* Copyright (c) 2019 Owain van Brakel <https://github.com/Owain94>
|
||||
* 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.
|
||||
*/
|
||||
|
||||
version = "1.0.0"
|
||||
|
||||
project.extra["PluginName"] = "iHerbCleaner"
|
||||
project.extra["PluginDescription"] = "Illumine - Herb Cleaner"
|
||||
|
||||
dependencies {
|
||||
//compileOnly(group = "com.openosrs.externals", name = "iutils", version = "1.0.0+") uncomment this is you want to use this in a project that doesn't also hold iUtils
|
||||
compileOnly(project(":iutils"))
|
||||
compileOnly(group = "com.owain.externals", name = "chinbreakhandler", version = "0.0.13+")
|
||||
}
|
||||
|
||||
tasks {
|
||||
jar {
|
||||
manifest {
|
||||
attributes(mapOf(
|
||||
"Plugin-Version" to project.version,
|
||||
"Plugin-Id" to nameToId(project.extra["PluginName"] as String),
|
||||
"Plugin-Provider" to project.extra["PluginProvider"],
|
||||
"Plugin-Dependencies" to
|
||||
arrayOf(
|
||||
nameToId("iUtils"),
|
||||
"chinbreakhandler-plugin"
|
||||
).joinToString(),
|
||||
"Plugin-Description" to project.extra["PluginDescription"],
|
||||
"Plugin-License" to project.extra["PluginLicense"]
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
package net.runelite.client.plugins.iherbcleaner;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.MenuEntry;
|
||||
import net.runelite.api.events.GameTick;
|
||||
import static net.runelite.client.plugins.iherbcleaner.iHerbCleanerPlugin.sleepLength;
|
||||
import static net.runelite.client.plugins.iherbcleaner.iHerbCleanerPlugin.tickLength;
|
||||
import net.runelite.client.plugins.iutils.CalculationUtils;
|
||||
import net.runelite.client.plugins.iutils.MenuUtils;
|
||||
import net.runelite.client.plugins.iutils.MouseUtils;
|
||||
import net.runelite.client.plugins.iutils.ObjectUtils;
|
||||
import net.runelite.client.plugins.iutils.PlayerUtils;
|
||||
import net.runelite.client.plugins.iutils.iUtils;
|
||||
|
||||
@Slf4j
|
||||
public abstract class Task
|
||||
{
|
||||
public Task()
|
||||
{
|
||||
}
|
||||
|
||||
@Inject
|
||||
public Client client;
|
||||
|
||||
@Inject
|
||||
public iHerbCleanerConfig config;
|
||||
|
||||
@Inject
|
||||
public iUtils utils;
|
||||
|
||||
@Inject
|
||||
public MenuUtils menu;
|
||||
|
||||
@Inject
|
||||
public MouseUtils mouse;
|
||||
|
||||
@Inject
|
||||
public CalculationUtils calc;
|
||||
|
||||
@Inject
|
||||
public PlayerUtils playerUtils;
|
||||
|
||||
@Inject
|
||||
public ObjectUtils object;
|
||||
|
||||
public MenuEntry entry;
|
||||
|
||||
public abstract boolean validate();
|
||||
|
||||
public long sleepDelay()
|
||||
{
|
||||
sleepLength = calc.randomDelay(config.sleepWeightedDistribution(), config.sleepMin(), config.sleepMax(), config.sleepDeviation(), config.sleepTarget());
|
||||
return sleepLength;
|
||||
}
|
||||
|
||||
public int tickDelay()
|
||||
{
|
||||
tickLength = (int) calc.randomDelay(config.tickDelayWeightedDistribution(), config.tickDelayMin(), config.tickDelayMax(), config.tickDelayDeviation(), config.tickDelayTarget());
|
||||
return tickLength;
|
||||
}
|
||||
|
||||
public String getTaskDescription()
|
||||
{
|
||||
return this.getClass().getSimpleName();
|
||||
}
|
||||
|
||||
public void onGameTick(GameTick event)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
package net.runelite.client.plugins.iherbcleaner;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class TaskSet
|
||||
{
|
||||
public List<Task> taskList = new ArrayList<>();
|
||||
|
||||
public TaskSet(Task... tasks)
|
||||
{
|
||||
taskList.addAll(Arrays.asList(tasks));
|
||||
}
|
||||
|
||||
public void addAll(Task... tasks)
|
||||
{
|
||||
taskList.addAll(Arrays.asList(tasks));
|
||||
}
|
||||
|
||||
public void clear()
|
||||
{
|
||||
taskList.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Iterates through all the tasks in the set and returns
|
||||
* the highest priority valid task.
|
||||
* @return The first valid task from the task list or null if no valid task.
|
||||
*/
|
||||
public Task getValidTask()
|
||||
{
|
||||
for (Task task : this.taskList)
|
||||
{
|
||||
if (task.validate())
|
||||
{
|
||||
return task;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,282 @@
|
|||
/*
|
||||
* Copyright (c) 2018, SomeoneWithAnInternetConnection
|
||||
* Copyright (c) 2018, oplosthee <https://github.com/oplosthee>
|
||||
* 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.iherbcleaner;
|
||||
|
||||
import net.runelite.client.config.Button;
|
||||
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.config.ConfigTitleSection;
|
||||
import net.runelite.client.config.Range;
|
||||
import net.runelite.client.config.Title;
|
||||
|
||||
@ConfigGroup("iHerbCleaner")
|
||||
public interface iHerbCleanerConfig extends Config
|
||||
{
|
||||
|
||||
@ConfigSection(
|
||||
keyName = "delayConfig",
|
||||
name = "Sleep Delay Configuration",
|
||||
description = "Configure how the bot handles sleep delays",
|
||||
position = 0
|
||||
)
|
||||
default boolean delayConfig()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Range(
|
||||
min = 0,
|
||||
max = 550
|
||||
)
|
||||
@ConfigItem(
|
||||
keyName = "sleepMin",
|
||||
name = "Sleep Min",
|
||||
description = "",
|
||||
position = 1,
|
||||
section = "delayConfig"
|
||||
)
|
||||
default int sleepMin()
|
||||
{
|
||||
return 60;
|
||||
}
|
||||
|
||||
@Range(
|
||||
min = 0,
|
||||
max = 550
|
||||
)
|
||||
@ConfigItem(
|
||||
keyName = "sleepMax",
|
||||
name = "Sleep Max",
|
||||
description = "",
|
||||
position = 2,
|
||||
section = "delayConfig"
|
||||
)
|
||||
default int sleepMax()
|
||||
{
|
||||
return 350;
|
||||
}
|
||||
|
||||
@Range(
|
||||
min = 0,
|
||||
max = 550
|
||||
)
|
||||
@ConfigItem(
|
||||
keyName = "sleepTarget",
|
||||
name = "Sleep Target",
|
||||
description = "",
|
||||
position = 3,
|
||||
section = "delayConfig"
|
||||
)
|
||||
default int sleepTarget()
|
||||
{
|
||||
return 100;
|
||||
}
|
||||
|
||||
@Range(
|
||||
min = 0,
|
||||
max = 550
|
||||
)
|
||||
@ConfigItem(
|
||||
keyName = "sleepDeviation",
|
||||
name = "Sleep Deviation",
|
||||
description = "",
|
||||
position = 4,
|
||||
section = "delayConfig"
|
||||
)
|
||||
default int sleepDeviation()
|
||||
{
|
||||
return 10;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "sleepWeightedDistribution",
|
||||
name = "Sleep Weighted Distribution",
|
||||
description = "Shifts the random distribution towards the lower end at the target, otherwise it will be an even distribution",
|
||||
position = 5,
|
||||
section = "delayConfig"
|
||||
)
|
||||
default boolean sleepWeightedDistribution()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@ConfigSection(
|
||||
keyName = "delayTickConfig",
|
||||
name = "Game Tick Configuration",
|
||||
description = "Configure how the bot handles game tick delays, 1 game tick equates to roughly 600ms",
|
||||
position = 10
|
||||
)
|
||||
default boolean delayTickConfig()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Range(
|
||||
min = 0,
|
||||
max = 10
|
||||
)
|
||||
@ConfigItem(
|
||||
keyName = "tickDelayMin",
|
||||
name = "Game Tick Min",
|
||||
description = "",
|
||||
position = 11,
|
||||
section = "delayTickConfig"
|
||||
)
|
||||
default int tickDelayMin()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Range(
|
||||
min = 0,
|
||||
max = 10
|
||||
)
|
||||
@ConfigItem(
|
||||
keyName = "tickDelayMax",
|
||||
name = "Game Tick Max",
|
||||
description = "",
|
||||
position = 12,
|
||||
section = "delayTickConfig"
|
||||
)
|
||||
default int tickDelayMax()
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Range(
|
||||
min = 0,
|
||||
max = 10
|
||||
)
|
||||
@ConfigItem(
|
||||
keyName = "tickDelayTarget",
|
||||
name = "Game Tick Target",
|
||||
description = "",
|
||||
position = 13,
|
||||
section = "delayTickConfig"
|
||||
)
|
||||
default int tickDelayTarget()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Range(
|
||||
min = 0,
|
||||
max = 10
|
||||
)
|
||||
@ConfigItem(
|
||||
keyName = "tickDelayDeviation",
|
||||
name = "Game Tick Deviation",
|
||||
description = "",
|
||||
position = 14,
|
||||
section = "delayTickConfig"
|
||||
)
|
||||
default int tickDelayDeviation()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "tickDelayWeightedDistribution",
|
||||
name = "Game Tick Weighted Distribution",
|
||||
description = "Shifts the random distribution towards the lower end at the target, otherwise it will be an even distribution",
|
||||
position = 15,
|
||||
section = "delayTickConfig"
|
||||
)
|
||||
default boolean tickDelayWeightedDistribution()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@ConfigTitleSection(
|
||||
keyName = "instructionsTitle",
|
||||
name = "Instructions",
|
||||
description = "",
|
||||
position = 16
|
||||
)
|
||||
default Title instructionsTitle()
|
||||
{
|
||||
return new Title();
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "instructions",
|
||||
name = "",
|
||||
description = "Instructions. Don't enter anything into this field",
|
||||
position = 17,
|
||||
titleSection = "instructionsTitle"
|
||||
)
|
||||
default String instructions()
|
||||
{
|
||||
return "Have herbs in bank, setup IDs in config and press Start. Sleep Delays determine length of time between cleaning.";
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "herbID",
|
||||
name = "Herb ID",
|
||||
description = "Item ID of the Herb you want to clean",
|
||||
position = 20
|
||||
)
|
||||
default int herbID()
|
||||
{
|
||||
return 199;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "bankID",
|
||||
name = "Bank Booth ID",
|
||||
description = "Game Object ID of the Bank Booth you want to use",
|
||||
position = 25
|
||||
)
|
||||
default int bankID()
|
||||
{
|
||||
return 10583;
|
||||
}
|
||||
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "enableUI",
|
||||
name = "Enable UI",
|
||||
description = "Enable to turn on in game UI",
|
||||
position = 95
|
||||
)
|
||||
default boolean enableUI()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "startButton",
|
||||
name = "Start/Stop",
|
||||
description = "Test button that changes variable value",
|
||||
position = 100
|
||||
)
|
||||
default Button startButton()
|
||||
{
|
||||
return new Button();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,93 @@
|
|||
package net.runelite.client.plugins.iherbcleaner;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Rectangle;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.Client;
|
||||
import static net.runelite.api.MenuOpcode.RUNELITE_OVERLAY_CONFIG;
|
||||
import static net.runelite.client.ui.overlay.OverlayManager.OPTION_CONFIGURE;
|
||||
import net.runelite.client.ui.overlay.OverlayMenuEntry;
|
||||
import net.runelite.client.ui.overlay.OverlayPanel;
|
||||
import net.runelite.client.ui.overlay.OverlayPosition;
|
||||
import net.runelite.client.ui.overlay.components.TitleComponent;
|
||||
import net.runelite.client.ui.overlay.components.table.TableAlignment;
|
||||
import net.runelite.client.ui.overlay.components.table.TableComponent;
|
||||
import net.runelite.client.util.ColorUtil;
|
||||
import static org.apache.commons.lang3.time.DurationFormatUtils.formatDuration;
|
||||
|
||||
@Slf4j
|
||||
@Singleton
|
||||
class iHerbCleanerOverlay extends OverlayPanel
|
||||
{
|
||||
private final Client client;
|
||||
private final iHerbCleanerPlugin plugin;
|
||||
private final iHerbCleanerConfig config;
|
||||
|
||||
String timeFormat;
|
||||
private String infoStatus = "Starting...";
|
||||
|
||||
@Inject
|
||||
private iHerbCleanerOverlay(final Client client, final iHerbCleanerPlugin plugin, final iHerbCleanerConfig config)
|
||||
{
|
||||
super(plugin);
|
||||
setPosition(OverlayPosition.BOTTOM_LEFT);
|
||||
this.client = client;
|
||||
this.plugin = plugin;
|
||||
this.config = config;
|
||||
getMenuEntries().add(new OverlayMenuEntry(RUNELITE_OVERLAY_CONFIG, OPTION_CONFIGURE, "Herb Cleaner overlay"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension render(Graphics2D graphics)
|
||||
{
|
||||
if (plugin.botTimer == null || !config.enableUI())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
TableComponent tableComponent = new TableComponent();
|
||||
tableComponent.setColumnAlignments(TableAlignment.LEFT, TableAlignment.RIGHT);
|
||||
|
||||
Duration duration = Duration.between(plugin.botTimer, Instant.now());
|
||||
timeFormat = (duration.toHours() < 1) ? "mm:ss" : "HH:mm:ss";
|
||||
tableComponent.addRow("Time running:", formatDuration(duration.toMillis(),timeFormat));
|
||||
|
||||
tableComponent.addRow("Status:", plugin.status);
|
||||
|
||||
TableComponent tableStatsComponent = new TableComponent();
|
||||
tableStatsComponent.setColumnAlignments(TableAlignment.LEFT, TableAlignment.RIGHT);
|
||||
|
||||
TableComponent tableDelayComponent = new TableComponent();
|
||||
tableDelayComponent.setColumnAlignments(TableAlignment.LEFT, TableAlignment.RIGHT);
|
||||
|
||||
tableDelayComponent.addRow("Sleep delay:", iHerbCleanerPlugin.sleepLength + "ms");
|
||||
tableDelayComponent.addRow("Tick delay:", String.valueOf(plugin.timeout));
|
||||
|
||||
if (!tableComponent.isEmpty())
|
||||
{
|
||||
panelComponent.setBackgroundColor(ColorUtil.fromHex("#121212")); //Material Dark default
|
||||
panelComponent.setPreferredSize(new Dimension(270,200));
|
||||
panelComponent.setBorder(new Rectangle(5,5,5,5));
|
||||
panelComponent.getChildren().add(TitleComponent.builder()
|
||||
.text("Illumine Herb Cleaner")
|
||||
.color(ColorUtil.fromHex("#40C4FF"))
|
||||
.build());
|
||||
panelComponent.getChildren().add(tableComponent);
|
||||
panelComponent.getChildren().add(TitleComponent.builder()
|
||||
.text("Stats")
|
||||
.color(ColorUtil.fromHex("#FFA000"))
|
||||
.build());
|
||||
panelComponent.getChildren().add(tableStatsComponent);
|
||||
panelComponent.getChildren().add(TitleComponent.builder()
|
||||
.text("Delays")
|
||||
.color(ColorUtil.fromHex("#F8BBD0"))
|
||||
.build());
|
||||
panelComponent.getChildren().add(tableDelayComponent);
|
||||
}
|
||||
return super.render(graphics);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,238 @@
|
|||
/*
|
||||
* Copyright (c) 2018, SomeoneWithAnInternetConnection
|
||||
* Copyright (c) 2018, oplosthee <https://github.com/oplosthee>
|
||||
* 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.iherbcleaner;
|
||||
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.Provides;
|
||||
import com.owain.chinbreakhandler.ChinBreakHandler;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import javax.inject.Inject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.GameState;
|
||||
import net.runelite.api.MenuEntry;
|
||||
import net.runelite.api.Player;
|
||||
import net.runelite.api.coords.LocalPoint;
|
||||
import net.runelite.api.events.ConfigButtonClicked;
|
||||
import net.runelite.api.events.GameTick;
|
||||
import net.runelite.client.config.ConfigManager;
|
||||
import net.runelite.client.eventbus.Subscribe;
|
||||
import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.plugins.PluginDependency;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
import net.runelite.client.plugins.PluginType;
|
||||
import net.runelite.client.plugins.iherbcleaner.tasks.BankItemsTask;
|
||||
import net.runelite.client.plugins.iherbcleaner.tasks.CleanHerbTask;
|
||||
import net.runelite.client.plugins.iherbcleaner.tasks.MovingTask;
|
||||
import net.runelite.client.plugins.iherbcleaner.tasks.OpenBankTask;
|
||||
import net.runelite.client.plugins.iherbcleaner.tasks.TimeoutTask;
|
||||
import net.runelite.client.plugins.iutils.iUtils;
|
||||
import net.runelite.client.ui.overlay.OverlayManager;
|
||||
import org.pf4j.Extension;
|
||||
|
||||
|
||||
@Extension
|
||||
@PluginDependency(iUtils.class)
|
||||
@PluginDescriptor(
|
||||
name = "iHerbCleaner",
|
||||
enabledByDefault = false,
|
||||
description = "Illumine - Herb Cleaner plugin",
|
||||
tags = {"illumine", "task", "herblore", "clean", "bot"},
|
||||
type = PluginType.MISCELLANEOUS
|
||||
)
|
||||
@Slf4j
|
||||
public class iHerbCleanerPlugin extends Plugin
|
||||
{
|
||||
@Inject
|
||||
private Injector injector;
|
||||
|
||||
@Inject
|
||||
private Client client;
|
||||
|
||||
@Inject
|
||||
private iHerbCleanerConfig config;
|
||||
|
||||
@Inject
|
||||
private OverlayManager overlayManager;
|
||||
|
||||
@Inject
|
||||
private iHerbCleanerOverlay overlay;
|
||||
|
||||
@Inject
|
||||
private iUtils utils;
|
||||
|
||||
@Inject
|
||||
public ChinBreakHandler chinBreakHandler;
|
||||
|
||||
@Inject
|
||||
private ConfigManager configManager;
|
||||
|
||||
private TaskSet tasks = new TaskSet();
|
||||
public static LocalPoint beforeLoc = new LocalPoint(0, 0);
|
||||
|
||||
MenuEntry targetMenu;
|
||||
Instant botTimer;
|
||||
Player player;
|
||||
|
||||
public static boolean startBot;
|
||||
public static long sleepLength;
|
||||
public static int tickLength;
|
||||
public static int timeout;
|
||||
public static String status = "starting...";
|
||||
|
||||
@Provides
|
||||
iHerbCleanerConfig provideConfig(ConfigManager configManager)
|
||||
{
|
||||
return configManager.getConfig(iHerbCleanerConfig.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void startUp()
|
||||
{
|
||||
chinBreakHandler.registerPlugin(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void shutDown()
|
||||
{
|
||||
resetVals();
|
||||
chinBreakHandler.unregisterPlugin(this);
|
||||
}
|
||||
|
||||
|
||||
private void loadTasks()
|
||||
{
|
||||
tasks.clear();
|
||||
tasks.addAll(
|
||||
injector.getInstance(TimeoutTask.class),
|
||||
injector.getInstance(MovingTask.class),
|
||||
injector.getInstance(CleanHerbTask.class),
|
||||
injector.getInstance(BankItemsTask.class),
|
||||
injector.getInstance(OpenBankTask.class)
|
||||
);
|
||||
}
|
||||
|
||||
public void resetVals()
|
||||
{
|
||||
log.debug("stopping iHerb Cleaner plugin");
|
||||
overlayManager.remove(overlay);
|
||||
chinBreakHandler.stopPlugin(this);
|
||||
startBot = false;
|
||||
botTimer = null;
|
||||
tasks.clear();
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
private void onConfigButtonPressed(ConfigButtonClicked configButtonClicked)
|
||||
{
|
||||
if (!configButtonClicked.getGroup().equalsIgnoreCase("iHerbCleaner"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
log.debug("button {} pressed!", configButtonClicked.getKey());
|
||||
if (configButtonClicked.getKey().equals("startButton"))
|
||||
{
|
||||
if (!startBot)
|
||||
{
|
||||
Player player = client.getLocalPlayer();
|
||||
if (client != null && player != null && client.getGameState() == GameState.LOGGED_IN)
|
||||
{
|
||||
log.info("starting Herb Cleaner plugin");
|
||||
loadTasks();
|
||||
startBot = true;
|
||||
chinBreakHandler.startPlugin(this);
|
||||
timeout = 0;
|
||||
targetMenu = null;
|
||||
botTimer = Instant.now();
|
||||
overlayManager.add(overlay);
|
||||
beforeLoc = client.getLocalPlayer().getLocalLocation();
|
||||
}
|
||||
else
|
||||
{
|
||||
log.info("Start logged in");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
resetVals();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void updateStats()
|
||||
{
|
||||
//templatePH = (int) getPerHour(totalBraceletCount);
|
||||
//coinsPH = (int) getPerHour(totalCoins - ((totalCoins / BRACELET_HA_VAL) * (unchargedBraceletCost + revEtherCost + natureRuneCost)));
|
||||
}
|
||||
|
||||
public long getPerHour(int quantity)
|
||||
{
|
||||
Duration timeSinceStart = Duration.between(botTimer, Instant.now());
|
||||
if (!timeSinceStart.isZero())
|
||||
{
|
||||
return (int) ((double) quantity * (double) Duration.ofHours(1).toMillis() / (double) timeSinceStart.toMillis());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
private void onGameTick(GameTick event)
|
||||
{
|
||||
if (!startBot || chinBreakHandler.isBreakActive(this))
|
||||
{
|
||||
return;
|
||||
}
|
||||
player = client.getLocalPlayer();
|
||||
if (client != null && player != null && client.getGameState() == GameState.LOGGED_IN)
|
||||
{
|
||||
if (chinBreakHandler.shouldBreak(this))
|
||||
{
|
||||
status = "Taking a break";
|
||||
chinBreakHandler.startBreak(this);
|
||||
timeout = 5;
|
||||
}
|
||||
if (timeout > 0)
|
||||
{
|
||||
timeout--;
|
||||
return;
|
||||
}
|
||||
Task task = tasks.getValidTask();
|
||||
|
||||
if (task != null)
|
||||
{
|
||||
status = task.getTaskDescription();
|
||||
task.onGameTick(event);
|
||||
}
|
||||
else
|
||||
{
|
||||
status = "Task not found";
|
||||
log.debug(status);
|
||||
}
|
||||
beforeLoc = player.getLocalLocation();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
package net.runelite.client.plugins.iherbcleaner.tasks;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
import javax.inject.Inject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.GameObject;
|
||||
import net.runelite.api.MenuEntry;
|
||||
import net.runelite.api.MenuOpcode;
|
||||
import net.runelite.api.events.GameTick;
|
||||
import net.runelite.client.plugins.iherbcleaner.Task;
|
||||
import net.runelite.client.plugins.iherbcleaner.iHerbCleanerPlugin;
|
||||
import static net.runelite.client.plugins.iherbcleaner.iHerbCleanerPlugin.startBot;
|
||||
import static net.runelite.client.plugins.iherbcleaner.iHerbCleanerPlugin.status;
|
||||
import net.runelite.client.plugins.iutils.ActionQueue;
|
||||
import net.runelite.client.plugins.iutils.BankUtils;
|
||||
import net.runelite.client.plugins.iutils.InventoryUtils;
|
||||
|
||||
@Slf4j
|
||||
public class BankItemsTask extends Task
|
||||
{
|
||||
|
||||
@Inject
|
||||
ActionQueue action;
|
||||
|
||||
@Inject
|
||||
InventoryUtils inventory;
|
||||
|
||||
@Inject
|
||||
BankUtils bank;
|
||||
|
||||
@Override
|
||||
public boolean validate()
|
||||
{
|
||||
return action.delayedActions.isEmpty() && !inventory.containsItem(config.herbID()) &&
|
||||
bank.isOpen();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTaskDescription()
|
||||
{
|
||||
return iHerbCleanerPlugin.status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGameTick(GameTick event)
|
||||
{
|
||||
int sleep = 0;
|
||||
if (!inventory.isEmpty())
|
||||
{
|
||||
status = "Depositing items";
|
||||
bank.depositAll();
|
||||
}
|
||||
else
|
||||
{
|
||||
status = "Withdrawing items";
|
||||
if (bank.contains(config.herbID(), 1))
|
||||
{
|
||||
bank.withdrawAllItem(config.herbID());
|
||||
}
|
||||
else
|
||||
{
|
||||
status = "Out of herbs to clean, stopping";
|
||||
utils.sendGameMessage(status);
|
||||
startBot = false;
|
||||
}
|
||||
}
|
||||
log.info(status);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
package net.runelite.client.plugins.iherbcleaner.tasks;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
import java.util.List;
|
||||
import javax.inject.Inject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.MenuEntry;
|
||||
import net.runelite.api.MenuOpcode;
|
||||
import net.runelite.api.Player;
|
||||
import net.runelite.api.events.GameTick;
|
||||
import net.runelite.api.widgets.WidgetInfo;
|
||||
import net.runelite.api.widgets.WidgetItem;
|
||||
import net.runelite.client.plugins.iherbcleaner.Task;
|
||||
import net.runelite.client.plugins.iherbcleaner.iHerbCleanerPlugin;
|
||||
import static net.runelite.client.plugins.iherbcleaner.iHerbCleanerPlugin.timeout;
|
||||
import net.runelite.client.plugins.iutils.ActionQueue;
|
||||
import net.runelite.client.plugins.iutils.InventoryUtils;
|
||||
import static net.runelite.client.plugins.iherbcleaner.iHerbCleanerPlugin.status;
|
||||
|
||||
@Slf4j
|
||||
public class CleanHerbTask extends Task
|
||||
{
|
||||
|
||||
@Inject
|
||||
ActionQueue action;
|
||||
|
||||
@Inject
|
||||
InventoryUtils inventory;
|
||||
|
||||
@Override
|
||||
public boolean validate()
|
||||
{
|
||||
return action.delayedActions.isEmpty() && inventory.containsItem(config.herbID());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTaskDescription()
|
||||
{
|
||||
return iHerbCleanerPlugin.status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGameTick(GameTick event)
|
||||
{
|
||||
status = "Starting herb cleaning";
|
||||
List<WidgetItem> herbs = inventory.getItems(List.of(config.herbID()));
|
||||
int sleep = 0;
|
||||
for (WidgetItem herb : herbs)
|
||||
{
|
||||
log.info("Adding herb: {}, delay time: {}", herb.getIndex(), sleep);
|
||||
entry = new MenuEntry("", "", herb.getId(), MenuOpcode.ITEM_FIRST_OPTION.getId(),
|
||||
herb.getIndex(), WidgetInfo.INVENTORY.getId(), true);
|
||||
sleep += (int) sleepDelay();
|
||||
herb.getCanvasBounds().getBounds();
|
||||
Rectangle rectangle = herb.getCanvasBounds().getBounds();
|
||||
utils.doActionMsTime(entry, rectangle, sleep);
|
||||
}
|
||||
log.info(status);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package net.runelite.client.plugins.iherbcleaner.tasks;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.Player;
|
||||
import net.runelite.api.events.GameTick;
|
||||
import net.runelite.client.plugins.iherbcleaner.Task;
|
||||
import net.runelite.client.plugins.iherbcleaner.iHerbCleanerPlugin;
|
||||
import static net.runelite.client.plugins.iherbcleaner.iHerbCleanerPlugin.beforeLoc;
|
||||
import static net.runelite.client.plugins.iherbcleaner.iHerbCleanerPlugin.timeout;
|
||||
|
||||
@Slf4j
|
||||
public class MovingTask extends Task
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean validate()
|
||||
{
|
||||
return playerUtils.isMoving(beforeLoc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTaskDescription()
|
||||
{
|
||||
return iHerbCleanerPlugin.status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGameTick(GameTick event)
|
||||
{
|
||||
Player player = client.getLocalPlayer();
|
||||
if (player != null)
|
||||
{
|
||||
playerUtils.handleRun(20, 30);
|
||||
timeout = tickDelay();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
package net.runelite.client.plugins.iherbcleaner.tasks;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
import java.util.List;
|
||||
import javax.inject.Inject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.GameObject;
|
||||
import net.runelite.api.MenuEntry;
|
||||
import net.runelite.api.MenuOpcode;
|
||||
import net.runelite.api.events.GameTick;
|
||||
import net.runelite.api.widgets.WidgetInfo;
|
||||
import net.runelite.api.widgets.WidgetItem;
|
||||
import net.runelite.client.plugins.iherbcleaner.Task;
|
||||
import net.runelite.client.plugins.iherbcleaner.iHerbCleanerPlugin;
|
||||
import static net.runelite.client.plugins.iherbcleaner.iHerbCleanerPlugin.status;
|
||||
import net.runelite.client.plugins.iutils.ActionQueue;
|
||||
import net.runelite.client.plugins.iutils.BankUtils;
|
||||
import net.runelite.client.plugins.iutils.InventoryUtils;
|
||||
|
||||
@Slf4j
|
||||
public class OpenBankTask extends Task
|
||||
{
|
||||
|
||||
@Inject
|
||||
ActionQueue action;
|
||||
|
||||
@Inject
|
||||
InventoryUtils inventory;
|
||||
|
||||
@Inject
|
||||
BankUtils bank;
|
||||
|
||||
@Override
|
||||
public boolean validate()
|
||||
{
|
||||
return action.delayedActions.isEmpty() && !inventory.containsItem(config.herbID()) &&
|
||||
!bank.isOpen();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTaskDescription()
|
||||
{
|
||||
return iHerbCleanerPlugin.status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGameTick(GameTick event)
|
||||
{
|
||||
GameObject bank = object.findNearestGameObject(config.bankID());
|
||||
if (bank != null)
|
||||
{
|
||||
status = "Opening bank";
|
||||
entry = new MenuEntry("", "", bank.getId(), MenuOpcode.GAME_OBJECT_SECOND_OPTION.getId(),
|
||||
bank.getSceneMinLocation().getX(), bank.getSceneMinLocation().getY(), false);
|
||||
Rectangle rectangle = (bank.getConvexHull() != null) ? bank.getConvexHull().getBounds() :
|
||||
new Rectangle(client.getCenterX() - 50, client.getCenterY() - 50, 100, 100);;
|
||||
utils.doActionMsTime(entry, rectangle, (int) sleepDelay());
|
||||
}
|
||||
else
|
||||
{
|
||||
status = "Bank not found";
|
||||
}
|
||||
log.info(status);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package net.runelite.client.plugins.iherbcleaner.tasks;
|
||||
|
||||
import net.runelite.api.events.GameTick;
|
||||
import net.runelite.client.plugins.iherbcleaner.Task;
|
||||
import static net.runelite.client.plugins.iherbcleaner.iHerbCleanerPlugin.timeout;
|
||||
|
||||
public class TimeoutTask extends Task
|
||||
{
|
||||
@Override
|
||||
public boolean validate() { return timeout > 0; }
|
||||
|
||||
@Override
|
||||
public String getTaskDescription()
|
||||
{
|
||||
return "Timeout: " + timeout;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGameTick(GameTick event)
|
||||
{
|
||||
timeout--;
|
||||
}
|
||||
}
|
|
@ -5,8 +5,6 @@ import lombok.extern.slf4j.Slf4j;
|
|||
import net.runelite.api.Client;
|
||||
import net.runelite.api.MenuEntry;
|
||||
import net.runelite.api.events.GameTick;
|
||||
import static net.runelite.client.plugins.itasktemplate.iTaskTemplatePlugin.sleepLength;
|
||||
import static net.runelite.client.plugins.itasktemplate.iTaskTemplatePlugin.tickLength;
|
||||
import net.runelite.client.plugins.iutils.CalculationUtils;
|
||||
import net.runelite.client.plugins.iutils.MenuUtils;
|
||||
import net.runelite.client.plugins.iutils.MouseUtils;
|
||||
|
@ -51,14 +49,14 @@ public abstract class Task
|
|||
|
||||
public long sleepDelay()
|
||||
{
|
||||
sleepLength = calc.randomDelay(config.sleepWeightedDistribution(), config.sleepMin(), config.sleepMax(), config.sleepDeviation(), config.sleepTarget());
|
||||
return sleepLength;
|
||||
iTaskTemplatePlugin.sleepLength = calc.randomDelay(config.sleepWeightedDistribution(), config.sleepMin(), config.sleepMax(), config.sleepDeviation(), config.sleepTarget());
|
||||
return iTaskTemplatePlugin.sleepLength;
|
||||
}
|
||||
|
||||
public int tickDelay()
|
||||
{
|
||||
tickLength = (int) calc.randomDelay(config.tickDelayWeightedDistribution(), config.tickDelayMin(), config.tickDelayMax(), config.tickDelayDeviation(), config.tickDelayTarget());
|
||||
return tickLength;
|
||||
iTaskTemplatePlugin.tickLength = (int) calc.randomDelay(config.tickDelayWeightedDistribution(), config.tickDelayMin(), config.tickDelayMax(), config.tickDelayDeviation(), config.tickDelayTarget());
|
||||
return iTaskTemplatePlugin.tickLength;
|
||||
}
|
||||
|
||||
public String getTaskDescription()
|
||||
|
|
|
@ -5,8 +5,6 @@ import net.runelite.api.Player;
|
|||
import net.runelite.api.events.GameTick;
|
||||
import net.runelite.client.plugins.itasktemplate.Task;
|
||||
import net.runelite.client.plugins.itasktemplate.iTaskTemplatePlugin;
|
||||
import static net.runelite.client.plugins.itasktemplate.iTaskTemplatePlugin.beforeLoc;
|
||||
import static net.runelite.client.plugins.itasktemplate.iTaskTemplatePlugin.timeout;
|
||||
|
||||
@Slf4j
|
||||
public class MovingTask extends Task
|
||||
|
@ -15,7 +13,7 @@ public class MovingTask extends Task
|
|||
@Override
|
||||
public boolean validate()
|
||||
{
|
||||
return playerUtils.isMoving(beforeLoc);
|
||||
return playerUtils.isMoving(iTaskTemplatePlugin.beforeLoc);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -31,7 +29,7 @@ public class MovingTask extends Task
|
|||
if (player != null)
|
||||
{
|
||||
playerUtils.handleRun(20, 30);
|
||||
timeout = tickDelay();
|
||||
iTaskTemplatePlugin.timeout = tickDelay();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,22 +2,22 @@ package net.runelite.client.plugins.itasktemplate.tasks;
|
|||
|
||||
import net.runelite.api.events.GameTick;
|
||||
import net.runelite.client.plugins.itasktemplate.Task;
|
||||
import static net.runelite.client.plugins.itasktemplate.iTaskTemplatePlugin.timeout;
|
||||
import net.runelite.client.plugins.itasktemplate.iTaskTemplatePlugin;
|
||||
|
||||
public class TimeoutTask extends Task
|
||||
{
|
||||
@Override
|
||||
public boolean validate() { return timeout > 0; }
|
||||
public boolean validate() { return iTaskTemplatePlugin.timeout > 0; }
|
||||
|
||||
@Override
|
||||
public String getTaskDescription()
|
||||
{
|
||||
return "Timeout: " + timeout;
|
||||
return "Timeout: " + iTaskTemplatePlugin.timeout;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGameTick(GameTick event)
|
||||
{
|
||||
timeout--;
|
||||
iTaskTemplatePlugin.timeout--;
|
||||
}
|
||||
}
|
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
|
@ -29,6 +29,7 @@ include(":botutils")
|
|||
include(":iutils")
|
||||
include("iblackjack")
|
||||
include(":icombinationrunecrafter")
|
||||
include("iherbcleaner")
|
||||
include(":imagiccaster")
|
||||
include(":imenudebugger")
|
||||
include(":ipowerfighter")
|
||||
|
|
Loading…
Reference in New Issue