Class BlockDataService
java.lang.Object
io.github.thebusybiscuit.slimefun4.core.services.BlockDataService
- All Implemented Interfaces:
net.kyori.adventure.key.Keyed
,org.bukkit.Keyed
The
BlockDataService
is similar to the CustomItemDataService
,
it is responsible for storing NBT data inside a TileState
.
This is used to speed up performance and prevent- Author:
- TheBusyBiscuit
-
Constructor Summary
ConstructorsConstructorDescriptionBlockDataService
(org.bukkit.plugin.Plugin plugin, String key) This creates a newBlockDataService
for the givenPlugin
. -
Method Summary
Modifier and TypeMethodDescriptiongetBlockData
(org.bukkit.block.Block b) This method returns the NBT data previously stored inside thisBlock
.getBlockData
(org.bukkit.block.Block b, org.bukkit.NamespacedKey key) org.bukkit.NamespacedKey
getKey()
getUniversalDataUUID
(org.bukkit.block.Block b) boolean
isTileEntity
(org.bukkit.Material type) This method checks whether the givenMaterial
is a Tile Entity.void
setBlockData
(org.bukkit.block.Block b, String value) This will store the givenString
inside the NBT data of the givenBlock
void
setBlockData
(org.bukkit.block.Block b, org.bukkit.NamespacedKey key, String value) This will store the givenString
inside the NBT data of the givenBlock
void
updateUniversalDataUUID
(org.bukkit.block.Block b, String uuid) This will store the universal dataUUID
inside the NBT data of the givenBlock
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.bukkit.Keyed
key
-
Constructor Details
-
BlockDataService
This creates a newBlockDataService
for the givenPlugin
. ThePlugin
and key will together form aNamespacedKey
used to store data on aTileState
.- Parameters:
plugin
- ThePlugin
responsible for this servicekey
- The key under which to store data
-
-
Method Details
-
getKey
public org.bukkit.NamespacedKey getKey()- Specified by:
getKey
in interfaceorg.bukkit.Keyed
-
setBlockData
This will store the givenString
inside the NBT data of the givenBlock
- Parameters:
b
- TheBlock
in which to store the given valuevalue
- The value to store
-
updateUniversalDataUUID
This will store the universal dataUUID
inside the NBT data of the givenBlock
- Parameters:
b
- TheBlock
in which to store the given valueuuid
- The uuid linked to certain slimefun item
-
setBlockData
public void setBlockData(@Nonnull org.bukkit.block.Block b, @Nonnull org.bukkit.NamespacedKey key, @Nonnull String value) This will store the givenString
inside the NBT data of the givenBlock
- Parameters:
b
- TheBlock
in which to store the given valuevalue
- The value to store
-
getBlockData
This method returns the NBT data previously stored inside thisBlock
.- Parameters:
b
- TheBlock
to retrieve data from- Returns:
- The stored value
-
getUniversalDataUUID
-
getBlockData
-
isTileEntity
public boolean isTileEntity(@Nullable org.bukkit.Material type) This method checks whether the givenMaterial
is a Tile Entity. This is used to determine whether theBlock
produced by thisMaterial
produces aTileState
, making it useable as aPersistentDataHolder
. Due toBlock.getState()
being a very expensive call performance-wise though, this simple lookup method is used instead.- Parameters:
type
- TheMaterial
to check for- Returns:
- Whether the given
Material
is considered a Tile Entity
-