Skip to content

Conversation

@thanthal1
Copy link
Contributor

@thanthal1 thanthal1 commented Oct 25, 2025

QSFindItemAddOn throws a NullPointerException if BentoBox is not installed, causing /finditem to get stuck at "Searching..." forever.

Solution

Added a null check before calling isIslandLocked() on BentoBoxPlugin. This prevents the async search task from crashing and allows the GUI to display search results normally.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed potential crash when the BentoBox plugin is not installed, improving stability and reliability when searching for shops.

@coderabbitai
Copy link

coderabbitai bot commented Oct 25, 2025

Walkthrough

A null-check guard is added in QSHikariAPIHandler.processPotentialShopMatchAndAddToFoundList to verify the BentoBox plugin reference before invoking isIslandLocked, preventing potential NullPointerException when the plugin is unavailable.

Changes

Cohort / File(s) Summary
Null-check Guard Addition
src/main/java/io/myzticbean/finditemaddon/quickshop/impl/QSHikariAPIHandler.java
Added null-check for BentoBox plugin reference before invoking isIslandLocked in processPotentialShopMatchAndAddToFoundList to guard against NPE when plugin is not present

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

  • Single defensive guard clause addition with no functional logic changes
  • Straightforward null-check pattern that retains existing behavior when plugin is available

Poem

A rabbit hops through code so fine,
With null-checks drawn in careful line,
No NPE shall pass this gate,
Safe and sound—our apps await! 🐰✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The pull request title "Fix: added null check for BentoBox to stop infinite searching" accurately reflects the main change in the changeset. The title correctly identifies the primary fix (null check for BentoBox plugin) and conveys both the technical implementation and the user-facing impact (preventing infinite searching). The title is concise, specific, and uses clear language without vague terms or noise, allowing a teammate to quickly understand that this addresses a NullPointerException issue when BentoBox is not installed.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@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: 0

🧹 Nitpick comments (1)
src/main/java/io/myzticbean/finditemaddon/quickshop/impl/QSHikariAPIHandler.java (1)

461-466: Fix correctly prevents NPE, but consider caching the plugin reference.

The null check successfully resolves the NPE when BentoBox is not installed, preventing the infinite "Searching..." issue. The short-circuit evaluation order is correct.

However, FindItemAddOn.getBentoboxPlugin() is called twice (lines 462 and 463). Cache the reference in a local variable to avoid redundant lookups:

+        var bentoboxPlugin = FindItemAddOn.getBentoboxPlugin();
         if (FindItemAddOn.getConfigProvider().BENTOBOX_IGNORE_LOCKED_ISLAND_SHOPS &&
-                 FindItemAddOn.getBentoboxPlugin() != null &&
-                 FindItemAddOn.getBentoboxPlugin().isIslandLocked(shopIterator.getLocation(), searchingPlayer)) {
+                 bentoboxPlugin != null &&
+                 bentoboxPlugin.isIslandLocked(shopIterator.getLocation(), searchingPlayer)) {
                  Logger.logDebugInfo("Shop is in locked BentoBox island - ignoring");
             return;
             }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4151dda and 94f9fcf.

📒 Files selected for processing (1)
  • src/main/java/io/myzticbean/finditemaddon/quickshop/impl/QSHikariAPIHandler.java (1 hunks)

@myzticbean myzticbean merged commit f136030 into myzticbean:master Oct 25, 2025
2 checks passed
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.

2 participants