Solved Need help with rendering a custom image on multiple maps

Discussion in 'Spigot Plugin Development' started by zackatack108, Aug 2, 2018.

  1. Okay so I'm trying to make a plugin to replace one I currently have since it doesn't seem to be updating to 1.13. The plugin I'm trying to replace is to put custom images on maps. Now I followed this tutorial and got it to render an image on one map. However when I try to do a second image it will give me a new map but it also replaces the image on the previous map to be the new image. I don't know why it's doing this since I'm new to doing the images on maps. Any help would be appreciated thanks.

    Code (Text):
        private void createMap(Player player, String[] args) {
            if(args.length == 2) {
                String url = args[1];
                try {
                    BufferedImage image = URL(url));
                    World world = Bukkit.getServer().getWorld("world");
                    MapView view = Bukkit.getServer().createMap(world);              
                    view.addRenderer(new Renderer());
                    ItemStack mapItem = new ItemStack(Material.FILLED_MAP, 1);
                    MapMeta mapMeta = (MapMeta) mapItem.getItemMeta();
                    //int ID = view.getId();              
                } catch (IOException e) {

    Code (Text):
    static BufferedImage image;

        static public void setImage(BufferedImage image_) {
            if(image_ != null) {
                image = image_;

        public void render(MapView view, MapCanvas canvas, Player player) {
            canvas.drawImage(0, 0, image);
  2. Code (Text):
    static BufferedImage image;
    You're sharing the same BufferedImage across all instances of your Renderer- that needs to be non-static.