Skip to content
This repository has been archived by the owner on Nov 16, 2022. It is now read-only.

Command Executor and TabCompleter #2

Closed
jyhsu2000 opened this issue Aug 29, 2017 · 6 comments
Closed

Command Executor and TabCompleter #2

jyhsu2000 opened this issue Aug 29, 2017 · 6 comments

Comments

@jyhsu2000
Copy link

Hi, this is an awesome project.
I want to use it in my spigot plugin.
I tried to following the description in README, but still having some trouble.

As following example in README,
I can register commands to CommandsManager now,
but I don't know how to register them to spigot plugin.
Usually in normal plugin, I write the code like the following,

this.getCommand("command").setExecutor(commandHandler);
this.getCommand("command").setTabCompleter(commandHandler);

But I don't know how to do it with intake-spigot.
Is there any example plugin using intake-spigot?
Or can you explain how to do?

@literalplus
Copy link
Owner

Hey, glad you like it!

Take a look at the CommandRegistrationManager class, which tricks Bukkit into thinking your custom command belongs to it! Intake-Spigot should take care of this for you, provided you call the CommandsManager#registerCommand(Object, String, String...) method, like in the readme. (src)

Sadly, I can't provide a full example because the only project I've been able to use this with so far is closed-source. (Might be able to release it soon though)

Please let me know if this doesn't work or you have any further issues.

@literalplus
Copy link
Owner

I've added a note in the readme to clarify.

@jyhsu2000
Copy link
Author

jyhsu2000 commented Aug 30, 2017

After reading the code in your reply,
I think I know what's wrong I did.
I found the commands are automatically registered with prefix mtc, but not prefix of my plugin.
And I forget to remove command defination in plugin.yml, so conflict happens.
It works fine after I remove the command section in plugin.yml.

Thanks for help.
But one more question, can you make it work with prefix of plugin which using this project?
Because only if use prefix of plugin, commands can be re-register successfully when disable and re-enable the plugin.

Now:
/command: works fine
/plugin:command: unknown command <- I hope this can work
/mtc:command: nothing happens, even no hint message.

@literalplus
Copy link
Owner

Actually, after reading your issue, I noticed the hardcoded prefix and added an option to change it! :)

Just get the latest version (version number now in the readme), and you should be fine. By default, your plugin's prefix from plugin.yml is used, and if you haven't defined that, it falls back to your plugin's name. However, you can also change the fallback prefix using CommandsManager#setFallbackPrefix().

@literalplus
Copy link
Owner

I've also noted your specific issue in the readme, I figured that'd be a common issue.

@jyhsu2000
Copy link
Author

jyhsu2000 commented Aug 30, 2017

Thanks for fixing efficiently.
Prefix change to plugin's prefix now,
But still somethings wrong,

  1. /plugin:command always return Please choose a sub-command
  2. Commands cannot be unregister when unload,
    I use /plugman unload plugin command of PlugMan (code of unload)
    I'm not sure is there any difference of handling commandMap, so I cannot figure out this issue is related intake-spigot or not.
    But it only happens when register command using intake-spigot, it doesn't happen if commands defined in plugin.yml and use this.getCommand("command").setExecutor(commandHandler); to register.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants