SetItem in Public menu, only for player click event

Discussion in 'Plugin Development' started by stonebloodtv, Apr 8, 2014.

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

    stonebloodtv

    Hi !

    I make a plugin and, when a player click on item,
    the item is set to new color (Dye)

    The problem is, if 2 player have open the menu inventory open,
    The Dye color is change on another player (With the menu inventory open)

    Code:java
    1. if(i == 10 && e.getCurrentItem().getTypeId() == 159){
    2. connecte();
    3. e.setCancelled(true);
    4. p.sendMessage(ChatColor.GREEN + "Ok");
    5. List<String> l1 = new ArrayList<String>();
    6. ItemStack i1 = new ItemStack(Material.STAINED_CLAY, 1, (short) 5);
    7. ItemMeta m1 = (ItemMeta) i1.getItemMeta();
    8. m1.setDisplayName(ChatColor.GOLD + "Title");
    9. l1.add(ChatColor.GRAY + "Item click");
    10. l1.add(ChatColor.GREEN + "Is click");
    11. m1.setLore(l1);
    12. i1.setItemMeta(m1);
    13. menu_r.setItem(10, i1);
    14. }
    15.  


    And, STAINED_CLAY have a new data value, is work, but is not a good player with a new stained_clay... is a first player who used the open inventory with new clay, and not the player who clicked on clay...


    help :(

    Please...

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
  2. Offline

    coasterman10

    You're probably showing the same inventory to both of the players. The proper way would be to create a new inventory for each player, so whatever they do doesn't affect other players.
     
  3. Offline

    jake000001111

    Is each player given a colored dye ?
    If so you are storing what color each of them have and not storing it as a global variable.
     
Thread Status:
Not open for further replies.

Share This Page