{"id":14985651,"url":"https://github.com/mikigal/configapi","last_synced_at":"2025-09-08T23:36:21.285Z","repository":{"id":102381420,"uuid":"303419046","full_name":"mikigal/ConfigAPI","owner":"mikigal","description":"Config API for Bukkit 1.8 - 1.20 based on Dynamic Proxies","archived":false,"fork":false,"pushed_at":"2024-04-22T20:47:22.000Z","size":156,"stargazers_count":31,"open_issues_count":1,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-09-08T23:36:20.964Z","etag":null,"topics":["bukkit","bukkit-api","config","config-api","configuration","minecraft","parser","reflections","spigot","spigot-api","yaml","yml"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mikigal.png","metadata":{"files":{"readme":"README.MD","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2020-10-12T14:33:34.000Z","updated_at":"2025-08-18T16:47:17.000Z","dependencies_parsed_at":null,"dependency_job_id":"ef8f8558-f946-4f49-b410-9e911eb5a0b9","html_url":"https://github.com/mikigal/ConfigAPI","commit_stats":{"total_commits":43,"total_committers":4,"mean_commits":10.75,"dds":"0.11627906976744184","last_synced_commit":"807d31fb5e16edbb2534dc30d6ad453959eaff38"},"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"purl":"pkg:github/mikigal/ConfigAPI","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikigal%2FConfigAPI","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikigal%2FConfigAPI/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikigal%2FConfigAPI/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikigal%2FConfigAPI/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mikigal","download_url":"https://codeload.github.com/mikigal/ConfigAPI/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikigal%2FConfigAPI/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274231168,"owners_count":25245675,"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","status":"online","status_checked_at":"2025-09-08T02:00:09.813Z","response_time":121,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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","bukkit-api","config","config-api","configuration","minecraft","parser","reflections","spigot","spigot-api","yaml","yml"],"created_at":"2024-09-24T14:11:25.926Z","updated_at":"2025-09-08T23:36:21.259Z","avatar_url":"https://github.com/mikigal.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ConfigAPI\nConfig API for Bukkit 1.8 - 1.20 based on dynamic proxies\n\n## Features:\n - Works with Bukkit 1.8 - 1.20\n - Compatible with Java 8 - 17\n - Multiple configuration files\n - Fastly create configs via Java interface with `default` getters\n - Automatic generation of config's YAML file\n - Automatic update of config's file after add new methods to it's interface\n - Support for setting new values to config\n - System of serializers for custom objects (e.g. ItemStack, Location)\n - Automatic serialization of custom objects based on reflections (mainly for simple DAO/DTO objects)\n - Support of comments in YAML config\n - Automatic translation of `\u0026` based colors\n\n## Import\n#### Gradle\n```groovy\nmaven {\n    url = 'https://repo.mikigal.pl/releases'\n}\n\ncompile group: 'pl.mikigal', name: 'ConfigAPI', version: '1.2.6'\n```\n\n#### Maven\n```xml\n\u003crepository\u003e\n    \u003cid\u003emikigal-repo\u003c/id\u003e\n    \u003curl\u003ehttps://repo.mikigal.pl/releases\u003c/url\u003e\n\u003c/repository\u003e\n\n\u003cdependency\u003e\n    \u003cgroupId\u003epl.mikigal\u003c/groupId\u003e\n    \u003cartifactId\u003eConfigAPI\u003c/artifactId\u003e\n    \u003cversion\u003e1.2.6\u003c/version\u003e\n    \u003cscope\u003ecompile\u003c/scope\u003e\n\u003c/dependency\u003e\n```\n\n## How to use?\n#### Java code\n```java\npublic class TestPlugin extends JavaPlugin {\n\n    private static TestConfig testConfig;\n\n    @Override\n    public void onEnable() {\n        testConfig = ConfigAPI.init(\n            TestConfig.class, // Class of config's interface\n            NameStyle.UNDERSCORE, // Style of fields' name in YAML file\n            CommentStyle.INLINE, // Style of comments in YAML file\n            true, // Automatic translation of '\u0026' based colors\n            this // Instance of plugin\n        );\n\n        // You can simply access data from the config by getters\n        System.out.println(testConfig.getExampleMessage());\n        Bukkit.getPlayer(\"mikigal\").getInventory().addItem(testConfig.getAward());\n\n        // After calling setter new data are automatically saved to file\n        testConfig.setAward(new ItemStack(Material.DIRT));\n\n        // If you want to do something manually you can access instance of YamlConfiguration\n        testConfig.getBukkitConfiguration();\n    }\n\n    public static TestConfig getTestConfig() {\n        return testConfig;\n    }\n}\n\n@ConfigName(\"test.yml\") // Name of YAML file\npublic interface TestConfig extends Config {\n\n    @Comment(\"This comment will be saved to YAML file!\")\n    default String getExampleMessage() {\n        // Getter method should return default value of the field\n        return \"\u0026cIt's default value of example message\";\n    }\n\n    default ItemStack getAward() {\n        return Item.of(Material.DIAMOND_SWORD)\n            .name(\"\u0026cAward\")\n            .lore(\"\u0026aFirst line\", \"\u0026cSecond line\")\n            .toItem();\n    }\n\n    public void setAward(ItemStack award);\n\n    // Key of Map must be String\n    default Map\u003cString, Integer\u003e getValues() {\n        Map\u003cString, Integer\u003e map = new HashMap\u003c\u003e();\n        map.put(\"a\", 1);\n        map.put(\"b\", 2);\n\n        return map;\n    }\n\n    default List\u003cLocation\u003e getSpawnPoints() {\n        World world = Bukkit.getWorld(\"world\");\n        return Arrays.asList(\n            new Location(world, 0, 100, 0),\n            new Location(world, 10, 90, 10, 90f, 0f),\n            new Location(world, 20, 80, 20, 0f, 180f)\n        );\n    }\n}\n```\n\n#### Automatic generated YAML from above Java code\n```yaml\nexample_message: '\u0026cIt''s default value of example message' # This comment will be saved to YAML file!\nspawn_points:\n  structure: java.util.ArrayList\n  type: org.bukkit.Location\n  '0':\n    world: world\n    x: 0.0\n    y: 100.0\n    z: 0.0\n    yaw: 0.0\n    pitch: 0.0\n  '1':\n    world: world\n    x: 10.0\n    y: 90.0\n    z: 10.0\n    yaw: 90.0\n    pitch: 0.0\n  '2':\n    world: world\n    x: 20.0\n    y: 80.0\n    z: 20.0\n    yaw: 0.0\n    pitch: 180.0\nvalues:\n  structure: java.util.HashMap\n  type: java.lang.Integer\n  a: 1\n  b: 2\naward:\n  material: DIAMOND_SWORD\n  amount: 1\n  name: '\u0026cAward'\n  lore:\n    structure: java.util.ArrayList\n    type: java.lang.String\n    '0': '\u0026aFirst line'\n    '1': '\u0026cSecond line'\n```\n\n## Serializers\n### API has built-in serializers for:\n - ItemStack\n - Location\n - PotionEffect\n - ShapedRecipe\n - UUID\n\n#### Automatic serializing of custom objects\nIf you have some simple DAO/DTO object you can serialize it without writing custom serializer!\n\n```java\npublic class User implements Serializable { // It must implement Serializable interface\n    private String username;\n    private int kills;\n    private transient String temporary; // Transient fields will not be serialized!\n\n    public User() { // It MUST have no-args constructor!\n\n    }\n\n    public User(String username, int kills, String temporary) {\n        this.username = username;\n        this.kills = kills;\n        this.temporary = temporary;\n    }\n\n    // Getters and setters...\n}\n\n@ConfigName(\"config\")\npublic interface MyConfig extends Config {\n\n    void setUser(User user);\n\n    default User getTest() {\n        return new User(\"mikigal\", 1, \"some text\");\n    }\n}\n```\n\n#### You can also make your own serializers\nFor more advanced objects you can make your own serializer\n```java\npublic class PotionEffectSerializer extends Serializer\u003cPotionEffect\u003e {\n\n    @Override\n    protected void saveObject(String path, PotionEffect object, BukkitConfiguration configuration) {\n        // In saveObject() method you have to set data of object to config. You can use set() method to set another object which need serialization too\n        configuration.set(path + \".type\", object.getType().getName());\n        configuration.set(path + \".duration\", object.getDuration());\n        configuration.set(path + \".amplifier\", object.getAmplifier());\n    }\n\n    @Override\n    public PotionEffect deserialize(String path, BukkitConfiguration configuration) {\n        // In deserialize() method you have to load data from config and return instance of object\n        PotionEffectType type = PotionEffectType.getByName(configuration.getString(path + \".type\"));\n        int duration = configuration.getInt(path + \".duration\");\n        int amplifier = configuration.getInt(path + \".amplifier\");\n\n        if (type == null) {\n            throw new InvalidConfigFileException(\"Invalid PotionEffect type (path: \" + path + \")\");\n        }\n\n        return new PotionEffect(type, duration, amplifier);\n    }\n}\n\npublic class TestPlugin extends JavaPlugin {\n\n    @Override\n    public void onEnable() {\n        // Remember to register you Serializer before use!\n        ConfigAPI.registerSerializer(PotionEffect.class, new PotionEffectSerializer());\n\n        // Init your configs...\n\n    }\n}\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmikigal%2Fconfigapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmikigal%2Fconfigapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmikigal%2Fconfigapi/lists"}