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,44 @@
/*
* 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.test;
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("ChaosTestConfig")
public interface TestConfig extends Config {
@ConfigItem(
keyName = "startButton",
name = "Start/Stop",
description = "Start the script",
position = 100
)
default Button startButton() {
return new Button();
}
}

View File

@ -0,0 +1,107 @@
package io.reisub.openosrs.test;
import com.google.inject.Provides;
import io.reisub.openosrs.test.tasks.Test;
import io.reisub.openosrs.util.Task;
import io.reisub.openosrs.util.Util;
import lombok.extern.slf4j.Slf4j;
import net.runelite.api.events.*;
import net.runelite.api.widgets.WidgetInfo;
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.game.iWidget;
import net.runelite.client.plugins.iutils.iUtils;
import net.runelite.client.plugins.iutils.scripts.iScript;
import org.pf4j.Extension;
import java.util.ArrayList;
import java.util.List;
@Extension
@PluginDependency(Util.class)
@PluginDependency(iUtils.class)
@PluginDescriptor(
name = "Chaos Test",
description = "Plugin for testing",
enabledByDefault = false
)
@Slf4j
public class TestPlugin extends iScript {
private List<Task> tasks;
@Provides
TestConfig provideConfig(ConfigManager configManager) {
return configManager.getConfig(TestConfig.class);
}
@Override
protected void loop() {
for (Task t : tasks) {
if (t.validate()) {
log.info(t.getStatus());
t.execute();
break;
}
}
game.sleepDelay();
}
@Override
protected void onStart() {
log.info("Starting Chaos Test");
log.info("selected itemt slot: " + game.client.getSelectedItemSlot());
log.info("is item selected: " + game.client().isItemSelected());
tasks = new ArrayList<>();
tasks.add(injector.getInstance(Test.class));
}
@Override
protected void onStop() {
log.info("Stopping Chaos Test");
if (tasks != null) {
tasks.clear();
}
}
@Subscribe
private void onConfigButtonPressed(ConfigButtonClicked configButtonClicked) {
if (configButtonClicked.getKey().equals("startButton")) {
execute();
}
}
@Subscribe
private void onScriptPreFired(ScriptPreFired event) {
// int id = event.getScriptId();
// if (id > 1000 || id == 900 || id == 100 || id == 44) return;
// if (event.getScriptEvent() == null) return;
// log.info("id: " + event.getScriptId());
}
@Subscribe
private void onAnimationChanged(AnimationChanged event) {
// if (event.getActor() != null) {
// log.info("actor: " + event.getActor().getName());
// log.info("id: " + event.getActor().getAnimation());
// }
}
@Subscribe
private void onProjectileMoved(ProjectileMoved event) {
// if (event.getProjectile().getInteracting() != null) {
// log.info("projectile interacting: " + event.getProjectile().getInteracting().getName());
// log.info("projectile id: " + event.getProjectile().getId());
// }
}
@Subscribe
private void onHitsplatApplied(HitsplatApplied event) {
}
}

View File

@ -0,0 +1,36 @@
package io.reisub.openosrs.test.tasks;
import io.reisub.openosrs.util.Task;
import net.runelite.api.GameState;
import net.runelite.client.plugins.iutils.scene.Position;
import net.runelite.client.plugins.iutils.ui.Chatbox;
public class Test extends Task {
private long last = System.currentTimeMillis();
@Override
public String getStatus() {
return "Running test task";
}
@Override
public boolean validate() {
//return false;
return System.currentTimeMillis() > last + 5000;
}
@Override
public void execute() {
log("running test task");
last = System.currentTimeMillis();
log("state: " + chatbox.chatState());
if (chatbox.chatState() == Chatbox.ChatState.OPTIONS_CHAT) {
log("choosing option");
chatbox.chooseOption(1);
game.tick(3);
}
}
}

52
test/test.gradle.kts Normal file
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 Test" // This is the name that is used in the external plugin manager panel
project.extra["PluginDescription"] = "Plugin for testing" // 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"]
))
}
}
}