Skip to content

fix: incorrect duplicated pack handling#4

Merged
mergify[bot] merged 8 commits into
devfrom
fix-duplicate-resourcepack
Dec 20, 2025
Merged

fix: incorrect duplicated pack handling#4
mergify[bot] merged 8 commits into
devfrom
fix-duplicate-resourcepack

Conversation

@jimchen5209

@jimchen5209 jimchen5209 commented Dec 20, 2025

Copy link
Copy Markdown
Owner
  • Fix incorrect duplicated pack handling
  • Fix critical thread-safety issue on loading config
  • Fix error handling for loading config
  • Fix applied resource pack diff handling
  • Improve efficiency for resource pack loading
  • Remove redundant logging and improve resource pack handling

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @jimchen5209, 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 focuses on enhancing the robustness and efficiency of the server's resource pack management system. The primary goal is to resolve issues related to incorrect handling of duplicated resource packs, ensuring that players consistently receive a unique and correct set of packs. Additionally, the changes include a cleanup of logging messages to provide clearer feedback and a general refactoring of the resource pack application logic for improved maintainability.

Highlights

  • Duplicate Resource Pack Handling: Implemented a new mechanism to prevent duplicate resource packs from being sent to players by filtering them based on their unique hash values. This ensures that only distinct resource packs are processed and applied.
  • Logging Refinement: Removed redundant logging messages from server startup and command execution, and introduced more informative logging during the resource pack processing phase within the configuration module.
  • Resource Pack Management Refactoring: Streamlined the internal logic for updating and applying resource packs to players by directly utilizing a de-duplicated list of ResourcePack objects, simplifying method signatures and reducing intermediate steps.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@jimchen5209 jimchen5209 added the type:bug Something isn't working label Dec 20, 2025

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

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 correctly fixes an issue with duplicated resource pack handling by introducing a de-duplication step based on pack hashes. The changes also improve the codebase by removing redundant logging and refactoring the resource pack handling logic to be cleaner. The implementation is solid. I have one suggestion to improve the readability of the logic for determining which resource packs need updating, making it more idiomatic and maintainable.

@jimchen5209

Copy link
Copy Markdown
Owner Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

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 correctly fixes an issue with duplicated resource packs by filtering them based on their hash. The changes also improve the code structure by centralizing resource pack loading and removing redundant logging. However, I've identified a critical thread-safety issue in the new implementation within ModConfig.kt that could lead to race conditions and application instability. My review includes a detailed explanation and a suggested refactoring to address this.

Comment thread src/main/kotlin/me/jimchen5209/serverResourcePackManager/util/ModConfig.kt Outdated
@jimchen5209

Copy link
Copy Markdown
Owner Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

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 effectively resolves the issue of handling duplicated resource packs by implementing de-duplication based on pack hashes. The refactoring to use a thread-safe ConfigState class and improving error handling for individual pack loading significantly enhances the robustness and maintainability of the code. The removal of redundant logging is also a welcome cleanup. I have a couple of suggestions to further improve error handling and code clarity.

@jimchen5209

Copy link
Copy Markdown
Owner Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

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 correctly addresses the issue of duplicated resource packs by using distinctBy on the pack hash. The refactoring to remove redundant logging and centralize resource pack processing in ModConfig using a thread-safe ConfigState is a good improvement. However, I've found a couple of high-severity issues in the new implementation. There's a bug in ModConfig where creating a new config file saves the old state, and the resend functionality in ResourcePackManager is broken. I've also left a medium-severity comment about improving the user experience when a config file is corrupted. Please review the detailed comments.

Comment thread src/main/kotlin/me/jimchen5209/serverResourcePackManager/util/ModConfig.kt Outdated
Comment thread src/main/kotlin/me/jimchen5209/serverResourcePackManager/util/ModConfig.kt Outdated
@jimchen5209 jimchen5209 force-pushed the fix-duplicate-resourcepack branch from f882132 to 662630b Compare December 20, 2025 13:41
@jimchen5209

