All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.minestom.server.command.builder.arguments.ArgumentStringArray Maven / Gradle / Ivy

There is a newer version: 7320437640
Show newest version
package net.minestom.server.command.builder.arguments;

import net.minestom.server.command.CommandSender;
import net.minestom.server.utils.StringUtils;
import net.minestom.server.utils.binary.BinaryWriter;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.regex.Pattern;

/**
 * Represents an argument which will take all the remaining of the command.
 * 

* Example: Hey I am a string */ public class ArgumentStringArray extends Argument { public ArgumentStringArray(String id) { super(id, true, true); } @NotNull @Override public String[] parse(@NotNull CommandSender sender, @NotNull String input) { return input.split(Pattern.quote(StringUtils.SPACE)); } @Override public String parser() { return "brigadier:string"; } @Override public byte @Nullable [] nodeProperties() { return BinaryWriter.makeArray(packetWriter -> { packetWriter.writeVarInt(2); // Greedy phrase }); } @Override public String toString() { return String.format("StringArray<%s>", getId()); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy