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

Support a @ExecuteDefault in command clasases to show usage originally #357

Open
CarmJos opened this issue Jan 5, 2024 · 4 comments · May be fixed by #366
Open

Support a @ExecuteDefault in command clasases to show usage originally #357

CarmJos opened this issue Jan 5, 2024 · 4 comments · May be fixed by #366

Comments

@CarmJos
Copy link
Contributor

CarmJos commented Jan 5, 2024

Sometimes we want to display originally usages to players instead of auto-generated one,
so maybe we could support a annotation like @UsageExecute used in command classes,
which will be called in "No command found" situtation, to replace the generated messages (by SchematicFormat usually).

It looks like this:

package com.artformgames.plugin.tempflight.command;

import dev.rollczi.litecommands.annotations.argument.Arg;
import dev.rollczi.litecommands.annotations.command.Command;
import dev.rollczi.litecommands.annotations.context.Context;
import dev.rollczi.litecommands.annotations.description.Description;
import dev.rollczi.litecommands.annotations.execute.Execute;
import dev.rollczi.litecommands.annotations.permission.Permission;
import org.bukkit.command.CommandSender;

@Command(name = "sample")
public class SampleCommand {

    @UsageExecute
    void help(@Context CommandSender sender) {
        sender.sendMessage("The command require xxx to execute,");
        sender.sendMessage("Maybe you can use /sample set <value> ?");
    }

    @Execute(name = "sample")
    @Description("Sample command")
    @Permission("sample.permission")
    void sample(@Context CommandSender sender) {
        System.out.println("Sample command");
    }


    @Execute(name = "set")
    @Description("Sample command")
    @Permission("sample.permission")
    void set(@Context CommandSender sender, @Arg Integer someValue) {
        System.out.println("Sample command");
    }
}
@Rollczi
Copy link
Owner

Rollczi commented Jan 6, 2024

Related #220

@CarmJos CarmJos changed the title Support a @UsageExecute in command clasases to show usage originally Support a @ExecuteDefault in command clasases to show usage originally Jan 7, 2024
@CarmJos
Copy link
Contributor Author

CarmJos commented Feb 4, 2024

Is there any updates?

@Rollczi
Copy link
Owner

Rollczi commented Feb 4, 2024

I want to do it right. And now I have some local changes in a related branch.

@CarmJos
Copy link
Contributor Author

CarmJos commented Feb 4, 2024

Many thanks for your hard work! I'm looking forward to seeing updates!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Todo
Development

Successfully merging a pull request may close this issue.

2 participants