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 newBlockDataServicefor 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.NamespacedKeygetKey()getUniversalDataUUID(org.bukkit.block.Block b) booleanisTileEntity(org.bukkit.Material type) This method checks whether the givenMaterialis a Tile Entity.voidsetBlockData(org.bukkit.block.Block b, String value) This will store the givenStringinside the NBT data of the givenBlockvoidsetBlockData(org.bukkit.block.Block b, org.bukkit.NamespacedKey key, String value) This will store the givenStringinside the NBT data of the givenBlockvoidupdateUniversalDataUUID(org.bukkit.block.Block b, String uuid) This will store the universal dataUUIDinside the NBT data of the givenBlockMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.bukkit.Keyed
key
-
Constructor Details
-
BlockDataService
This creates a newBlockDataServicefor the givenPlugin. ThePluginand key will together form aNamespacedKeyused to store data on aTileState.- Parameters:
plugin- ThePluginresponsible for this servicekey- The key under which to store data
-
-
Method Details
-
getKey
public org.bukkit.NamespacedKey getKey()- Specified by:
getKeyin interfaceorg.bukkit.Keyed
-
setBlockData
This will store the givenStringinside the NBT data of the givenBlock- Parameters:
b- TheBlockin which to store the given valuevalue- The value to store
-
updateUniversalDataUUID
This will store the universal dataUUIDinside the NBT data of the givenBlock- Parameters:
b- TheBlockin 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 givenStringinside the NBT data of the givenBlock- Parameters:
b- TheBlockin which to store the given valuevalue- The value to store
-
getBlockData
This method returns the NBT data previously stored inside thisBlock.- Parameters:
b- TheBlockto retrieve data from- Returns:
- The stored value
-
getUniversalDataUUID
-
getBlockData
-
isTileEntity
public boolean isTileEntity(@Nullable org.bukkit.Material type) This method checks whether the givenMaterialis a Tile Entity. This is used to determine whether theBlockproduced by thisMaterialproduces 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- TheMaterialto check for- Returns:
- Whether the given
Materialis considered a Tile Entity
-