Calling an Event within an event (i want to type in a /command and a GUI pops up)

  • what I am trying to do is


    type /XXXX and an editable text field with an OK button pops up


    I set the ok button to clickable, but I need the "onGuiElementClickEvent" in order for it to work, I am confused on how to do this.

  • It is rather simple: add another onGuiElementClickEvent(GuiElementClickEvent event) to the same class containing the current onCommand(PlayerCommandEvent event); in it you can test which GUI element has been clicked with the event.getGuielement() method.



    Of course, for this you need to move the GuiTextField label, GuiLabel okbutton (and possibly also the GuiPanel panel) variables from local to the onCommand(PlayerCommandEvent event) method to class-wide fields, so they are kept when the latter method ends.

Participate now!

Don’t have an account yet? Create a new account now and be part of our community!