Package de.fairplay.storage
Class OwnershipStorage
java.lang.Object
de.fairplay.storage.OwnershipStorage
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 coordinatesentity_ownership— keyed by entity UUID
-
Constructor Summary
ConstructorsConstructorDescriptionOwnershipStorage(FairPlayPlugin plugin) Constructs a new OwnershipStorage with the given plugin instance. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the SQLite connection.getBlockOwner(String world, int x, int y, int z) Returns the owner of the block at the given coordinates, ornullif unowned.getBlockOwner(org.bukkit.block.Block block) Returns the owner of the given block, ornullif unowned.getEntityOwner(UUID entityUUID) Returns the owner of an entity, ornullif unowned (wild / not tracked).voidOpens the SQLite connection and creates the tables if they do not exist yet.voidremoveBlockOwner(String world, int x, int y, int z) Removes the ownership entry for a block identified by coordinates.voidremoveBlockOwner(org.bukkit.block.Block block) Removes the ownership entry for a block.voidremoveEntityOwner(UUID entityUUID) Removes the ownership entry for an entity.voidsetBlockOwner(String world, int x, int y, int z, UUID owner) Stores or replaces the owner of a block identified by world name and coordinates.voidsetBlockOwner(org.bukkit.block.Block block, UUID owner) Stores or replaces the owner of a block.voidsetEntityOwner(UUID entityUUID, UUID owner) Stores or replaces the owner of an entity (vehicle, bred or tamed animal).
-
Constructor Details
-
OwnershipStorage
Constructs a new OwnershipStorage with the given plugin instance.- Parameters:
plugin- the owningFairPlayPlugin, 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
Stores or replaces the owner of a block.- Parameters:
block- the block whose ownership is setowner- UUID of the owning player
-
setBlockOwner
Stores or replaces the owner of a block identified by world name and coordinates. Use this overload when aBlockreference is not available (e.g. from aBlockStatelist).- Parameters:
world- world namex- block X coordinatey- block Y coordinatez- block Z coordinateowner- UUID of the owning player
-
getBlockOwner
Returns the owner of the given block, ornullif unowned.- Parameters:
block- the block to look up- Returns:
- owner UUID, or
null
-
getBlockOwner
Returns the owner of the block at the given coordinates, ornullif unowned.- Parameters:
world- world namex- block X coordinatey- block Y coordinatez- 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
Removes the ownership entry for a block identified by coordinates. No-op if the block was not owned.- Parameters:
world- world namex- block X coordinatey- block Y coordinatez- block Z coordinate
-
setEntityOwner
Stores or replaces the owner of an entity (vehicle, bred or tamed animal).- Parameters:
entityUUID- UUID of the entityowner- UUID of the owning player
-
getEntityOwner
Returns the owner of an entity, ornullif unowned (wild / not tracked).- Parameters:
entityUUID- UUID of the entity- Returns:
- owner UUID, or
null
-
removeEntityOwner
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.
-