-
Type:
New Feature
-
Resolution: Unresolved
-
Priority:
Minor
-
None
-
Affects Version/s: None
-
None
-
n/a
-
Yes
As one of the devs of Skript, it was recently brought to my attention that setting entity names with HEX color codes was extremely limited in length.
After doing some testing to make sure this was true, I took at look at the source code and found this:
@Override public void setCustomName(String name) { // sane limit for name length if (name != null && name.length() > 256) { name = name.substring(0, 256); } getHandle().setCustomName(CraftChatMessage.fromStringOrNull(name)); }
As seen here, the length is limited without accounting for color codes. As we all know, HEX color codes can be quite long, so if using multiple HEX color codes for different parts of a string, you are extremely limited in the possible length you can use.
Doing some fun testing, when bypassing this limit, if I had 1000 characters, this failed to save the chunk as the name was too long.
Doing another test, with 256 characters (each with a different color code) the chunk saved/loaded with no issues. This shows me that 256 characters each with a different hex color code is very possible to achieve (see picture below - its a bunch of armor stands with 256 coloured character names)
So using ChatColor.stripColor() to compare the length could be used here.
The maximum JSON text length that could be saved in NBT is 65535.