Skip to content

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

PropertyValue
Module IDemaki-corelib
Version3.4.0
Main Classnet.pekocraft.emaki.corelib.EmakiCoreLib
CommandsNone
Soft DependenciesVault, 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 InterfaceDescription
1ActionServiceAction parsing and execution
2GuiServiceGUI template loading and session management
3ItemSourceServiceItem source resolution and retrieval
4AssemblyServiceItem assembly and structured rendering
5PdcServicePDC persistent data storage
6EconomyServiceEconomy operation bridging
7ConditionServiceCondition expression evaluation
8ExpressionServiceMath expression evaluation
9PlaceholderServicePlaceholder resolution
10SoundServiceSound playback
11TemplateServiceAction template management
12CooldownServiceCooldown management
13LanguageServiceMulti-language text management
14ConfigServiceConfiguration file management
15NamespaceRegistryAssembly namespace registration
16CacheServiceCache management
17SignatureServiceData signing and verification

Example of obtaining a service:

java
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:

LibraryPurpose
adventure-api / adventure-platform-bukkitMiniMessage and Component text processing
exp4jMath expression parsing and evaluation
boosted-yamlEnhanced YAML configuration read/write

Configuration Files

config.yml

yaml
# 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
yaml
# 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.

Released under the GPL-3.0 License