How to make a target player in events

Discussion in 'Plugin Development' started by MuvooX, Jan 26, 2019.

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

    MuvooX

    How to make a target player in events. Example: InventoryClickEvent??

    Thank you
     
  2. Offline

    timtower Administrator Administrator Moderator

    @MuvooX Could you provide an usage example? Ban gui or something?
     
  3. Offline

    KarimAKL

    @MuvooX If you want to get a player on the server you can try something like this:
    Code:Java
    1. //You can use a player name like this:
    2. Player target = Bukkit.getPlayer("Player name here");
    3.  
    4. //Or a player's UUID like this:
    5. Player target = Bukkit.getPlayer(uuid);
     
  4. Offline

    MuvooX

    @timtower
    For a gui rank system. (Example: player.performcommand("manuadd " + target.getName()))

    Thank you but I already knew that. I just need to make target player for events. But I will try the things you sent.
     
  5. Offline

    KarimAKL

    @MuvooX If you open the GUI with a command then get the player there and give it to the class with the event.
     
  6. Offline

    MuvooX

    How do I do that? Im fairly new?
     
  7. Offline

    KarimAKL

    @MuvooX You could create a HashMap<UUID, UUID> with the key as the executor of the command and the value as the target (set this in the command class) and then in the event class you can get that map and get the value (target) using the key.
     
  8. Offline

    MuvooX

    Bump

    Could you help me?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jan 31, 2019
  9. Offline

    timtower Administrator Administrator Moderator

    What have you tried then?
     
  10. Offline

    MuvooX

    I tried to do hashmaps and arrays but it breaks my plugin for some reason.
     
  11. Offline

    timtower Administrator Administrator Moderator

    Then please post the used code.
     
Thread Status:
Not open for further replies.

Share This Page