-
-
Notifications
You must be signed in to change notification settings - Fork 3
Bump down version and add readme and banner #54
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
* Innit commit with tests * Fix testes --------- Co-authored-by: Rollczi <[email protected]>
…atch user settings.
…icationNoticeCdnComposer.java Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
…icationNoticeCdnComposer.java Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
…d in official release
📝 Walkthrough📝 WalkthroughWalkthroughThis pull request introduces several key updates to the Multification library, primarily focusing on enhancing notification capabilities within Minecraft plugins. A new Additionally, a new Maven repository for Adventure snapshots has been added to the build configuration. The example plugin has been updated to register new commands, specifically a Possibly related PRs
Suggested reviewers
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🧰 Additional context used🔇 Additional comments (1)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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: 7
🧹 Outside diff range and nitpick comments (8)
buildSrc/src/main/kotlin/multification-repositories.gradle.kts (1)
13-13: Looks good! Maybe add a space?The new repository is a nice addition. For consistency with other lines, consider adding a space after the comment slash.
- maven("https://s01.oss.sonatype.org/content/repositories/snapshots/") // adventure snapshots + maven("https://s01.oss.sonatype.org/content/repositories/snapshots/") // adventure snapshotsmultification-core/src/com/eternalcode/multification/notice/resolver/bossbar/BossBarContent.java (1)
11-11: Nice job on the record!The
BossBarContentrecord looks good. It covers all the needed info for a boss bar.Quick tip: You could add a short comment explaining what this record does.
examples/bukkit/src/main/java/com/eternalcode/example/bukkit/command/timer/TimerCommand.java (1)
18-21: The execute method works, but could be more flexible.Maybe consider allowing different timer durations?
examples/bukkit/src/main/java/com/eternalcode/example/bukkit/command/timer/TimerManager.java (1)
24-36: Let's make the timer even better!The
tickTimermethod works, but we can improve it:
- Maybe add a check for negative seconds?
- For very long timers, we might want to use a different approach.
Want help making these changes?
examples/bukkit/src/main/java/com/eternalcode/example/bukkit/ExamplePlugin.java (1)
41-42: Command setup looks good, but could be even better!Nice job adding the TimerCommand! It's great that you're using the plugin's resources for the TimerManager.
A small suggestion: Consider moving the TimerManager creation to a separate method. It'll make the code even easier to read!
README.md (2)
1-13: Add alt text to the banner imageHey there! The banner looks great, but let's make it even better by adding some alt text. This helps everyone understand what's in the image, even if they can't see it.
Try updating line 3 like this:
- +🧰 Tools
🪛 Markdownlint
3-3: null
Images should have alternate text (alt text)(MD045, no-alt-text)
99-101: Small tweaks for the final sectionGreat info here! Let's make it even better with a few small changes:
- In line 99, try: "To add messages to the configuration, create a variable in the config with class
NoticeorBukkitNotice."- For line 101, let's remove the period at the end of the heading.
These little fixes will make your README shine even more!
Here's how you could update it:
-Setting up configuration is easy both in cdn and okaeri configs. To add messages to the configuration, create variable in config with class `Notice` or `BukktiNotice`. You can also use builder. After plugin deploy you can find messages in configuration file. +Setting up configuration is easy both in cdn and okaeri configs. To add messages to the configuration, create a variable in the config with class `Notice` or `BukkitNotice`. You can also use a builder. After plugin deployment, you can find messages in the configuration file. -### To see more examples open the [example plugin module](https://github.com/EternalCodeTeam/multification/tree/master/examples/bukkit). +### To see more examples open the [example plugin module](https://github.com/EternalCodeTeam/multification/tree/master/examples/bukkit)🧰 Tools
🪛 LanguageTool
[uncategorized] ~99-~99: You might be missing the article “a” here.
Context: ...d messages to the configuration, create variable in config with classNoticeor `Bukkt...(AI_EN_LECTOR_MISSING_DETERMINER_A)
[uncategorized] ~99-~99: You might be missing the article “the” here.
Context: ...uration, create variable in config with classNoticeorBukktiNotice. You can als...(AI_EN_LECTOR_MISSING_DETERMINER_THE)
[uncategorized] ~101-~101: Possible missing comma found.
Context: ...in configuration file. ### To see more examples open the [example plugin module](https:...(AI_HYDRA_LEO_MISSING_COMMA)
🪛 Markdownlint
101-101: Punctuation: '.'
Trailing punctuation in heading(MD026, no-trailing-punctuation)
multification-okaeri/test/com/eternalcode/multification/okaeri/NoticeSerializerTest.java (1)
583-583: Quick note: Be cautious with string replacementsIn the
removeBlankNewLinesmethod, removing all quotation marks might affect the expected YAML strings.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
⛔ Files ignored due to path filters (1)
assets/readme-banner.pngis excluded by!**/*.png
📒 Files selected for processing (19)
- README.md (1 hunks)
- buildSrc/src/main/kotlin/multification-repositories.gradle.kts (1 hunks)
- examples/bukkit/src/main/java/com/eternalcode/example/bukkit/ExamplePlugin.java (2 hunks)
- examples/bukkit/src/main/java/com/eternalcode/example/bukkit/command/timer/TimerCommand.java (1 hunks)
- examples/bukkit/src/main/java/com/eternalcode/example/bukkit/command/timer/TimerManager.java (1 hunks)
- examples/bukkit/src/main/java/com/eternalcode/example/bukkit/config/MessagesConfig.java (3 hunks)
- multification-cdn/src/com/eternalcode/multification/cdn/MultificationNoticeCdnComposer.java (9 hunks)
- multification-cdn/test/com/eternalcode/multification/cdn/NoticeComposerTest.java (14 hunks)
- multification-core/src/com/eternalcode/multification/notice/Notice.java (4 hunks)
- multification-core/src/com/eternalcode/multification/notice/NoticeBroadcastImpl.java (1 hunks)
- multification-core/src/com/eternalcode/multification/notice/NoticeKey.java (2 hunks)
- multification-core/src/com/eternalcode/multification/notice/resolver/NoticeResolverDefaults.java (2 hunks)
- multification-core/src/com/eternalcode/multification/notice/resolver/NoticeSerdesResult.java (2 hunks)
- multification-core/src/com/eternalcode/multification/notice/resolver/bossbar/BossBarContent.java (1 hunks)
- multification-core/src/com/eternalcode/multification/notice/resolver/bossbar/BossBarResolver.java (1 hunks)
- multification-core/src/com/eternalcode/multification/notice/resolver/bossbar/BossBarService.java (1 hunks)
- multification-core/test/com/eternalcode/multification/MultificationTest.java (2 hunks)
- multification-okaeri/src/com/eternalcode/multification/okaeri/MultificationNoticeSerializer.java (3 hunks)
- multification-okaeri/test/com/eternalcode/multification/okaeri/NoticeSerializerTest.java (16 hunks)
🧰 Additional context used
🪛 LanguageTool
README.md
[uncategorized] ~99-~99: You might be missing the article “a” here.
Context: ...d messages to the configuration, create variable in config with classNoticeor `Bukkt...(AI_EN_LECTOR_MISSING_DETERMINER_A)
[uncategorized] ~99-~99: You might be missing the article “the” here.
Context: ...uration, create variable in config with classNoticeorBukktiNotice. You can als...(AI_EN_LECTOR_MISSING_DETERMINER_THE)
[uncategorized] ~101-~101: Possible missing comma found.
Context: ...in configuration file. ### To see more examples open the [example plugin module](https:...(AI_HYDRA_LEO_MISSING_COMMA)
🪛 Markdownlint
README.md
101-101: Punctuation: '.'
Trailing punctuation in heading(MD026, no-trailing-punctuation)
3-3: null
Images should have alternate text (alt text)(MD045, no-alt-text)
🔇 Additional comments (58)
multification-core/src/com/eternalcode/multification/notice/resolver/bossbar/BossBarContent.java (2)
1-9: Looks good!The package and imports are set up correctly.
13-16: Good work on the method!The
contents()method does exactly what it needs to do. It's simple and clear.examples/bukkit/src/main/java/com/eternalcode/example/bukkit/command/timer/TimerCommand.java (4)
1-7: Looks good!The package and imports are set up nicely.
8-9: Good job on the annotations!The command name and permission are clearly defined.
10-12: Nice and clean class setup!The class and field are well-defined.
14-16: Good constructor!It's set up correctly to initialize the timer manager.
multification-core/src/com/eternalcode/multification/notice/resolver/NoticeSerdesResult.java (2)
4-4: Looks good!The new import is needed for the
Sectionrecord. Nice job adding it.
36-41: Can you explain theSectionrecord?The new
Sectionrecord looks okay, but I'm not sure why it's needed. Could you add a comment explaining what it's for? Also, why doesanyElements()return an empty list?examples/bukkit/src/main/java/com/eternalcode/example/bukkit/command/timer/TimerManager.java (3)
1-8: Good job on the setup!The class name and imports look good. They match what the class does.
10-18: Nice work on the constructor!The fields and constructor look good. They're set up correctly.
20-22: Good start to the timer!The
startTimermethod looks simple and does its job well.multification-core/src/com/eternalcode/multification/notice/NoticeKey.java (2)
5-5: New import looks good!The import for
BossBarContentfits right in with the other imports.
21-21: Nice addition of BOSS_BAR constant!The new
BOSS_BARconstant matches the style of the other constants. Good job keeping things consistent!multification-core/src/com/eternalcode/multification/notice/resolver/NoticeResolverDefaults.java (2)
4-5: New imports look good!These imports will help with the new boss bar feature. Nice addition!
31-31: Great job adding the boss bar resolver!The new boss bar resolver fits in nicely with the other resolvers. It's a good addition to the registry.
examples/bukkit/src/main/java/com/eternalcode/example/bukkit/config/MessagesConfig.java (3)
6-6: New imports look good!The added imports for BossBar and Duration are needed for the new timer feature. Nice job!
Also applies to: 10-10
25-25: Cool gradient effect!The new subtitle looks great with the gradient colors. It's a nice touch that makes the message pop!
35-38: Awesome boss bar timer!The new bossbarTimer looks great! It adds a cool feature for showing timers to players. Good job on using a placeholder for the time too!
examples/bukkit/src/main/java/com/eternalcode/example/bukkit/ExamplePlugin.java (2)
5-6: New imports look good!The TimerCommand and TimerManager imports are in the right place. They'll help with the new timer feature.
5-6: Great job adding the timer feature!You've smoothly integrated the new timer functionality into the plugin. The imports and command setup look good. This update will give users more options, which is awesome!
Also applies to: 41-42
README.md (3)
15-30: Great job on the introduction!The intro looks spot-on! It's clear and covers all the key points about what Multification can do. Nice work!
32-39: Setup instructions look goodThe setup part is clear and easy to follow. You've made it simple for people to add Multification to their projects. Well done!
41-97: Code examples are helpfulThese examples are great! They show exactly how to set up and use Multification in a project. This will be super helpful for users.
multification-core/test/com/eternalcode/multification/MultificationTest.java (1)
104-104: Nice touch with the test name!Adding a display name makes the test purpose clearer. Good job!
multification-okaeri/src/com/eternalcode/multification/okaeri/MultificationNoticeSerializer.java (1)
61-63: Handling 'Section' results looks good!The addition for serializing
NoticeSerdesResult.Sectionis correct.multification-core/src/com/eternalcode/multification/notice/Notice.java (2)
107-130: Great addition of bossBar methods!The new static methods for boss bar notifications are a valuable enhancement.
218-233: Builder methods for bossBar look good!The builder now offers flexible options for creating boss bar notices.
multification-core/src/com/eternalcode/multification/notice/NoticeBroadcastImpl.java (1)
325-328: Nice addition of thegetThis()method!Including this method helps with method chaining and keeps the code clean.
multification-cdn/test/com/eternalcode/multification/cdn/NoticeComposerTest.java (9)
331-333: Great addition of boss bar testsAdding the
ConfigBossbarWOBuilderclass improves test coverage for boss bar serialization without using the builder.
335-359: Test methods are well-structuredThe test
serializeBossBarSectionWithAllPropertiesWOBuildereffectively verifies serialization with all properties.
361-387: Good job testing without progressYour tests for boss bar serialization without progress ensure correct handling when progress isn't specified.
389-417: Effective testing without overlayThe
ConfigBossbarWithoutOverlayWOBuilderclass and its test confirm proper behavior when overlay is omitted.
419-447: Comprehensive tests for minimal configurationsIncluding tests without both progress and overlay enhances confidence in default behavior handling.
449-478: Nice use of builder patternThe
ConfigBossBarWithAllPropertiesclass demonstrates effective use of the builder for boss bar configuration.
481-509: Thorough testing without progressYour test ensures that boss bar serialization works correctly when progress isn't provided.
511-542: Solid verification without overlayTesting boss bar serialization without an overlay confirms the robustness of default settings.
544-574: Ensuring functionality with minimal settingsThe test for boss bar without progress and overlay confirms proper handling of minimal configurations.
multification-okaeri/test/com/eternalcode/multification/okaeri/NoticeSerializerTest.java (16)
322-324: Great addition of the ConfigBossbarWOBuilder class!The boss bar notice configuration is clear and easy to understand.
326-339: Test method looks solidThe
serializeBossBarWOBuilderWithAllPropertiestest correctly verifies serialization with all properties.
353-354: Nice work on ConfigBossbarWithoutProgressWOBuilderThis class effectively tests serialization without the progress property.
356-369: Test covers the scenario wellThe
serializeBossBarWOBuilderWithoutProgressPropertytest checks serialization without the progress property as expected.
381-382: ConfigBossbarWithoutOverlayWOBuilder looks goodYou're properly testing the absence of the overlay property.
384-396: Test method is well-implementedThe
serializeBossBarWOBuilderWithoutOverlayPropertytest verifies serialization without the overlay property effectively.
412-413: ConfigBossbarWithoutProgressAndOverlayWOBuilder is well-definedThis class tests serialization without both progress and overlay properties nicely.
415-426: Test accurately checks serializationThe
serializeBossBarWOBuilderWithoutProgressAndOverlayPropertiestest validates the serialization without progress and overlay properties.
441-445: Good use of the builder pattern in ConfigBossBarThis enhances readability and makes the code easy to maintain.
447-470: Test effectively verifies boss bar serializationThe
serializeBossBarSectionWithAllPropertiestest checks all properties are serialized correctly.
472-476: ConfigBossBarWithoutProgress is well-craftedTesting without the progress property is handled well here.
478-500: Test properly verifies absence of progress propertyThe
serializeBossBarSectionWithoutProgressPropertytest functions as expected.
502-506: ConfigBossBarWithoutOverlay looks goodThis configuration tests serialization without the overlay property effectively.
508-533: Test correctly checks serialization without overlayThe
serializeBossBarSectionWithoutOverlayPropertytest validates the intended behavior.
535-539: ConfigBossBarWithoutProgressAndOverlay is well-designedYou're covering the scenario without both progress and overlay properties nicely.
541-565: Test effectively handles serialization without progress and overlayThe
serializeBossBarSectionWithoutProgressAndOverlayPropertiestest confirms the expected serialization.multification-cdn/src/com/eternalcode/multification/cdn/MultificationNoticeCdnComposer.java (5)
14-14: Imports look good!The necessary classes are properly imported.
Also applies to: 16-16, 27-27
46-46: Method signature updated appropriately.Adding
String keyenhances the method's functionality.
110-114: Great addition for handling sections.This improves the serialization logic.
139-146: New methodtoNamedSectionis a helpful addition.It enhances how sections are serialized.
215-218: Double-checkresult.project()usage.Please ensure it returns the intended result in this context.
|
|
||
| public class BossBarService { | ||
|
|
||
| private final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(8); |
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.
🛠️ Refactor suggestion
Consider using fewer threads.
An 8-thread pool might be more than necessary. A smaller pool could work just as well.
| } | ||
|
|
||
| Duration remaining = Duration.between(Instant.now(), expiration); | ||
| float progress = 1 - (float) remaining.getSeconds() / duration.getSeconds(); |
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.
Avoid division by zero.
If duration.getSeconds() is zero, this will cause an error. Please add a check to prevent this.
| BossBar.Color color = BossBar.Color.valueOf(sectionResult.elements().getOrDefault("color", DEFAULT_COLOR)); | ||
| Duration duration = DurationParser.TIME_UNITS.parse(sectionResult.elements().getOrDefault("duration", DEFAULT_DURATION)); | ||
|
|
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.
Handle invalid color input
If the 'color' value is invalid, it might cause an exception. Let's add a check to use the default color when needed.
| if (sectionResult.elements().get("overlay") != null) { | ||
| overlay = Optional.of(BossBar.Overlay.valueOf(sectionResult.elements().get("overlay"))); | ||
| } | ||
| else { | ||
| overlay = Optional.empty(); | ||
| } |
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.
Handle invalid overlay input
An invalid 'overlay' value could lead to exceptions. It's a good idea to default to a safe value if parsing fails.
| double progress = Double.parseDouble(rawProgress); | ||
| return OptionalDouble.of(progress); | ||
| } |
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.
Ensure 'progress' is within valid range
Let's validate that 'progress' is between 0.0 and 1.0 to prevent unexpected behavior.
| if (value instanceof Map<?, ?> mapValue) { | ||
| NoticeDeserializeResult<?> noticeResult = this.noticeRegistry.deserialize(key, new NoticeSerdesResult.Section((Map<String, String>) mapValue)) | ||
| .orElseThrow(() -> new UnsupportedOperationException( | ||
| "Unsupported notice key: " + key + " with values: " + mapValue)); | ||
|
|
||
| this.withPart(builder, noticeResult); | ||
| continue; | ||
| } | ||
|
|
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.
Ensure safe casting in deserialization.
Casting mapValue to (Map<String, String>) may cause issues if the map doesn't contain String keys and values. Please check the map's contents before casting to prevent potential errors.
| private Result<Blank, Exception> appendEntry(Entry entry, Notice.Builder builder) { | ||
| String value = this.deserializePiece(entry.getValue()); | ||
| String key = entry.getName(); | ||
|
|
||
| NoticeSerdesResult.Single result = new NoticeSerdesResult.Single(value); | ||
| Optional<NoticeDeserializeResult<?>> optional = this.noticeRegistry.deserialize(key, result); | ||
|
|
||
| if (optional.isEmpty()) { | ||
| return Result.error(new IllegalStateException("Unsupported notice type: " + key)); | ||
| } | ||
|
|
||
| this.withPart(builder, optional.get()); | ||
| return Result.ok(); | ||
| } | ||
|
|
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.
🛠️ Refactor suggestion
Consider simplifying similar code in appendEntry and appendSection.
Combining shared logic might make the code cleaner.
Also applies to: 255-286
* Innit commit with tests * Fix testes --------- Co-authored-by: Rollczi <[email protected]>
…atch user settings.
…d in official release
…n-version # Conflicts: # multification-core/src/com/eternalcode/multification/notice/Notice.java
No description provided.