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,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 Autodropper" // This is the name that is used in the external plugin manager panel
project.extra["PluginDescription"] = "Automatically drops stuff" // 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"]
))
}
}
}

View File

@ -0,0 +1,129 @@
package io.reisub.openosrs.autodropper;
import com.google.inject.Provides;
import io.reisub.openosrs.util.Util;
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.eventbus.Subscribe;
import net.runelite.client.events.ConfigChanged;
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.util.Locale;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
@Extension
@PluginDependency(Util.class)
@PluginDependency(iUtils.class)
@PluginDescriptor(
name = "Chaos Autodropper",
description = "Automatically drops stuff",
enabledByDefault = false
)
@Slf4j
public class Autodropper extends Plugin {
@SuppressWarnings("unused")
@Inject
private Game game;
@SuppressWarnings("unused")
@Inject
private Config config;
@SuppressWarnings("unused")
@Provides
Config provideConfig(ConfigManager configManager) {
return configManager.getConfig(Config.class);
}
private ScheduledExecutorService executor;
private String[] itemNames;
private int[] itemIds;
@Override
protected void startUp() {
log.info("Starting Chaos Autodropper");
executor = Executors.newSingleThreadScheduledExecutor();
}
@Override
protected void shutDown() {
log.info("Stopping Chaos Autodropper");
executor.shutdownNow();
}
@SuppressWarnings("unused")
@Subscribe
private void onItemContainerChanged(ItemContainerChanged event) {
if (game.client().getGameState() != GameState.LOGGED_IN) 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);
}
@Subscribe
@SuppressWarnings("unused")
private void onConfigChanged(ConfigChanged event) {
String name = this.getName().replaceAll(" ", "").toLowerCase(Locale.ROOT);
if (event.getGroup().equals(name) && event.getKey().startsWith("item")) {
itemNames = parseNames();
itemIds = parseIds();
}
}
@SuppressWarnings("unused")
@Subscribe
private void onConfigButtonPressed(ConfigButtonClicked event) {
String name = this.getName().replaceAll(" ", "").toLowerCase(Locale.ROOT);
if (event.getGroup().equals(name) && event.getKey().equals("reloadButton")) {
itemNames = parseNames();
itemIds = parseIds();
}
}
private String[] parseNames() {
String[] names = config.itemNames().split(";");
for (int i = 0; i < names.length; i++) {
names[i] = names[i].trim();
}
return names;
}
private int[] parseIds() {
if (config.itemIds().equals("")) return new int[]{};
String[] idsStr = config.itemIds().split(";");
int[] ids = new int[idsStr.length];
for (int i = 0; i < idsStr.length; i++) {
ids[i] = Integer.parseInt(idsStr[i].trim());
}
return ids;
}
}

View File

@ -0,0 +1,65 @@
/*
* 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.autodropper;
import net.runelite.client.config.Button;
import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem;
@ConfigGroup("chaosautodropper")
public interface Config extends net.runelite.client.config.Config {
@ConfigItem(
keyName = "itemNames",
name = "Item names",
description = "List of item names, separated with a semicolon.",
position = 0
)
default String itemNames() { return "Empty plant pot"; }
@ConfigItem(
keyName = "itemIds",
name = "Item IDs",
description = "List of item IDs, separated with a semicolon. Useful if you want to differentiate between 2 items with the same name.",
position = 1
)
default String itemIds() { return ""; }
@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
)
default boolean dropWhileItemSelected() { return false; }
@ConfigItem(
keyName = "reloadButton",
name = "Reload configuration",
description = "Force reload the configuration.",
position = 100
)
default Button reloadButton() { return new Button(); }
}