craftbukkit/src/test/java/org/bukkit
Aikar 1b2830a3b3 SPIGOT-4441: Fix serializing Components to and from Legacy
While cfeef75cd9 might of semi helped being able to save black text
lore, it actually took a fundamental problem with the legacy serialization
code and expanded it to break even more aspects of the server when dealing
with Component to Legacy conversion.

This is causing data loss in Spigot with cases such as setting an item name
to white gets stripped resulting in it being italic.

Additionally, things such as book pages have been returning black formatting
codes for the end of the line even when the user doesn't have colors in the book.

The root issue is that the "Default Color" system is fundamentally wrong.

Components do not and should not care about what element of the game they
are being used by, and that's what the default color system did.

It results in components that if obtained from 1 source such as a Book
where the default / rendered color is black, is then copied to another
source such as an Entity name, the black is carried forward and shown
in the Entity name, when in reality it should have been white.

This commit reverts cfeef75cd9 and fixes the underlying serialization
issues when it comes to Legacy to and From conversions.

There was quite a number of issues with this code overall, in how
it handles inserting color codes, new line parsing and such.

Books was using mojangs own "getLegacyString" which doesn't match behavior.
We also do not want to use Mojangs method as there is no guarantee they don't
remove that in future.
Plus, everything about books uses the CB implementation anyways, and it should
be consistent (this was mandatory to avoid serialization format changes on old vs new)

These changes as is results in Item Stacks already serialized will not
change contents when they go to component and back, so this won't impact
any existing data.

Newly created books though for example will change behavior in that they
will no longer insert black color codes in the serialized data and will
only represent intentional color changes by the creator of the book.
This will result in cleaner data on them, and books are the only thing
I'm aware of that has a behavioral shift due to the likelyhood of the
default color system kicking in on other parts of the string.

A unit test has been added to verify integrity of serialization to
ensure that any legacy string that is converted into Components will
always re-encode back in the same way when going back to Legacy.
2020-06-01 19:19:42 +10:00
..
block/banner SPIGOT-4818: Unit test banner patterns 2019-04-30 15:20:11 +10:00
craftbukkit SPIGOT-4441: Fix serializing Components to and from Legacy 2020-06-01 19:19:42 +10:00
enchantments SPIGOT-5516: Correct EnchantmentTarget values 2020-01-15 14:20:14 +11:00
entity Misc checkstyle fixes 2020-04-14 12:34:43 +10:00
map Update to Minecraft 1.13-pre7 2018-07-15 10:00:00 +10:00
potion Misc checkstyle fixes 2020-04-14 12:34:43 +10:00
support Misc checkstyle fixes 2020-04-14 12:34:43 +10:00
ArtTest.java Apply import ordering rules to CraftBukkit classes 2019-04-23 14:56:58 +10:00
BiomeTest.java Update to Minecraft 1.13.1 2018-08-26 12:00:00 +10:00
BlockDataConversionTest.java Add additional tests for CraftBlockData 2018-08-26 18:17:55 +10:00
BlockDataTest.java Apply import ordering rules to CraftBukkit classes 2019-04-23 14:56:58 +10:00
ChatTest.java Apply import ordering rules to CraftBukkit classes 2019-04-23 14:56:58 +10:00
DyeColorsTest.java Misc checkstyle fixes 2020-04-14 12:34:43 +10:00
EnchantmentTest.java Update to Minecraft 1.13.1 2018-08-26 12:00:00 +10:00
GameRuleTest.java Update to Minecraft 1.14.3-pre4 2019-06-21 20:00:00 +10:00
LootTablesTest.java SPIGOT-4872: LootTables missing a few loot tables 2019-05-06 08:40:15 +10:00
MaterialTest.java Apply import ordering rules to CraftBukkit classes 2019-04-23 14:56:58 +10:00
ParticleTest.java Update to Minecraft 1.14-pre5 2019-04-23 12:00:00 +10:00
PerMaterialTest.java #665: Add test for Material#getCraftingRemainingItem() 2020-05-28 19:31:27 +10:00
SoundTest.java Apply import ordering rules to CraftBukkit classes 2019-04-23 14:56:58 +10:00
StatisticsAndAchievementsTest.java Update to Minecraft 1.14.4 2019-07-20 09:00:00 +10:00
StructureTypeTest.java Update to Minecraft 1.14-pre5 2019-04-23 12:00:00 +10:00
WorldTypeTest.java Apply import ordering rules to CraftBukkit classes 2019-04-23 14:56:58 +10:00