-
-
Notifications
You must be signed in to change notification settings - Fork 883
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add parsing support for block NBT #2173
Conversation
f07a1d0
to
65b2109
Compare
Codecov Report
@@ Coverage Diff @@
## master #2173 +/- ##
===========================================
+ Coverage 8.88% 9.20% +0.31%
+ Complexity 1095 1038 -57
===========================================
Files 886 871 -15
Lines 46452 43683 -2769
Branches 5189 4881 -308
===========================================
- Hits 4129 4019 -110
+ Misses 42130 39483 -2647
+ Partials 193 181 -12
... and 89 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
65b2109
to
ce43cdf
Compare
640b0ff
to
c5d327f
Compare
...edit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/DefaultBlockParser.java
Outdated
Show resolved
Hide resolved
} | ||
|
||
String stateString = null; | ||
if (stateStart != -1) { | ||
if (stateStart + 1 >= blockAndExtraData[0].length()) { | ||
throw new InputParseException(TranslatableComponent.of("worldedit.error.parser.hanging-lbracket", TextComponent.of(stateStart))); | ||
} | ||
int stateEnd = blockAndExtraData[0].lastIndexOf(']'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check behavior for this test case: chest[double={whoops:"nbt ]"}
; it might pass, or fail with a weird error.
I suspect we might need to be a little more strict in what is accepted here. It might be worth writing an ANTLR grammar for this instead, since it's getting quite complex.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
State is missing trailing ']'
is the error we get here, which appears to be the correct error
if (nbtStart + 1 >= blockAndExtraData[0].length()) { | ||
throw new InputParseException(TranslatableComponent.of("worldedit.error.parser.hanging-lbrace", TextComponent.of(nbtStart))); | ||
} | ||
int nbtEnd = blockAndExtraData[0].lastIndexOf('}'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similarly here, we might cut off NBT early if there's }
in an NBT string, and someone doesn't put one at the end, resulting in a weird error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will result in an invalid NBT error
...edit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/DefaultBlockParser.java
Outdated
Show resolved
Hide resolved
c5d327f
to
1fb6d35
Compare
4bd2c50
to
b840b85
Compare
Closes #2375 |
…o a lin-bus issue
8c988c0
to
c000572
Compare
Adds block NBT parsing support.
Test with
//set chest{'Lock':'cake'}
, then notice you can only open the chest with an item namedcake
Test with
//set oak_sign[rotation=12]{'is_waxed':1,'front_text':{'messages':['{"text":"a"}','{"text":"a"}','{"text":"a"}','{"text":"a","color":"red"}']}}
for a waxed sign with 'a' on every line where the last line is red