我对编码很陌生。我已经尝试了一切。我可以考虑尝试获取存储在我的配置中的标题列表,以作为消息发送给播放器,而我尝试过的任何方法都不起作用。
引用的当前配置设置
players:
player1name:
- title1
- title2
- title3
player2name:
- title1
- title3
调用发送消息代码行
if (args.length == 2) {
try {
// insert code here to display titles list available
// to
// player
Player p = Bukkit.getPlayer(args[1]);
if (p == null) {
sender.sendMessage("Could Not Find Player!!");
return true;
}
Bukkit.broadcastMessage("I got to this point pre- list");
List<String> s = this.Ach.getConfig()
.getStringList("players." + p + "titles");
StringBuilder message = new StringBuilder();
Bukkit.broadcastMessage("I got to this point post message");
for (String players : s) {
message.append(players).append(" - ");
Bukkit.broadcastMessage("I got to this point post for");
sender.sendMessage(message.toString()); // (message.toString());
}
// Set<String> keys =
// this.Ach.getConfig().getConfigurationSection("player."
// + p + "titles").getKeys(false);
// sender.sendMessage(keys + " - ");
Bukkit.broadcastMessage("I got to this point pre return");
return true;}
catch (Exception e) {
e.printStackTrace();
}
'Ach' 是前面定义的,以引用我在其中定义 get config 的主类。
我期望输出player1name
的args[1]
值
title1 - title2 - title3 -
使用有效的玩家名称而不是返回玩家拥有的头衔,我被发送到聊天的只是
[] -
任何帮助将不胜感激。