Java Code Examples for com.mojang.brigadier.arguments.StringArgumentType#string()

The following examples show how to use com.mojang.brigadier.arguments.StringArgumentType#string() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StringArgumentPropertySerializer.java    From Velocity with MIT License 5 votes vote down vote up
@Override
public StringArgumentType deserialize(ByteBuf buf) {
  int type = ProtocolUtils.readVarInt(buf);
  switch (type) {
    case 0:
      return StringArgumentType.word();
    case 1:
      return StringArgumentType.string();
    case 2:
      return StringArgumentType.greedyString();
    default:
      throw new IllegalArgumentException("Invalid string argument type " + type);
  }
}
 
Example 2
Source File: ArgumentTest.java    From Chimera with MIT License 5 votes vote down vote up
@Test
void constructors() {
    var command = new Argument<>("name", StringArgumentType.string(), (context) -> 1, null, null);
    var execution = new Argument<>("name", StringArgumentType.string(), (source, context) -> {}, null, null);
    
    assertEquals("name", command.getName());
    assertEquals(StringArgumentType.string().getClass(), command.getType().getClass());
    
    assertEquals("name", execution.getName());
    assertEquals(StringArgumentType.string().getClass(), execution.getType().getClass());
}
 
Example 3
Source File: TextArgument.java    From 1.13-Command-API with Apache License 2.0 4 votes vote down vote up
/**
 * A string argument for one word, or multiple words encased in quotes
 */
public TextArgument() {
	super(StringArgumentType.string());
}
 
Example 4
Source File: CustomArgument.java    From 1.13-Command-API with Apache License 2.0 2 votes vote down vote up
/**
 * Creates a CustomArgument with a valid parser
 * 
 * @param parser
 *            A CustomArgumentParser that maps a String to the object of your choice.
 *            The String input is the text that the CommandSender inputs for
 *            this argument
 * @param keyed Whether this argument can accept Minecraft's <code>NamespacedKey</code> as
 * valid arguments
 */
public CustomArgument(CustomArgumentParser<T> parser, boolean keyed) {
	super(keyed ? CommandAPIHandler.getNMS()._ArgumentMinecraftKeyRegistered() : StringArgumentType.string());
	this.parser = parser;
}