1.17.1 Get Offline Player effects

Discussion in 'Spigot Plugin Development' started by SkrtPvP, Jun 27, 2021.

  1. How can I get and edit the effects of offline players who have ever logged into the server and disconnected with potion effects active?
  2. What exactly are you trying to do with this? If you want to make sure a specific person has a potion effect, you can just give it to them on the PlayerJoinEvent
    Code (Java):
    if (event.getPlayer().getName().equals("playernamehere")) {
         // Add potion effect here
    Or, if you want to maybe change some player data while a player is offline, you can edit player data in the world folder with JNBT (Java NBT library).
  3. Or, remove the effects on playerQuit().
    What would be the point of changing the player's properties if they never joined the server again?
  4. The ideal solution would be to cache the PotionEffects in the PlayerQuitEvent, from there just save any specific PotionEffects in Map<UUID, PotionEffect[]> and just apply the effects when the user joins.