Repository navigation
feat: staff admin commands; clean departures from factions and guilds - #207
Conversation
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>
|
No actionable comments were generated in the recent review.
|
| 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:
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
Possibly related PRs
- TF-Minecraft/SimpleFactions#202: Changes the guild lookup path used by the staff command’s
/guild admintargets and completions.
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.
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.
Comment @coderabbitai help to get the list of available commands.
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>
…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>
|
@coderabbitai review |
✅ Action performed
|
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 admininfo <faction>who <character>rename <faction> <name...>renamesettlement <faction> <settlement|capital> <name...>capitalpicks the faction capital. Settlement ids match without regard to case. Free, and doesn't use up the faction's free capital changemovecapital <faction> [name...]confirm/faction setcapital, at no cost, and does not count as a capital movesetcolour <faction> <R,G,B>setbanner <faction>set <faction> <culture|religion|rulingsystem|rulertitle> <value...>kick <faction> <character>forceleaderfirst)quarantine .../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 adminequivalent.Tab completion covers subcommands, faction and guild ids, settlement ids (plus
capital), current colour,setfields and member names (multi-word too).TreasuryTopology.capitalgains an overload withcountMove; the existing signature passestrue, 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 kickand/guild leaveonly 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:leaveRealm) drops:Government.removeRights, whichremoveDeadCharacternow delegates to): council seat, proposals, election candidacy and ballots, movement and cause roles, and their vote in a sitting council session;EspionageState.vacateFor); it falls back to the leader like any vacancy;/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 leavecounts as walking out, so it blocks rejoining that battle's host. A kick doesn't, so the realm can let the member back.leaveGuild) clears that guild's invite, dividend and leadership offer, and returns the character to the main guild.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 leavethemselves.Testing
Unit:
StaffAdminServiceTest(20) andStaffAdminCommandTest(15), with 100% line coverage of the new classes, plus aTreasuryTopologyTestcase showing a staff move is free and leavescapital movesunchanged. Routing and completion tests were updated.Departures:
MemberDeparturesTest,EspionageStateVacateTestandCampaignWarbandOfflineLeaveTest, plus new cases inWarbandMembershipServiceTest,GuildDividendEligibilityTestandGuildDeleteCommandTest(the cross-realm invite).CommandManagerCoverageTestnow checks that the four player commands use the cleanup.Local full suite: on Windows,
mainalready has 515 failing tests (fsync and POSIX permissions). This branch adds only the newTreasuryTopologyTestcase, which fails on Windows the same way as its siblingcapitalLossRevalidates.... Linux CI is authoritative.Review, staff commands: three rounds. Fixed along the way:
<placeholder>values were accepted;Dev (TFMCDev01), with a mineflayer staff bot and a target bot on Dev's copy of Sunsora: 54/54 checks passed.
renamesettlement Sunsora capital Sunsora_Castle; the web map export then showed "Sunsora Castle".who→ guild kick → faction kick, with the target told each time.Capital changes madestayed at 0.[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:/guild leavereturned the target to the main guild;/faction kickremoved it;/faction leaveworked;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:
confirmcould act on a faction deleted and refounded under the same id within the 60 s; the pending move now holds the faction itself;/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