kators 1 Share Posted June 23, 2019 I'm fairly new to both java and scripting so forgive me if I'm missing something blatantly obvious but for some reason, enums don't seem to be working for me at the moment. At first, I thought it was something else in my script but after testing it, no script I create can use enums I create. Although, the Dreambot enums seem to work(Normal specifically). Basically, here is what happens: Run script Script gets stuck on the enum call The script has no problem running, but it never stops either despite the fact it doesn't do anything. In the test I made, all it has to do is log the string from the enum. Instead, it does nothing and just hangs indefinitely. What I've Tried: Restarting client Deleting and reinstalling client Creating a new script Creating a new enum Running dreambot enums(they work) Using "Fresh Start" on the client As I said, I'm new to java/scripting with dreambot so I feel like I'm probably just missing something obvious. Any help would be appreciated, here are the classes. main class of my test script: import org.dreambot.api.methods.Calculations; import org.dreambot.api.script.AbstractScript; import org.dreambot.api.script.ScriptManifest; import org.dreambot.api.script.Category; @ScriptManifest(author = "You", name = "Enum Test", version = 1.0, description = "Testing ENums", category = Category.FISHING) public class main extends AbstractScript { public void onStart() { } public void onExit() { } @Override public int onLoop() { log(DoesItWork.YES.getS()); return Calculations.random(500, 600); } } enum class of my test script: public enum DoesItWork { YES("YES"), NO("NO"); String s; DoesItWork(String s){ this.s = s; } public String getS() { return s; } } Link to comment Share on other sites More sharing options...
kators 1 Author Share Posted June 23, 2019 Forgot to mention I also deleted the jagexcache as well and it still didn't work. Link to comment Share on other sites More sharing options...
Nuclear Nezz 1969 Share Posted June 23, 2019 You're not importing the enum Link to comment Share on other sites More sharing options...
kators 1 Author Share Posted June 23, 2019 16 minutes ago, Nuclear Nezz said: You're not importing the enum Both of them are in the same package so it shouldn't have to be imported. I've also tried using enums outside of a dreambot script and it works so I don't know what's happening. Link to comment Share on other sites More sharing options...
Nuclear Nezz 1969 Share Posted June 23, 2019 14 hours ago, kators said: Both of them are in the same package so it shouldn't have to be imported. I've also tried using enums outside of a dreambot script and it works so I don't know what's happening. O you're right, my bad. Run your client through cmd and then run the script, it'll give you an error that our debug console won't Link to comment Share on other sites More sharing options...
kators 1 Author Share Posted June 24, 2019 8 hours ago, Nuclear Nezz said: O you're right, my bad. Run your client through cmd and then run the script, it'll give you an error that our debug console won't Exception in thread "Thread-28" java.lang.NoClassDefFoundError: DoesItWork at main.onLoop(main.java:19) at org.dreambot.api.script.AbstractScript.run(AbstractScript.java:256) at java.lang.Thread.run(Unknown Source) Caused by: java.lang.ClassNotFoundException: DoesItWork at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) ... 3 more This is what I got. I'm lost on what it means. Link to comment Share on other sites More sharing options...
Nuclear Nezz 1969 Share Posted June 24, 2019 I'm assuming you have these in separate classes, but it looks like your build is not correct. It may just be putting your main script class into the jar (or however you're adding it) Double check that you're exporting the jar correctly, if that looks fine, download bytecodeviewer and put your script jar in there, and check for the enum class. Keep in mind, you shouldn't be building the client into your jar as well (I've seen people make that mistake) but just the source files needed. If your build looks fine but you're not finding the class in the jar itself, then Google is probably a better friend, as you'll know more details to include in your search than we will. If the build is fine, class is there, etc, then I'll see if I can think of any other reasons why it may not be working. Are there any other errors in cmd that happen, maybe before that one? Also make sure that you're running the correct script from the correct jar, maybe update the version # in your main script and double check that it changes in the one you're running. I've seen more than a few times people getting frustrated trying to fix something just to realize they weren't running the same version they were fixing. (Happens if you maybe have two of the same jar, or just have two of the same script name in different local scripts) Link to comment Share on other sites More sharing options...
kators 1 Author Share Posted June 24, 2019 3 hours ago, Nuclear Nezz said: I'm assuming you have these in separate classes, but it looks like your build is not correct. It may just be putting your main script class into the jar (or however you're adding it) Double check that you're exporting the jar correctly, if that looks fine, download bytecodeviewer and put your script jar in there, and check for the enum class. Keep in mind, you shouldn't be building the client into your jar as well (I've seen people make that mistake) but just the source files needed. If your build looks fine but you're not finding the class in the jar itself, then Google is probably a better friend, as you'll know more details to include in your search than we will. If the build is fine, class is there, etc, then I'll see if I can think of any other reasons why it may not be working. Are there any other errors in cmd that happen, maybe before that one? Also make sure that you're running the correct script from the correct jar, maybe update the version # in your main script and double check that it changes in the one you're running. I've seen more than a few times people getting frustrated trying to fix something just to realize they weren't running the same version they were fixing. (Happens if you maybe have two of the same jar, or just have two of the same script name in different local scripts) Thanks for your help. I thought the issue was something more complex but it turns out I'm just an idiot and wasn't building the entire project, just the single class. I'm gonna go put my dunce cap on now. Nuclear Nezz 1 Link to comment Share on other sites More sharing options...
Nuclear Nezz 1969 Share Posted June 28, 2019 On 6/24/2019 at 12:00 PM, kators said: Thanks for your help. I thought the issue was something more complex but it turns out I'm just an idiot and wasn't building the entire project, just the single class. I'm gonna go put my dunce cap on now. Glad you figured it out Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now