Skip to content

Commit

Permalink
8.1.4
Browse files Browse the repository at this point in the history
- NEW (by @vengestonedragoon): custom-check-url: #### Must link to a json file which contains a list/array of plugin versions where each item/object contains specific keys for version (\"version_number\", \"version\") and download URL (\"download_url\", \"download\", \"file\", \"download_file\").
Also works for mods.
  • Loading branch information
Osiris-Team committed Jun 23, 2024
1 parent 96c7168 commit 176dd66
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 21 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ plugins {
// Important for AutoPlugs Self-Updater!
// Also take a look at the generateAutoplugProperties task where these properties get turned into the actual autoplug.properties file.
group = 'com.osiris.autoplug.client'
version = '8.1.3'
version = '8.1.4'
description = 'Responsible for all the main actions.'

java {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2023 Osiris-Team.
* Copyright (c) 2021-2024 Osiris-Team.
* All rights reserved.
*
* This software is copyrighted work, licensed under the terms
Expand Down Expand Up @@ -46,6 +46,7 @@ public ModsConfig() throws IOException, DuplicateKeyException, YamlReaderExcepti
"curseforge-id: Is also called 'Project-ID' and can be found on the mods curseforge site inside of the 'About' box at the right.\n" +
"ignore-content-type: If true, does not check if the downloaded file is of type jar or zip, and downloads it anyway.\n" +
"force-latest: If true, does not search for updates compatible with this Minecraft version and simply picks the latest release.\n" +
"custom-check-url: #### Must link to a json file which contains a list/array of plugin versions where each item/object contains specific keys for version (\"version_number\", \"version\") and download URL (\"download_url\", \"download\", \"file\", \"download_file\").\n" +
"custom-download-url: must be a static url to the mods latest jar file.\n" +
"alternatives.github.repo-name: Example: 'EssentialsX/Essentials' (can be found in its url: https://github.com/EssentialsX/Essentials)\n" +
"alternatives.github.asset-name: Example: 'EssentialsX' (wrong: 'EssentialsX-1.7.23.jar', we discard the version info).\n" +
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022-2023 Osiris-Team.
* Copyright (c) 2022-2024 Osiris-Team.
* All rights reserved.
*
* This software is copyrighted work, licensed under the terms
Expand All @@ -15,6 +15,7 @@ public class MinecraftMod {
public String jenkinsProjectUrl, jenkinsArtifactName;
public int jenkinsBuildId;
public boolean forceLatest;
public String customCheckURL;
private String name, author, version;

public MinecraftMod(String installationPath, String name, String version,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ public void runAtStart() throws Exception {
YamlSection curseforgeId = modsConfig.put(name, plName, "curseforge-id");
YamlSection ignoreContentType = modsConfig.put(name, plName, "ignore-content-type").setDefValues("false");
YamlSection forceLatest = modsConfig.put(name, plName, "force-latest").setDefValues("false");
YamlSection customCheckURL = modsConfig.put(name, plName, "custom-check-url");
YamlSection customDownloadURL = modsConfig.put(name, plName, "custom-download-url");
YamlSection githubRepoUrl = modsConfig.put(name, plName, "alternatives", "github", "repo-name");
YamlSection githubAssetName = modsConfig.put(name, plName, "alternatives", "github", "asset-name");
Expand All @@ -115,6 +116,7 @@ public void runAtStart() throws Exception {
installedMod.curseforgeId = (curseforgeId.asString());
installedMod.ignoreContentType = (ignoreContentType.asBoolean());
installedMod.forceLatest = (forceLatest.asBoolean());
installedMod.customCheckURL = (customCheckURL.asString());
installedMod.customDownloadURL = (customDownloadURL.asString());
installedMod.githubRepoName = (githubRepoUrl.asString());
installedMod.githubAssetName = (githubAssetName.asString());
Expand Down Expand Up @@ -179,6 +181,7 @@ public void runAtStart() throws Exception {
int sizemodrinthMods = 0;
int sizeBukkitMods = 0;
int sizeUnknownMods = 0;
int sizeCustomMods = 0;


String mcVersion = updaterConfig.mods_updater_version.asString();
Expand All @@ -195,7 +198,10 @@ public void runAtStart() throws Exception {
includedMods) {
try {
setStatus("Initialising update check for " + mod.getName() + "...");
if (mod.jenkinsProjectUrl != null) { // JENKINS MOD
if (mod.customCheckURL != null) { // Custom Check
sizeCustomMods++;
activeFutures.add(executorService.submit(() -> new ResourceFinder().findByCustomCheckURL(mod)));
} else if (mod.jenkinsProjectUrl != null) { // JENKINS MOD
sizeJenkinsMods++;
activeFutures.add(executorService.submit(() -> new ResourceFinder().findByJenkinsUrl(mod)));
} else if (mod.githubRepoName != null) { // GITHUB MOD
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
import com.osiris.autoplug.client.tasks.updater.mods.InstalledModLoader;
import com.osiris.autoplug.client.tasks.updater.mods.MinecraftMod;
import com.osiris.autoplug.client.tasks.updater.mods.ModrinthAPI;
import com.osiris.autoplug.client.tasks.updater.search.CustomCheckURL;
import com.osiris.autoplug.client.tasks.updater.search.GithubSearch;
import com.osiris.autoplug.client.tasks.updater.search.JenkinsSearch;
import com.osiris.autoplug.client.tasks.updater.search.SearchResult;
import com.osiris.autoplug.client.tasks.updater.search.bukkit.BukkitSearchById;
import com.osiris.autoplug.client.tasks.updater.search.spigot.SpigotSearchByAuthor;
import com.osiris.autoplug.client.tasks.updater.search.spigot.SpigotSearchById;
import com.osiris.autoplug.client.tasks.updater.search.spigot.SpigotSearchByName;
import com.osiris.autoplug.client.tasks.updater.search.CustomCheckURL;

public class ResourceFinder {

Expand Down Expand Up @@ -121,8 +121,14 @@ public SearchResult findByJenkinsUrl(MinecraftPlugin plugin) {
return sr;
}

public SearchResult findByCustomCheckURL(MinecraftMod mod) {
SearchResult sr = new CustomCheckURL().doCustomCheck(mod.customCheckURL, mod.getVersion());
sr.mod = mod;
return sr;
}

public SearchResult findByCustomCheckURL(MinecraftPlugin plugin) {
SearchResult sr = new CustomCheckURL().doCustomCheck(plugin);
SearchResult sr = new CustomCheckURL().doCustomCheck(plugin.customCheckURL, plugin.getVersion());
sr.plugin = plugin;
return sr;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ else if (installedPlugin.getVersion() == null || installedPlugin.getVersion().tr
includedPlugins) {
try {
setStatus("Initialising update check for " + pl.getName() + "...");
if (pl.customCheckURL != null) { // Custome Check
if (pl.customCheckURL != null) { // Custom Check
sizeCustomPlugins++;
activeFutures.add(executorService.submit(() -> new ResourceFinder().findByCustomCheckURL(pl)));
} else if (pl.getJenkinsProjectUrl() != null) { // JENKINS PLUGIN
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
/*
* Copyright (c) 2024 Osiris-Team.
* All rights reserved.
*
* This software is copyrighted work, licensed under the terms
* of the MIT-License. Consult the "LICENSE" file for details.
*/

package com.osiris.autoplug.client.tasks.updater.search;

import com.google.gson.JsonObject;
import com.osiris.autoplug.client.tasks.updater.plugins.MinecraftPlugin;
import com.osiris.autoplug.client.tasks.updater.search.SearchResult;
import com.osiris.autoplug.client.utils.UtilsURL;
import com.osiris.jlib.json.Json;
import com.osiris.jlib.logger.AL;

import java.io.File;
import java.time.Instant;
import java.util.ArrayList;
import java.util.List;


public class CustomCheckURL {
Expand All @@ -26,9 +26,7 @@ private boolean isInt(String s) {
}
}

public SearchResult doCustomCheck(MinecraftPlugin plugin) {

String url = plugin.getCustomCheckURL();
public SearchResult doCustomCheck(String url, String currentVersion) {
url = new UtilsURL().clean(url);
Exception exception = null;
String latest = null;
Expand Down Expand Up @@ -68,7 +66,7 @@ public SearchResult doCustomCheck(MinecraftPlugin plugin) {
}
}

String[] pluginVersionComponents = plugin.getVersion().split("\\.");
String[] pluginVersionComponents = currentVersion.split("\\.");
String[] latestVersionComponents = latest.split("\\.");

for (int i = 0; i < Math.min(pluginVersionComponents.length, latestVersionComponents.length); i++) {
Expand All @@ -89,8 +87,8 @@ public SearchResult doCustomCheck(MinecraftPlugin plugin) {
exception = e;
code = 2;
}
if (downloadUrl == null && plugin.customDownloadURL == null)

if (downloadUrl == null && url == null)
code = 2;
SearchResult result = new SearchResult(null, code, latest, downloadUrl, type, null, null, false);
result.setException(exception);
Expand Down

0 comments on commit 176dd66

Please sign in to comment.