Skip to content

Fix canSpawnFor to use allMatch insted of anyMatch#50

Merged
Tofaa2 merged 2 commits intoTofaa2:masterfrom
Dominilk01:canSpawnFor
Mar 29, 2026
Merged

Fix canSpawnFor to use allMatch insted of anyMatch#50
Tofaa2 merged 2 commits intoTofaa2:masterfrom
Dominilk01:canSpawnFor

Conversation

@Dominilk01
Copy link
Copy Markdown
Contributor

@Dominilk01 Dominilk01 commented Mar 29, 2026

https://discord.com/channels/1197504277787201616/1197504277787201619/1487602605231439923

Summary by CodeRabbit

  • Bug Fixes
    • Tightened entity visibility evaluation: entities now spawn only when every applicable viewer rule and every global rule explicitly permits the user. This changes prior behavior where a single matching rule could allow spawning, reducing unintended visibility and improving consistency of who can see spawned entities.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 29, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9c2320eb-b7e8-4396-85d9-a957e3a0fed7

📥 Commits

Reviewing files that changed from the base of the PR and between fb2de0f and 9b192e7.

📒 Files selected for processing (1)
  • api/src/main/java/me/tofaa/entitylib/ve/ViewerEngine.java
🚧 Files skipped from review as they are similar to previous changes (1)
  • api/src/main/java/me/tofaa/entitylib/ve/ViewerEngine.java

📝 Walkthrough

Walkthrough

ViewerEngine's spawn permission logic was tightened: entity-specific viewer rules now require a non-empty rule list and every rule must allow the user; global viewer rules also require every rule to permit the user before spawning is allowed.

Changes

Cohort / File(s) Summary
ViewerEngine Rule Evaluation
api/src/main/java/me/tofaa/entitylib/ve/ViewerEngine.java
Changed canSpawnFor(User, WrapperEntity) to require all applicable entity viewer rules (and a non-empty entity rule list) to pass, and changed global rule checking from any-match to all-match.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I nibble through the rule-bound hay,

Every gate must nod "okay",
No lone rule gets to decide,
All must cheer for me to hide,
Hops of strict, collective play 🥕

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: switching from anyMatch to allMatch logic in the canSpawnFor method, which is the core modification evident in the changeset.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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
Copy Markdown

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

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@api/src/main/java/me/tofaa/entitylib/ve/ViewerEngine.java`:
- Around line 123-125: The canSpawnFor method currently ORs entity and global
rule checks causing entities with no local rules to bypass globalRules; update
the method (ViewerEngine.canSpawnFor) to require both rule sets pass by
replacing the current early-return logic with a single combined check: evaluate
entity.getViewerRules().stream().allMatch(rule -> rule.shouldSee(user)) &&
globalRules.stream().allMatch(rule -> rule.shouldSee(user)), and return that
result so both entity-level and global rules must allow spawning.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 53e1da86-0267-4e39-a9ba-7ad6a35c2054

📥 Commits

Reviewing files that changed from the base of the PR and between befebbf and fb2de0f.

📒 Files selected for processing (1)
  • api/src/main/java/me/tofaa/entitylib/ve/ViewerEngine.java

@Tofaa2 Tofaa2 merged commit 93a2c94 into Tofaa2:master Mar 29, 2026
1 check 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