-
-
Notifications
You must be signed in to change notification settings - Fork 20
GH-959 Move warp contents from language files. #1172
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?
Conversation
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 successfully refactors the warp inventory configuration from language files into a dedicated warp-inventory.yml
, which is a significant improvement for maintainability. The adoption of a repository pattern with asynchronous, transactional operations is a solid architectural choice. However, I've identified a few critical issues, including a race condition and a bug where changes are not persisted, which could lead to data inconsistency. My review provides detailed feedback and suggestions to address these problems by better utilizing the new repository pattern.
eternalcore-core/src/main/java/com/eternalcode/core/feature/warp/inventory/WarpInventory.java
Outdated
Show resolved
Hide resolved
...re/src/main/java/com/eternalcode/core/feature/warp/inventory/WarpInventoryConfigService.java
Show resolved
Hide resolved
...ode/core/configuration/migrations/Migration_0010_Move_WarpInventory_to_dedicated_config.java
Outdated
Show resolved
Hide resolved
...core-core/src/main/java/com/eternalcode/core/feature/warp/inventory/WarpInventoryConfig.java
Outdated
Show resolved
Hide resolved
...e/src/main/java/com/eternalcode/core/feature/warp/inventory/WarpInventoryRepositoryImpl.java
Outdated
Show resolved
Hide resolved
} | ||
|
||
public Map<String, WarpInventoryItem> getItems() { | ||
return new HashMap<>(this.items); |
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.
Czemu kopia mapy?
} | ||
|
||
public void setItems(Map<String, WarpInventoryItem> items) { | ||
if (items == null) { |
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.
Ja bym nie zakładał że coś wchodzi jako null
import java.util.logging.Logger; | ||
|
||
@Repository | ||
class WarpInventoryRepositoryImpl implements WarpInventoryRepository { |
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.
Hm tutaj już trochę nadinżynieria
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.
I agree with Rollczi that the repository class it's complicated and could cause problems when maintaining the code in the future
} | ||
|
||
public CompletableFuture<Void> removeWarp(String warpName) { | ||
if (!this.warpSettings.autoAddNewWarps()) { |
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.
here maybe add check if the warp is in the inventory instead of checking the settings
}); | ||
} | ||
|
||
private void performSlotShift(List<WarpInventoryItem> itemsToShift, int removedSlot) { |
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.
Maybe this nested method can be simplified and used inside of #shiftWarpItems() method instead of extracting it
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.
yes, inline
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.
Please test the changes and ensure the behavior of the inventories is proper
this.warpInventoryConfigService = warpInventoryConfigService; | ||
} | ||
|
||
public void openInventory(Player player) { |
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.
WarpInventory#openInventory
is redundant. Cut it to open()
}); | ||
} | ||
|
||
private void performSlotShift(List<WarpInventoryItem> itemsToShift, int removedSlot) { |
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.
yes, inline
Fixes: GH-959