-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConnectorAPI.java
More file actions
96 lines (83 loc) · 2.81 KB
/
ConnectorAPI.java
File metadata and controls
96 lines (83 loc) · 2.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
package fr.sandro642.github;
import fr.sandro642.github.hook.MCSupport;
import fr.sandro642.github.jobs.JobGetInfos;
import fr.sandro642.github.jobs.misc.ResourceType;
import fr.sandro642.github.utils.Logger;
import fr.sandro642.github.utils.StoreAndRetrieve;
import fr.sandro642.github.utils.YamlUtils;
/**
* ConnectorAPI est une librairie Java permettant de créer un lien de communication entre son projet Java et une API Rest Fastify.
* @author Sandro642
* @version 1.0
* @since 1.0
* @see ConnectorAPI#initialize(ResourceType)
* @see ConnectorAPI#JobGetInfos()
* @see ConnectorAPI#Logger()
* @see ConnectorAPI#StoreAndRetrieve()
* @see ConnectorAPI#YamlUtils()
*/
public class ConnectorAPI {
private static Logger logger = new Logger();
private static StoreAndRetrieve storeAndRetrieve = new StoreAndRetrieve();
private static YamlUtils yamlUtils = new YamlUtils();
/**
* Initialise le ConnectorAPI avec le type de ressource spécifié
*/
public static void initialize(ResourceType resourceType) {
logger = new Logger();
storeAndRetrieve = new StoreAndRetrieve();
yamlUtils = new YamlUtils();
// Génère le template si nécessaire
yamlUtils.generateTemplateIfNotExists(resourceType);
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();
if (baseUrl != null) {
storeAndRetrieve.store.put(storeAndRetrieve.URL_KEY, baseUrl);
}
}
/**
* Retourne une instance de JobGetInfos pour les opérations API
*/
public static JobGetInfos JobGetInfos() {
return new JobGetInfos();
}
/**
* Retourne l'instance du Logger
*/
public static Logger Logger() {
if (logger == null) {
logger = new Logger();
}
return logger;
}
/**
* Retourne l'instance de StoreAndRetrieve
*/
public static StoreAndRetrieve StoreAndRetrieve() {
if (storeAndRetrieve == null) {
storeAndRetrieve = new StoreAndRetrieve();
}
return storeAndRetrieve;
}
/**
* Retourne l'instance de YamlUtils
*/
public static YamlUtils YamlUtils() {
if (yamlUtils == null) {
yamlUtils = new 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();
}
}