Register command without plugin.yml 1.13.2?

Discussion in 'Spigot Plugin Development' started by mkcoldwolf, Jan 5, 2019.

  1. upload_2019-1-5_16-42-2.png
    This is how i hook command when the game is running without register the command at plugin.yml
    it works work any version even 1.13.2 but there is a problem
    1.13.2 adds a new system which detect the command before using "Tab" key and thats sh*t
    so it becomes like this
    sinces it does't actually registered in /help
    it warns me its a error command and dont even let me "Tab" it for playername or "TabEvent" wont event fire i think?
    but the command will still work after i send it
    How should i fix it?
    • Informative Informative x 1
  2. That's Essentials's help, which overrides the default help. Essentials iterates over plugins and then checks the commands in said plugin's plugin.yml. You can fix it by overriding essentials's help command (isn't too hard, I've done it too)

    As for the tab completion I don't know..
  3. Sorry my bad, this should be the real help on bukkit
    Thats why i hated ess very much, it overrides almost everytings
    • Agree Agree x 1
  4. I'm quite sure that little if-statement avalanche can be done away with if you make some changes.

    First off, you should notice flashes of warning in your face because you're repeating similar sections or statements of code when registering command modules if and only if the module is enabled.

    It tells me that your code isn't designed with modularity or simplicity in mind, but for functional purposes. I respect that, but here's a design plan for you to consider.

    First off, let's think about what we should do to "modularise" your components. We can start off with an AbstractModule class that contains methods to determine if the module should be enabled. Subclasses should implement CommandExecutor.

    Code (Text):
    class AbstractModule {
      Plugin plugin;
      AbstractModule(Plugin plugin) {
        this.plugin = plugin;
      boolean shouldEnable() {
        return true; // by default. subclasses can override

    Our modules are now able to determine if they want to be enabled, with their own conditions. Yay!

    Then, we want to keep track of them some way. This is somewhat a hack, since ClassLoaders don't provide information on subclasses. Instead, we will have to let ourselves know which classes extend AbstractModule.

    Perhaps, we can keep track of a static list located in our plugin class.

    Code (Text):
    static final Set<? extends AbstractModule> MODULES = Sets.newHashSet(ModuleClass, OtherModuleClass, ...);
    Now, we want to register the commands. This is made easy by Java 8 streams. In fact, they can be one-liners now!

    Code (Text):
    class CommandRegistryClass {
      void someRegisteringMethod(...) {
        plugin.getModules().filter(module -> module.canEnable()).forEach(module -> commandMap.register(plugin, newinstanceofmodule));
    • Informative Informative x 1
  5. Really Thanks you for ur reply, its the API i made like 2 years ago, and i dont have enough time to update it yet, or ill not asking how to update it to 1.13.2 , btw still thanks for ur reply!
  6. Really no answer for this one? 0.0

Share This Page