Fix auto updater attempting to update to "null"
This commit is contained in:
+8
-1
@@ -36,7 +36,7 @@ public class UpdateModScreen extends DhScreen
|
||||
private String nextVer;
|
||||
|
||||
|
||||
public UpdateModScreen(Screen parent, String newVersionID)
|
||||
public UpdateModScreen(Screen parent, String newVersionID) throws IllegalArgumentException
|
||||
{
|
||||
super(Translatable(ModInfo.ID + ".updater.title"));
|
||||
this.parent = parent;
|
||||
@@ -54,6 +54,13 @@ public class UpdateModScreen extends DhScreen
|
||||
this.currentVer = ModJarInfo.Git_Commit.substring(0,7);
|
||||
this.nextVer = this.newVersionID.substring(0,7);
|
||||
}
|
||||
|
||||
// done to prevent trying to update to "null"
|
||||
// (this can happen if no versions are available to check/download from modrinth/gitlab)
|
||||
if (this.nextVer == null)
|
||||
{
|
||||
throw new IllegalArgumentException("No new version found with the ID ["+newVersionID+"].");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+24
@@ -9,12 +9,14 @@ import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||
import com.seibel.distanthorizons.core.jar.installer.GitlabGetter;
|
||||
import com.seibel.distanthorizons.core.jar.installer.ModrinthGetter;
|
||||
import com.seibel.distanthorizons.core.jar.updater.SelfUpdater;
|
||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.IVersionConstants;
|
||||
import com.seibel.distanthorizons.coreapi.ModInfo;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screens.TitleScreen;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
@@ -31,6 +33,10 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
@Mixin(Minecraft.class)
|
||||
public abstract class MixinMinecraft
|
||||
{
|
||||
@Unique
|
||||
private static final Logger LOGGER = DhLoggerBuilder.getLogger(MixinMinecraft.class.getSimpleName());
|
||||
|
||||
|
||||
@Shadow
|
||||
public abstract boolean isLocalServer();
|
||||
|
||||
@@ -89,6 +95,7 @@ public abstract class MixinMinecraft
|
||||
)
|
||||
private void buildInitialScreens(Runnable runnable)
|
||||
{
|
||||
// TODO merge logic for forge, neo, and fabric
|
||||
if (
|
||||
DEBUG_ALWAYS_SHOW_UPDATER ||
|
||||
(
|
||||
@@ -111,11 +118,28 @@ public abstract class MixinMinecraft
|
||||
versionId = GitlabGetter.INSTANCE.projectPipelines.get(0).get("sha");
|
||||
}
|
||||
|
||||
if (versionId != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
Minecraft.getInstance().setScreen(new UpdateModScreen(
|
||||
// TODO: Change to runnable, instead of tittle screen
|
||||
new TitleScreen(false), // We don't want to use the vanilla title screen as it would fade the buttons
|
||||
versionId
|
||||
));
|
||||
}
|
||||
catch (IllegalArgumentException e)
|
||||
{
|
||||
// info instead of error since this can be ignored and probably just means
|
||||
// there isn't a new DH version available
|
||||
LOGGER.info("Unable to show DH update screen, reason: ["+e.getMessage()+"].");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER.info("Unable to find new DH update for the ["+updateBranch+"] branch. Assuming DH is up to date...");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
+24
@@ -25,6 +25,11 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
@Mixin(Minecraft.class)
|
||||
public class MixinMinecraft
|
||||
{
|
||||
@Unique
|
||||
private static final Logger LOGGER = DhLoggerBuilder.getLogger(MixinMinecraft.class.getSimpleName());
|
||||
|
||||
|
||||
|
||||
#if MC_VER < MC_1_20_2
|
||||
#if MC_VER == MC_1_20_1
|
||||
@Redirect(
|
||||
@@ -68,6 +73,7 @@ public class MixinMinecraft
|
||||
)
|
||||
private void buildInitialScreens(Runnable runnable)
|
||||
{
|
||||
// TODO merge logic for forge, neo, and fabric
|
||||
if (
|
||||
Config.Client.Advanced.AutoUpdater.enableAutoUpdater.get() // Don't do anything if the user doesn't want it
|
||||
&& SelfUpdater.onStart()
|
||||
@@ -86,11 +92,29 @@ public class MixinMinecraft
|
||||
versionId = GitlabGetter.INSTANCE.projectPipelines.get(0).get("sha");
|
||||
}
|
||||
|
||||
if (versionId != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
Minecraft.getInstance().setScreen(new UpdateModScreen(
|
||||
// TODO: Change to runnable, instead of tittle screen
|
||||
new TitleScreen(false), // We don't want to use the vanilla title screen as it would fade the buttons
|
||||
versionId
|
||||
));
|
||||
}
|
||||
catch (IllegalArgumentException e)
|
||||
{
|
||||
// info instead of error since this can be ignored and probably just means
|
||||
// there isn't a new DH version available
|
||||
LOGGER.info("Unable to show DH update screen, reason: ["+e.getMessage()+"].");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER.info("Unable to find new DH update for the ["+updateBranch+"] branch. Assuming DH is up to date...");
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
+38
-1
@@ -7,11 +7,14 @@ import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||
import com.seibel.distanthorizons.core.jar.installer.GitlabGetter;
|
||||
import com.seibel.distanthorizons.core.jar.installer.ModrinthGetter;
|
||||
import com.seibel.distanthorizons.core.jar.updater.SelfUpdater;
|
||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.IVersionConstants;
|
||||
import com.seibel.distanthorizons.coreapi.ModInfo;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screens.TitleScreen;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
@@ -25,6 +28,18 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
@Mixin(Minecraft.class)
|
||||
public class MixinMinecraft
|
||||
{
|
||||
@Unique
|
||||
private static final Logger LOGGER = DhLoggerBuilder.getLogger(MixinMinecraft.class.getSimpleName());
|
||||
|
||||
/**
|
||||
* Can be enabled for testing the auto updater UI. <br/>
|
||||
* will always show the auto updater if set to true.
|
||||
*/
|
||||
@Unique
|
||||
private static final boolean DEBUG_ALWAYS_SHOW_UPDATER = false;
|
||||
|
||||
|
||||
|
||||
// commented out due to a bug with Manifold and having nested preprocessors
|
||||
// and since neoforge doesn't work for anything before MC 1.20.6 anyway it doesn't need to be included
|
||||
|
||||
@@ -71,10 +86,15 @@ public class MixinMinecraft
|
||||
)
|
||||
private void buildInitialScreens(Runnable runnable)
|
||||
{
|
||||
// TODO merge logic for forge, neo, and fabric
|
||||
if (
|
||||
Config.Client.Advanced.AutoUpdater.enableAutoUpdater.get() // Don't do anything if the user doesn't want it
|
||||
DEBUG_ALWAYS_SHOW_UPDATER ||
|
||||
(
|
||||
// Don't do anything if the user doesn't want it
|
||||
Config.Client.Advanced.AutoUpdater.enableAutoUpdater.get()
|
||||
&& SelfUpdater.onStart()
|
||||
)
|
||||
)
|
||||
{
|
||||
runnable = () ->
|
||||
{
|
||||
@@ -89,11 +109,28 @@ public class MixinMinecraft
|
||||
versionId = GitlabGetter.INSTANCE.projectPipelines.get(0).get("sha");
|
||||
}
|
||||
|
||||
if (versionId != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
Minecraft.getInstance().setScreen(new UpdateModScreen(
|
||||
// TODO: Change to runnable, instead of tittle screen
|
||||
new TitleScreen(false), // We don't want to use the vanilla title screen as it would fade the buttons
|
||||
versionId
|
||||
));
|
||||
}
|
||||
catch (IllegalArgumentException e)
|
||||
{
|
||||
// info instead of error since this can be ignored and probably just means
|
||||
// there isn't a new DH version available
|
||||
LOGGER.info("Unable to show DH update screen, reason: ["+e.getMessage()+"].");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER.info("Unable to find new DH update for the ["+updateBranch+"] branch. Assuming DH is up to date...");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user