Why do my commands not work?

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
280
17
56
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