refactor: split util/ vs features/ + modular opt-in setupX() config
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>
This commit is contained in:
@@ -367,6 +367,70 @@ Format léger : une décision = un titre + contexte + choix + raison.
|
||||
bases existantes, ALTER TABLE manuel ou suppression du fichier
|
||||
(les bases d'event sont jetables).
|
||||
|
||||
## 2026-06-10 — Réorganisation : `util/` (toujours) vs `features/` (opt-in)
|
||||
|
||||
- **Choix** : séparation nette en deux couches :
|
||||
- `fr.luc.crcore.util.*` — couche **utilitaire**, toujours active : common,
|
||||
command framework, database, message, broadcast, gui, placeholder.
|
||||
- `fr.luc.crcore.features.*` — couche **features**, opt-in : team, player.
|
||||
- `fr.luc.crcore.builtin.*` — les commandes top-level CoreCommand +
|
||||
CoreReloadSubCommand (pas un util, pas une feature, mais le routing
|
||||
global).
|
||||
- **Renames de FQN** (importer côté plugin de jeu si on les utilise) :
|
||||
- `fr.luc.crcore.common.*` → `fr.luc.crcore.util.common.*`
|
||||
- `fr.luc.crcore.command.*` → `fr.luc.crcore.util.command.*`
|
||||
(le framework — Command, BaseCommand, SubCommand, ArgumentType…)
|
||||
- `fr.luc.crcore.command.builtin.team.*`
|
||||
→ `fr.luc.crcore.features.team.command.*`
|
||||
(les 14+ Team*SubCommand)
|
||||
- `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.*`
|
||||
(et sous-packages event/exception/impl/config)
|
||||
- `fr.luc.crcore.player.*` → `fr.luc.crcore.features.player.*`
|
||||
- **Raison** : prépare la modularisation à long terme. Chaque feature est
|
||||
isolée dans son sous-package `features/<nom>/` et peut éventuellement
|
||||
être extraite en module Maven séparé plus tard. Les utils sont
|
||||
partagés. Le top-level reste minimal (CRCore, CRCoreConfig, builtin).
|
||||
|
||||
## 2026-06-10 — Setup modulaire via `CRCoreConfig.setupX()`
|
||||
|
||||
- **Choix** : les features sont désormais **opt-in**. Par défaut une
|
||||
instance de `CRCoreConfig` n'active **aucune** feature ; le plugin de
|
||||
jeu opt-in via :
|
||||
- `setupTeams()` — active team service, repo, config + GUI, sous-cmds
|
||||
- `setupPlayers()` — active player profile service + repo
|
||||
- `setupPlaceholders()` — active la hook PAPI (no-op si PAPI absent)
|
||||
- `setupAll()` — raccourci, active tout
|
||||
- **Comportement quand off** : les getters de service (ex.
|
||||
`core.getTeamService()`) lèvent `IllegalStateException` avec un
|
||||
message explicite. Les commandes built-in correspondantes ne sont
|
||||
simplement pas enregistrées (ex. `/core team` n'existe pas si teams
|
||||
off).
|
||||
- **Util toujours actif** : messages, broadcasts, GUI framework, command
|
||||
framework, database sont systématiquement chargés. C'est la couche
|
||||
infrastructure que les features et les game plugins consomment.
|
||||
- **Listeners Bukkit toujours register** : `CRCoreBroadcastListener` et
|
||||
`GuiListener` sont register unconditionnellement. Si aucune feature ne
|
||||
tire d'event, ils sont idle — aucun coût.
|
||||
- **Snippet d'usage** :
|
||||
```java
|
||||
this.core = new CRCore(this,
|
||||
new CRCoreConfig().setupAll()).enable();
|
||||
// ou granular :
|
||||
this.core = new CRCore(this,
|
||||
new CRCoreConfig().setupTeams()).enable();
|
||||
```
|
||||
- **Raison** : un game plugin qui n'a pas besoin des teams ne charge
|
||||
pas le service ; pas de fichier `<plugin>-team-config.yml` créé, pas
|
||||
de table `crcore_teams` créée, pas de sous-commande `/core team`. La
|
||||
surface est minimale par défaut.
|
||||
|
||||
## 2026-06-10 — Settings d'équipe : cascade per-team → global → default + GUI
|
||||
|
||||
- **Choix** : nouveau module `fr.luc.crcore.team.config` avec :
|
||||
|
||||
Reference in New Issue
Block a user