Skip to content

GH-121 Enhanced delivery logic#121

Merged
Jakubk15 merged 44 commits intomasterfrom
enhanced-delivery-logic
Jul 5, 2025
Merged

GH-121 Enhanced delivery logic#121
Jakubk15 merged 44 commits intomasterfrom
enhanced-delivery-logic

Conversation

@Jakubk15
Copy link
Member

No description provided.

@Jakubk15 Jakubk15 added the 🆕 feature New feature or request label Mar 15, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 15, 2025

Walkthrough

This update removes Vault economy support and related code. It adds a new delivery system with classes and interfaces to manage parcel deliveries and timing. Parcels now include a status field tracked by a new enum. Configuration replaces parcel cost settings with delivery durations and updates messages and GUI items. Some commands now accept general senders instead of just players. Placeholder handling in GUIs is centralized for consistency. Parcel saving and delivery scheduling are now asynchronous. The build script is simplified by fixing repository URLs, merging clean tasks, and updating dependencies. Cache and repository logic are improved. Overall, these changes improve parcel delivery management and clean up unused features.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 040478b and 5f2d275.

📒 Files selected for processing (1)
  • build.gradle.kts (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • build.gradle.kts
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build
✨ Finishing Touches
  • 📝 Generate Docstrings

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@Jakubk15 Jakubk15 changed the title Enhanced delivery logic GH-121 Enhanced delivery logic Mar 15, 2025
@Jakubk15 Jakubk15 marked this pull request as ready for review April 26, 2025 18:20
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 6

🧹 Nitpick comments (13)
src/main/java/com/eternalcode/parcellockers/ParcelLockersCommand.java (1)

30-30: Command alias removed

The "rl" alias has been removed from the reload command. Now users will need to type the full "reload" command instead of the shorter alias.

src/main/java/com/eternalcode/parcellockers/configuration/composer/DurationComposer.java (2)

13-14: Consider adding a comment explaining the regex pattern

The regex pattern is a bit complex. A comment explaining what it does would make future maintenance easier.

.substring(2)
- .replaceAll("(\\d[HMS])(?!$)", "$1 ")
+ // Add spaces after each time unit (H, M, S) except the last one
+ // Example: "1H30M5S" becomes "1H 30M 5S"
+ .replaceAll("(\\d[HMS])(?!$)", "$1 ")
.toLowerCase());

24-25: The comment doesn't match exactly what the code does

The comment says it converts "1h 30m 5s" to "1H30M5S", but the code actually converts any input string with spaces removed and made uppercase.

- // Remove spaces and convert to uppercase (e.g., "1h 30m 5s" -> "1H30M5S")
+ // Normalize by removing spaces and converting to uppercase
+ // Examples: "1h 30m 5s" -> "1H30M5S", "2 hours" -> "2HOURS"
String normalized = input.replace(" ", "").toUpperCase();
src/main/java/com/eternalcode/parcellockers/parcel/ParcelStatus.java (1)

3-7: Add documentation and consider future status values

This enum would benefit from javadoc comments explaining each status. Also, consider if additional states like CANCELLED or RETURNED might be needed in the future.

public enum ParcelStatus {
+    /**
+     * Parcel has been created but not yet delivered
+     */
    PENDING,
+    
+    /**
+     * Parcel has been successfully delivered
+     */
    DELIVERED
+    
+    // Potential future states:
+    // CANCELLED, RETURNED, etc.
}
src/main/java/com/eternalcode/parcellockers/delivery/Delivery.java (1)

1-7: Add documentation to clarify the record's purpose and usage

This new record looks good for tracking parcel deliveries. Consider adding a simple Javadoc comment to explain what the record represents and the format of the timestamp field (e.g., milliseconds since epoch).

+/**
+ * Represents a scheduled parcel delivery with its target timestamp.
+ * The deliveryTimestamp is stored as milliseconds since epoch.
+ */
public record Delivery(UUID parcel, long deliveryTimestamp) {

}
src/main/java/com/eternalcode/parcellockers/parcel/repository/ParcelRepository.java (1)

15-15: Clarify the difference between save and update methods

The new update method looks good but consider adding a comment to explain when to use save vs. update to make the API more clear for other developers.

    CompletableFuture<Void> save(Parcel parcel);

+   /**
+    * Updates an existing parcel in the database.
+    * Use this method when modifying parcel properties rather than creating new ones.
+    */
    CompletableFuture<Void> update(Parcel parcel);
