Menu help

Discussion in 'Plugin Development' started by CrashBandiMan, May 25, 2015.

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

    CrashBandiMan

    Hi there. i am working on an "outfit" plugin. The player will click on a certain NPC and it will open a menu with a preview of the outfit as well as a "purchase" and "cancel" button. Also, when the player has bought an outfit, it will appear in a menu when they do the /outfits command. But i have a couple of questions:

    1. Is there a RightClickEvent for clicking on an NPC, also if there was a way to open a specific menu based on the name of the npc via a Nametag.
    2. I want to have the player be only be able to click an NPC where they haven't bought something from. Meaning if they already purchased one outfit, they wont be able to purchase it again.
    3. After a player has purchased an outfit it will appear in a menu when the /outfits command is ran.

    thanks!
     
  2. Offline

    marknzl

    Hi,

    I think there isn't an event for "right clicking" but you could use the EnityInteractEvent and check if the player performs a right click and check's if the entity is an NPC. For question 2 you could use a config file to check if they have already purchased the outfit and. Not really sure of question 3.
     
  3. Offline

    CrashBandiMan

    @marknzl awesome! thanks for the help. i will see if it works!
     
  4. Offline

    nverdier

    To do something on right click, you would use a PlayerInteractEntityEvent, and check if what #getRightClicked() returns is an NCP. You can get the NCP from that, and get the name of it to do a specific action.

    Just add a check if they have bought something before you open it.

    Add the outfit to some kind of Collection and then put it in an Inventory when the command is run.
     
  5. Offline

    CrashBandiMan

    @nverdier alright, i understand the NPC part, but im a bit confused as to add a check, and the add a "collection". i dont know if i would store the data in a config file or what.
     
  6. Offline

    Zombie_Striker

    @CrashBandiMan
    Storing it in a config saves the data, any other way would have the data deleted upon restart.
     
  7. You could store data on MetaData it will be removed on restart but you can have saved it on the config, and on chunk load or something like that set the data again, or you just could store the entity uuid and when you right click check if there's any npc with that uuid.
     
Thread Status:
Not open for further replies.

Share This Page