Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
# Conflicts:
#	build.gradle
#	src/main/java/net/fabricmc/installer/InstallerGui.java
#	src/main/java/net/fabricmc/installer/client/ClientHandler.java
#	src/main/resources/lang/installer.properties
#	src/main/resources/lang/installer_es_ES.properties
#	src/main/resources/lang/installer_et_EE.properties
#	src/main/resources/lang/installer_fi_FI.properties
#	src/main/resources/lang/installer_fr_FR.properties
#	src/main/resources/lang/installer_ja_JP.properties
#	src/main/resources/lang/installer_pl_PL.properties
#	src/main/resources/lang/installer_pt_BR.properties
#	src/main/resources/lang/installer_ru_RU.properties
#	src/main/resources/lang/installer_zh_CN.properties
  • Loading branch information
thecatcore committed Feb 5, 2024
2 parents b2b5bf5 + 7e37801 commit efe1518
Show file tree
Hide file tree
Showing 17 changed files with 112 additions and 32 deletions.
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ plugins {
}

sourceCompatibility = 1.8
version = '0.11.2'
version = '1.0.0'
archivesBaseName = "legacy-fabric-installer"

def ENV = System.getenv()
Expand Down Expand Up @@ -82,7 +82,7 @@ task serverJar(type: com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar)
}
assemble.dependsOn serverJar

def bootstrapVersion = "0.3.2"
def bootstrapVersion = "0.5.1"
def bootstrapArch = "i686"

task downloadBootstrap(type: Download) {
Expand Down Expand Up @@ -153,7 +153,7 @@ publishing {
}
}

//artifact nativeExe.output
artifact nativeExe.output

// No point in signing as it is designed to get modified
artifact (serverJar) {
Expand Down
21 changes: 19 additions & 2 deletions src/main/java/net/fabricmc/installer/InstallerGui.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@

package net.fabricmc.installer;

import java.awt.Toolkit;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Image;
import java.awt.Toolkit;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Method;
import java.util.Locale;
import java.util.function.Consumer;
import java.util.function.Supplier;
Expand All @@ -46,7 +48,9 @@ public InstallerGui() throws IOException {
setContentPane(contentPane);

setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
setIconImage(Toolkit.getDefaultToolkit().getImage(ClassLoader.getSystemClassLoader().getResource("icon.png")));
Image iconImage = Toolkit.getDefaultToolkit().getImage(ClassLoader.getSystemClassLoader().getResource("icon.png"));
setIconImage(iconImage);
setTaskBarImage(iconImage);

instance = this;

Expand Down Expand Up @@ -95,4 +99,17 @@ private void initComponents() {
contentPane = new JTabbedPane(JTabbedPane.TOP);
Main.HANDLERS.forEach(handler -> contentPane.addTab(Utils.BUNDLE.getString("tab." + handler.name().toLowerCase(Locale.ROOT)), handler.makePanel(this)));
}

private static void setTaskBarImage(Image image) {
try {
// Only supported in Java 9 +
Class<?> taskbarClass = Class.forName("java.awt.Taskbar");
Method getTaskbar = taskbarClass.getDeclaredMethod("getTaskbar");
Method setIconImage = taskbarClass.getDeclaredMethod("setIconImage", Image.class);
Object taskbar = getTaskbar.invoke(null);
setIconImage.invoke(taskbar, image);
} catch (Exception e) {
// Ignored, running on Java 8
}
}
}
24 changes: 20 additions & 4 deletions src/main/java/net/fabricmc/installer/client/ClientHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@

package net.fabricmc.installer.client;

import java.awt.Color;
import java.awt.Desktop;
import java.awt.GridBagConstraints;
import java.awt.Image;
import java.awt.Toolkit;
import java.io.FileNotFoundException;
import java.nio.file.Files;
import java.nio.file.Path;
Expand All @@ -26,6 +29,7 @@
import java.util.List;
import java.util.Locale;

import javax.swing.ImageIcon;
import javax.swing.JCheckBox;
import javax.swing.JEditorPane;
import javax.swing.JOptionPane;
Expand All @@ -39,6 +43,7 @@
import net.fabricmc.installer.launcher.MojangLauncherHelperWrapper;
import net.fabricmc.installer.util.ArgumentParser;
import net.fabricmc.installer.util.InstallerProgress;
import net.fabricmc.installer.util.NoopCaret;
import net.fabricmc.installer.util.Reference;
import net.fabricmc.installer.util.Utils;

Expand Down Expand Up @@ -107,7 +112,7 @@ private void doInstall() {
profileInstaller.setupProfile(profileName, gameVersion, launcherType);
}

SwingUtilities.invokeLater(() -> showInstalledMessage(loaderVersion.name, gameVersion));
SwingUtilities.invokeLater(() -> showInstalledMessage(loaderVersion.name, gameVersion, mcPath.resolve("mods")));
} catch (Exception e) {
error(e);
} finally {
Expand All @@ -116,14 +121,18 @@ private void doInstall() {
}).start();
}

