PlayerUIElementClickEvent issue

  • ive been trying to get this method to work for a few days now. Ive went as far breaking it down to see if i could find an issue on my end. the event is being triggered but nothing after. Ive also made sure to register a listener


    [Java] Trigger Java event: net.risingworld.api.events.player.ui.PlayerUIElementClickEvent@29b39dca


    Java
    @EventMethod
    public void elementClickTest(PlayerUIElementClickEvent evt){
    player = evt.getPlayer();
    String playername = player.getName();
    System.out.println(playername);
    UIElement elementclicked = evt.getUIElement();
    int id = elementclicked.getID();
    System.out.println(id);
    System.out.println("processing click");
    }

    if this is something on my end i apologize!

  • Java
    @EventMethod
    public void elementClickTest(PlayerUIElementClickEvent evt){
    Player player = evt.getPlayer();
    String playername = player.getName();
    System.out.println(playername);
    int id = evt.getUIElement().getID(); // the id is the elementclicked id so you can just use if (elementclickedID == id){ then do this}
    System.out.println(id);
    System.out.println("processing click");
    }


    so to get the element id do this


    UIElement thiselement = new UIElement();

    elementclickedID = thiselement.getID;



    You can save that in a Attribute so you can fetch it under the clickEvent like this


    player.setAttribute("elementclickedID" elementclickedID);



    then to get it you do player.getAttribute("elementclickedID");


    so

    elementclicked = player.getAttribute("elementclickedID");


    if (evt.getUIElement().getID() == elementclicked){ player.sendtextmessage("then this thiselement was clicked"}

    Yahgiggle Steam Signature, real name Deon Hamilton :thumbsup: Server @ ip 139.99.136.76:4255 Name (The Federation of territory) Unity :thumbsup:

    If at first your code does not work call it version 0.1 with the odd bug :thinking:

    My Own Website




    31245-logo-png
  • you should setup all your UIelements first under say onplayerconnect like this


    Yahgiggle Steam Signature, real name Deon Hamilton :thumbsup: Server @ ip 139.99.136.76:4255 Name (The Federation of territory) Unity :thumbsup:

    If at first your code does not work call it version 0.1 with the odd bug :thinking:

    My Own Website




    31245-logo-png
  • you should setup all your UIelements first under say onplayerconnect like this

    my panel is displaying correctly

    the code i used just to test the event method should get called on any uielementclickevent. all my test code (below) should do is print the player name and element id anytime my panel is clicked.

    Java
    @EventMethod
    public void elementClickTest(PlayerUIElementClickEvent evt){
    player = evt.getPlayer();
    String playername = player.getName();
    System.out.println(playername);
    int elementclicked = evt.getUIElement().getID();
    System.out.println(elementclicked);
    System.out.println("processing click");

Participate now!

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