Skip to content

Conversation

vLuckyyy
Copy link
Member

Fixes: GH-959

@vLuckyyy vLuckyyy requested a review from a team as a code owner September 19, 2025 21:21
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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.

}

public Map<String, WarpInventoryItem> getItems() {
return new HashMap<>(this.items);
Copy link
Member

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) {
Copy link
Member

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 {
Copy link
Member

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

Copy link
Member

@CitralFlo CitralFlo left a 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()) {
Copy link
Member

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) {
Copy link
Member

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

Copy link
Member

Choose a reason for hiding this comment

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

yes, inline

Copy link
Member

@Jakubk15 Jakubk15 left a 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) {
Copy link
Member

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) {
Copy link
Member

Choose a reason for hiding this comment

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

yes, inline

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Move the warp GUI 100% to warps.yml (without messages)
6 participants