弥猫うた
本帖最后由 Mucrazy 于 2019-9-12 19:32 编辑

我想要读取配置文件内容,0可以正常读取,1无法读取,求解
  1. FileConfiguration config = Main.getInstance().getConfig();
  2. Set<String> key = config.getConfigurationSection("物品").getKeys(false);
  3. String s = config.getString(key+".xx");
复制代码
  1. 物品:
  2.   0:
  3.     xx: 'xx'   
  4.     xx: true
  5.     xx: 'xx'
  6.   1:
  7.     xx: 'xx'   
  8.     xx: true
  9.     xx: 'xx'
复制代码



白灯
可以试试看这个
  1. String s = config.getString("物品." + key + ".xx");
复制代码

Karlatemp
ConfigurationSection root = Main.getInstance().getConfig();
ConfigurationSection sub = root.getConfigurationSection("物品");
Set<String>keys = sub.getKeys(false);
for (String key : keys){
  // String value1 = sub.getString(key+".xx");
  ConfigurationSection loop = sub.getConfigurationSection(key);
  System.out.println(loop.getString("xx"));
}

第一页 上一页 下一页 最后一页