-
-
Notifications
You must be signed in to change notification settings - Fork 0
Add parcel fees #144
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
base: master
Are you sure you want to change the base?
Add parcel fees #144
Conversation
Summary of ChangesHello @Jakubk15, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a comprehensive fee system for sending parcels within the plugin, leveraging the Vault economy API. It allows server administrators to configure different costs for various parcel sizes, enhancing the in-game economy and resource management. The changes include core plugin modifications for economy integration, new configuration options for fees, and user-facing messages for transaction feedback. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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.
Code Review
This pull request introduces a fee system for sending parcels, integrating with Vault for economy management. The changes include updating the build configuration to add Vault dependencies, modifying the main plugin class to handle Vault setup, and implementing the fee logic within the ParcelServiceImpl.
My review has identified a critical issue where a constructor change was not propagated to its call site, which will cause a compilation failure. I've also pointed out a couple of medium-severity issues related to dependency declaration in Gradle and locale-sensitive string formatting that could lead to bugs in different server environments. Overall, the core logic for the fee system is well-implemented, but the identified issues should be addressed to ensure the plugin is functional and robust.
| if (!this.setupEconomy()) { | ||
| this.getLogger().severe("No economy provider registered! Disabling..."); | ||
| server.getPluginManager().disablePlugin(this); | ||
| return; | ||
| } |
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 instantiation of ParcelServiceImpl in ParcelLockers.java was not updated to match the new constructor signature. This will cause a compilation error. You need to pass the config and economy instances when creating ParcelService.
I am commenting here as this is the closest related change, but the actual fix is in ParcelLockers.java at line 123.
| NoticeService noticeService, | ||
| ParcelRepository parcelRepository, | ||
| ParcelContentRepository parcelContentRepository, | ||
| Scheduler scheduler | ||
| Scheduler scheduler, PluginConfig config, Economy economy | ||
| ) { |
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 constructor signature has been updated. This is a breaking change, and the call site in ParcelLockers.java where ParcelServiceImpl is instantiated has not been updated to reflect this. This will cause a compilation error. Please update the instantiation to pass the new config and economy arguments.
Example fix in ParcelLockers.java:
// ...
ParcelService parcelService = new ParcelServiceImpl(
noticeService,
parcelRepository,
parcelContentRepository,
scheduler,
config, // add this
this.economy // add this
);
// ...| repositories { | ||
| gradlePluginPortal() | ||
| maven { url = uri("https://maven-central.storage-download.googleapis.com/maven2/")} | ||
| maven("https://maven-central.storage-download.googleapis.com/maven2/") // maven central mirror |
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.
| this.noticeService.create() | ||
| .notice(messages -> messages.parcel.insufficientFunds) | ||
| .player(sender.getUniqueId()) | ||
| .placeholder("{AMOUNT}", String.format("%.2f", fee)) |
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.
Using String.format without a Locale can lead to incorrect formatting on systems with different locale settings (e.g., using a comma as a decimal separator instead of a period). This can cause issues with how the fee is displayed. It's safer to specify a fixed locale, like java.util.Locale.US, to ensure consistent formatting.
| .placeholder("{AMOUNT}", String.format("%.2f", fee)) | |
| .placeholder("{AMOUNT}", String.format(java.util.Locale.US, "%.2f", fee)) |
| this.noticeService.create() | ||
| .notice(messages -> messages.parcel.feeWithdrawn) | ||
| .player(sender.getUniqueId()) | ||
| .placeholder("{AMOUNT}", String.format("%.2f", fee)) |
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.
Using String.format without a Locale can lead to incorrect formatting on systems with different locale settings (e.g., using a comma as a decimal separator instead of a period). This can cause issues with how the fee is displayed. It's safer to specify a fixed locale, like java.util.Locale.US, to ensure consistent formatting.
| .placeholder("{AMOUNT}", String.format("%.2f", fee)) | |
| .placeholder("{AMOUNT}", String.format(java.util.Locale.US, "%.2f", fee)) |
No description provided.