Java getInt函数没有';我什么也不退
我目前正在尝试制作一个自定义规则插件(用于minecraft),我正在尝试查看玩家是否激活了一些我存储在配置文件中的东西。它位于listener类中(从main调用配置)。这是我的密码:Java getInt函数没有';我什么也不退,java,config,minecraft,Java,Config,Minecraft,我目前正在尝试制作一个自定义规则插件(用于minecraft),我正在尝试查看玩家是否激活了一些我存储在配置文件中的东西。它位于listener类中(从main调用配置)。这是我的密码: @EventHandler public void onEvent(AsyncPlayerChatEvent e) { Player player = e.getPlayer(); if (config.getInt("EditingLine." + player.getName().to
@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()函数当前不返回任何内容。这可能是因为侦听器类中的配置实际上正在调用一个定制的配置,称为“playerdata.yml”,而不是实际的“config.yml”。如果有任何更简单的方法来写这个脚本,也让我知道。我正在尽可能地简化这个问题。通过将我的两个配置文件合并在一起,答案已经解决。配置是什么类型的?
getInt()
的签名是什么?@Paul Hicks配置创建一个文件配置,然后将其设置为在主类中创建的'playerdata.yml'配置。方法不能“不返回任何内容”,除非它是void
,在这种情况下,您的代码将无法编译。我尝试使用player.sendMessage(“+config.getInt('path'))调用OneEvent时,没有发送任何内容。这说明sendMessage
没有发送任何内容,而不是getInt
没有返回任何内容。请尝试记录返回值,而不是将其作为消息发送。