Skip to content

feat: staff admin commands; clean departures from factions and guilds - #207

Merged
XxFran10xX merged 6 commits into
mainfrom
feat/staff-faction-tools
Oct 25, 2026
Merged

XxFran10xX merged 6 commits into
mainfrom
feat/staff-faction-tools

Conversation

@XxFran10xX

@XxFran10xX XxFran10xX commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Why

Staff could not change a faction or guild whose leader is away or stuck. Every rename, colour, banner, capital and kick command only checks "is this player the leader", so a request like "rename our capital from Research Tower of the Castle to Sunsora Castle" needed the leader online, or a hand edit of the faction file with the server stopped.

What

Two staff command groups, permission simplefactions.admin. The staff versions skip the leader check and any price, and nothing else: names, colours and membership follow the same rules as the player commands. Anything that doesn't need a location or a held item also works from the console. Every change is written to the server log as [StaffAdmin] <who> ran /<command>: <result>.

/faction admin

Subcommand What it does
info <faction> Leader, members, provinces, colour, culture/religion/ruling system/ruler title, capital and its settlement, other settlements (with their ids), guilds, bank balance, capital changes made
who <character> Which faction and guild a character is in, and whether they lead it (name or character ID, online or not)
rename <faction> <name...> Faction display name (id unchanged), redraws the map
renamesettlement <faction> <settlement|capital> <name...> Renames any settlement; capital picks the faction capital. Settlement ids match without regard to case. Free, and doesn't use up the faction's free capital change
movecapital <faction> [name...] Previews moving the capital to the province the staff member stands in, including any provinces that would be cut off. A name is needed only when no settlement exists there. It can also re-found a capital whose settlement is gone
confirm Applies the previewed move within 60 s, only if the capital hasn't changed and the staff member is still in that province. It goes through the same journaled treasury path as /faction setcapital, at no cost, and does not count as a capital move
setcolour <faction> <R,G,B> Same validation and uniqueness as the player command
setbanner <faction> Uses the banner in hand
set <faction> <culture|religion|rulingsystem|rulertitle> <value...> Free-text fields
kick <faction> <character> Removes a member from the faction and any guild in it. Refuses the faction leader and guild leaders (use forceleader first)
quarantine ... Unchanged, now routed through the same entry point

