Skip to content
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 toFormattedString for null nodes #5303

Merged

Conversation

AyhamAl-Ali
Copy link
Member

Description

This PR fixes logger level color for messages that doesn't have a node.

Before:
image

After:

image


Target Minecraft Versions: Any
Requirements: None
Related Issues: None

@AyhamAl-Ali AyhamAl-Ali added the bug An issue that needs to be fixed. Alternatively, a PR fixing an issue. label Jan 1, 2023
@AyhamAl-Ali AyhamAl-Ali changed the title 🚀 Fix toFormattedString for null nodes 1ب6ث0 Fix toFormattedString for null nodes Jan 1, 2023
@AyhamAl-Ali AyhamAl-Ali changed the title 1ب6ث0 Fix toFormattedString for null nodes 🛠 Fix toFormattedString for null nodes Jan 1, 2023
@AyhamAl-Ali AyhamAl-Ali requested a review from TPGamesNL January 2, 2023 09:59
// Replace configured messages chat styles without user variables
String lineInfoMsg = replaceNewline(Utils.replaceEnglishChatStyles(lineInfo.getValue() == null ? lineInfo.key : lineInfo.getValue()));
String detailsMsg = replaceNewline(Utils.replaceEnglishChatStyles(details.getValue() == null ? details.key : details.getValue()));
String lineDetailsMsg = replaceNewline(Utils.replaceEnglishChatStyles(LINE_DETAILS.getValue() == null ? LINE_DETAILS.key : LINE_DETAILS.getValue()));

if (node == null)
return String.format(detailsMsg.replaceAll("(\\s){2,}", ""), message); // Remove line beginning spaces
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if replacing 2+ whitespace is the best approach here.

Also the group isn't needed I think: \\s{2,}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding upon what TP said, you can use String#stripLeading to remove the leading whitespaces in a string

Copy link
Member Author

@AyhamAl-Ali AyhamAl-Ali Apr 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

String#stripLeading Java 12 11 feature :(

@TheLimeGlass TheLimeGlass merged commit fd2425b into SkriptLang:master May 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An issue that needs to be fixed. Alternatively, a PR fixing an issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants