Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
6bfdd48
Add: create MC_Support class for future functionality
Sandro642 Jul 8, 2025
8969e56
Merge pull request #8 from Sandro642/main
Sandro642 Jul 8, 2025
6b22feb
Add: bump version to 0.1.3.0-Alpha in build.gradle.kts
Sandro642 Jul 9, 2025
6c1b18a
Merge remote-tracking branch 'origin/feature/hook' into feature/hook
Sandro642 Jul 9, 2025
2bdedab
Add: implement MCSupport class for Minecraft project integration and …
Sandro642 Jul 9, 2025
50c8846
Refactor: remove unused imports and simplify MCSupport method in Conn…
Sandro642 Jul 9, 2025
a19ce71
Bump version to 0.1.3.1-Alpha in build.gradle.kts
Sandro642 Jul 9, 2025
e430fa0
Change: update access modifiers for setPluginVariable and getPluginPa…
Sandro642 Jul 9, 2025
3ebd055
Update GitHub Actions workflow to handle tag overwrites and improve v…
Sandro642 Jul 9, 2025
8cbc9db
Refactor: simplify MCSupport instantiation and add singleton pattern
Sandro642 Jul 9, 2025
088086f
Update GitHub Actions workflow to deploy ConnectorAPI artifacts and c…
Sandro642 Jul 9, 2025
f695a8c
Bump version to 0.1.3.2-Alpha in build.gradle.kts
Sandro642 Jul 9, 2025
044d8c9
Update README: refine Minecraft version support notation
Sandro642 Jul 9, 2025
0e1d167
Refactor: implement singleton pattern for MCSupport and enhance plugi…
Sandro642 Jul 9, 2025
0e5dfd3
Bump version to 0.1.3.3-SNAPSHOT in build.gradle.kts
Sandro642 Jul 9, 2025
45c4777
Bump version to 0.1.3.4-SNAPSHOT and comment out Minecraft project ch…
Sandro642 Jul 9, 2025
7e63f27
Bump version to 0.1.3.5-SNAPSHOT and update MC_RESOURCES path handlin…
Sandro642 Jul 9, 2025
d2b9ded
Refactor: update ApiClient to handle MC_RESOURCES URL retrieval and b…
Sandro642 Jul 9, 2025
dd4aba6
Refactor: simplify ApiClient initialization and bump version to 0.1.3…
Sandro642 Jul 9, 2025
c64992c
Refactor: remove unused import for ResourceType in ApiClient
Sandro642 Jul 9, 2025
88de645
Refactor: update ApiClient to retrieve base URL from StoreAndRetrieve…
Sandro642 Jul 9, 2025
5a6a9c7
Update readme.md
Sandro642 Jul 9, 2025
950fae2
Update readme.md
Sandro642 Jul 9, 2025
92515c0
Update readme.md
Sandro642 Jul 9, 2025
d515296
Merge pull request #9 from Sandro642/feature/serializer
Sandro642 Jul 9, 2025
087d4ae
Feature: add SerialMap class for serialization management
Sandro642 Jul 9, 2025
fac972d
Refactor: update project version to 0.0.0 in build.gradle.kts : Versi…
Sandro642 Jul 9, 2025
c59f731
Update readme.md
Sandro642 Jul 10, 2025
087f2cf
Feature: implement serialization for store and retrieve data management
Sandro642 Jul 10, 2025
a3df442
Merge remote-tracking branch 'origin/feature/serializer' into feature…
Sandro642 Jul 10, 2025
af822d5
Feature: update work-jar.yml to include feature/serializer branch and…
Sandro642 Jul 10, 2025
0e8a496
Feature: refactor data management to use HookManager for loading and …
Sandro642 Jul 10, 2025
f755820
Feature: update project version to 0.1.3.10-SNAPSHOT in build.gradle.kts
Sandro642 Jul 10, 2025
5b16132
Feature: update project version to 0.1.3.11-SNAPSHOT and fix file pat…
Sandro642 Jul 10, 2025
6e43956
Feature: update project version to 0.1.3.12-SNAPSHOT and add getUsedT…
Sandro642 Jul 10, 2025
267dc71
Feature: update project version to 0.1.3.13-SNAPSHOT and add debug lo…
Sandro642 Jul 10, 2025
a1f6305
Feature: update project version to 0.1.3.14-SNAPSHOT and add debug lo…
Sandro642 Jul 10, 2025
26430be
Feature: update project version to 0.1.3.15-SNAPSHOT and add debug lo…
Sandro642 Jul 10, 2025
8607c04
Feature: update project version to 0.1.3.16-SNAPSHOT and refactor sav…
Sandro642 Jul 10, 2025
cb86f75
Feature: update project version to 0.1.3.16-SNAPSHOT and add printVer…
Sandro642 Jul 10, 2025
d8e758b
Feature: update project version to 0.1.3.17-SNAPSHOT and remove debug…
Sandro642 Jul 10, 2025
e39b78b
Feature: refactor data loading and saving in ApiClient, ConnectorAPI,…
Sandro642 Jul 10, 2025
faa627e
Feature: add feature/clean/serial branch to work-jar.yml
Sandro642 Jul 10, 2025
39ad215
Feature: clean up unused imports and comments in ApiClient, Connector…
Sandro642 Jul 10, 2025
63cd593
Merge pull request #10 from Sandro642/feature/clean/serial
Sandro642 Jul 10, 2025
9456100
Feature: remove unused test methods and clean up main method in Main.…
Sandro642 Jul 10, 2025
6cf1a20
Feature: update branch triggers in work-jar.yml to include main branch
Sandro642 Jul 10, 2025
11c1564
Merge branch 'main' into feature/hook
Sandro642 Jul 10, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/work-jar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,4 @@ jobs:
git tag -a "${{ steps.extract_version.outputs.version }}" -m "Release version ${{ steps.extract_version.outputs.version }}"
git push origin "${{ steps.extract_version.outputs.version }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ plugins {
id("maven-publish") // Plugin pour la publication
}


