{"id":26359237,"url":"https://github.com/hashtek-mc/hashconfig","last_synced_at":"2025-03-16T15:59:04.757Z","repository":{"id":222736205,"uuid":"752023236","full_name":"hashtek-mc/hashconfig","owner":"hashtek-mc","description":"Une librairie permettant de gérer les fichiers de configuration facilement.","archived":false,"fork":false,"pushed_at":"2024-04-26T01:11:31.000Z","size":19193,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2024-04-27T01:32:58.947Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://hashtek.fr","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/hashtek-mc.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}},"created_at":"2024-02-02T20:58:16.000Z","updated_at":"2024-04-26T01:11:34.000Z","dependencies_parsed_at":"2024-04-26T01:42:32.932Z","dependency_job_id":null,"html_url":"https://github.com/hashtek-mc/hashconfig","commit_stats":null,"previous_names":["hashtek-mc/hashconfig"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hashtek-mc%2Fhashconfig","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hashtek-mc%2Fhashconfig/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hashtek-mc%2Fhashconfig/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hashtek-mc%2Fhashconfig/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hashtek-mc","download_url":"https://codeload.github.com/hashtek-mc/hashconfig/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243893845,"owners_count":20364916,"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":[],"created_at":"2025-03-16T15:59:04.196Z","updated_at":"2025-03-16T15:59:04.742Z","avatar_url":"https://github.com/hashtek-mc.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ⚙️ HashConfig v0.0.1 - Guide d'utilisation\n\n## Description de la librairie\nCette librairie est faîte pour manipuler des fichiers de configuration ainsi que des `.env` plus facilement.\n\n---\n\n## 🏁 Getting Started\n\n### Classe\n```java\nHashConfig(Class\u003c?\u003e plugin, String resourcePath, String outputPath, boolean withDotEnv);\n```\n\n### Paramètres\n- `Class\u003c?\u003e plugin`: La classe principale du plugin.\n- `String resourcePath`: Le chemin du fichier de configuration se trouvant dans votre `.jar`. *(Appelé ressource)*\n- `String outputPath`: Le chemin vers la sauvegarde locale du fichier de configuration.\n- `boolean withDotEnv`: S'il faut charger le fichier d'environnement ou non.\n\n\u003e [!warning]\n\u003e **Le fichier de configuration ne sera pas chargé/recréé depuis les ressources si il existe déjà en local. Il sera uniquement chargé depuis le fichier local.**\n\n\n### Utilisation\n\n**Structure du serveur**\n```\nserver/\n├─ ...\n├─ spigot.jar\n├─ plugins/\n│  ├─ TonPlugin.jar\n├─ ...\n```\n\n**Structure de `TonPlugin.jar`**\n```\nTonPlugin.jar/\n├─ config.yml\n├─ main/\n│  ├─ java/\n│  │  ├─ .../\n```\n\n**Fichier de configuration: `config.yml`:**\n```yaml\nusers:\n    1:\n        username: L1x\n        password: 1234\n    2:\n        username: Epitoch\n        password: 5678\n```\n\n**Fichier de variable d'environnement: `.env`:**\n```env\nTOKEN=YOUR_TOKEN\n```\n\n---\n\n### Codes d'exemple\n\n**Chargement basic du fichier de configuration**\n```java\nimport fr.hashtek.hashconfig.HashConfig;\n\n// Pour un plugin minecraft\npublic class TonPlugin extends JavaPlugin\n{\n    \n    @Override\n    public void onEnable()\n    {\n        HashConfig config = new HashConfig(\n            this.getClass(),\n            \"config.yml\",\n            this.getDataFolder().getPath() + \"/\" + \"config.yml\",\n            false // Définir à true pour charger les fichiers .env\n        );\n    }\n\n    @Override\n    public void onDisable() {}\n    \n}\n\n// Pour un autre type de projet Java\npublic class TonProjet\n{\n    \n    public static void main(String[] args)\n    {\n        HashConfig config = new HashConfig(\n            this.getClass(),\n            \"config.yml\",\n            \"chemin/de/destination/config.yml\",\n            false // Définir à true pour charger les fichiers .env\n        );\n    }\n    \n}\n```\n\n**Récupération des variables d'environnement**\n\n```java\nimport fr.hashtek.hashconfig.HashConfig;\n\nHashConfig config = ...;\nString value = config.getEnv().get(\"key\");\n```\n\n**Récupération d'un élément de votre fichier de configuration**\n```java\nHashConfig config = ...;\nYamlFile yaml = config.getYaml();\n\nString str = yaml.getString(\"path.to.your.string\");\nint number = yaml.getInt(\"path.to.your.number\");\ndouble number2 = yaml.getDouble(\"path.to.your.double\");\n// etc...\n```\n\n**Modification des valeurs dans le fichier de configuration**\n```java\nHashConfig config = ...;\nYamlFile yaml = config.getYaml();\n\nString your_string = \"blabla\";\nint your_integer = 1234;\ndouble your_double = 1234.2934;\n\n// Définir les nouvelles valeurs.\nyaml.set(\"path.to.your.string\", your_string);\nyaml.set(\"path.to.your.integer\", your_integer);\nyaml.set(\"path.to.your.double\", your_double);\n\nconfig.save(); // Sauvegarder les nouvelles valeurs.\n```\n\n**Rechargement du fichier de configuration**\n```java\nHashConfig config = ...;\n\n// Vos modifications ici...\n\nconfig.reload();\n```\n\n---\n\n\u003e [!warning]\n\u003e ⚠️ RAPPEL DES WARNINGS\n\u003e \n\u003e Le fichier de configuration ne sera pas chargé/recréé depuis les ressources s'il existe déjà en local.\n\u003e Il sera uniquement chargé depuis le fichier local et non depuis l'archive.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhashtek-mc%2Fhashconfig","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhashtek-mc%2Fhashconfig","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhashtek-mc%2Fhashconfig/lists"}