Class CommonParameters
parameters that can be reused in
 multiple commands.
 The intent behind these parameters is to reduce the amount of boilerplate
 used when creating commands and retrieving elements. A general workflow for
 defining a command with a ServerPlayer parameter may look like this:
 
 
 final Parameter.Value<ServerPlayer> parameter = Parameter.player().setKey("player").build();
 final Command.Parameterized builder = Command.builder()
      .parameter(parameter)
      .executor(context -> {
          context.sendMessage(Component.text(context.requireOne(parameter).getName()));
          return CommandResult.success();
      }).build();
 // registration happens here.
 
 While this is a totally valid approach, there are two particular considerations that can be made:
- Sponge provided ValueParameters and, by extension,Parameter.Values are stateless and so can be reused by multiple commands, or indeed, multiple times within the same command; and
- Due to the type safety provided by the CommandContextand the requirement of retrieving parsed arguments by theParameter.Key(or the actualParameter.Value, which implements this key, plugin developers will either need to keep a reference to the parameter value, its key, or rebuild the key as required (paying close attention to theParameter.Valuetype).
Given these two considerations, it generally makes sense to store one
 Parameter.Value for a given ValueParameter and 
 Parameter.Key combination. Further, it is clear that plugins will
 tend to use similar, if not the same, parameter/key combinations.
The values held by this class are commonly used Parameter.Values
 with sensible key names such that plugin developers do not have to generate
 their own parameters and can also use these as Parameter.Keys when
 obtaining results from the CommandContext. The example above would
 then become:
 
 final Command.Parameterized builder = Command.builder()
      .parameter(CommonParameters.PLAYER)
      .executor(context -> {
          context.sendMessage(Component.text(context.requireOne(CommonParameters.PLAYER).getName()));
          return CommandResult.success();
      }).build();
 // registration happens here.
 
 reducing object creation and slightly reducing repetition amongst commands that use the same parameters.
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final Parameter.Value<Boolean>AParameter.Valuethat parses aBooleanwith the key name "true/false".static final Parameter.Value<ServerLocation>AParameter.Valuethat parses a world and a position and stores it as aServerLocationunder the key "location".static final Parameter.Value<String>AParameter.Valuethat parses the remainder of the string under the key "message".static final Parameter.Value<ServerPlayer>AParameter.Valuethat parses a player name or selector and stores the results under the key "player".static final Parameter.Value<ServerPlayer>AParameter.Valuethat parses a player name or selector and stores the results under the key "player" if the input is valid.static final Parameter.Value<Vector3d>AParameter.Valuethat parses a position and stores it as aVector3dunder the key "position".static final Parameter.Value<ServerWorld>AParameter.Valuethat parses a world id and stores it as aServerWorldunder the key "world".
- 
Method Summary
- 
Field Details- 
WORLDAParameter.Valuethat parses a world id and stores it as aServerWorldunder the key "world".- See Also:
 
- 
BOOLEANAParameter.Valuethat parses aBooleanwith the key name "true/false".- See Also:
 
- 
LOCATION_ONLINE_ONLYAParameter.Valuethat parses a world and a position and stores it as aServerLocationunder the key "location".- See Also:
 
- 
MESSAGEAParameter.Valuethat parses the remainder of the string under the key "message".
- 
PLAYERAParameter.Valuethat parses a player name or selector and stores the results under the key "player".- See Also:
 
- 
PLAYER_OPTIONALAParameter.Valuethat parses a player name or selector and stores the results under the key "player" if the input is valid. Otherwise, this parameter is skipped.- See Also:
 
- 
POSITIONAParameter.Valuethat parses a position and stores it as aVector3dunder the key "position".- See Also:
 
 
-