Skip to content

Commit 3fe0876

Browse files
author
BadAccuracyID
committed
Bump version (0.5.3-RELEASE):
- Fixed java.lang.NoClassDefFoundError due to missing dependencies
1 parent c7da7e7 commit 3fe0876

File tree

13 files changed

+123
-9
lines changed

13 files changed

+123
-9
lines changed
Binary file not shown.
Binary file not shown.

.gradle/7.1/fileHashes/fileHashes.bin

150 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
5.41 KB
Binary file not shown.
Binary file not shown.
18 Bytes
Binary file not shown.

.gradle/checksums/checksums.lock

0 Bytes
Binary file not shown.

plugin/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ plugins {
66

77
def pluginName = 'LuckyEssentials'
88
group 'id.luckynetwork.dev.lyrams.lej'
9-
version '0.5.2-RELEASE'
9+
version '0.5.3-RELEASE'
1010

1111
repositories {
1212
mavenCentral()

plugin/src/main/java/id/luckynetwork/dev/lyrams/lej/LuckyEssentials.java

+73-5
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ public void onEnable() {
5757

5858
instance = this;
5959
this.loadDependencies();
60+
this.loadRetardedDependencies();
6061
this.loadVersionSupport();
6162

6263
this.loadConfigs();
@@ -120,10 +121,77 @@ private void loadDependencies() {
120121

121122
for (JsonElement element : dependencies) {
122123
JsonObject dependency = element.getAsJsonObject();
123-
dependencyMap.put(
124-
dependency.get("name").getAsString(),
125-
dependency.get("url").getAsString()
126-
);
124+
if (!dependency.get("name").getAsString().contains("adventure-api")) {
125+
dependencyMap.put(
126+
dependency.get("name").getAsString(),
127+
dependency.get("url").getAsString()
128+
);
129+
}
130+
}
131+
} catch (Exception e) {
132+
e.printStackTrace();
133+
} finally {
134+
if (stream != null) {
135+
try {
136+
stream.close();
137+
} catch (IOException e) {
138+
e.printStackTrace();
139+
}
140+
}
141+
if (reader != null) {
142+
try {
143+
reader.close();
144+
} catch (IOException e) {
145+
e.printStackTrace();
146+
}
147+
}
148+
}
149+
150+
DependencyHelper helper = new DependencyHelper(LuckyEssentials.class.getClassLoader());
151+
File dir = new File("plugins/LuckyEssentials/libs");
152+
try {
153+
helper.download(dependencyMap, dir.toPath());
154+
helper.loadDir(dir.toPath(), false);
155+
} catch (IOException | IllegalAccessException e) {
156+
e.printStackTrace();
157+
}
158+
}
159+
160+
/**
161+
* downloads and/or loads retarded dependencies
162+
*/
163+
private void loadRetardedDependencies() {
164+
try {
165+
Class.forName("net.kyori.adventure.sound.Sound");
166+
return;
167+
} catch (ClassNotFoundException ignored) {
168+
}
169+
170+
this.getLogger().info("Loading and injecting retarded dependencies...");
171+
Map<String, String> dependencyMap = new HashMap<>();
172+
173+
InputStream stream = null;
174+
InputStreamReader reader = null;
175+
try {
176+
stream = LuckyEssentials.class.getClassLoader().getResourceAsStream("dependencies-retarded.json");
177+
178+
assert stream != null;
179+
reader = new InputStreamReader(stream);
180+
181+
JsonParser parser = new JsonParser();
182+
JsonArray dependencies = parser.parse(reader).getAsJsonArray();
183+
if (dependencies.size() == 0) {
184+
return;
185+
}
186+
187+
for (JsonElement element : dependencies) {
188+
JsonObject dependency = element.getAsJsonObject();
189+
if (dependency.get("name").getAsString().contains("adventure-api")) {
190+
dependencyMap.put(
191+
dependency.get("name").getAsString(),
192+
dependency.get("url").getAsString()
193+
);
194+
}
127195
}
128196
} catch (Exception e) {
129197
e.printStackTrace();
@@ -148,7 +216,7 @@ private void loadDependencies() {
148216
File dir = new File("plugins/LuckyEssentials/libs");
149217
try {
150218
helper.download(dependencyMap, dir.toPath());
151-
helper.loadDir(dir.toPath());
219+
helper.loadDir(dir.toPath(), true);
152220
} catch (IOException | IllegalAccessException e) {
153221
e.printStackTrace();
154222
}

plugin/src/main/java/id/luckynetwork/dev/lyrams/lej/dependency/DependencyHelper.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,12 @@ public void load(File file) throws IOException, IllegalAccessException {
9191
* loads all dependencies on a specific directory
9292
*
9393
* @param dirPath the directory path
94+
* @param retarded whether to load the retarded dependencies
9495
* @throws IOException if the dependency file doesn't exist
9596
* @throws IllegalAccessException if the dependency file isn't a .jar
9697
*/
9798
@SuppressWarnings("ConstantConditions")
98-
public void loadDir(Path dirPath) throws IOException, IllegalAccessException {
99+
public void loadDir(Path dirPath, boolean retarded) throws IOException, IllegalAccessException {
99100
File dir = dirPath.toFile();
100101
if (!dir.isDirectory()) {
101102
return;
@@ -105,6 +106,9 @@ public void loadDir(Path dirPath) throws IOException, IllegalAccessException {
105106
if (!file.getName().endsWith(".jar")) {
106107
continue;
107108
}
109+
if (!retarded && file.getName().contains("adventure-api")) {
110+
continue;
111+
}
108112
this.load(file);
109113
}
110114
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[
2+
{
3+
"name": "adventure-api-4.9.3.jar",
4+
"url": "https://search.maven.org/remotecontent?filepath=net/kyori/adventure-api/4.9.3/adventure-api-4.9.3.jar"
5+
}
6+
]
+38-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
[
2+
{
3+
"name": "cloud-core-1.5.0.jar",
4+
"url": "https://search.maven.org/remotecontent?filepath=cloud/commandframework/cloud-core/1.5.0/cloud-core-1.5.0.jar"
5+
},
26
{
37
"name": "cloud-annotations-1.5.0.jar",
48
"url": "https://search.maven.org/remotecontent?filepath=cloud/commandframework/cloud-annotations/1.5.0/cloud-annotations-1.5.0.jar"
@@ -8,15 +12,47 @@
812
"url": "https://search.maven.org/remotecontent?filepath=cloud/commandframework/cloud-paper/1.5.0/cloud-paper-1.5.0.jar"
913
},
1014
{
11-
"name": "cloud-core-1.5.0.jar",
12-
"url": "https://search.maven.org/remotecontent?filepath=cloud/commandframework/cloud-core/1.5.0/cloud-core-1.5.0.jar"
15+
"name": "cloud-bukkit-1.5.0.jar",
16+
"url": "https://search.maven.org/remotecontent?filepath=cloud/commandframework/cloud-bukkit/1.5.0/cloud-bukkit-1.5.0.jar"
17+
},
18+
{
19+
"name": "cloud-brigadier-1.5.0.jar",
20+
"url": "https://search.maven.org/remotecontent?filepath=cloud/commandframework/cloud-brigadier/1.5.0/cloud-brigadier-1.5.0.jar"
21+
},
22+
{
23+
"name": "cloud-services-1.5.0.jar",
24+
"url": "https://search.maven.org/remotecontent?filepath=cloud/commandframework/cloud-services/1.5.0/cloud-services-1.5.0.jar"
25+
},
26+
{
27+
"name": "cloud-tasks-1.5.0.jar",
28+
"url": "https://search.maven.org/remotecontent?filepath=cloud/commandframework/cloud-tasks/1.5.0/cloud-tasks-1.5.0.jar"
1329
},
1430
{
1531
"name": "cloud-minecraft-extras-1.5.0.jar",
1632
"url": "https://search.maven.org/remotecontent?filepath=cloud/commandframework/cloud-minecraft-extras/1.5.0/cloud-minecraft-extras-1.5.0.jar"
1733
},
34+
{
35+
"name": "adventure-key-4.9.3.jar",
36+
"url": "https://search.maven.org/remotecontent?filepath=net/kyori/adventure-key/4.9.3/adventure-key-4.9.3.jar"
37+
},
38+
{
39+
"name": "adventure-platform-api-4.0.0.jar",
40+
"url": "https://repo1.maven.org/maven2/net/kyori/adventure-platform-api/4.0.0/adventure-platform-api-4.0.0.jar"
41+
},
1842
{
1943
"name": "adventure-platform-bukkit-4.0.0.jar",
2044
"url": "https://repo1.maven.org/maven2/net/kyori/adventure-platform-bukkit/4.0.0/adventure-platform-bukkit-4.0.0.jar"
45+
},
46+
{
47+
"name": "adventure-platform-facet-4.0.0.jar",
48+
"url": "https://repo1.maven.org/maven2/net/kyori/adventure-platform-facet/4.0.0/adventure-platform-facet-4.0.0.jar"
49+
},
50+
{
51+
"name": "examination-api-1.3.0.jar",
52+
"url": "https://search.maven.org/remotecontent?filepath=net/kyori/examination-api/1.3.0/examination-api-1.3.0.jar"
53+
},
54+
{
55+
"name": "geantyref-1.3.11.jar",
56+
"url": "https://search.maven.org/remotecontent?filepath=io/leangen/geantyref/geantyref/1.3.11/geantyref-1.3.11.jar"
2157
}
2258
]

0 commit comments

Comments
 (0)