Skip to content

Commit

Permalink
Fix mirrior message in log having html.
Browse files Browse the repository at this point in the history
  • Loading branch information
LexManos committed Nov 7, 2023
1 parent b3c73d5 commit ac6f9be
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
import net.minecraftforge.installer.actions.ProgressCallback;
import net.minecraftforge.installer.json.Install;
import net.minecraftforge.installer.json.InstallV1;
import net.minecraftforge.installer.json.Mirror;
import net.minecraftforge.installer.json.OptionalLibrary;
import net.minecraftforge.installer.json.Util;

Expand Down Expand Up @@ -356,7 +357,8 @@ private void updateFilePath()

if (profile.getMirror() != null)
{
sponsorButton.setText(action.getSponsorMessage());
String message = String.format("<html><a href=\'%s\'>Data kindly mirrored by %s</a></html>", profile.getMirror().getName(), profile.getMirror().getHomepage());
sponsorButton.setText(message);
sponsorButton.setToolTipText(profile.getMirror().getHomepage());
if (profile.getMirror().getImageAddress() != null)
sponsorButton.setIcon(profile.getMirror().getImage());
Expand Down Expand Up @@ -408,6 +410,7 @@ public void run(ProgressCallback monitor)
try {
prog.setVisible(true);
prog.toFront();

if (action.run(targetDir, optPred, installer)) {
prog.start("Finished!");
prog.progress(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ public static void main(String[] args) throws IOException, URISyntaxException
SimpleInstaller.headless = true;
monitor.message("Target Directory: " + target);
InstallV1 install = Util.loadInstallProfile();
if (install.getMirror() != null)
monitor.stage(String.format("Data kindly mirrored by %s at %s", install.getMirror().getName(), install.getMirror().getHomepage()));

if (!action.getAction(install, monitor).run(target, a -> true, installer))
{
monitor.stage("There was an error during installation");
Expand Down Expand Up @@ -188,6 +191,8 @@ private static void launchGui(ProgressCallback monitor, File installer, String b

try {
InstallV1 profile = Util.loadInstallProfile();
if (profile.getMirror() != null)
monitor.stage(String.format("Data kindly mirrored by %s at %s", profile.getMirror().getName(), profile.getMirror().getHomepage()));
InstallerPanel panel = new InstallerPanel(getMCDir(), profile, installer, badCerts);
panel.run(monitor);
} catch (Throwable e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@ protected void error(String message) {
public abstract String getFileError(File targetDir);
public abstract String getSuccessMessage();

public String getSponsorMessage() {
return profile.getMirror() != null ? String.format(SimpleInstaller.headless ? "Data kindly mirrored by %2$s at %1$s" : "<html><a href=\'%s\'>Data kindly mirrored by %s</a></html>", profile.getMirror().getHomepage(), profile.getMirror().getName()) : null;
}

protected boolean downloadLibraries(File librariesDir, Predicate<String> optionals, List<File> additionalLibDirs) throws ActionCanceledException {
monitor.start("Downloading libraries");
String userHome = System.getProperty("user.home");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ public boolean run(File target, Predicate<String> optionals, File installer) thr
if (!target.exists())
target.mkdirs();
librariesDir.mkdir();
if (profile.getMirror() != null)
monitor.stage(getSponsorMessage());
checkCancel();

// Extract main executable jar
Expand Down

0 comments on commit ac6f9be

Please sign in to comment.