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

Feature: CommandSender in DynamicSuggestedStringArgument #41

Closed
Draycia opened this issue Jan 8, 2019 · 3 comments
Closed

Feature: CommandSender in DynamicSuggestedStringArgument #41

Draycia opened this issue Jan 8, 2019 · 3 comments
Labels
enhancement New feature or request

Comments

@Draycia
Copy link

Draycia commented Jan 8, 2019

Please describe your suggestion
Would be nice to dynamically suggest strings per user. For instance, each user has a set of homes, and I would like to display their homes as they're typing the argument.

Please supply examples of the desired inputs and outputs
Example:
Input: /home homename
Output: /home <home, farm, friend, newbase>

Example:

class CommandHome {
    private fun run(sender: CommandSender, args: Array<Any>) {
        if (sender !is Player) return;

        // Check if home exists and teleport player there.
    }

    private fun dynamicStringArgument(sender: CommandSender): Array<String> {
        if (sender !is Player) return arrayOf();
        return PluginMain.homes[sender.uniqueId] ?: arrayOf();
    }

    fun registerCommand() {
        val normal = LinkedHashMap<String, Argument>();
        normal["Home"] = DynamicSuggestedStringArgument(::dynamicStringArgument);
        CommandAPI.getInstance().register("home", CommandPermission.fromString("commands.home"), normal, ::run);

    }
}
@JorelAli
Copy link
Owner

JorelAli commented Jan 8, 2019

Sounds doable. I'll take a look at it!

@Draycia
Copy link
Author

Draycia commented Jan 8, 2019

Thank you!

JorelAli added a commit that referenced this issue Jan 8, 2019
@JorelAli
Copy link
Owner

JorelAli commented Jan 8, 2019

Implemented in this commit

This will be included in the 1.9 release which is due soon!

@JorelAli JorelAli closed this as completed Jan 8, 2019
@JorelAli JorelAli added the enhancement New feature or request label Jan 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants