-
Notifications
You must be signed in to change notification settings - Fork 0
04 configuration
KLibrary employs a format-agnostic layer called ConfigNode. This allows the library to easily deserialize Bukkit YamlConfiguration or any other structured format into its core objects (Action, Requirement).
When defining a block in YAML, it is passed into KLibrary's deserializers as a ConfigNode. The node handles parsing specific values cleanly without needing a tight couple to the Spigot API.
Here is a common representation of how actions and requirements are configured inside a menu/*.yml or a config.yml.
my-custom-event:
# The Requirements list block
requirements:
has-vip:
type: "permission"
permission: "myplugin.vip"
deny-actions:
- "[message] <red>You must be a VIP to do this!"
- "[sound] ENTITY_VILLAGER_NO;1.0;1.0"
# The Actions list block
actions:
- "[message] <green>Welcome to the VIP zone!"
- "[console] give %player_name% diamond 1"
- "[sound] ENTITY_PLAYER_LEVELUP;1.0;1.0"Actions are typically represented as Lists of Strings.
Each string consists of a tag [action_type] followed by the arguments.
For example: "[message] <gold>Hello World" maps to the message Action identifier.
Requirements are mapped as a key-value section.
Each requirement definition has a type string (which matches the requirement's registered identifier), the properties of that requirement (like permission above), and an optional deny-actions list, which executes if the requirement fails.
For inventories, KLibrary provides InventoryConfigDeserializer to translate typical YAML configurations directly into GUI layouts.
my-gui:
title: "My Awesome GUI"
size: 27
items:
exit-button:
slot: 26
material: BARRIER
name: "<red>Close Menu"
actions:
- "[close]"By passing the my-gui section into the deserializer, KLibrary constructs the entire InventoryProvider and maps the defined actions onto the exit-button click listener automatically.