Add various new scripts

This commit is contained in:
2022-01-19 12:35:11 +01:00
parent fb86f97efa
commit 78786709eb
84 changed files with 2674 additions and 76 deletions

View File

@ -2,23 +2,26 @@ package io.reisub.openosrs.autodropper;
import com.google.inject.Provides;
import io.reisub.openosrs.util.Util;
import io.reisub.openosrs.util.enums.Activity;
import lombok.extern.slf4j.Slf4j;
import net.runelite.api.GameState;
import net.runelite.api.events.ConfigButtonClicked;
import net.runelite.api.events.ItemContainerChanged;
import net.runelite.client.config.ConfigManager;
import net.runelite.client.config.Keybind;
import net.runelite.client.eventbus.Subscribe;
import net.runelite.client.events.ConfigChanged;
import net.runelite.client.input.KeyListener;
import net.runelite.client.input.KeyManager;
import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDependency;
import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.plugins.iutils.game.Game;
import net.runelite.client.plugins.iutils.game.InventoryItem;
import net.runelite.client.plugins.iutils.iUtils;
import org.pf4j.Extension;
import javax.inject.Inject;
import java.util.List;
import java.awt.event.KeyEvent;
import java.util.Locale;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
@ -33,7 +36,7 @@ import java.util.concurrent.TimeUnit;
enabledByDefault = false
)
@Slf4j
public class Autodropper extends Plugin {
public class Autodropper extends Plugin implements KeyListener {
@SuppressWarnings("unused")
@Inject
private Game game;
@ -42,6 +45,10 @@ public class Autodropper extends Plugin {
@Inject
private Config config;
@SuppressWarnings("unused")
@Inject
private KeyManager keyManager;
@SuppressWarnings("unused")
@Provides
Config provideConfig(ConfigManager configManager) {
@ -56,6 +63,10 @@ public class Autodropper extends Plugin {
protected void startUp() {
log.info("Starting Chaos Autodropper");
itemNames = parseNames();
itemIds = parseIds();
keyManager.registerKeyListener(this);
executor = Executors.newSingleThreadScheduledExecutor();
}
@ -63,23 +74,20 @@ public class Autodropper extends Plugin {
protected void shutDown() {
log.info("Stopping Chaos Autodropper");
keyManager.unregisterKeyListener(this);
executor.shutdownNow();
}
@SuppressWarnings("unused")
@Subscribe
private void onItemContainerChanged(ItemContainerChanged event) {
if (game.client().getGameState() != GameState.LOGGED_IN) return;
if (game.client().getGameState() != GameState.LOGGED_IN || config.dropMethod() == DropMethod.NONE) return;
if (!config.dropWhileItemSelected() && game.client().isItemSelected() == 1) return;
if (itemNames == null) itemNames = parseNames();
if (itemIds == null) itemIds = parseIds();
executor.schedule(() -> {
game.inventory().withName(itemNames).drop();
game.inventory().withId(itemIds).drop();
}, 0, TimeUnit.MILLISECONDS);
if (config.dropMethod() == DropMethod.ON_ADD) {
drop();
} else if (config.dropMethod() == DropMethod.ON_FULL_INVENTORY && game.inventory().full()) {
drop();
}
}
@Subscribe
@ -105,10 +113,18 @@ public class Autodropper extends Plugin {
}
private String[] parseNames() {
String[] names = config.itemNames().split(";");
String[] itemNames = config.itemNames().split(";");
String[] seedNames = config.seedNames().split(";");
String[] names = new String[itemNames.length + seedNames.length];
for (int i = 0; i < names.length; i++) {
names[i] = names[i].trim();
int i = 0;
for (String name : itemNames) {
names[i++] = name.trim();
}
for (String name : seedNames) {
names[i++] = name.trim();
}
return names;
@ -126,4 +142,26 @@ public class Autodropper extends Plugin {
return ids;
}
@Override
public void keyTyped(KeyEvent e) {}
@Override
public void keyPressed(KeyEvent e) {
if (config.dropEnableHotkey() && config.dropHotkey().matches(e)) {
drop();
}
}
@Override
public void keyReleased(KeyEvent e) {}
private void drop() {
if (!config.dropWhileItemSelected() && game.client().isItemSelected() == 1) return;
executor.schedule(() -> {
game.inventory().withName(itemNames).drop();
game.inventory().withId(itemIds).drop();
}, 0, TimeUnit.MILLISECONDS);
}
}

View File

@ -24,9 +24,11 @@
*/
package io.reisub.openosrs.autodropper;
import net.runelite.client.config.Button;
import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem;
import io.reisub.openosrs.util.enums.Activity;
import net.runelite.client.config.*;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
@ConfigGroup("chaosautodropper")
@ -47,14 +49,57 @@ public interface Config extends net.runelite.client.config.Config {
)
default String itemIds() { return ""; }
@ConfigItem(
keyName = "dropMethod",
name = "Auto drop method",
description = "Choose the automatic drop method.",
position = 3
)
default DropMethod dropMethod() { return DropMethod.NONE; }
@ConfigItem(
keyName = "dropEnableHotkey",
name = "Enable hotkey",
description = "Enable dropping on hotkey.",
position = 4
)
default boolean dropEnableHotkey() { return false; }
@ConfigItem(
keyName = "dropHotkey",
name = "Hotkey",
description = "Choose the hotkey.",
hidden = true,
unhide = "dropEnableHotkey",
position = 5
)
default Keybind dropHotkey() { return new Keybind(KeyEvent.VK_A, InputEvent.CTRL_DOWN_MASK); }
@ConfigItem(
keyName = "dropWhileItemSelected",
name = "Drop while item selected",
description = "If enabled, this will drop items even if an item is selected, resulting in deselecting the item.",
position = 2
position = 6
)
default boolean dropWhileItemSelected() { return false; }
@ConfigSection(
keyName = "seedsConfig",
name = "Seeds configuration",
description = "Seeds configuration",
position = 70
)
String seedsConfig = "seedsConfig";
@ConfigItem(
keyName = "seedNames",
name = "Seed names",
description = "List of seeds to drop. This works the same as regular items but is an extra field to not clog the regular one.",
position = 71
)
default String seedNames() { return "Potato seed; Onion seed; Cabbage seed; Tomato seed; Sweetcorn seed; Marigold seed; Rosemary seed; Nasturtium seed; Woad seed; Redberry seed; Cadavaberry seed; Dwellberry seed; Acorn; Apple tree seed; Banana tree seed"; }
@ConfigItem(
keyName = "reloadButton",
name = "Reload configuration",

View File

@ -0,0 +1,7 @@
package io.reisub.openosrs.autodropper;
public enum DropMethod {
NONE,
ON_ADD,
ON_FULL_INVENTORY;
}