Skip to content

fix: only complain about claim rank when a chunk is actually targeted - #27

Merged
tastybento merged 1 commit into
developfrom
fix/claim-rank-nag-on-ordinary-clicks
Aug 10, 2026
Merged

fix: only complain about claim rank when a chunk is actually targeted#27
tastybento merged 1 commit into
developfrom
fix/claim-rank-nag-on-ordinary-clicks

Conversation

@tastybento

Copy link
Copy Markdown
Member

The bug

Reported in-game: a non-owner island member gets Your rank cannot claim chunks for this island! in chat every time they open a chest. The chest opens normally and nothing appears in console.

Cause

ChunkClaimListener.onBorderHit checked the claim rank before anything had established that the click was a claim gesture at all:

User user = User.getInstance(player);
if (!island.isAllowed(user, addon.CHUNKBLOCK_CLAIM_CHUNKS)) {
    denyClaim(user, island);   // <- the message
    return;
}

Every left or right click anywhere in the world reached that branch. The checks that recognise ordinary interaction — the clicked block sitting in unlocked territory, and the aim ray finding no locked chunk — all sat below it and never got the chance to bail out.

So any player below the claim rank was nagged for opening a chest, pressing a button, or mining. It was throttled to once per two seconds, the event was never cancelled (hence the chest still opening), and it is a plain user.notify (hence no console output).

Fix

Move the rank check to after the target chunk is resolved. Order is now:

  1. standing in unlocked territory
  2. clicked block is not itself in unlocked territory
  3. a locked chunk is actually targeted
  4. then rank

A low-rank teammate only hears about the claim flag when they genuinely aim at a locked chunk, which is what denyClaim's "tell teammates why rather than leave them wondering" intent was for. Visitors are still told nothing.

Test

testUsingABlockInOwnTerritoryNeverRaisesTheRankComplaint — a MEMBER-rank player with the flag denied right-clicks a block at x=14, z=8 (their own chunk, close enough to the border that the aim line crosses into the locked neighbour) and must be told nothing. Fails on the old ordering.

Full suite: 659 tests, 0 failures.

🤖 Generated with Claude Code

https://claude.ai/code/session_017EZEwab2kL4i1FNnBYvSmp

The claim rank was checked before anything had established that the click
was a claim gesture, so every left or right click in the world ran the
denial branch. Any player below the claim rank was told "Your rank cannot
claim chunks for this island!" for opening a chest, pressing a button or
mining — throttled to once every two seconds, uncancelled and unlogged,
so the interaction still went through and nothing showed in console.

The checks that recognise ordinary interaction — clicked block sits in
unlocked territory, aim ray finds no locked chunk — all sat below the rank
check and never got the chance to bail out.

Move the rank check to after the target chunk is resolved, so a low-rank
teammate only hears about the claim flag when they genuinely aim at a
locked chunk, which is what that message was for.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017EZEwab2kL4i1FNnBYvSmp
@sonarqubecloud

Copy link
Copy Markdown

@tastybento
tastybento merged commit 16c527b into develop Aug 10, 2026
3 checks passed
This was referenced Aug 10, 2026
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.

1 participant