Giving a map with ID to player

Discussion in 'Plugin Development' started by gmfreaky, Dec 13, 2011.

Thread Status:
Not open for further replies.
  1. Offline

    gmfreaky

    Hi there, I am making a mod which creates special maps. Now I have created a map, but I want to give the map to a player. I used this code:

    Code:
            ItemStack newstack = new ItemStack(Material.MAP);
            newstack.setDurability(newmap.getId());
            p.getInventory().addItem(newstack);
    However, sometimes I cannot pick up the map, and when I give it to other players, it is buggy. Can someone help me on how to do this?

    Thanks,
    Gmfreaky

    Nevermind, I solved it by changing it to:
    Code:
    ItemStack newstack = new ItemStack(Material.MAP,1,newmap.getId());
    p.getInventory().addItem(newstack);
    
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 22, 2016
Thread Status:
Not open for further replies.

Share This Page