mirror of
https://github.com/Minestom/Minestom.git
synced 2024-06-24 13:34:53 +02:00
* first join
* add new entities
* fix type on interpolation duration
* switch long to var long
* switch long to var long, round 2
* add flags to TextDisplay
* 1.19.4
* setView in Entity#teleport
* do not trigger touchTick if entity physics are disabled
* Add new 1.19.4 packets
* constant expr
* no localhost on github actions
* yoinked changes from 1.19.3 main
* update to forked changes
* remove potion command
* remove potion command
---------
Co-authored-by: GreatWyrm <alecmusante@gmail.com>
(cherry picked from commit 7f3144337d
)
47 lines
1.4 KiB
Java
47 lines
1.4 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 net.minestom.server.utils.StringUtils;
|
|
import net.minestom.server.utils.binary.BinaryWriter;
|
|
import org.jetbrains.annotations.NotNull;
|
|
import org.jetbrains.annotations.Nullable;
|
|
|
|
public class ArgumentResource extends Argument<String> {
|
|
|
|
public static final int SPACE_ERROR = 1;
|
|
|
|
private final String identifier;
|
|
|
|
public ArgumentResource(@NotNull String id, @NotNull String identifier) {
|
|
super(id);
|
|
this.identifier = identifier;
|
|
}
|
|
|
|
@Override
|
|
public @NotNull 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";
|
|
}
|
|
|
|
@Override
|
|
public String toString() {
|
|
return String.format("Resource<%s>", getId());
|
|
}
|
|
|
|
@Override
|
|
public byte @Nullable [] nodeProperties() {
|
|
return BinaryWriter.makeArray(packetWriter ->
|
|
packetWriter.writeSizedString(this.identifier)
|
|
);
|
|
}
|
|
}
|