mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-22 17:27:38 +00:00
chore: add a more informative error when parsing block properties (#2524)
This commit is contained in:
parent
17abaeb19e
commit
f44b1b48c7
@ -178,9 +178,18 @@ public class BlockState implements BlockStateHolder<BlockState>, Pattern {
|
||||
String name = property.getName();
|
||||
|
||||
charSequence.setSubstring(propStrStart + name.length() + 2, state.length() - 1);
|
||||
int index = charSequence.length() <= 0 ? -1 : property.getIndexFor(charSequence);
|
||||
if (index != -1) {
|
||||
return type.withPropertyId(index);
|
||||
try {
|
||||
int index = charSequence.length() <= 0 ? -1 : property.getIndexFor(charSequence);
|
||||
if (index != -1) {
|
||||
return type.withPropertyId(index);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new InputParseException(Caption.of(
|
||||
"fawe.error.invalid-block-state-property",
|
||||
TextComponent.of(charSequence.toString()),
|
||||
TextComponent.of(name),
|
||||
TextComponent.of(state)
|
||||
), e);
|
||||
}
|
||||
}
|
||||
int stateId;
|
||||
@ -200,7 +209,17 @@ public class BlockState implements BlockStateHolder<BlockState>, Pattern {
|
||||
case ',': {
|
||||
charSequence.setSubstring(last, i);
|
||||
if (property != null) {
|
||||
int index = property.getIndexFor(charSequence);
|
||||
int index;
|
||||
try {
|
||||
index = property.getIndexFor(charSequence);
|
||||
} catch (Exception e) {
|
||||
throw new InputParseException(Caption.of(
|
||||
"fawe.error.invalid-block-state-property",
|
||||
TextComponent.of(charSequence.toString()),
|
||||
TextComponent.of(property.getName()),
|
||||
TextComponent.of(state)
|
||||
), e);
|
||||
}
|
||||
if (index == -1) {
|
||||
throw SuggestInputParseException.of(charSequence.toString(), (List<Object>) property.getValues());
|
||||
}
|
||||
|
@ -92,6 +92,7 @@
|
||||
"fawe.error.parser.invalid-data": "Invalid data: {0}",
|
||||
"fawe.error.unsupported": "Unsupported!",
|
||||
"fawe.error.invalid-block-type": "Does not match a valid block type: {0}",
|
||||
"fawe.error.invalid-block-state-property": "Cannot parse value `{0}` for property `{1}`, block state: `{2}`",
|
||||
"fawe.error.nbt.forbidden": "You are not allowed to use nbt. Lacking permission: {0}",
|
||||
"fawe.error.invalid-arguments": "Invalid amount of arguments. Expected: {0}",
|
||||
"fawe.error.unrecognised-tag": "Unrecognised tag: {0} {1}",
|
||||
|
Loading…
Reference in New Issue
Block a user