Querz / NBT

A java implementation of the NBT protocol, including a way to implement custom tags.
MIT License
182 stars 48 forks source link

add array type indicator, string escaping and remove joinTagString #7

Closed Querz closed 6 years ago

Querz commented 6 years ago

From @jochembroekhoff

This PR adds support for the following two new features:

An array type indicator as described in https://minecraft.gamepedia.com/Commands. Escaping of strings when needed. To check if a string needs to be escaped, it simply checks if the pattern [A-z0-9_\-+]+ does not match. I've tested that in-game and it seemed like the game only accepts non-escaped strings in that > pattern.

This makes it possible to really use the output of toTagString() in a Minecraft command. Without the > array type indicator and without the string escaping, it might sometimes not work.

I've updated the unit tests as well.

I changed the pattern to not match any ASCII characters between Z and a, removed the NBTUtil#joinTagString method and added a unit test for escaping an empty string.

jochembroekhoff commented 6 years ago

Thanks Querz,

Do you have any idea when you'll release a new version?

Querz commented 6 years ago

There we go.

I haven't worked on this project for some time, sorry if i acted a little bit clunky :)

I found some inconsistencies in the CompoundTag class while updating to 1.13, like a missing getListTag() method. Nothing too important but i'll probably add this in the near future.