{"id":25959783,"url":"https://github.com/mkotb/configapi","last_synced_at":"2025-03-04T18:48:29.706Z","repository":{"id":9609948,"uuid":"62348320","full_name":"mkotb/ConfigAPI","owner":"mkotb","description":"GSON-like ORM for Bukkit YAML API's","archived":false,"fork":false,"pushed_at":"2024-02-21T12:38:17.000Z","size":69,"stargazers_count":25,"open_issues_count":2,"forks_count":5,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-08-04T09:09:13.544Z","etag":null,"topics":["bukkit","config","config-api","gson","minecraft"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mkotb.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}},"created_at":"2016-06-30T23:26:53.000Z","updated_at":"2024-08-04T09:09:13.544Z","dependencies_parsed_at":"2022-07-18T10:38:54.555Z","dependency_job_id":null,"html_url":"https://github.com/mkotb/ConfigAPI","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/mkotb%2FConfigAPI","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkotb%2FConfigAPI/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkotb%2FConfigAPI/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkotb%2FConfigAPI/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mkotb","download_url":"https://codeload.github.com/mkotb/ConfigAPI/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241904718,"owners_count":20040021,"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","config","config-api","gson","minecraft"],"created_at":"2025-03-04T18:48:29.126Z","updated_at":"2025-03-04T18:48:29.690Z","avatar_url":"https://github.com/mkotb.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ConfigAPI\nThis project is a GSON-like project for Bukkit's YML Config API. This project is on maven central! You can add it to your project using the following:\n\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003exyz.mkotb\u003c/groupId\u003e\n  \u003cartifactId\u003econfig-api\u003c/artifactId\u003e\n  \u003cversion\u003e1.0.1\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\nIf you're not familiar with GSON, let me show you a quick example of what you can do with this API:\n\n```java\npublic class MyPlugin extends JavaPlugin {\n    private MyConfig myConfig;\n    private ConfigFactory configFactory = ConfigFactory.newFactory(this);\n\n    @Override\n    public void onEnable() {\n        myConfig = configFactory.fromFile(\"config\", MyConfig.class);\n        getLogger().info(myConfig.getStartMessage());\n\n        if (myConfig.myFavouriteNumbers != null) {\n            getLogger().info(myConfig.myFavouriteNumbers.toString());\n        }\n    }\n\n    @Override\n    public void onDisable() {\n        // if we changed values in my config while the server is up\n        // we should save it\n        configFactory.save(\"config\", myConfig);\n    }\n}\n\n@Comment(\"This is my header comment\")\npublic class MyConfig {\n                    // init values will be saved as part of the \"default config\"\n    private String startMessage = \"This awesome bukkit plugin has started!\";\n    @Comment(\"Put in your favourite number here!\")\n    @RequiredField // if this field is not set in the config file due to user error\n                   // an exception will be thrown\n    private int myFavouriteNumber = 3;\n                   // lists, sets, queues, maps, and arrays are supported!\n    List\u003cInteger\u003e myFavouriteNumbers;\n                   // supports concurrency classes!\n    private AtomicInteger myFavouriteAtomicNumber = new AtomicInteger(4);\n                   // myWeapon will be set if it's in the config but won't exist\n                   // by default\n    private ItemStack myWeapon;\n                   // additionally objects within the config are allowed\n    private PartOfConfig part;\n\n    public String getStartMessage() {\n        return startMessage;\n    }\n}\n\npublic class PartOfConfig {\n    private String hi = \"my name is billy\";\n}\n```\n\nIn the following example, we displayed majority of the features available in the API. The `fromFile()` method takes care of all the initial processes you may need, such as creating the new file and placing default values. Many additional classes such as color, offline players, and vectors are supported to be saved. In the future, extensibility to the Adapter API will be added to where you can use your own data types which can be converted.\n\n## Interaction with the File\n\nAs of currently, if you were to setup and run this plugin, it would write the following to `config.yml` using the default values:\n\n```yml\n# This is my header comment\nstart-message: This awesome bukkit plugin has started!\n# Put in your favourite number here!\nmy-favourite-number: 3\nmy-favourite-atomic-number: 4\n```\n\nAs you can see, it only saved the fields which were already set as defaults. If you haven't noticed already, the API changed the naming conventions from Java lower camel case (`likeThis`) to the conventional YAML namespace (`like-this`). You can modify which naming convention the API uses. There will be more information you can refer to on this on [the wiki]( Wiki).\n\nIf we were to add a list of our favourite numbers to the config manually, we will be able to see the API being able to load them up without a problem:\n\n```yml\nmy-favourite-numbers:\n- 2\n- 6\n- 8\n```\n\nAnd if we start up our server with the new config, we'll see the following printed in console:\n\n```\n[01:09:42 INFO]: [ConfigTestPlugin] Enabling ConfigTestPlugin v1.0\n[01:09:42 INFO]: [ConfigTestPlugin] This super cool awesome bukkit plugin has started!\n[01:09:42 INFO]: [ConfigTestPlugin] [2, 6, 8]\n```\n\nWell, that was easy.\n\nConfigAPI is still in early development and will soon be for release for developers to use in their projects. Contributions are more than welcome!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmkotb%2Fconfigapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmkotb%2Fconfigapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmkotb%2Fconfigapi/lists"}