Question Chaining completablefutures together

  • After careful consideration and due to limited usage, we’ve made the decision to discontinue the PaperMC forums. Moving forward, we recommend using Hangar for plugin uploads, and for all other community discussions and support, please join us on Discord.

AggerTV

New member
Sep 27, 2023
8
0
1
Hello, I am making a guard plugin, and I need to know if I am using completablefutures in the most efficient way / the correct way.

The following code is from a command which fires guards, it handles both online and offline players. The tricky bit is when the player is offline, because it involves multiple heavy tasks that needs to be performed asynchronously away from the main thread. I've tested the code, and it does work, I am just interested in knowing if it is the best way to chain multiple completablefutures together.
(I've added some comments explaining what the code does)

Hopefully someone with more experience can tell me if this is how you would chain multiple completablefutures together, or if there is just something that could be better about my code in general :)