[英]getInt Function Doesn't Return Anything
我目前正在尝试制作一个自定义规则插件(用于我的世界),我正在尝试查看玩家是否激活了我存储在配置文件中的内容。 它在侦听器类中(从主调用配置)。 这是我的代码:
@EventHandler
public void onEvent(AsyncPlayerChatEvent e) {
Player player = e.getPlayer();
if (config.getInt("EditingLine." + player.getName().toLowerCase()) == 1) {
int line = 0;
try {
line = Integer.parseInt(e.getMessage());
} catch (Exception b) {
player.sendMessage(ChatColor.RED + "Invalid Number.");
config.set("EditingLine." + player.getName().toLowerCase(), 0);
}
if (!(line == 0)) {
config.set("EditingLine." + player.getName().toLowerCase(), 0);
config.set("EditingText." + player.getName().toLowerCase(), 1);
e.setCancelled(true);
player.sendMessage(ChatColor.GRAY + "[" + ChatColor.GOLD + "Custom Rules" + ChatColor.GRAY + "]" + ChatColor.GREEN + " Enter the text you would now like on that line.");
}
}
}
if then 语句中的 config.getInt() 函数当前不返回任何内容。 这可能是因为 Listener 类中的配置实际上正在调用自定义配置,称为“playerdata.yml”而不是实际的“config.yml”。 如果有任何更简单的方法来编写这个脚本,也请告诉我。 我正在努力使这尽可能简单。
通过将我的两个配置文件合并在一起,答案已得到解决。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.