feat: admin/chef/player permission model + leaderless teams + setleader

Commands:
- Drop all short aliases (c/i/t/j/vis/disband/...) — long names only.
- Every /core team <action> now has a crcore.team.<action> permission.
- Three-tier model:
  * Admin (perm only): create, delete, setleader, score
  * Chef (perm + chef-check in execute): add, remove, transfer, visibility, setspawn
  * Player (perm): join, leave, info, list, top
- delete now takes <team> as argument (admin); no more chef-disband shortcut.

New /core team setleader <team> <player>:
- Admin assigns or replaces a team's leader.
- More permissive than transfer: target may not yet be a member (auto-add),
  and works on leaderless teams.

Leaderless teams:
- Team.leaderId is now nullable.
- getLeaderId() and getLeader() return Optional<...>.
- hasLeader() and isLeader(UUID) helpers added.
- New constructors Team(id, name, tag, color [, visibility]) for leaderless.
- TeamService.createTeam overloads without leaderId.
- TeamService.setLeader(teamId, playerId): assigns/replaces leader (auto-adds
  as member if needed). Fires TeamLeadershipTransferEvent with optional old.
- TeamLeadershipTransferEvent.getOldLeaderId() returns Optional<UUID>.
- SqliteTeamRepository: leader_id column no longer NOT NULL.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Antone Barbaud
2026-06-09 14:56:07 +02:00
parent 5bd6e227d3
commit 002fefdc02
24 changed files with 472 additions and 138 deletions
+72 -24
View File
@@ -1,5 +1,5 @@
@startuml builtin-commands-diagram
title CR-Core — Default /core team commands
title CR-Core — Default /core team commands (admin / chef / joueur)
skinparam classAttributeIconSize 0
hide empty members
@@ -13,7 +13,6 @@ package "fr.luc.crcore.command.builtin" {
class CoreCommand {
+ CoreCommand(teamSvc, playerSvc)
# registerDefaults(): void
}
CoreCommand --|> BaseCommand
@@ -29,44 +28,93 @@ package "fr.luc.crcore.command.builtin" {
+ {static} teamByName(service): ArgumentType<Team>
}
class TeamCreateSubCommand {
+ execute(ctx): CommandResult
' === ADMIN commands (permission seule) ===
package "admin" <<Rectangle>> {
class TeamCreateSubCommand {
perm: crcore.team.create
args: name, tag, color, [leader]
}
class TeamDeleteSubCommand {
perm: crcore.team.delete
args: <team>
}
class TeamSetLeaderSubCommand {
perm: crcore.team.setleader
args: <team> <player>
}
class TeamScoreSubCommand {
perm: crcore.team.score
args: <team> <name> <add|set> <value>
}
}
' === CHEF commands (permission + check chef) ===
package "chef" <<Rectangle>> {
class TeamAddSubCommand {
perm: crcore.team.add
args: <player>
}
class TeamRemoveSubCommand {
perm: crcore.team.remove
args: <player>
}
class TeamTransferSubCommand {
perm: crcore.team.transfer
args: <player>
}
class TeamVisibilitySubCommand {
perm: crcore.team.visibility
args: <vis>
}
class TeamSetSpawnSubCommand {
perm: crcore.team.setspawn
}
}
' === PLAYER commands ===
package "player" <<Rectangle>> {
class TeamJoinSubCommand {
perm: crcore.team.join
args: <team>
}
class TeamLeaveSubCommand {
perm: crcore.team.leave
}
class TeamInfoSubCommand {
perm: crcore.team.info
args: [team]
}
class TeamListSubCommand {
perm: crcore.team.list
}
class TeamTopSubCommand {
perm: crcore.team.top
args: [score]
}
}
class TeamDeleteSubCommand
class TeamAddSubCommand
class TeamRemoveSubCommand
class TeamJoinSubCommand
class TeamLeaveSubCommand
class TeamInfoSubCommand
class TeamListSubCommand
class TeamTransferSubCommand
class TeamVisibilitySubCommand
class TeamScoreSubCommand
class TeamTopSubCommand
class TeamSetSpawnSubCommand
TeamCreateSubCommand --|> SubCommand
TeamDeleteSubCommand --|> SubCommand
TeamSetLeaderSubCommand --|> SubCommand
TeamScoreSubCommand --|> SubCommand
TeamAddSubCommand --|> SubCommand
TeamRemoveSubCommand --|> SubCommand
TeamTransferSubCommand --|> SubCommand
TeamVisibilitySubCommand --|> SubCommand
TeamSetSpawnSubCommand --|> SubCommand
TeamJoinSubCommand --|> SubCommand
TeamLeaveSubCommand --|> SubCommand
TeamInfoSubCommand --|> SubCommand
TeamListSubCommand --|> SubCommand
TeamTransferSubCommand --|> SubCommand
TeamVisibilitySubCommand --|> SubCommand
TeamScoreSubCommand --|> SubCommand
TeamTopSubCommand --|> SubCommand
TeamSetSpawnSubCommand --|> SubCommand
CoreCommand "1" *-- "1" TeamGroupSubCommand : contains
TeamGroupSubCommand "1" *-- "13" SubCommand : contains
TeamGroupSubCommand "1" *-- "14" SubCommand : contains
}
}
note right of CoreCommand
Le plugin de jeu downstream
remplace une feuille avec :
note bottom of TeamGroupSubCommand
Override d'une feuille :
core.getCoreCommand()
.findSubCommand("team")
.replaceSubCommand("create",
+18 -6
View File
@@ -101,17 +101,24 @@ package "fr.luc.crcore.team" {
- name: String
- tag: String
- color: TeamColor
- leaderId: UUID
- leaderId: UUID *(nullable)*
- visibility: TeamVisibility
- members: Set<TeamMember>
- scores: Map<String, Integer>
- spawnPoint: Location
--
+ Team(id, name, tag, color) ' leaderless, PRIVATE
+ Team(id, name, tag, color, visibility) ' leaderless
+ Team(id, name, tag, color, leaderId) ' with leader, PRIVATE
+ Team(id, name, tag, color, leaderId, visibility)
--
+ getName(): String
+ getTag(): String
+ getColor(): TeamColor
+ getLeaderId(): UUID
+ getLeader(): TeamMember
+ getLeaderId(): Optional<UUID>
+ getLeader(): Optional<TeamMember>
+ hasLeader(): boolean
+ isLeader(playerId): boolean
+ getVisibility(): TeamVisibility
+ setVisibility(v): void
+ isPublic(): boolean
@@ -121,7 +128,8 @@ package "fr.luc.crcore.team" {
+ size(): int
+ addMember(playerId): TeamMember
+ removeMember(playerId): boolean
+ transferLeadership(newLeaderId): void
+ transferLeadership(newLeaderId): void ' strict: chef→chef
+ setLeader(newLeaderId): void ' permissive: assign
--
+ getScore(name): int
+ hasScore(name): boolean
@@ -157,12 +165,16 @@ package "fr.luc.crcore.team" {
}
interface TeamService {
+ createTeam(name, tag, color, leaderId, [visibility]): Team
+ createTeam(name, tag, color): Team ' leaderless, PRIVATE
+ createTeam(name, tag, color, visibility): Team ' leaderless
+ createTeam(name, tag, color, leaderId): Team
+ createTeam(name, tag, color, leaderId, visibility): Team
+ dissolveTeam(teamId): boolean
+ addMember(teamId, playerId): boolean
+ removeMember(teamId, playerId): boolean
+ joinTeam(teamId, playerId): boolean
+ transferLeadership(teamId, newLeaderId): boolean
+ transferLeadership(teamId, newLeaderId): boolean ' strict: chef→chef
+ setLeader(teamId, newLeaderId): boolean ' permissive (admin)
+ setVisibility(teamId, visibility): void
--
+ addScore(teamId, name, delta): int