Class OwnershipStorage

java.lang.Object
de.fairplay.storage.OwnershipStorage

public class OwnershipStorage extends Object
Persists block and entity ownership in a local SQLite database (plugins/FairPlay/ownership.db).

Two tables are used:

  • block_ownership — keyed by world name + x/y/z coordinates
  • entity_ownership — keyed by entity UUID
All methods are synchronous and must be called from the server main thread.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a new OwnershipStorage with the given plugin instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Closes the SQLite connection.
    getBlockOwner(String world, int x, int y, int z)
    Returns the owner of the block at the given coordinates, or null if unowned.
    getBlockOwner(org.bukkit.block.Block block)
    Returns the owner of the given block, or null if unowned.
    getEntityOwner(UUID entityUUID)
    Returns the owner of an entity, or null if unowned (wild / not tracked).
    void
    Opens the SQLite connection and creates the tables if they do not exist yet.
    void
    removeBlockOwner(String world, int x, int y, int z)
    Removes the ownership entry for a block identified by coordinates.
    void
    removeBlockOwner(org.bukkit.block.Block block)
    Removes the ownership entry for a block.
    void
    removeEntityOwner(UUID entityUUID)
    Removes the ownership entry for an entity.
    void
    setBlockOwner(String world, int x, int y, int z, UUID owner)
    Stores or replaces the owner of a block identified by world name and coordinates.
    void
    setBlockOwner(org.bukkit.block.Block block, UUID owner)
    Stores or replaces the owner of a block.
    void
    setEntityOwner(UUID entityUUID, UUID owner)
    Stores or replaces the owner of an entity (vehicle, bred or tamed animal).

    Methods inherited from class java.lang.Object

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

    • OwnershipStorage

      public OwnershipStorage(FairPlayPlugin plugin)
      Constructs a new OwnershipStorage with the given plugin instance.
      Parameters:
      plugin - the owning FairPlayPlugin, used for data folder access and logging
  • Method Details

    • initialize

      public void initialize()
      Opens the SQLite connection and creates the tables if they do not exist yet. Must be called once during plugin enable before any other method.
    • setBlockOwner

      public void setBlockOwner(org.bukkit.block.Block block, UUID owner)
      Stores or replaces the owner of a block.
      Parameters:
      block - the block whose ownership is set
      owner - UUID of the owning player
    • setBlockOwner

      public void setBlockOwner(String world, int x, int y, int z, UUID owner)
      Stores or replaces the owner of a block identified by world name and coordinates. Use this overload when a Block reference is not available (e.g. from a BlockState list).
      Parameters:
      world - world name
      x - block X coordinate
      y - block Y coordinate
      z - block Z coordinate
      owner - UUID of the owning player
    • getBlockOwner

      public UUID getBlockOwner(org.bukkit.block.Block block)
      Returns the owner of the given block, or null if unowned.
      Parameters:
      block - the block to look up
      Returns:
      owner UUID, or null
    • getBlockOwner

      public UUID getBlockOwner(String world, int x, int y, int z)
      Returns the owner of the block at the given coordinates, or null if unowned.
      Parameters:
      world - world name
      x - block X coordinate
      y - block Y coordinate
      z - block Z coordinate
      Returns:
      owner UUID, or null
    • removeBlockOwner

      public void removeBlockOwner(org.bukkit.block.Block block)
      Removes the ownership entry for a block. No-op if the block was not owned.
      Parameters:
      block - the block whose ownership is removed
    • removeBlockOwner

      public void removeBlockOwner(String world, int x, int y, int z)
      Removes the ownership entry for a block identified by coordinates. No-op if the block was not owned.
      Parameters:
      world - world name
      x - block X coordinate
      y - block Y coordinate
      z - block Z coordinate
    • setEntityOwner

      public void setEntityOwner(UUID entityUUID, UUID owner)
      Stores or replaces the owner of an entity (vehicle, bred or tamed animal).
      Parameters:
      entityUUID - UUID of the entity
      owner - UUID of the owning player
    • getEntityOwner

      public UUID getEntityOwner(UUID entityUUID)
      Returns the owner of an entity, or null if unowned (wild / not tracked).
      Parameters:
      entityUUID - UUID of the entity
      Returns:
      owner UUID, or null
    • removeEntityOwner

      public void removeEntityOwner(UUID entityUUID)
      Removes the ownership entry for an entity. Typically called when the entity dies. No-op if the entity was not tracked.
      Parameters:
      entityUUID - UUID of the entity
    • close

      public void close()
      Closes the SQLite connection. Called during plugin disable.