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>
120 lines
3.6 KiB
Plaintext
120 lines
3.6 KiB
Plaintext
@startuml team-config-class-diagram
|
|
title CR-Core — Team config (class diagram, cascade per-team → global → default)
|
|
|
|
skinparam classAttributeIconSize 0
|
|
hide empty members
|
|
|
|
package "fr.luc.crcore.features.team.config" {
|
|
|
|
class "TeamSetting<T>" as TeamSetting <<final>> {
|
|
- key: String
|
|
- type: Class<T>
|
|
- defaultValue: T
|
|
- kind: Kind
|
|
- parser: Function<Object,T>
|
|
- serializer: Function<T,Object>
|
|
--
|
|
+ {static} ofBoolean(key, default): TeamSetting<Boolean>
|
|
+ {static} ofInt(key, default): TeamSetting<Integer>
|
|
+ {static} ofString(key, default): TeamSetting<String>
|
|
+ {static} ofEnum(key, default): TeamSetting<E>
|
|
--
|
|
+ parse(raw): T
|
|
+ serialize(value): Object
|
|
+ getKey() / getType() / getDefaultValue() / getKind()
|
|
}
|
|
|
|
enum "TeamSetting.Kind" as Kind {
|
|
BOOLEAN
|
|
INTEGER
|
|
STRING
|
|
ENUM
|
|
}
|
|
TeamSetting +-- Kind
|
|
|
|
class TeamSettings <<utility>> {
|
|
+ {static} FRIENDLY_FIRE: TeamSetting<Boolean>
|
|
+ {static} PVP_PROTECTION_SECONDS: TeamSetting<Integer>
|
|
+ {static} MAX_SIZE: TeamSetting<Integer>
|
|
+ {static} MIN_SIZE: TeamSetting<Integer>
|
|
+ {static} RESPAWN_AT_TEAM_SPAWN: TeamSetting<Boolean>
|
|
+ {static} TEAM_CHAT_ENABLED: TeamSetting<Boolean>
|
|
+ {static} SHOW_TAG_ABOVE_HEAD: TeamSetting<Boolean>
|
|
+ {static} TEAM_COLOR_IN_NAME: TeamSetting<Boolean>
|
|
--
|
|
+ {static} register(setting): void
|
|
+ {static} get(key): Optional<TeamSetting<?>>
|
|
+ {static} all(): Collection<TeamSetting<?>>
|
|
}
|
|
TeamSettings ..> TeamSetting
|
|
|
|
interface TeamConfigService {
|
|
+ get(team, setting): T
|
|
+ getGlobal(setting): T
|
|
+ setPerTeam(team, setting, value): void
|
|
+ resetPerTeam(team, setting): void
|
|
+ setGlobal(setting, value): void
|
|
+ reload(): void
|
|
+ hasPerTeamOverride(team, setting): boolean
|
|
+ getGlobalSnapshot(): Map<TeamSetting<?>, Object>
|
|
+ getGlobalFileName(): Optional<String>
|
|
}
|
|
|
|
package "fr.luc.crcore.features.team.config.impl" {
|
|
class YamlTeamConfigService {
|
|
- plugin: JavaPlugin
|
|
- teamRepository: TeamRepository
|
|
- userFile: File
|
|
- globalValues: Map<String, Object>
|
|
--
|
|
- ensureUserFile(): void
|
|
- rebuildGlobalValues(): void
|
|
- persistGlobals(): void
|
|
}
|
|
YamlTeamConfigService ..|> TeamConfigService
|
|
}
|
|
|
|
TeamConfigService ..> TeamSetting : reads/writes
|
|
}
|
|
|
|
package "fr.luc.crcore.features.team" {
|
|
class Team {
|
|
- settings: Map<String, Object>
|
|
+ getSettings(): Map<String, Object>
|
|
}
|
|
}
|
|
|
|
package "fr.luc.crcore.features.team.config.gui" {
|
|
abstract class AbstractSettingsGui {
|
|
- rebuild() : peint la grille
|
|
# {abstract} getCurrentValue(setting): T
|
|
# {abstract} onChange(setting, newValue): void
|
|
# isOverride(setting): boolean
|
|
# renderFooter(): void
|
|
}
|
|
class GlobalSettingsGui
|
|
class TeamSettingsGui
|
|
GlobalSettingsGui --|> AbstractSettingsGui
|
|
TeamSettingsGui --|> AbstractSettingsGui
|
|
AbstractSettingsGui --|> "fr.luc.crcore.util.gui.AbstractInventoryGui"
|
|
|
|
GlobalSettingsGui --> TeamConfigService
|
|
TeamSettingsGui --> TeamConfigService
|
|
TeamSettingsGui --> Team
|
|
}
|
|
|
|
YamlTeamConfigService --> "fr.luc.crcore.features.team.TeamRepository" : persists per-team via save()
|
|
TeamConfigService ..> Team : reads/writes settings map
|
|
|
|
note bottom of YamlTeamConfigService
|
|
Cascade de résolution :
|
|
1. team.getSettings().get(key) ← override per-team (SQLite)
|
|
2. globalValues.get(key) ← <plugin>-team-config.yml
|
|
3. setting.getDefaultValue() ← constante Java
|
|
|
|
Le YAML global est ré-écrit à chaque setGlobal() (persistant à crash).
|
|
Les per-team sont écrits via teamRepository.save(team).
|
|
end note
|
|
|
|
@enduml
|