Class PlayerOptOut

java.lang.Object
valorless.rarespawns.databases.PlayerOptOut

public class PlayerOptOut extends Object
In-memory cache and persistence helper for RareSpawns opt-out players.

Persists a list of player UUIDs under optout.yml (key: "optedout") and maintains a runtime list of currently opted-out online players. Call init() during plugin enable to load existing data and shutdown() during disable to save.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected static valorless.valorlessutils.config.Config
    Backing configuration file (optout.yml).
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    Initializes the storage and loads the opt-out list from optout.yml.
    static boolean
    isOptedOut(org.bukkit.entity.Player player)
    Checks whether the given player is currently opted out.
    static void
    Persists opt-out data to disk.
    static void
    toggleOptOut(org.bukkit.entity.Player player)
    Toggles the player's opt-out status in the in-memory list.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • config

      protected static valorless.valorlessutils.config.Config config
      Backing configuration file (optout.yml).
  • Constructor Details

    • PlayerOptOut

      public PlayerOptOut()
  • Method Details

    • init

      public static void init()
      Initializes the storage and loads the opt-out list from optout.yml.

      Behavior:

      • Creates optout.yml if missing and ensures the "optedout" key exists.
      • Clears any in-memory state.
      • Reads UUID strings from "optedout" and adds those players that are currently online.

    • isOptedOut

      public static boolean isOptedOut(org.bukkit.entity.Player player)
      Checks whether the given player is currently opted out.
      Parameters:
      player - the player to check
      Returns:
      true if the player is in the in-memory opt-out list; false otherwise
    • toggleOptOut

      public static void toggleOptOut(org.bukkit.entity.Player player)
      Toggles the player's opt-out status in the in-memory list.

      Note: Persistence occurs during shutdown().

      Parameters:
      player - the player to toggle
    • shutdown

      public static void shutdown()
      Persists opt-out data to disk. Call on plugin disable.