Skip to content

Commit

Permalink
7.2.25
Browse files Browse the repository at this point in the history
- Fixed mods and plugins names containing colons (:) to break the complete file
- Added force-latest to each mod in /mods.yml
  • Loading branch information
Osiris-Team committed May 26, 2023
1 parent 7526870 commit 7a6ff9e
Show file tree
Hide file tree
Showing 13 changed files with 95 additions and 74 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

<groupId>com.osiris.autoplug.client</groupId>
<artifactId>autoplug-client</artifactId>
<version>7.2.24</version>
<version>7.2.25</version>
<packaging>jar</packaging>

<name>AutoPlug-Client</name>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Osiris-Team.
* Copyright (c) 2022-2023 Osiris-Team.
* All rights reserved.
*
* This software is copyrighted work, licensed under the terms
Expand Down Expand Up @@ -45,7 +45,7 @@ public SearchResult searchUpdate(MinecraftMod mod, String mcVersion, boolean che
String type = ".jar";
String downloadUrl = null;
byte code = 0;
String modInfo = mod.name + "/" + (Server.isFabric ? "fabric" : "forge");
String modInfo = mod.getName() + "/" + (Server.isFabric ? "fabric" : "forge");
try {
if (!isIdNumber) { // Determine project id, since we only got slug
try {
Expand All @@ -57,15 +57,17 @@ public SearchResult searchUpdate(MinecraftMod mod, String mcVersion, boolean che
}
if (mod.curseforgeId == null) throw new Exception("Failed to determine curseforge-id!");
modInfo += "/" + mod.curseforgeId;
url = baseUrl + "/mods/" + mod.curseforgeId + "/files?gameVersion=" + mcVersion;
url = baseUrl + "/mods/" + mod.curseforgeId + "/files" +
(mod.forceLatest ? "" : "?gameVersion=" + mcVersion);
url = new UtilsURL().clean(url);
AL.debug(this.getClass(), modInfo + " fetch details from: " + url);
JsonArray arr;
try {
arr = new CurseForgeJson().getJsonObject(url).get("data").getAsJsonArray();
} catch (Exception e) {
if (!isInt(mod.curseforgeId)) { // Try another url, with slug replaced _ with -
url = baseUrl + "/mods/" + mod.curseforgeId.replace("_", "-") + "/files?gameVersion=" + mcVersion;
url = baseUrl + "/mods/" + mod.curseforgeId.replace("_", "-") + "/files" +
(mod.forceLatest ? "" : "?gameVersion=" + mcVersion);
url = new UtilsURL().clean(url);
AL.debug(this.getClass(), modInfo + " fetch details from: " + url);
arr = new CurseForgeJson().getJsonObject(url).get("data").getAsJsonArray();
Expand All @@ -83,10 +85,14 @@ public SearchResult searchUpdate(MinecraftMod mod, String mcVersion, boolean che
for (int i = arr.size() - 1; i >= 0; i--) {
JsonObject tempRelease = arr.get(i).getAsJsonObject();
boolean isVersionCompatible = false, isModLoaderCompatible = false;
for (JsonElement el : tempRelease.get("gameVersions").getAsJsonArray()) {
if (el.getAsString().equals(mcVersion)) {
isVersionCompatible = true;
break;
if (mod.forceLatest) {
isVersionCompatible = true;
} else {
for (JsonElement el : tempRelease.get("gameVersions").getAsJsonArray()) {
if (el.getAsString().equals(mcVersion)) {
isVersionCompatible = true;
break;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Osiris-Team.
* Copyright (c) 2022-2023 Osiris-Team.
* All rights reserved.
*
* This software is copyrighted work, licensed under the terms
Expand All @@ -9,25 +9,35 @@
package com.osiris.autoplug.client.tasks.updater.mods;

public class MinecraftMod {
public String installationPath, name, modrinthId, curseforgeId, customDownloadURL;
public String installationPath, modrinthId, curseforgeId, customDownloadURL;
public boolean ignoreContentType;
public String githubRepoName, githubAssetName;
public String jenkinsProjectUrl, jenkinsArtifactName;
public int jenkinsBuildId;
private String author, version;
public boolean forceLatest;
private String name, author, version;

public MinecraftMod(String installationPath, String name, String version,
String author, String modrinthId, String curseforgeId,
String customDownloadURL) {
this.installationPath = installationPath;
this.name = name;
setName(name);
setAuthor(author);
setVersion(version);
this.modrinthId = modrinthId;
this.curseforgeId = curseforgeId;
this.customDownloadURL = customDownloadURL;
}

public String getName() {
return name;
}

public void setName(String name) {
if (name != null)
this.name = name.replaceAll(":", ""); // Before passing over remove : numbers and dots
}

public String getVersion() {
return version;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Osiris-Team.
* Copyright (c) 2022-2023 Osiris-Team.
* All rights reserved.
*
* This software is copyrighted work, licensed under the terms
Expand Down Expand Up @@ -59,7 +59,7 @@ public SearchResult searchUpdate(MinecraftMod mod, String mcVersion) {
if (!isInt(mod.modrinthId)) { // Try another url, with slug replaced _ with -
url = baseUrl + "/project/" + mod.modrinthId.replace("_", "-")
+ "/version?loaders=[\"" +
(Server.isFabric ? "fabric" : "forge") + "\"]&game_versions=[\"" + mcVersion + "\"]";
(Server.isFabric ? "fabric" : "forge") + "\"]" + (mod.forceLatest ? "" : "&game_versions=[\"" + mcVersion + "\"]");
AL.debug(this.getClass(), url);
release = Json.getAsJsonArray(url)
.get(0).getAsJsonObject();
Expand Down
Loading

0 comments on commit 7a6ff9e

Please sign in to comment.