Check for updates on launch on dedicated servers

This commit is contained in:
s809
2025-01-03 00:30:03 +05:00
parent 56e430dff2
commit 5c03c6d99d
3 changed files with 19 additions and 2 deletions
@@ -824,6 +824,7 @@ public class Config
.set(false)
.comment(""
+ "Should Distant Horizons silently, automatically download and install new versions? \n"
+ "This setting is force disabled on dedicated servers for stability reasons. \n"
+ "")
.build();
@@ -117,7 +117,9 @@ public class GitlabGetter
for (Config cfg : currentPipelineInfo)
{
if (!cfg.get("stage").equals("build"))
{
continue;
}
downloads.put(
((String) cfg.get("name")).split("\\[|\\]")[1], // Regex to extract the Minecraft version from the text
new URL(this.GitProjID + "jobs/" + cfg.get("id") + "/artifacts")
@@ -145,7 +147,7 @@ public class GitlabGetter
public static URL getLatestForVersion(String mcVer)
{
try {
return new URL("https://gitlab.com/jeseibel/distant-horizons/-/jobs/artifacts/main/download?job=build:%20[" + mcVer + "]");
return new URL("https://gitlab.com/distant-horizons-team/distant-horizons/-/jobs/artifacts/main/download?job=build:%20%5B" + mcVer + "%5D");
} catch (Exception e) { e.printStackTrace(); return null; } // This should always be safe (unless you stuff up **badly** somewhere)
}
}
@@ -129,14 +129,20 @@ public class SelfUpdater
// Auto-update mod
updateMod(mcVersion, newFileLocation);
return false;
} // else
}
else
{
LOGGER.info("Download link: " + ModrinthGetter.getLatestDownloadForVersion(mcVersion));
}
return true;
}
public static boolean onNightlyStart()
{
if (GitlabGetter.INSTANCE.projectPipelines.size() == 0)
{
return false;
}
com.electronwill.nightconfig.core.Config pipeline = GitlabGetter.INSTANCE.projectPipelines.get(0);
if (!pipeline.get("ref").equals(ModJarInfo.Git_Branch))
@@ -160,7 +166,9 @@ public class SelfUpdater
String latestCommit = pipeline.get("sha");
if (ModJarInfo.Git_Commit.equals(latestCommit)) // If we are already on the latest commit, then dont update
{
return false;
}
LOGGER.info("New version (" + latestCommit + ") of " + ModInfo.READABLE_NAME + " is available");
@@ -171,6 +179,10 @@ public class SelfUpdater
updateMod(mcVersion, newFileLocation);
return false;
}
else
{
LOGGER.info("Download link: " + GitlabGetter.getLatestForVersion(mcVersion));
}
return true;
}
@@ -244,7 +256,9 @@ public class SelfUpdater
public static boolean updateNightlyMod(String minecraftVersion, File file)
{
if (GitlabGetter.INSTANCE.projectPipelines.size() == 0)
{
return false;
}
try
{