Skip to content

Commit 97c5969

Browse files
committed
Bump version to 0.3.0-STABLE, add LangType support in ConnectLib initialization, and update README
1 parent 8d19662 commit 97c5969

17 files changed

Lines changed: 162 additions & 10 deletions

File tree

.idea/copilot.data.migration.agent.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/copilot.data.migration.edit.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ plugins {
55
}
66

77
group = 'fr.sandro642.github'
8-
version = '0.2.9-STABLE'
8+
version = '0.3.0-STABLE'
99

1010
tasks.register('printVersion') {
1111
doLast {
@@ -93,4 +93,4 @@ publishing {
9393
url = uri(layout.buildDirectory.dir('repo'))
9494
}
9595
}
96-
}
96+
}

readme.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ And if you thought APIs were complicated, think again! With ConnectLib, it's lik
1717
---
1818

1919
```java
20-
Stable Version: 0.2.9-STABLE
20+
Stable Version: 0.3.0-STABLE
2121
```
2222

2323
---
@@ -27,6 +27,7 @@ Support Lib : Java 23
2727
2828
Hook -----------------------|
2929
- Support Minecraft 1.8 - Latest Version
30+
- Support LangType 0.1.0 - Latest Version
3031
3132
- Coming Soon.
3233
```
@@ -107,7 +108,7 @@ repositories {
107108

108109
dependencies {
109110

110-
implementation("fr.sandro642.github:ConnectLib:0.2.9-STABLE")
111+
implementation("fr.sandro642.github:ConnectLib:0.3.0-STABLE")
111112

112113
}
113114

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package fr.sandro642.github;
22

3+
import fr.sandro642.github.enums.LangType;
34
import fr.sandro642.github.hook.HookManager;
5+
import fr.sandro642.github.hook.LangSupport;
46
import fr.sandro642.github.hook.MCSupport;
57
import fr.sandro642.github.misc.*;
68
import fr.sandro642.github.jobs.JobGetInfos;
@@ -35,7 +37,7 @@ public class ConnectLib {
3537
* @param resourceType the type of resource to initialize
3638
* @param routes the routes to be used in the ConnectLib
3739
*/
38-
public static void initialize(ResourceType resourceType, Class<? extends Enum<?>>... routes) {
40+
public static void initialize(ResourceType resourceType, LangType langType, Class<? extends Enum<?>>... routes) {
3941
try {
4042
Map<Enum<?>, String> routesEnums = new HashMap<>();
4143
for (Class<? extends Enum<?>> route : routes) {
@@ -52,6 +54,7 @@ public static void initialize(ResourceType resourceType, Class<? extends Enum<?>
5254
logs = new Logs();
5355

5456
HookManager().initHook(resourceType);
57+
LangSupport().setLangTypeVariable(langType);
5558
HookManager().FILE_LOCATION_KEY();
5659

5760
yamlUtils.generateTemplateIfNotExists(routesEnums);
@@ -152,4 +155,9 @@ public static MCSupport MCSupport() {
152155
public static HookManager HookManager() {
153156
return HookManager.getInstance();
154157
}
158+
159+
public static LangSupport LangSupport() {
160+
return LangSupport.getInstance();
161+
162+
}
155163
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package fr.sandro642.github.enums;
2+
3+
public enum LangType {
4+
ENGLISH("EN_US"),
5+
FRENCH("FR_EU"),
6+
SPANISH("ES_EU"),
7+
GERMAN("DE_EU"),
8+
ITALIAN("IT_EU"),
9+
PORTUGUESE("PT_EU"),
10+
RUSSIAN("RU_RU");
11+
12+
private final String lang;
13+
14+
LangType(String lang) {
15+
this.lang = lang;
16+
}
17+
18+
public String getLang() {
19+
return lang;
20+
}
21+
}

src/main/java/fr/sandro642/github/example/ExampleUsages.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import fr.sandro642.github.ConnectLib;
44
import fr.sandro642.github.api.ApiFactory;
5+
import fr.sandro642.github.enums.LangType;
56
import fr.sandro642.github.enums.MethodType;
67
import fr.sandro642.github.enums.ResourceType;
78
import fr.sandro642.github.enums.VersionType;
@@ -40,9 +41,9 @@ public String route() {
4041
public void initializeLib() {
4142

4243
// Optionally, you can specify routes if needed
43-
ConnectLib.initialize(ResourceType.MAIN_RESOURCES, ExampleRoutes.class);
44+
ConnectLib.initialize(ResourceType.MAIN_RESOURCES, LangType.FRENCH, ExampleRoutes.class);
4445
// You can also initialize without specifying routes
45-
ConnectLib.initialize(ResourceType.MAIN_RESOURCES);
46+
ConnectLib.initialize(ResourceType.MAIN_RESOURCES, LangType.FRENCH);
4647
}
4748

4849
// Add methods here to demonstrate how to use the ConnectLib library
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
package fr.sandro642.github.hook;
2+
3+
import fr.sandro642.github.ConnectLib;
4+
import fr.sandro642.github.enums.LangType;
5+
6+
/**
7+
* LangSupport is a placeholder class for future language support implementations.
8+
* Currently, it does not contain any methods or properties.
9+
*
10+
* @author Sandro642
11+
* @version 1.0
12+
*/
13+
14+
public class LangSupport {
15+
16+
/**
17+
* Instance of LangSupport.
18+
*/
19+
private static LangSupport instance;
20+
21+
/**
22+
* Prefix for language files.
23+
*/
24+
private final String PREFIX = "lang";
25+
26+
/**
27+
* Paths for different languages.
28+
* FRENCH_PATH, ENGLISH_PATH, SPANISH_PATH, GERMAN_PATH, ITALIAN_PATH, PORTUGUESE_PATH, RUSSIAN_PATH
29+
*/
30+
private final String FRENCH_PATH = ConnectLib.HookManager().BASE_PATH() + "/" + PREFIX + "/";
31+
32+
private final String ENGLISH_PATH = ConnectLib.HookManager().BASE_PATH() + "/" + PREFIX + "/";
33+
34+
private final String SPANISH_PATH = ConnectLib.HookManager().BASE_PATH() + "/" + PREFIX + "/";
35+
36+
private final String GERMAN_PATH = ConnectLib.HookManager().BASE_PATH() + "/" + PREFIX + "/";
37+
38+
private final String ITALIAN_PATH = ConnectLib.HookManager().BASE_PATH() + "/" + PREFIX + "/";
39+
40+
private final String PORTUGUESE_PATH = ConnectLib.HookManager().BASE_PATH() + "/" + PREFIX + "/";
41+
42+
private final String RUSSIAN_PATH = ConnectLib.HookManager().BASE_PATH() + "/" + PREFIX + "/";
43+
44+
/**
45+
* Private singleton langType.
46+
* @return langTypeSingleton
47+
*/
48+
private LangType langTypeSingleton;
49+
50+
/**
51+
* Method to set the LangType variable.
52+
* @param langType
53+
* @return
54+
*/
55+
public LangType setLangTypeVariable(LangType langType) {
56+
if (langType == null) {
57+
throw new IllegalArgumentException("LangType cannot be null");
58+
}
59+
this.langTypeSingleton = langType;
60+
return this.langTypeSingleton;
61+
}
62+
63+
/**
64+
* Method to get the path of the language file based on the LangType.
65+
* @return The path of the language file.
66+
* @throws IllegalArgumentException If the LangType is null or unsupported.
67+
*/
68+
public String getPathFile() {
69+
if (langTypeSingleton == null) {
70+
throw new IllegalArgumentException("LangType cannot be null");
71+
}
72+
73+
switch (langTypeSingleton) {
74+
case FRENCH:
75+
return FRENCH_PATH + langTypeSingleton.getLang() + ".lang";
76+
case ENGLISH:
77+
return ENGLISH_PATH + langTypeSingleton.getLang() + ".lang";
78+
case SPANISH:
79+
return SPANISH_PATH + langTypeSingleton.getLang() + ".lang";
80+
case GERMAN:
81+
return GERMAN_PATH + langTypeSingleton.getLang() + ".lang";
82+
case ITALIAN:
83+
return ITALIAN_PATH + langTypeSingleton.getLang() + ".lang";
84+
case PORTUGUESE:
85+
return PORTUGUESE_PATH + langTypeSingleton.getLang() + ".lang";
86+
case RUSSIAN:
87+
return RUSSIAN_PATH + langTypeSingleton.getLang() + ".lang";
88+
89+
default:
90+
ConnectLib.Logger().CRITICAL("Unsupported LangType: " + langTypeSingleton);
91+
throw new IllegalArgumentException("Unsupported LangType: " + langTypeSingleton);
92+
}
93+
}
94+
95+
/**
96+
* Public Getter of LangSupport instance.
97+
* This method returns the singleton instance of LangSupport.
98+
* If the instance is null, it creates a new instance.
99+
* @return instance
100+
*/
101+
public static LangSupport getInstance() {
102+
if (instance == null) {
103+
instance = new LangSupport();
104+
}
105+
return instance;
106+
}
107+
}

src/main/java/fr/sandro642/github/lang/DE_EU.lang

Whitespace-only changes.

src/main/java/fr/sandro642/github/lang/EN_US.lang

Whitespace-only changes.

0 commit comments

Comments
 (0)