当 运行 自定义 Spigot 命令时,输出是 plugin.yml 用法属性

When running custom Spigot commands, the output is the plugin.yml usage atribute

我最近开始从事 Minecraft 插件开发,并决定试一试。我正在使用 Eclipse IDE。当我尝试 运行 自定义命令时,聊天中会出现一条消息,它只是 plugin.yml 用法属性。例如,如果 'kit' 用法属性是 usage: /kit,则服务器中的输出将是 /kit。我不知道为什么会这样,如有任何帮助,我们将不胜感激。

代码

CommandKit.java

package tech.but.plugin;

import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin;

public class CommandKit extends JavaPlugin implements CommandExecutor {

    
    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        
        if (sender instanceof Player) {
            Player player = (Player) sender;
        
            
            //Send a message to the chat/console
                sender.sendMessage("Applying kit");
            
            //Clear the players inventory
                 
                player.getInventory().clear();
            
            
            
            //Assign block variables, enchant the items, and add them to the players inventory
            
                //slot 1
                ItemStack sword = new ItemStack(Material.DIAMOND_SWORD, 1);
                
                sword.addEnchantment(Enchantment.DAMAGE_ALL,2);
                sword.addEnchantment(Enchantment.FIRE_ASPECT,2);
                
                //slot 2
                ItemStack waterBucket = new ItemStack(Material.WATER_BUCKET, 1);
                
                //slot 3
                ItemStack axe = new ItemStack(Material.DIAMOND_AXE, 1);
                
                axe.addEnchantment(Enchantment.DAMAGE_ALL,2);
     
                //slot 4
                ItemStack bow = new ItemStack(Material.BOW, 1);
                
                bow.addEnchantment(Enchantment.ARROW_DAMAGE,2);
                bow.addEnchantment(Enchantment.ARROW_FIRE,2);
                bow.addEnchantment(Enchantment.ARROW_KNOCKBACK,2);

                //slot 5
                ItemStack gapple = new ItemStack(Material.ENCHANTED_GOLDEN_APPLE, 64);
                
                //slot 6
                ItemStack pickaxe = new ItemStack(Material.DIAMOND_PICKAXE, 1);
                
                pickaxe.addEnchantment(Enchantment.DIG_SPEED, 2);
                pickaxe.addEnchantment(Enchantment.WATER_WORKER, 2);
                
                //slot 7
                ItemStack cobble = new ItemStack(Material.COBBLESTONE, 64);
                
                //INVENTORY
                ItemStack arrows = new ItemStack(Material.ARROW, 128);
                
                
                
                
                
            //Assign Armor and enchant it
                
                ItemStack[] armor = new ItemStack[4];
                armor[0] = new ItemStack(Material.DIAMOND_BOOTS, 1);
                armor[0].addEnchantment(Enchantment.PROTECTION_FALL, 1);
                
                armor[1] = new ItemStack(Material.DIAMOND_LEGGINGS, 1);
                armor[1].addEnchantment(Enchantment.PROTECTION_FIRE, 1);
                
                armor[2] = new ItemStack(Material.DIAMOND_CHESTPLATE, 1);
                armor[2].addEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 1);

                armor[3] = new ItemStack(Material.DIAMOND_HELMET, 1);
                armor[3].addEnchantment(Enchantment.PROTECTION_PROJECTILE, 1);
            
                
                
                
                
                
                
            //set players inventory and armor
                player.getInventory().setArmorContents(armor);  
                player.getInventory().addItem(sword,waterBucket,axe,bow,gapple,cobble,arrows);
        }

        return true;
    
            
    }
}

Main.java

package tech.but.plugin;


import org.bukkit.plugin.java.JavaPlugin;
public class Main extends JavaPlugin{
    @Override
    public void onEnable() {
        this.getCommand("kit").setExecutor(new CommandKit());
        
    }
    @Override
    public void onDisable() {
    }
    
    
    
    
    
    
}

Plugin.yml

name: MCBut
main: tech.but.plugin.Main
version: Alpha 1.3
author: piffle
description: A plugin that is piffle
api-version: 1.13
commands:
      kit:
        description: Kit command. Fills your inventory with PVP items and applies armor.
        usage: /kit
      
      
      

我认为这是因为您使用的是 return true; 而不是 return false; 尝试将其切换为 return false;

感谢 RGNT,修复了错误!