Package at.hugob.plugin.library.config
Class ConfigUtils
java.lang.Object
at.hugob.plugin.library.config.ConfigUtils
Configuration Utils
-
Method Summary
Modifier and TypeMethodDescriptionstatic @Nullable BooleangetBoolean(@NotNull org.bukkit.configuration.ConfigurationSection config, @NotNull String path) Gets anBooleanfrom anConfigurationSectionat the specified Pathstatic @NotNull net.kyori.adventure.text.ComponentgetComponent(@NotNull org.bukkit.configuration.ConfigurationSection config, @NotNull String path) Parses a component from the config at a specific pathstatic @NotNull net.kyori.adventure.text.ComponentgetComponent(@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 pathstatic @NotNull net.kyori.adventure.text.ComponentgetComponent(@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 pathstatic @NotNull net.kyori.adventure.text.ComponentgetComponent(@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 pathstatic <T extends net.kyori.adventure.text.Component>
@NotNull net.kyori.adventure.text.ComponentgetComponent(@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 anComponentfrom anConfigurationSectionat the specified Pathstatic @Nullable DoubleGets anDoublefrom anConfigurationSectionat the specified Pathstatic @Nullable IntegergetInteger(@NotNull org.bukkit.configuration.ConfigurationSection config, @NotNull String path) Gets anIntegerfrom anConfigurationSectionat the specified Pathstatic @NotNull org.bukkit.inventory.ItemStackgetItemStack(@NotNull org.bukkit.configuration.ConfigurationSection config) Gets anItemStackfrom anConfigurationSectionstatic org.bukkit.inventory.ItemStackgetItemStack(@NotNull org.bukkit.configuration.ConfigurationSection config, @NotNull String path) Gets anItemStackfrom anConfigurationSectionat the specified Pathstatic @Nullable org.bukkit.inventory.ItemTypegetItemType(@NotNull String itemName) Converts aStringto the correspondingItemTypestatic @Nullable org.bukkit.inventory.ItemTypegetItemType(@NotNull org.bukkit.configuration.ConfigurationSection config, @NotNull String path) Gets anItemTypefrom anConfigurationSectionat the specified Pathstatic @Nullable Collection<org.bukkit.inventory.ItemType> getItemTypes(@NotNull String itemName) Converts aStringTag or ItemType Key to the correspondingCollection<ItemType>static @Nullable Collection<org.bukkit.inventory.ItemType> getItemTypes(@NotNull org.bukkit.configuration.ConfigurationSection config, @NotNull String path) Converts aList<String>in anConfigurationSectionto anEnumSet<Material>static @Nullable org.bukkit.MaterialgetMaterial(@NotNull String materialName) Converts aStringto the correspondingMaterialstatic @Nullable org.bukkit.MaterialgetMaterial(@NotNull org.bukkit.configuration.ConfigurationSection config, @NotNull String path) Gets anMaterialfrom anConfigurationSectionat the specified Pathstatic @Nullable EnumSet<org.bukkit.Material> getMaterialSet(@NotNull org.bukkit.configuration.ConfigurationSection config, @NotNull String path) Converts aList<String>in anConfigurationSectionto anEnumSet<Material>static @Nullable StringGets anStringfrom anConfigurationSectionat the specified Pathstatic @Nullable UUIDGets anUUIDfrom anConfigurationSectionat the specified Pathstatic org.bukkit.configuration.ConfigurationSectionobjectToConfigurationSection(Object object) Tries to convert an Object to anConfigurationSectionstatic @NotNull net.kyori.adventure.text.ComponentparseComponent(@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 findsstatic @NotNull net.kyori.adventure.text.ComponentparseComponent(@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 findsstatic @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 findsstatic @Nullable net.kyori.adventure.key.KeyParses aStringinto a Keystatic @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
-
Method Details
-
objectToConfigurationSection
public static org.bukkit.configuration.ConfigurationSection objectToConfigurationSection(Object object) Tries to convert an Object to anConfigurationSection- Parameters:
object- The object that should be turned into aConfigurationSection- Returns:
- A
ConfigurationSectionif 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 aList<String>in anConfigurationSectionto anEnumSet<Material>- Parameters:
config- theConfigurationSectionwhere theList<String>is inpath- the path to theList<String>in theConfigurationSection- Returns:
- the created
EnumSet<Material>,nullwhen theList<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 anMaterialfrom anConfigurationSectionat the specified Path- Parameters:
config- theConfigurationSectionwhere theMaterialis inpath- to theMaterial- Returns:
- corresponding
Material,nullwhen theMaterialdoes not exist
-
getMaterial
@Nullable public static @Nullable org.bukkit.Material getMaterial(@NotNull @NotNull String materialName) Converts aStringto the correspondingMaterial- Parameters:
materialName-Stringto convert- Returns:
- corresponding
Material,nullwhen theMaterialdoes 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 aList<String>in anConfigurationSectionto anEnumSet<Material>- Parameters:
config- theConfigurationSectionwhere theList<String>is inpath- the path to theList<String>in theConfigurationSection- Returns:
- the created
EnumSet<Material>,nullwhen theList<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 anItemTypefrom anConfigurationSectionat the specified Path- Parameters:
config- theConfigurationSectionwhere theMaterialis inpath- to theItemType- Returns:
- corresponding
ItemType,nullwhen theItemTypedoes not exist
-
getItemTypes
@Nullable public static @Nullable Collection<org.bukkit.inventory.ItemType> getItemTypes(@NotNull @NotNull String itemName) Converts aStringTag or ItemType Key to the correspondingCollection<ItemType>- Parameters:
itemName-Stringto convert- Returns:
- corresponding
Collection<ItemType>, an emptyCollection<ItemType>when the Tag does not exist
-
getItemType
@Nullable public static @Nullable org.bukkit.inventory.ItemType getItemType(@NotNull @NotNull String itemName) Converts aStringto the correspondingItemType- Parameters:
itemName-Stringto convert- Returns:
- corresponding
ItemType,nullwhen theItemTypedoes not exist
-
parseKey
@Nullable public static @Nullable net.kyori.adventure.key.Key parseKey(@NotNull @NotNull String key) Parses aStringinto a Key- Parameters:
key- the key to parse in the format abc:xyz- Returns:
- The parsed
Keyor 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 anIntegerfrom anConfigurationSectionat the specified Path- Parameters:
config- theConfigurationSectionwhere theIntegeris inpath- to theInteger- Returns:
- corresponding
Integer,nullwhen theIntegerdoes not exist
-
getDouble
@Nullable public static @Nullable Double getDouble(@NotNull @NotNull org.bukkit.configuration.ConfigurationSection config, @NotNull @NotNull String path) Gets anDoublefrom anConfigurationSectionat the specified Path- Parameters:
config- theConfigurationSectionwhere theDoubleis inpath- to theDouble- Returns:
- corresponding
Double,nullwhen theDoubledoes not exist
-
getBoolean
@Nullable public static @Nullable Boolean getBoolean(@NotNull @NotNull org.bukkit.configuration.ConfigurationSection config, @NotNull @NotNull String path) Gets anBooleanfrom anConfigurationSectionat the specified Path- Parameters:
config- theConfigurationSectionwhere theBooleanis inpath- to theBoolean- Returns:
- corresponding
Boolean,nullwhen theBooleandoes not exist
-
getString
@Nullable public static @Nullable String getString(@NotNull @NotNull org.bukkit.configuration.ConfigurationSection config, @NotNull @NotNull String path) Gets anStringfrom anConfigurationSectionat the specified Path- Parameters:
config- theConfigurationSectionwhere theStringis inpath- to theString- Returns:
- corresponding
String,nullwhen theStringdoes not exist
-
getUUID
@Nullable public static @Nullable UUID getUUID(@NotNull @NotNull org.bukkit.configuration.ConfigurationSection config, @NotNull @NotNull String path) Gets anUUIDfrom anConfigurationSectionat the specified Path- Parameters:
config- theConfigurationSectionwhere theUUIDis inpath- to theUUID- Returns:
- corresponding
UUID,nullwhen theUUIDdoes 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 anComponentfrom anConfigurationSectionat the specified Pathdeserialized with the specified serializer
- Type Parameters:
T- the type that the deserializer uses- Parameters:
config- theConfigurationSectionwhere theComponentis inpath- to theComponentserializer- the serializer to deserialize the message- Returns:
- corresponding
Component,Component.empty()when theComponentdoes 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 frompath- 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 frompath- The path where the component should be parse fromtagResolver- 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 frompath- The path where the component should be parse fromtagResolver- A tag resolvertarget- 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 frompath- The path where the component should be parse fromserializer- The serializer to usetagResolver- A tag resolvertarget- 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 fromtext- The text to parsetagResolver- An optional TagResolver to usetarget- 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 fromtext- The List of texts to parsetagResolver- An optional TagResolver to usetarget- 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 fromtext- The List of texts to parsetagResolver- An optional TagResolver to usetarget- 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 fromtext- The List of texts to parsetagResolver- An optional TagResolver to usetarget- 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 anItemStackfrom anConfigurationSectionat the specified Path- Parameters:
config- theConfigurationSectionwhere theItemStackis inpath- to theItemStack- Returns:
- the
ItemStackfor the correspondingConfigurationSection
-
getItemStack
@NotNull public static @NotNull org.bukkit.inventory.ItemStack getItemStack(@NotNull @NotNull org.bukkit.configuration.ConfigurationSection config) Gets anItemStackfrom anConfigurationSection- Parameters:
config- theConfigurationSectionwhere theItemStackis in- Returns:
- the
ItemStackfor the correspondingConfigurationSection
-