Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/364.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 我的插件一直以消息的形式返回我的命令_Java_Bukkit - Fatal编程技术网

Java 我的插件一直以消息的形式返回我的命令

Java 我的插件一直以消息的形式返回我的命令,java,bukkit,Java,Bukkit,每次我在游戏中运行命令时,它都会将命令作为消息返回。例如)我在游戏中键入“/heal”,它会向我返回消息“/heal” 我的代码 public boolean onCommand(CommandSender sender, Command cmd, String label, Strings [] args) { Player player = (Player) sender; if (cmd.getName().equalsIgnoreCase("heal")) {

每次我在游戏中运行命令时,它都会将命令作为消息返回。例如)我在游戏中键入“/heal”,它会向我返回消息“/heal”

我的代码

public boolean onCommand(CommandSender sender, Command cmd, String label, Strings [] args) {

    Player player = (Player) sender;

    if (cmd.getName().equalsIgnoreCase("heal")) {
        if (sender.hasPermission("city.heal")) {
            player.setHealth(20);
            player.setFoodLevel(20);
            sender.sendMessage("§fYou have been §bhealed §fand §bsated§f.");
            return true;
        }

        if (!sender.hasPermission("city.heal")) {
            sender.sendMessage("§cNo permission.");
            return true;
        }
    }
    return true;
}
}

我的plugin.yml

main: me.rarfiles.code.Code
name: Test
author: rarfiles
version: 1.0

commands:
  heal:
    usage: /<command>
main:me.rarfiles.code.code
名称:测试
作者:rarfiles
版本:1.0
命令:
治愈:
用法:/

您确定其他地方没有使用该方法的另一段代码吗?因为在所显示的代码中,没有任何东西会用输入的命令开始向您发送消息。您是否也确定该命令没有注册,并且您看到了自己的消息?我认为没有任何干扰。这是我为heal命令制作的测试插件。下面是关于插件的所有内容:当它“回复您的消息”时,它是什么样子的?我认为这与
用法:
部分有关。由于游戏认为您没有正确使用该命令,导致触发的原因是什么。然而,我无法理解,为什么会是这种情况。你确定你没有其他地方使用这种方法的代码吗?因为在所显示的代码中,没有任何东西会用输入的命令开始向您发送消息。您是否也确定该命令没有注册,并且您看到了自己的消息?我认为没有任何干扰。这是我为heal命令制作的测试插件。下面是关于插件的所有内容:当它“回复您的消息”时,它是什么样子的?我认为这与
用法:
部分有关。由于游戏认为您没有正确使用该命令,导致触发的原因是什么。但我不明白为什么会这样。