refactor: clean up some unused classes, make some things final and fix a couple String.format

This commit is contained in:
Ryan Dowling 2021-11-20 16:41:37 +11:00
parent 12486ba0d6
commit c040bde02e
No known key found for this signature in database
GPG key ID: 5539FCDB88950EFD
30 changed files with 112 additions and 319 deletions

View file

@ -10,11 +10,11 @@ modpacks easily and quickly.
## Links
- [ATLauncher Website](https://atlauncher.com)
- [ATLauncher Discord](https://atl.pw/discord)
- [ATLauncher Facebook](https://www.facebook.com/ATLauncher)
- [ATLauncher Reddit](https://www.reddit.com/r/ATLauncher)
- [ATLauncher Twitter](https://twitter.com/ATLauncher)
- [ATLauncher Website](https://atlauncher.com)
- [ATLauncher Discord](https://atl.pw/discord)
- [ATLauncher Facebook](https://www.facebook.com/ATLauncher)
- [ATLauncher Reddit](https://www.reddit.com/r/ATLauncher)
- [ATLauncher Twitter](https://twitter.com/ATLauncher)
## Contributing to ATLauncher
@ -26,8 +26,8 @@ Please see the [TESTING.md](TESTING.md) file for information on how we write tes
## Prerequisites
In order to build ATLauncher, you will need Java 8, 9, 10, 11 or 12. Java 8 is recommended since we compile to Java 8
compatability regardless.
In order to build ATLauncher, you will need any Java version 8 or above. Java 8 is recommended since we compile to Java
8 compatability regardless.
Everything else that's needed for the project is provided by Gradle, and accessed using the Gradle wrapper which can be
invoked by using `./gradlew`.
@ -99,9 +99,9 @@ ATLauncher supports custom themes. The process is fairly straight forward, but m
First you must create a `MyThemeName.java` in the `src/main/java/com/atlauncher/themes/` directory. Your theme should
extend one of the base ATLauncher themes depending on what you need:
- `Dark` is the default theme and is a dark theme. It's a good place to start with some defaults for new dark themes.
- `Light` is a light theme. It's a good place to start with some defaults for new light themes.
- `ATLauncherLaf` is a base class which every theme MUST at some point extend. It provides some defaults including our
- `Dark` is the default theme and is a dark theme. It's a good place to start with some defaults for new dark themes.
- `Light` is a light theme. It's a good place to start with some defaults for new light themes.
- `ATLauncherLaf` is a base class which every theme MUST at some point extend. It provides some defaults including our
brand colours and some defaults. This shouldn't be extended from unless you need absolute power.
Once you've created your class (look at other themes in the directory for an idea on what you can do), you'll need to
@ -115,12 +115,12 @@ Now you can open the launcher and then switch to your theme.
We use a library called [FlatLaf](https://github.com/JFormDesigner/FlatLaf) to provide theme support. There are some
good references listed below to see the default values for the themes and see what you can overwrite:
- <https://github.com/JFormDesigner/FlatLaf/blob/master/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLaf.properties>
- This file contains all the base properties for all themes
- <https://github.com/JFormDesigner/FlatLaf/blob/master/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLightLaf.properties>
- This file contains all the base properties for light themes
- <https://github.com/JFormDesigner/FlatLaf/blob/master/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatDarkLaf.properties>
- This file contains all the base properties for dark themes
- <https://github.com/JFormDesigner/FlatLaf/blob/master/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLaf.properties>
- This file contains all the base properties for all themes
- <https://github.com/JFormDesigner/FlatLaf/blob/master/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLightLaf.properties>
- This file contains all the base properties for light themes
- <https://github.com/JFormDesigner/FlatLaf/blob/master/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatDarkLaf.properties>
- This file contains all the base properties for dark themes
### IntelliJ theme.json Support

View file

@ -44,7 +44,6 @@ import com.atlauncher.gui.tabs.NewsTab;
import com.atlauncher.gui.tabs.PacksBrowserTab;
import com.atlauncher.gui.tabs.FeaturedPacksTab;
import com.atlauncher.gui.tabs.ServersTab;
import com.atlauncher.gui.tabs.VanillaPacksTab;
import com.atlauncher.managers.AccountManager;
import com.atlauncher.managers.CheckingServersManager;
import com.atlauncher.managers.ConfigManager;

View file

@ -401,7 +401,7 @@ public class Instance extends MinecraftVersion {
}
public Path getCustomMinecraftJarLibraryPath() {
return ROOT.resolve(String.format("bin/minecraft.jar", this.id));
return ROOT.resolve("bin/minecraft.jar");
}
/**
@ -2293,7 +2293,7 @@ public class Instance extends MinecraftVersion {
if (Files.isDirectory(runtimeDirectory)) {
javaPath = runtimeDirectory.toAbsolutePath().toString();
LogManager.debug(String.format("Using Java runtime %s (major version %n) at path %s",
LogManager.debug(String.format("Using Java runtime %s (major version %d) at path %s",
javaVersion.component, javaVersion.majorVersion, javaPath));
}
}

View file

@ -58,7 +58,7 @@ public class InstanceV1 implements Cloneable {
/**
* The name of the Instance.
*/
private String name;
private final String name;
/**
* The name of the Pack this instance is for.
@ -74,12 +74,12 @@ public class InstanceV1 implements Cloneable {
/**
* The UUID of the user who installed this if it's set to be for that user only.
*/
private String userLock;
private final String userLock;
/**
* The version installed for this Instance.
*/
private String version;
private final String version;
/**
* The hash of this instance if it's a dev version.
@ -89,17 +89,17 @@ public class InstanceV1 implements Cloneable {
/**
* The version of Minecraft that this Instance uses.
*/
private String minecraftVersion;
private final String minecraftVersion;
/**
* The version type that this instance uses.
*/
private String versionType;
private final String versionType;
/**
* The java requirements for this instance.
*/
private Java java;
private final Java java;
/**
* If this version allows Curse mod integration.
@ -116,7 +116,7 @@ public class InstanceV1 implements Cloneable {
/**
* The loader version chosen to be installed for this instance.
*/
private LoaderVersion loaderVersion;
private final LoaderVersion loaderVersion;
/**
* The minimum RAM/memory recommended for this Instance by the pack developer/s.
@ -197,18 +197,18 @@ public class InstanceV1 implements Cloneable {
*
* @see com.atlauncher.data.Pack
*/
private transient Pack realPack;
private final transient Pack realPack;
/**
* If this Instance was installed from a development version of the Pack.
*/
private boolean isDev;
private final boolean isDev;
/**
* If this Instance is playable or not. It may become unplayable after a failed
* update or if files are found corrupt.
*/
private boolean isPlayable;
private final boolean isPlayable;
/**
* List of DisableableMod objects for the mods in the Instance.
@ -223,7 +223,7 @@ public class InstanceV1 implements Cloneable {
*/
private List<String> ignoredUpdates;
private InstanceSettings settings = null;
private final InstanceSettings settings = null;
public transient Path ROOT;

View file

@ -21,7 +21,6 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.Optional;
import com.atlauncher.Gsons;
import com.atlauncher.builders.HTMLBuilder;
import com.atlauncher.data.microsoft.Entitlements;
import com.atlauncher.data.microsoft.LoginResponse;

View file

@ -21,8 +21,8 @@ import com.atlauncher.annot.Json;
@Json
public class Java {
private int min = 0;
private int max = 0;
private final int min = 0;
private final int max = 0;
public int getMin() {
return this.min;

View file

@ -36,16 +36,16 @@ public class XboxLiveAuthErrorResponse {
public String redirect;
public String getErrorMessageForCode() {
if (xErr == 2148916233l) {
if (xErr == 2148916233L) {
return GetText.tr(
"Account doesn't have an Xbox account.<br/><br/>Please create one by logging into minecraft.net before trying to login again.");
}
if (xErr == 2148916238l) {
if (xErr == 2148916238L) {
return GetText.tr("Child accounts cannot login without being part of a family.");
}
if (xErr == 2148916235l) {
if (xErr == 2148916235L) {
return GetText.tr("Account is from a country where Xbox Live is banned/not available.");
}
@ -53,7 +53,7 @@ public class XboxLiveAuthErrorResponse {
}
public String getBrowserLinkForCode() {
if (xErr == 2148916233l) {
if (xErr == 2148916233L) {
return "https://minecraft.net/login";
}

View file

@ -18,8 +18,6 @@
package com.atlauncher.data.minecraft.loaders;
import com.atlauncher.data.Instance;
import com.atlauncher.data.json.Loader;
import com.atlauncher.data.minecraft.loaders.fabric.FabricLoader;
public class LoaderVersion {
public String version;

View file

@ -53,7 +53,7 @@ public class FabricLoader implements Loader {
protected FabricMetaVersion version;
protected File tempDir;
protected InstanceInstaller instanceInstaller;
private Pattern manifestPattern = Pattern.compile("META-INF/[^/]+\\.(SF|DSA|RSA|EC)");
private final Pattern manifestPattern = Pattern.compile("META-INF/[^/]+\\.(SF|DSA|RSA|EC)");
@Override
public void set(Map<String, Object> metadata, File tempDir, InstanceInstaller instanceInstaller,

View file

@ -47,9 +47,9 @@ import org.mini2Dx.gettext.GetText;
@SuppressWarnings("serial")
public final class CurseForgeFileDependencyCard extends JPanel {
private Window parent;
private final Window parent;
private final CurseForgeFileDependency dependency;
private Instance instance;
private final Instance instance;
public CurseForgeFileDependencyCard(Window parent, CurseForgeFileDependency dependency, Instance instance) {
this.parent = parent;

View file

@ -1,115 +0,0 @@
/*
* ATLauncher - https://github.com/ATLauncher/ATLauncher
* Copyright (C) 2013-2021 ATLauncher
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.atlauncher.gui.card;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Window;
import java.util.Comparator;
import java.util.Optional;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.border.EmptyBorder;
import javax.swing.border.TitledBorder;
import com.atlauncher.App;
import com.atlauncher.data.modpacksch.ModpacksChPackArt;
import com.atlauncher.data.modpacksch.ModpacksChPackArtType;
import com.atlauncher.data.modpacksch.ModpacksChPackManifest;
import com.atlauncher.gui.dialogs.InstanceInstallerDialog;
import com.atlauncher.network.Analytics;
import com.atlauncher.utils.OS;
import com.atlauncher.utils.Utils;
import com.atlauncher.workers.BackgroundImageWorker;
import org.mini2Dx.gettext.GetText;
@SuppressWarnings("serial")
public final class FTBPackCard extends JPanel {
private final Window parent;
public final ModpacksChPackManifest pack;
public FTBPackCard(Window parent, final ModpacksChPackManifest pack) {
this.parent = parent;
this.pack = pack;
setupComponents();
}
private void setupComponents() {
setLayout(new BorderLayout());
setPreferredSize(new Dimension(250, 180));
JPanel summaryPanel = new JPanel(new BorderLayout());
JTextArea summary = new JTextArea();
summary.setText(pack.synopsis);
summary.setBorder(BorderFactory.createEmptyBorder(0, 5, 5, 5));
summary.setEditable(false);
summary.setHighlighter(null);
summary.setLineWrap(true);
summary.setWrapStyleWord(true);
summary.setEditable(false);
JLabel icon = new JLabel(Utils.getIconImage("/assets/image/no-icon.png"));
icon.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
icon.setVisible(false);
summaryPanel.add(icon, BorderLayout.WEST);
summaryPanel.add(summary, BorderLayout.CENTER);
summaryPanel.setBorder(new EmptyBorder(0, 0, 10, 0));
JPanel buttonsPanel = new JPanel(new FlowLayout());
JButton addButton = new JButton(GetText.tr("Add"));
JButton viewButton = new JButton(GetText.tr("View"));
buttonsPanel.add(addButton);
buttonsPanel.add(viewButton);
addButton.addActionListener(e -> {
Analytics.sendEvent(pack.name, "Add", "FTBPack");
new InstanceInstallerDialog(parent, pack);
});
// The Feed The Beast website only displays modpacks with the 'FTB'
// tag present, so we should disable the view button for packs without.
if (!pack.hasTag("FTB")) {
viewButton.setEnabled(false);
}
viewButton.addActionListener(e -> OS.openWebBrowser(this.pack.getWebsiteUrl()));
add(summaryPanel, BorderLayout.CENTER);
add(buttonsPanel, BorderLayout.SOUTH);
TitledBorder border = new TitledBorder(null, pack.name, TitledBorder.DEFAULT_JUSTIFICATION,
TitledBorder.DEFAULT_POSITION, App.THEME.getBoldFont().deriveFont(12f));
setBorder(border);
Optional<ModpacksChPackArt> art = pack.art.stream()
.filter(a -> a.type == ModpacksChPackArtType.LOGO || a.type == ModpacksChPackArtType.SQUARE)
.sorted(Comparator.comparingInt((ModpacksChPackArt a) -> a.updated).reversed()).findFirst();
if (art.isPresent()) {
new BackgroundImageWorker(icon, art.get().url).execute();
}
}
}

View file

@ -19,35 +19,25 @@ package com.atlauncher.gui.card;
import java.awt.BorderLayout;
import java.awt.Cursor;
import java.awt.Dialog.ModalityType;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.File;
import java.io.IOException;
import java.sql.Timestamp;
import java.util.Date;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFileChooser;
import javax.swing.JLabel;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JProgressBar;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTextArea;
import javax.swing.filechooser.FileNameExtensionFilter;
import com.atlauncher.App;
import com.atlauncher.FileSystem;
import com.atlauncher.builders.HTMLBuilder;
import com.atlauncher.data.Server;
import com.atlauncher.evnt.listener.RelocalizationListener;
import com.atlauncher.evnt.manager.RelocalizationManager;
@ -58,7 +48,6 @@ import com.atlauncher.managers.DialogManager;
import com.atlauncher.managers.LogManager;
import com.atlauncher.managers.ServerManager;
import com.atlauncher.network.Analytics;
import com.atlauncher.utils.ArchiveUtils;
import com.atlauncher.utils.OS;
import com.atlauncher.utils.Utils;

View file

@ -1,90 +0,0 @@
/*
* ATLauncher - https://github.com/ATLauncher/ATLauncher
* Copyright (C) 2013-2021 ATLauncher
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.atlauncher.gui.card;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionListener;
import java.util.Optional;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.border.EmptyBorder;
import javax.swing.border.TitledBorder;
import com.atlauncher.App;
import com.atlauncher.data.curseforge.CurseForgeAttachment;
import com.atlauncher.data.curseforge.CurseForgeProject;
import com.atlauncher.data.technic.TechnicModpack;
import com.atlauncher.data.technic.TechnicModpackSlim;
import com.atlauncher.utils.OS;
import com.atlauncher.utils.Utils;
import com.atlauncher.workers.BackgroundImageWorker;
import org.mini2Dx.gettext.GetText;
@SuppressWarnings("serial")
public final class TechnicPackCard extends JPanel {
public TechnicPackCard(final TechnicModpackSlim pack, ActionListener al) {
setLayout(new BorderLayout());
setPreferredSize(new Dimension(250, 180));
JPanel summaryPanel = new JPanel(new BorderLayout());
JTextArea summary = new JTextArea();
summary.setText(pack.name);
summary.setBorder(BorderFactory.createEmptyBorder(0, 5, 5, 5));
summary.setEditable(false);
summary.setHighlighter(null);
summary.setLineWrap(true);
summary.setWrapStyleWord(true);
summary.setEditable(false);
JLabel icon = new JLabel(Utils.getIconImage("/assets/image/no-icon.png"));
icon.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
icon.setVisible(false);
summaryPanel.add(icon, BorderLayout.WEST);
summaryPanel.add(summary, BorderLayout.CENTER);
summaryPanel.setBorder(new EmptyBorder(0, 0, 10, 0));
JPanel buttonsPanel = new JPanel(new FlowLayout());
JButton addButton = new JButton(GetText.tr("Add"));
JButton viewButton = new JButton(GetText.tr("View"));
buttonsPanel.add(addButton);
buttonsPanel.add(viewButton);
addButton.addActionListener(al);
viewButton.addActionListener(e -> OS.openWebBrowser(pack.url));
add(summaryPanel, BorderLayout.CENTER);
add(buttonsPanel, BorderLayout.SOUTH);
TitledBorder border = new TitledBorder(null, pack.name, TitledBorder.DEFAULT_JUSTIFICATION,
TitledBorder.DEFAULT_POSITION, App.THEME.getBoldFont().deriveFont(12f));
setBorder(border);
if (pack.iconUrl != null) {
new BackgroundImageWorker(icon, pack.iconUrl).execute();
}
}
}

View file

@ -66,7 +66,7 @@ import org.mini2Dx.gettext.GetText;
@SuppressWarnings("serial")
public final class AddModsDialog extends JDialog {
private Instance instance;
private final Instance instance;
private boolean updating = false;

View file

@ -59,7 +59,7 @@ import org.mini2Dx.gettext.GetText;
public class CurseForgeProjectFileSelectorDialog extends JDialog {
private int filesLength = 0;
private final CurseForgeProject mod;
private Instance instance;
private final Instance instance;
private Integer installedFileId = null;
private final JPanel dependenciesPanel = new JPanel(new FlowLayout());

View file

@ -80,6 +80,7 @@ import com.atlauncher.data.modpacksch.ModpacksChPackLinkType;
import com.atlauncher.data.modpacksch.ModpacksChPackManifest;
import com.atlauncher.data.modpacksch.ModpacksChPackVersion;
import com.atlauncher.data.modrinth.pack.ModrinthModpackManifest;
import com.atlauncher.data.multimc.MultiMCComponent;
import com.atlauncher.data.multimc.MultiMCManifest;
import com.atlauncher.data.technic.TechnicModpack;
import com.atlauncher.data.technic.TechnicModpackSlim;
@ -114,22 +115,22 @@ public class InstanceInstallerDialog extends JDialog {
private MultiMCManifest multiMCManifest = null;
private TechnicModpack technicModpack = null;
private JPanel middle;
private JButton install;
private JTextField nameField;
private final JPanel middle;
private final JButton install;
private final JTextField nameField;
private JComboBox<PackVersion> versionsDropDown;
private JLabel loaderVersionLabel;
private JComboBox<ComboItem<LoaderVersion>> loaderVersionsDropDown;
private final List<LoaderVersion> loaderVersions = new ArrayList<>();
private JLabel showAllMinecraftVersionsLabel = new JLabel(GetText.tr("Show All"));
private JCheckBox showAllMinecraftVersionsCheckbox = new JCheckBox();
private final JLabel showAllMinecraftVersionsLabel = new JLabel(GetText.tr("Show All"));
private final JCheckBox showAllMinecraftVersionsCheckbox = new JCheckBox();
private JLabel saveModsLabel;
private JCheckBox saveModsCheckbox;
private final boolean isUpdate;
private final PackVersion autoInstallVersion;
private Path extractedPath;
private final Path extractedPath;
public InstanceInstallerDialog(CurseForgeManifest manifest, Path curseExtractedPath) {
this(manifest, false, false, null, null, false, curseExtractedPath, App.launcher.getParent());
@ -638,8 +639,15 @@ public class InstanceInstallerDialog extends JDialog {
packVersion.version = "1";
try {
packVersion.minecraftVersion = MinecraftManager.getMinecraftVersion(multiMCManifest.components.stream()
.filter(c -> c.uid.equalsIgnoreCase("net.minecraft")).findFirst().get().version);
Optional<MultiMCComponent> minecraftVersionComponent = multiMCManifest.components.stream()
.filter(c -> c.uid.equalsIgnoreCase("net.minecraft")).findFirst();
if (!minecraftVersionComponent.isPresent()) {
LogManager.error("No net.minecraft component present in manifest");
return;
}
packVersion.minecraftVersion = MinecraftManager.getMinecraftVersion(minecraftVersionComponent.get().version);
} catch (InvalidMinecraftVersion e) {
LogManager.error(e.getMessage());
return;

View file

@ -43,14 +43,14 @@ import org.mini2Dx.gettext.GetText;
@SuppressWarnings("serial")
public class InstanceSettingsDialog extends JDialog {
private Instance instance;
private final Instance instance;
private final JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
private final JPanel bottomPanel = new JPanel();
private GeneralInstanceSettingsTab generalInstanceSettingsTab;
private JavaInstanceSettingsTab javaInstanceSettingsTab;
private CommandsInstanceSettingsTab commandsInstanceSettingsTab;
private final GeneralInstanceSettingsTab generalInstanceSettingsTab;
private final JavaInstanceSettingsTab javaInstanceSettingsTab;
private final CommandsInstanceSettingsTab commandsInstanceSettingsTab;
final ImageIcon HELP_ICON = Utils.getIconImage(App.THEME.getIconPath("question"));
final ImageIcon ERROR_ICON = Utils.getIconImage(App.THEME.getIconPath("error"));

View file

@ -59,8 +59,8 @@ import net.freeutils.httpserver.HTTPServer.VirtualHost;
@SuppressWarnings("serial")
public final class LoginWithMicrosoftDialog extends JDialog {
private static HTTPServer server = new HTTPServer(Constants.MICROSOFT_LOGIN_REDIRECT_PORT);
private static VirtualHost host = server.getVirtualHost(null);
private static final HTTPServer server = new HTTPServer(Constants.MICROSOFT_LOGIN_REDIRECT_PORT);
private static final VirtualHost host = server.getVirtualHost(null);
private MicrosoftAccount account = null;
@ -177,7 +177,7 @@ public final class LoginWithMicrosoftDialog extends JDialog {
}
// if forced to relogin, then make sure they logged into correct account
if (account != null && this.account != null && account.username != this.account.username) {
if (account != null && this.account != null && !account.username.equals(this.account.username)) {
DialogManager.okDialog().setTitle(GetText.tr("Incorrect account"))
.setContent(
GetText.tr("Logged into incorrect account. Please login again on the Accounts tab."))

View file

@ -53,7 +53,7 @@ import org.mini2Dx.gettext.GetText;
public class ModrinthVersionSelectorDialog extends JDialog {
private int filesLength = 0;
private final ModrinthMod mod;
private Instance instance;
private final Instance instance;
private String installedVersionId = null;
private JButton addButton;

View file

@ -48,7 +48,7 @@ public class RenameInstanceDialog extends JDialog {
private JTextField instanceName;
private Instance instance;
private final Instance instance;
public RenameInstanceDialog(Instance instance) {
this(instance, App.launcher.getParent());

View file

@ -38,7 +38,7 @@ import org.mini2Dx.gettext.GetText;
@SuppressWarnings("serial")
public class GeneralInstanceSettingsTab extends JPanel {
private Instance instance;
private final Instance instance;
private JComboBox<ComboItem<String>> account;
private JComboBox<ComboItem<Boolean>> enableDiscordIntegration;

View file

@ -61,7 +61,7 @@ import org.mini2Dx.gettext.GetText;
@SuppressWarnings("serial")
public class JavaInstanceSettingsTab extends JPanel {
private Instance instance;
private final Instance instance;
private JSpinner initialMemory;
private JSpinner maximumMemory;

View file

@ -55,26 +55,26 @@ import org.mini2Dx.gettext.GetText;
@SuppressWarnings("serial")
public final class PacksBrowserTab extends JPanel implements Tab, RelocalizationListener {
private JPanel actionsPanel = new JPanel();
private JPanel categoriesPanel = new JPanel();
private JLabel categoriesLabel = new JLabel();
private JComboBox<ComboItem<Integer>> categoriesComboBox = new JComboBox<>();
private JPanel sortPanel = new JPanel();
private JLabel sortLabel = new JLabel();
private JComboBox<ComboItem<String>> sortComboBox = new JComboBox<>();
private JPanel spacer = new JPanel();
private JTextField searchField = new JTextField();
private JButton searchButton = new JButton();
private final JPanel actionsPanel = new JPanel();
private final JPanel categoriesPanel = new JPanel();
private final JLabel categoriesLabel = new JLabel();
private final JComboBox<ComboItem<Integer>> categoriesComboBox = new JComboBox<>();
private final JPanel sortPanel = new JPanel();
private final JLabel sortLabel = new JLabel();
private final JComboBox<ComboItem<String>> sortComboBox = new JComboBox<>();
private final JPanel spacer = new JPanel();
private final JTextField searchField = new JTextField();
private final JButton searchButton = new JButton();
private JTabbedPane platformTabbedPane = new JTabbedPane();
private PackBrowserPlatformPanel atlauncherPacksPanel = new ATLauncherPacksPanel();
private PackBrowserPlatformPanel curseForgePacksPanel = new CurseForgePacksPanel();
private PackBrowserPlatformPanel ftbPacksPanel = new FTBPacksPanel();
private PackBrowserPlatformPanel modrinthPacksPanel = new ModrinthPacksPanel();
private PackBrowserPlatformPanel technicPacksPanel = new TechnicPacksPanel();
private final JTabbedPane platformTabbedPane = new JTabbedPane();
private final PackBrowserPlatformPanel atlauncherPacksPanel = new ATLauncherPacksPanel();
private final PackBrowserPlatformPanel curseForgePacksPanel = new CurseForgePacksPanel();
private final PackBrowserPlatformPanel ftbPacksPanel = new FTBPacksPanel();
private final PackBrowserPlatformPanel modrinthPacksPanel = new ModrinthPacksPanel();
private final PackBrowserPlatformPanel technicPacksPanel = new TechnicPacksPanel();
private JScrollPane scrollPane;
private JPanel contentPanel = new JPanel();
private final JPanel contentPanel = new JPanel();
private boolean loading = false;
private int page = 1;

View file

@ -74,35 +74,35 @@ import org.mini2Dx.gettext.GetText;
@SuppressWarnings("serial")
public final class VanillaPacksTab extends JPanel implements Tab {
private List<VersionManifestVersionType> minecraftVersionTypeFilters = new ArrayList<>(
private final List<VersionManifestVersionType> minecraftVersionTypeFilters = new ArrayList<>(
Arrays.asList(VersionManifestVersionType.RELEASE));
private String selectedMinecraftVersion = null;
private JTextField nameField = new JTextField(32);
private final JTextField nameField = new JTextField(32);
private boolean nameFieldDirty = false;
private JTextArea descriptionField = new JTextArea(2, 40);
private final JTextArea descriptionField = new JTextArea(2, 40);
private boolean descriptionFieldDirty = false;
private JCheckBox minecraftVersionReleasesFilterCheckbox = new JCheckBox(GetText.tr("Releases"));
private JCheckBox minecraftVersionExperimentsFilterCheckbox = new JCheckBox(GetText.tr("Experiments"));
private JCheckBox minecraftVersionSnapshotsFilterCheckbox = new JCheckBox(GetText.tr("Snapshots"));
private JCheckBox minecraftVersionBetasFilterCheckbox = new JCheckBox(GetText.tr("Betas"));
private JCheckBox minecraftVersionAlphasFilterCheckbox = new JCheckBox(GetText.tr("Alphas"));
private final JCheckBox minecraftVersionReleasesFilterCheckbox = new JCheckBox(GetText.tr("Releases"));
private final JCheckBox minecraftVersionExperimentsFilterCheckbox = new JCheckBox(GetText.tr("Experiments"));
private final JCheckBox minecraftVersionSnapshotsFilterCheckbox = new JCheckBox(GetText.tr("Snapshots"));
private final JCheckBox minecraftVersionBetasFilterCheckbox = new JCheckBox(GetText.tr("Betas"));
private final JCheckBox minecraftVersionAlphasFilterCheckbox = new JCheckBox(GetText.tr("Alphas"));
private JTable minecraftVersionTable;
private DefaultTableModel minecraftVersionTableModel;
private ButtonGroup loaderTypeButtonGroup = new ButtonGroup();
private JRadioButton loaderTypeNoneRadioButton = new JRadioButton(GetText.tr("None"));
private JRadioButton loaderTypeFabricRadioButton = new JRadioButton("Fabric");
private JRadioButton loaderTypeForgeRadioButton = new JRadioButton("Forge");
private JRadioButton loaderTypeQuiltRadioButton = new JRadioButton("Quilt");
private final ButtonGroup loaderTypeButtonGroup = new ButtonGroup();
private final JRadioButton loaderTypeNoneRadioButton = new JRadioButton(GetText.tr("None"));
private final JRadioButton loaderTypeFabricRadioButton = new JRadioButton("Fabric");
private final JRadioButton loaderTypeForgeRadioButton = new JRadioButton("Forge");
private final JRadioButton loaderTypeQuiltRadioButton = new JRadioButton("Quilt");
private JComboBox<ComboItem<LoaderVersion>> loaderVersionsDropDown = new JComboBox<>();
private final JComboBox<ComboItem<LoaderVersion>> loaderVersionsDropDown = new JComboBox<>();
private JButton createServerButton = new JButton(GetText.tr("Create Server"));
private JButton createInstanceButton = new JButton(GetText.tr("Create Instance"));
private final JButton createServerButton = new JButton(GetText.tr("Create Server"));
private final JButton createInstanceButton = new JButton(GetText.tr("Create Instance"));
public VanillaPacksTab() {
super(new BorderLayout());

View file

@ -168,7 +168,7 @@ public class MCLauncher {
String javaPath = instance.getJavaPath();
if (instance.isUsingJavaRuntime()) {
LogManager.debug(String.format("Using Java runtime %s (major version %n) at path %s",
LogManager.debug(String.format("Using Java runtime %s (major version %d) at path %s",
instance.javaVersion.component, instance.javaVersion.majorVersion, javaPath));
}

View file

@ -67,7 +67,7 @@ public final class Download {
private OkHttpClient httpClient = Network.CLIENT;
private RequestBody post = null;
private CacheControl cacheControl = null;
private Map<String, String> headers = new HashMap<String, String>();
private final Map<String, String> headers = new HashMap<String, String>();
// generated on/after request
public Response response;

View file

@ -180,7 +180,7 @@ public class CommandExecutor {
if (Files.isDirectory(runtimeDirectory)) {
javaPath = runtimeDirectory.toAbsolutePath().toString();
LogManager.debug(String.format("Using Java runtime %s (major version %n) at path %s",
LogManager.debug(String.format("Using Java runtime %s (major version %d) at path %s",
instance.javaVersion.component, instance.javaVersion.majorVersion, javaPath));
}
}

View file

@ -64,7 +64,7 @@ public enum OS {
private static int memory = 0;
private static SystemInfo systemInfo = null;
private static Integer memoryFromTool = null;
private static final Integer memoryFromTool = null;
public static OS getOS() {
String osName = System.getProperty("os.name").toLowerCase();

View file

@ -706,7 +706,6 @@ public class Utils {
/**
* Replace text.
*
* @param originalFile the original file
* @param destinationFile the destination file
* @param replaceThis the replace this
* @param withThis the with this

View file

@ -830,8 +830,14 @@ public class InstanceInstaller extends SwingWorker<Boolean, Void> implements Net
throw new Exception("Format is version " + multiMCManifest.formatVersion + " which I cannot install");
}
String minecraftVersion = multiMCManifest.components.stream()
.filter(c -> c.uid.equalsIgnoreCase("net.minecraft")).findFirst().get().version;
Optional<MultiMCComponent> minecraftVersionComponent = multiMCManifest.components.stream()
.filter(c -> c.uid.equalsIgnoreCase("net.minecraft")).findFirst();
if (!minecraftVersionComponent.isPresent()) {
throw new Exception("No net.minecraft component present in manifest");
}
String minecraftVersion = minecraftVersionComponent.get().version;
this.packVersion = new Version();
packVersion.version = "1";