Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import org.dreambot.api.wrappers.widgets.message.Message;
- import java.util.Random;
- import java.awt.Color;
- import java.awt.Font;
- import java.awt.Graphics;
- import org.dreambot.api.wrappers.widgets.WidgetChild;
- import org.dreambot.api.wrappers.interactive.GameObject;
- import org.dreambot.api.wrappers.interactive.NPC;
- import org.dreambot.api.methods.tabs.Tab;
- import org.dreambot.api.methods.Calculations;
- import org.dreambot.api.methods.container.impl.bank.BankLocation;
- import org.dreambot.api.wrappers.interactive.Entity;
- import org.dreambot.api.methods.skills.Skill;
- import org.dreambot.api.utilities.Timer;
- import org.dreambot.api.script.Category;
- import org.dreambot.api.script.ScriptManifest;
- import org.dreambot.api.script.AbstractScript;
- import java.awt.Point;
- @ScriptManifest(author = "Deus", category = Category.MISC, name = "Crafting", version = 1.0, description = "gets crafting lvls")
- public class main extends AbstractScript {
- private Timer timer;
- private String needle;
- private String leather;
- private boolean startup;
- int xp;
- int level;
- public main() {
- this.timer = new Timer();
- this.needle = "Needle";
- this.leather = "Leather";
- }
- private State getState() {
- if (this.getSkills().getRealLevel(Skill.CRAFTING) < 7 && this.getInventory().contains("Needle") && this.getInventory().contains("Thread")) {
- return State.gloves;
- }
- if (this.getSkills().getRealLevel(Skill.CRAFTING) < 9 && this.getSkills().getRealLevel(Skill.CRAFTING) >= 7 && this.getInventory().contains("Needle") && this.getInventory().contains("Thread")) {
- return State.boots;
- }
- if (this.getSkills().getRealLevel(Skill.CRAFTING) < 11 && this.getSkills().getRealLevel(Skill.CRAFTING) >= 9 && this.getInventory().contains("Needle") && this.getInventory().contains("Thread")) {
- return State.cowl;
- }
- if (this.getSkills().getRealLevel(Skill.CRAFTING) < 14 && this.getSkills().getRealLevel(Skill.CRAFTING) >= 11 && this.getInventory().contains("Needle") && this.getInventory().contains("Thread")) {
- return State.vambs;
- }
- if (this.getSkills().getRealLevel(Skill.CRAFTING) < 18 && this.getSkills().getRealLevel(Skill.CRAFTING) >= 14 && this.getInventory().contains("Needle") && this.getInventory().contains("Thread")) {
- return State.body;
- }
- if (this.getSkills().getRealLevel(Skill.CRAFTING) < 28 && this.getSkills().getRealLevel(Skill.CRAFTING) >= 18 && this.getInventory().contains("Needle") && this.getInventory().contains("Thread")) {
- return State.chaps;
- }
- if (this.getSkills().getRealLevel(Skill.CRAFTING) < 46 && this.getSkills().getRealLevel(Skill.CRAFTING) >= 28 && this.getInventory().contains("Needle") && this.getInventory().contains("Thread")) {
- return State.hardbody;
- }
- if (!this.getInventory().contains("Leather")) {
- return State.bank;
- }
- if (this.getDialogues().inDialogue()) {
- return State.dialog;
- }
- return State.nothing;
- }
- public int onLoop() {
- switch (this.getState()) {
- case dialog: {
- if (this.getDialogues().canContinue()) {
- this.getDialogues().continueDialogue();
- sleep(300, 600);
- }
- break;
- }
- case gloves: {
- if (this.getWidgets().getWidget(154) == null) {
- this.getInventory().get(this.needle).useOn(this.leather);
- sleepUntil(() -> this.getWidgets().getWidget(154) != null, 16000L);
- }
- if (this.getWidgets().getWidget(154) != null && this.getWidgets().getWidget(154).getChild(127).interact("Make All pairs of Leather gloves")) {
- sleepUntil(() -> !this.getInventory().contains("Leather"), 16000L);
- }
- break;
- }
- case boots: {
- if (this.getWidgets().getWidget(154) == null) {
- this.getInventory().get(this.needle).useOn(this.leather);
- sleepUntil(() -> this.getWidgets().getWidget(154) != null, 16000L);
- }
- if (this.getWidgets().getWidget(154) != null && this.getWidgets().getWidget(154).getChild(109).interact("Make All pairs of Leather boots")) {
- sleepUntil(() -> !this.getInventory().contains("Leather"), 16000L);
- }
- break;
- }
- case cowl: {
- if (this.getWidgets().getWidget(154) == null) {
- this.getInventory().get(this.needle).useOn(this.leather);
- sleepUntil(() -> this.getWidgets().getWidget(154) != null, 16000L);
- }
- if (this.getWidgets().getWidget(154) != null && this.getWidgets().getWidget(154).getChild(113).interact("Make All Cowls")) {
- sleepUntil(() -> !this.getInventory().contains("Leather"), 16000L);
- }
- break;
- }
- case vambs: {
- if (this.getWidgets().getWidget(154) == null) {
- this.getInventory().get(this.needle).useOn(this.leather);
- sleepUntil(() -> this.getWidgets().getWidget(154) != null, 16000L);
- }
- if (this.getWidgets().getWidget(154) != null && this.getWidgets().getWidget(154).getChild(110).interact("Make All pairs of Leather vambraces")) {
- sleepUntil(() -> !this.getInventory().contains("Leather"), 16000L);
- }
- break;
- }
- case body: {
- if (this.getWidgets().getWidget(154) == null) {
- this.getInventory().get(this.needle).useOn(this.leather);
- sleepUntil(() -> this.getWidgets().getWidget(154) != null, 16000L);
- }
- if (this.getWidgets().getWidget(154) != null && this.getWidgets().getWidget(154).getChild(114).interact("Make All Leather bodies")) {
- sleepUntil(() -> !this.getInventory().contains("Leather"), 16000L);
- } else if (this.getDialogues().canContinue()) {
- this.getDialogues().continueDialogue();
- sleep(300, 600);
- }
- else if (!this.getBank().isOpen() && !this.getInventory().contains("Leather")) {
- if (this.getBank().open(BankLocation.GRAND_EXCHANGE)) {
- this.getBank().deposit("Leather body", 30);
- this.getBank().withdraw("Leather", 26);
- sleep(300, 600);
- }
- break;
- }
- }
- case chaps: {
- if (this.getWidgets().getWidget(154) == null) {
- this.getInventory().get(this.needle).useOn(this.leather);
- sleepUntil(() -> this.getWidgets().getWidget(154) != null, 16000L);
- }
- if (this.getWidgets().getWidget(154) != null && this.getWidgets().getWidget(154).getChild(111).interact("Make All pairs of Leather chaps")) {
- sleepUntil(() -> !this.getInventory().contains("Leather"), 16000L);
- } else if (!this.getBank().isOpen() && !this.getInventory().contains("Leather")) {
- if (this.getBank().open(BankLocation.GRAND_EXCHANGE)) {
- this.getBank().deposit("Leather chaps", 30);
- this.getBank().withdraw("Leather", 26);
- sleep(300, 600);
- }
- break;
- }
- }
- case hardbody: {
- if (this.getWidgets().getWidget(154) == null) {
- this.getInventory().get(this.needle).useOn(this.leather);
- sleepUntil(() -> this.getWidgets().getWidget(154) != null, 16000L);
- }
- if (this.getWidgets().getWidget(154) != null && this.getWidgets().getWidget(154).getChild(109).interact("Make All pairs of Leather boots")) {
- sleepUntil(() -> !this.getInventory().contains("Leather"), 16000L);
- }
- break;
- }
- case bank: {
- if (!this.getBank().isOpen()) {
- if (!this.getInventory().contains("Leather")) {
- this.getBank().deposit("Leather gloves", 30);
- sleep(300, 600);
- }
- if (!this.getInventory().contains("Leather")) {
- this.getBank().deposit("Leather boots", 30);
- sleep(300, 600);
- }
- if (!this.getInventory().contains("Leather")) {
- this.getBank().deposit("Leather cowl", 30);
- sleep(300, 600);
- }
- if (!this.getInventory().contains("Leather")) {
- this.getBank().deposit("Leather vambraces", 30);
- sleep(300, 600);
- }
- if (!this.getInventory().contains("Leather")) {
- this.getBank().deposit("Leather body", 30);
- sleep(300, 600);
- }
- if (!this.getInventory().contains("Leather")) {
- this.getBank().deposit("Leather chaps", 30);
- sleep(300, 600);
- }
- if (!this.getInventory().contains("Leather")) {
- this.getBank().deposit("Hardleather body", 30);
- sleep(300, 600);
- }
- if (this.getBank().contains("Leather")) {
- this.getBank().withdraw("Leather", 26);
- sleep(300, 600);
- this.getBank().close();
- } else {
- log("Bank doesn't contain Leather, stopping script.");
- this.stop();
- }
- return 0;
- }
- this.getBank().open(BankLocation.GRAND_EXCHANGE);
- return 0;
- }
- }
- return Calculations.random(500, 900);
- }
- public void onPaint(final Graphics g) {
- g.setFont(new Font("Arial", 1, 16));
- g.setColor(Color.YELLOW);
- g.drawString("Runtime: " + this.timer.formatTime(), 25, 40);
- g.drawString("State: " + this.getState().name(), 25, 55);
- g.drawString("Levels gained = " + (this.getSkills().getRealLevel(Skill.CRAFTING) - this.level), 25, 70);
- g.drawString("xp gained = " + (this.getSkills().getExperience(Skill.CRAFTING) - this.xp) + " xp/hr = " + this.timer.getHourlyRate(this.getSkills().getExperience(Skill.MAGIC) - this.xp), 25, 85);
- }
- public void onExit() {
- }
- public void onStart() {
- this.xp = this.getSkills().getExperience(Skill.CRAFTING);
- this.level = this.getSkills().getRealLevel(Skill.CRAFTING);
- }
- private static int randInt(final int min, final int max) {
- final Random rand = new Random();
- final int randomNum = rand.nextInt(max - min + 1) + min;
- return randomNum;
- }
- private void customSleep(final boolean name) {
- sleepUntil(() -> name, (long)Calculations.random(2000, 4000));
- }
- public enum State
- {
- nothing,
- dialog,
- bank,
- gloves,
- boots,
- cowl,
- vambs,
- body,
- chaps,
- hardbody;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement