ffc77c4213
Pure Maven library for CR Minecraft game plugins, targeting Paper 1.16.5. Common abstractions (fr.luc.crcore.common): Identifiable, Named, ScoreHolder, AbstractEntity, Repository<T>. Team domain (fr.luc.crcore.team): Team entity with name/tag/color/leader/ visibility (PUBLIC|PRIVATE)/members/scores/spawn point, TeamMember, TeamRole/TeamColor/TeamVisibility enums, TeamRanking record, TeamService with overridable hooks (factories, validations, lifecycle events), in-memory repository, dedicated exception hierarchy. Player domain (fr.luc.crcore.player): PlayerProfile with named scores per player, PlayerProfileService with auto-creation, individual rankings, exception hierarchy. Both Team and PlayerProfile implement ScoreHolder. Command framework (fr.luc.crcore.command): Command interface, AbstractCommand base, BaseCommand (CommandExecutor + TabCompleter), SubCommand, CommandContext, CommandResult, ArgumentType<T> + ArgumentTypes catalogue (STRING, INTEGER, DOUBLE, BOOLEAN, ONLINE_PLAYER, enumOf, choice). Docs (docs/) is the single source of truth: README, setup, features, decisions log, and 6 PlantUML diagrams (team class/sequence/activity/join, player class, command class). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
133 lines
3.6 KiB
Plaintext
133 lines
3.6 KiB
Plaintext
@startuml command-class-diagram
|
|
title CR-Core — Command framework (class diagram)
|
|
|
|
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, argIndex, partial): 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>
|
|
# addAlias(...): void
|
|
# permission(p): void
|
|
# playerOnly(): void
|
|
# description(d): void
|
|
# usage(u): void
|
|
# argument(name, type): void
|
|
# optionalArgument(name, type): void
|
|
# buildContext(sender, label, subArgs): CommandContext
|
|
+ getRequiredArgumentCount(): int
|
|
+ getTotalArgumentCount(): int
|
|
+ getUsage(): String
|
|
}
|
|
|
|
abstract class BaseCommand {
|
|
- subCommandsByName: Map<String, SubCommand>
|
|
- subCommandsByAlias: Map<String, SubCommand>
|
|
# addSubCommand(sub: SubCommand): void
|
|
+ findSubCommand(label: String): Optional<SubCommand>
|
|
+ getSubCommands(): Collection<SubCommand>
|
|
# execute(ctx): CommandResult
|
|
+ onCommand(sender, cmd, label, args): boolean
|
|
+ onTabComplete(sender, cmd, alias, args): List<String>
|
|
# checkAccess(sender, target): boolean
|
|
# handleResult(sender, result): void
|
|
}
|
|
|
|
abstract class SubCommand {
|
|
+ {abstract} execute(ctx: CommandContext): CommandResult
|
|
}
|
|
|
|
class CommandContext {
|
|
- sender: CommandSender
|
|
- label: String
|
|
- rawArgs: String[]
|
|
- parsedArgs: Map<String, Object>
|
|
+ getSender(): CommandSender
|
|
+ isPlayer(): boolean
|
|
+ getPlayer(): Optional<Player>
|
|
+ requirePlayer(): Player
|
|
+ get(name: String): T
|
|
+ getOptional(name): Optional<T>
|
|
+ has(name): boolean
|
|
+ reply(msg): void
|
|
}
|
|
|
|
class CommandResult {
|
|
- type: Type
|
|
- message: String
|
|
+ getType(): Type
|
|
+ getMessage(): String
|
|
+ isSuccess(): boolean
|
|
+ {static} success(): CommandResult
|
|
+ {static} success(msg): CommandResult
|
|
+ {static} failure(msg): CommandResult
|
|
+ {static} invalidUsage(): CommandResult
|
|
+ {static} noPermission(): CommandResult
|
|
+ {static} playerOnly(): CommandResult
|
|
}
|
|
|
|
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 << (S, #FFC107) static >> {
|
|
+ {static} STRING: ArgumentType<String>
|
|
+ {static} INTEGER: ArgumentType<Integer>
|
|
+ {static} DOUBLE: ArgumentType<Double>
|
|
+ {static} BOOLEAN: ArgumentType<Boolean>
|
|
+ {static} ONLINE_PLAYER: ArgumentType<Player>
|
|
+ {static} enumOf(type): ArgumentType<E>
|
|
+ {static} choice(choices): ArgumentType<String>
|
|
}
|
|
|
|
class ArgumentDef << (P, #BBBBBB) package-private >> {
|
|
- name: String
|
|
- type: ArgumentType<?>
|
|
- required: boolean
|
|
}
|
|
|
|
AbstractCommand ..|> Command
|
|
BaseCommand --|> AbstractCommand
|
|
SubCommand --|> AbstractCommand
|
|
BaseCommand "1" o-- "*" SubCommand : subCommands
|
|
AbstractCommand "1" *-- "*" ArgumentDef : arguments
|
|
ArgumentDef --> ArgumentType
|
|
CommandResult +-- ResultType
|
|
CommandException --|> RuntimeException
|
|
|
|
BaseCommand ..> CommandContext : creates
|
|
AbstractCommand ..> CommandContext : creates
|
|
SubCommand ..> CommandResult : returns
|
|
}
|
|
|
|
@enduml
|