I’m making this community plugin for a server. I have a /com add ready, but I want to send the player they want to add a message asking if they want to join the community. How do I get their permission that they want to join the community?
I don’t understand what you are trying to ask. Can you rephrase the question?
I think your talking about request. Like tpa from essentials.
What you need to do is have a request object that holds the player being requested, whether they accepted and the community. After that when they say they want to join you look through all the reqests and match the community and player. From there you have a boolean value of if they accepted.
The better way to do this would be to use the data api because then its saved to the player and the reqests stay even if the server restarts
If MoseMister is correct, we also provide clickable texts with command callbacks that ‘just magically run code’
Behind the scenes they are cached, and have a lifetime, and when clicked, auto submit a command we register and listen to, but if they are being sent in chat I’ve not yet seen anyone run into the issue of the callbacks timing out.
Okay! Can I use the Pagination Service to make it so only 1 item in the pagination contents when clicked runs the command? Also, how do I let them have a lifetime?
You can’t override the default lifetimes by default… https://github.com/SpongePowered/SpongeCommon/blob/74080b0c75e59075f164f5151b08be395e2d17fc/src/main/java/org/spongepowered/common/text/action/SpongeCallbackHolder.java#L61 But you could always code an additional one yourself.
If you find that the inherent (10 minute) lifetimes (implementation detail of SpongeCommon, other implemtations may vary) clash with yours, then I suggest recreating the system or filing a ticket for more control against SpongeAPI.
Texts are hierarchical, so if you have Text(“some text”, Text(TextColors.Red, “red”), “not red”) then only ‘red’ will be red. The same goes if red had a click action, only red would be clickable.
Okay. I made it so when you click accept in the message, you run a command that makes you join it, but is there a way when the text is clicked to run a method, not a command?
TextActions.executeCallback() instead of
TextActions.runCommand() (as @ryantheleach suggested).