Skip to content

Commit 6248977

Browse files
committed
Feature: rename ConnectorAPI to ConnectLib and update related references
1 parent 02bdda1 commit 6248977

18 files changed

Lines changed: 586 additions & 598 deletions

build.gradle

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
plugins {
22
id 'java'
33
id 'application'
4-
id 'maven-publish' // Plugin pour la publication
4+
id 'maven-publish'
55
}
66

77
group = 'fr.sandro642.github'
8-
version = '0.2.2-STABLE' // Version de votre projet
8+
version = '0.2.2-STABLE'
99

10-
// Ajoutez cette tâche à votre build.gradle
1110
tasks.register('printVersion') {
1211
doLast {
1312
println project.version
@@ -36,12 +35,12 @@ dependencies {
3635
}
3736

3837
application {
39-
mainClass = 'fr.sandro642.github.ConnectorAPI'
38+
mainClass = 'fr.sandro642.github.ConnectLib'
4039
}
4140

4241
tasks.jar {
4342
manifest {
44-
attributes 'Main-Class': 'fr.sandro642.github.ConnectorAPI'
43+
attributes 'Main-Class': 'fr.sandro642.github.ConnectLib'
4544
}
4645
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
4746
}
@@ -51,8 +50,8 @@ tasks.test {
5150
}
5251

5352
java {
54-
withSourcesJar() // Ajoute le JAR des sources
55-
withJavadocJar() // Ajoute le JAR de Javadoc
53+
withSourcesJar()
54+
withJavadocJar()
5655
}
5756

5857
publishing {
@@ -61,37 +60,37 @@ publishing {
6160
from components.java
6261

6362
groupId = project.group.toString()
64-
artifactId = 'ConnectorAPI'
63+
artifactId = 'ConnectLib'
6564
version = project.version.toString()
6665
pom {
67-
name = 'ConnectorAPI'
66+
name = 'ConnectLib'
6867
description = 'A library for connecting to APIs'
6968
url = 'https://sandro642.github.io/connectorapi'
7069
licenses {
7170
license {
7271
name = 'The MIT License, Version 2.0'
73-
url = 'https://github.com/Sandro642/ConnectorAPI/blob/patch/groovy/LICENSE'
72+
url = 'https://github.com/Sandro642/ConnectLib/blob/patch/groovy/LICENSE'
7473
}
7574
}
7675
developers {
7776
developer {
7877
id = 'sandro642'
7978
name = 'Sandro'
80-
email = 'sandro33810@gmail.com' // Correction de l'email (point-virgule -> point)
79+
email = 'sandro33810@gmail.com'
8180
}
8281
}
8382
scm {
84-
connection = 'scm:git:git://github.com/sandro642/ConnectorAPI.git'
85-
developerConnection = 'scm:git:ssh://github.com/sandro642/ConnectorAPI.git'
86-
url = 'https://github.com/sandro642/ConnectorAPI'
83+
connection = 'scm:git:git://github.com/sandro642/ConnectLib.git'
84+
developerConnection = 'scm:git:ssh://github.com/sandro642/ConnectLib.git'
85+
url = 'https://github.com/sandro642/ConnectLib'
8786
}
8887
}
8988
}
9089
}
9190
repositories {
9291
maven {
9392
name = 'LocalRepo'
94-
url = uri(layout.buildDirectory.dir('repo')) // Publie dans build/repo
93+
url = uri(layout.buildDirectory.dir('repo'))
9594
}
9695
}
9796
}

feature/schematic.md

Lines changed: 0 additions & 56 deletions
This file was deleted.

settings.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
rootProject.name = 'ConnectorAPI'
1+
rootProject.name = 'ConnectLib'
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
package fr.sandro642.github;
2+
3+
import fr.sandro642.github.hook.MCSupport;
4+
import fr.sandro642.github.utils.*;
5+
import fr.sandro642.github.jobs.JobGetInfos;
6+
import fr.sandro642.github.jobs.misc.ResourceType;
7+
8+
import java.util.HashMap;
9+
import java.util.Map;
10+
11+
/**
12+
* ConnectLib is the main class of the ConnectorAPI library for Standard API.
13+
* It provides methods to initialize the library with resource types, routes, and schemas,
14+
* @author Sandro642
15+
* @version 1.0
16+
* @see ConnectLib#JobGetInfos()
17+
* @see ConnectLib#Logger()
18+
* @see ConnectLib#StoreAndRetrieve()
19+
* @see ConnectLib#YamlUtils()
20+
* @see ConnectLib#MCSupport()
21+
*/
22+
23+
public class ConnectLib {
24+
25+
private static Logger logger = new Logger();
26+
private static StoreAndRetrieve storeAndRetrieve = new StoreAndRetrieve();
27+
private static YamlUtils yamlUtils = new YamlUtils();
28+
private static final Map<String,String> routes = new HashMap<>();
29+
private static Logs logs = new Logs();
30+
31+
/**
32+
* Init the ConnectLib with the specified resource type and routes.
33+
* @param resourceType the type of resource to initialize
34+
* @param routes the routes to be used in the ConnectLib
35+
*/
36+
public static void initialize(ResourceType resourceType, Class<? extends Enum<?>>... routes) {
37+
try {
38+
Map<Enum<?>, String> routesEnums = new HashMap<>();
39+
for (Class<? extends Enum<?>> route : routes) {
40+
if (route == null) {
41+
ConnectLib.Logger().ERROR("Route class cannot be null.");
42+
}
43+
44+
routesEnums.putAll(ConvertEnum.convertRouteImport(route));
45+
}
46+
47+
logger = new Logger();
48+
storeAndRetrieve = new StoreAndRetrieve();
49+
yamlUtils = new YamlUtils();
50+
logs = new Logs();
51+
52+
yamlUtils.generateTemplateIfNotExists(resourceType, routesEnums);
53+
logs.setPathFile(resourceType);
54+
55+
if (resourceType == ResourceType.MC_RESOURCES) {
56+
storeAndRetrieve.store.put(storeAndRetrieve.FILE_LOCATION_KEY, MCSupport().getPluginPath());
57+
} else {
58+
storeAndRetrieve.store.put(storeAndRetrieve.FILE_LOCATION_KEY, resourceType.getPath());
59+
}
60+
61+
String baseUrl = yamlUtils.getURL();
62+
if (baseUrl != null) {
63+
storeAndRetrieve.store.put(storeAndRetrieve.URL_KEY, baseUrl);
64+
}
65+
66+
Map<String, String> yamlRoutes = yamlUtils.getRoutes();
67+
if (yamlRoutes != null) {
68+
ConnectLib.routes.putAll(yamlRoutes);
69+
}
70+
} catch (Exception e) {
71+
ConnectLib.Logger().ERROR("Error while initializing ConnectLib: " + e.getMessage());
72+
}
73+
}
74+
75+
/**
76+
* Return the route associated with the given route name.
77+
* @param routeName the name of the route to retrieve
78+
* @return the route as a String
79+
*/
80+
public static String getRoute(String routeName) {
81+
if (routes.containsKey(routeName)) {
82+
return routes.get(routeName);
83+
} else {
84+
ConnectLib.Logger().ERROR("Route '" + routeName + "' not found in the ConnectorAPI routes.");
85+
return null;
86+
}
87+
}
88+
89+
/**
90+
* Return the route associated with the given Enum route.
91+
* The Enum name is converted to lowercase to match the route names.
92+
* @param routeEnum the Enum representing the route
93+
* @return the route as a String
94+
*/
95+
public static String getRoute(Enum<?> routeEnum) {
96+
return getRoute(routeEnum.name().toLowerCase());
97+
}
98+
99+
/**
100+
* Return an instance of JobGetInfos.
101+
* @return JobGetInfos instance
102+
*/
103+
public static JobGetInfos JobGetInfos() {
104+
return new JobGetInfos();
105+
}
106+
107+
/**
108+
* Return the instance of Logger.
109+
* @return Logger instance
110+
*/
111+
public static Logger Logger() {
112+
if (logger == null) {
113+
logger = new Logger();
114+
}
115+
return logger;
116+
}
117+
118+
/**
119+
* Return the instance of StoreAndRetrieve.
120+
* @return StoreAndRetrieve instance
121+
*/
122+
public static StoreAndRetrieve StoreAndRetrieve() {
123+
if (storeAndRetrieve == null) {
124+
storeAndRetrieve = new StoreAndRetrieve();
125+
}
126+
return storeAndRetrieve;
127+
}
128+
129+
/**
130+
* Return the instance of YamlUtils.
131+
* @return YamlUtils instance
132+
*/
133+
public static YamlUtils YamlUtils() {
134+
if (yamlUtils == null) {
135+
yamlUtils = new YamlUtils();
136+
}
137+
return yamlUtils;
138+
}
139+
140+
/**
141+
* Return the instance of Logs.
142+
* @return Logs instance
143+
*/
144+
public static MCSupport MCSupport() {
145+
return MCSupport.getInstance();
146+
}
147+
}

0 commit comments

Comments
 (0)