EmakiCoreLib Overview
EmakiCoreLib is the core foundation library of the Emaki plugin ecosystem, providing unified service registration, GUI framework, action system, item source abstraction, assembly rendering, PDC persistence, economy bridging, condition evaluation, and expression engine capabilities for all feature modules.
Basic Information
| Property | Value |
|---|---|
| Module ID | emaki-corelib |
| Version | 3.4.0 |
| Main Class | net.pekocraft.emaki.corelib.EmakiCoreLib |
| Commands | None |
| Soft Dependencies | Vault, ExcellentEconomy, PlaceholderAPI, CraftEngine, ItemsAdder, NeigeItems, MMOItems, Nexo |
Core Responsibilities
EmakiCoreLib handles the following core responsibilities:
- GUI Framework — YAML template-based chest GUI system with async rendering and sound configuration support
- Action System — Unified action execution pipeline with support for condition, probability, delay, and other control prefixes
- Item Source — Cross-plugin item retrieval abstraction layer supporting vanilla and various third-party item plugins
- Assembly System — Structured display engine managing layered rendering of item names and lore
- PDC Service — Partitioned persistent storage based on PersistentDataContainer
- Economy Bridge — Unified wrapper for economy plugins like Vault / ExcellentEconomy
- Condition System — Condition evaluation engine supporting comparison operators and logical combinations
- Expression Engine — Math expression evaluation based on exp4j with random distribution support
- Bootstrap — Module lifecycle and service registration management
- Custom Block Bridge (CustomBlockBridge) — Shared block identification API for CraftEngine, ItemsAdder, and Nexo, used by Cooking and other modules to check whether a world block is a custom block station
- PDC Attribute Gateway (PdcAttributeGateway) — Discovers and invokes EmakiAttribute's PDC attribute API via Bukkit ServicesManager, used by Forge, Strengthen, Gem, and other modules to write attribute payloads to items
Service Registry
EmakiCoreLib manages all service instances through EmakiServiceRegistry. Each module registers its provided services with the registry during startup, and other modules obtain service references through the registry.
Registered Services
The following are all 17 services registered by CoreLib:
| # | Service Interface | Description |
|---|---|---|
| 1 | ActionService | Action parsing and execution |
| 2 | GuiService | GUI template loading and session management |
| 3 | ItemSourceService | Item source resolution and retrieval |
| 4 | AssemblyService | Item assembly and structured rendering |
| 5 | PdcService | PDC persistent data storage |
| 6 | EconomyService | Economy operation bridging |
| 7 | ConditionService | Condition expression evaluation |
| 8 | ExpressionService | Math expression evaluation |
| 9 | PlaceholderService | Placeholder resolution |
| 10 | SoundService | Sound playback |
| 11 | TemplateService | Action template management |
| 12 | CooldownService | Cooldown management |
| 13 | LanguageService | Multi-language text management |
| 14 | ConfigService | Configuration file management |
| 15 | NamespaceRegistry | Assembly namespace registration |
| 16 | CacheService | Cache management |
| 17 | SignatureService | Data signing and verification |
Example of obtaining a service:
ActionService actionService = EmakiServiceRegistry.get(ActionService.class);Tip
All services are registered during CoreLib's onEnable phase. Modules that depend on CoreLib should declare EmakiCoreLib in their softdepend or depend to ensure correct loading order.
Auto-loaded Libraries
CoreLib automatically loads the following libraries at startup, so other modules don't need to include them again:
| Library | Purpose |
|---|---|
adventure-api / adventure-platform-bukkit | MiniMessage and Component text processing |
exp4j | Math expression parsing and evaluation |
boosted-yaml | Enhanced YAML configuration read/write |
Configuration Files
config.yml
# Configuration file version, do not modify manually
config_version: 3
# Action template definitions
action:
templates:
# Template name -> action list
notify_and_sound:
- "sendmessage message=<green>操作成功!"
- "playsound sound=entity.experience_orb.pickup volume=1.0 pitch=1.2"
reward_basic:
- "givemoney amount=100"
- "giveexp amount=50"
- "sendmessage message=<gold>你获得了基础奖励!"Warning
config_version is automatically managed by the plugin for configuration migration. Do not modify this value manually, as it may cause configurations to be overwritten or migration issues.
Action Templates
Templates defined under action.templates can be referenced in any action list via the usetemplate action. See Action System for details.
Language System
CoreLib uses a file-based multi-language system with language files stored in the lang/ directory.
plugins/EmakiCoreLib/
├── config.yml
└── lang/
├── zh_CN.yml ← Default language
├── en_US.yml
└── ...- The default language is
zh_CN(Simplified Chinese) - Language files use standard YAML format with message IDs as keys and MiniMessage-formatted text as values
- Other modules can register and query their own language keys through
LanguageService
# lang/zh_CN.yml example
messages:
prefix: "<gray>[<gradient:gold:yellow>Emaki</gradient>]</gray> "
no_permission: "{prefix}<red>你没有权限执行此操作。"
player_only: "{prefix}<red>该命令只能由玩家执行。"
reload_success: "{prefix}<green>配置已重新加载。"Tip
Language files support MiniMessage format, including gradient colors, hover text, click events, and other rich text features.