mirror of
https://github.com/Minestom/Minestom.git
synced 2024-12-30 21:17:53 +01:00
Fix item stack argument
This commit is contained in:
parent
13b7039721
commit
de944edf42
@ -24,6 +24,7 @@ public class ArgumentItemStack extends Argument<ItemStack> {
|
||||
|
||||
public static final int NO_MATERIAL = 1;
|
||||
public static final int INVALID_NBT = 2;
|
||||
public static final int INVALID_MATERIAL = 3;
|
||||
|
||||
public ArgumentItemStack(String id) {
|
||||
super(id, true);
|
||||
@ -56,11 +57,15 @@ public class ArgumentItemStack extends Argument<ItemStack> {
|
||||
if (nbtIndex == -1) {
|
||||
// Only material name
|
||||
final Material material = Material.fromNamespaceId(input);
|
||||
if (material == null)
|
||||
throw new ArgumentSyntaxException("Material is invalid", input, INVALID_MATERIAL);
|
||||
return ItemStack.of(material);
|
||||
} else {
|
||||
// Material plus additional NBT
|
||||
final String materialName = input.substring(0, nbtIndex);
|
||||
final Material material = Material.fromNamespaceId(materialName);
|
||||
if (material == null)
|
||||
throw new ArgumentSyntaxException("Material is invalid", input, INVALID_MATERIAL);
|
||||
|
||||
final String sNBT = input.substring(nbtIndex).replace("\\\"", "\"");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user