Initial commit
This commit is contained in:
52
glassblower/glassblower.gradle.kts
Normal file
52
glassblower/glassblower.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 Glassblower" // This is the name that is used in the external plugin manager panel
|
||||
project.extra["PluginDescription"] = "Huffs and puffs" // 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"]
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
/*
|
||||
* 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.glassblower;
|
||||
|
||||
import net.runelite.client.config.Button;
|
||||
import net.runelite.client.config.ConfigGroup;
|
||||
import net.runelite.client.config.ConfigItem;
|
||||
|
||||
@ConfigGroup("chaosglassblower")
|
||||
|
||||
public interface Config extends net.runelite.client.config.Config {
|
||||
@ConfigItem(
|
||||
keyName = "targetProduct",
|
||||
name = "Blow",
|
||||
description = "Choose what to blow.",
|
||||
position = 0
|
||||
)
|
||||
default Product targetProduct() { return Product.LANTERN_LENS; }
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "startButton",
|
||||
name = "Start/Stop",
|
||||
description = "Start the script",
|
||||
position = 100
|
||||
)
|
||||
default Button startButton() {
|
||||
return new Button();
|
||||
}
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
package io.reisub.openosrs.glassblower;
|
||||
|
||||
import com.google.inject.Provides;
|
||||
import io.reisub.openosrs.glassblower.tasks.Blow;
|
||||
import io.reisub.openosrs.glassblower.tasks.HandleBank;
|
||||
import io.reisub.openosrs.glassblower.tasks.PickupSeed;
|
||||
import io.reisub.openosrs.util.enums.Activity;
|
||||
import io.reisub.openosrs.util.CScript;
|
||||
import io.reisub.openosrs.util.Util;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.AnimationID;
|
||||
import net.runelite.api.GameState;
|
||||
import net.runelite.api.Skill;
|
||||
import net.runelite.api.events.AnimationChanged;
|
||||
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 org.pf4j.Extension;
|
||||
|
||||
@Extension
|
||||
@PluginDependency(Util.class)
|
||||
@PluginDependency(iUtils.class)
|
||||
@PluginDescriptor(
|
||||
name = "Chaos Glassblower",
|
||||
description = "Huffs and puffs",
|
||||
enabledByDefault = false
|
||||
)
|
||||
@Slf4j
|
||||
public class Glassblower extends CScript {
|
||||
public static final int FOSSIL_ISLAND_SMALL_ISLAND_REGION = 14908;
|
||||
public static final int FOSSIL_ISLAND_SEAWEED_REGION = 15008;
|
||||
|
||||
@Provides
|
||||
Config provideConfig(ConfigManager configManager) {
|
||||
return configManager.getConfig(Config.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
|
||||
idleCheckSkills.put(Skill.CRAFTING, Activity.GLASSBLOWING);
|
||||
|
||||
addTask(PickupSeed.class);
|
||||
addTask(HandleBank.class);
|
||||
addTask(Blow.class);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Subscribe
|
||||
private void onAnimationChanged(AnimationChanged event) {
|
||||
if (game.client().getGameState() != GameState.LOGGED_IN) return;
|
||||
if (event.getActor() != game.client().getLocalPlayer()) return;
|
||||
|
||||
|
||||
int animId = game.localPlayer().animation();
|
||||
switch (animId) {
|
||||
case AnimationID.CRAFTING_GLASSBLOWING:
|
||||
setActivity(Activity.GLASSBLOWING);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package io.reisub.openosrs.glassblower;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum Product {
|
||||
BEER_GLASS(0),
|
||||
EMPTY_CANDLE_LANTERN(1),
|
||||
EMPTY_OIL_LAMP(2),
|
||||
VIAL(3),
|
||||
FISHBOWL(4),
|
||||
UNPOWERED_ORB(5),
|
||||
LANTERN_LENS(6),
|
||||
LIGHT_ORB(7);
|
||||
|
||||
private final int makeIndex;
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
package io.reisub.openosrs.glassblower.tasks;
|
||||
|
||||
import io.reisub.openosrs.glassblower.Config;
|
||||
import io.reisub.openosrs.glassblower.Glassblower;
|
||||
import io.reisub.openosrs.util.enums.Activity;
|
||||
import io.reisub.openosrs.util.Task;
|
||||
import net.runelite.api.ItemID;
|
||||
import net.runelite.client.plugins.iutils.game.InventoryItem;
|
||||
import net.runelite.client.plugins.iutils.game.iObject;
|
||||
import net.runelite.client.plugins.iutils.ui.Chatbox;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class Blow extends Task {
|
||||
@Inject
|
||||
private Glassblower plugin;
|
||||
|
||||
@Inject
|
||||
private Config config;
|
||||
|
||||
@Override
|
||||
public String getStatus() {
|
||||
return "Glassblowing";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validate() {
|
||||
return game.inventory().withId(ItemID.GLASSBLOWING_PIPE).exists()
|
||||
&& game.inventory().withId(ItemID.MOLTEN_GLASS).exists()
|
||||
&& plugin.getCurrentActivity() == Activity.IDLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
if (game.localPlayer().position().regionID() == Glassblower.FOSSIL_ISLAND_SMALL_ISLAND_REGION) {
|
||||
iObject rowboat = game.objects().withName("Rowboat").nearest();
|
||||
if (rowboat == null) return;
|
||||
|
||||
rowboat.interact("Dive");
|
||||
game.waitUntil(() -> chatbox.chatState() == Chatbox.ChatState.OPTIONS_CHAT
|
||||
|| game.localPlayer().position().regionID() == Glassblower.FOSSIL_ISLAND_SEAWEED_REGION, 10);
|
||||
|
||||
if (chatbox.chatState() == Chatbox.ChatState.OPTIONS_CHAT) {
|
||||
chatbox.chooseOption(1);
|
||||
game.waitUntil(() -> game.localPlayer().position().regionID() == Glassblower.FOSSIL_ISLAND_SEAWEED_REGION, 10);
|
||||
}
|
||||
game.tick();
|
||||
}
|
||||
|
||||
InventoryItem pipe = game.inventory().withId(ItemID.GLASSBLOWING_PIPE).first();
|
||||
InventoryItem moltenGlass = game.inventory().withId(ItemID.MOLTEN_GLASS).first();
|
||||
if (pipe == null || moltenGlass == null) return;
|
||||
|
||||
pipe.useOn(moltenGlass);
|
||||
game.waitUntil(() -> chatbox.chatState() == Chatbox.ChatState.MAKE, 5);
|
||||
|
||||
int quantity = (int) game.inventory().withId(ItemID.MOLTEN_GLASS).count();
|
||||
|
||||
chatbox.make(config.targetProduct().getMakeIndex(), quantity);
|
||||
game.waitUntil(() -> plugin.getCurrentActivity() == Activity.GLASSBLOWING, 5);
|
||||
}
|
||||
}
|
@ -0,0 +1,76 @@
|
||||
package io.reisub.openosrs.glassblower.tasks;
|
||||
|
||||
import io.reisub.openosrs.glassblower.Glassblower;
|
||||
import io.reisub.openosrs.util.Task;
|
||||
import net.runelite.api.ItemID;
|
||||
import net.runelite.client.plugins.iutils.game.iObject;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
|
||||
public class HandleBank extends Task {
|
||||
private Instant lastBanking = Instant.EPOCH;
|
||||
|
||||
@Override
|
||||
public String getStatus() {
|
||||
return "Banking";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validate() {
|
||||
return !game.inventory().withId(ItemID.MOLTEN_GLASS).exists()
|
||||
&& Duration.between(lastBanking, Instant.now()).getSeconds() > 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
if (game.localPlayer().position().regionID() == Glassblower.FOSSIL_ISLAND_SEAWEED_REGION) {
|
||||
iObject rope = game.objects().withName("Anchor rope").first();
|
||||
if (rope == null) return;
|
||||
|
||||
rope.interact("Climb");
|
||||
if (!game.waitUntil(() -> game.localPlayer().position().regionID() == Glassblower.FOSSIL_ISLAND_SMALL_ISLAND_REGION
|
||||
|| game.groundItems().withId(ItemID.SEAWEED_SPORE).exists(), 30)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (game.groundItems().withId(ItemID.SEAWEED_SPORE).exists()) return;
|
||||
|
||||
game.tick();
|
||||
}
|
||||
|
||||
if (!bank.isOpen()) {
|
||||
iObject bankObj = game.objects().withName("Bank chest", "Bank booth", "Bank Chest-wreck").nearest();
|
||||
if (bankObj == null) return;
|
||||
|
||||
bankObj.interact(0);
|
||||
game.waitUntil(() -> bank.isOpen(), 15);
|
||||
}
|
||||
|
||||
bank.depositExcept(false, ItemID.GLASSBLOWING_PIPE, ItemID.SEAWEED_SPORE);
|
||||
// bank.depositAll(false, ItemID.BEER_GLASS,
|
||||
// ItemID.EMPTY_CANDLE_LANTERN,
|
||||
// ItemID.EMPTY_OIL_LAMP,
|
||||
// ItemID.VIAL,
|
||||
// ItemID.FISHBOWL,
|
||||
// ItemID.UNPOWERED_ORB,
|
||||
// ItemID.LANTERN_LENS,
|
||||
// ItemID.LIGHT_ORB);
|
||||
game.tick();
|
||||
game.sleepDelay();
|
||||
|
||||
if (!game.inventory().withId(ItemID.GLASSBLOWING_PIPE).exists()) {
|
||||
bank.withdraw(ItemID.GLASSBLOWING_PIPE, 1, false);
|
||||
game.sleepDelay();
|
||||
}
|
||||
|
||||
int quantity = game.inventory().withId(ItemID.SEAWEED_SPORE).exists() ? 26 : 27;
|
||||
|
||||
bank.withdraw(ItemID.MOLTEN_GLASS, quantity, false);
|
||||
game.sleepDelay();
|
||||
|
||||
bank.close();
|
||||
game.sleepDelay();
|
||||
lastBanking = Instant.now();
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package io.reisub.openosrs.glassblower.tasks;
|
||||
|
||||
import io.reisub.openosrs.util.Task;
|
||||
import net.runelite.api.ItemID;
|
||||
import net.runelite.client.plugins.iutils.game.iGroundItem;
|
||||
|
||||
public class PickupSeed extends Task {
|
||||
@Override
|
||||
public String getStatus() {
|
||||
return "Picking up seed";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validate() {
|
||||
return game.groundItems().withId(ItemID.SEAWEED_SPORE).exists();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
iGroundItem item = game.groundItems().withId(ItemID.SEAWEED_SPORE).nearest();
|
||||
if (item == null) return;
|
||||
|
||||
int quantity = game.inventory().withId(ItemID.SEAWEED_SPORE).quantity();
|
||||
|
||||
item.interact("Take");
|
||||
game.waitUntil(() -> game.inventory().withId(ItemID.SEAWEED_SPORE).quantity() > quantity, 30);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user