Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • Try asking for help in the chatbox
  • Robosoldier2

    • Posts

    • Joined

    • Last visited

    Recent Profile Visitors

    44 profile views

    Robosoldier2's Achievements

    1. There are run() and stop() methods within AbstractScript class. I don't think these will help you load a new artifact though. https://dreambot.org/javadocs/org/dreambot/api/script/AbstractScript.html You could instead aim to automate the loading of the jar from outside the script. Below is a high level example: Have your Java detect when a new jar file has appeared on the system through a check on the modified date for example. If found, call stop(). Then a shell script either spawned by Java or acting independently could terminate all Dreambot processes at OS level, followed by spawning new processes with CLI arguments specifying the accounts and new jar file.. Someone more versed with Dreambot behaviour can sanity check my CLI thinking. I think it has that functionality, but at work so can't check.
    2. Ah fantastic, I hadn't come across the onExit() and wondered if something like that existed. That's perfect. Agree that the library should have some close down functions, will check it out tomorrow. Thanks again for the help, and appreciate the quick reply @Pandemic!
    3. Hey @Pandemic. Sorry if the tag notifies you, just afraid this thread would be buried by now, and you clearly know your stuff. Hoping you can lend a hand again... Things are going well and I'm able to receive messages via the overriden onMessageReceived event. What I have noticed though is that when I stop scripts executing via Dreambot, it's as if the object I created for the discord event listener and the overriden onMessageReceived function stay in tact. By this I mean, the original connection and object still exists and continues to run, and will receive messages and print them to console. If I start and stop it again, another one spawns. So on and so forth, causing duplication. I expected when stopping the script, that it would kill execution and discard any references to the object. Any clues on why this doesn't happen? And if so, how I should best perform clean-up of it on script stopping to prevent duplication of the handler? I instantiate the bot within the class scope. Then, within the loop I check if setup has been performed. If not, it's performed, which is essentially the logging in with a token etc. Warning: Might not be the nicest code, nor best practice. Bit of a Java learning exercise, along with Dreambot behaviors. I've also stripped out some unrelated code. Main class: @ScriptManifest(name = "Runescape Testing", description = "Fantastic levels of testing!", author = "H", version = 1.0, category = Category.WOODCUTTING, image = "") public class TestScript extends AbstractScript implements ChatListener { private Bot bot = new Bot(); @Override public int onLoop() { if (!bot.GetSetupPerformed()) { try { bot.setup(); } catch (LoginException e) { throw new RuntimeException(e); } } return 1000; } Discord bot class: public class Bot extends ListenerAdapter { private String newDiscordMessage = "empty"; private JDA jda; private Boolean setupPerformed = false; public static void main(String[] args) { } public void setup() throws LoginException { this.jda = JDABuilder.createDefault("<redacted>").build(); this.jda.addEventListener(new Bot()); MethodProvider.log("Discord bot setup performed"); this.setupPerformed = true; } public Bot() { } public boolean GetSetupPerformed() { return this.setupPerformed; } @Override public void onMessageReceived(MessageReceivedEvent event) { MethodProvider.log("Event tripped"); if (event.isFromType(ChannelType.PRIVATE)) { MethodProvider.log(String.format("[PM] %s: %s\n", event.getAuthor().getName(), event.getMessage().getContentDisplay())); } else { MethodProvider.log(String.format("[%s][%s] %s: %s\n", event.getGuild().getName(), event.getTextChannel().getName(), event.getMember().getEffectiveName(), event.getMessage().getContentDisplay())); } } public String getReceivedMessage() { MethodProvider.log("Received message (in return function): " + this.newDiscordMessage); return this.newDiscordMessage; } } Thanks in advance!
    4. You're bloody absolutely right! And I don't know why I hadn't thought of checking the console for errors... foolish me. It is failing to find the ListenerAdapter class as you guessed. Given it runs within the project using the jar I imported, it must be how I'm building it which is causing the problem. Appreciate the nudge in the right direction @Pandemic, and now one I'll need to wrap my head around. java.lang.NoClassDefFoundError: net/dv8tion/jda/api/hooks/ListenerAdapter at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(Unknown Source)
    5. Hey thanks @Pandemic. What you've said makes sense and is how I have it set up per the guides. When I remove the extension of ListenerAdapter on my dedicated Discord class, the artifact builds and is picked up by Dreambot fine. It's only when I build with the extension active that it doesn't show up as a script choice. This all without touching my first class with the extension of AbstractScript and annotation of ScriptManifest. Any clues? I can share additional info that you think might help.
    6. Hey guys, So for background, I've got a script that was built using the recommended setup tutorial in the Dreambot docs. All works well: build the artifact into Dreambot folder, client sees script, click to run, voila. I was looking to integrate Discord into my project. I picked out the JDA (Java Discord API) from a few options as the wrapper to use. Setup is straight forward; maven, gradle, or import the jar with dependancies as a library manually. I did the latter as I'm not familiar with maven or gradle quite yet — new to Java and all. This is where things go funny. I put together the class based on a sample provided on their Github, just to verify it's working. All of the imports are found fine, and the code has no errors. I can run the class directly via the project by right clicking on it, and it connects in fine. I performed some tests with some prints of messages being received. Also works in a standalone program. However, when I try to use the below in my bot program, the artifact I build succeeds, but cannot be picked up by Dreambot. This before I've added any interaction from the bot script (no Bot objects instantiated etc). I did a bit of trial and error and tracked the cause to the extension of the ListenerAdapter class. As said it has no problems in standalone programs, or running the class alone within the project. However the Dreambot client doesn't pick up the produced jar so long as this class is being extended. But building does succeed as mentioned. If I remove the extension of ListenerAdapter, and the @Override declaration (given no extension), it then picks up the jar fine on the script selection window. I can also extend other classes in this class just fine and it remains visible. I welcome any advice. I'm on the novice side when it comes to Java, and Dreambot is a black-box to me in regards to what it does to determine scripts are good to run. If wanting to reference the library I'm using: https://github.com/DV8FromTheWorld/JDA And below is the version in use (this is a link to the latest jar with dependencies (5.0.0-alpha.11): https://github.com/DV8FromTheWorld/JDA/releases/download/v5.0.0-alpha.11/JDA-5.0.0-alpha.11-withDependencies.jar Thanks all, Robo import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.JDABuilder; import net.dv8tion.jda.api.entities.ChannelType; import net.dv8tion.jda.api.events.message.MessageReceivedEvent; import net.dv8tion.jda.api.hooks.ListenerAdapter; import javax.security.auth.login.LoginException; public class Bot extends ListenerAdapter { public static void main(String[] args) throws LoginException { JDA jda = JDABuilder.createDefault("token").build(); //You can also add event listeners to the already built JDA instance // Note that some events may not be received if the listener is added after calling build() // This includes events such as the ReadyEvent jda.addEventListener(new Bot()); } @Override public void onMessageReceived(MessageReceivedEvent event) { } }
    7. Haha, spoken like a true RuneScape purist. I've only just realised there is a resizable classic option. Being locked into the tiny box was what put me off and made me use modern. Sounds like a good way to have the "always-open" tabs with a much better view of the game. Will give it a whirl later. Thanks for the code. I haven't looked at the widget class, but I see what the code is aiming to do. Fingers crossed it gives a viable option for those peasants out there choosing to use modern!
    8. Thanks Camal. Forgot about the differences, it's a modern thing yeah. Dreambot offers modern layout as an option in the client, and I like the look of it myself (I do partly play on the account in the midst of botting). Had hoped there might be a way to do it given the client support. I guess generating a click on the tab's location could work as an alternative to a built-in method. Either way, thanks for your help. One for me to think about.
    9. Hey all, I'm having a little trouble finding a method to close tabs (i.e. skills pane, backpack). I did search for "closing tab" on the forum and for predictable method names in the API docs, but to no avail. Looking through the methods for both the Tabs and Tab classes, I couldn't see any that applied. One thing I haven't tried is running openWithMouse whilst it is already open, to see if it will close it. Something I'll have to try later when at my development machine. I'm new to using the Dreambot API and Java in general, so not sure if javadocs is a common thing. Must say they're bloody great. Thanks for the work put in, and thanks in advance to anyone who can help me with this query. Robo
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.