Copy link
Copy Markdown
Owner Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

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 several important fixes and improvements for resource pack handling. The introduction of a thread-safe ConfigState to manage configuration loading is a great enhancement for stability. The logic for handling duplicated packs and applying diffs to players has also been significantly improved and made more robust. However, I've identified a critical issue in the new error handling logic for configuration loading. When the config file is corrupt, the system falls back to a default configuration but fails to save this valid default back to disk, which could lead to persistent issues across server restarts. My review includes a detailed comment with a suggested fix for this problem.

Comment thread src/main/kotlin/me/jimchen5209/serverResourcePackManager/util/ModConfig.kt Outdated
@jimchen5209 jimchen5209 force-pushed the fix-duplicate-resourcepack branch from 662630b to b86cab2 Compare December 20, 2025 13:50
@jimchen5209

Copy link
Copy Markdown
Owner Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

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 several significant improvements and bug fixes. The change to ModConfig to use a volatile ConfigState is an excellent fix for a critical thread-safety issue, ensuring atomic updates to the configuration. The error handling during config loading is now more robust and user-friendly. Additionally, the logic for handling duplicate resource packs has been correctly implemented using distinctBy, and a bug in the resource pack diffing logic within updatePlayerResourcePacks has been resolved. The code is also cleaner due to the removal of redundant logging. I have one suggestion to further optimize the resource pack processing.

Comment thread src/main/kotlin/me/jimchen5209/serverResourcePackManager/util/ModConfig.kt Outdated
@jimchen5209

Copy link
Copy Markdown
Owner Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

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 series of excellent fixes and refactorings. The correction of the duplicated pack handling, the critical thread-safety improvements for configuration loading using a volatile state object, and the refined error handling are all significant enhancements to the codebase's robustness and correctness. The logic for handling resource pack diffs has also been made more reliable. I have one suggestion to further improve performance by parallelizing resource pack processing, which could be beneficial if many packs are configured.

Comment thread src/main/kotlin/me/jimchen5209/serverResourcePackManager/util/ModConfig.kt Outdated
@jimchen5209 jimchen5209 force-pushed the fix-duplicate-resourcepack branch from ebab616 to 4ae143d Compare December 20, 2025 14:10
@jimchen5209

Copy link
Copy Markdown
Owner Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

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 updates the mod version to 1.0.1 and significantly refactors the resource pack loading and management. The ModConfig class now uses a ConfigState data class and a @Volatile property for thread-safe, immutable configuration, and loadConfig was refactored to handle JsonParseException and IOException more robustly, falling back to default configurations. Resource pack processing was made asynchronous using Kotlin coroutines (async, awaitAll) to improve performance and error handling for individual packs. A new getMappedResourcePacks() function was introduced to retrieve processed packs. Correspondingly, the ResourcePackManager was updated to use this new getMappedResourcePacks() method and its updatePlayerResourcePacks function was refactored to accept a direct list of ResourcePack objects, improving its logic for adding and removing packs. Minor formatting changes were also applied across several files, and redundant logging of loaded resource packs was removed from ServerResourcePackManager and ResourcePackManagerCommand. Review comments suggest refactoring the loadedConfig initialization in ModConfig.kt to use an immutable val with an if-else expression for better idiomatic Kotlin and safety, and optimizing appliedPacks[player] = newPacks.toList() in ResourcePackManager.kt by directly assigning newPacks to avoid an unnecessary list copy.

Comment thread src/main/kotlin/me/jimchen5209/serverResourcePackManager/util/ModConfig.kt Outdated
@jimchen5209 jimchen5209 force-pushed the fix-duplicate-resourcepack branch from 09f3e30 to c83f85a Compare December 20, 2025 14:28
@jimchen5209

Copy link
Copy Markdown
Owner Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

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 several significant improvements to the resource pack handling logic. The move to a thread-safe, atomic state object for configuration using @Volatile and a ConfigState class is a great step towards resolving concurrency issues. The parallel loading of resource packs using coroutines should provide a noticeable performance boost, and the enhanced error handling for config parsing makes the system more robust. The fixes for duplicated pack handling and the diff logic for applying packs to players are also solid improvements.

