Why do my commands not work?

  • After careful consideration and due to limited usage, we’ve made the decision to discontinue the PaperMC forums. Moving forward, we recommend using Hangar for plugin uploads, and for all other community discussions and support, please join us on Discord.

Pepf

New member
Oct 25, 2024
1
0
1
this is in the paper-plugin.yml
commands:
food:
description: Gives a stack of food!
usage: /<command>
freehealth:
description: Gives free health!
usage: /<command>

This is the code in the main class:

Code:
if (command.getName().equalsIgnoreCase("food"))
        {
             if (sender instanceof Player) {
                Player p = (Player)sender;
                p.getInventory().addItem(new ItemStack(Material.COOKED_BEEF, 64));
                p.sendMessage(ChatColor.GREEN + "You got a stack of" + ChatColor.BOLD +  "FOOD!");
            }
        }
        if (command.getName().equalsIgnoreCase("freehealth"))
        {
            if (sender instanceof Player) {
                Player p = (Player)sender;
                p.setHealth(p.getHealth() + 1);
            }
        }
 

electronicboy

Administrator
Staff member
Dec 11, 2021
321
18
68
28
paper-plugin.yml does not let you define commands, if you're not using any paper plugin specific features, rename the file to plugin.yml, otherwise, you would need to register commands dynamically