mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-30 12:01:26 +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
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public ItemStack parse(@NotNull String input) throws ArgumentSyntaxException {
|
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("{");
|
final int nbtIndex = input.indexOf("{");
|
||||||
|
|
||||||
if (nbtIndex == 0)
|
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
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return String.format("ItemStack<%s>", getId());
|
return String.format("ItemStack<%s>", getId());
|
||||||
|
Loading…
Reference in New Issue
Block a user