Skip to content

Feature: CommandSender in DynamicSuggestedStringArgument #41

@Draycia

Description

@Draycia

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);

    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions