Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do you register a command with addon? #1074

Closed
Redemption2033 opened this issue Dec 19, 2019 · 4 comments
Closed

How do you register a command with addon? #1074

Redemption2033 opened this issue Dec 19, 2019 · 4 comments
Assignees
Labels
Status: Done This issue has been completed or answered. This pull request has been merged. Type: API relating to the BentoBox API Type: Documentation Type: Question Question or issue related to configuration, API or features.

Comments

@Redemption2033
Copy link

Redemption2033 commented Dec 19, 2019

Hello, I'm making an addon that will work with BSkyBlock and I'm having trouble registering the command. I've followed everything on the Wiki but it seems that it's unfinished and I've looked through the source of other addons such as Level and the way that it's done there is not working for me, the command doesn't exist when I try using /is (command).

Is there a different way to do it other than something similar to:

getPlugin().getAddonsManager().getGameModeAddons().forEach(gm -> {

        gm.getPlayerCommand().ifPresent(cmd -> {
            new BankCommand(this,cmd);
        });

    });

I've also tried doing it exactly how it's done in Level with marking the specific gamemodes, but it's not working. The features in my addon won't be gamemode specific so it doesn't matter to me that it's registered for all gamemode addons.

I appreciate any help. Sorry if this isn't the place to ask for help, not sure where else I could ask.

@Poslovitch Poslovitch added Type: Documentation Type: Question Question or issue related to configuration, API or features. labels Dec 19, 2019
@tastybento
Copy link
Member

tastybento commented Dec 20, 2019

This is the way to obtain the player command from the game modes, but what is the code from the constructor of the BandCommand? That is actually where the command is linked in. For example, look at the level command:

public IslandLevelCommand(Level levelPlugin, CompositeCommand parent) {
        super(parent, "level");
        this.levelPlugin = levelPlugin;
    }

The super is where the command is placed under the parent command, e.g., /island, /ai, /cb etc.

So, that is the critical part. Share that part if you still need help.

@tastybento tastybento self-assigned this Dec 20, 2019
@tastybento tastybento added Status: Done This issue has been completed or answered. This pull request has been merged. Type: API relating to the BentoBox API labels Dec 20, 2019
@Redemption2033
Copy link
Author

Redemption2033 commented Dec 20, 2019

This is the way to obtain the player command from the game modes, but what is the code from the constructor of the BandCommand? That is actually where the command is linked in. For example, look at the level command:

public IslandLevelCommand(Level levelPlugin, CompositeCommand parent) {
        super(parent, "level");
        this.levelPlugin = levelPlugin;
    }

The super is where the command is placed under the parent command, e.g., /island, /ai, /cb etc.

So, that is the critical part. Share that part if you still need help.

Yea that's what I have and the command still doesn't exist when I use /is bank:

public BankCommand(BankAddon addon, CompositeCommand parent) {
super(parent, "bank");
this.addon = addon;
}

But my addon is enabled and shows up when I use '/bentobox version' to list the addons.

@tastybento
Copy link
Member

That should be it. Can you share the code with me? Is it on GitHub?

@tastybento
Copy link
Member

@Redemption2033 Did you get it working?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Done This issue has been completed or answered. This pull request has been merged. Type: API relating to the BentoBox API Type: Documentation Type: Question Question or issue related to configuration, API or features.
Projects
None yet
Development

No branches or pull requests

3 participants