Initial commit

This commit is contained in:
2022-01-08 19:46:18 +01:00
commit 57ba5a5858
207 changed files with 12402 additions and 0 deletions

View File

@ -0,0 +1,64 @@
/*
* Copyright (c) 2018, Andrew EP | ElPinche256 <https://github.com/ElPinche256>
* 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 io.reisub.openosrs.woodcutter;
import net.runelite.client.config.Button;
import net.runelite.client.config.Config;
import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem;
@ConfigGroup("ChaosWoodcutterConfig")
public interface WoodcutterConfig extends Config {
@ConfigItem(
keyName = "burnLogs",
name = "Burn logs",
description = "Enable to burn logs",
position = 90
)
default boolean burnLogs() {
return true;
}
@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 = "Start the script",
position = 100
)
default Button startButton() {
return new Button();
}
}

View File

@ -0,0 +1,75 @@
package io.reisub.openosrs.woodcutter;
import com.google.inject.Provides;
import io.reisub.openosrs.util.Task;
import io.reisub.openosrs.util.Util;
import io.reisub.openosrs.woodcutter.tasks.Chop;
import io.reisub.openosrs.woodcutter.tasks.Drop;
import lombok.extern.slf4j.Slf4j;
import net.runelite.api.Client;
import net.runelite.api.events.ConfigButtonClicked;
import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.Subscribe;
import net.runelite.client.plugins.PluginDependency;
import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.plugins.iutils.iUtils;
import net.runelite.client.plugins.iutils.scripts.iScript;
import org.pf4j.Extension;
import javax.inject.Inject;
import java.util.ArrayList;
import java.util.List;
@Extension
@PluginDependency(Util.class)
@PluginDependency(iUtils.class)
@PluginDescriptor(
name = "Chaos Woodcutter",
description = "Cuts wood",
enabledByDefault = false
)
@Slf4j
public class WoodcutterPlugin extends iScript {
@Inject
private Client client;
private List<Task> tasks;
@Provides
WoodcutterConfig provideConfig(ConfigManager configManager) {
return configManager.getConfig(WoodcutterConfig.class);
}
@Override
protected void loop() {
for (Task t : tasks) {
if (t.validate()) {
t.execute();
}
}
game.tickDelay();
}
@Override
protected void onStart() {
log.info("Starting Chaos Woodcutter");
tasks = new ArrayList<>();
tasks.add(injector.getInstance(Chop.class));
tasks.add(injector.getInstance(Drop.class));
}
@Override
protected void onStop() {
log.info("Stopping Chaos Woodcutter");
tasks.clear();
}
@Subscribe
private void onConfigButtonPressed(ConfigButtonClicked configButtonClicked) {
if (configButtonClicked.getKey().equals("startButton")) {
execute();
}
}
}

View File

@ -0,0 +1,39 @@
package io.reisub.openosrs.woodcutter.tasks;
import io.reisub.openosrs.util.Task;
import net.runelite.client.plugins.iutils.game.iObject;
public class Chop extends Task {
private iObject tree;
@Override
public String getStatus() {
return "Chopping";
}
@Override
public boolean validate() {
if (!game.localPlayer().isIdle() || game.inventory().full()) {
return false;
}
tree = game.objects().withName("Tree").within(9).nearestPath();
if (tree == null) {
tree = game.objects().withName("Tree").nearest();
}
return tree != null;
}
@Override
public void execute() {
tree.interact("Chop down");
if (!game.waitUntil(() -> !game.localPlayer().isIdle(), 5)) {
logWarn("Failed to start chopping tree");
}
tree = null;
}
}

View File

@ -0,0 +1,31 @@
package io.reisub.openosrs.woodcutter.tasks;
import io.reisub.openosrs.util.Task;
import io.reisub.openosrs.woodcutter.WoodcutterConfig;
import javax.inject.Inject;
public class Drop extends Task {
@Inject
private WoodcutterConfig config;
@Override
public String getStatus() {
return "Dropping";
}
@Override
public boolean validate() {
return !config.burnLogs()
&& game.inventory().full()
&& game.inventory().withNamePart("logs", "Logs").findAny().isPresent();
}
@Override
public void execute() {
game.inventory().withNamePart("logs", "Logs").forEach((item -> {
item.interact("Drop");
game.sleepDelay();
}));
}
}

View File

@ -0,0 +1,52 @@
/*
* 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 = "0.0.1"
project.extra["PluginName"] = "Chaos Woodcutter" // This is the name that is used in the external plugin manager panel
project.extra["PluginDescription"] = "Chops wood" // This is the description that is used in the external plugin manager panel
dependencies {
compileOnly(project(":util"))
}
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-Description" to project.extra["PluginDescription"],
"Plugin-Dependencies" to
arrayOf(
nameToId("Chaos Util"),
nameToId("iUtils")
).joinToString(),
"Plugin-License" to project.extra["PluginLicense"]
))
}
}
}