Class ConfigUtils

java.lang.Object
at.hugob.plugin.library.config.ConfigUtils

public class ConfigUtils extends Object
Configuration Utils
  • Method Summary

    Modifier and Type
    Method
    Description
    static @Nullable Boolean
    getBoolean(@NotNull org.bukkit.configuration.ConfigurationSection config, @NotNull String path)
    Gets an Boolean from an ConfigurationSection at the specified Path
    static @NotNull net.kyori.adventure.text.Component
    getComponent(@NotNull org.bukkit.configuration.ConfigurationSection config, @NotNull String path)
    Parses a component from the config at a specific path
    static @NotNull net.kyori.adventure.text.Component
    getComponent(@NotNull org.bukkit.configuration.ConfigurationSection config, @NotNull String path, @NotNull net.kyori.adventure.text.minimessage.MiniMessage serializer, @Nullable net.kyori.adventure.text.minimessage.tag.resolver.TagResolver tagResolver, @Nullable net.kyori.adventure.pointer.Pointered target)
    Parses a component from the config at a specific path
    static @NotNull net.kyori.adventure.text.Component
    getComponent(@NotNull org.bukkit.configuration.ConfigurationSection config, @NotNull String path, @Nullable net.kyori.adventure.text.minimessage.tag.resolver.TagResolver tagResolver)
    Parses a component from the config at a specific path
    static @NotNull net.kyori.adventure.text.Component
    getComponent(@NotNull org.bukkit.configuration.ConfigurationSection config, @NotNull String path, @Nullable net.kyori.adventure.text.minimessage.tag.resolver.TagResolver tagResolver, @Nullable net.kyori.adventure.pointer.Pointered target)
    Parses a component from the config at a specific path
    static <T extends net.kyori.adventure.text.Component>
    @NotNull net.kyori.adventure.text.Component
    getComponent(@NotNull org.bukkit.configuration.ConfigurationSection config, @NotNull String path, @NotNull net.kyori.adventure.text.serializer.ComponentSerializer<net.kyori.adventure.text.Component,T,String> serializer)
    Gets an Component from an ConfigurationSection at the specified Path
    static @Nullable Double
    getDouble(@NotNull org.bukkit.configuration.ConfigurationSection config, @NotNull String path)
    Gets an Double from an ConfigurationSection at the specified Path
    static @Nullable Integer
    getInteger(@NotNull org.bukkit.configuration.ConfigurationSection config, @NotNull String path)
    Gets an Integer from an ConfigurationSection at the specified Path
    static @NotNull org.bukkit.inventory.ItemStack
    getItemStack(@NotNull org.bukkit.configuration.ConfigurationSection config)
    Gets an ItemStack from an ConfigurationSection
    static org.bukkit.inventory.ItemStack
    getItemStack(@NotNull org.bukkit.configuration.ConfigurationSection config, @NotNull String path)
    Gets an ItemStack from an ConfigurationSection at the specified Path
    static @Nullable org.bukkit.inventory.ItemType
    getItemType(@NotNull String itemName)
    Converts a String to the corresponding ItemType
    static @Nullable org.bukkit.inventory.ItemType
    getItemType(@NotNull org.bukkit.configuration.ConfigurationSection config, @NotNull String path)
    Gets an ItemType from an ConfigurationSection at the specified Path
    static @Nullable Collection<org.bukkit.inventory.ItemType>
    getItemTypes(@NotNull String itemName)
    Converts a String Tag or ItemType Key to the corresponding Collection<ItemType>
    static @Nullable Collection<org.bukkit.inventory.ItemType>
    getItemTypes(@NotNull org.bukkit.configuration.ConfigurationSection config, @NotNull String path)
    Converts a List<String> in an ConfigurationSection to an EnumSet<Material>
    static @Nullable org.bukkit.Material
    getMaterial(@NotNull String materialName)
    Converts a String to the corresponding Material
    static @Nullable org.bukkit.Material
    getMaterial(@NotNull org.bukkit.configuration.ConfigurationSection config, @NotNull String path)
    Gets an Material from an ConfigurationSection at the specified Path
    static @Nullable EnumSet<org.bukkit.Material>
    getMaterialSet(@NotNull org.bukkit.configuration.ConfigurationSection config, @NotNull String path)
    Converts a List<String> in an ConfigurationSection to an EnumSet<Material>
    static @Nullable String
    getString(@NotNull org.bukkit.configuration.ConfigurationSection config, @NotNull String path)
    Gets an String from an ConfigurationSection at the specified Path
    static @Nullable UUID
    getUUID(@NotNull org.bukkit.configuration.ConfigurationSection config, @NotNull String path)
    Gets an UUID from an ConfigurationSection at the specified Path
    static org.bukkit.configuration.ConfigurationSection
    Tries to convert an Object to an ConfigurationSection
    static @NotNull net.kyori.adventure.text.Component
    parseComponent(@NotNull org.bukkit.configuration.ConfigurationSection config, @NotNull String text, @Nullable net.kyori.adventure.text.minimessage.tag.resolver.TagResolver tagResolver, @Nullable net.kyori.adventure.pointer.Pointered target)
    Parses a text into a Component and tries to parse any references (<ref:'<path>'>) that it finds
    static @NotNull net.kyori.adventure.text.Component
    parseComponent(@NotNull org.bukkit.configuration.ConfigurationSection config, @NotNull List<String> text, @Nullable net.kyori.adventure.text.minimessage.tag.resolver.TagResolver tagResolver, @Nullable net.kyori.adventure.pointer.Pointered target)
    Parses a list of texts into a Component seperated by new lines and tries to parse any references (<ref:'<path>'>) that it finds
    static @NotNull List<net.kyori.adventure.text.Component>
    parseComponentList(@NotNull org.bukkit.configuration.ConfigurationSection config, @NotNull List<String> text, @Nullable net.kyori.adventure.text.minimessage.tag.resolver.TagResolver tagResolver, @Nullable net.kyori.adventure.pointer.Pointered target)
    Parses a list of texts into a List of Components seperated by new lines and tries to parse any references (<ref:'<path>'>) that it finds
    static @Nullable net.kyori.adventure.key.Key
    parseKey(@NotNull String key)
    Parses a String into a Key
    static @NotNull List<? extends net.kyori.adventure.text.Component>
    parseLoreComponentList(@NotNull org.bukkit.configuration.ConfigurationSection config, @NotNull List<String> text, @Nullable net.kyori.adventure.text.minimessage.tag.resolver.TagResolver tagResolver, @Nullable net.kyori.adventure.pointer.Pointered target)
    Parses a list of texts into a List of Components seperated by new lines and tries to parse any references (<ref:'<path>'>) that it finds

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • objectToConfigurationSection

      public static org.bukkit.configuration.ConfigurationSection objectToConfigurationSection(Object object)
      Tries to convert an Object to an ConfigurationSection
      Parameters:
      object - The object that should be turned into a ConfigurationSection
      Returns:
      A ConfigurationSection if successful else null
    • getMaterialSet

      @Nullable public static @Nullable EnumSet<org.bukkit.Material> getMaterialSet(@NotNull @NotNull org.bukkit.configuration.ConfigurationSection config, @NotNull @NotNull String path)
      Converts a List<String> in an ConfigurationSection to an EnumSet<Material>
      Parameters:
      config - the ConfigurationSection where the List<String> is in
      path - the path to the List<String> in the ConfigurationSection
      Returns:
      the created EnumSet<Material>, null when the List<String> wasn't found
    • getMaterial

      @Nullable public static @Nullable org.bukkit.Material getMaterial(@NotNull @NotNull org.bukkit.configuration.ConfigurationSection config, @NotNull @NotNull String path)
      Gets an Material from an ConfigurationSection at the specified Path
      Parameters:
      config - the ConfigurationSection where the Material is in
      path - to the Material
      Returns:
      corresponding Material, null when the Material does not exist
    • getMaterial

      @Nullable public static @Nullable org.bukkit.Material getMaterial(@NotNull @NotNull String materialName)
      Converts a String to the corresponding Material
      Parameters:
      materialName - String to convert
      Returns:
      corresponding Material, null when the Material does not exist
    • getItemTypes

      @Nullable public static @Nullable Collection<org.bukkit.inventory.ItemType> getItemTypes(@NotNull @NotNull org.bukkit.configuration.ConfigurationSection config, @NotNull @NotNull String path)
      Converts a List<String> in an ConfigurationSection to an EnumSet<Material>
      Parameters:
      config - the ConfigurationSection where the List<String> is in
      path - the path to the List<String> in the ConfigurationSection
      Returns:
      the created EnumSet<Material>, null when the List<String> wasn't found
    • getItemType

      @Nullable public static @Nullable org.bukkit.inventory.ItemType getItemType(@NotNull @NotNull org.bukkit.configuration.ConfigurationSection config, @NotNull @NotNull String path)
      Gets an ItemType from an ConfigurationSection at the specified Path
      Parameters:
      config - the ConfigurationSection where the Material is in
      path - to the ItemType
      Returns:
      corresponding ItemType, null when the ItemType does not exist
    • getItemTypes

      @Nullable public static @Nullable Collection<org.bukkit.inventory.ItemType> getItemTypes(@NotNull @NotNull String itemName)
      Converts a String Tag or ItemType Key to the corresponding Collection<ItemType>
      Parameters:
      itemName - String to convert
      Returns:
      corresponding Collection<ItemType>, an empty Collection<ItemType> when the Tag does not exist
    • getItemType

      @Nullable public static @Nullable org.bukkit.inventory.ItemType getItemType(@NotNull @NotNull String itemName)
      Converts a String to the corresponding ItemType
      Parameters:
      itemName - String to convert
      Returns:
      corresponding ItemType, null when the ItemType does not exist
    • parseKey

      @Nullable public static @Nullable net.kyori.adventure.key.Key parseKey(@NotNull @NotNull String key)
      Parses a String into a Key
      Parameters:
      key - the key to parse in the format abc:xyz
      Returns:
      The parsed Key or null if it could not be parsed
    • getInteger

      @Nullable public static @Nullable Integer getInteger(@NotNull @NotNull org.bukkit.configuration.ConfigurationSection config, @NotNull @NotNull String path)
      Gets an Integer from an ConfigurationSection at the specified Path
      Parameters:
      config - the ConfigurationSection where the Integer is in
      path - to the Integer
      Returns:
      corresponding Integer, null when the Integer does not exist
    • getDouble

      @Nullable public static @Nullable Double getDouble(@NotNull @NotNull org.bukkit.configuration.ConfigurationSection config, @NotNull @NotNull String path)
      Gets an Double from an ConfigurationSection at the specified Path
      Parameters:
      config - the ConfigurationSection where the Double is in
      path - to the Double
      Returns:
      corresponding Double, null when the Double does not exist
    • getBoolean

      @Nullable public static @Nullable Boolean getBoolean(@NotNull @NotNull org.bukkit.configuration.ConfigurationSection config, @NotNull @NotNull String path)
      Gets an Boolean from an ConfigurationSection at the specified Path
      Parameters:
      config - the ConfigurationSection where the Boolean is in
      path - to the Boolean
      Returns:
      corresponding Boolean, null when the Boolean does not exist
    • getString

      @Nullable public static @Nullable String getString(@NotNull @NotNull org.bukkit.configuration.ConfigurationSection config, @NotNull @NotNull String path)
      Gets an String from an ConfigurationSection at the specified Path
      Parameters:
      config - the ConfigurationSection where the String is in
      path - to the String
      Returns:
      corresponding String, null when the String does not exist
    • getUUID

      @Nullable public static @Nullable UUID getUUID(@NotNull @NotNull org.bukkit.configuration.ConfigurationSection config, @NotNull @NotNull String path)
      Gets an UUID from an ConfigurationSection at the specified Path
      Parameters:
      config - the ConfigurationSection where the UUID is in
      path - to the UUID
      Returns:
      corresponding UUID, null when the UUID does not exist
    • getComponent

      @NotNull public static <T extends net.kyori.adventure.text.Component> @NotNull net.kyori.adventure.text.Component getComponent(@NotNull @NotNull org.bukkit.configuration.ConfigurationSection config, @NotNull @NotNull String path, @NotNull @NotNull net.kyori.adventure.text.serializer.ComponentSerializer<net.kyori.adventure.text.Component,T,String> serializer)
      Gets an Component from an ConfigurationSection at the specified Path

      deserialized with the specified serializer

      Type Parameters:
      T - the type that the deserializer uses
      Parameters:
      config - the ConfigurationSection where the Component is in
      path - to the Component
      serializer - the serializer to deserialize the message
      Returns:
      corresponding Component, Component.empty() when the Component does not exist
    • getComponent

      @NotNull public static @NotNull net.kyori.adventure.text.Component getComponent(@NotNull @NotNull org.bukkit.configuration.ConfigurationSection config, @NotNull @NotNull String path)
      Parses a component from the config at a specific path
      Parameters:
      config - The config to parse from
      path - The path where the component should be parse from
      Returns:
      The component that was parsed or Component.empty()
    • getComponent

      @NotNull public static @NotNull net.kyori.adventure.text.Component getComponent(@NotNull @NotNull org.bukkit.configuration.ConfigurationSection config, @NotNull @NotNull String path, @Nullable @Nullable net.kyori.adventure.text.minimessage.tag.resolver.TagResolver tagResolver)
      Parses a component from the config at a specific path
      Parameters:
      config - The config to parse from
      path - The path where the component should be parse from
      tagResolver - A tag resolver
      Returns:
      The component that was parsed or Component.empty()
    • getComponent

      @NotNull public static @NotNull net.kyori.adventure.text.Component getComponent(@NotNull @NotNull org.bukkit.configuration.ConfigurationSection config, @NotNull @NotNull String path, @Nullable @Nullable net.kyori.adventure.text.minimessage.tag.resolver.TagResolver tagResolver, @Nullable @Nullable net.kyori.adventure.pointer.Pointered target)
      Parses a component from the config at a specific path
      Parameters:
      config - The config to parse from
      path - The path where the component should be parse from
      tagResolver - A tag resolver
      target - A target to use for the tag resolvers
      Returns:
      The component that was parsed or Component.empty()
    • getComponent

      @NotNull public static @NotNull net.kyori.adventure.text.Component getComponent(@NotNull @NotNull org.bukkit.configuration.ConfigurationSection config, @NotNull @NotNull String path, @NotNull @NotNull net.kyori.adventure.text.minimessage.MiniMessage serializer, @Nullable @Nullable net.kyori.adventure.text.minimessage.tag.resolver.TagResolver tagResolver, @Nullable @Nullable net.kyori.adventure.pointer.Pointered target)
      Parses a component from the config at a specific path
      Parameters:
      config - The config to parse from
      path - The path where the component should be parse from
      serializer - The serializer to use
      tagResolver - A tag resolver
      target - A target to use for the tag resolvers
      Returns:
      The component that was parsed or Component.empty()
    • parseComponent

      @NotNull public static @NotNull net.kyori.adventure.text.Component parseComponent(@NotNull @NotNull org.bukkit.configuration.ConfigurationSection config, @NotNull @NotNull String text, @Nullable @Nullable net.kyori.adventure.text.minimessage.tag.resolver.TagResolver tagResolver, @Nullable @Nullable net.kyori.adventure.pointer.Pointered target)
      Parses a text into a Component and tries to parse any references (<ref:'<path>'>) that it finds
      Parameters:
      config - The config to take the paths from
      text - The text to parse
      tagResolver - An optional TagResolver to use
      target - An optional target to use
      Returns:
      the parsed Component
    • parseComponent

      @NotNull public static @NotNull net.kyori.adventure.text.Component parseComponent(@NotNull @NotNull org.bukkit.configuration.ConfigurationSection config, @NotNull @NotNull List<String> text, @Nullable @Nullable net.kyori.adventure.text.minimessage.tag.resolver.TagResolver tagResolver, @Nullable @Nullable net.kyori.adventure.pointer.Pointered target)
      Parses a list of texts into a Component seperated by new lines and tries to parse any references (<ref:'<path>'>) that it finds
      Parameters:
      config - The config to take the paths from
      text - The List of texts to parse
      tagResolver - An optional TagResolver to use
      target - An optional target to use
      Returns:
      the parsed Component
    • parseComponentList

      @NotNull public static @NotNull List<net.kyori.adventure.text.Component> parseComponentList(@NotNull @NotNull org.bukkit.configuration.ConfigurationSection config, @NotNull @NotNull List<String> text, @Nullable @Nullable net.kyori.adventure.text.minimessage.tag.resolver.TagResolver tagResolver, @Nullable @Nullable net.kyori.adventure.pointer.Pointered target)
      Parses a list of texts into a List of Components seperated by new lines and tries to parse any references (<ref:'<path>'>) that it finds
      Parameters:
      config - The config to take the paths from
      text - The List of texts to parse
      tagResolver - An optional TagResolver to use
      target - An optional target to use
      Returns:
      the List of parsed Component
    • parseLoreComponentList

      @NotNull public static @NotNull List<? extends net.kyori.adventure.text.Component> parseLoreComponentList(@NotNull @NotNull org.bukkit.configuration.ConfigurationSection config, @NotNull @NotNull List<String> text, @Nullable @Nullable net.kyori.adventure.text.minimessage.tag.resolver.TagResolver tagResolver, @Nullable @Nullable net.kyori.adventure.pointer.Pointered target)
      Parses a list of texts into a List of Components seperated by new lines and tries to parse any references (<ref:'<path>'>) that it finds
      Parameters:
      config - The config to take the paths from
      text - The List of texts to parse
      tagResolver - An optional TagResolver to use
      target - An optional target to use
      Returns:
      the List of parsed Component
    • getItemStack

      public static org.bukkit.inventory.ItemStack getItemStack(@NotNull @NotNull org.bukkit.configuration.ConfigurationSection config, @NotNull @NotNull String path)
      Gets an ItemStack from an ConfigurationSection at the specified Path
      Parameters:
      config - the ConfigurationSection where the ItemStack is in
      path - to the ItemStack
      Returns:
      the ItemStack for the corresponding ConfigurationSection
    • getItemStack

      @NotNull public static @NotNull org.bukkit.inventory.ItemStack getItemStack(@NotNull @NotNull org.bukkit.configuration.ConfigurationSection config)
      Gets an ItemStack from an ConfigurationSection
      Parameters:
      config - the ConfigurationSection where the ItemStack is in
      Returns:
      the ItemStack for the corresponding ConfigurationSection