Klasse PipeService
This is the single place that keeps the three representations of a sign in step: the in-memory
PipeRuntime, the persisted PipeSignData, and the physical sign block (its text,
its waxed state and the pipe id stored in its persistent data container). Event listeners and the
GUI call into this service rather than touching persistence directly.
All methods run on the main server thread. Reads and writes are handed to the
StorageExecutor; writes are fire-and-forget, the registry being the source of truth.
- Seit:
- 0.1.0
-
Feldübersicht
FelderModifizierer und TypFeldBeschreibungstatic final StringKey under which a sign stores its pipe id in its persistent data container. -
Konstruktorübersicht
KonstruktorenKonstruktorBeschreibungPipeService(org.bukkit.plugin.Plugin plugin, PipeRegistry registry, StorageExecutor storageExecutor, NetworkStorage networkStorage, PipeStorage pipeStorage, FilterStorage filterStorage, TrustStorage trustStorage) Creates the service. -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungvoidassignNetwork(PipeRuntime pipe, UUID newNetworkId) Reassigns a sign to another of its owner's networks, persisting and re-rendering it.voidassignToSharedNetwork(PipeRuntime pipe, NetworkRuntime target) Moves a sign into a shared network owned by someone else, transferring ownership to that owner.booleancan(org.bukkit.entity.Player player, PipeRuntime pipe, TrustPermission permission) Returns whether a player may perform an action on a sign: always for the sign's owner and for admins, otherwise only if the player is trusted in the sign's network with that permission.createCollector(UUID ownerId, org.bukkit.block.Block signBlock) Creates a collector sign: a networked source that vacuums ground items instead of draining a container.createNetwork(UUID ownerId) Creates a new network for an owner with an auto-generated, collision-free name ("LagerN"with the lowest freeN) and persists it.createNetwork(UUID ownerId, String name) Creates a new network for an owner with the given display name and persists it.createSign(UUID ownerId, org.bukkit.block.Block signBlock, ResolvedContainer container) Creates and registers a new pipe sign owned by a player, persisting it asynchronously.intdeleteNetworkForce(NetworkRuntime network) Force-deletes a network together with all its signs.booleandeleteNetworkIfEmpty(NetworkRuntime network) Deletes a network if it has no signs.voidfinalizeSignLater(org.bukkit.block.Block signBlock, PipeRuntime pipe) Schedules stamping of the physical sign block one tick later.findNetworkByName(UUID ownerId, String name) Finds an owner's network by display name, case-insensitively.invalidPipesOf(UUID ownerId) Returns the currently-invalid signs owned by a player.booleanisOwnerOrAdmin(org.bukkit.entity.Player player, PipeRuntime pipe) Gibt whether a player owns a sign or is an admin zurück.voidloadAll()Loads all networks and signs from the database into the registry.networkById(UUID networkId) Looks up a network by id alone, across all owners.networkOf(PipeRuntime pipe) Returns the network a sign belongs to.networksOf(UUID ownerId) Returns all networks owned by a player, in insertion order.org.bukkit.NamespacedKeyReturns the namespaced key under which pipe ids are stored on sign blocks.voidremoveSign(PipeRuntime pipe) Removes a sign from the registry and deletes it from the database asynchronously.voidrenameNetwork(NetworkRuntime network, String newName) Renames a network, persisting the change and re-rendering the network's signs (whose second line shows the network name).voidrevalidate(PipeRuntime pipe, ResolvedContainer container) Re-checks and reactivates a previously-invalid sign whose sign block and container are back.voidrunNextTick(Runnable task) Runs a task on the next server tick.voidsaveFilters(PipeRuntime pipe) Persists a sign's current filter items (whole-list replace).voidsetContainerDirection(PipeRuntime pipe, ContainerDirection direction) Binds a sign to a different adjacent container (the player's chat selection), clears its cached container so the new one is resolved next tick, and persists and re-renders it.voidsetEnabled(PipeRuntime pipe, boolean enabled) Enables or disables a sign, persisting the change.voidsetFilterMode(PipeRuntime pipe, FilterMode filterMode) Sets a sign's input filter mode, persisting and re-rendering it.voidsetMode(PipeRuntime pipe, PipeMode mode) Sets a sign's transport direction, persisting and re-rendering it.intsetNetworkEnabled(NetworkRuntime network, boolean enabled) Enables or disables every sign in a network in one go.voidsetPriority(PipeRuntime pipe, int priority) Sets a sign's delivery priority, persisting and re-rendering it.voidsetTrustFlags(NetworkRuntime network, UUID playerId, int flags) Sets a trusted player's permission bitmask in a network and persists it.sharedNetworksFor(UUID playerId, TrustPermission permission) Returns the networks a player is trusted in, with the given permission granted.intReturns the total number of signs an owner has across all their networks.booleantrust(NetworkRuntime network, UUID playerId) Trusts a player in a network (with no permissions) and persists it.booleanuntrust(NetworkRuntime network, UUID playerId) Removes a player's trust from a network and persists it.voidupdateSignText(org.bukkit.block.Block signBlock, PipeRuntime pipe) Renders the current text of a sign and pushes it to the physical block immediately.
-
Felddetails
-
PIPE_ID_KEY
Key under which a sign stores its pipe id in its persistent data container.- Siehe auch:
-
-
Konstruktordetails
-
PipeService
public PipeService(org.bukkit.plugin.Plugin plugin, PipeRegistry registry, StorageExecutor storageExecutor, NetworkStorage networkStorage, PipeStorage pipeStorage, FilterStorage filterStorage, TrustStorage trustStorage) Creates the service.- Parameter:
plugin- the owning plugin; nevernullregistry- the in-memory registry; nevernullstorageExecutor- the storage thread; nevernullnetworkStorage- network persistence; nevernullpipeStorage- sign persistence; nevernullfilterStorage- filter persistence; nevernulltrustStorage- trust persistence; nevernull
-
-
Methodendetails
-
pipeIdKey
public org.bukkit.NamespacedKey pipeIdKey()Returns the namespaced key under which pipe ids are stored on sign blocks.- Gibt zurück:
- the pipe-id key; never
null
-
loadAll
public void loadAll()Loads all networks and signs from the database into the registry.Runs the queries on the storage thread and builds the registry on the calling (main) thread. Signs whose network is missing are skipped and reported rather than failing the whole load. Containers are not resolved here; that happens lazily, since worlds and chunks may not be loaded yet.
- Löst aus:
StorageException- if a query fails
-
createSign
public PipeRuntime createSign(UUID ownerId, org.bukkit.block.Block signBlock, ResolvedContainer container) Creates and registers a new pipe sign owned by a player, persisting it asynchronously.If the owner has no network yet, a default one ("Lager1") is created first. The sign is created with the default configuration: output, whitelist, priority 1, enabled. The physical sign block is not touched here; call
finalizeSignLater(Block, PipeRuntime)afterwards to stamp it.- Parameter:
ownerId- the owning player'sUUID; nevernullsignBlock- the sign block; nevernullcontainer- the resolved bound container; nevernull- Gibt zurück:
- the newly registered runtime sign
-
createCollector
Creates a collector sign: a networked source that vacuums ground items instead of draining a container. It has no bound container and starts unfiltered (picks up everything), in the owner's default network (created if needed).- Parameter:
ownerId- the owning player; nevernullsignBlock- the sign block; nevernull- Gibt zurück:
- the newly created collector runtime
-
removeSign
Removes a sign from the registry and deletes it from the database asynchronously.- Parameter:
pipe- the sign to remove; nevernull
-
setContainerDirection
Binds a sign to a different adjacent container (the player's chat selection), clears its cached container so the new one is resolved next tick, and persists and re-renders it.- Parameter:
pipe- the sign; nevernulldirection- the chosen container direction; nevernull
-
revalidate
Re-checks and reactivates a previously-invalid sign whose sign block and container are back.- Parameter:
pipe- the sign to reactivate; nevernullcontainer- the freshly-resolved container the sign is bound to; nevernull
-
networkById
Looks up a network by id alone, across all owners.- Parameter:
networkId- the network id; nevernull- Gibt zurück:
- the network, or
nullif not found
-
signCount
Returns the total number of signs an owner has across all their networks.- Parameter:
ownerId- the owning player'sUUID; nevernull- Gibt zurück:
- the owner's total sign count
-
networkOf
Returns the network a sign belongs to.- Parameter:
pipe- the sign; nevernull- Gibt zurück:
- the sign's network, or
nullif it is not registered
-
networksOf
Returns all networks owned by a player, in insertion order.- Parameter:
ownerId- the owning player'sUUID; nevernull- Gibt zurück:
- a fresh list of the owner's networks; never
null
-
invalidPipesOf
Returns the currently-invalid signs owned by a player.- Parameter:
ownerId- the owning player'sUUID; nevernull- Gibt zurück:
- a fresh list of the owner's invalid signs (possibly empty); never
null
-
setMode
Sets a sign's transport direction, persisting and re-rendering it.- Parameter:
pipe- the sign; nevernullmode- the new mode; nevernull
-
setFilterMode
Sets a sign's input filter mode, persisting and re-rendering it.- Parameter:
pipe- the sign; nevernullfilterMode- the new filter mode; nevernull
-
setPriority
Sets a sign's delivery priority, persisting and re-rendering it.- Parameter:
pipe- the sign; nevernullpriority- the new priority (>= 1)
-
setEnabled
Enables or disables a sign, persisting the change.- Parameter:
pipe- the sign; nevernullenabled- the new enabled state
-
saveFilters
Persists a sign's current filter items (whole-list replace).- Parameter:
pipe- the sign; nevernull
-
can
Returns whether a player may perform an action on a sign: always for the sign's owner and for admins, otherwise only if the player is trusted in the sign's network with that permission.- Parameter:
player- the acting player; nevernullpipe- the sign; nevernullpermission- the permission required; nevernull- Gibt zurück:
trueif the action is allowed
-
isOwnerOrAdmin
Gibt whether a player owns a sign or is an admin zurück. Owner-only actions (breaking regardless of trust flags is not owner-only; reassigning the network is).- Parameter:
player- the acting player; nevernullpipe- the sign; nevernull- Gibt zurück:
- whether a player owns a sign or is an admin
-
trust
Trusts a player in a network (with no permissions) and persists it.- Parameter:
network- the network; nevernullplayerId- the player to trust; nevernull- Gibt zurück:
trueif the player was newly trusted
-
untrust
Removes a player's trust from a network and persists it.- Parameter:
network- the network; nevernullplayerId- the player to untrust; nevernull- Gibt zurück:
trueif the player was trusted and is now removed
-
setTrustFlags
Sets a trusted player's permission bitmask in a network and persists it.- Parameter:
network- the network; nevernullplayerId- the trusted player; nevernullflags- the new permission bitmask
-
setNetworkEnabled
Enables or disables every sign in a network in one go.- Parameter:
network- the network; nevernullenabled- the new enabled state for all its signs- Gibt zurück:
- the number of signs whose state actually changed
-
assignNetwork
Reassigns a sign to another of its owner's networks, persisting and re-rendering it.- Parameter:
pipe- the sign; nevernullnewNetworkId- the target network id; must belong to the same owner
-
createNetwork
Creates a new network for an owner with an auto-generated, collision-free name ("LagerN"with the lowest freeN) and persists it.- Parameter:
ownerId- the owning player'sUUID; nevernull- Gibt zurück:
- the newly created and registered network
-
createNetwork
Creates a new network for an owner with the given display name and persists it.- Parameter:
ownerId- the owning player'sUUID; nevernullname- the display name; nevernull- Gibt zurück:
- the newly created and registered network
-
findNetworkByName
Finds an owner's network by display name, case-insensitively.- Parameter:
ownerId- the owning player'sUUID; nevernullname- the display name to match; nevernull- Gibt zurück:
- the matching network, or
nullif none matches
-
renameNetwork
Renames a network, persisting the change and re-rendering the network's signs (whose second line shows the network name).- Parameter:
network- the network to rename; nevernullnewName- the new display name; nevernull
-
deleteNetworkIfEmpty
Deletes a network if it has no signs. A network that still has signs is left untouched, so a delete never silently relocates anything — the caller offers a force-delete instead.- Parameter:
network- the network to delete; nevernull- Gibt zurück:
trueif it was empty and is now deleted,falseif it still has signs
-
deleteNetworkForce
Force-deletes a network together with all its signs. The signs are removed from the system (registry and database, open GUIs closed); their physical sign blocks stay in the world as inert, ordinary signs that can be broken normally.- Parameter:
network- the network to delete; nevernull- Gibt zurück:
- the number of signs that were removed with it
-
runNextTick
Runs a task on the next server tick. Used by GUIs to open a follow-up inventory outside of the click event that triggered it.- Parameter:
task- the task to run; nevernull
-
finalizeSignLater
Schedules stamping of the physical sign block one tick later.The block state is only final after the
SignChangeEventcompletes, so the pipe id, the waxed flag and the rendered text are applied on the next tick.- Parameter:
signBlock- the sign block; nevernullpipe- the runtime sign backing it; nevernull
-
updateSignText
Renders the current text of a sign and pushes it to the physical block immediately.Used after a GUI edit. Does nothing if the block is no longer a sign.
- Parameter:
signBlock- the sign block; nevernullpipe- the runtime sign; nevernull
-