mirror of
https://github.com/Minestom/Minestom.git
synced 2024-11-02 17:00:41 +01:00
Support standalone itemstack string parsing
This commit is contained in:
parent
34d81f2bca
commit
47e7d35949
@ -33,6 +33,18 @@ public class ArgumentItemStack extends Argument<ItemStack> {
|
||||
@NotNull
|
||||
@Override
|
||||
public ItemStack parse(@NotNull String input) throws ArgumentSyntaxException {
|
||||
return staticParse(input);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processNodes(@NotNull NodeMaker nodeMaker, boolean executable) {
|
||||
DeclareCommandsPacket.Node argumentNode = simpleArgumentNode(this, executable, false, false);
|
||||
argumentNode.parser = "minecraft:item_stack";
|
||||
|
||||
nodeMaker.addNodes(new DeclareCommandsPacket.Node[]{argumentNode});
|
||||
}
|
||||
|
||||
public static ItemStack staticParse(@NotNull String input) throws ArgumentSyntaxException {
|
||||
final int nbtIndex = input.indexOf("{");
|
||||
|
||||
if (nbtIndex == 0)
|
||||
@ -60,14 +72,6 @@ public class ArgumentItemStack extends Argument<ItemStack> {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processNodes(@NotNull NodeMaker nodeMaker, boolean executable) {
|
||||
DeclareCommandsPacket.Node argumentNode = simpleArgumentNode(this, executable, false, false);
|
||||
argumentNode.parser = "minecraft:item_stack";
|
||||
|
||||
nodeMaker.addNodes(new DeclareCommandsPacket.Node[]{argumentNode});
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("ItemStack<%s>", getId());
|
||||
|
Loading…
Reference in New Issue
Block a user