Add update branch config "auto"
This commit is contained in:
+30
-3
@@ -1,14 +1,41 @@
|
||||
package com.seibel.distanthorizons.api.enums.config;
|
||||
|
||||
import com.seibel.distanthorizons.coreapi.ModInfo;
|
||||
|
||||
/**
|
||||
* AUTO, <br>
|
||||
* STABLE, <br>
|
||||
* NIGHTLY, <br><br>
|
||||
*
|
||||
* @since API 2.0.0
|
||||
* @version 2024-4-6
|
||||
* @since API 2.1.0
|
||||
* @version 2024-6-8
|
||||
*/
|
||||
public enum EDhApiUpdateBranch
|
||||
{
|
||||
AUTO,
|
||||
STABLE,
|
||||
NIGHTLY
|
||||
NIGHTLY;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* If the updateBranch value is {@link EDhApiUpdateBranch#AUTO}
|
||||
* this method will convert it either to {@link EDhApiUpdateBranch#STABLE} or {@link EDhApiUpdateBranch#NIGHTLY}
|
||||
* based on this jar's state. <Br><br>
|
||||
*
|
||||
* If updateBranch is {@link EDhApiUpdateBranch#STABLE} or {@link EDhApiUpdateBranch#NIGHTLY}
|
||||
* it just returns.
|
||||
*/
|
||||
public static EDhApiUpdateBranch convertAutoToStableOrNightly(EDhApiUpdateBranch updateBranch)
|
||||
{
|
||||
if (updateBranch != EDhApiUpdateBranch.AUTO)
|
||||
{
|
||||
return updateBranch;
|
||||
}
|
||||
else
|
||||
{
|
||||
return ModInfo.IS_DEV_BUILD ? EDhApiUpdateBranch.NIGHTLY : EDhApiUpdateBranch.STABLE;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1054,11 +1054,12 @@ public class Config
|
||||
.build();
|
||||
|
||||
public static ConfigEntry<EDhApiUpdateBranch> updateBranch = new ConfigEntry.Builder<EDhApiUpdateBranch>()
|
||||
.set(
|
||||
ModInfo.IS_DEV_BUILD? EDhApiUpdateBranch.NIGHTLY: EDhApiUpdateBranch.STABLE // If it's already a nightly build, then download the nightly build ofc
|
||||
)
|
||||
.set(EDhApiUpdateBranch.AUTO)
|
||||
.comment(""
|
||||
+ " If DH should use the nightly (provided by Gitlab), or stable (provided by Modrinth) build")
|
||||
+ "If DH should use the nightly (provided by Gitlab), or stable (provided by Modrinth) build. \n"
|
||||
+ "If ["+EDhApiUpdateBranch.AUTO+"] is selected DH will update to new stable releases if the current jar is a stable jar \n"
|
||||
+ "and will update to new nightly builds if the current jar is a nightly jar (IE the version number ends in '-dev')."
|
||||
+ "")
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
package com.seibel.distanthorizons.core.jar.updater;
|
||||
|
||||
import com.seibel.distanthorizons.api.enums.config.EDhApiUpdateBranch;
|
||||
import com.seibel.distanthorizons.core.config.Config;
|
||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||
import com.seibel.distanthorizons.core.jar.JarUtils;
|
||||
@@ -83,15 +84,8 @@ public class SelfUpdater
|
||||
boolean returnValue = false;
|
||||
try
|
||||
{
|
||||
switch (Config.Client.Advanced.AutoUpdater.updateBranch.get())
|
||||
{
|
||||
case STABLE:
|
||||
returnValue = onStableStart();
|
||||
break;
|
||||
case NIGHTLY:
|
||||
returnValue = onNightlyStart();
|
||||
break;
|
||||
};
|
||||
EDhApiUpdateBranch updateBranch = EDhApiUpdateBranch.convertAutoToStableOrNightly(Config.Client.Advanced.AutoUpdater.updateBranch.get());
|
||||
returnValue = (updateBranch == EDhApiUpdateBranch.STABLE) ? onStableStart() : onNightlyStart();
|
||||
}
|
||||
catch (Exception e) // Shouldn't be needed, but just in case
|
||||
{
|
||||
|
||||
@@ -920,6 +920,8 @@
|
||||
"Stable",
|
||||
"distanthorizons.config.enum.EDhApiUpdateBranch.NIGHTLY":
|
||||
"Nightly",
|
||||
"distanthorizons.config.enum.EDhApiUpdateBranch.AUTO":
|
||||
"Auto",
|
||||
|
||||
"distanthorizons.config.enum.EDhApiGrassSideRendering.AS_GRASS":
|
||||
"As Grass",
|
||||
|
||||
Reference in New Issue
Block a user