java.lang.Object
io.github.thebusybiscuit.slimefun4.utils.biomes.BiomeMap<T>
Type Parameters:
T - The stored data type
All Implemented Interfaces:
net.kyori.adventure.key.Keyed, org.bukkit.Keyed

public class BiomeMap<T> extends Object implements org.bukkit.Keyed
BiomeMaps are used to map data values to Biome constants.

We heavily utilise this method of data mapping for GEOResources, especially when supporting multiple versions of Minecraft. This way, we can have different BiomeMaps for different versions of Minecraft, in case Biome names change in-between versions.

The data type can be any type of Object. The most common type is Integer, if you are using complex objects and try to read your BiomeMap from a JsonElement, make sure to provide an adequate BiomeDataConverter to convert the raw json data.

Author:
TheBusyBiscuit
  • Constructor Details

    • BiomeMap

      @ParametersAreNonnullByDefault public BiomeMap(org.bukkit.NamespacedKey namespacedKey)
      This constructs a new BiomeMap with the given NamespacedKey.
      Parameters:
      namespacedKey - The NamespacedKey for this BiomeMap
  • Method Details

    • get

      @Nullable public T get(@Nonnull org.bukkit.block.Biome biome)
    • getOrDefault

      @Nonnull public T getOrDefault(@Nonnull org.bukkit.block.Biome biome, T defaultValue)
    • containsKey

      public boolean containsKey(@Nonnull org.bukkit.block.Biome biome)
    • containsValue

      public boolean containsValue(@Nonnull T value)
    • isEmpty

      public boolean isEmpty()
      This returns whether this BiomeMap is empty. An empty BiomeMap contains no biomes or values.
      Returns:
      Whether this BiomeMap is empty.
    • put

      public boolean put(@Nonnull org.bukkit.block.Biome biome, @Nonnull T value)
    • putAll

      public void putAll(@Nonnull Map<org.bukkit.block.Biome,T> map)
    • putAll

      public void putAll(@Nonnull BiomeMap<T> map)
    • remove

      public boolean remove(@Nonnull org.bukkit.block.Biome biome)
    • getKey

      @Nonnull public org.bukkit.NamespacedKey getKey()
      Specified by:
      getKey in interface org.bukkit.Keyed
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • fromJson

      @ParametersAreNonnullByDefault @Nonnull public static <T> BiomeMap<T> fromJson(org.bukkit.NamespacedKey key, String json, BiomeDataConverter<T> valueConverter) throws BiomeMapException
      Throws:
      BiomeMapException
    • fromJson

      @ParametersAreNonnullByDefault @Nonnull public static <T> BiomeMap<T> fromJson(org.bukkit.NamespacedKey key, String json, BiomeDataConverter<T> valueConverter, boolean isLenient) throws BiomeMapException
      Throws:
      BiomeMapException
    • fromResource

      @ParametersAreNonnullByDefault @Nonnull public static <T> BiomeMap<T> fromResource(org.bukkit.NamespacedKey key, org.bukkit.plugin.java.JavaPlugin plugin, String path, BiomeDataConverter<T> valueConverter) throws BiomeMapException
      Throws:
      BiomeMapException
    • getIntMapFromResource

      @ParametersAreNonnullByDefault @Nonnull public static BiomeMap<Integer> getIntMapFromResource(org.bukkit.NamespacedKey key, org.bukkit.plugin.java.JavaPlugin plugin, String path) throws BiomeMapException
      Throws:
      BiomeMapException
    • getLongMapFromResource

      @ParametersAreNonnullByDefault @Nonnull public static BiomeMap<Long> getLongMapFromResource(org.bukkit.NamespacedKey key, org.bukkit.plugin.java.JavaPlugin plugin, String path) throws BiomeMapException
      Throws:
      BiomeMapException
    • getStringMapFromResource

      @ParametersAreNonnullByDefault @Nonnull public static BiomeMap<String> getStringMapFromResource(org.bukkit.NamespacedKey key, org.bukkit.plugin.java.JavaPlugin plugin, String path) throws BiomeMapException
      Throws:
      BiomeMapException