Focus Configuration
About 1083 wordsAbout 4 min
A focus is defined by a YAML file in plugins/MyCompany/focus/. The file name is the focus id, so mob.yml defines the mob focus.
Tips
The trees inside focus/none.yml and focus/mob.yml are examples. You can add, remove, rename or rewrite expertises at any time, and the pages in this section describe the default content.
The current build loads the focus ids none and mob; a new focus file is not picked up as a third focus. The trees inside the two files, however, are fully editable.
The file focus.yml in the plugin folder still contains a focus-tree section, but that section is no longer read. Always edit the files inside the focus folder.
File generation
focus/none.ymlandfocus/mob.ymlare copied from the jar as examples on the first start, whengenerate-default-configistrue.- At the end of that startup the plugin sets
generate-default-configback tofalse. - If a focus file is missing, set
generate-default-config: trueinconfig.ymland restart the server to generate it again. Do not delete a focus file that companies are still using; the plugin loads their tree at startup.
Focus file structure
id: mob
label: Mob
description:
- 'Focus on killing mobs'
- 'Four branches: zombie loot, general loot, combat and company profit.'
condition:
company_money: 60000
expertise:
zombie_loot_1:
label: 'More Zombie Loot I'
description:
- '&7Zombie drops: &a30% &7chance of &a+1 rotten flesh&7.'
value_type: boolean
default:
value: 'false'
condition:
company_money: 15000
effect:
mob_drops_add:
ZOMBIE:
- 'ROTTEN_FLESH,+1,30'
action:
console_command:
- 'eco give %player% 500'| Key | Description |
|---|---|
id | Informational only. The file name is the actual focus id. |
label | Display name of the focus. Falls back to the focus id. |
description | List of lore lines. Color codes with & are supported. |
condition | Conditions for selecting the focus. Optional. Money conditions are checked but not consumed here. |
expertise | The nodes of the tree. The section must exist. |
Expertise fields
| Key | Description |
|---|---|
label | Display name of the node. Falls back to No Label. |
description | List of lore lines shown in the menu. |
value_type | boolean, integer, double or string. Defaults to boolean when omitted. |
default.value | The stored value before the node is learned. Must match value_type. |
condition | Conditions for unlocking the node. Required; use condition: {} for a node with no requirement. |
effect | Bonuses applied while the node is learned. Optional. |
action | Actions executed once when the node is unlocked. Optional. |
Warning
Every expertise must have a condition section, even if it is empty. A node without the section makes the focus fail to load, so write condition: {} when the node has no requirement.
Adding, editing and removing expertises
The tree is read from the file at startup, so any of the following changes work without touching the code. Restart the server after the edit.
- Add a node by adding a new key under
expertisewith the fields shown above. A node withcondition: {}is available immediately. - Remove a node by deleting its block. Its saved progress stays in the company data but is ignored. Check whether another node still lists it in a prerequisite or in
disable_expertise/enable_expertise. - Rename a node by changing its key. The company loses the progress of the old id, because progress is stored by id.
- Edit costs, conditions, effects, actions, labels and descriptions of an existing node in place.
- Check the result by opening the focus menu in game; the tree shows the current labels, conditions and costs of the file.
Keep ids unique across both focus files. An id used twice overwrites the configuration and label of the earlier one.
Keep the value type of an existing node stable. Changing value_type later makes old saved data unreadable for that node.
Localization
On the first start with generate-default-config: true, the plugin overwrites the labels and descriptions of every focus and expertise with the texts from the selected language file:
focus:
focus:
mob:
label: 'Mob'
description:
- 'Focus on killing mobs'
expertise:
zombie_loot_1:
label: 'More Zombie Loot I'
description:
- '&7Zombie drops: &a30% &7chance of &a+1 rotten flesh&7.'The texts are written back into focus/*.yml, so the files inside focus/ become the source of truth after that first start.
- To apply a language change afterwards, set
generate-default-config: trueinconfig.ymland restart. - A missing language entry produces an empty description, or the label
No Labelfor an expertise. - The menu titles and button texts are separate; they live under
menu.focusandmenu.focus_listin the language file.
Applying changes
After editing anything in focus/, restart the server. The configuration reload is mainly for menus and language files; applying focus changes with a restart avoids stale focus lists.
Progress is stored by expertise id. After a restart:
- new nodes start locked with their
default.value - removed nodes are no longer loaded, but their saved progress stays in the company data
- renaming an id makes the company lose the progress of the old id
Validation rules
- Expertise ids must be unique across all focus files, because conditions and labels are cached by id.
conditionids andeffectids are case-sensitive. Use the exact lower-case ids from Conditions, Effects and Actions.- An unknown condition id is ignored silently, which effectively removes the requirement. Check the spelling carefully.
- Unknown effect and action ids are logged as a warning and skipped.
- Malformed effect arguments, such as an unknown material or entity type, throw an error while the focus is loaded.
- Entity keys are Bukkit entity types (
ZOMBIE,SKELETON,CREEPER); item keys are Bukkit materials (ROTTEN_FLESH);ALLis accepted in both places.
Troubleshooting
| Symptom | Cause |
|---|---|
| A learned node disappears from the menu | It was disabled by a disable_expertise action. Learn the node that enables it again. |
| Edits have no effect | The server was not restarted. Restart after editing focus/*.yml. |
An expertise shows No Label | The language file has no entry for it, and first-start localization already ran. |
| A focus file is not created | generate-default-config is already false. Set it to true and restart. |
| A condition line is missing from the lore | The condition id is unknown, so the plugin ignored it. Check the spelling. |
| A condition never succeeds | The expertise id belongs to another focus, or the kill counter has not reached the required amount. |
| The plugin fails to load the focus | An expertise is missing condition, or an effect argument is invalid. Check the console for the focus and expertise id. |