group = "fr.sandro642.github"
version = "0.1.2"
version = "0.1.3.17.1-SNAPSHOT" // Version de votre projet


// Ajoutez cette tâche à votre build.gradle.kts
tasks.register("printVersion") {
Expand All @@ -17,6 +19,9 @@ tasks.register("printVersion") {

repositories {
mavenCentral()

maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/")
maven("https://oss.sonatype.org/content/repositories/snapshots/")
}

dependencies {
Expand All @@ -28,6 +33,8 @@ dependencies {

implementation("org.openjfx:javafx-controls:21")
implementation("org.openjfx:javafx-fxml:21")

compileOnly("org.spigotmc:spigot-api:1.8-R0.1-SNAPSHOT")
}

javafx {
Expand Down
8 changes: 8 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ Hook -----------------------|
```
---

Changelog :

```java
- [0.1.3.9-SNAPSHOT] : Ajout de la sérialisation des données pour une compatibilisation parfaite des données avec les HOOK.
```

---

## 🌟 Pourquoi ConnectorAPI ?

Imaginez une API qui ne se contente pas de relier des services, mais qui devient le chef d’orchestre de vos intégrations. ConnectorAPI est conçu pour :
Expand Down
17 changes: 14 additions & 3 deletions src/main/java/fr/sandro642/github/ConnectorAPI.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package fr.sandro642.github;

import fr.sandro642.github.hook.MCSupport;
import fr.sandro642.github.jobs.JobGetInfos;
import fr.sandro642.github.jobs.misc.MethodType;
import fr.sandro642.github.jobs.misc.ResourceType;
import fr.sandro642.github.jobs.misc.VersionType;
import fr.sandro642.github.utils.Logger;
import fr.sandro642.github.utils.StoreAndRetrieve;
import fr.sandro642.github.utils.YamlUtils;
Expand Down Expand Up @@ -37,7 +36,11 @@ public static void initialize(ResourceType resourceType) {
// Génère le template si nécessaire
yamlUtils.generateTemplateIfNotExists(resourceType);

storeAndRetrieve.store.put(storeAndRetrieve.FILE_LOCATION_KEY, resourceType.getPath());
if (resourceType == ResourceType.MC_RESOURCES) {
storeAndRetrieve.store.put(storeAndRetrieve.FILE_LOCATION_KEY, MCSupport().getPluginPath());
} else {
storeAndRetrieve.store.put(storeAndRetrieve.FILE_LOCATION_KEY, resourceType.getPath());
}

// Charge l'URL depuis le fichier YAML
String baseUrl = yamlUtils.getURL();
Expand Down Expand Up @@ -82,4 +85,12 @@ public static YamlUtils YamlUtils() {
}
return yamlUtils;
}

/**
* Retourne une instance de MCSupport si le projet est un projet Minecraft
* @return MCSupport ou null si ce n'est pas un projet Minecraft
*/
public static MCSupport MCSupport() {
return MCSupport.getInstance();
}
}
7 changes: 3 additions & 4 deletions src/main/java/fr/sandro642/github/api/ApiClient.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package fr.sandro642.github.api;

import fr.sandro642.github.ConnectorAPI;
import fr.sandro642.github.jobs.misc.ResourceType;
import fr.sandro642.github.utils.Logger;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.web.reactive.function.client.WebClient;
Expand Down Expand Up @@ -29,12 +28,12 @@ public class ApiClient {

/**
* Constructeur de ApiClient qui initialise WebClient avec l'URL de base.
* @param resourceType Type de ressource (peut être utilisé pour des configurations spécifiques).
*/
public ApiClient(ResourceType resourceType) {
public ApiClient() {
String baseUrl = (String) ConnectorAPI.StoreAndRetrieve().store.get(ConnectorAPI.StoreAndRetrieve().URL_KEY);

if (baseUrl == null) {
throw new RuntimeException("URL de base non trouvée. Assurez-vous d'avoir initialisé ConnectorAPI.");
throw new RuntimeException("URL de base non trouvée. Assurez-vous d'avoir initialisé ConnectorAPI. ");
}

this.webClient = WebClient.builder()
Expand Down
1 change: 0 additions & 1 deletion src/main/java/fr/sandro642/github/api/ApiResponse.java
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,6 @@ public String display() {
", msg='" + msg + '\'' +
", code=" + code +
", data=" + data +
", extra=" + extra +
'}';
}
}
4 changes: 3 additions & 1 deletion src/main/java/fr/sandro642/github/example/ExampleUsage.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
import fr.sandro642.github.jobs.misc.ResourceType;
import fr.sandro642.github.jobs.misc.VersionType;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
Expand Down Expand Up @@ -132,7 +134,7 @@ public static void main(String[] args) {
complexBody.put("nestedObject", subObject);

// Array
java.util.List<String> arrayValue = java.util.Arrays.asList("item1", "item2", "item3");
List<String> arrayValue = Arrays.asList("item1", "item2", "item3");
complexBody.put("arrayValue", arrayValue);

ApiResponse<Void> complexResponse = ConnectorAPI.JobGetInfos()
Expand Down
122 changes: 122 additions & 0 deletions src/main/java/fr/sandro642/github/hook/MCSupport.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
package fr.sandro642.github.hook;

import org.bukkit.plugin.Plugin;

/**
* MCSupport est une classe utilitaire pour gérer les hooks liés à Minecraft.
* Elle permet de vérifier si le projet est un projet Minecraft et de gérer les ressources associées.
* @author Sandro642
* @version 1.0
*/
public class MCSupport {

/**
* Création de l'instance unique de MCSupport.
*/
private static MCSupport instance;

/**
* Instance unique du plugin Minecraft.
* Utilisée pour stocker la variable du plugin Minecraft.
*/
private Plugin pluginSingleton;

/**
* Constructeur privé pour empêcher l'instanciation directe.
*/
private MCSupport() {
// Constructeur privé pour le pattern Singleton
}

/**
* Méthode permettant de vérifier si le projet est un projet Minecraft.
* Elle vérifie si le chemin du fichier de configuration contient le chemin des ressources Minecraft.
*
* @return true si c'est un projet Minecraft, false sinon.
*/
public boolean isMCProject() {
try {

String fileLocation = (String) fr.sandro642.github.ConnectorAPI.StoreAndRetrieve().store.get(fr.sandro642.github.ConnectorAPI.StoreAndRetrieve().FILE_LOCATION_KEY);
return fileLocation != null && fileLocation.contains(fr.sandro642.github.jobs.misc.ResourceType.MC_RESOURCES.getPath());
} catch (Exception e) {
// En cas d'erreur, considérer que ce n'est pas un projet MC
return false;
}
}

/**
* Méthode permettant de définir la variable du plugin Minecraft.
* Elle doit être appelée dans un projet Minecraft pour initialiser le plugin.
*
* @param plugin Le plugin Minecraft à définir.
* @return L'instance du plugin définie.
* @throws IllegalStateException Si la méthode n'est pas appelée dans un projet Minecraft.
* @throws IllegalArgumentException Si le plugin fourni est null.
*/
public Plugin setPluginVariable(Plugin plugin) {
if (plugin == null) {
throw new IllegalArgumentException("Plugin cannot be null.");
}
this.pluginSingleton = plugin;
return this.pluginSingleton;
}

/**
* Méthode permettant d'obtenir le chemin du path du plugin Minecraft.
* Elle doit être appelée dans un projet Minecraft pour récupérer le chemin du dossier de données du plugin.
*
* @return Le chemin du dossier de données du plugin.
* @throws IllegalStateException Si la méthode n'est pas appelée dans un projet Minecraft ou si le plugin n'est pas initialisé.
*/
public String getPluginPath() {

if (pluginSingleton == null) {
throw new IllegalStateException("Plugin variable is not set. Please call setPluginVariable first.");
}

return pluginSingleton.getDataFolder().getAbsolutePath();
}

/**
* Méthode permettant de vérifier si le plugin est initialisé.
*
* @return true si le plugin est initialisé, false sinon.
*/
public boolean isPluginInitialized() {
return pluginSingleton != null;
}

/**
* Méthode permettant d'obtenir l'instance du plugin (si initialisé).
*
* @return L'instance du plugin ou null si non initialisé.
*/
public Plugin getPlugin() {
return pluginSingleton;
}

/**
* Méthode permettant de réinitialiser l'instance du plugin.
* Utile pour les tests ou le rechargement.
*/
public void resetPlugin() {
this.pluginSingleton = null;
}

/**
* Méthode permettant d'obtenir l'instance unique de MCSupport.
*
* @return L'instance unique de MCSupport.
*/
public static MCSupport getInstance() {
if (instance == null) {
synchronized (MCSupport.class) {
if (instance == null) {
instance = new MCSupport();
}
}
}
return instance;
}
}
11 changes: 5 additions & 6 deletions src/main/java/fr/sandro642/github/jobs/JobGetInfos.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import fr.sandro642.github.api.ApiClient;
import fr.sandro642.github.api.ApiResponse;
import fr.sandro642.github.jobs.misc.MethodType;
import fr.sandro642.github.jobs.misc.ResourceType;
import fr.sandro642.github.jobs.misc.VersionType;
import fr.sandro642.github.utils.YamlUtils;

Expand All @@ -25,15 +24,14 @@ public class JobGetInfos {
* ApiClient est utilisé pour effectuer les requêtes HTTP vers l'API.
* YamlUtils est utilisé pour lire les routes depuis le fichier YAML.
*/
private ApiClient apiClient;
private YamlUtils yamlUtils;
private final ApiClient apiClient;
private final YamlUtils yamlUtils;

/**
* Constructeur de JobGetInfos qui initialise ApiClient et YamlUtils.
* Utilise ResourceType.MAIN_RESOURCES pour le type de ressource par défaut.
*/
public JobGetInfos() {
this.apiClient = new ApiClient(ResourceType.MAIN_RESOURCES);
this.apiClient = new ApiClient();
this.yamlUtils = ConnectorAPI.YamlUtils();
}

Expand Down Expand Up @@ -135,7 +133,7 @@ public JobGetInfos getRoutes(VersionType versionType, MethodType methodType, Str
String paramKey = "{" + entry.getKey() + "}";
String paramValue = entry.getValue().toString();

// Remplace tous les occurrences du paramètre dans la route
// Remplace toutes les occurrences du paramètre dans la route
fullRoute = fullRoute.replace(paramKey, paramValue);
}
}
Expand Down Expand Up @@ -169,6 +167,7 @@ public JobGetInfos getRoutes(VersionType versionType, MethodType methodType, Str
*/
public ApiResponse<Void> getResponse() {
try {

String route = (String) ConnectorAPI.StoreAndRetrieve().store.get("currentRoute");
MethodType method = (MethodType) ConnectorAPI.StoreAndRetrieve().store.get("currentMethod");
Map<String, Object> body = (Map<String, Object>) ConnectorAPI.StoreAndRetrieve().store.get("currentBody");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public enum ResourceType {
*/
MAIN_RESOURCES("src/main/resources"),
TEST_RESOURCES("src/test/resources"),
MC_RESOURCES("Arrive prochainement");
MC_RESOURCES("");


/**
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/fr/sandro642/github/utils/StoreAndRetrieve.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package fr.sandro642.github.utils;

import java.util.concurrent.ConcurrentHashMap;
import java.util.Map;
import java.util.HashMap;

/**
* StoreAndRetrieve est une classe utilitaire pour stocker et récupérer des valeurs associées à des clés.
Expand All @@ -22,7 +21,7 @@ public class StoreAndRetrieve {
*/
public final String URL_KEY = "baseUrl";
public final String FILE_LOCATION_KEY = "fileLocation";
public final Map<String, Object> store = new ConcurrentHashMap<>();
public final HashMap<String, Object> store = new HashMap<>();

/**
* Ajoute une valeur à la map avec la clé spécifiée.
Expand Down
14 changes: 13 additions & 1 deletion src/main/java/fr/sandro642/github/utils/YamlUtils.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package fr.sandro642.github.utils;

import fr.sandro642.github.ConnectorAPI;
import fr.sandro642.github.hook.MCSupport;
import fr.sandro642.github.jobs.misc.ResourceType;
import org.yaml.snakeyaml.Yaml;

Expand All @@ -26,6 +27,8 @@ public class YamlUtils {
* @return l'URL de base définie dans le fichier YAML, ou null si une erreur se produit
*/
public String getURL() {
//HashMap<String, Object> storeLoad = ConnectorAPI.HookManager().loadData("store_and_retrieve.yml");

String yamlFilePath = ConnectorAPI.StoreAndRetrieve().store.get(ConnectorAPI.StoreAndRetrieve().FILE_LOCATION_KEY) + "/infos.yml";

try (InputStream inputStream = Files.newInputStream(Paths.get(yamlFilePath))) {
Expand All @@ -43,6 +46,8 @@ public String getURL() {
* @return
*/
public String getRoute(String routeName) {
//HashMap<String, Object> storeLoad = ConnectorAPI.HookManager().loadData("store_and_retrieve.yml");

String yamlFilePath = ConnectorAPI.StoreAndRetrieve().store.get(ConnectorAPI.StoreAndRetrieve().FILE_LOCATION_KEY) + "/infos.yml";

try (InputStream inputStream = Files.newInputStream(Paths.get(yamlFilePath))) {
Expand All @@ -65,7 +70,14 @@ public String getRoute(String routeName) {
* @param type
*/
public void generateTemplateIfNotExists(ResourceType type) {
String basePath = type.getPath();
String basePath;

if (type == ResourceType.MC_RESOURCES) {
basePath = MCSupport.getInstance().getPluginPath();
} else {
basePath = type.getPath();
}

File directory = new File(basePath);
if (!directory.exists()) {
directory.mkdirs();
Expand Down
Loading