Question register CommandExecutor class to my main class in paper-plugin.yml

  • 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.

MkdirGit

New member
Jul 2, 2023
10
2
1
3
Israel
Hello visitor,
today i tried to register class that implements CommandExecutor ( aka command class )
to my main class,
but because i'm developing in 1.20 paper plugin with paper-plugin.yml .
Iv'e been stuck for a
LOT of time.
Please help.

Command Class:
Java:
package my.not.working.command;


import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;


public class MyNotWorkingCommand implements CommandExecutor {



    public boolean onCommand( CommandSender commandSender, @NotNull String s, @NotNull String[] args) {
        return true;
    }
}

Main Class
Java:
package my.not;



import org.bukkit.plugin.java.JavaPlugin;



public class MyNot extends JavaPlugin {


    @Override
    public void onEnable() {
        // Plugin startup logic
       
        //  how to register the command here?
    }

    @Override
    public void onDisable() {
        // Plugin shutdown logic

        //  how to unregister the command ( if you should )
    }


}

i will appreciate your help.
thanks for reading to here :)
 

electronicboy

Administrator
Staff member
Dec 11, 2021
321
18
68
28
general advice is to use a command framework, otherwise, get the command map and use the register methods on that