Share variable of one class with another

Discussion in 'Plugin Development' started by Alias_Me, Jan 19, 2019.

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

    Alias_Me

    So this is more general Java than Bukkit but if my plugin sends a player a clickable message which executes a command, how can I give the class that executes the command a variable from the class that send the message?

    More specific:
    One class is an EventHandler which checks for right-clicks on signs and sends the player a message which can be clicked to execute a command.
    That class is supposed to give the Location of the sign to the class that executes the command to check the distance between the player and the sign on clicking the message(!not on clicking the sign) to make sure the player can`t click on the sign to receive the message, then walk away and click on the message to execute the command from somewhere else entirely.

    So yeah, its kind of a basic question, but I have no idea how to do this and other forum posts werent much help sadly.
     
  2. Offline

    timtower Administrator Administrator Moderator

    @Alias_Me Put the variable in the main class, then make a getter for it that both classes can access.
     
Thread Status:
Not open for further replies.

Share This Page