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:
+97
-99
@@ -66,7 +66,12 @@ api-version: 1.16
|
||||
> Dans ce cas, CR-Core détecte la commande déclarée et s'y branche
|
||||
> normalement via `setExecutor` (pas d'enregistrement dynamique).
|
||||
|
||||
### Code minimal
|
||||
### Code minimal — setup modulaire
|
||||
|
||||
> ⚠️ **Important** : depuis 2026-06-10, les features (teams, players,
|
||||
> placeholders) sont **opt-in** via `CRCoreConfig.setupX()`. Une instance
|
||||
> `new CRCoreConfig()` n'active rien par défaut — il faut appeler
|
||||
> `setupAll()` ou les `setupX()` individuels.
|
||||
|
||||
```java
|
||||
public class MyGamePlugin extends JavaPlugin {
|
||||
@@ -75,13 +80,27 @@ public class MyGamePlugin extends JavaPlugin {
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
// 1 ligne = SQLite + services + /core team ... opérationnels
|
||||
this.core = new CRCore(this).enable();
|
||||
// OPTION A — tout activer en une ligne (teams + players + placeholders)
|
||||
this.core = new CRCore(this, new CRCoreConfig().setupAll()).enable();
|
||||
|
||||
// Listener custom sur les events team
|
||||
// OPTION B — granularité, n'activer que ce qu'on veut
|
||||
// this.core = new CRCore(this, new CRCoreConfig()
|
||||
// .setupTeams()
|
||||
// .setupPlaceholders()) // pas de players
|
||||
// .enable();
|
||||
|
||||
// OPTION C — par défaut + options
|
||||
// this.core = new CRCore(this, new CRCoreConfig()
|
||||
// .withSqliteFile("mygame.db")
|
||||
// .withCommandName("game")
|
||||
// .setupTeams())
|
||||
// .enable();
|
||||
|
||||
// Listener custom sur les events team (nécessite setupTeams)
|
||||
getServer().getPluginManager().registerEvents(new MyTeamListener(), this);
|
||||
|
||||
// Table custom pour stocker des données spécifiques au jeu
|
||||
// (database util est toujours disponible)
|
||||
core.getDatabase().table("my_kills")
|
||||
.ifNotExists()
|
||||
.column("player_id", ColumnType.UUID).primaryKey()
|
||||
@@ -168,101 +187,80 @@ CitesPlugin/ # dossier IntelliJ (renommer plus t
|
||||
│ ├── decisions.md
|
||||
│ └── diagrams/*.puml
|
||||
└── src/main/java/fr/luc/crcore/
|
||||
├── CRCore.java # bootstrap orchestrator
|
||||
├── CRCoreConfig.java # config (sqlite, command name, …)
|
||||
├── common/
|
||||
│ ├── Identifiable.java
|
||||
│ ├── Named.java
|
||||
│ ├── ScoreHolder.java # contrat partagé Team + PlayerProfile
|
||||
│ ├── AbstractEntity.java
|
||||
│ └── Repository.java
|
||||
├── database/ # wrapper SQLite
|
||||
│ ├── Database.java
|
||||
│ ├── TableBuilder.java
|
||||
│ ├── ColumnType.java
|
||||
│ ├── RowMapper.java
|
||||
│ └── DatabaseException.java
|
||||
├── command/ # framework
|
||||
│ ├── Command.java (interface)
|
||||
│ ├── AbstractCommand.java # base partagée, nested sub-commands
|
||||
│ ├── BaseCommand.java # top-level Bukkit-aware
|
||||
│ ├── SubCommand.java
|
||||
│ ├── CommandContext.java
|
||||
│ ├── CommandResult.java
|
||||
│ ├── CommandException.java
|
||||
│ ├── ArgumentType.java
|
||||
│ ├── ArgumentTypes.java
|
||||
│ ├── ArgumentDef.java # package-private
|
||||
│ └── builtin/ # commandes prêtes à l'emploi
|
||||
│ ├── CoreCommand.java # /core
|
||||
│ └── team/
|
||||
│ ├── TeamGroupSubCommand.java # /core team (container)
|
||||
│ ├── TeamArgumentTypes.java # ArgumentType<Team> avec tab-complete
|
||||
│ ├── TeamCreateSubCommand.java # /core team create
|
||||
│ ├── TeamDeleteSubCommand.java # /core team delete
|
||||
│ ├── TeamAddSubCommand.java # /core team add
|
||||
│ ├── TeamRemoveSubCommand.java # /core team remove
|
||||
│ ├── TeamJoinSubCommand.java # /core team join
|
||||
│ ├── TeamLeaveSubCommand.java # /core team leave
|
||||
│ ├── TeamInfoSubCommand.java # /core team info
|
||||
│ ├── TeamListSubCommand.java # /core team list
|
||||
│ ├── TeamTransferSubCommand.java # /core team transfer
|
||||
│ ├── TeamVisibilitySubCommand.java # /core team visibility
|
||||
│ ├── TeamScoreSubCommand.java # /core team score (admin)
|
||||
│ ├── TeamTopSubCommand.java # /core team top
|
||||
│ └── TeamSetSpawnSubCommand.java # /core team setspawn
|
||||
├── message/ # service de messages YAML
|
||||
│ ├── MessagesService.java # interface (contrat public)
|
||||
│ └── impl/
|
||||
│ └── YamlMessagesService.java # impl par défaut
|
||||
├── team/ # contrats + entités au top
|
||||
│ ├── Team.java # entité
|
||||
│ ├── TeamMember.java # entité
|
||||
│ ├── TeamRole.java # enum
|
||||
│ ├── TeamColor.java # enum
|
||||
│ ├── TeamVisibility.java # enum
|
||||
│ ├── TeamRanking.java # value
|
||||
│ ├── TeamService.java # interface
|
||||
│ ├── TeamRepository.java # interface
|
||||
│ ├── event/ # Bukkit events team
|
||||
│ │ ├── TeamEvent.java # base
|
||||
│ │ ├── TeamCreateEvent.java
|
||||
│ │ ├── TeamDissolveEvent.java
|
||||
│ │ ├── TeamMemberAddEvent.java
|
||||
│ │ ├── TeamMemberRemoveEvent.java
|
||||
│ │ ├── PlayerJoinTeamEvent.java
|
||||
│ │ ├── TeamLeadershipTransferEvent.java
|
||||
│ │ ├── TeamVisibilityChangeEvent.java
|
||||
│ │ ├── TeamScoreChangeEvent.java
|
||||
│ │ └── TeamSpawnPointChangeEvent.java
|
||||
│ ├── exception/ # hiérarchie d'exceptions team
|
||||
│ │ ├── TeamException.java # base
|
||||
│ │ ├── TeamAlreadyExistsException.java
|
||||
│ │ ├── TeamNotFoundException.java
|
||||
│ │ └── TeamAccessException.java
|
||||
│ └── impl/ # implémentations swappables
|
||||
│ ├── TeamServiceImpl.java # service de base
|
||||
│ ├── BukkitEventFiringTeamServiceImpl.java # impl par défaut
|
||||
│ ├── InMemoryTeamRepository.java # repo en mémoire
|
||||
│ └── SqliteTeamRepository.java # repo SQLite write-through
|
||||
└── player/ # contrats + entités au top
|
||||
├── PlayerProfile.java # entité
|
||||
├── PlayerRanking.java # value
|
||||
├── PlayerProfileService.java # interface
|
||||
├── PlayerProfileRepository.java # interface
|
||||
├── event/ # Bukkit events player
|
||||
│ ├── PlayerProfileEvent.java
|
||||
│ ├── PlayerProfileCreateEvent.java
|
||||
│ ├── PlayerProfileDeleteEvent.java
|
||||
│ └── PlayerScoreChangeEvent.java
|
||||
├── exception/
|
||||
│ ├── PlayerException.java
|
||||
│ └── PlayerProfileNotFoundException.java
|
||||
└── impl/
|
||||
├── PlayerProfileServiceImpl.java
|
||||
├── BukkitEventFiringPlayerProfileServiceImpl.java
|
||||
├── InMemoryPlayerProfileRepository.java
|
||||
└── SqlitePlayerProfileRepository.java
|
||||
├── CRCore.java # bootstrap (setupAll/setupTeams/...)
|
||||
├── CRCoreConfig.java # config builder + flags features
|
||||
├── builtin/ # commandes top-level (toutes features)
|
||||
│ ├── CoreCommand.java # /core
|
||||
│ └── CoreReloadSubCommand.java # /core reload
|
||||
├── util/ # ◆ couche util — toujours active ◆
|
||||
│ ├── common/ # abstractions partagées
|
||||
│ │ ├── Identifiable.java
|
||||
│ │ ├── Named.java
|
||||
│ │ ├── ScoreHolder.java
|
||||
│ │ ├── AbstractEntity.java
|
||||
│ │ └── Repository.java
|
||||
│ ├── database/ # wrapper SQLite générique
|
||||
│ │ ├── Database.java
|
||||
│ │ ├── TableBuilder.java
|
||||
│ │ ├── ColumnType.java
|
||||
│ │ ├── RowMapper.java
|
||||
│ │ └── DatabaseException.java
|
||||
│ ├── command/ # framework de commandes
|
||||
│ │ ├── Command.java (interface)
|
||||
│ │ ├── AbstractCommand.java
|
||||
│ │ ├── BaseCommand.java
|
||||
│ │ ├── SubCommand.java
|
||||
│ │ ├── CommandContext.java
|
||||
│ │ ├── CommandResult.java
|
||||
│ │ ├── CommandException.java
|
||||
│ │ ├── ArgumentType.java
|
||||
│ │ ├── ArgumentTypes.java
|
||||
│ │ └── ArgumentDef.java (package-private)
|
||||
│ ├── message/ # service messages YAML
|
||||
│ │ ├── MessagesService.java
|
||||
│ │ └── impl/YamlMessagesService.java
|
||||
│ ├── broadcast/ # service broadcasts YAML + listener
|
||||
│ │ ├── BroadcastService.java
|
||||
│ │ ├── BroadcastAudience.java
|
||||
│ │ ├── BroadcastContext.java
|
||||
│ │ ├── CRCoreBroadcastListener.java
|
||||
│ │ └── impl/YamlBroadcastService.java
|
||||
│ ├── gui/ # framework GUI (InventoryHolder)
|
||||
│ │ ├── AbstractInventoryGui.java
|
||||
│ │ ├── GuiClickHandler.java
|
||||
│ │ ├── GuiListener.java
|
||||
│ │ └── GuiItems.java
|
||||
│ └── placeholder/ # PAPI expansion (opt-in)
|
||||
│ └── CRCorePlaceholderExpansion.java
|
||||
└── features/ # ◆ features opt-in via setupX() ◆
|
||||
├── team/ (setupTeams())
|
||||
│ ├── Team.java, TeamMember, enums, TeamRanking
|
||||
│ ├── TeamService.java (interface)
|
||||
│ ├── TeamRepository.java (interface)
|
||||
│ ├── event/ (9 events Bukkit)
|
||||
│ ├── exception/ (4 exceptions)
|
||||
│ ├── impl/ (TeamServiceImpl, BukkitEventFiring*, InMemory*, Sqlite*)
|
||||
│ ├── config/ (settings typés)
|
||||
│ │ ├── TeamSetting.java
|
||||
│ │ ├── TeamSettings.java (registry)
|
||||
│ │ ├── TeamConfigService.java
|
||||
│ │ ├── impl/YamlTeamConfigService.java
|
||||
│ │ └── gui/ (Global + TeamSettingsGui)
|
||||
│ │ ├── AbstractSettingsGui.java
|
||||
│ │ ├── GlobalSettingsGui.java
|
||||
│ │ └── TeamSettingsGui.java
|
||||
│ └── command/ (14 sous-commandes /core team)
|
||||
│ ├── TeamGroupSubCommand.java
|
||||
│ ├── TeamArgumentTypes.java
|
||||
│ └── Team*SubCommand.java
|
||||
└── player/ (setupPlayers())
|
||||
├── PlayerProfile.java
|
||||
├── PlayerRanking.java
|
||||
├── PlayerProfileService.java (interface)
|
||||
├── PlayerProfileRepository.java (interface)
|
||||
├── event/ (3 events)
|
||||
├── exception/ (2 exceptions)
|
||||
└── impl/ (services + repositories)
|
||||
```
|
||||
|
||||
## Fichiers de config générés au premier `enable()`
|
||||
|
||||
Reference in New Issue
Block a user