src/main/java/com/eternalcode/parcellockers/gui/implementation/locker/ParcelItemStorageGui.java (1)

128-128: Improved error message with specific item information

Showing the specific illegal item type in the error message is a nice improvement for user feedback.

Consider handling multiple illegal items more clearly if that's a common scenario. The placeholder name "{ITEMS}" suggests multiple items, but the code only shows one item at a time.

src/main/java/com/eternalcode/parcellockers/parcel/task/ParcelSendTask.java (2)

13-18: Drop the unused PluginConfiguration field

config is stored but never referenced, so both the field and its import can be removed to keep the class tidy.

-    private final PluginConfiguration config;
...
-    public ParcelSendTask(Parcel parcel, Delivery delivery, ParcelRepository parcelRepository, DeliveryRepository deliveryRepository, PluginConfiguration config) {
+    public ParcelSendTask(Parcel parcel, Delivery delivery, ParcelRepository parcelRepository, DeliveryRepository deliveryRepository) {
...
-        this.config = config;

41-41: Swap System.out.println for the plugin logger

Using the Bukkit logger keeps output consistent with the rest of the plugin and respects log-level filtering.

-        System.out.println("Delivered: " + updatedParcel);
+        Bukkit.getLogger().info("Delivered: " + updatedParcel); // or inject a Logger
src/main/java/com/eternalcode/parcellockers/gui/implementation/locker/ParcelCollectionGui.java (1)

105-110: Filter at the repository level for cleaner paging

Skipping non-delivered parcels after fetching can leave pages half-empty and forces extra database work. Consider adding status = DELIVERED to the repository query instead.

src/main/java/com/eternalcode/parcellockers/delivery/repository/DeliveryRepository.java (1)

1-20: Well-designed repository interface.

This interface follows good practices with async operations via CompletableFuture.

Consider adding method documentation for clarity, especially for edge cases.

src/main/java/com/eternalcode/parcellockers/parcel/ParcelManager.java (1)

42-43: Remove debug print statement.

The System.out.println should be replaced with proper logging or removed before production.

-        System.out.println("scheduled parcel: " + parcel);
src/main/java/com/eternalcode/parcellockers/delivery/repository/DeliveryRepositoryOrmLite.java (1)

38-43: Simplify return type by avoiding Optional for collections.

Returning Optional<List<Delivery>> is unusual. Typically, collections are returned as empty collections rather than wrapped in Optionals.

@Override
-public CompletableFuture<Optional<List<Delivery>>> findAll() {
-    return this.selectAll(DeliveryWrapper.class).thenApply(parcels -> Optional.of(parcels.stream()
+public CompletableFuture<List<Delivery>> findAll() {
+    return this.selectAll(DeliveryWrapper.class).thenApply(parcels -> parcels.stream()
        .map(DeliveryWrapper::toDelivery)
-        .toList()));
+        .toList());
}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 249f759 and 9a5c0dc.

📒 Files selected for processing (28)
  • build.gradle.kts (4 hunks)
  • src/main/java/com/eternalcode/parcellockers/ParcelLockers.java (5 hunks)
  • src/main/java/com/eternalcode/parcellockers/ParcelLockersCommand.java (1 hunks)
  • src/main/java/com/eternalcode/parcellockers/command/debug/DebugCommand.java (2 hunks)
  • src/main/java/com/eternalcode/parcellockers/configuration/ConfigurationManager.java (2 hunks)
  • src/main/java/com/eternalcode/parcellockers/configuration/composer/DurationComposer.java (1 hunks)
  • src/main/java/com/eternalcode/parcellockers/configuration/implementation/PluginConfiguration.java (11 hunks)
  • src/main/java/com/eternalcode/parcellockers/delivery/Delivery.java (1 hunks)
  • src/main/java/com/eternalcode/parcellockers/delivery/repository/DeliveryRepository.java (1 hunks)
  • src/main/java/com/eternalcode/parcellockers/delivery/repository/DeliveryRepositoryOrmLite.java (1 hunks)
  • src/main/java/com/eternalcode/parcellockers/delivery/repository/DeliveryWrapper.java (1 hunks)
  • src/main/java/com/eternalcode/parcellockers/gui/implementation/locker/LockerMainGui.java (2 hunks)
  • src/main/java/com/eternalcode/parcellockers/gui/implementation/locker/ParcelCollectionGui.java (3 hunks)
  • src/main/java/com/eternalcode/parcellockers/gui/implementation/locker/ParcelItemStorageGui.java (1 hunks)
  • src/main/java/com/eternalcode/parcellockers/gui/implementation/locker/ParcelSendingGui.java (5 hunks)
  • src/main/java/com/eternalcode/parcellockers/gui/implementation/locker/ParcelSendingGuiState.java (4 hunks)
  • src/main/java/com/eternalcode/parcellockers/gui/implementation/remote/MainGui.java (0 hunks)
  • src/main/java/com/eternalcode/parcellockers/gui/implementation/remote/SentParcelsGui.java (2 hunks)
  • src/main/java/com/eternalcode/parcellockers/parcel/Parcel.java (1 hunks)
  • src/main/java/com/eternalcode/parcellockers/parcel/ParcelManager.java (3 hunks)
  • src/main/java/com/eternalcode/parcellockers/parcel/ParcelStatus.java (1 hunks)
  • src/main/java/com/eternalcode/parcellockers/parcel/command/ParcelCommand.java (2 hunks)
  • src/main/java/com/eternalcode/parcellockers/parcel/repository/ParcelRepository.java (1 hunks)
  • src/main/java/com/eternalcode/parcellockers/parcel/repository/ParcelRepositoryOrmLite.java (1 hunks)
  • src/main/java/com/eternalcode/parcellockers/parcel/repository/ParcelWrapper.java (3 hunks)
  • src/main/java/com/eternalcode/parcellockers/parcel/task/ParcelSendTask.java (1 hunks)
  • src/main/java/com/eternalcode/parcellockers/parcel/util/ParcelPlaceholderUtil.java (2 hunks)
  • src/test/java/com/eternalcode/parcellockers/database/ParcelDatabaseServiceIntegrationTest.java (2 hunks)
💤 Files with no reviewable changes (1)
  • src/main/java/com/eternalcode/parcellockers/gui/implementation/remote/MainGui.java
🧰 Additional context used
🧬 Code Graph Analysis (5)
src/main/java/com/eternalcode/parcellockers/configuration/ConfigurationManager.java (2)
src/main/java/com/eternalcode/parcellockers/configuration/composer/DurationComposer.java (1)
  • DurationComposer (7-35)
src/main/java/com/eternalcode/parcellockers/configuration/composer/PositionComposer.java (1)
  • PositionComposer (6-18)
src/main/java/com/eternalcode/parcellockers/gui/implementation/locker/LockerMainGui.java (1)
src/main/java/com/eternalcode/parcellockers/user/UserManager.java (1)
  • UserManager (13-76)
src/main/java/com/eternalcode/parcellockers/gui/implementation/remote/SentParcelsGui.java (1)
src/main/java/com/eternalcode/parcellockers/parcel/util/ParcelPlaceholderUtil.java (1)
  • ParcelPlaceholderUtil (18-68)
src/main/java/com/eternalcode/parcellockers/parcel/task/ParcelSendTask.java (1)
src/main/java/com/eternalcode/parcellockers/configuration/implementation/PluginConfiguration.java (1)
  • PluginConfiguration (16-392)
src/main/java/com/eternalcode/parcellockers/parcel/ParcelManager.java (3)
src/main/java/com/eternalcode/parcellockers/notification/NotificationAnnouncer.java (1)
  • NotificationAnnouncer (14-64)
src/main/java/com/eternalcode/parcellockers/parcel/task/ParcelSendTask.java (1)
  • ParcelSendTask (11-47)
src/main/java/com/eternalcode/parcellockers/shared/SentryExceptionHandler.java (1)
  • SentryExceptionHandler (7-26)
🔇 Additional comments (43)
src/test/java/com/eternalcode/parcellockers/database/ParcelDatabaseServiceIntegrationTest.java (1)

8-8: LGTM! Correctly updated test for new ParcelStatus field

The test has been properly updated to include the new ParcelStatus field in the Parcel constructor.

Also applies to: 51-51

src/main/java/com/eternalcode/parcellockers/parcel/command/ParcelCommand.java (1)

13-13: Good addition of async processing

Making the info command async is a smart improvement that can help prevent blocking the main thread.

Make sure that ParcelPlaceholderUtil and announcer.sendMessage are thread-safe for use in async contexts.

Also applies to: 49-49

src/main/java/com/eternalcode/parcellockers/parcel/Parcel.java (1)

13-14: Good addition of status tracking

Adding the status field to track parcel delivery state improves the system's clarity. This change properly integrates with the new delivery management system.

src/main/java/com/eternalcode/parcellockers/parcel/util/ParcelPlaceholderUtil.java (1)

38-40: Good timeout management to prevent blocking

Adding a 3-second timeout to the locker lookup prevents the application from freezing if the repository operation takes too long. This helps keep the UI responsive.

src/main/java/com/eternalcode/parcellockers/configuration/ConfigurationManager.java (3)

3-3: LGTM: Duration composer import added

This import supports the new duration-based configuration features.


10-10: LGTM: Duration import added

Needed for the new duration fields in the configuration.


19-20: LGTM: Duration composer registration

Good job registering the new composer for Duration values in the configuration system.

src/main/java/com/eternalcode/parcellockers/gui/implementation/locker/LockerMainGui.java (3)

75-82: Updated GUI rendering logic

Changed the order to fill background first, then corners. This helps ensure corners don't get overwritten by the background fill.


89-92: Updated dependencies for ParcelCollectionGui

Good job adding UserManager and LockerRepository to support the new placeholder functionality.


94-107: Updated GUI layout and removed status item

The collect and send buttons were moved from slots 20 and 22 to slots 21 and 23, and the status item was removed. This aligns with the new delivery status system.

src/main/java/com/eternalcode/parcellockers/gui/implementation/locker/ParcelSendingGuiState.java (4)

4-4: Added ParcelStatus import

Import needed for the new status tracking functionality.


17-17: Added status field

New status field to track parcel delivery state.


27-27: Initialized status in constructor

Good default value of PENDING for new parcels.


86-92: Added getter and setter for status

Standard accessor methods for the new status field.

src/main/java/com/eternalcode/parcellockers/gui/implementation/locker/ParcelCollectionGui.java (1)

113-114: Nice reuse of ParcelPlaceholderUtil

Centralising placeholder logic makes future tweaks much easier. Looks good!

src/main/java/com/eternalcode/parcellockers/gui/implementation/locker/ParcelSendingGui.java (1)

215-218: Guard against null status

state.getStatus() can still be null for first-time sends. Defaulting to PENDING (or similar) prevents accidental NPEs when the parcel is persisted.

src/main/java/com/eternalcode/parcellockers/parcel/repository/ParcelRepositoryOrmLite.java (2)

39-45: Updated save method looks good!

Nice improvement using saveIfNotExist instead of save and simplifying the cache update logic.


47-54: The new update method is well implemented.

The method correctly saves the parcel to the database, then properly updates the cache by removing the old entry and adding the updated one.

src/main/java/com/eternalcode/parcellockers/parcel/repository/ParcelWrapper.java (4)

5-5: Good import addition.

Properly imported the ParcelStatus enum.


41-42: Correctly added new database field.

The status field is properly annotated with @DatabaseField.


47-58: Constructor properly updated.

The constructor now includes and correctly assigns the status parameter.


60-66: Factory and conversion methods handle status correctly.

Both the static factory method and the toParcel() method now include the status field properly.

src/main/java/com/eternalcode/parcellockers/ParcelLockers.java (1)

143-146: Good integration of the new delivery repository.

Correctly instantiated DeliveryRepositoryOrmLite and updated ParcelManager constructor.

build.gradle.kts (4)

38-38: Library version update looks good.

The CDN library has been updated from 1.14.6 to 1.14.8, which seems to be a minor update with compatibility maintained.


51-51: HikariCP version update looks good.

Upgrading HikariCP from 6.2.1 to 6.3.0 is a reasonable minor version update.


115-120: Clean task simplification looks good.

The clean task now only removes run/plugins and run/logs directories, which simplifies build maintenance.


127-127: Simplified jar naming looks better.

Removing the Minecraft version range from the filename makes the output cleaner and easier to work with.

src/main/java/com/eternalcode/parcellockers/delivery/repository/DeliveryWrapper.java (1)

9-33: DeliveryWrapper implementation looks good.

The class is well-structured for ORM usage with:

  • Proper annotations for database mapping
  • No-args constructor required by ORM frameworks
  • Clean conversion methods between domain and database objects
src/main/java/com/eternalcode/parcellockers/gui/implementation/remote/SentParcelsGui.java (2)

9-9: Added import for new utility class.

The import for ParcelPlaceholderUtil supports the refactoring of placeholder handling.


77-81: Good refactoring to use centralized placeholder utility.

Replacing custom placeholder logic with a reusable utility method improves code maintainability and consistency.

src/main/java/com/eternalcode/parcellockers/parcel/ParcelManager.java (4)

6-20: New imports support delivery system integration.

Added imports for the delivery system components and content handling.


29-40: Constructor updated correctly for delivery integration.

Added DeliveryRepository as a dependency to support the new delivery functionality.


44-60: Delivery scheduling implementation looks good.

The code now:

  1. Calculates delivery delay based on priority
  2. Saves parcel content asynchronously
  3. Schedules delivery with appropriate timing

89-91: Good switch from lambda to traditional loop.

Using a standard for loop instead of forEach with lambda makes the code easier to read.

src/main/java/com/eternalcode/parcellockers/command/debug/DebugCommand.java (3)

41-47: Command flexibility improved.

The method now accepts any CommandSender rather than just Player, making it more versatile. Note that message colors have changed from green to red for success messages.


44-44: Consistent error message formatting.

The error message color has been changed from &c to &4 for all failure messages, making them more distinguishable from success messages.

Also applies to: 52-52, 60-60, 68-68


73-79: Updated deleteAll method to match parameter changes.

The deleteAll method has been correctly updated to use CommandSender and pass it to the individual methods.

src/main/java/com/eternalcode/parcellockers/configuration/implementation/PluginConfiguration.java (6)

70-74: Replaced cost values with duration-based delivery scheduling.

The configuration now uses time durations instead of monetary costs, supporting the new delivery scheduling system.


96-96: Enhanced error message for illegal items.

The message now includes the actual illegal items using the {ITEMS} placeholder, providing better feedback to users.


110-119: Improved parcel info message formatting.

The parcel info messages have been reformatted with bullet points and different color codes, making them easier to read.


182-193: Updated priority item styling.

The priority item now has a rocket emoji and updated descriptions, improving visual clarity.


214-218: Enhanced submit button with gradient text.

The submit button now uses gradient colors and clearer warnings about the finality of the action.


369-371: Extended illegal items list for security.

Added BEDROCK, VAULT, and END_PORTAL_FRAME to illegal items, preventing potential exploits.

Jakubk15 and others added 5 commits April 26, 2025 20:42
Migrate to new PaperMC repo endpoint
…oser/DurationComposer.java

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
coderabbitai[bot]
coderabbitai bot previously approved these changes Jun 7, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

♻️ Duplicate comments (1)
src/main/java/com/eternalcode/parcellockers/configuration/composer/DurationComposer.java (1)

12-14: Remove negative number support from regex pattern

The regex pattern allows negative durations, but your business requirements specify only positive durations should be accepted.

🧹 Nitpick comments (2)
src/main/java/com/eternalcode/parcellockers/configuration/composer/DurationComposer.java (2)

21-24: Add validation for Duration.toString() format

The code assumes duration.toString() always starts with "PT", but very large durations might have different formats. Consider adding validation.

-return Result.ok(duration.toString()
-    .substring(2)  // Remove the PT prefix
-    .replaceAll("(\\d[HMS])(?!$)", "$1 ")  // Add spaces between components
-    .toLowerCase());
+String durationStr = duration.toString();
+if (!durationStr.startsWith("PT")) {
+    return Result.error(new IllegalArgumentException("Unsupported duration format"));
+}
+return Result.ok(durationStr
+    .substring(2)  // Remove the PT prefix
+    .replaceAll("(\\d[HMS])(?!$)", "$1 ")  // Add spaces between components
+    .toLowerCase());

66-69: Simplify decimal seconds parsing

The manual nanoseconds calculation could introduce precision errors. Consider using Duration.ofNanos() for simpler and more accurate parsing.

-if (value.contains(".")) {
-    double seconds = Double.parseDouble(value);
-    long wholeSeconds = (long) seconds;
-    long nanos = (long) ((seconds - wholeSeconds) * 1_000_000_000);
-    duration = duration.plusSeconds(wholeSeconds).plusNanos(nanos);
-} else {
-    duration = duration.plusSeconds(Long.parseLong(value));
-}
+if (value.contains(".")) {
+    double seconds = Double.parseDouble(value);
+    duration = duration.plus(Duration.ofNanos((long) (seconds * 1_000_000_000)));
+} else {
+    duration = duration.plusSeconds(Long.parseLong(value));
+}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5466356 and 65f6ed4.

📒 Files selected for processing (3)
  • src/main/java/com/eternalcode/parcellockers/configuration/composer/DurationComposer.java (1 hunks)
  • src/main/java/com/eternalcode/parcellockers/gui/implementation/locker/ParcelSendingGui.java (5 hunks)
  • src/main/java/com/eternalcode/parcellockers/parcel/ParcelManager.java (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/main/java/com/eternalcode/parcellockers/gui/implementation/locker/ParcelSendingGui.java
  • src/main/java/com/eternalcode/parcellockers/parcel/ParcelManager.java
🧰 Additional context used
🧠 Learnings (1)
src/main/java/com/eternalcode/parcellockers/configuration/composer/DurationComposer.java (1)
Learnt from: Jakubk15
PR: EternalCodeTeam/ParcelLockers#121
File: src/main/java/com/eternalcode/parcellockers/configuration/composer/DurationComposer.java:31-31
Timestamp: 2025-06-07T16:46:29.651Z
Learning: The DurationComposer in the ParcelLockers project should only accept positive durations, not negative ones. This is a business requirement specific to this parcel locker system.
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build

Jakubk15 added 2 commits June 22, 2025 21:31
…hanced-delivery-logic

# Conflicts:
#	src/main/java/com/eternalcode/parcellockers/configuration/composer/DurationComposer.java
Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

🧹 Nitpick comments (1)
src/main/java/com/eternalcode/parcellockers/configuration/composer/DurationComposer.java (1)

91-93: Preserve original exception details for better debugging

The catch block currently loses the original exception information, making it harder to debug parsing issues.

 } catch (Exception e) {
-    return Result.error(new IllegalArgumentException("Invalid duration format. Expected format like '1d 2h 3m 4s' or ISO-8601 duration."));
+    return Result.error(new IllegalArgumentException("Invalid duration format. Expected format like '1d 2h 3m 4s' or ISO-8601 duration.", e));
 }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c092a5c and a134365.

📒 Files selected for processing (2)
  • src/main/java/com/eternalcode/parcellockers/configuration/composer/DurationComposer.java (1 hunks)
  • src/test/java/com/eternalcode/parcellockers/configuration/composer/DurationComposerTest.java (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/test/java/com/eternalcode/parcellockers/configuration/composer/DurationComposerTest.java
🧰 Additional context used
🧠 Learnings (1)
src/main/java/com/eternalcode/parcellockers/configuration/composer/DurationComposer.java (1)
Learnt from: Jakubk15
PR: EternalCodeTeam/ParcelLockers#121
File: src/main/java/com/eternalcode/parcellockers/configuration/composer/DurationComposer.java:31-31
Timestamp: 2025-06-07T16:46:29.679Z
Learning: The DurationComposer in the ParcelLockers project should only accept positive durations, not negative ones. This is a business requirement specific to this parcel locker system.
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build
🔇 Additional comments (1)
src/main/java/com/eternalcode/parcellockers/configuration/composer/DurationComposer.java (1)

9-95: Great implementation with robust format support!

This composer handles multiple duration formats nicely and follows good practices with proper null checking and clear error messages. The regex pattern is well-designed and the serialization logic is clean.

Jakubk15 and others added 12 commits July 2, 2025 11:04
…gCommand.java

Co-authored-by: DMK <81445555+imDMK@users.noreply.github.com>
…SendTask.java

Co-authored-by: DMK <81445555+imDMK@users.noreply.github.com>
…SendTask.java

Co-authored-by: DMK <81445555+imDMK@users.noreply.github.com>
…gCommand.java

Co-authored-by: DMK <81445555+imDMK@users.noreply.github.com>
…gCommand.java

Co-authored-by: DMK <81445555+imDMK@users.noreply.github.com>
…gCommand.java

Co-authored-by: DMK <81445555+imDMK@users.noreply.github.com>
…gCommand.java

Co-authored-by: DMK <81445555+imDMK@users.noreply.github.com>
…/locker/ParcelSendingGuiState.java

Co-authored-by: DMK <81445555+imDMK@users.noreply.github.com>
imDMK
imDMK previously approved these changes Jul 4, 2025
@imDMK
Copy link
Contributor

imDMK commented Jul 4, 2025

Fix buliding

coderabbitai[bot]
coderabbitai bot previously approved these changes Jul 5, 2025
@Jakubk15 Jakubk15 dismissed stale reviews from coderabbitai[bot] and imDMK via 5f2d275 July 5, 2025 18:53
@Jakubk15 Jakubk15 merged commit 375dc08 into master Jul 5, 2025
2 checks passed
@Jakubk15 Jakubk15 deleted the enhanced-delivery-logic branch July 5, 2025 19:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🆕 feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants