3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-10-03 04:10:06 +02:00

chore: add a more informative error when parsing block properties (#2524)

Dieser Commit ist enthalten in:
Jordan 2023-12-18 14:58:53 +00:00 committet von GitHub
Ursprung 17abaeb19e
Commit f44b1b48c7
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23
2 geänderte Dateien mit 24 neuen und 4 gelöschten Zeilen

Datei anzeigen

@ -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());
}

Datei anzeigen

@ -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}",