c1b414f400
CRCore bootstrap class: one-line setup for game plugins (new CRCore(this).enable()).
Wires SQLite, services with event firing, and the /core command tree.
SQLite layer (fr.luc.crcore.database): Database wrapper exposing execute/update/
queryOne/query plus a fluent TableBuilder. ColumnType enum, RowMapper interface,
DatabaseException. Game plugins create their own tables in 2 lines via
db.table("foo").ifNotExists().column(...).create().
Repositories: SqliteTeamRepository and SqlitePlayerProfileRepository extend their
InMemory counterparts (write-through cache). 5 internal tables prefixed crcore_.
Command framework refactored for nested sub-commands: subcommand storage moved
from BaseCommand to AbstractCommand, recursive dispatch() and tabComplete(),
replaceSubCommand() for plugin overrides.
Default /core team commands (13 leaf sub-commands): create, delete, add, remove,
join, leave, info, list, transfer, visibility, score, top, setspawn. Each in its
own class under fr.luc.crcore.command.builtin.team, fully substitutable.
Bukkit events: 9 team events (Create/Dissolve/MemberAdd/MemberRemove/PlayerJoin/
LeadershipTransfer/VisibilityChange/ScoreChange/SpawnPointChange) + 3 player
events (ProfileCreate/Delete/ScoreChange). All post-only, non-cancellable.
BukkitEventFiringTeamServiceImpl and BukkitEventFiringPlayerProfileServiceImpl
override the on* hooks to call Bukkit.getPluginManager().callEvent.
JavaDoc on all new public classes and key existing ones. docs/, GEMINI.md and
PUML diagrams synced: new sections (built-in commands, events, database,
bootstrap), 4 new diagrams (builtin-commands, events, database, bootstrap-
sequence), and 7 new architecture decisions logged.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
125 lines
3.4 KiB
Plaintext
125 lines
3.4 KiB
Plaintext
@startuml command-class-diagram
|
|
title CR-Core — Command framework (class diagram, nested sub-commands)
|
|
|
|
skinparam classAttributeIconSize 0
|
|
hide empty members
|
|
|
|
package "fr.luc.crcore.command" {
|
|
|
|
interface Command {
|
|
+ getName(): String
|
|
+ getAliases(): List<String>
|
|
+ getPermission(): String
|
|
+ isPlayerOnly(): boolean
|
|
+ getDescription(): String
|
|
+ execute(ctx: CommandContext): CommandResult
|
|
+ tabComplete(sender, args: String[]): List<String>
|
|
+ matches(label: String): boolean
|
|
}
|
|
|
|
abstract class AbstractCommand {
|
|
- name: String
|
|
- aliases: List<String>
|
|
- permission: String
|
|
- playerOnly: boolean
|
|
- description: String
|
|
- usage: String
|
|
- arguments: List<ArgumentDef>
|
|
- subCommandsByName: Map<String, SubCommand>
|
|
- subCommandsByAlias: Map<String, SubCommand>
|
|
--
|
|
# addAlias(...) / permission / playerOnly / description / usage
|
|
# argument(name, type) / optionalArgument(name, type)
|
|
# addSubCommand(sub: SubCommand): void
|
|
--
|
|
+ findSubCommand(label): Optional<SubCommand>
|
|
+ getSubCommands(): Collection<SubCommand>
|
|
+ replaceSubCommand(name, newSub): Optional<SubCommand>
|
|
+ hasSubCommands(): boolean
|
|
--
|
|
+ dispatch(sender, label, args): CommandResult
|
|
+ tabComplete(sender, args): List<String>
|
|
+ execute(ctx): CommandResult
|
|
# listSubCommands(ctx): CommandResult
|
|
# checkAccess(sender): boolean
|
|
# buildContext(sender, label, rawArgs): CommandContext
|
|
}
|
|
|
|
abstract class BaseCommand {
|
|
+ onCommand(sender, cmd, label, args): boolean
|
|
+ onTabComplete(sender, cmd, alias, args): List<String>
|
|
# handleResult(sender, result): void
|
|
}
|
|
|
|
abstract class SubCommand
|
|
|
|
class CommandContext {
|
|
- sender: CommandSender
|
|
- label: String
|
|
- rawArgs: String[]
|
|
- parsedArgs: Map<String, Object>
|
|
+ getSender / isPlayer / getPlayer / requirePlayer
|
|
+ get(name): T
|
|
+ getOptional(name): Optional<T>
|
|
+ has(name): boolean
|
|
+ reply(msg): void
|
|
}
|
|
|
|
class CommandResult {
|
|
- type: Type
|
|
- message: String
|
|
+ {static} success / failure / invalidUsage / noPermission / playerOnly
|
|
}
|
|
|
|
enum "CommandResult.Type" as ResultType {
|
|
SUCCESS
|
|
FAILURE
|
|
INVALID_USAGE
|
|
NO_PERMISSION
|
|
PLAYER_ONLY
|
|
}
|
|
|
|
class CommandException
|
|
|
|
interface "ArgumentType<T>" as ArgumentType {
|
|
+ parse(input: String): T
|
|
+ suggestions(sender, partial): List<String>
|
|
}
|
|
|
|
class ArgumentTypes <<utility>> {
|
|
+ STRING / INTEGER / DOUBLE / BOOLEAN / ONLINE_PLAYER
|
|
+ enumOf(Class<E>): ArgumentType<E>
|
|
+ choice(String...): ArgumentType<String>
|
|
}
|
|
|
|
class ArgumentDef <<package-private>> {
|
|
- name: String
|
|
- type: ArgumentType<?>
|
|
- required: boolean
|
|
}
|
|
|
|
AbstractCommand ..|> Command
|
|
BaseCommand --|> AbstractCommand
|
|
SubCommand --|> AbstractCommand
|
|
BaseCommand ..|> "org.bukkit.command.CommandExecutor"
|
|
BaseCommand ..|> "org.bukkit.command.TabCompleter"
|
|
|
|
AbstractCommand "1" o-- "*" SubCommand : sub-commands\n(recursive)
|
|
AbstractCommand "1" *-- "*" ArgumentDef : arguments
|
|
ArgumentDef --> ArgumentType
|
|
CommandResult +-- ResultType
|
|
CommandException --|> RuntimeException
|
|
|
|
AbstractCommand ..> CommandContext : creates
|
|
AbstractCommand ..> CommandResult : returns
|
|
}
|
|
|
|
note bottom of AbstractCommand
|
|
Le routage est récursif :
|
|
/core team create → CoreCommand.dispatch("team", ["create",...])
|
|
→ TeamGroup.dispatch("create", [...])
|
|
→ TeamCreate.execute(ctx)
|
|
end note
|
|
|
|
@enduml
|