frengor / UltimateAdvancementAPI

A powerful API to create custom advancements for your Minecraft server.
https://modrinth.com/plugin/ultimateadvancementapi
GNU General Public License v3.0
74 stars 5 forks source link

Add support to grant advancements to offline players. #69

Closed tlm9201 closed 1 month ago

tlm9201 commented 1 month ago

Would be nice to have some feature in the API for this. Currently I have to listen to an additional PlayerJoinEvent.

For example, an advancement based on how many chunks are in the town you're currently in.

Currently:

class ChunkClaimAdv extends BaseAdvancement {
// ...
 ChunkClaimAdv(/*...*/) {
  super();

  registerEvent(PlayerJoinEvent.class, event -> {
   // towny claim logic, get players town chunks
  });

  registerEvent(TownChunkClaimEvent.class, event -> {
   // additional towny claim logic, loop thru all ONLINE players in the town.
  } 
 }
}

With offline player support:

class ChunkClaimAdv extends BaseAdvancement {
// ...
 ChunkClaimAdv(/*...*/) {
  super();

  registerEvent(TownChunkClaimEvent.class, event -> {
   // towny claim logic, loop thru all online AND offline players in the town.
   // offline progression is applied by the API on player join
  } 
 }
}
EscanorTargaryen commented 1 month ago

Offline players are already supported, you can find more in the wiki.