Setting Inventory Menu for a Specific Player

Discussion in 'Plugin Development' started by TheCakeMaster, Nov 5, 2014.

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

    TheCakeMaster

    So I have a problem. I am making an unlockable menu, where players can click on item in an inventory GUI, then if the player has not clicked it before they will be added to an array to check if the player has unlocked it yet. When a player unlocks an item, it displays that in the GUI by changing the item/item name. The problem is, when I set an item in the GUI it will display for all players.
    How can I set an item so only the player who has unlocked the item can see it?
    Any help is appreciated! ;)
     
  2. Offline

    mine-care

    Can we see your current progress ?
     
  3. Offline

    TheCakeMaster

    Here is a bit of it:
    (The bottom is the part is the problem, also createDisplay() is my method for setting items)
    Code:java
    1.  
    2. @EventHandler
    3. public void click(InventoryClickEvent event) {
    4. Player player = (Player) event.getWhoClicked();
    5. ItemStack clicked = event.getCurrentItem();
    6. Inventory inv = event.getInventory();
    7. String player1 = player.getName();
    8.  
    9. //MainGadgetMenu
    10. if (inv.getName().equals(mainGadgetMenu.getName())) {
    11. if (clicked.getType() == Material.HAY_BLOCK) {
    12. event.setCancelled(true);
    13. player.closeInventory();
    14. player.openInventory(petGadgetMenu);
    15. }
    16. if (clicked.getType() == Material.DIAMOND_HELMET) {
    17. event.setCancelled(true);
    18. player.sendMessage(ChatColor.YELLOW+"Still in development!");
    19. }
    20. if (clicked.getType() == Material.FIRE) {
    21. event.setCancelled(true);
    22. player.sendMessage(ChatColor.YELLOW+"Still in development!");
    23. }
    24. if (clicked.getType() == Material.NETHER_STAR) {
    25. event.setCancelled(true);
    26. player.sendMessage(ChatColor.YELLOW+"Still in development!");
    27. }
    28. }
    29.  
    30. //PetGadgetMenu
    31. if (inv.getName().equals(petGadgetMenu.getName())) {
    32. if (clicked.getItemMeta().getDisplayName().equals("§cSheep Pet") || clicked.getItemMeta().getDisplayName().equals("")) {
    33. if (!sheepPet.contains(player1)) { //TODO check if player has the credits
    34. player.sendMessage(stek+ChatColor.YELLOW+"Unlocked sheep pet!");
    35. createDisplay(Material.MONSTER_EGG, petGadgetMenu, 1, "§aSheep Pet", ChatColor.GOLD+("Click to activate!"), (short) 91);
    36. sheepPet.add(player1);
    37. } else {
    38. player.sendMessage(stek+ChatColor.GREEN+"Activated sheep pet!");
    39.  
    40. }
    41. event.setCancelled(true);
    42. }
    43. }
    44. }
    45.  
    46. Any help?
    47.  
    48. EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 14, 2016
  4. Offline

    WesJD

  5. Offline

    TheCakeMaster

    How would I do that?
     
Thread Status:
Not open for further replies.

Share This Page