Class Config

java.lang.Object
org.bukkit.configuration.MemorySection
org.bukkit.configuration.MemoryConfiguration
org.bukkit.configuration.file.FileConfiguration
org.bukkit.configuration.file.YamlConfiguration
com.mclds.plugins.customplugin.utils.Config
All Implemented Interfaces:
org.bukkit.configuration.Configuration, org.bukkit.configuration.ConfigurationSection

public class Config extends org.bukkit.configuration.file.YamlConfiguration
  • Field Summary

    Fields inherited from class org.bukkit.configuration.file.YamlConfiguration

    BLANK_CONFIG, COMMENT_PREFIX

    Fields inherited from class org.bukkit.configuration.MemoryConfiguration

    defaults, options

    Fields inherited from class org.bukkit.configuration.MemorySection

    map
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    @NotNull Map<String,Object>
    获取整个配置文件,如果为空则返回空map
    getMap(String path)
    获取一个配置文件的某个路径的值,如果不存在,返回空map
    static <T, R> R
    handle(Object value, Class<T> valueType, Function<T,R> handler, R defaultValue)
     
    static <T> void
    isList(Object listLike, Class<T> type, Consumer<List<T>> ifIsList)
     
    static void
    isMap(@Nullable Object mapLike, Consumer<Map<String,Object>> ifIsMap)
    判断一个对象是否是map,如果是,执行ifIsMap
    static <T> List<T>
    list(Object listLike, Class<T> type)
    获取一个list,如果 listLike 是 null 或者类型不匹配 ,返回一个空list
    static <T> List<T>
    list(Object listLike, Class<T> type, List<T> defaultValue)
    获取一个list,如果 listLike 是null,返回默认值
    static <V> List<Map<String,V>>
    listMap(Object listLike, Class<V> mapValueType)
     
    static <V> List<Map<String,V>>
    listMap(Object listLike, Class<V> mapValueType, List<Map<String,V>> defaultValue)
     
    static Map<String,Object>
    map(@Nullable Object mapLike)
    获取一个map,如果 mapLike 是null,返回一个空map
    static <T> Map<String,T>
    map(@Nullable Object mapLike, Class<T> valueType)
     
    static <T> Map<String,T>
    map(@Nullable Object mapLike, Class<T> valueType, Map<String,T> defaultValue)
    获取一个map,如果 mapLike 是 null,返回默认值 如果 map 值不是 valueType 类型,返回默认值
    static Map<String,Object>
    map(@Nullable Object mapLike, Map<String,Object> defaultValue)
    获取一个map,如果 mapLike 是null,返回默认值
    static Boolean
    valueBoolean(Object baseValueLike, Boolean defaultValue)
     
    static Double
    valueDouble(Object baseValueLike, Double defaultValue)
     
    static Float
    valueFloat(Object baseValueLike, Float defaultValue)
     
    static Integer
    valueInteger(Object baseValueLike, Integer defaultValue)
     
    static Long
    valueLong(Object baseValueLike, Long defaultValue)
     
    static String
    valueString(Object baseValueLike, String defaultValue)
     

    Methods inherited from class org.bukkit.configuration.file.YamlConfiguration

    loadConfiguration, loadConfiguration, loadFromString, options, saveToString

    Methods inherited from class org.bukkit.configuration.file.FileConfiguration

    buildHeader, load, load, load, save, save

    Methods inherited from class org.bukkit.configuration.MemoryConfiguration

    addDefault, addDefaults, addDefaults, getDefaults, getParent, setDefaults

    Methods inherited from class org.bukkit.configuration.MemorySection

    contains, contains, createPath, createPath, createSection, createSection, get, get, getBoolean, getBoolean, getBooleanList, getByteList, getCharacterList, getColor, getColor, getComments, getConfigurationSection, getCurrentPath, getDefault, getDefaultSection, getDouble, getDouble, getDoubleList, getFloatList, getInlineComments, getInt, getInt, getIntegerList, getItemStack, getItemStack, getKeys, getList, getList, getLocation, getLocation, getLong, getLong, getLongList, getMapList, getName, getObject, getObject, getOfflinePlayer, getOfflinePlayer, getRoot, getSerializable, getSerializable, getShortList, getString, getString, getStringList, getValues, getVector, getVector, isBoolean, isColor, isConfigurationSection, isDouble, isInt, isItemStack, isList, isLocation, isLong, isOfflinePlayer, isPrimitiveWrapper, isSet, isString, isVector, mapChildrenKeys, mapChildrenValues, set, setComments, setInlineComments, toString

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.bukkit.configuration.ConfigurationSection

    contains, contains, createSection, createSection, get, get, getBoolean, getBoolean, getBooleanList, getByteList, getCharacterList, getColor, getColor, getComments, getComponent, getComponent, getConfigurationSection, getCurrentPath, getDefaultSection, getDouble, getDouble, getDoubleList, getFloatList, getInlineComments, getInt, getInt, getIntegerList, getItemStack, getItemStack, getKeys, getList, getList, getLocation, getLocation, getLong, getLong, getLongList, getMapList, getName, getObject, getObject, getOfflinePlayer, getOfflinePlayer, getRichMessage, getRichMessage, getRoot, getSerializable, getSerializable, getShortList, getString, getString, getStringList, getValues, getVector, getVector, isBoolean, isColor, isConfigurationSection, isDouble, isInt, isItemStack, isList, isLocation, isLong, isOfflinePlayer, isSet, isString, isVector, set, setComments, setComponent, setInlineComments, setRichMessage
  • Constructor Details

    • Config

      public Config()
  • Method Details

    • getMap

      @NotNull public @NotNull Map<String,Object> getMap()
      获取整个配置文件,如果为空则返回空map
    • getMap

      public Map<String,Object> getMap(String path)
      获取一个配置文件的某个路径的值,如果不存在,返回空map
    • isMap

      public static void isMap(@Nullable @Nullable Object mapLike, Consumer<Map<String,Object>> ifIsMap)
      判断一个对象是否是map,如果是,执行ifIsMap
    • map

      public static Map<String,Object> map(@Nullable @Nullable Object mapLike)
      获取一个map,如果 mapLike 是null,返回一个空map
    • map

      public static Map<String,Object> map(@Nullable @Nullable Object mapLike, Map<String,Object> defaultValue)
      获取一个map,如果 mapLike 是null,返回默认值
    • map

      public static <T> Map<String,T> map(@Nullable @Nullable Object mapLike, Class<T> valueType)
    • map

      public static <T> Map<String,T> map(@Nullable @Nullable Object mapLike, Class<T> valueType, Map<String,T> defaultValue)
      获取一个map,如果 mapLike 是 null,返回默认值 如果 map 值不是 valueType 类型,返回默认值
    • isList

      public static <T> void isList(Object listLike, Class<T> type, Consumer<List<T>> ifIsList)
    • listMap

      public static <V> List<Map<String,V>> listMap(Object listLike, Class<V> mapValueType)
    • listMap

      public static <V> List<Map<String,V>> listMap(Object listLike, Class<V> mapValueType, List<Map<String,V>> defaultValue)
    • list

      public static <T> List<T> list(Object listLike, Class<T> type)
      获取一个list,如果 listLike 是 null 或者类型不匹配 ,返回一个空list
      Parameters:
      listLike - 列表
      type - 列表元素的类型
    • list

      public static <T> List<T> list(Object listLike, Class<T> type, List<T> defaultValue)
      获取一个list,如果 listLike 是null,返回默认值
      Parameters:
      listLike - 列表
      type - 列表元素的类型
      defaultValue - 默认值
    • valueInteger

      public static Integer valueInteger(Object baseValueLike, Integer defaultValue)
    • valueDouble

      public static Double valueDouble(Object baseValueLike, Double defaultValue)
    • valueFloat

      public static Float valueFloat(Object baseValueLike, Float defaultValue)
    • valueLong

      public static Long valueLong(Object baseValueLike, Long defaultValue)
    • valueBoolean

      public static Boolean valueBoolean(Object baseValueLike, Boolean defaultValue)
    • valueString

      public static String valueString(Object baseValueLike, String defaultValue)
    • handle

      public static <T, R> R handle(Object value, Class<T> valueType, Function<T,R> handler, R defaultValue)