Skip to content

Add bookspy and unify spy modes - #59

Merged
Paldiu merged 6 commits into
tfreedomorg:release/v26.9-siriusfrom
luke560:feat/bookspy
Aug 4, 2026
Merged

Add bookspy and unify spy modes#59
Paldiu merged 6 commits into
tfreedomorg:release/v26.9-siriusfrom
luke560:feat/bookspy

Conversation

@luke560

@luke560 luke560 commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

Adds /bookspy and unifies the spy on/off flags into a single shared mode enum so all four spies filter the same way.

/signspy is in this PR because release/v26.9-sirius forked from prod just before the PR merged, so signspy does not exist on this branch. The first four commits are that feature with two conflicts resolved for sirius: PlayerData.saveTo() dropped since sirius removes ConfigSavable from PlayerData and persistence now lives in GenericPlayerRepository; ranks.yml dropped in favor of ranks.json.

The last commit is the new work:

SpyMode

player/CommandSpyMode.java is replaced by player/SpyMode.java (OFF, OPS, ADMINS, ALL) with a single shows(boolean senderIsAdmin) used by CommandSpy, PotionSpy, SignSpy, and BookSpy.

All four commands take the same argument and tab complete the same values [ops | admins | all | off]. A bare /signspy or /bookspy enables OPS, so admin edits stay out of the way by default. A bare /cmdspy or /potionspy still enables ALL, unchanged behavior.

Unknown modes are now rejected instead of disabling the spy. The lenient parser is deliberately named fromStorage rather than fromString: EnumArgumentResolver prefers a static fromString over its own lookup, so naming it that would make e.g. /signspy opss resolve to OFF.

/bookspy

BookSpy listens to PlayerEditBookEvent and reports edits in the same shape as SignSpy, with a per page line-level diff:

shroomp edited book (page 14) +'the new line', -'the line that went away'
shroomp edited book (pages 2, 4, 7) +'first'[...] (and 3 more)
shroomp signed book 'Abolish OP Rights' [Read Book]

Buttons are [See Edit | Read Book], or just [Read Book] for a book's first write, where both would open the same page. See Edit opens at the first edited page; Read Book opens the whole book from page 1. Paper's openBook can't be told which page to open at, so See Edit hands over a copy sliced to start at that page.

Closing a book without changing it is ignored, as is a new blank draft. Signing is reported separately. Output is capped with [...] and (and N more) markers so a large book can't flood chat.

Storage

The players table gains potion_spy_mode, sign_spy_mode, and book_spy_mode (TEXT/VARCHAR(16), default 'off') across the SQLite, MySQL, and PostgreSQL adapters, with addColumnIfMissing migrations for existing databases. The boolean potion_spy column is gone.

Legacy yaml still imports correctly: PlayerData.loadFrom maps the old potion_spy and sign_spy booleans to all, and that is the path YamlMigrationService.migratePlayers uses.

The spy mode getters null-coalesce to OFF because PlayerList snapshots PlayerData through Gson, which allocates the object without running field initializers, so a snapshot written before a mode existed comes back with the field unset.

@Paldiu
Paldiu merged commit d2cd1ae into tfreedomorg:release/v26.9-sirius Aug 4, 2026
@luke560
luke560 deleted the feat/bookspy branch August 4, 2026 18:50
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