Class BlockDataService

java.lang.Object
io.github.thebusybiscuit.slimefun4.core.services.BlockDataService
All Implemented Interfaces:
net.kyori.adventure.key.Keyed, org.bukkit.Keyed

public class BlockDataService extends Object implements 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 Details

    • BlockDataService

      public BlockDataService(@Nonnull org.bukkit.plugin.Plugin plugin, @Nonnull String key)
      This creates a new BlockDataService for the given Plugin. The Plugin and key will together form a NamespacedKey used to store data on a TileState.
      Parameters:
      plugin - The Plugin responsible for this service
      key - The key under which to store data
  • Method Details

    • getKey

      public org.bukkit.NamespacedKey getKey()
      Specified by:
      getKey in interface org.bukkit.Keyed
    • setBlockData

      public void setBlockData(@Nonnull org.bukkit.block.Block b, @Nonnull String value)
      This will store the given String inside the NBT data of the given Block
      Parameters:
      b - The Block in which to store the given value
      value - The value to store
    • updateUniversalDataUUID

      public void updateUniversalDataUUID(@Nonnull org.bukkit.block.Block b, @Nonnull String uuid)
      This will store the universal data UUID inside the NBT data of the given Block
      Parameters:
      b - The Block in which to store the given value
      uuid - 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 given String inside the NBT data of the given Block
      Parameters:
      b - The Block in which to store the given value
      value - The value to store
    • getBlockData

      public Optional<String> getBlockData(@Nonnull org.bukkit.block.Block b)
      This method returns the NBT data previously stored inside this Block.
      Parameters:
      b - The Block to retrieve data from
      Returns:
      The stored value
    • getUniversalDataUUID

      public Optional<UUID> getUniversalDataUUID(@Nonnull org.bukkit.block.Block b)
    • getBlockData

      public Optional<String> getBlockData(@Nonnull org.bukkit.block.Block b, @Nonnull org.bukkit.NamespacedKey key)
    • isTileEntity

      public boolean isTileEntity(@Nullable org.bukkit.Material type)
      This method checks whether the given Material is a Tile Entity. This is used to determine whether the Block produced by this Material produces a TileState, making it useable as a PersistentDataHolder. Due to Block.getState() being a very expensive call performance-wise though, this simple lookup method is used instead.
      Parameters:
      type - The Material to check for
      Returns:
      Whether the given Material is considered a Tile Entity