/guild admin: info, rename, setcolour, setbanner, kick (back to the faction's main guild). The main guild is refused with a pointer to the /faction admin equivalent.

Tab completion covers subcommands, faction and guild ids, settlement ids (plus capital), current colour, set fields and member names (multi-word too).

TreasuryTopology.capital gains an overload with countMove; the existing signature passes true, so player moves are unchanged.

Leaving a faction or guild now cleans up properly (player and staff)

Before this PR, /faction kick, /faction leave, /guild kick and /guild leave only took the character off the member list. Everything else they held stayed until they died. All of these, and both staff kicks, now go through one helper, guild/MemberDepartures:

  • Leaving the realm (leaveRealm) drops:
    • guild invites, dividend eligibility and leadership offers in every guild of the realm;
    • the same political rights a death removes (Government.removeRights, which removeDeadCharacter now delegates to): council seat, proposals, election candidacy and ballots, movement and cause roles, and their vote in a sitting council session;
    • the Spymaster office, if they held it (EspionageState.vacateFor); it falls back to the leader like any vacancy;
    • their place in a faction war host, via the same path as /warband leave (CampaignWarbandBattleService.processLeave, now also callable for an offline account): leadership passes on, the battle is updated and saved. A kept rejoin place for that host is dropped. Places in a player's own warband are untouched.
  • /faction leave counts as walking out, so it blocks rejoining that battle's host. A kick doesn't, so the realm can let the member back.
  • Leaving a guild (leaveGuild) clears that guild's invite, dividend and leadership offer, and returns the character to the main guild.
  • Mercenary company enlistment is unchanged, since it doesn't depend on faction membership.

Related fix: a guild invite received while factionless could, once accepted, pull the character out of a faction they had joined since, without any of this cleanup. Accepting it now refuses with "You belong to X. Use /faction leave first.", and the invite isn't used up.

Known, unchanged: if a departure empties a war host mid-battle, the side's auto-lose check runs. That's the same as members using /warband leave themselves.

Testing

  • Unit: StaffAdminServiceTest (20) and StaffAdminCommandTest (15), with 100% line coverage of the new classes, plus a TreasuryTopologyTest case showing a staff move is free and leaves capital moves unchanged. Routing and completion tests were updated.

  • Departures: MemberDeparturesTest, EspionageStateVacateTest and CampaignWarbandOfflineLeaveTest, plus new cases in WarbandMembershipServiceTest, GuildDividendEligibilityTest and GuildDeleteCommandTest (the cross-realm invite). CommandManagerCoverageTest now checks that the four player commands use the cleanup.

  • Local full suite: on Windows, main already has 515 failing tests (fsync and POSIX permissions). This branch adds only the new TreasuryTopologyTest case, which fails on Windows the same way as its sibling capitalLossRevalidates.... Linux CI is authoritative.

  • Review, staff commands: three rounds. Fixed along the way:

    • confirm threw when staff had no character session;
    • a capital province with no settlement couldn't be repaired;
    • banner-pattern items passed the banner check;
    • <placeholder> values were accepted;
    • clearer refusals outside any province.
  • Dev (TFMCDev01), with a mineflayer staff bot and a target bot on Dev's copy of Sunsora: 54/54 checks passed.

    • Permission refusal, usage and tab completion.
    • Console renamesettlement Sunsora capital Sunsora_Castle; the web map export then showed "Sunsora Castle".
    • Lowercase settlement id; faction rename, colour (reserved and spaced input), culture, banner (with and without a banner in hand).
    • Guild info, rename, main-guild refusal, bad colour; refused leader kicks.
    • who → guild kick → faction kick, with the target told each time.
    • Capital move refusals ("already the capital", wrong province on confirm), then a move to Neo Nordbaum and back. Capital changes made stayed at 0.
    • 25 [StaffAdmin] log lines and no SimpleFactions errors. Dev's SimpleFactions data was restored afterwards.
  • Dev, departures (jar 2f98c1c): the 54-check run above passed again. A second run passed 8/8:

    • a staff bot made leader of Sunsora appointed the target bot Spymaster (saved);
    • /guild leave returned the target to the main guild;
    • the leader's /faction kick removed it;
    • /faction leave worked;
    • there were no SimpleFactions errors.

    After stopping Dev, the saved faction had no Spymaster and the target was gone. Dev data was restored again.

  • Review: three more rounds on the departure change. It found a dropped kept place in unrelated warbands, kicks setting the leave block, and the cross-realm invite; all fixed. The last round was clean.

  • Sol review of the whole PR: round 1 found two issues, both fixed:

    • a capital confirm could act on a faction deleted and refounded under the same id within the 60 s; the pending move now holds the faction itself;
    • the console couldn't tab-complete /guild admin.

    Round 2: VERDICT: APPROVE.

  • Dev, final (jar 5b5a30a): both runs passed again (54/54 and 8/8). The Spymaster was vacated by the kick and Dev data was restored.

Wiki: the staff commands are staff-only. The departure clean-up is what players would expect, and no wiki page currently says otherwise.

🤖 Generated with Claude Code

XxFran10xX and others added 3 commits October 24, 2026 23:19
Adds /faction admin and /guild admin (simplefactions.admin) so staff can
fix realms whose leader is away: info, who, rename, renamesettlement,
movecapital + confirm, setcolour, setbanner, set culture/religion/
rulingsystem/rulertitle and kick for factions; info, rename, setcolour,
setbanner and kick for guilds. They skip the leader check and any price
and keep every other rule. Changes are logged as [StaffAdmin].

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Staff can found the settlement again in a capital province that lost
  it, as /faction setcapital <name> does for leaders.
- A capital move through the treasury needs the staff member to be
  playing a character; say so instead of throwing on confirm.
- Only *_BANNER items count as banners (not banner patterns).
- /faction admin set refuses a <placeholder> value.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Standing outside any province says so, and only a capital move that
goes through the treasury asks the staff member to play a character;
founding a first capital or repairing one in place does not.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1ba10367-a3cb-452b-b94a-df3eb9264d80
Commits

Reviewing files that changed from the base of the PR and between ea9a3d2 and 5b5a30a.

Files selected for processing: 23
  • src/main/java/net/tfminecraft/simplefactions/admin/StaffAdminCommand.java
  • src/main/java/net/tfminecraft/simplefactions/admin/StaffAdminService.java
  • src/main/java/net/tfminecraft/simplefactions/economy/TreasuryTopology.java
  • src/main/java/net/tfminecraft/simplefactions/espionage/EspionageState.java
  • src/main/java/net/tfminecraft/simplefactions/government/Government.java
  • src/main/java/net/tfminecraft/simplefactions/guild/Guild.java
  • src/main/java/net/tfminecraft/simplefactions/guild/MemberDepartures.java
  • src/main/java/net/tfminecraft/simplefactions/managers/CommandManager.java
  • src/main/java/net/tfminecraft/simplefactions/managers/InviteCommands.java
  • src/main/java/net/tfminecraft/simplefactions/utils/TabCompletion.java
  • src/main/java/net/tfminecraft/simplefactions/war/battle/campaign/warband/CampaignWarbandBattleService.java
  • src/main/java/net/tfminecraft/simplefactions/war/battle/warband/WarbandMembershipService.java
  • src/test/java/net/tfminecraft/simplefactions/admin/StaffAdminCommandTest.java
  • src/test/java/net/tfminecraft/simplefactions/admin/StaffAdminServiceTest.java
  • src/test/java/net/tfminecraft/simplefactions/economy/TreasuryTopologyTest.java
  • src/test/java/net/tfminecraft/simplefactions/espionage/EspionageStateVacateTest.java
  • src/test/java/net/tfminecraft/simplefactions/guild/GuildDeleteCommandTest.java
  • src/test/java/net/tfminecraft/simplefactions/guild/GuildDividendEligibilityTest.java
  • src/test/java/net/tfminecraft/simplefactions/guild/MemberDeparturesTest.java
  • src/test/java/net/tfminecraft/simplefactions/managers/CommandManagerCoverageTest.java
  • src/test/java/net/tfminecraft/simplefactions/managers/TabCompletionCoverageTest.java
  • src/test/java/net/tfminecraft/simplefactions/war/battle/campaign/warband/CampaignWarbandOfflineLeaveTest.java
  • src/test/java/net/tfminecraft/simplefactions/war/battle/warband/WarbandMembershipServiceTest.java

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

📝 Summary

Summary by CodeRabbit

  • New Features
    • Added staff administration commands for managing factions and guilds, including information, member management, settings, names and appearance.
    • Added a preview and confirmation flow for staff capital moves.
    • Guild invitations to a guild in another faction no longer take effect until the player leaves their current faction.
    • Departing members are removed from related faction, guild, government, espionage and warband roles, with offline warband departures supported.
  • Bug Fixes
    • Prevented guild invitations from being consumed when the player must first leave another faction’s guild.

Adds staff commands for faction and guild administration, including capital-move previews and confirmation. It centralises guild and realm departure handling, supports faction-warband removal for offline members, and checks faction membership before a guild invite is consumed.

Changes: Staff administration

Layer / File(s) Summary
Faction and guild administration
src/main/java/net/tfminecraft/simplefactions/admin/StaffAdminService.java, src/test/java/net/tfminecraft/simplefactions/admin/StaffAdminServiceTest.java
Adds faction and guild information, editing, renaming, and member-removal operations. Tests cover validation, service results, and removal cases.
Capital-move preview and confirmation
src/main/java/net/tfminecraft/simplefactions/admin/StaffAdminCommand.java, src/main/java/net/tfminecraft/simplefactions/admin/StaffAdminService.java, src/main/java/net/tfminecraft/simplefactions/economy/TreasuryTopology.java, src/test/java/net/tfminecraft/simplefactions/admin/StaffAdmin*Test.java, src/test/java/net/tfminecraft/simplefactions/economy/TreasuryTopologyTest.java
Adds preview and confirmation checks for staff capital moves. Treasury capital-move counting can be disabled for these moves.
Command routing and completion
src/main/java/net/tfminecraft/simplefactions/admin/StaffAdminCommand.java, src/main/java/net/tfminecraft/simplefactions/managers/CommandManager.java, src/main/java/net/tfminecraft/simplefactions/utils/TabCompletion.java, src/test/java/net/tfminecraft/simplefactions/admin/StaffAdminCommandTest.java, src/test/java/net/tfminecraft/simplefactions/managers/TabCompletionCoverageTest.java
Routes faction and guild staff commands, applies admin permission checks, and adds command-specific completions. Tests cover routing, permissions, and completion.

Member departure handling

Layer / File(s) Summary
Faction-warband member removal
src/main/java/net/tfminecraft/simplefactions/war/battle/warband/WarbandMembershipService.java, src/main/java/net/tfminecraft/simplefactions/war/battle/campaign/warband/CampaignWarbandBattleService.java, src/test/java/net/tfminecraft/simplefactions/war/battle/*/warband/*Test.java
Adds faction-warband removal for a matching character and supports leave processing when the member is offline.
Departure state cleanup
src/main/java/net/tfminecraft/simplefactions/guild/MemberDepartures.java, src/main/java/net/tfminecraft/simplefactions/government/Government.java, src/main/java/net/tfminecraft/simplefactions/espionage/EspionageState.java, src/main/java/net/tfminecraft/simplefactions/guild/Guild.java, src/test/java/net/tfminecraft/simplefactions/guild/*Test.java, src/test/java/net/tfminecraft/simplefactions/espionage/EspionageStateVacateTest.java
Adds shared guild and realm departure operations. Departure cleanup removes government rights and espionage roles, and clears guild invites, dividend eligibility, and matching leadership offers.
Departure command integration
src/main/java/net/tfminecraft/simplefactions/managers/CommandManager.java, src/test/java/net/tfminecraft/simplefactions/managers/CommandManagerCoverageTest.java
Routes guild leave and kick, and faction leave and kick, through the shared departure operations.

Guild invite membership check

Layer / File(s) Summary
Cross-faction guild invite check
src/main/java/net/tfminecraft/simplefactions/managers/InviteCommands.java, src/test/java/net/tfminecraft/simplefactions/guild/GuildDeleteCommandTest.java, src/test/java/net/tfminecraft/simplefactions/managers/CommandManagerCoverageTest.java
Checks whether the current guild belongs to another faction before consuming the target guild’s invite. Tests verify that the current guild is not left and the invite is not consumed.

Priority: Normal

Estimated code review effort: 4 (Complex) | ~60 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant StaffPlayer
  participant StaffAdminCommand
  participant StaffAdminService
  participant TreasuryTopology
  StaffPlayer->>StaffAdminCommand: Request capital-move preview
  StaffAdminCommand->>StaffAdminService: previewCapital(...)
  StaffAdminService-->>StaffAdminCommand: Return CapitalMove or validation lines
  StaffAdminCommand-->>StaffPlayer: Show preview
  StaffPlayer->>StaffAdminCommand: Confirm capital move
  StaffAdminCommand->>StaffAdminService: moveCapital(..., standing)
  StaffAdminService->>TreasuryTopology: Apply existing-capital move with countMove false
  TreasuryTopology-->>StaffAdminService: Return move result
  StaffAdminService-->>StaffAdminCommand: Return result lines
  StaffAdminCommand-->>StaffPlayer: Show result
Loading

Possibly related PRs

Suggested labels: size:L

Suggested reviewers: ryanbarlow97

Merge Risk: Minimal · up to 5b5a3

This PR adds staff faction and guild administration commands and routes member departures through shared cleanup. No concrete merge-blocking defect was found in the supplied evidence, and the commands and departure paths have unit and routing coverage.

- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@github-actions github-actions Bot added the size:XL 500-999 effective changed lines (tests excluded in mixed PRs). label Oct 24, 2026
XxFran10xX and others added 2 commits October 24, 2026 23:46
Kicks and leaves (/faction kick, /faction leave, /guild kick, /guild
leave and both staff kicks) now go through MemberDepartures, so a
character who leaves no longer keeps:
- guild invites, dividend eligibility or a leadership offer;
- a council seat, proposals, election candidacy and ballots, or a
  movement role, and their vote in a sitting council session
  (the same rights a death removes);
- the Spymaster office, which falls back to the leader;
- a place in a faction war host: they leave it as with /warband leave,
  so leadership passes on and the battle is told, even when offline.

Leaving only a guild clears that guild's invite, dividend and offer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ining

- A place kept after quitting a player's own warband survives leaving
  the faction; only a faction war host place is dropped.
- Only /faction leave blocks rejoining the battle's host; after a kick
  the realm may let the member back.
- A guild invite from another realm can no longer move a member out of
  the faction they joined since; they are told to /faction leave first.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@XxFran10xX XxFran10xX changed the title feat: staff admin commands for factions and guilds feat: staff admin commands; clean departures from factions and guilds Oct 25, 2026
…etion

- A previewed capital move holds the faction itself. If that faction
  was deleted and refounded under the same id before /faction admin
  confirm, the new faction is left alone.
- The console's /guild completion offers admin (the only /guild
  command it can run), and guild id completion skips missing guilds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@XxFran10xX
XxFran10xX marked this pull request as ready for review October 25, 2026 09:17
@XxFran10xX

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@XxFran10xX
XxFran10xX merged commit 88252c3 into main Oct 25, 2026
4 checks passed
@XxFran10xX
XxFran10xX deleted the feat/staff-faction-tools branch October 25, 2026 09:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XL 500-999 effective changed lines (tests excluded in mixed PRs).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant