The issue "Formatting was not a valid color: §m"#12863
Closed
Nu11ified wants to merge 1 commit into
Closed
Conversation
occurs because: 1. The TextColor.parseColor method in Minecraft is trying to parse formatting codes (like §m, §n, §o, §k, §l) as colors 2. These codes are formatting codes (strikethrough, underline, italic, obfuscated, bold), not color codes 3. When the server tries to serialize text components during world saving, these formatting codes are incorrectly processed through the color parsing pipeline 4. The PaperAdventure.asAdventure(ChatFormatting) method throws an exception when it encounters formatting codes because ChatFormatting.getColor() returns null for these codes The fix: Fix in PaperAdventure.java where the the error message was improved to be more descriptive. Fix in AdventureCodecs.java where the TEXT_COLOR_CODEC was modified to handle formatting codes properly. The changes ensure that: 1. Server crashes are prevented when encountering formatting codes during world saving. 2. Clear error messages are provided for debugging. 3. The serialization system can handle the errors gracefully instead of crashing the entire server.
Contributor
|
This does not actually fix the bug, nor is it really a bug. Thank you anyway for the PR! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request improves error handling and validation in the
AdventureCodecsandPaperAdventureclasses. The changes ensure better differentiation between formatting codes and valid colors, enhancing clarity and robustness in handling text color conversions.Error Handling Improvements:
AdventureCodecs(paper-server/src/main/java/io/papermc/paper/adventure/AdventureCodecs.java): Added checks to identify and reject formatting codes (e.g.,§k,§l, etc.) when they are mistakenly passed as colors. This ensures that only valid color codes or named colors are processed, with appropriate error messages for invalid inputs.PaperAdventure(paper-server/src/main/java/io/papermc/paper/adventure/PaperAdventure.java): Enhanced the error message in theasAdventuremethod to include the specific formatting code that caused the exception, providing more context for debugging.