Skip to content

Commit 8cbc9db

Browse files
committed
Refactor: simplify MCSupport instantiation and add singleton pattern
1 parent 3ebd055 commit 8cbc9db

3 files changed

Lines changed: 16 additions & 12 deletions

File tree

src/main/java/fr/sandro642/github/ConnectorAPI.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,6 @@ public static YamlUtils YamlUtils() {
8787
* @return MCSupport ou null si ce n'est pas un projet Minecraft
8888
*/
8989
public static MCSupport MCSupport() {
90-
if (MCSupport().isMCProject()) {
91-
return new MCSupport();
92-
} else {
93-
logger.ERROR("MCSupport ne peut être utilisé que dans un projet Minecraft.");
94-
return null;
95-
}
90+
return new MCSupport();
9691
}
9792
}

src/main/java/fr/sandro642/github/hook/MCSupport.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@
1111

1212
public class MCSupport {
1313

14+
/**
15+
* Création de l'instance unique de MCSupport.
16+
*/
17+
private static MCSupport instance;
18+
1419
/**
1520
* Instance unique du plugin Minecraft.
1621
* Utilisée pour stocker la variable du plugin Minecraft.
@@ -57,4 +62,14 @@ public String getPluginPath() {
5762
}
5863
}
5964

65+
/**
66+
* Méthode permettant d'obtenir l'instance unique de MCSupport.
67+
* @return L'instance unique de MCSupport.
68+
*/
69+
public static MCSupport getInstance() {
70+
if (instance == null) {
71+
instance = new MCSupport();
72+
}
73+
return instance;
74+
}
6075
}

src/test/java/fr/sandro642/github/test/Main.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,6 @@ public static void main(String[] args) {
6262
@Test
6363
public void testHorsData() {
6464
ConnectorAPI.initialize(ResourceType.TEST_RESOURCES);
65-
66-
ApiResponse<Void> response = ConnectorAPI.JobGetInfos()
67-
.getRoutes(VersionType.V1_BRANCH, MethodType.GET, "example1")
68-
.getResponse();
69-
70-
System.out.println(response.display());
7165
}
7266

7367
}

0 commit comments

Comments
 (0)