THIS PLUGIN IS A DEMO FOR A DEVELOPER API.
CustomFileConfig is an API that bridges the gap between other data representation formats and Spigot's Configuration API
Goals
The solution for supporting alternate configuration formats must be
- Extensible
- Fast
- Connect directly with the Bukkit Configuration File
- Serve as an alternative to the YamlConfiguration class
Problems Seeking to solve
- Uprooting entire code base to support an alternative configuration format
- End user complaints of configuration breaking due to misalignment of indent
- Easily switch to a more end user friendly configuration format without much hassle.
How it works
Each of the implementations work by acting as a translator between the configuration format and Bukkit's configuration api. These translation needs to happen in both way's which brings us to the Constructor and Representer classes. The Representer builds a configuration format representation of objects passed to it and the Constructor constructs Java objects from the configuration representation.
Format Comparison
Yaml
broken_sword:
==: org.bukkit.inventory.ItemStack
type: WOOD_SWORD
damage: 60
meta:
==: ItemMeta
meta-type: UNSPECIFIC
display-name: broken sword
lore:
- falling apart...
enchants:
DAMAGE_ALL: 9999
ARROW_DAMAGE: 9999
DAMAGE_UNDEAD: 9999
ARROW_KNOCKBACK: 34463
DURABILITY: 9999
DAMAGE_ARTHROPODS: 34463
KNOCKBACK: 9999
FIRE_ASPECT: 9999
LOOT_BONUS_MOBS: 5
ItemFlags:
- HIDE_ENCHANTS
- HIDE_ATTRIBUTES
myboots:
==: org.bukkit.inventory.ItemStack
type: LEATHER_BOOTS
meta:
==: ItemMeta
meta-type: LEATHER_ARMOR
display-name: Sonic's Speedys
lore:
- Use these
enchants:
PROTECTION_FALL: 5
ItemFlags:
- HIDE_ENCHANTS
- HIDE_ATTRIBUTES
Unbreakable: true
internal: H4sIAAAAAAAAAONiYOBkEHIsKSnKTCotSfXNT8lMy0wtKuZiYGBgZGbgCA31dPHNLy5hYJjDzczACeL6pCYC+ezre5kZ2Bxz80vzSkBqORh44ab4JeamMoimp+alFmUm6+Xml6XmpuaVBBekpqYAzfAvSC1KLMnMzwNqY+BgYMGjmoEBAKJKxwagAAAA
color:
==: Color
RED: 254
BLUE: 3
GREEN: 3Json
{
"broken_sword": {
"_BUKKITTYPE_": "org.bukkit.inventory.ItemStack",
"type": "WOOD_SWORD",
"damage": "60$i$",
"meta": {
"_BUKKITTYPE_": "ItemMeta",
"meta-type": "UNSPECIFIC",
"display-name": "broken sword",
"lore": [
"falling apart..."
],
"enchants": {
"DAMAGE_ALL": "9999$i$",
"ARROW_DAMAGE": "9999$i$",
"DAMAGE_UNDEAD": "9999$i$",
"ARROW_KNOCKBACK": "34463$i$",
"DURABILITY": "9999$i$",
"DAMAGE_ARTHROPODS": "34463$i$",
"KNOCKBACK": "9999$i$",
"FIRE_ASPECT": "9999$i$",
"LOOT_BONUS_MOBS": "5$i$"
},
"ItemFlags": [
"HIDE_ENCHANTS",
"HIDE_ATTRIBUTES"
]
}
},
"myboots": {
"_BUKKITTYPE_": "org.bukkit.inventory.ItemStack",
"type": "LEATHER_BOOTS",
"meta": {
"_BUKKITTYPE_": "ItemMeta",
"meta-type": "LEATHER_ARMOR",
"display-name": "Sonic\u0027s Speedys",
"lore": [
"Use these"
],
"enchants": {
"PROTECTION_FALL": "5$i$"
},
"ItemFlags": [
"HIDE_ENCHANTS",
"HIDE_ATTRIBUTES"
],
"Unbreakable": true,
"internal": "H4sIAAAAAAAAAONiYOBkEHIsKSnKTCotSfXNT8lMy0wtKuZiYGBgZGbgCA31dPHNLy5hYJjDzczACeL6pCYC+ezre5kZ2Bxz80vzSkBqORh44ab4JeamMoimp+alFmUm6+Xml6XmpuaVBBekpqYAzfAvSC1KLMnMzwNqY+BgYMGjmoEBAKJKxwagAAAA",
"color": {
"_BUKKITTYPE_": "Color",
"RED": "254$i$",
"BLUE": "3$i$",
"GREEN": "3$i$"
}
}
}
}XML
<?xml version="1.0" encoding="UTF-8"?>
<config>
<broken_sword>
<_BUKKITTYPE_>org.bukkit.inventory.ItemStack</_BUKKITTYPE_>
<type>WOOD_SWORD</type>
<damage>60</damage>
<meta>
<_BUKKITTYPE_>ItemMeta</_BUKKITTYPE_>
<meta-type>UNSPECIFIC</meta-type>
<display-name>broken sword</display-name>
<lore>
<_>falling apart...</_>
</lore>
<enchants>
<DAMAGE_ALL>9999</DAMAGE_ALL>
<ARROW_DAMAGE>9999</ARROW_DAMAGE>
<DAMAGE_UNDEAD>9999</DAMAGE_UNDEAD>
<ARROW_KNOCKBACK>34463</ARROW_KNOCKBACK>
<DURABILITY>9999</DURABILITY>
<DAMAGE_ARTHROPODS>34463</DAMAGE_ARTHROPODS>
<KNOCKBACK>9999</KNOCKBACK>
<FIRE_ASPECT>9999</FIRE_ASPECT>
<LOOT_BONUS_MOBS>5</LOOT_BONUS_MOBS>
</enchants>
<ItemFlags>
<_>HIDE_ENCHANTS</_>
<_>HIDE_ATTRIBUTES</_>
</ItemFlags>
</meta>
</broken_sword>
<myboots>
<_BUKKITTYPE_>org.bukkit.inventory.ItemStack</_BUKKITTYPE_>
<type>LEATHER_BOOTS</type>
<meta>
<_BUKKITTYPE_>ItemMeta</_BUKKITTYPE_>
<meta-type>LEATHER_ARMOR</meta-type>
<display-name>Sonic's Speedys</display-name>
<lore>
<_>Use these</_>
</lore>
<enchants>
<PROTECTION_FALL>5</PROTECTION_FALL>
</enchants>
<ItemFlags>
<_>HIDE_ENCHANTS</_>
<_>HIDE_ATTRIBUTES</_>
</ItemFlags>
<Unbreakable>true</Unbreakable>
<internal>H4sIAAAAAAAAAONiYOBkEHIsKSnKTCotSfXNT8lMy0wtKuZiYGBgZGbgCA31dPHNLy5hYJjDzczACeL6pCYC+ezre5kZ2Bxz80vzSkBqORh44ab4JeamMoimp+alFmUm6+Xml6XmpuaVBBekpqYAzfAvSC1KLMnMzwNqY+BgYMGjmoEBAKJKxwagAAAA</internal>
<color>
<_BUKKITTYPE_>Color</_BUKKITTYPE_>
<RED>254</RED>
<BLUE>3</BLUE>
<GREEN>3</GREEN>
</color>
</meta>
</myboots>
</config>HJson
{
broken_sword:
{
==: org.bukkit.inventory.ItemStack
type: WOOD_SWORD
damage: 60$i$
meta:
{
==: ItemMeta
meta-type: UNSPECIFIC
display-name: broken sword
lore:
[
falling apart...
]
enchants:
{
DAMAGE_ALL: 9999$i$
ARROW_DAMAGE: 9999$i$
DAMAGE_UNDEAD: 9999$i$
ARROW_KNOCKBACK: 34463$i$
DURABILITY: 9999$i$
DAMAGE_ARTHROPODS: 34463$i$
KNOCKBACK: 9999$i$
FIRE_ASPECT: 9999$i$
LOOT_BONUS_MOBS: 5$i$
}
ItemFlags:
[
HIDE_ENCHANTS
HIDE_ATTRIBUTES
]
}
}
myboots:
{
==: org.bukkit.inventory.ItemStack
type: LEATHER_BOOTS
meta:
{
==: ItemMeta
meta-type: LEATHER_ARMOR
display-name: Sonic's Speedys
lore:
[
Use these
]
enchants:
{
PROTECTION_FALL: 5$i$
}
ItemFlags:
[
HIDE_ENCHANTS
HIDE_ATTRIBUTES
]
Unbreakable: true
internal: H4sIAAAAAAAAAONiYOBkEHIsKSnKTCotSfXNT8lMy0wtKuZiYGBgZGbgCA31dPHNLy5hYJjDzczACeL6pCYC+ezre5kZ2Bxz80vzSkBqORh44ab4JeamMoimp+alFmUm6+Xml6XmpuaVBBekpqYAzfAvSC1KLMnMzwNqY+BgYMGjmoEBAKJKxwagAAAA
color:
{
==: Color
RED: 254$i$
BLUE: 3$i$
GREEN: 3$i$
}
}
}
}For more information, visit the forum link: https://www.spigotmc.org/threads/customfileconfiguration.326306/
Similar projects
Plugin →Let Me Despawn
Improves performance by tweaking mob despawn rules. Say bye to pesky unintentional persistent mobs.
25MSueta
JourneyMap
Real-time map used for mapping in-game or your browser as you explore.
14.7MSueta
Emotecraft
Create your own emotes in Minecraft.
7.5MSueta
Simple Tpa
A simple tpa plugin which sends requests
5.4MSueta
Common Network
Forge and Fabric Unified Networking Solution
3.9MSueta
Set Home
A lightweight plugin for players to set their homes.
3.8MSueta