refactor: clean up some things around the main Constants file
This commit is contained in:
parent
9298d3bbaa
commit
6f51e542a4
46 changed files with 95 additions and 256 deletions
|
@ -137,7 +137,7 @@ in your `.properties` file.
|
|||
## Plugging In Your Data
|
||||
|
||||
To get started with the code and plug in your own data, you need to edit the
|
||||
`/src/main/java/com/atlauncher/data/Constants.java` file.
|
||||
`/src/main/java/com/atlauncher/constants/Constants.java` file.
|
||||
|
||||
By using this source code you don't get permissions to use our CDN/files/assets/modpacks. See the License section at the
|
||||
bottom for more.
|
||||
|
|
|
@ -52,7 +52,7 @@ import javax.swing.UIManager;
|
|||
import javax.swing.text.DefaultEditorKit;
|
||||
|
||||
import com.atlauncher.builders.HTMLBuilder;
|
||||
import com.atlauncher.data.Constants;
|
||||
import com.atlauncher.constants.Constants;
|
||||
import com.atlauncher.data.Instance;
|
||||
import com.atlauncher.data.Language;
|
||||
import com.atlauncher.data.Pack;
|
||||
|
|
|
@ -24,7 +24,7 @@ import java.nio.file.Path;
|
|||
import java.nio.file.Paths;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
|
||||
import com.atlauncher.data.Constants;
|
||||
import com.atlauncher.constants.Constants;
|
||||
import com.atlauncher.managers.LogManager;
|
||||
import com.atlauncher.utils.FileUtils;
|
||||
import com.atlauncher.utils.OS;
|
||||
|
|
|
@ -34,7 +34,7 @@ import javax.swing.JFrame;
|
|||
import javax.swing.JLabel;
|
||||
|
||||
import com.atlauncher.builders.HTMLBuilder;
|
||||
import com.atlauncher.data.Constants;
|
||||
import com.atlauncher.constants.Constants;
|
||||
import com.atlauncher.data.DownloadableFile;
|
||||
import com.atlauncher.data.LauncherVersion;
|
||||
import com.atlauncher.gui.dialogs.ProgressDialog;
|
||||
|
|
|
@ -29,7 +29,7 @@ import javax.net.ssl.SSLSocketFactory;
|
|||
import javax.net.ssl.TrustManager;
|
||||
import javax.net.ssl.X509TrustManager;
|
||||
|
||||
import com.atlauncher.data.Constants;
|
||||
import com.atlauncher.constants.Constants;
|
||||
import com.atlauncher.interfaces.NetworkProgressable;
|
||||
import com.atlauncher.listener.ProgressListener;
|
||||
import com.atlauncher.network.DebugLoggingInterceptor;
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
* 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.data;
|
||||
package com.atlauncher.constants;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
|
@ -23,6 +23,7 @@ import java.nio.charset.StandardCharsets;
|
|||
import java.util.stream.Collectors;
|
||||
|
||||
import com.atlauncher.App;
|
||||
import com.atlauncher.data.LauncherVersion;
|
||||
|
||||
public class Constants {
|
||||
static {
|
|
@ -18,6 +18,7 @@
|
|||
package com.atlauncher.data;
|
||||
|
||||
import com.atlauncher.FileSystem;
|
||||
import com.atlauncher.constants.Constants;
|
||||
import com.atlauncher.network.Download;
|
||||
import com.atlauncher.utils.OS;
|
||||
|
||||
|
|
|
@ -46,6 +46,7 @@ import com.atlauncher.Gsons;
|
|||
import com.atlauncher.Network;
|
||||
import com.atlauncher.annot.Json;
|
||||
import com.atlauncher.builders.HTMLBuilder;
|
||||
import com.atlauncher.constants.Constants;
|
||||
import com.atlauncher.data.curse.CurseFile;
|
||||
import com.atlauncher.data.curse.CurseMod;
|
||||
import com.atlauncher.data.curse.CurseModLatestFile;
|
||||
|
|
|
@ -30,6 +30,7 @@ import java.util.stream.Collectors;
|
|||
import com.atlauncher.App;
|
||||
import com.atlauncher.FileSystem;
|
||||
import com.atlauncher.Gsons;
|
||||
import com.atlauncher.constants.Constants;
|
||||
import com.atlauncher.data.json.Java;
|
||||
import com.atlauncher.data.minecraft.ArgumentRule;
|
||||
import com.atlauncher.data.minecraft.Arguments;
|
||||
|
|
|
@ -28,6 +28,7 @@ import javax.swing.ImageIcon;
|
|||
|
||||
import com.atlauncher.FileSystem;
|
||||
import com.atlauncher.Gsons;
|
||||
import com.atlauncher.constants.Constants;
|
||||
import com.atlauncher.data.curse.CurseMod;
|
||||
import com.atlauncher.data.json.Version;
|
||||
import com.atlauncher.data.modpacksch.ModpacksChPackManifest;
|
||||
|
|
|
@ -34,6 +34,7 @@ import java.util.UUID;
|
|||
|
||||
import com.atlauncher.FileSystem;
|
||||
import com.atlauncher.Gsons;
|
||||
import com.atlauncher.constants.Constants;
|
||||
import com.atlauncher.managers.LogManager;
|
||||
import com.atlauncher.utils.OS;
|
||||
import com.atlauncher.utils.Timestamper;
|
||||
|
|
|
@ -19,7 +19,7 @@ package com.atlauncher.data.curse;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import com.atlauncher.data.Constants;
|
||||
import com.atlauncher.constants.Constants;
|
||||
import com.atlauncher.data.json.ModType;
|
||||
|
||||
public class CurseMod {
|
||||
|
|
|
@ -25,7 +25,7 @@ import java.util.List;
|
|||
import com.atlauncher.FileSystem;
|
||||
import com.atlauncher.annot.Json;
|
||||
import com.atlauncher.builders.HTMLBuilder;
|
||||
import com.atlauncher.data.Constants;
|
||||
import com.atlauncher.constants.Constants;
|
||||
import com.atlauncher.data.curse.CurseFile;
|
||||
import com.atlauncher.data.curse.CurseMod;
|
||||
import com.atlauncher.managers.DialogManager;
|
||||
|
|
|
@ -22,7 +22,7 @@ import java.nio.file.Path;
|
|||
|
||||
import com.atlauncher.FileSystem;
|
||||
import com.atlauncher.annot.Json;
|
||||
import com.atlauncher.data.Constants;
|
||||
import com.atlauncher.constants.Constants;
|
||||
import com.atlauncher.data.minecraft.Download;
|
||||
import com.atlauncher.data.minecraft.Downloads;
|
||||
import com.atlauncher.data.minecraft.Library;
|
||||
|
|
|
@ -23,7 +23,7 @@ import java.nio.file.Path;
|
|||
import java.util.List;
|
||||
|
||||
import com.atlauncher.FileSystem;
|
||||
import com.atlauncher.data.Constants;
|
||||
import com.atlauncher.constants.Constants;
|
||||
import com.atlauncher.data.minecraft.Download;
|
||||
import com.atlauncher.data.minecraft.Downloads;
|
||||
import com.atlauncher.managers.LogManager;
|
||||
|
|
|
@ -28,8 +28,8 @@ import java.util.stream.Collectors;
|
|||
import com.atlauncher.FileSystem;
|
||||
import com.atlauncher.Gsons;
|
||||
import com.atlauncher.Network;
|
||||
import com.atlauncher.constants.Constants;
|
||||
import com.atlauncher.data.APIResponse;
|
||||
import com.atlauncher.data.Constants;
|
||||
import com.atlauncher.data.minecraft.ArgumentRule;
|
||||
import com.atlauncher.data.minecraft.Arguments;
|
||||
import com.atlauncher.data.minecraft.Library;
|
||||
|
|
|
@ -34,7 +34,7 @@ import javax.swing.JPopupMenu;
|
|||
import javax.swing.JScrollPane;
|
||||
|
||||
import com.atlauncher.App;
|
||||
import com.atlauncher.data.Constants;
|
||||
import com.atlauncher.constants.Constants;
|
||||
import com.atlauncher.evnt.listener.RelocalizationListener;
|
||||
import com.atlauncher.evnt.manager.ConsoleCloseManager;
|
||||
import com.atlauncher.evnt.manager.ConsoleOpenManager;
|
||||
|
|
|
@ -34,7 +34,7 @@ import javax.swing.JTabbedPane;
|
|||
import javax.swing.WindowConstants;
|
||||
|
||||
import com.atlauncher.App;
|
||||
import com.atlauncher.data.Constants;
|
||||
import com.atlauncher.constants.Constants;
|
||||
import com.atlauncher.data.Pack;
|
||||
import com.atlauncher.data.PackVersion;
|
||||
import com.atlauncher.evnt.listener.RelocalizationListener;
|
||||
|
|
|
@ -31,8 +31,8 @@ import javax.swing.border.TitledBorder;
|
|||
|
||||
import com.atlauncher.App;
|
||||
import com.atlauncher.data.curse.CurseMod;
|
||||
import com.atlauncher.gui.dialogs.InstanceInstallerDialog;
|
||||
import com.atlauncher.network.Analytics;
|
||||
import com.atlauncher.utils.ImportPackUtils;
|
||||
import com.atlauncher.utils.OS;
|
||||
|
||||
import org.mini2Dx.gettext.GetText;
|
||||
|
@ -73,7 +73,8 @@ public final class CurseForgePackCard extends JPanel {
|
|||
|
||||
addButton.addActionListener(e -> {
|
||||
Analytics.sendEvent(project.name, "Add", "CurseForgePack");
|
||||
ImportPackUtils.loadCurseForgePack(parent, project);
|
||||
|
||||
new InstanceInstallerDialog(parent, project);
|
||||
});
|
||||
|
||||
viewButton.addActionListener(e -> OS.openWebBrowser(project.websiteUrl));
|
||||
|
@ -81,8 +82,7 @@ public final class CurseForgePackCard extends JPanel {
|
|||
add(summaryPanel, BorderLayout.CENTER);
|
||||
add(buttonsPanel, BorderLayout.SOUTH);
|
||||
|
||||
TitledBorder border = new TitledBorder(null,
|
||||
project.name, TitledBorder.DEFAULT_JUSTIFICATION,
|
||||
TitledBorder border = new TitledBorder(null, project.name, TitledBorder.DEFAULT_JUSTIFICATION,
|
||||
TitledBorder.DEFAULT_POSITION, App.THEME.getBoldFont().deriveFont(12f));
|
||||
setBorder(border);
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ import java.awt.BorderLayout;
|
|||
import java.awt.Dimension;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.Window;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.JButton;
|
||||
|
@ -30,13 +31,16 @@ import javax.swing.border.EmptyBorder;
|
|||
import javax.swing.border.TitledBorder;
|
||||
|
||||
import com.atlauncher.App;
|
||||
import com.atlauncher.constants.Constants;
|
||||
import com.atlauncher.data.modpacksch.ModpacksChPackManifest;
|
||||
import com.atlauncher.gui.dialogs.InstanceInstallerDialog;
|
||||
import com.atlauncher.network.Analytics;
|
||||
import com.atlauncher.utils.ImportPackUtils;
|
||||
import com.atlauncher.utils.OS;
|
||||
|
||||
import org.mini2Dx.gettext.GetText;
|
||||
|
||||
import okhttp3.CacheControl;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public final class FTBPackCard extends JPanel {
|
||||
private final Window parent;
|
||||
|
@ -73,7 +77,13 @@ public final class FTBPackCard extends JPanel {
|
|||
|
||||
addButton.addActionListener(e -> {
|
||||
Analytics.sendEvent(pack.name, "Add", "FTBPack");
|
||||
ImportPackUtils.loadModpacksChPack(parent, pack.id);
|
||||
|
||||
ModpacksChPackManifest packManifest = com.atlauncher.network.Download.build()
|
||||
.setUrl(String.format("%s/modpack/%d", Constants.MODPACKS_CH_API_URL, pack.id))
|
||||
.cached(new CacheControl.Builder().maxStale(1, TimeUnit.HOURS).build())
|
||||
.asClass(ModpacksChPackManifest.class);
|
||||
|
||||
new InstanceInstallerDialog(parent, packManifest);
|
||||
});
|
||||
|
||||
// The Feed The Beast website only displays modpacks with the 'FTB'
|
||||
|
|
|
@ -55,8 +55,8 @@ import com.atlauncher.App;
|
|||
import com.atlauncher.FileSystem;
|
||||
import com.atlauncher.Gsons;
|
||||
import com.atlauncher.builders.HTMLBuilder;
|
||||
import com.atlauncher.constants.Constants;
|
||||
import com.atlauncher.data.APIResponse;
|
||||
import com.atlauncher.data.Constants;
|
||||
import com.atlauncher.data.Instance;
|
||||
import com.atlauncher.evnt.listener.RelocalizationListener;
|
||||
import com.atlauncher.evnt.manager.RelocalizationManager;
|
||||
|
|
|
@ -28,7 +28,7 @@ import javax.swing.JScrollPane;
|
|||
import javax.swing.JSplitPane;
|
||||
import javax.swing.JTextArea;
|
||||
|
||||
import com.atlauncher.data.Constants;
|
||||
import com.atlauncher.constants.Constants;
|
||||
import com.atlauncher.data.Pack;
|
||||
import com.atlauncher.evnt.listener.RelocalizationListener;
|
||||
import com.atlauncher.evnt.manager.RelocalizationManager;
|
||||
|
|
|
@ -29,7 +29,7 @@ import javax.swing.JPanel;
|
|||
|
||||
import com.atlauncher.App;
|
||||
import com.atlauncher.builders.HTMLBuilder;
|
||||
import com.atlauncher.data.Constants;
|
||||
import com.atlauncher.constants.Constants;
|
||||
import com.atlauncher.evnt.listener.RelocalizationListener;
|
||||
import com.atlauncher.evnt.manager.RelocalizationManager;
|
||||
import com.atlauncher.managers.DialogManager;
|
||||
|
|
|
@ -35,7 +35,7 @@ import javax.swing.JTextField;
|
|||
import javax.swing.SwingUtilities;
|
||||
|
||||
import com.atlauncher.App;
|
||||
import com.atlauncher.data.Constants;
|
||||
import com.atlauncher.constants.Constants;
|
||||
import com.atlauncher.data.curse.CurseMod;
|
||||
import com.atlauncher.gui.card.CurseForgePackCard;
|
||||
import com.atlauncher.gui.layouts.WrapLayout;
|
||||
|
|
|
@ -36,7 +36,7 @@ import javax.swing.JTextField;
|
|||
import javax.swing.SwingUtilities;
|
||||
|
||||
import com.atlauncher.App;
|
||||
import com.atlauncher.data.Constants;
|
||||
import com.atlauncher.constants.Constants;
|
||||
import com.atlauncher.data.modpacksch.ModpacksChPackList;
|
||||
import com.atlauncher.data.modpacksch.ModpacksChPackManifest;
|
||||
import com.atlauncher.gui.card.FTBPackCard;
|
||||
|
|
|
@ -36,7 +36,7 @@ import javax.swing.JTextField;
|
|||
import javax.swing.SwingUtilities;
|
||||
|
||||
import com.atlauncher.App;
|
||||
import com.atlauncher.data.Constants;
|
||||
import com.atlauncher.constants.Constants;
|
||||
import com.atlauncher.data.Instance;
|
||||
import com.atlauncher.data.curse.CurseMod;
|
||||
import com.atlauncher.data.minecraft.loaders.LoaderVersion;
|
||||
|
|
|
@ -38,7 +38,7 @@ import javax.swing.JProgressBar;
|
|||
import javax.swing.JScrollPane;
|
||||
|
||||
import com.atlauncher.App;
|
||||
import com.atlauncher.data.Constants;
|
||||
import com.atlauncher.constants.Constants;
|
||||
import com.atlauncher.data.Instance;
|
||||
import com.atlauncher.data.curse.CurseFile;
|
||||
import com.atlauncher.data.curse.CurseFileDependency;
|
||||
|
@ -201,8 +201,8 @@ public class CurseModFileSelectorDialog extends JDialog {
|
|||
if (dependencies.size() != 0) {
|
||||
dependenciesPanel.removeAll();
|
||||
|
||||
dependencies.forEach(
|
||||
dependency -> dependenciesPanel.add(new CurseFileDependencyCard(this, dependency, instance)));
|
||||
dependencies.forEach(dependency -> dependenciesPanel
|
||||
.add(new CurseFileDependencyCard(this, dependency, instance)));
|
||||
|
||||
dependenciesPanel.setLayout(new GridLayout(dependencies.size() < 2 ? 1 : dependencies.size() / 2,
|
||||
(dependencies.size() / 2) + 1));
|
||||
|
|
|
@ -173,10 +173,10 @@ public class ImportInstanceDialog extends JDialog {
|
|||
|
||||
dialog.addThread(new Thread(() -> {
|
||||
if (!url.getText().isEmpty()) {
|
||||
Analytics.sendEvent(url.getText(), "AddFromUrl", "ImportPack");
|
||||
Analytics.sendEvent(url.getText(), "AddFromUrl", "ImportInstance");
|
||||
dialog.setReturnValue(ImportPackUtils.loadFromUrl(url.getText()));
|
||||
} else if (!filePath.getText().isEmpty()) {
|
||||
Analytics.sendEvent(new File(filePath.getText()).getName(), "AddFromZip", "ImportPack");
|
||||
Analytics.sendEvent(new File(filePath.getText()).getName(), "AddFromZip", "ImportInstance");
|
||||
dialog.setReturnValue(ImportPackUtils.loadFromFile(new File(filePath.getText())));
|
||||
} else {
|
||||
dialog.setReturnValue(false);
|
||||
|
@ -188,9 +188,9 @@ public class ImportInstanceDialog extends JDialog {
|
|||
|
||||
if (!((boolean) dialog.getReturnValue())) {
|
||||
setVisible(true);
|
||||
DialogManager.okDialog().setTitle(GetText.tr("Failed To Add Pack"))
|
||||
DialogManager.okDialog().setTitle(GetText.tr("Failed To Import Instance"))
|
||||
.setContent(new HTMLBuilder().center().text(GetText.tr(
|
||||
"An error occured when trying to add CurseForge pack.<br/><br/>Check the console for more information."))
|
||||
"An error occured when trying to import an instance.<br/><br/>Check the console for more information."))
|
||||
.build())
|
||||
.setType(DialogManager.ERROR).show();
|
||||
} else {
|
||||
|
|
|
@ -28,7 +28,7 @@ import javax.swing.JDialog;
|
|||
import com.atlauncher.App;
|
||||
import com.atlauncher.Gsons;
|
||||
import com.atlauncher.builders.HTMLBuilder;
|
||||
import com.atlauncher.data.Constants;
|
||||
import com.atlauncher.constants.Constants;
|
||||
import com.atlauncher.data.MicrosoftAccount;
|
||||
import com.atlauncher.data.microsoft.LoginResponse;
|
||||
import com.atlauncher.data.microsoft.OauthTokenResponse;
|
||||
|
|
|
@ -35,7 +35,7 @@ import javax.swing.JLabel;
|
|||
import javax.swing.JPanel;
|
||||
|
||||
import com.atlauncher.App;
|
||||
import com.atlauncher.data.Constants;
|
||||
import com.atlauncher.constants.Constants;
|
||||
import com.atlauncher.data.Language;
|
||||
import com.atlauncher.evnt.listener.RelocalizationListener;
|
||||
import com.atlauncher.evnt.manager.RelocalizationManager;
|
||||
|
|
|
@ -1,80 +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.handlers;
|
||||
|
||||
import java.awt.datatransfer.DataFlavor;
|
||||
import java.awt.datatransfer.UnsupportedFlavorException;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.TransferHandler;
|
||||
|
||||
import com.atlauncher.builders.HTMLBuilder;
|
||||
import com.atlauncher.gui.dialogs.ProgressDialog;
|
||||
import com.atlauncher.managers.DialogManager;
|
||||
import com.atlauncher.utils.ImportPackUtils;
|
||||
|
||||
import org.mini2Dx.gettext.GetText;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class CursePackTransferHandler extends TransferHandler {
|
||||
public int getSourceActions(JComponent c) {
|
||||
return COPY;
|
||||
}
|
||||
|
||||
public boolean canImport(TransferSupport ts) {
|
||||
return ts.isDataFlavorSupported(DataFlavor.javaFileListFlavor)
|
||||
|| ts.isDataFlavorSupported(DataFlavor.stringFlavor);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public boolean importData(TransferSupport ts) {
|
||||
final ProgressDialog dialog = new ProgressDialog(GetText.tr("Adding CurseForge Pack"), 0,
|
||||
GetText.tr("Adding CurseForge Pack"));
|
||||
|
||||
dialog.addThread(new Thread(() -> {
|
||||
try {
|
||||
if (ts.getTransferable().isDataFlavorSupported(DataFlavor.stringFlavor)) {
|
||||
dialog.setReturnValue(ImportPackUtils.loadFromCurseForgeUrl(
|
||||
(String) ts.getTransferable().getTransferData(DataFlavor.stringFlavor)));
|
||||
} else if (ts.getTransferable().isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
|
||||
dialog.setReturnValue(ImportPackUtils.loadFromFile(
|
||||
((List<File>) ts.getTransferable().getTransferData(DataFlavor.javaFileListFlavor)).get(0)));
|
||||
}
|
||||
} catch (UnsupportedFlavorException | IOException e) {
|
||||
dialog.setReturnValue(false);
|
||||
}
|
||||
|
||||
dialog.close();
|
||||
}));
|
||||
|
||||
dialog.start();
|
||||
|
||||
if (!((boolean) dialog.getReturnValue())) {
|
||||
DialogManager.okDialog().setTitle(GetText.tr("Failed To Add Pack"))
|
||||
.setContent(new HTMLBuilder().center().text(GetText.tr(
|
||||
"An error occured when trying to add CurseForge pack.<br/><br/>Check the console for more information."))
|
||||
.build())
|
||||
.setType(DialogManager.ERROR).show();
|
||||
}
|
||||
|
||||
return (boolean) dialog.getReturnValue();
|
||||
}
|
||||
}
|
|
@ -34,8 +34,8 @@ import javax.swing.JPanel;
|
|||
|
||||
import com.atlauncher.App;
|
||||
import com.atlauncher.builders.HTMLBuilder;
|
||||
import com.atlauncher.constants.Constants;
|
||||
import com.atlauncher.constants.UIConstants;
|
||||
import com.atlauncher.data.Constants;
|
||||
import com.atlauncher.data.Language;
|
||||
import com.atlauncher.gui.components.JLabelWithHover;
|
||||
import com.atlauncher.utils.ComboItem;
|
||||
|
|
|
@ -38,8 +38,8 @@ import javax.swing.SpinnerNumberModel;
|
|||
|
||||
import com.atlauncher.App;
|
||||
import com.atlauncher.builders.HTMLBuilder;
|
||||
import com.atlauncher.constants.Constants;
|
||||
import com.atlauncher.constants.UIConstants;
|
||||
import com.atlauncher.data.Constants;
|
||||
import com.atlauncher.evnt.listener.RelocalizationListener;
|
||||
import com.atlauncher.evnt.listener.SettingsListener;
|
||||
import com.atlauncher.evnt.manager.RelocalizationManager;
|
||||
|
|
|
@ -29,7 +29,7 @@ import javax.swing.JLabel;
|
|||
import com.atlauncher.App;
|
||||
import com.atlauncher.FileSystem;
|
||||
import com.atlauncher.builders.HTMLBuilder;
|
||||
import com.atlauncher.data.Constants;
|
||||
import com.atlauncher.constants.Constants;
|
||||
import com.atlauncher.evnt.listener.SettingsListener;
|
||||
import com.atlauncher.evnt.manager.SettingsManager;
|
||||
import com.atlauncher.gui.dialogs.ProgressDialog;
|
||||
|
@ -52,10 +52,10 @@ public class NetworkCheckerToolPanel extends AbstractToolPanel implements Action
|
|||
super(GetText.tr("Network Checker"));
|
||||
|
||||
JLabel INFO_LABEL = new JLabel(new HTMLBuilder().center().split(70)
|
||||
.text(GetText
|
||||
.tr("This tool does various tests on your network and determines any issues that may pop up with "
|
||||
+ "connecting to our file servers and to other servers."))
|
||||
.build());
|
||||
.text(GetText.tr(
|
||||
"This tool does various tests on your network and determines any issues that may pop up with "
|
||||
+ "connecting to our file servers and to other servers."))
|
||||
.build());
|
||||
MIDDLE_PANEL.add(INFO_LABEL);
|
||||
BOTTOM_PANEL.add(LAUNCH_BUTTON);
|
||||
LAUNCH_BUTTON.addActionListener(this);
|
||||
|
@ -84,38 +84,48 @@ public class NetworkCheckerToolPanel extends AbstractToolPanel implements Action
|
|||
StringBuilder results = new StringBuilder();
|
||||
|
||||
// Connection to CDN
|
||||
results.append("Ping results to " + Constants.DOWNLOAD_HOST + " was ").append(Utils.pingAddress(Constants.DOWNLOAD_HOST));
|
||||
results.append("Ping results to " + Constants.DOWNLOAD_HOST + " was ")
|
||||
.append(Utils.pingAddress(Constants.DOWNLOAD_HOST));
|
||||
dialog.doneTask();
|
||||
|
||||
results.append("Tracert to " + Constants.DOWNLOAD_HOST + " was ").append(Utils.traceRoute(Constants.DOWNLOAD_HOST)).append("\n\n----------------\n\n");
|
||||
results.append("Tracert to " + Constants.DOWNLOAD_HOST + " was ")
|
||||
.append(Utils.traceRoute(Constants.DOWNLOAD_HOST)).append("\n\n----------------\n\n");
|
||||
dialog.doneTask();
|
||||
|
||||
// Connection to ATLauncher API
|
||||
results.append("Ping results to " + Constants.API_HOST + " was ").append(Utils.pingAddress(Constants.API_HOST));
|
||||
results.append("Ping results to " + Constants.API_HOST + " was ")
|
||||
.append(Utils.pingAddress(Constants.API_HOST));
|
||||
dialog.doneTask();
|
||||
|
||||
results.append("Tracert to " + Constants.API_HOST + " was ").append(Utils.traceRoute(Constants.API_HOST)).append("\n\n----------------\n\n");
|
||||
results.append("Tracert to " + Constants.API_HOST + " was ")
|
||||
.append(Utils.traceRoute(Constants.API_HOST)).append("\n\n----------------\n\n");
|
||||
dialog.doneTask();
|
||||
|
||||
// Connection to Curse API
|
||||
results.append("Ping results to " + Constants.CURSE_HOST + " was ").append(Utils.pingAddress(Constants.CURSE_HOST));
|
||||
results.append("Ping results to " + Constants.CURSE_HOST + " was ")
|
||||
.append(Utils.pingAddress(Constants.CURSE_HOST));
|
||||
dialog.doneTask();
|
||||
|
||||
results.append("Tracert to " + Constants.CURSE_HOST + " was ").append(Utils.traceRoute(Constants.CURSE_HOST)).append("\n\n----------------\n\n");
|
||||
results.append("Tracert to " + Constants.CURSE_HOST + " was ")
|
||||
.append(Utils.traceRoute(Constants.CURSE_HOST)).append("\n\n----------------\n\n");
|
||||
dialog.doneTask();
|
||||
|
||||
// Connection to Fabric CDN
|
||||
results.append("Ping results to " + Constants.FABRIC_HOST + " was ").append(Utils.pingAddress(Constants.FABRIC_HOST));
|
||||
results.append("Ping results to " + Constants.FABRIC_HOST + " was ")
|
||||
.append(Utils.pingAddress(Constants.FABRIC_HOST));
|
||||
dialog.doneTask();
|
||||
|
||||
results.append("Tracert to " + Constants.FABRIC_HOST + " was ").append(Utils.traceRoute(Constants.FABRIC_HOST)).append("\n\n----------------\n\n");
|
||||
results.append("Tracert to " + Constants.FABRIC_HOST + " was ")
|
||||
.append(Utils.traceRoute(Constants.FABRIC_HOST)).append("\n\n----------------\n\n");
|
||||
dialog.doneTask();
|
||||
|
||||
// Connection to Forge CDN
|
||||
results.append("Ping results to " + Constants.FORGE_HOST + " was ").append(Utils.pingAddress(Constants.FORGE_HOST));
|
||||
results.append("Ping results to " + Constants.FORGE_HOST + " was ")
|
||||
.append(Utils.pingAddress(Constants.FORGE_HOST));
|
||||
dialog.doneTask();
|
||||
|
||||
results.append("Tracert to " + Constants.FORGE_HOST + " was ").append(Utils.traceRoute(Constants.FORGE_HOST)).append("\n\n----------------\n\n");
|
||||
results.append("Tracert to " + Constants.FORGE_HOST + " was ")
|
||||
.append(Utils.traceRoute(Constants.FORGE_HOST)).append("\n\n----------------\n\n");
|
||||
dialog.doneTask();
|
||||
|
||||
// Resolution of key services
|
||||
|
@ -123,9 +133,11 @@ public class NetworkCheckerToolPanel extends AbstractToolPanel implements Action
|
|||
try {
|
||||
String resolvedHosts = Arrays.stream(InetAddress.getAllByName(host))
|
||||
.map(InetAddress::getHostAddress).collect(Collectors.joining(", "));
|
||||
results.append("Resolution of ").append(host).append(" was ").append(resolvedHosts).append("\n\n");
|
||||
results.append("Resolution of ").append(host).append(" was ").append(resolvedHosts)
|
||||
.append("\n\n");
|
||||
} catch (Exception e1) {
|
||||
results.append("Resolution of ").append(host).append(" failed: ").append(e1.toString()).append("\n\n");
|
||||
results.append("Resolution of ").append(host).append(" failed: ").append(e1.toString())
|
||||
.append("\n\n");
|
||||
}
|
||||
|
||||
dialog.doneTask();
|
||||
|
|
|
@ -28,7 +28,7 @@ import com.atlauncher.App;
|
|||
import com.atlauncher.FileSystem;
|
||||
import com.atlauncher.Network;
|
||||
import com.atlauncher.builders.HTMLBuilder;
|
||||
import com.atlauncher.data.Constants;
|
||||
import com.atlauncher.constants.Constants;
|
||||
import com.atlauncher.data.Runtime;
|
||||
import com.atlauncher.data.Runtimes;
|
||||
import com.atlauncher.gui.dialogs.ProgressDialog;
|
||||
|
@ -50,10 +50,9 @@ public class RuntimeDownloaderToolPanel extends AbstractToolPanel implements Act
|
|||
public RuntimeDownloaderToolPanel() {
|
||||
super(GetText.tr("Runtime Downloader"));
|
||||
|
||||
JLabel INFO_LABEL = new JLabel(new HTMLBuilder().center().split(70)
|
||||
.text(GetText.tr(
|
||||
"Use this to automatically install and use a recommended version of Java to use with ATLauncher."))
|
||||
.build());
|
||||
JLabel INFO_LABEL = new JLabel(new HTMLBuilder().center().split(70).text(GetText
|
||||
.tr("Use this to automatically install and use a recommended version of Java to use with ATLauncher."))
|
||||
.build());
|
||||
MIDDLE_PANEL.add(INFO_LABEL);
|
||||
BOTTOM_PANEL.add(LAUNCH_BUTTON);
|
||||
LAUNCH_BUTTON.addActionListener(this);
|
||||
|
|
|
@ -22,7 +22,7 @@ import java.util.concurrent.TimeUnit;
|
|||
|
||||
import com.atlauncher.App;
|
||||
import com.atlauncher.Data;
|
||||
import com.atlauncher.data.Constants;
|
||||
import com.atlauncher.constants.Constants;
|
||||
import com.atlauncher.data.Instance;
|
||||
import com.atlauncher.data.modpacksch.ModpacksChPackManifest;
|
||||
import com.atlauncher.data.modpacksch.ModpacksChPackVersion;
|
||||
|
|
|
@ -26,8 +26,8 @@ import java.util.stream.Collectors;
|
|||
|
||||
import com.atlauncher.App;
|
||||
import com.atlauncher.FileSystem;
|
||||
import com.atlauncher.constants.Constants;
|
||||
import com.atlauncher.data.AbstractAccount;
|
||||
import com.atlauncher.data.Constants;
|
||||
import com.atlauncher.data.Instance;
|
||||
import com.atlauncher.data.InstanceSettings;
|
||||
import com.atlauncher.data.LoginResponse;
|
||||
|
|
|
@ -19,7 +19,7 @@ package com.atlauncher.network;
|
|||
|
||||
import com.atlauncher.App;
|
||||
import com.atlauncher.Network;
|
||||
import com.atlauncher.data.Constants;
|
||||
import com.atlauncher.constants.Constants;
|
||||
import com.atlauncher.evnt.listener.SettingsListener;
|
||||
import com.atlauncher.managers.LogManager;
|
||||
import com.atlauncher.utils.Java;
|
||||
|
|
|
@ -22,7 +22,7 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.atlauncher.data.Constants;
|
||||
import com.atlauncher.constants.Constants;
|
||||
import com.atlauncher.data.minecraft.loaders.LoaderVersion;
|
||||
import com.atlauncher.utils.Java;
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ import java.net.URLEncoder;
|
|||
import java.util.concurrent.Callable;
|
||||
|
||||
import com.atlauncher.App;
|
||||
import com.atlauncher.data.Constants;
|
||||
import com.atlauncher.constants.Constants;
|
||||
import com.atlauncher.managers.LogManager;
|
||||
|
||||
public final class PasteUpload implements Callable<String> {
|
||||
|
|
|
@ -26,7 +26,7 @@ import java.util.concurrent.TimeUnit;
|
|||
import java.util.stream.Collectors;
|
||||
|
||||
import com.atlauncher.Gsons;
|
||||
import com.atlauncher.data.Constants;
|
||||
import com.atlauncher.constants.Constants;
|
||||
import com.atlauncher.data.curse.CurseFile;
|
||||
import com.atlauncher.data.curse.CurseFingerprint;
|
||||
import com.atlauncher.data.curse.CurseMod;
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
*/
|
||||
package com.atlauncher.utils;
|
||||
|
||||
import java.awt.Window;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileReader;
|
||||
|
@ -25,104 +24,19 @@ import java.io.IOException;
|
|||
import java.io.InputStream;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Properties;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import com.atlauncher.FileSystem;
|
||||
import com.atlauncher.Gsons;
|
||||
import com.atlauncher.data.APIResponse;
|
||||
import com.atlauncher.data.ATLauncherApiCurseModpack;
|
||||
import com.atlauncher.data.Constants;
|
||||
import com.atlauncher.data.curse.CurseFile;
|
||||
import com.atlauncher.data.curse.CurseMod;
|
||||
import com.atlauncher.data.curse.pack.CurseManifest;
|
||||
import com.atlauncher.data.modpacksch.ModpacksChPackManifest;
|
||||
import com.atlauncher.data.multimc.MultiMCInstanceConfig;
|
||||
import com.atlauncher.data.multimc.MultiMCManifest;
|
||||
import com.atlauncher.gui.dialogs.InstanceInstallerDialog;
|
||||
import com.atlauncher.managers.LogManager;
|
||||
import com.atlauncher.network.Download;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
import org.zeroturnaround.zip.ZipUtil;
|
||||
|
||||
import okhttp3.CacheControl;
|
||||
|
||||
public class ImportPackUtils {
|
||||
/**
|
||||
* Can have multiple formats:
|
||||
*
|
||||
* Simple root url:
|
||||
*
|
||||
* https://www.curseforge.com/minecraft/modpacks/madpack-4
|
||||
*
|
||||
* Main install button on a project:
|
||||
*
|
||||
* https://www.curseforge.com/minecraft/modpacks/madpack-4/download?client=y
|
||||
*
|
||||
* Specific file buttons:
|
||||
*
|
||||
* https://www.curseforge.com/minecraft/modpacks/madpack-4/download/2719411
|
||||
* https://www.curseforge.com/minecraft/modpacks/madpack-4/download/2719411?client=y
|
||||
* https://www.curseforge.com/minecraft/modpacks/madpack-4/files/2719411
|
||||
*/
|
||||
public static boolean loadFromCurseForgeUrl(String url) {
|
||||
if (!url.startsWith("https://www.curseforge.com/minecraft/modpacks")) {
|
||||
LogManager.error("Cannot install as the url was not a Curse modpack url");
|
||||
return false;
|
||||
}
|
||||
|
||||
Pattern pattern = Pattern.compile(
|
||||
"https:\\/\\/www\\.curseforge\\.com\\/minecraft\\/modpacks\\/([a-zA-Z0-9-]+)\\/?(?:download|files)?\\/?([0-9]+)?");
|
||||
Matcher matcher = pattern.matcher(url);
|
||||
|
||||
if (!matcher.find() || matcher.groupCount() < 2) {
|
||||
LogManager.error("Cannot install as the url was not a valid Curse modpack url");
|
||||
return false;
|
||||
}
|
||||
|
||||
String packSlug = matcher.group(1);
|
||||
Integer projectId;
|
||||
Integer fileId = null;
|
||||
|
||||
if (matcher.groupCount() == 2 && matcher.group(2) != null) {
|
||||
fileId = Integer.parseInt(matcher.group(2));
|
||||
}
|
||||
|
||||
java.lang.reflect.Type type = new TypeToken<APIResponse<ATLauncherApiCurseModpack>>() {
|
||||
}.getType();
|
||||
|
||||
APIResponse<ATLauncherApiCurseModpack> curseModpackInfo = com.atlauncher.network.Download.build()
|
||||
.setUrl(String.format("%scurse-modpack/%s", Constants.API_BASE_URL, packSlug))
|
||||
.cached(new CacheControl.Builder().maxStale(1, TimeUnit.HOURS).build()).asType(type);
|
||||
|
||||
if (curseModpackInfo.wasError() || curseModpackInfo.getData() == null
|
||||
|| curseModpackInfo.getData().id == null) {
|
||||
LogManager.error(
|
||||
"Cannot install as we couldn't convert the slug to a project id. Try using a zip file download instead.");
|
||||
return false;
|
||||
}
|
||||
|
||||
projectId = curseModpackInfo.getData().id;
|
||||
|
||||
if (fileId == null) {
|
||||
fileId = CurseApi.getModById(projectId).defaultFileId;
|
||||
}
|
||||
|
||||
if (projectId == null || fileId == null) {
|
||||
LogManager.error(
|
||||
"Cannot install as the id's couldn't be found. Try using a specific files install link instead.");
|
||||
return false;
|
||||
}
|
||||
|
||||
CurseFile curseFile = CurseApi.getFileForMod(projectId, fileId);
|
||||
Path tempZip = FileSystem.TEMP.resolve(curseFile.fileName);
|
||||
|
||||
return loadFromUrl(new Download().setUrl(curseFile.downloadUrl).downloadTo(tempZip).size(curseFile.fileLength)
|
||||
.fingerprint(curseFile.packageFingerprint), projectId, fileId);
|
||||
}
|
||||
|
||||
public static boolean loadFromUrl(String url) {
|
||||
return loadFromUrl(new Download().setUrl(url).downloadTo(FileSystem.TEMP.resolve("import.zip")), null, null);
|
||||
}
|
||||
|
@ -225,26 +139,4 @@ public class ImportPackUtils {
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean loadModpacksChPack(Window parent, int packId) {
|
||||
try {
|
||||
ModpacksChPackManifest packManifest = com.atlauncher.network.Download.build()
|
||||
.setUrl(String.format("%s/modpack/%d", Constants.MODPACKS_CH_API_URL, packId))
|
||||
.cached(new CacheControl.Builder().maxStale(1, TimeUnit.HOURS).build())
|
||||
.asClass(ModpacksChPackManifest.class);
|
||||
|
||||
new InstanceInstallerDialog(parent, packManifest);
|
||||
} catch (Exception e) {
|
||||
LogManager.logStackTrace("Failed to install Modpacks.ch pack", e);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean loadCurseForgePack(Window parent, CurseMod curseForgeProject) {
|
||||
new InstanceInstallerDialog(parent, curseForgeProject);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
import com.atlauncher.Gsons;
|
||||
import com.atlauncher.data.Constants;
|
||||
import com.atlauncher.constants.Constants;
|
||||
import com.atlauncher.data.microsoft.LoginResponse;
|
||||
import com.atlauncher.data.microsoft.OauthTokenResponse;
|
||||
import com.atlauncher.data.microsoft.Profile;
|
||||
|
|
|
@ -49,7 +49,7 @@ import java.util.stream.Collectors;
|
|||
|
||||
import com.atlauncher.FileSystem;
|
||||
import com.atlauncher.Update;
|
||||
import com.atlauncher.data.Constants;
|
||||
import com.atlauncher.constants.Constants;
|
||||
import com.atlauncher.managers.LogManager;
|
||||
import com.atlauncher.managers.PerformanceManager;
|
||||
import com.atlauncher.network.Analytics;
|
||||
|
|
|
@ -78,7 +78,7 @@ import javax.swing.ImageIcon;
|
|||
import com.atlauncher.App;
|
||||
import com.atlauncher.Gsons;
|
||||
import com.atlauncher.Network;
|
||||
import com.atlauncher.data.Constants;
|
||||
import com.atlauncher.constants.Constants;
|
||||
import com.atlauncher.data.minecraft.ExtractRule;
|
||||
import com.atlauncher.data.minecraft.FabricMod;
|
||||
import com.atlauncher.data.minecraft.MCMod;
|
||||
|
|
|
@ -39,8 +39,8 @@ import com.atlauncher.App;
|
|||
import com.atlauncher.FileSystem;
|
||||
import com.atlauncher.Gsons;
|
||||
import com.atlauncher.Network;
|
||||
import com.atlauncher.constants.Constants;
|
||||
import com.atlauncher.data.APIResponse;
|
||||
import com.atlauncher.data.Constants;
|
||||
import com.atlauncher.data.DisableableMod;
|
||||
import com.atlauncher.data.Instance;
|
||||
import com.atlauncher.data.InstanceLauncher;
|
||||
|
|
Loading…
Reference in a new issue