-
-
Notifications
You must be signed in to change notification settings - Fork 631
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
Fix ShutdownCommand message styling #1427
base: dev/3.0.0
Are you sure you want to change the base?
Conversation
)); | ||
Component reasonComponent = null; | ||
|
||
if (reason.startsWith("{") || reason.startsWith("[") || reason.startsWith("\"")) { |
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.
maybe we should do it like this?
char firstChar = reason.charAt(0);
char lastChar = reason.charAt(reason.length() - 1);
if ((firstChar == '{' && lastChar == '}')
|| (firstChar == '[' && lastChar == ']')
|| (firstChar == '"' && lastChar == '"')) {
try {
reasonComponent = GsonComponentSerializer.gson()
.deserializeOrNull(reason);
} catch (JsonSyntaxException e) {
log.warn("Failed to parse reason as JSON object: {}", reason, e);
}
}
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.
generally not fond of printing a warning for that kinda thing, and generally not sure what exactly this would solve vs the current approach
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.
generally not fond of printing a warning for that kinda thing, and generally not sure what exactly this would solve vs the current approach
this will allow server administrators to know the exact error when formatting is incorrect
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.
The command accepts json or MiniMessage, the intent is that it will silently fall through to parsing the alt format rather than blowing up
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.
The command accepts json or MiniMessage, the intent is that it will silently fall through to parsing the alt format rather than blowing up
How then to quickly determine where the error occurred? Maybe in that case it is worth trying log.debug?
@456dev can you fix the checkstyle issue here? |
the docs specify the command as accepting json components, as well as minimessage
in the previous implementation, neither were true, as the minimessage deserialisation after parsing legacy escaped any tags internally.
This PR fixes that by only deserialising the string once before parsing it on.
due to this, legacy "&" support has been removed
to support parsing as both minimessage + json, parsing as json will only kick in if it looks like a valid json text component:
Docs PR: PaperMC/docs#493