-
-
Notifications
You must be signed in to change notification settings - Fork 74
Feature: CommandSender in DynamicSuggestedStringArgument #41
Copy link
Copy link
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
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);
}
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request