84735221f1
Package restructure to prepare future modularization. Three layers now:
1. fr.luc.crcore.util.* (always active)
- common, command framework, database, message, broadcast, gui,
placeholder
2. fr.luc.crcore.features.* (opt-in)
- team (entities, services, repos, events, exceptions, config + GUI,
command/Team*SubCommand)
- player (profile, ranking, services, repos, events, exceptions)
3. fr.luc.crcore.builtin.*
- CoreCommand + CoreReloadSubCommand (top-level routing — not a
feature, not an util)
FQN moves (game plugins importing these need their imports updated):
- fr.luc.crcore.common.* → fr.luc.crcore.util.common.*
- fr.luc.crcore.command.* → fr.luc.crcore.util.command.*
- fr.luc.crcore.command.builtin.team.*
→ fr.luc.crcore.features.team.command.*
- fr.luc.crcore.command.builtin.CoreCommand / CoreReloadSubCommand
→ fr.luc.crcore.builtin.*
- fr.luc.crcore.database.* → fr.luc.crcore.util.database.*
- fr.luc.crcore.message.* → fr.luc.crcore.util.message.*
- fr.luc.crcore.broadcast.* → fr.luc.crcore.util.broadcast.*
- fr.luc.crcore.gui.* → fr.luc.crcore.util.gui.*
- fr.luc.crcore.placeholder.* → fr.luc.crcore.util.placeholder.*
- fr.luc.crcore.team.* → fr.luc.crcore.features.team.*
- fr.luc.crcore.player.* → fr.luc.crcore.features.player.*
CRCoreConfig — features opt-in via fluent setup:
- setupTeams() enables team feature
- setupPlayers() enables player feature
- setupPlaceholders() enables PAPI integration
- setupAll() shortcut
By default no feature is active. Game plugin must opt-in.
CRCore.enable() now conditional:
- Util services always built (messages, broadcasts, gui listener).
- Team services + repos + config built only if setupTeams().
- Player services + repos built only if setupPlayers().
- Placeholder hook registered only if setupPlaceholders() (and PAPI
installed at runtime).
- Getters of disabled features throw IllegalStateException with a clear
message pointing to the missing setupX() call.
- CoreCommand only registers TeamGroupSubCommand if teamService and
teamConfig are non-null. CoreReloadSubCommand handles teamConfig=null
(just skips that reload). /core reload always available.
Docs:
- setup.md tree fully rewritten to reflect util/+features/+builtin
layout (~70 lines of arborescence).
- setup.md code snippet shows the three opt-in patterns (setupAll /
granular / with options).
- decisions.md logs both decisions (restructure + modular setup).
- All .puml diagrams auto-updated to new FQNs.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
111 lines
2.8 KiB
Plaintext
111 lines
2.8 KiB
Plaintext
@startuml player-class-diagram
|
|
title CR-Core — Player domain (class diagram)
|
|
|
|
skinparam classAttributeIconSize 0
|
|
hide empty members
|
|
|
|
' === Common abstractions ===
|
|
|
|
package "fr.luc.crcore.util.common" {
|
|
|
|
interface Identifiable {
|
|
+ getId(): UUID
|
|
}
|
|
|
|
interface ScoreHolder {
|
|
+ getScore(name): int
|
|
+ hasScore(name): boolean
|
|
+ getScores(): Map<String, Integer>
|
|
+ getTotalScore(): int
|
|
+ addScore(name, delta): int
|
|
+ setScore(name, value): int
|
|
+ resetScore(name): boolean
|
|
+ resetAllScores(): void
|
|
}
|
|
|
|
abstract class AbstractEntity {
|
|
- id: UUID
|
|
+ getId(): UUID
|
|
}
|
|
|
|
interface "Repository<T extends Identifiable>" as Repository {
|
|
+ save(entity: T): T
|
|
+ findById(id): Optional<T>
|
|
+ findAll(): Collection<T>
|
|
+ delete(id): boolean
|
|
}
|
|
|
|
AbstractEntity ..|> Identifiable
|
|
}
|
|
|
|
' === Player domain ===
|
|
|
|
package "fr.luc.crcore.features.player" {
|
|
|
|
class PlayerProfile {
|
|
- scores: Map<String, Integer>
|
|
+ PlayerProfile(playerId: UUID)
|
|
+ getPlayerId(): UUID
|
|
}
|
|
|
|
class PlayerRanking <<record>> {
|
|
+ rank: int
|
|
+ profile: PlayerProfile
|
|
+ score: int
|
|
}
|
|
|
|
interface PlayerProfileRepository
|
|
|
|
class InMemoryPlayerProfileRepository {
|
|
- profiles: Map<UUID, PlayerProfile>
|
|
}
|
|
|
|
interface PlayerProfileService {
|
|
+ getOrCreateProfile(playerId): PlayerProfile
|
|
+ getProfile(playerId): Optional<PlayerProfile>
|
|
+ deleteProfile(playerId): boolean
|
|
+ getAllProfiles(): Collection<PlayerProfile>
|
|
--
|
|
+ addScore(playerId, name, delta): int
|
|
+ setScore(playerId, name, value): int
|
|
+ getScore(playerId, name): int
|
|
+ resetScore(playerId, name): boolean
|
|
+ resetAllScores(playerId): void
|
|
--
|
|
+ getRankingByScore(name): List<PlayerRanking>
|
|
+ getGlobalRanking(): List<PlayerRanking>
|
|
+ getTopRankingByScore(name, limit): List<PlayerRanking>
|
|
+ getTopGlobalRanking(limit): List<PlayerRanking>
|
|
}
|
|
|
|
class PlayerProfileServiceImpl {
|
|
- repository: PlayerProfileRepository
|
|
--
|
|
# newProfile(playerId): PlayerProfile
|
|
# newRanking(rank, profile, score): PlayerRanking
|
|
# rank(scoreFn): List<PlayerRanking>
|
|
--
|
|
# onProfileCreated(profile): void
|
|
# onProfileDeleted(profile): void
|
|
# onScoreChanged(profile, name, oldV, newV): void
|
|
}
|
|
|
|
class PlayerException
|
|
class PlayerProfileNotFoundException
|
|
|
|
PlayerProfile --|> AbstractEntity
|
|
PlayerProfile ..|> ScoreHolder
|
|
PlayerProfileRepository --|> Repository
|
|
InMemoryPlayerProfileRepository ..|> PlayerProfileRepository
|
|
PlayerProfileServiceImpl ..|> PlayerProfileService
|
|
|
|
PlayerRanking --> PlayerProfile
|
|
PlayerProfileServiceImpl o--> PlayerProfileRepository
|
|
PlayerProfileService ..> PlayerRanking : produces
|
|
|
|
PlayerException --|> RuntimeException
|
|
PlayerProfileNotFoundException --|> PlayerException
|
|
}
|
|
|
|
@enduml
|