private void showInstalledMessage(String loaderVersion, String gameVersion) {
private void showInstalledMessage(String loaderVersion, String gameVersion, Path modsDirectory) {
JEditorPane pane = new JEditorPane("text/html", "<html><body style=\"" + buildEditorPaneStyle() + "\">" + new MessageFormat(Utils.BUNDLE.getString("prompt.install.successful")).format(new Object[]{loaderVersion, gameVersion, Reference.LEGACY_FABRIC_API_URL}) + "</body></html>");
pane.setBackground(new Color(0, 0, 0, 0));
pane.setEditable(false);
pane.setCaret(new NoopCaret());

pane.addHyperlinkListener(e -> {
try {
if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {
if (e.getDescription().equals("fabric://mods")) {
Desktop.getDesktop().open(modsDirectory.toFile());
} else if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {
Desktop.getDesktop().browse(e.getURL().toURI());
} else {
throw new UnsupportedOperationException("Failed to open " + e.getURL().toString());
Expand All @@ -134,7 +143,14 @@ private void showInstalledMessage(String loaderVersion, String gameVersion) {
}
});

JOptionPane.showMessageDialog(null, pane, Utils.BUNDLE.getString("prompt.install.successful.title"), JOptionPane.INFORMATION_MESSAGE);
final Image iconImage = Toolkit.getDefaultToolkit().getImage(ClassLoader.getSystemClassLoader().getResource("icon.png"));
JOptionPane.showMessageDialog(
null,
pane,
Utils.BUNDLE.getString("prompt.install.successful.title"),
JOptionPane.INFORMATION_MESSAGE,
new ImageIcon(iconImage.getScaledInstance(64, 64, Image.SCALE_DEFAULT))
);
}

private ProfileInstaller.LauncherType showLauncherTypeSelection() {
Expand Down
13 changes: 2 additions & 11 deletions src/main/java/net/fabricmc/installer/client/ClientInstaller.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,8 @@ public static String install(Path mcDir, String gameVersion, LoaderVersion loade
Files.createDirectories(profileDir);
}

/*
This is a fun meme
The vanilla launcher assumes the profile name is the same name as a maven artifact, how ever our profile name is a combination of 2
(mappings and loader). The launcher will also accept any jar with the same name as the profile, it doesnt care if its empty
*/
Path dummyJar = profileDir.resolve(profileName + ".jar");
Files.deleteIfExists(dummyJar);
Files.createFile(dummyJar);
Path profileJar = profileDir.resolve(profileName + ".jar");
Files.deleteIfExists(profileJar);

Json json = FabricService.queryMetaJson(String.format("v2/versions/loader/%s/%s/profile/json", gameVersion, loaderVersion.name));
Files.write(profileJson, json.toString().getBytes(StandardCharsets.UTF_8));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ public void setupProfile(String name, String gameVersion, LauncherType launcherT
profile.set("lastVersionId", name);

Utils.writeToFile(launcherProfiles, jsonObject.toString());

// Create the mods directory
Files.createDirectories(mcDir.resolve("mods"));
}

private static Json createProfile(String name) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/fabricmc/installer/util/CrashDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

public class CrashDialog {
public CrashDialog(Throwable throwable) {
JFrame frame = new JFrame("Fabric installer has crashed!");
JFrame frame = new JFrame(String.format("Fabric installer %s has crashed!", CrashDialog.class.getPackage().getImplementationVersion()));
Container pane = frame.getContentPane();
pane.setLayout(new BorderLayout());

Expand Down
51 changes: 51 additions & 0 deletions src/main/java/net/fabricmc/installer/util/NoopCaret.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* Copyright (c) 2016, 2017, 2018, 2019 FabricMC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package net.fabricmc.installer.util;

import java.awt.event.MouseEvent;

import javax.swing.text.DefaultCaret;

// Disables text selection and the caret.
public class NoopCaret extends DefaultCaret {
public NoopCaret() {
setBlinkRate(0);
super.setSelectionVisible(false);
}

@Override
public int getDot() {
return 0;
}

@Override
public int getMark() {
return 0;
}

@Override
public void setSelectionVisible(boolean vis) {
}

@Override
protected void positionCaret(MouseEvent e) {
}

@Override
protected void moveCaret(MouseEvent e) {
}
}
5 changes: 3 additions & 2 deletions src/main/resources/lang/installer.properties
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ prompt.launcher.type.xbox=Microsoft Store / Xbox
prompt.launcher.type.win32=Standalone (Win32)
prompt.game.version=Minecraft Version:
prompt.ready.install=Ready to install
prompt.select.location=Select Install Location:
prompt.select.location=Launcher Location:
prompt.server.info.jar=The official Minecraft server jar is required to run fabric
prompt.server.info.command=Use this command to start the server
prompt.server.info.scipt=Or generate launch scripts
Expand All @@ -37,7 +37,8 @@ prompt.server.jar.invalid=No valid {0} server jar found
prompt.server.downloading=Downloading {0}/{1} MB
prompt.server.generate=Generate
prompt.server.overwrite=Are you sure you want to override the existing launch scripts?
prompt.server.launcher=Click here to use the standalone server launcher for an easier setup
prompt.install.successful.title=Successfully Installed
prompt.install.successful=Fabric Loader {0} for {1} has been successfully installed.<br>Many mods also require you to put <a href="{2}">Legacy Fabric API</a> into the mods folder.
prompt.install.successful=Fabric Loader {0} for {1} has successfully been installed.<br>Many mods also require you to put <a href="{2}">Legacy Fabric API</a> into the <a href="fabric://mods">mods</a> folder.
tab.client=Client
tab.server=Server
2 changes: 1 addition & 1 deletion src/main/resources/lang/installer_es_ES.properties
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ prompt.server.jar.invalid=No se encontró un JAR del servidor de la {0} válido
prompt.server.generate=Generar
prompt.server.overwrite=¿Estás seguro que quieres sobreescribir los scripts de lanzamiento existentes?
prompt.install.successful.title=Instalado Correctamente
prompt.install.successful=Fabric Loader {0} para {1} ha sido instalado correctamente.<br>Muchos mods también necesitan que descargues <a href="{2}">Legacy Fabric API</a> en tu carpeta de mods.
prompt.install.successful=Fabric Loader {0} para {1} ha sido instalado correctamente.<br>Muchos mods también necesitan que descargues <a href="{2}">Legacy Fabric API</a> en tu carpeta de <a href="fabric://mods">mods</a>.
tab.client=Cliente
tab.server=Servidor
3 changes: 2 additions & 1 deletion src/main/resources/lang/installer_et_EE.properties
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ prompt.server.jar.invalid=Sobivat {0} serveri JARi ei leitud
prompt.server.downloading=Allalaadimine {0}/{1} MB
prompt.server.generate=Genereeri
prompt.server.overwrite=Kas soovid kindlasti olemasolevad käivitusskriptid üle kirjutada?
prompt.server.launcher=Klõpsa siia, et kasutada lihtsamaks seadistuseks eraldiseisvat serverikäivitajat
prompt.install.successful.title=Edukalt paigaldatud
prompt.install.successful=Fabric Loader {0} versioonile {1} on edukalt paigaldatud.<br>Mitmed modid eeldavad ka <a href="{2}">Legacy Fabric API</a> asetamist mods kausta.
prompt.install.successful=Fabric Loader {0} versioonile {1} on edukalt paigaldatud.<br>Mitmed modid eeldavad ka <a href="{2}">Legacy Fabric API</a> asetamist <a href="fabric://mods">mods</a> kausta.
tab.client=Klient
tab.server=Server
2 changes: 1 addition & 1 deletion src/main/resources/lang/installer_fi_FI.properties
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ prompt.server.downloading=Ladataan {0}/{1} Mt
prompt.server.generate=Generoi
prompt.server.overwrite=Haluatko varmasti korvata olemassaolevat käynnistinskriptit?
prompt.install.successful.title=Asennus onnistui
prompt.install.successful=Fabric Loader {0} versiolle {1} asennettiin onnistuneesti.<br>Monet modit vaativat myös <a href="{2}">Legacy Fabric API:n</a> lataamisen mods-kansioon.
prompt.install.successful=Fabric Loader {0} versiolle {1} asennettiin onnistuneesti.<br>Monet modit vaativat myös <a href="{2}">Legacy Fabric API:n</a> lataamisen <a href="fabric://mods">mods</a>-kansioon.
tab.client=Asiakasohjelma
tab.server=Palvelin
2 changes: 1 addition & 1 deletion src/main/resources/lang/installer_fr_FR.properties
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ prompt.server.jar.invalid=Aucun fichier jar serveur {0} valide trouvé
prompt.server.generate=Générer
prompt.server.overwrite=Voulez-vous vraiment remplacer les scripts de lancement existants?
prompt.install.successful.title=Installé avec succès
prompt.install.successful=Fabric Loader {0} pour la version {1} a été installé avec succès. <br> De nombreux mods vous demanderons également de placer <a href="{2}">Legacy Fabric API</a> dans le dossier mods.
prompt.install.successful=Fabric Loader {0} pour la version {1} a été installé avec succès. <br> De nombreux mods vous demanderons également de placer <a href="{2}">Legacy Fabric API</a> dans le dossier <a href="fabric://mods">mods</a>.
tab.client=Client
tab.server=Serveur
2 changes: 1 addition & 1 deletion src/main/resources/lang/installer_ja_JP.properties
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ prompt.server.jar.invalid=無効な {0} サーバー JAR が見つかりまし
prompt.server.generate=生成
prompt.server.overwrite=既存の起動スクリプトを上書きしてもよろしいですか?
prompt.install.successful.title=正常にインストールされました
prompt.install.successful={1}用のFabric ローダー {0} が正常にインストールされました。<br>多くのmodを使用する場合には、<a href="{2}">Legacy Fabric API</a> をmodsフォルダーに入れる必要があります
prompt.install.successful={1}用のFabric ローダー {0} が正常にインストールされました。<br>多くのmodを使用する場合には、<a href="{2}">Legacy Fabric API</a> を<a href="fabric://mods">mods</a>フォルダーに入れる必要があります
tab.client=クライアント
tab.server=サーバー
2 changes: 1 addition & 1 deletion src/main/resources/lang/installer_pl_PL.properties
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ prompt.server.jar.invalid=Poprawny plik jar serwera {0} nie został znaleziony
prompt.server.generate=Generuj
prompt.server.overwrite=Czy na pewno chcesz nadpisać istniejące skrypty uruchamiające?
prompt.install.successful.title=Pomyślnie zainstalowano
prompt.install.successful=Loader Fabric {0} dla {1} został pomyślnie zainstalowany.<br>Wiele modów wymaga także umieszczenia <a href="{2}">Legacy Fabric API</a> w folderze modów.
prompt.install.successful=Loader Fabric {0} dla {1} został pomyślnie zainstalowany.<br>Wiele modów wymaga także umieszczenia <a href="{2}">Legacy Fabric API</a> w folderze <a href="fabric://mods">modów</a>.
tab.client=Klient
tab.server=Serwer
2 changes: 1 addition & 1 deletion src/main/resources/lang/installer_pt_BR.properties
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ prompt.server.downloading=Baixando {0}/{1} MB
prompt.server.generate=Gerar
prompt.server.overwrite=Deseja mesmo sobrescrever os scripts de inicialização atuais?
prompt.install.successful.title=Instalação com êxito
prompt.install.successful=O Fabric Loader {0} para {1} foi instalado com êxito.<br>Muitos mods exigem o <a href="{2}">Legacy Fabric API</a> na pasta de mods.
prompt.install.successful=O Fabric Loader {0} para {1} foi instalado com êxito.<br>Muitos mods exigem o <a href="{2}">Legacy Fabric API</a> na pasta de <a href="fabric://mods">mods</a>.
tab.client=Cliente
tab.server=Servidor
2 changes: 1 addition & 1 deletion src/main/resources/lang/installer_ru_RU.properties
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ prompt.server.jar.invalid=Действительный {0} jar сервера н
prompt.server.generate=Сгенерировать
prompt.server.overwrite=Вы уверены, что хотите переопределить существующий скрипт запуска?
prompt.install.successful.title=Успешно установлено
prompt.install.successful=Загрузчик Fabric {0} для {1} был успешно установлен.<br>Многие моды также требуют, чтобы вы положили <a href="{2}">Legacy Fabric API</a> в папку модов.
prompt.install.successful=Загрузчик Fabric {0} для {1} был успешно установлен.<br>Многие моды также требуют, чтобы вы положили <a href="{2}">Legacy Fabric API</a> в папку <a href="fabric://mods">модов</a>.
tab.client=Клиент
tab.server=Сервер
2 changes: 1 addition & 1 deletion src/main/resources/lang/installer_zh_CN.properties
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ prompt.server.jar.invalid=找不到有效的 {0} 服务端
prompt.server.generate=生成
prompt.server.overwrite=您确定要覆盖现有的启动脚本吗?
prompt.install.successful.title=安装成功
prompt.install.successful={1}的Fabric加载器{0}已成功安装。<br>许多MOD还要求您将<a href="{2}">Legacy Fabric API</a>放入mods文件夹
prompt.install.successful={1}的Fabric加载器{0}已成功安装。<br>许多MOD还要求您将<a href="{2}">Legacy Fabric API</a>放入<a href="fabric://mods">mods</a>文件夹
tab.client=客户端
tab.server=服务端

0 comments on commit efe1518

Please sign in to comment.