Add a greedy "list argument"
See original GitHub issueFrom #275.
Please describe your suggestion
Allowing users to enter a list of values is very useful. WorldEdit has a nice implementation of a list argument, where users can provide a list of materials to manipulate blocks:
Implementing this “properly” is outside of the basic scope of the CommandAPI for now (see regex argument mod), however we can “simulate” a list argument by using an underlying GreedyStringArgument
with a powerful suggestion provider.
Work for this has already begun on the dev/listargument branch.
Formally, we need to support:
- Providing a list of values for the list
- Ensuring that the inputs to the argument don’t accept values outside of the provided list (e.g. a list
[apple, banana, cat]
can’t (or won’t) acceptdirt
as a value) - Allowing users to provide tooltips to entries
- Allowing users to specify a delimiter (e.g. a comma vs a space)
- The casting type should be a
Collection
parameterized over some typeT
which is provided by the users
Please supply examples of the desired inputs and outputs Example: Input: Using the following code:
List<String> list = List.of("apple", "banana", "cat", "dog", "elephant");
new CommandAPICommand("blah")
.withArguments(new ListArgumentBuilder<String>("node", " ").withList(list).withStringMapper().build())
.executes((sender, args) -> {
Collection<String> myList = (Collection<String>) args[0];
sender.sendMessage("Provided: " + myList);
})
.register();
new CommandAPICommand("blahcomma")
.withArguments(new ListArgumentBuilder<String>("node", ",").withList(list).withStringMapper().build())
.executes((sender, args) -> {
Collection<String> myList = (Collection<String>) args[0];
sender.sendMessage("Provided: " + myList);
})
.register();
Output: Typing a command can accept a list of arguments:
Issue Analytics
- State:
- Created a year ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Basics of Greedy Algorithms Tutorials & Notes - HackerEarth
Detailed tutorial on Basics of Greedy Algorithms to improve your understanding of Algorithms. Also try practice problems to test & improve your skill...
Read more >using greedy algorithm search in lists - prolog - Stack Overflow
using greedy algorithm search in lists ... Given a list of positive integer Items whose elements are guaranteed to be in sorted ascending...
Read more >Greedy Algorithm Explained using LeetCode Problems
Show that if we make the greedy choice, then only one subproblem remains. Validate the rightness of the greedy choice.
Read more >Greedy Algorithms
This argument implies by induction that some optimal solution contains the entire greedy solution, and therefore equals the greedy solution.
Read more >Greedy Algorithms
Lemma 1: The greedy algorithm always finds a path from the start lilypad to the destination lilypad. Proof: By contradiction; suppose it did...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’m looking forward to this update. 😃 👍
Thank you! I will upgrade my project in future. (I am too busy now.)