Crashing

Discussion in 'Plugin Development' started by danichef, Oct 28, 2016.

Thread Status:
Not open for further replies.
  1. 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());
    }

    });

    }
     
  2. Offline

    Zombie_Striker

    @danichef
    Have you debugged? Does the event get called multiple times? What is hanging the server?
     
  3. Its only runned once and the server kicks me and idk wat u mean by debugged
     
  4. Offline

    Zombie_Striker

    @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.
     
  5. Heres the file:
     
  6. Offline

    Zombie_Striker

    @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"
     
  7. It gives me this error:
    The method drawImage(int, int, Image) in the type MapCanvas is not applicable for the arguments (int, int, File)
     
  8. Offline

    mythbusterma

    @danichef

    A File is not an Image. Provide an Image.
     
  9. Offline

    Zombie_Striker

  10. 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
     
  11. Offline

    Zombie_Striker

    @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.
     
Thread Status:
Not open for further replies.

Share This Page