Initial commit
This commit is contained in:
52
shopper/shopper.gradle.kts
Normal file
52
shopper/shopper.gradle.kts
Normal 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 = "1.0.0"
|
||||
|
||||
project.extra["PluginName"] = "Chaos Shopper"
|
||||
project.extra["PluginDescription"] = "Hops worlds and buys stuff from NPCs"
|
||||
|
||||
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"]
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
298
shopper/src/main/java/io/reisub/openosrs/shopper/Config.java
Normal file
298
shopper/src/main/java/io/reisub/openosrs/shopper/Config.java
Normal file
@ -0,0 +1,298 @@
|
||||
/*
|
||||
* 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.shopper;
|
||||
|
||||
import net.runelite.client.config.Button;
|
||||
import net.runelite.client.config.ConfigGroup;
|
||||
import net.runelite.client.config.ConfigItem;
|
||||
import net.runelite.client.config.ConfigSection;
|
||||
|
||||
@ConfigGroup("ChaosShopperConfig")
|
||||
|
||||
public interface Config extends net.runelite.client.config.Config {
|
||||
@ConfigItem(
|
||||
keyName = "npcName",
|
||||
name = "NPC Name",
|
||||
description = "Name of the NPC to buy from",
|
||||
position = 0
|
||||
)
|
||||
default String npcName() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@ConfigSection(
|
||||
keyName = "itemOne",
|
||||
name = "Item 1",
|
||||
description = "Configure the item to buy",
|
||||
position = 10
|
||||
)
|
||||
String itemOne = "itemOne";
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "itemOneEnabled",
|
||||
name = "Enable",
|
||||
description = "Enable the buying of this item",
|
||||
position = 11
|
||||
)
|
||||
default boolean itemOneEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "itemOneName",
|
||||
name = "Name",
|
||||
description = "Name of the item",
|
||||
position = 12
|
||||
)
|
||||
default String itemOneName() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "itemOneAmount",
|
||||
name = "Amount",
|
||||
description = "Amount of the item to buy",
|
||||
position = 13
|
||||
)
|
||||
default int itemOneAmount() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "itemOneMinInStore",
|
||||
name = "Min in store",
|
||||
description = "Amount to keep in store to prevent overpaying",
|
||||
position = 14
|
||||
)
|
||||
default int itemOneMinInStore() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ConfigSection(
|
||||
keyName = "itemTwo",
|
||||
name = "Item 2",
|
||||
description = "Configure the item to buy",
|
||||
closedByDefault = true,
|
||||
position = 20
|
||||
)
|
||||
String itemTwo = "itemTwo";
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "itemTwoEnabled",
|
||||
name = "Enable",
|
||||
description = "Enable the buying of this item",
|
||||
position = 21
|
||||
)
|
||||
default boolean itemTwoEnabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "itemTwoName",
|
||||
name = "Name",
|
||||
description = "Name of the item",
|
||||
position = 22
|
||||
)
|
||||
default String itemTwoName() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "itemTwoAmount",
|
||||
name = "Amount",
|
||||
description = "Amount of the item to buy",
|
||||
position = 23
|
||||
)
|
||||
default int itemTwoAmount() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "itemTwoMinInStore",
|
||||
name = "Min in store",
|
||||
description = "Amount to keep in store to prevent overpaying",
|
||||
position = 24
|
||||
)
|
||||
default int itemTwoMinInStore() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ConfigSection(
|
||||
keyName = "itemThree",
|
||||
name = "Item 3",
|
||||
description = "Configure the item to buy",
|
||||
closedByDefault = true,
|
||||
position = 30
|
||||
)
|
||||
String itemThree = "itemThree";
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "itemThreeEnabled",
|
||||
name = "Enable",
|
||||
description = "Enable the buying of this item",
|
||||
position = 31
|
||||
)
|
||||
default boolean itemThreeEnabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "itemThreeName",
|
||||
name = "Name",
|
||||
description = "Name of the item",
|
||||
position = 32
|
||||
)
|
||||
default String itemThreeName() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "itemThreeAmount",
|
||||
name = "Amount",
|
||||
description = "Amount of the item to buy",
|
||||
position = 33
|
||||
)
|
||||
default int itemThreeAmount() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "itemThreeMinInStore",
|
||||
name = "Min in store",
|
||||
description = "Amount to keep in store to prevent overpaying",
|
||||
position = 34
|
||||
)
|
||||
default int itemThreeMinInStore() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ConfigSection(
|
||||
keyName = "itemFour",
|
||||
name = "Item 4",
|
||||
description = "Configure the item to buy",
|
||||
closedByDefault = true,
|
||||
position = 40
|
||||
)
|
||||
String itemFour = "itemFour";
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "itemFourEnabled",
|
||||
name = "Enable",
|
||||
description = "Enable the buying of this item",
|
||||
position = 41
|
||||
)
|
||||
default boolean itemFourEnabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "itemFourName",
|
||||
name = "Name",
|
||||
description = "Name of the item",
|
||||
position = 42
|
||||
)
|
||||
default String itemFourName() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "itemFourAmount",
|
||||
name = "Amount",
|
||||
description = "Amount of the item to buy",
|
||||
position = 43
|
||||
)
|
||||
default int itemFourAmount() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "itemFourMinInStore",
|
||||
name = "Min in store",
|
||||
description = "Amount to keep in store to prevent overpaying",
|
||||
position = 44
|
||||
)
|
||||
default int itemFourMinInStore() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ConfigSection(
|
||||
keyName = "itemFive",
|
||||
name = "Item 5",
|
||||
description = "Configure the item to buy",
|
||||
closedByDefault = true,
|
||||
position = 50
|
||||
)
|
||||
String itemFive = "itemFive";
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "itemFiveEnabled",
|
||||
name = "Enable",
|
||||
description = "Enable the buying of this item",
|
||||
position = 51
|
||||
)
|
||||
default boolean itemFiveEnabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "itemFiveName",
|
||||
name = "Name",
|
||||
description = "Name of the item",
|
||||
position = 52
|
||||
)
|
||||
default String itemFiveName() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "itemFiveAmount",
|
||||
name = "Amount",
|
||||
description = "Amount of the item to buy",
|
||||
position = 53
|
||||
)
|
||||
default int itemFiveAmount() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "itemFiveMinInStore",
|
||||
name = "Min in store",
|
||||
description = "Amount to keep in store to prevent overpaying",
|
||||
position = 54
|
||||
)
|
||||
default int itemFiveMinInStore() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "startButton",
|
||||
name = "Start/Stop",
|
||||
description = "Start the script",
|
||||
position = 100
|
||||
)
|
||||
default Button startButton() {
|
||||
return new Button();
|
||||
}
|
||||
}
|
16
shopper/src/main/java/io/reisub/openosrs/shopper/Item.java
Normal file
16
shopper/src/main/java/io/reisub/openosrs/shopper/Item.java
Normal file
@ -0,0 +1,16 @@
|
||||
package io.reisub.openosrs.shopper;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@AllArgsConstructor
|
||||
public class Item {
|
||||
@Getter
|
||||
private final String name;
|
||||
|
||||
@Getter
|
||||
private final int amount;
|
||||
|
||||
@Getter
|
||||
private final int minInShop;
|
||||
}
|
109
shopper/src/main/java/io/reisub/openosrs/shopper/Shopper.java
Normal file
109
shopper/src/main/java/io/reisub/openosrs/shopper/Shopper.java
Normal file
@ -0,0 +1,109 @@
|
||||
package io.reisub.openosrs.shopper;
|
||||
|
||||
import com.google.inject.Provides;
|
||||
import io.reisub.openosrs.util.Task;
|
||||
import io.reisub.openosrs.util.Util;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.events.ConfigButtonClicked;
|
||||
import net.runelite.api.mixins.Inject;
|
||||
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 java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Extension
|
||||
@PluginDependency(Util.class)
|
||||
@PluginDependency(iUtils.class)
|
||||
@PluginDescriptor(
|
||||
name = "Chaos Shopper",
|
||||
description = "Hops worlds and buys stuff from NPCs",
|
||||
enabledByDefault = false
|
||||
)
|
||||
@Slf4j
|
||||
public class Shopper extends iScript {
|
||||
@Inject
|
||||
private Config config;
|
||||
|
||||
private List<Task> tasks;
|
||||
|
||||
@Getter
|
||||
private List<Item> items;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean hop;
|
||||
|
||||
@Provides
|
||||
@SuppressWarnings("unused")
|
||||
Config provideConfig(ConfigManager configManager) {
|
||||
return configManager.getConfig(Config.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 Shopper");
|
||||
|
||||
loadItems();
|
||||
|
||||
tasks = new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
log.info("Stopping Chaos Shopper");
|
||||
if (tasks != null) {
|
||||
tasks.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
@SuppressWarnings("unused")
|
||||
private void onConfigButtonPressed(ConfigButtonClicked configButtonClicked) {
|
||||
if (configButtonClicked.getKey().equals("startButton")) {
|
||||
execute();
|
||||
}
|
||||
}
|
||||
|
||||
private void loadItems() {
|
||||
if (config.itemOneEnabled()) {
|
||||
items.add(new Item(config.itemOneName(), config.itemOneAmount(), config.itemOneMinInStore()));
|
||||
}
|
||||
|
||||
if (config.itemTwoEnabled()) {
|
||||
items.add(new Item(config.itemTwoName(), config.itemTwoAmount(), config.itemTwoMinInStore()));
|
||||
}
|
||||
|
||||
if (config.itemThreeEnabled()) {
|
||||
items.add(new Item(config.itemThreeName(), config.itemThreeAmount(), config.itemThreeMinInStore()));
|
||||
}
|
||||
|
||||
if (config.itemFourEnabled()) {
|
||||
items.add(new Item(config.itemFourName(), config.itemFourAmount(), config.itemFourMinInStore()));
|
||||
}
|
||||
|
||||
if (config.itemFiveEnabled()) {
|
||||
items.add(new Item(config.itemFiveName(), config.itemFiveAmount(), config.itemFiveMinInStore()));
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package io.reisub.openosrs.shopper.tasks;
|
||||
|
||||
import io.reisub.openosrs.shopper.Shopper;
|
||||
import io.reisub.openosrs.util.Task;
|
||||
import net.runelite.api.mixins.Inject;
|
||||
import net.runelite.api.widgets.WidgetInfo;
|
||||
import net.runelite.client.plugins.iutils.game.iWidget;
|
||||
|
||||
public class Buy extends Task {
|
||||
@Inject
|
||||
private Shopper plugin;
|
||||
|
||||
@Override
|
||||
public String getStatus() {
|
||||
return "Buying";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validate() {
|
||||
iWidget shop = game.widget(WidgetInfo.SHOP_ITEMS_CONTAINER);
|
||||
|
||||
return shop != null
|
||||
&& !shop.hidden()
|
||||
&& !game.inventory().full();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user