I've added a couple of review comments:

  • A high-severity suggestion to make ResourcePackConfig immutable to fully realize the thread-safety benefits of the new state management model.
  • A medium-severity suggestion for a minor code cleanup in the pack diffing logic.

Overall, this is a high-quality contribution that significantly improves the stability and performance of the mod. Well done!

…ing config

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@jimchen5209 jimchen5209 force-pushed the fix-duplicate-resourcepack branch from c83f85a to 3c4f662 Compare December 20, 2025 14:41
@jimchen5209

Copy link
Copy Markdown
Owner Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

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 several significant improvements and bug fixes. The implementation correctly addresses a critical thread-safety issue in configuration loading by using a volatile state object for atomic updates. It also properly fixes the handling of duplicated resource packs by de-duplicating them by both URL and content hash. Efficiency is enhanced by loading resource packs concurrently using coroutines, and error handling for configuration loading is now more robust. Furthermore, a bug in the resource pack diffing logic has been resolved. Overall, these changes make the code cleaner, more efficient, and more reliable. I have one minor suggestion to further improve performance.

jimchen5209 and others added 2 commits December 20, 2025 22:46
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@jimchen5209 jimchen5209 force-pushed the fix-duplicate-resourcepack branch from 3c4f662 to 1fed980 Compare December 20, 2025 14:46
@jimchen5209

Copy link
Copy Markdown
Owner Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

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 series of excellent improvements and bug fixes. The changes address a critical thread-safety issue in configuration loading by using a volatile state object, improve performance by loading resource packs concurrently, and fix incorrect handling of duplicate resource packs. The code is also made more robust and maintainable by using immutable data structures and fixing a bug in the resource pack diffing logic. Overall, this is a high-quality contribution. I have one suggestion to improve the automatic recovery from a corrupted configuration file.

@jimchen5209 jimchen5209 force-pushed the fix-duplicate-resourcepack branch 2 times, most recently from c9a1aec to c9c141d Compare December 20, 2025 15:06
@jimchen5209 jimchen5209 force-pushed the fix-duplicate-resourcepack branch from c9c141d to f15e7d6 Compare December 20, 2025 15:12
@jimchen5209 jimchen5209 added the status:ready-to-merge PR is ready to merge label Dec 20, 2025
@mergify mergify Bot added the queued label Dec 20, 2025
mergify Bot added a commit that referenced this pull request Dec 20, 2025
@mergify

mergify Bot commented Dec 20, 2025

Copy link
Copy Markdown
Contributor

Merge Queue Status

✅ The pull request has been merged at f15e7d6

This pull request spent 2 minutes 35 seconds in the queue, including 1 minute 29 seconds running CI.
The checks were run on draft #8.

Required conditions to merge
  • any of [🛡 GitHub repository ruleset rule]:
    • check-success = build (21, ubuntu-latest)
    • check-neutral = build (21, ubuntu-latest)
    • check-skipped = build (21, ubuntu-latest)
  • any of [🛡 GitHub repository ruleset rule]:
    • check-success = build (21, windows-latest)
    • check-neutral = build (21, windows-latest)
    • check-skipped = build (21, windows-latest)
  • any of [🛡 GitHub repository ruleset rule]:
    • check-success = Socket Security: Project Report
    • check-neutral = Socket Security: Project Report
    • check-skipped = Socket Security: Project Report
  • any of [🛡 GitHub repository ruleset rule]:
    • check-success = Socket Security: Pull Request Alerts
    • check-neutral = Socket Security: Pull Request Alerts
    • check-skipped = Socket Security: Pull Request Alerts
  • any of [🛡 GitHub repository ruleset rule]:
    • check-neutral = Mergify Merge Protections
    • check-skipped = Mergify Merge Protections
    • check-success = Mergify Merge Protections

@mergify mergify Bot merged commit 0d9e221 into dev Dec 20, 2025
10 checks passed
@mergify mergify Bot removed the queued label Dec 20, 2025
@jimchen5209 jimchen5209 deleted the fix-duplicate-resourcepack branch December 20, 2025 15:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status:ready-to-merge PR is ready to merge type:bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant