mirror of
https://github.com/Minestom/Minestom.git
synced 2024-06-24 13:34:53 +02:00
Signed-off-by: mworzala <mattheworzala@gmail.com>
fix default argument issue
(cherry picked from commit a7440639c8541faeb91155c53ce3a1f4d60df127)
Add sender to command parse chain
(cherry picked from commit 853307891d178abdc7036f8c809c52909cdca327)
(cherry picked from commit 1268cf16c0
)
38 lines
1.0 KiB
Java
38 lines
1.0 KiB
Java
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 org.jetbrains.annotations.NotNull;
|
|
|
|
import java.util.UUID;
|
|
|
|
public class ArgumentUUID extends Argument<UUID> {
|
|
|
|
public static final int INVALID_UUID = -1;
|
|
|
|
public ArgumentUUID(@NotNull String id) {
|
|
super(id);
|
|
}
|
|
|
|
@NotNull
|
|
@Override
|
|
public UUID parse(@NotNull CommandSender sender, @NotNull String input) throws ArgumentSyntaxException {
|
|
try {
|
|
return UUID.fromString(input);
|
|
} catch (IllegalArgumentException exception) {
|
|
throw new ArgumentSyntaxException("Invalid UUID", input, INVALID_UUID);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public String parser() {
|
|
return "minecraft:uuid";
|
|
}
|
|
|
|
@Override
|
|
public String toString() {
|
|
return String.format("UUID<%s>", getId());
|
|
}
|
|
}
|