Chambo Posted August 22, 2015 Share Posted August 22, 2015 Ok so i'm just trying to make a script to walk from lumbridge to different locations depending on what the user selects. In Eclipse it shows no errors but then when I run the script I get this error in the Debug. [ERROR][08/22 02:01:53 PM]: Failed to start script [Chambo's Bot Walker PRO] java.lang.NoSuchMethodException: Main.<init>() at java.lang.Class.getConstructor0(Unknown Source) at java.lang.Class.getConstructor(Unknown Source) at org.osbot.PRN.run(cf:278) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) And here is my Source: import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.WindowAdapter; import javax.swing.*; import org.osbot.rs07.api.map.Area; import org.osbot.rs07.api.map.Position; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import com.sun.glass.events.WindowEvent; @ScriptManifest(author = "Chambo", info = "Chambo's Bot Walker", logo = "", name = "Chambo's Bot Walker PRO", version = 0.89) final class Main extends Script { private String botLoc; public boolean shouldWalk = false; Position[] path1 = new Position[] { new Position(3233,3236,0), new Position(3232,3230,0), new Position(3233,3236,0), new Position(3232,3246,0), new Position(3232,3253,0), new Position(3231,3257,0), new Position(3240,3261,0), new Position(3241,3263,0), new Position(3241,3265,0), new Position(3242,3266,0), new Position(3243,3268,0), new Position(3243,3270,0), new Position(3240,3278,0), new Position(3239,3282,0), new Position(3239,3296,0), new Position(3238,3283,0), new Position(3238,3293,0), new Position(3238,3304,0), new Position(3242,3309,0), new Position(3248,3315,0), new Position(3252,3318,0), new Position(3256,3324,0), new Position(3263,3326,0), new Position(3268,3328,0), new Position(3274,3338,0), new Position(3278,3345,0), new Position(3274,3338,0), new Position(3277,3343,0), new Position(3278,3345,0), new Position(3278,3345,0), new Position(3282,3351,0), new Position(3278,3354,0), new Position(3273,3360,0), new Position(3277,3364,0), new Position(3285,3366,0), new Position(3277,3364,0), new Position(3278,3370,0), new Position(3280,3371,0), new Position(3284,3367,0),}; Position[] path2 = new Position[] { new Position(3233,3236,0), new Position(3232,3230,0), new Position(3233,3236,0), new Position(3232,3246,0), new Position(3232,3253,0), new Position(3231,3257,0), new Position(3240,3261,0), new Position(3241,3263,0), new Position(3241,3265,0), new Position(3242,3266,0), new Position(3243,3268,0), new Position(3243,3270,0), new Position(3240,3278,0), new Position(3239,3282,0), new Position(3239,3296,0), new Position(3238,3283,0), new Position(3238,3293,0), new Position(3238,3304,0), new Position(3242,3309,0), new Position(3248,3315,0), new Position(3252,3318,0), new Position(3256,3324,0), new Position(3263,3326,0), new Position(3268,3328,0), new Position(3274,3338,0), new Position(3278,3345,0), new Position(3274,3338,0), new Position(3277,3343,0), new Position(3278,3345,0), new Position(3278,3345,0), new Position(3282,3351,0), new Position(3278,3354,0), new Position(3273,3360,0), new Position(3277,3364,0), new Position(3285,3366,0), new Position(3277,3364,0), new Position(3278,3370,0), new Position(3280,3371,0), new Position(3284,3367,0),}; final Area miningLoc = new Area( new Position(3283,3368,0), new Position(3289,3362,0)); final Area wcLoc = new Area( new Position(3283,3368,0), new Position(3289,3362,0)); final Area lumby = new Area( new Position(3229,3233,0), new Position(3235,3227,0)); public void onStart(Runnable initSettings) { EventQueue.invokeLater(initSettings); } @SuppressWarnings("unused") private void initSettings() { final JFrame frame = new JFrame("Settings"); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent event) { frame.dispose(); Main.this.stop(); } }); frame.setLocationByPlatform(true); String[] botLocs = { "Mining (VE)", "Woodcutting (VE)", "Random" }; final JComboBox<String> botLocBox = new JComboBox<String>(botLocs); frame.add(botLocBox); JButton startbtn = new JButton("Start"); startbtn.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e) { botLoc = (String) botLocBox.getSelectedItem(); frame.dispose(); }}); frame.add(startbtn); frame.pack(); frame.setVisible(true); } public int onLoop() throws InterruptedException { //use values from settings (logType) if(botLoc.equals("Mining VE")){ if(!miningLoc.contains(players.myPosition())){ log("Walking to Varrock East Mine"); localWalker.walkPath(path1); }else{ log("You are already in the Mining Area!"); } } else if(botLoc.equals("Woodcutting VE")){ if(!wcLoc.contains(players.myPosition())){ log("Walking to Varrock East Trees"); localWalker.walkPath(path2); }else{ log("You are already in the Woodcutting Area!"); } } return 600; } public void onPaint(Graphics2D g) { //This is where you will put your code for paint(s) final Color color1 = new Color(153, 153, 153); final Color color2 = new Color(255, 0, 0); final Color color3 = new Color(0, 0, 0); final Color color4 = new Color(255, 255, 255); final BasicStroke stroke1 = new BasicStroke(3); final Font font1 = new Font("Arial", 0, 9); final Font font2 = new Font("Arial", 1, 21); final Font font3 = new Font("Arial", 0, 15); final Font font4 = new Font("Arial", 0, 8); g.setColor(color1); g.fillRect(9, 346, 500, 126); g.setColor(color2); g.setStroke(stroke1); g.drawRect(9, 346, 500, 126); g.setFont(font1); g.setColor(color1); g.drawString("Version: ", 15, 332); g.setFont(font2); g.setColor(color3); g.drawString("EXP p/h:", 17, 378); g.setColor(color4); g.drawString("EXP p/h:", 14, 375); g.setColor(color3); g.drawString("Gold p/h:", 18, 417); g.setColor(color4); g.drawString("Gold p/h:", 15, 414); g.setColor(color3); g.drawString("Run Time:", 18, 454); g.setColor(color4); g.drawString("Run Time:", 15, 451); g.setColor(color3); g.drawString("Current Level:", 270, 380); g.setColor(color4); g.drawString("Current Level:", 267, 377); g.setColor(color3); g.drawString("Levels Gained:", 271, 417); g.setColor(color4); g.drawString("Levels Gained:", 268, 414); g.setColor(color3); g.drawString("Status:", 273, 453); g.setColor(color4); g.drawString("Status:", 270, 450); g.setFont(font3); g.drawString("EXPPH", 121, 375); g.drawString("GOLDPH", 128, 414); g.drawString("RUNTIME", 137, 450); g.drawString("40", 439, 377); g.drawString("+29", 444, 414); g.drawString("Running: " +botLoc, 370, 452); g.setFont(font4); g.setColor(color1); g.drawString("0.29", 59, 332); } } If someone could help me solve this that would be awesome! Thanks! Quote Link to comment Share on other sites More sharing options...
FrostBug Posted August 22, 2015 Share Posted August 22, 2015 Not sure where you've gotten this from; but onStart(Runnable runnable) isn't defined in script, and doesn't seem to be called at all. So your init stuff is never executed. That's a problem; tho I don't really know why the exception indicates the lack of a parameter-less constructor Quote Link to comment Share on other sites More sharing options...
Chambo Posted August 22, 2015 Author Share Posted August 22, 2015 So what would I need to do to fix this error? Just replace the public void onStart(Runnable initSettings) { with public void onStart() { ? Quote Link to comment Share on other sites More sharing options...
FrostBug Posted August 22, 2015 Share Posted August 22, 2015 So what would I need to do to fix this error? Just replace the public void onStart(Runnable initSettings) { with public void onStart() { ? Yes, if you do that, you will be overriding the onStart method from the Script class. This overridden method will be invoked by the script executor on script start. Quote Link to comment Share on other sites More sharing options...
Chambo Posted August 22, 2015 Author Share Posted August 22, 2015 I removed it and i'm still getting the same error as before? Quote Link to comment Share on other sites More sharing options...
FrostBug Posted August 22, 2015 Share Posted August 22, 2015 I removed it and i'm still getting the same error as before? The class must be public in order for the Script Executor to access the default constructor. Add the public keyword to the class signature Quote Link to comment Share on other sites More sharing options...
Chambo Posted August 22, 2015 Author Share Posted August 22, 2015 Alright so the Script actually starts up now but now it freezes the client and gives me another error. And my combobox won't show up in the GUI either. And the current source: import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.WindowAdapter; import javax.swing.*; import org.osbot.rs07.api.map.Area; import org.osbot.rs07.api.map.Position; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import com.sun.glass.events.WindowEvent; @ScriptManifest(author = "Chambo", info = "Chambo's Bot Walker", logo = "", name = "Chambo's Bot Walker PRO", version = 0.89) public class Main extends Script { public String botLoc; public boolean guiWait = true; public boolean shouldWalk = false; Position[] path1 = new Position[] { new Position(3233,3236,0), new Position(3232,3230,0), new Position(3233,3236,0), new Position(3232,3246,0), new Position(3232,3253,0), new Position(3231,3257,0), new Position(3240,3261,0), new Position(3241,3263,0), new Position(3241,3265,0), new Position(3242,3266,0), new Position(3243,3268,0), new Position(3243,3270,0), new Position(3240,3278,0), new Position(3239,3282,0), new Position(3239,3296,0), new Position(3238,3283,0), new Position(3238,3293,0), new Position(3238,3304,0), new Position(3242,3309,0), new Position(3248,3315,0), new Position(3252,3318,0), new Position(3256,3324,0), new Position(3263,3326,0), new Position(3268,3328,0), new Position(3274,3338,0), new Position(3278,3345,0), new Position(3274,3338,0), new Position(3277,3343,0), new Position(3278,3345,0), new Position(3278,3345,0), new Position(3282,3351,0), new Position(3278,3354,0), new Position(3273,3360,0), new Position(3277,3364,0), new Position(3285,3366,0), new Position(3277,3364,0), new Position(3278,3370,0), new Position(3280,3371,0), new Position(3284,3367,0),}; Position[] path2 = new Position[] { new Position(3233,3236,0), new Position(3232,3230,0), new Position(3233,3236,0), new Position(3232,3246,0), new Position(3232,3253,0), new Position(3231,3257,0), new Position(3240,3261,0), new Position(3241,3263,0), new Position(3241,3265,0), new Position(3242,3266,0), new Position(3243,3268,0), new Position(3243,3270,0), new Position(3240,3278,0), new Position(3239,3282,0), new Position(3239,3296,0), new Position(3238,3283,0), new Position(3238,3293,0), new Position(3238,3304,0), new Position(3242,3309,0), new Position(3248,3315,0), new Position(3252,3318,0), new Position(3256,3324,0), new Position(3263,3326,0), new Position(3268,3328,0), new Position(3274,3338,0), new Position(3278,3345,0), new Position(3274,3338,0), new Position(3277,3343,0), new Position(3278,3345,0), new Position(3278,3345,0), new Position(3282,3351,0), new Position(3278,3354,0), new Position(3273,3360,0), new Position(3277,3364,0), new Position(3285,3366,0), new Position(3277,3364,0), new Position(3278,3370,0), new Position(3280,3371,0), new Position(3284,3367,0),}; final Area miningLoc = new Area( new Position(3283,3368,0), new Position(3289,3362,0)); final Area wcLoc = new Area( new Position(3283,3368,0), new Position(3289,3362,0)); final Area lumby = new Area( new Position(3229,3233,0), new Position(3235,3227,0)); public void onStart() { EventQueue.invokeLater(initSettings()); } @SuppressWarnings("unused") public Runnable initSettings() { final JFrame frame = new JFrame("Settings"); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent event) { frame.dispose(); Main.this.stop(); } }); frame.setLocationByPlatform(true); String[] botLocs = { "Mining (VE)", "Woodcutting (VE)", "Random" }; final JComboBox<String> botLocBox = new JComboBox<String>(botLocs); frame.add(botLocBox); JButton startbtn = new JButton("Start"); startbtn.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e) { guiWait = false; botLoc = (String) botLocBox.getSelectedItem(); frame.dispose(); }}); frame.add(startbtn); frame.pack(); frame.setVisible(true); return null; } public int onLoop() throws InterruptedException { //use values from settings (logType) if(guiWait = false){ if(botLoc.equals("Mining VE")){ if(!miningLoc.contains(players.myPosition())){ log("Walking to Varrock East Mine"); localWalker.walkPath(path1); }else{ log("You are already in the Mining Area!"); } } else if(botLoc.equals("Woodcutting VE")){ if(!wcLoc.contains(players.myPosition())){ log("Walking to Varrock East Trees"); localWalker.walkPath(path2); }else{ log("You are already in the Woodcutting Area!"); } } } else { log("Waiting for GUI Settings to be completed..."); Main.class.wait(); } return 600; } public void onPaint(Graphics2D g) { //This is where you will put your code for paint(s) final Color color1 = new Color(153, 153, 153); final Color color2 = new Color(255, 0, 0); final Color color3 = new Color(0, 0, 0); final Color color4 = new Color(255, 255, 255); final BasicStroke stroke1 = new BasicStroke(3); final Font font1 = new Font("Arial", 0, 9); final Font font2 = new Font("Arial", 1, 21); final Font font3 = new Font("Arial", 0, 15); final Font font4 = new Font("Arial", 0, 8); g.setColor(color1); g.fillRect(9, 346, 500, 126); g.setColor(color2); g.setStroke(stroke1); g.drawRect(9, 346, 500, 126); g.setFont(font1); g.setColor(color1); g.drawString("Version: ", 15, 332); g.setFont(font2); g.setColor(color3); g.drawString("EXP p/h:", 17, 378); g.setColor(color4); g.drawString("EXP p/h:", 14, 375); g.setColor(color3); g.drawString("Gold p/h:", 18, 417); g.setColor(color4); g.drawString("Gold p/h:", 15, 414); g.setColor(color3); g.drawString("Run Time:", 18, 454); g.setColor(color4); g.drawString("Run Time:", 15, 451); g.setColor(color3); g.drawString("Current Level:", 270, 380); g.setColor(color4); g.drawString("Current Level:", 267, 377); g.setColor(color3); g.drawString("Levels Gained:", 271, 417); g.setColor(color4); g.drawString("Levels Gained:", 268, 414); g.setColor(color3); g.drawString("Status:", 273, 453); g.setColor(color4); g.drawString("Status:", 270, 450); g.setFont(font3); g.drawString("EXPPH", 121, 375); g.drawString("GOLDPH", 128, 414); g.drawString("RUNTIME", 137, 450); g.drawString("40", 439, 377); g.drawString("+29", 444, 414); g.drawString("Running: " +botLoc, 370, 452); g.setFont(font4); g.setColor(color1); g.drawString("0.29", 59, 332); } } Quote Link to comment Share on other sites More sharing options...
FrostBug Posted August 22, 2015 Share Posted August 22, 2015 Alright so the Script actually starts up now but now it freezes the client and gives me another error. And my combobox won't show up in the GUI either. And the current source: import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.WindowAdapter; import javax.swing.*; import org.osbot.rs07.api.map.Area; import org.osbot.rs07.api.map.Position; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import com.sun.glass.events.WindowEvent; @ScriptManifest(author = "Chambo", info = "Chambo's Bot Walker", logo = "", name = "Chambo's Bot Walker PRO", version = 0.89) public class Main extends Script { public String botLoc; public boolean guiWait = true; public boolean shouldWalk = false; Position[] path1 = new Position[] { new Position(3233,3236,0), new Position(3232,3230,0), new Position(3233,3236,0), new Position(3232,3246,0), new Position(3232,3253,0), new Position(3231,3257,0), new Position(3240,3261,0), new Position(3241,3263,0), new Position(3241,3265,0), new Position(3242,3266,0), new Position(3243,3268,0), new Position(3243,3270,0), new Position(3240,3278,0), new Position(3239,3282,0), new Position(3239,3296,0), new Position(3238,3283,0), new Position(3238,3293,0), new Position(3238,3304,0), new Position(3242,3309,0), new Position(3248,3315,0), new Position(3252,3318,0), new Position(3256,3324,0), new Position(3263,3326,0), new Position(3268,3328,0), new Position(3274,3338,0), new Position(3278,3345,0), new Position(3274,3338,0), new Position(3277,3343,0), new Position(3278,3345,0), new Position(3278,3345,0), new Position(3282,3351,0), new Position(3278,3354,0), new Position(3273,3360,0), new Position(3277,3364,0), new Position(3285,3366,0), new Position(3277,3364,0), new Position(3278,3370,0), new Position(3280,3371,0), new Position(3284,3367,0),}; Position[] path2 = new Position[] { new Position(3233,3236,0), new Position(3232,3230,0), new Position(3233,3236,0), new Position(3232,3246,0), new Position(3232,3253,0), new Position(3231,3257,0), new Position(3240,3261,0), new Position(3241,3263,0), new Position(3241,3265,0), new Position(3242,3266,0), new Position(3243,3268,0), new Position(3243,3270,0), new Position(3240,3278,0), new Position(3239,3282,0), new Position(3239,3296,0), new Position(3238,3283,0), new Position(3238,3293,0), new Position(3238,3304,0), new Position(3242,3309,0), new Position(3248,3315,0), new Position(3252,3318,0), new Position(3256,3324,0), new Position(3263,3326,0), new Position(3268,3328,0), new Position(3274,3338,0), new Position(3278,3345,0), new Position(3274,3338,0), new Position(3277,3343,0), new Position(3278,3345,0), new Position(3278,3345,0), new Position(3282,3351,0), new Position(3278,3354,0), new Position(3273,3360,0), new Position(3277,3364,0), new Position(3285,3366,0), new Position(3277,3364,0), new Position(3278,3370,0), new Position(3280,3371,0), new Position(3284,3367,0),}; final Area miningLoc = new Area( new Position(3283,3368,0), new Position(3289,3362,0)); final Area wcLoc = new Area( new Position(3283,3368,0), new Position(3289,3362,0)); final Area lumby = new Area( new Position(3229,3233,0), new Position(3235,3227,0)); public void onStart() { EventQueue.invokeLater(initSettings()); } @SuppressWarnings("unused") public Runnable initSettings() { final JFrame frame = new JFrame("Settings"); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent event) { frame.dispose(); Main.this.stop(); } }); frame.setLocationByPlatform(true); String[] botLocs = { "Mining (VE)", "Woodcutting (VE)", "Random" }; final JComboBox<String> botLocBox = new JComboBox<String>(botLocs); frame.add(botLocBox); JButton startbtn = new JButton("Start"); startbtn.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e) { guiWait = false; botLoc = (String) botLocBox.getSelectedItem(); frame.dispose(); }}); frame.add(startbtn); frame.pack(); frame.setVisible(true); return null; } public int onLoop() throws InterruptedException { //use values from settings (logType) if(guiWait = false){ if(botLoc.equals("Mining VE")){ if(!miningLoc.contains(players.myPosition())){ log("Walking to Varrock East Mine"); localWalker.walkPath(path1); }else{ log("You are already in the Mining Area!"); } } else if(botLoc.equals("Woodcutting VE")){ if(!wcLoc.contains(players.myPosition())){ log("Walking to Varrock East Trees"); localWalker.walkPath(path2); }else{ log("You are already in the Woodcutting Area!"); } } } else { log("Waiting for GUI Settings to be completed..."); Main.class.wait(); } return 600; } public void onPaint(Graphics2D g) { //This is where you will put your code for paint(s) final Color color1 = new Color(153, 153, 153); final Color color2 = new Color(255, 0, 0); final Color color3 = new Color(0, 0, 0); final Color color4 = new Color(255, 255, 255); final BasicStroke stroke1 = new BasicStroke(3); final Font font1 = new Font("Arial", 0, 9); final Font font2 = new Font("Arial", 1, 21); final Font font3 = new Font("Arial", 0, 15); final Font font4 = new Font("Arial", 0, 8); g.setColor(color1); g.fillRect(9, 346, 500, 126); g.setColor(color2); g.setStroke(stroke1); g.drawRect(9, 346, 500, 126); g.setFont(font1); g.setColor(color1); g.drawString("Version: ", 15, 332); g.setFont(font2); g.setColor(color3); g.drawString("EXP p/h:", 17, 378); g.setColor(color4); g.drawString("EXP p/h:", 14, 375); g.setColor(color3); g.drawString("Gold p/h:", 18, 417); g.setColor(color4); g.drawString("Gold p/h:", 15, 414); g.setColor(color3); g.drawString("Run Time:", 18, 454); g.setColor(color4); g.drawString("Run Time:", 15, 451); g.setColor(color3); g.drawString("Current Level:", 270, 380); g.setColor(color4); g.drawString("Current Level:", 267, 377); g.setColor(color3); g.drawString("Levels Gained:", 271, 417); g.setColor(color4); g.drawString("Levels Gained:", 268, 414); g.setColor(color3); g.drawString("Status:", 273, 453); g.setColor(color4); g.drawString("Status:", 270, 450); g.setFont(font3); g.drawString("EXPPH", 121, 375); g.drawString("GOLDPH", 128, 414); g.drawString("RUNTIME", 137, 450); g.drawString("40", 439, 377); g.drawString("+29", 444, 414); g.drawString("Running: " +botLoc, 370, 452); g.setFont(font4); g.setColor(color1); g.drawString("0.29", 59, 332); } } You're passing null to the invokeLater method, since initSettings returns null as a runnable. Just create a new runnable that invokes initSettings. eg. public void onStart() { EventQueue.invokeLater(() -> initSettings()); } ^ using a lambda expression, so make sure you're on source 8 Quote Link to comment Share on other sites More sharing options...