Skip to content

Commit

Permalink
Remove artifact duplication in the classpath
Browse files Browse the repository at this point in the history
  • Loading branch information
FlowArg committed Aug 18, 2024
1 parent 10ea818 commit ca19c76
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 11 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {
}

group 'fr.flowarg'
version '3.2.10'
version '3.2.11'
archivesBaseName = 'openlauncherlib'

java {
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#Sun Dec 29 21:36:55 CET 2019
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-all.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
Expand Down
19 changes: 12 additions & 7 deletions src/main/java/fr/flowarg/openlauncherlib/NoFramework.java
Original file line number Diff line number Diff line change
Expand Up @@ -250,26 +250,28 @@ private List<String> getVmArgsFor(JSONObject object, JSONObject vanilla)
private String getClassPath(JSONObject vanilla, JSONObject modLoader)
{
final List<String> cp = new ArrayList<>();
final List<String> artifacts = new ArrayList<>();

if (modLoader != null)
this.appendLibraries(cp, modLoader);
this.appendLibraries(cp, vanilla);
this.appendLibraries(cp, artifacts, modLoader);
this.appendLibraries(cp, artifacts, vanilla);

cp.add(this.gameDir.resolve(this.clientJar).toAbsolutePath().toString());

return this.toString(cp);
}

private void appendLibraries(List<String> sb, JSONObject object)
private void appendLibraries(List<String> sb, List<String> artifacts, JSONObject object)
{
object.getJSONArray("libraries").forEach(jsonElement -> {
final JSONObject libraryObject = ((JSONObject)jsonElement);
final Path path;
final String[] nameParts = libraryObject.getString("name").split(":");
String internalArtifactName = nameParts[0] + ':' + nameParts[1];
if(nameParts.length == 4)
internalArtifactName += ':' + nameParts[3];
if(libraryObject.isNull("downloads"))
{
final String[] nameParts = libraryObject.getString("name").split(":");
path = this.libraries.resolve(nameParts[0].replace('.', '/')).resolve(nameParts[1]).resolve(nameParts[2]).resolve(nameParts[1] + "-" + nameParts[2] + ".jar");
}
else
{
final JSONObject downloads = libraryObject.getJSONObject("downloads");
Expand All @@ -279,8 +281,11 @@ private void appendLibraries(List<String> sb, JSONObject object)
path = this.libraries.resolve(downloads.getJSONObject("artifact").getString("path"));
}
final String str = path.toAbsolutePath() + File.pathSeparator;
if(!sb.contains(str) && Files.exists(path))
if(!sb.contains(str) && Files.exists(path) && !artifacts.contains(internalArtifactName))
{
sb.add(str);
artifacts.add(internalArtifactName);
}
});
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/assets/languages/en.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"hi-ext": "OpenLauncherLib 3.2.10 by Adrien 'Litarvan' Navratil and Flow (FlowArg) Arg - External Launching System",
"hi-ext": "OpenLauncherLib 3.2.11 by Adrien 'Litarvan' Navratil and Flow (FlowArg) Arg - External Launching System",
"options": "Options",
"ram": "RAM",
"warn": "Warning",
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/assets/languages/fr.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"hi-ext": "OpenLauncherLib 3.2.10 par Adrien 'Litarvan' Navratil et Flow (Flow Arg) Arg - Systeme de lancement externe",
"hi-ext": "OpenLauncherLib 3.2.11 par Adrien 'Litarvan' Navratil et Flow (Flow Arg) Arg - Systeme de lancement externe",
"options": "Options",
"ram": "RAM",
"warn": "Attention",
Expand Down

0 comments on commit ca19c76

Please sign in to comment.