Hi, Im making a custom map plugin and im having trouble. When i make a map the server crashes. heres part of the code: @EventHandler public void onInitMap(MapInitializeEvent e){ MapView view = e.getMap(); for (MapRenderer render : view.getRenderers()){ view.removeRenderer(render); } view.addRenderer(new MapRenderer() { public void render (MapView view, MapCanvas canvas, Player p) { canvas.drawText(10, 15, MinecraftFont.Font, "Welcome to a serverl!" ); canvas.drawImage(10, 30, new ImageIcon(getDataFolder().getPath() + "/pic.png" ).getImage()); } }); }
@danichef It kicks you because the server is most likely hanging. (I don't know for sure because you did not post the console logs). This means that there is something running longer than it should. Try figuring out what is causing this delay. By debugging, that just means write a line that shows the code is working/ running. It can be as simple as printing out "this line has been activated" to show that the line has been read and activated.
@danichef The image cannot be found. It is saying the image's width and length are -1, so the file does not exist. Are you sure you are providing the correct file location? Try using the following to get the image: Code: new File(getDataFolder(),"pic.png"); This will get the image at "/sever/plugins/<your plugin>/pic.png"
It gives me this error: The method drawImage(int, int, Image) in the type MapCanvas is not applicable for the arguments (int, int, File)
And if i wanted to take any file from the folder not just the one i named would i do it like i did before of doing pic.png ive tryed it but it gave me error
@danichef If you wanted to get any file from that folder, just get the File by using the method I provided. If you are getting an error, please post the error with the code that causes the error.