net.minestom.server.command.builder.arguments.minecraft.ArgumentResourceLocation Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of minestom-snapshots Show documentation
Show all versions of minestom-snapshots Show documentation
1.20.4 Lightweight Minecraft server
package net.minestom.server.command.builder.arguments.minecraft;
import net.minestom.server.command.CommandSender;
import net.minestom.server.command.builder.arguments.Argument;
import net.minestom.server.command.builder.exception.ArgumentSyntaxException;
import net.minestom.server.utils.StringUtils;
import org.jetbrains.annotations.NotNull;
public class ArgumentResourceLocation extends Argument {
public static final int SPACE_ERROR = 1;
public ArgumentResourceLocation(@NotNull String id) {
super(id);
}
@NotNull
@Override
public String parse(@NotNull CommandSender sender, @NotNull String input) throws ArgumentSyntaxException {
if (input.contains(StringUtils.SPACE))
throw new ArgumentSyntaxException("Resource location cannot contain space character", input, SPACE_ERROR);
return input;
}
@Override
public String parser() {
return "minecraft:resource_location";
}
@Override
public String toString() {
return String.format("ResourceLocation<%s>", getId());
}
}