{"id":13775119,"url":"https://github.com/OkaeriPoland/okaeri-configs","last_synced_at":"2025-05-11T07:31:57.058Z","repository":{"id":38423274,"uuid":"350087681","full_name":"OkaeriPoland/okaeri-configs","owner":"OkaeriPoland","description":"Simple Java/POJO config library written with love and Lombok","archived":false,"fork":false,"pushed_at":"2024-08-28T15:31:26.000Z","size":977,"stargazers_count":76,"open_issues_count":9,"forks_count":11,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-08-28T17:13:49.380Z","etag":null,"topics":["bukkit","bungee","config","gson","hjson","hocon","java","json","minecraft","paper","snakeyaml","spigot","yaml"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/OkaeriPoland.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-03-21T18:41:54.000Z","updated_at":"2024-08-28T15:31:31.000Z","dependencies_parsed_at":"2024-08-28T17:13:51.999Z","dependency_job_id":null,"html_url":"https://github.com/OkaeriPoland/okaeri-configs","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OkaeriPoland%2Fokaeri-configs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OkaeriPoland%2Fokaeri-configs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OkaeriPoland%2Fokaeri-configs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OkaeriPoland%2Fokaeri-configs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/OkaeriPoland","download_url":"https://codeload.github.com/OkaeriPoland/okaeri-configs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225027333,"owners_count":17409413,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bukkit","bungee","config","gson","hjson","hocon","java","json","minecraft","paper","snakeyaml","spigot","yaml"],"created_at":"2024-08-03T17:01:34.154Z","updated_at":"2024-11-17T10:30:32.018Z","avatar_url":"https://github.com/OkaeriPoland.png","language":"Java","funding_links":[],"categories":["Configuration","配置管理"],"sub_categories":["语音合成"],"readme":"# Okaeri Configs\n\n![License](https://img.shields.io/github/license/OkaeriPoland/okaeri-configs)\n![Total lines](https://img.shields.io/tokei/lines/github/OkaeriPoland/okaeri-configs)\n![Repo size](https://img.shields.io/github/repo-size/OkaeriPoland/okaeri-configs)\n![Contributors](https://img.shields.io/github/contributors/OkaeriPoland/okaeri-configs)\n[![Discord](https://img.shields.io/discord/589089838200913930)](https://discord.gg/hASN5eX)\n\n## Supported platforms (general use)\n\nGeneral implementations based on standard format libraries directly.\n\n- **YAML**\n    - 🌟 [yaml-snakeyaml](https://github.com/OkaeriPoland/okaeri-configs/tree/master/yaml-snakeyaml): YAML for everyone! Your best choice for public projects and their configurations\n- **HJSON**\n    - 🌟 [hjson-java](https://github.com/OkaeriPoland/okaeri-configs/tree/master/hjson): Human JSON is the best choice for your JSON configuration, small (core+55kB) but yet powerful\n- **JSON**\n    - 🌟 [Google GSON](https://github.com/OkaeriPoland/okaeri-configs/tree/master/json-gson): ideal for GSON lovers, best suited for in-app storage or advanced user configurations\n    - [json-simple](https://github.com/OkaeriPoland/okaeri-configs/tree/master/json-simple): fairly limited but still working, no pretty print, probably best suited for simple in-app storage\n- **HOCON**\n    - [Lightbend (HOCON) Config](https://github.com/OkaeriPoland/okaeri-configs/tree/master/hocon-lightbend): use Human-Optimized Config Object Notation for your configs, but beware of limitations\n\n## Supported platforms (environment dependant)\n\nSpecial implementations for safe use in specific environment, eg. gameservers.\n\n- **Bukkit/Spigot/Paper (Minecraft server)**\n    - 🌟 [Minecraft (Bukkit) YamlConfiguration](https://github.com/OkaeriPoland/okaeri-configs/tree/master/yaml-bukkit): no need for additional dependencies when writing Spigot/Paper plugins\n      (best used with [okaeri-platform](https://github.com/OkaeriPoland/okaeri-platform))\n- **BungeeCord/Waterfall (Minecraft proxy)**\n    - 🌟 [Minecraft (Bungee) YamlConfiguration](https://github.com/OkaeriPoland/okaeri-configs/tree/master/yaml-bungee): no need for additional dependencies when writing BungeeCord/Waterfall plugins\n- **Velocity (Minecraft proxy), Sponge (Minecraft server)**\n    - currently no ready adapters, but use with [Google GSON](https://github.com/OkaeriPoland/okaeri-configs/tree/master/json-gson),\n      [Lightbend (HOCON) Config](https://github.com/OkaeriPoland/okaeri-configs/tree/master/hocon-lightbend), [SnakeYAML](https://github.com/OkaeriPoland/okaeri-configs/tree/master/yaml-snakeyaml)\n      is possible (remember to exclude format specific dependencies (eg. gson) when shading, these should be provided by the environment directly).\n\n## Validation extensions\n\n- 🌟 [Okaeri Validator](https://github.com/OkaeriPoland/okaeri-configs/tree/master/validator-okaeri): simple validator with jakrataee-like annotations but much less code (+15kB)\n- [Jakarta EE](https://github.com/OkaeriPoland/okaeri-configs/tree/master/validator-jakartaee): hibernate-validator based with full Jakarta Bean Validation 3.0 support\n\n## Serialization extensions\n\n- 🌟 [serdes-commons](https://github.com/OkaeriPoland/okaeri-configs/tree/master/serdes-commons): for common but not mandatory types, e.g. Instant, Pattern, Duration\n- [serdes-bukkit](https://github.com/OkaeriPoland/okaeri-configs/tree/master/serdes-bukkit): for Minecraft (Bukkit) types\n- [serdes-bucket4j](https://github.com/OkaeriPoland/okaeri-configs/tree/master/serdes-bucket4j): for [vladimir-bukhtoyarov/bucket4j](https://github.com/vladimir-bukhtoyarov/bucket4j) types\n\n## Recommendations\n\nFor `standalone platforms` [hjson](https://github.com/OkaeriPoland/okaeri-configs/tree/master/hjson) module is the best choice, it supports all the features, eg. full comment support.\nCombine it with [Okaeri Validator](https://github.com/OkaeriPoland/okaeri-configs/tree/master/validator-okaeri) for the best config experience. \nTotal of only ~155kB, less than half of just the latest snakeyaml 1.28 which is 319kB!\n\nFor `any platform` if some form of config validation is applicable (eg. requiring that integer is positive) it is recommended to use [Okaeri Validator](https://github.com/OkaeriPoland/okaeri-configs/tree/master/validator-okaeri) when possible.\nOnly few kilobytes but makes for a lot better experience for the end-user and developer too.\n\nFor `any platform` if some form of the i18n/translation is needed, you may be interested in [okaeri-i18n](https://github.com/OkaeriPoland/okaeri-i18n) which can use okaeri-configs as a translation source.\n\n## Genesis\n\nOkaeri's configuration library is an easy way to use java classes as config adapters:\n\n- Supports different environments with minimal hassle and relatively small footprint\n- Allows for even complex types to be serialized/deserialized\n- Enhances your configs with durable comments and strongly-typed fields\n- Provides ability to access typed fields with the classic getters and setters\n- Core library is just ~100kB in size, most of the adapters require only ~100 lines of code\n\n## Example\n\n```java\n// getter/setter from lombok recommended\n@Header(\"################################################################\")\n@Header(\"#                                                              #\")\n@Header(\"#    okaeri-configs test                                       #\")\n@Header(\"#                                                              #\")\n@Header(\"#    Nie wiesz jak uzywac? Zerknij do dokumentacji!            #\")\n@Header(\"#    https://github.com/OkaeriPoland/okaeri-configs            #\")\n@Header(\"#                                                              #\")\n@Header(\"#    Trouble using? Check out the documentation!               #\")\n@Header(\"#    https://github.com/OkaeriPoland/okaeri-configs            #\")\n@Header(\"#                                                              #\")\n@Header(\"################################################################\")\n// optional global key formatting (may yield unexpected names, use at own risk)\n// @Names(strategy = NameStrategy.HYPHEN_CASE, modifier = NameModifier.TO_LOWER_CASE)\npublic class TestConfig extends OkaeriConfig {\n\n    @Variable(\"APP_TOKEN\") // use jvm property or environment variable if available\n    @Comment({\"Klucz prywatny API\", \"API secret\"})\n    private String token = \"\";\n\n    @CustomKey(\"myList\")\n    @Comment({\"Example list\", \"providing @CustomKey demonstration\"})\n    private List\u003cString\u003e exampleList = Collections.singletonList(\"127.0.0.1\");\n\n    @Comment({\"Simple maps\", \"ready to go\"})\n    private Map\u003cString, String\u003e messages = Collections.singletonMap(\"test\", \"testing\");\n\n    @Comment({\"Test complex map 1\", \"looks like complex maps are working too\"})\n    private Map\u003cString, Map\u003cString, Integer\u003e\u003e complexMap = Collections.singletonMap(\"aa\", Collections.singletonMap(\"bb\", 222));\n\n    @Comment(\"Test complex map 2\")\n    private Map\u003cString, Map\u003cInteger, String\u003e\u003e complexMap2 = Collections.singletonMap(\"bb\", Collections.singletonMap(232, \"aadda\"));\n\n    @Comment(\"Custom objects can be serialized\")\n    private Location spawn = new Location(null, 1, 2, 3, 4, 5);\n\n    @Comment(\"Non-string map keys\")\n    private Map\u003cInteger, String\u003e levels = Collections.singletonMap(1, \"aaaaaa\");\n\n    @Comment(\"okaeri-configs likes classes more than primitives\")\n    private Integer version = 2;\n\n    @Comment({\"Test enum\", \"very nice\", \"right?\"})\n    private TestEnum testEnum = TestEnum.ONE_THO_THREE;\n\n    @Comment(\"Test enum list\")\n    private List\u003cTestEnum\u003e testEnumList = Arrays.asList(TestEnum.ONE, TestEnum.ONE_THO_THREE);\n\n    @Comment(\"Test enum set\")\n    private Set\u003cTestEnum\u003e testEnumSet = new HashSet\u003c\u003e(Arrays.asList(TestEnum.ONE, TestEnum.ONE_THO_THREE));\n\n    @Comment(\"Test custom object list\")\n    @Comment(\".. and repeating comments\")\n    private List\u003cLocation\u003e testLocationList = Arrays.asList(\n            new Location(null, 1, 2, 3, 4, 5),\n            new Location(null, 3, 3, 5, 6, 9)\n    );\n\n    @Comment(\"Uber-complex-map test\")\n    private Map\u003cTestEnum, Location\u003e enumToLocationMap = Collections.singletonMap(TestEnum.THREE, new Location(null, 1, 2, 3, 4, 5));\n\n    @CustomKey(\"listToUberComplexMap\")\n    @Comment(\"List-to-Uber-complex-map test\")\n    private List\u003cMap\u003cTestEnum, Location\u003e\u003e listMapEnumToLocationMap = Arrays.asList(\n            Collections.singletonMap(TestEnum.THREE, new Location(null, 1, 2, 3, 4, 5)),\n            Collections.singletonMap(TestEnum.ONE_THO_THREE, new Location(null, 3, 2, 3, 4, 5))\n    );\n\n    @Comment(\"Math test\")\n    private BigInteger bigInteger = new BigInteger(\"999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999876543210\");\n\n    @Comment(\"Subconfigs are the way!\")\n    private StorageConfig storage = new StorageConfig();\n\n    // getter/setter from lombok recommended\n    public class StorageConfig extends OkaeriConfig {\n\n        @Variable(\"APP_STORAGE_URI\")\n        @Comment(\"FLAT   : not applicable, plugin controlled\")\n        @Comment(\"REDIS  : redis://localhost\")\n        @Comment(\"MYSQL  : jdbc:mysql://localhost:3306/db?user=root\u0026password=1234\")\n        @Comment(\"H2     : jdbc:h2:file:./plugins/OkaeriPlatformBukkitExample/storage;mode=mysql\")\n        private String uri = \"redis://localhost\";\n\n        /* ... */\n    }\n\n    // in-memory only field\n    private transient Instant start = Instant.now();\n\n    /* ... */\n}\n```\n\n## Usage\n\n### With create(clazz, initializer)\n\n```java\n// recommended\nTestConfig config = ConfigManager.create(TestConfig.class, (it) -\u003e {\n    it.withConfigurer(new YamlBukkitConfigurer(), new SerdesBukkit()); // specify configurer implementation, optionally additional serdes packages\n    it.withBindFile(new File(this.getDataFolder(), \"config.yml\")); // specify Path, File or pathname\n    it.withRemoveOrphans(true); // automatic removal of undeclared keys\n    it.saveDefaults(); // save file if does not exists\n    it.load(true); // load and save to update comments/new fields \n});\n```\n\n### With create(clazz)\n\n```java\nTestConfig config = (TestConfig) ConfigManager.create(TestConfig.class)\n    .withConfigurer(new YamlBukkitConfigurer(), new SerdesBukkit()) // specify configurer implementation, optionally additional serdes packages\n    .withBindFile(new File(this.getDataFolder(), \"config.yml\")) // specify Path, File or pathname\n    .withRemoveOrphans(true); // automatic removal of undeclared keys\n    .saveDefaults() // save file if does not exists\n    .load(true); // load and save to update comments/new fields\n````\n\n## Supported types\n\n- Subconfigs: Any OkaeriConfig class can be used in the field of another\n- Serializable: Treated similarly to subconfigs but now with less bloat\n- Basic Java types: Boolean, Byte, Character, Double, Float, Integer, Long, Short, String\n- Primitives: boolean, byte, char, double, float, int, long, short\n- Math types: `java.math.BigInteger`, `java.math.BigDecimal`\n- Complex types:\n    - `Map\u003cK, V\u003e`: results in LinkedHashMap\n    - `Set\u003cT\u003e`: results in LinkedHashSet\n    - `List\u003cT\u003e`: results in ArrayList\n    - Any type assignable from Map or Collection if non-interface type is used and default constructor is available\n- Enum types: any enum is automatically transformed using `valueOf()` (with case-insensitive fallback) and `name()`\n- Custom types using `ObjectSerializer`/`ObjectTransformer` (see in supported platforms)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FOkaeriPoland%2Fokaeri-configs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FOkaeriPoland%2Fokaeri-configs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FOkaeriPoland%2Fokaeri-configs/lists"}