-
Notifications
You must be signed in to change notification settings - Fork 0
Improve lore support #86
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
Conversation
📝 WalkthroughWalkthroughAdds multi-line (lore) support to Lang via four public getList overloads returning List<Component) and a private splitAndParseComponents helper. Updates loadSpecialTags iteration to use entrySet/getKey/getValue and adds 🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Actionable comments posted: 1
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.
Actionable comments posted: 2
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.
Actionable comments posted: 1
| private static List<Component> splitAndParseComponents(@Nullable Audience audience, @NotNull String raw, @NotNull String key) { | ||
| if (raw.isEmpty()) | ||
| return Collections.emptyList(); | ||
|
|
||
| return Arrays.stream(raw.split("\\R", -1)) | ||
| .map(line -> getComponentInternal(audience, line, key)) | ||
| .toList(); | ||
| } |
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.
🧹 Nitpick | 🔵 Trivial
Return a mutable list (or document immutability).
Stream#toList() returns an unmodifiable list; callers may try to append lore lines and hit UnsupportedOperationException. Consider returning a mutable list or explicitly documenting immutability.
♻️ Proposed change
- return Arrays.stream(raw.split("\\R", -1))
- .map(line -> getComponentInternal(audience, line, key))
- .toList();
+ return new ArrayList<>(
+ Arrays.stream(raw.split("\\R", -1))
+ .map(line -> getComponentInternal(audience, line, key))
+ .toList()
+ );📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| private static List<Component> splitAndParseComponents(@Nullable Audience audience, @NotNull String raw, @NotNull String key) { | |
| if (raw.isEmpty()) | |
| return Collections.emptyList(); | |
| return Arrays.stream(raw.split("\\R", -1)) | |
| .map(line -> getComponentInternal(audience, line, key)) | |
| .toList(); | |
| } | |
| private static List<Component> splitAndParseComponents(`@Nullable` Audience audience, `@NotNull` String raw, `@NotNull` String key) { | |
| if (raw.isEmpty()) | |
| return Collections.emptyList(); | |
| return new ArrayList<>( | |
| Arrays.stream(raw.split("\\R", -1)) | |
| .map(line -> getComponentInternal(audience, line, key)) | |
| .toList() | |
| ); | |
| } |
No description provided.