Java 从yml配置文件中读取未知数据

Java 从yml配置文件中读取未知数据,java,yaml,config,bukkit,Java,Yaml,Config,Bukkit,我正在编写一个bukkit插件,它应该从用户创建的yml配置文件中读取数据,如下面的示例所示。 我以前搜索过,但没有结果,事实上我真的不知道我应该搜索什么 配置示例: maps: 01: name: world displayname: Plains icon: 2 size: 1000 info: - 'Some information' - 'Another information string' 02: name: w

我正在编写一个bukkit插件,它应该从用户创建的yml配置文件中读取数据,如下面的示例所示。 我以前搜索过,但没有结果,事实上我真的不知道我应该搜索什么

配置示例:

maps:
  01:
    name: world
    displayname: Plains
    icon: 2
    size: 1000
    info:
    - 'Some information'
    - 'Another information string'
  02:
    name: world_nether
    displayname: Nether
    icon: 87
    size: 500
    info:
    - 'Information'
    - 'More information'
    - 'As many lines as needed...'
地图的数量未知,用户可以创建任意数量的地图,因此不仅有
01
02
,内容(
name
icon
info
,…)始终相同

如何读取
映射的数量(
01
02
,…)以及用Java保存不同类型内容(字符串、整数、列表)的好方法是什么?

您可以获得子对象的

看,


您可以使用参数
/[yourcommand][Number][…]
。 如果您不需要命令,您可以保存一行,如:
Worlds:1
当您创建一个新的
arena
时,您可以从
Worlds
获取数字并覆盖它

FileConfiguration fc = getConfig(); // Get the config
ConfigurationSection cs = fc.getConfigurationSection("maps");
boolean deep = false; 
for (String key : cs.getKeys(deep)) {
    //Key will be 01
}