TCmc
rt
如果config是这样的


我该如何获取Msg下所有的list呢? 只获取"list"或者"list2"这个数字 并且不要返回null

SumCraft
  1. public java.util.Set<java.lang.String> getKeys(boolean deep)
  2. 从接口复制的说明: ConfigurationSection
  3. 获取此配置文件的键集合.
  4. 如果为 true, 则返回包括所有的能访问到的键的集合. 类似于获取硬盘中第一层目录还是遍历全部子目录.

  5. 例如:

  6. top1. Second1

  7. top1. Second2

  8. top2. Second1

  9. top2. Second2

  10. 原文: Gets a set containing all keys in this section.

  11. If deep is set to true, then this will contain all the keys within any child ConfigurationSections (and their children, etc). These will be in a valid path notation for you to use.

  12. If deep is set to false, then this will contain only the keys of any direct children, and not their own children.

  13. 指定者:
  14. getKeys 在接口中 ConfigurationSection
  15. 参数:
  16. deep - 获取全部键, 或者仅仅获取表层键.
  17. 返回:
  18. 将返回一个 set, 装载着符合要求的键.
复制代码

TCmc

这个我用着一直返回null呀
不知道是不是我用错了
可以给个例子吗

结冰的离季
config.getConfigurationSection("Msg").getKeys(false)
返回包含 list 和 list2 的字符串集合

TCmc
结冰的离季 发表于 2022-8-20 13:20
config.getConfigurationSection("Msg").getKeys(false)
返回包含 list 和 list2 的字符串集合

我就这样写的,然后获取之后a,b那些值的时候直接null

结冰的离季
TCmc 发表于 2022-8-20 20:42
我就这样写的,然后获取之后a,b那些值的时候直接null

你得确保你的配置正确加载

TS_cimao
TCmc 发表于 2022-8-20 20:42
我就这样写的,然后获取之后a,b那些值的时候直接null

贴一下你的写法

TCmc

我是这样写的 新手写法勿喷

TCmc
TCmc 发表于 2022-8-21 19:44
我是这样写的 新手写法勿喷

arg[1]是正确的

TS_cimao
("Msg."+arg[1]+"a");
这里修改成
("Msg."+arg[1]+".a");

TS_cimao
Msg.list.a嘛

TS_cimao
其他代码没啥问题

TCmc
TS_cimao 发表于 2022-8-22 11:47
其他代码没啥问题

但就是null 我人麻了

TS_cimao
TCmc 发表于 2022-8-22 11:48
但就是null 我人麻了

加我q我远程你看看