-
-
Notifications
You must be signed in to change notification settings - Fork 57
Make default values more powerful #500
Copy link
Copy link
Closed
Milestone
Description
In Cloud v1 the default values are stored in the arguments, and the argument builder has the ability to serialize objects into strings. These values are then pushed onto the input queue when parsing.
In Cloud v2 the default values are stored in the command components, instead of the arguments. This means they bypass the argument entirely, and we thus lose the ability to pre-serialize these objects. However, instead of bringing back that functionality, I am instead proposing a new mechanism for default values.
public interface DefaultValue<C, T> {
@NonNull <T> evaluteDefault(@NonNull CommandContext<C> context);
}We'd offer three types:
- constant:
DefaultValue.constant(5),DefaultValue.constant(Duration.ofSeconds(5L)) - dynamic:
DefaultValue.dynamic(ctx -> ctx.sender().getLocation()) - parsed:
DefaultValue.parsed("5"),DefaultValue.parsed("@p")
constant/dynamic would bypass the optional argument entirely, whereas parsed would still push the default value onto the input
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels