Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ce24ae4fae | ||
|
|
16152de39d | ||
|
|
4a2ac63d25 | ||
|
|
5437968c83 |
No files matched your search
+2
-1
@@ -96,7 +96,8 @@ public abstract class IAuthenticator {
|
|||||||
public void onLoadSettings(Map m) {
|
public void onLoadSettings(Map m) {
|
||||||
if (m == null)
|
if (m == null)
|
||||||
return;
|
return;
|
||||||
username = (String) m.get("IAuthenticator_UserName");
|
Object o = m.get("IAuthenticator_UserName");
|
||||||
|
username = o instanceof String ? (String) o : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUserName() {
|
public String getUserName() {
|
||||||
|
|||||||
+1
-1
@@ -29,6 +29,6 @@ public class MinecraftRemoteVersion {
|
|||||||
public String getUrl(DownloadType type) {
|
public String getUrl(DownloadType type) {
|
||||||
if (url == null)
|
if (url == null)
|
||||||
return type.getProvider().getVersionsDownloadURL() + id + "/" + id + ".json";
|
return type.getProvider().getVersionsDownloadURL() + id + "/" + id + ".json";
|
||||||
return url;
|
return type.getProvider().getParsedDownloadURL(url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+1
-1
@@ -64,7 +64,7 @@ public class MojangDownloadProvider extends IDownloadProvider {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getAssetsDownloadURL() {
|
public String getAssetsDownloadURL() {
|
||||||
return "http://resources.download.minecraft.net/";
|
return "https://resources.download.minecraft.net/";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+7
-3
@@ -29,6 +29,7 @@ import org.jackhuang.hellominecraft.launcher.core.install.optifine.vanilla.OptiF
|
|||||||
import org.jackhuang.hellominecraft.util.tasks.Task;
|
import org.jackhuang.hellominecraft.util.tasks.Task;
|
||||||
import org.jackhuang.hellominecraft.util.tasks.download.FileDownloadTask;
|
import org.jackhuang.hellominecraft.util.tasks.download.FileDownloadTask;
|
||||||
import org.jackhuang.hellominecraft.util.system.IOUtils;
|
import org.jackhuang.hellominecraft.util.system.IOUtils;
|
||||||
|
import org.jackhuang.hellominecraft.util.tasks.DeleteFileTask;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -61,7 +62,8 @@ public final class MinecraftInstallerService extends IMinecraftInstallerService
|
|||||||
return null;
|
return null;
|
||||||
else
|
else
|
||||||
return new FileDownloadTask(service.getDownloadType().getProvider().getParsedDownloadURL(v.installer), filepath).setTag("forge")
|
return new FileDownloadTask(service.getDownloadType().getProvider().getParsedDownloadURL(v.installer), filepath).setTag("forge")
|
||||||
.after(new ForgeInstaller(service, filepath));
|
.after(new ForgeInstaller(service, filepath))
|
||||||
|
.after(new DeleteFileTask(filepath));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -71,13 +73,15 @@ public final class MinecraftInstallerService extends IMinecraftInstallerService
|
|||||||
return null;
|
return null;
|
||||||
OptiFineDownloadFormatter task = new OptiFineDownloadFormatter(v.installer);
|
OptiFineDownloadFormatter task = new OptiFineDownloadFormatter(v.installer);
|
||||||
return task.after(new FileDownloadTask(filepath).registerPreviousResult(task).setTag("optifine"))
|
return task.after(new FileDownloadTask(filepath).registerPreviousResult(task).setTag("optifine"))
|
||||||
.after(new OptiFineInstaller(service, installId, v, filepath));
|
.after(new OptiFineInstaller(service, installId, v, filepath))
|
||||||
|
.after(new DeleteFileTask(filepath));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Task downloadLiteLoader(String installId, InstallerVersion v) {
|
public Task downloadLiteLoader(String installId, InstallerVersion v) {
|
||||||
File filepath = IOUtils.tryGetCanonicalFile(IOUtils.currentDirWithSeparator() + "liteloader-universal.jar");
|
File filepath = IOUtils.tryGetCanonicalFile(IOUtils.currentDirWithSeparator() + "liteloader-universal.jar");
|
||||||
FileDownloadTask task = (FileDownloadTask) new FileDownloadTask(v.universal, filepath).setTag("LiteLoader");
|
FileDownloadTask task = (FileDownloadTask) new FileDownloadTask(v.universal, filepath).setTag("LiteLoader");
|
||||||
return task.after(new LiteLoaderInstaller(service, installId, (LiteLoaderVersionList.LiteLoaderInstallerVersion) v).registerPreviousResult(task));
|
return task.after(new LiteLoaderInstaller(service, installId, (LiteLoaderVersionList.LiteLoaderInstallerVersion) v).registerPreviousResult(task))
|
||||||
|
.after(new DeleteFileTask(filepath));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+2
-1
@@ -19,6 +19,7 @@ package org.jackhuang.hellominecraft.launcher.core.version;
|
|||||||
|
|
||||||
import org.jackhuang.hellominecraft.launcher.core.download.DownloadType;
|
import org.jackhuang.hellominecraft.launcher.core.download.DownloadType;
|
||||||
import org.jackhuang.hellominecraft.util.StrUtils;
|
import org.jackhuang.hellominecraft.util.StrUtils;
|
||||||
|
import org.jackhuang.hellominecraft.util.system.IOUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -38,7 +39,7 @@ public class LibraryDownloadInfo extends GameDownloadInfo {
|
|||||||
if (path == null)
|
if (path == null)
|
||||||
return null;
|
return null;
|
||||||
else
|
else
|
||||||
myURL += path.replace('\\', '/');
|
myURL = IOUtils.addURLSeparator(myURL) + path.replace('\\', '/');
|
||||||
return myURL;
|
return myURL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -52,10 +52,10 @@ import org.jackhuang.hellominecraft.util.ui.GraphicsUtils;
|
|||||||
import org.jackhuang.hellominecraft.lookandfeel.Theme;
|
import org.jackhuang.hellominecraft.lookandfeel.Theme;
|
||||||
import org.jackhuang.hellominecraft.util.MessageBox;
|
import org.jackhuang.hellominecraft.util.MessageBox;
|
||||||
import org.jackhuang.hellominecraft.util.StrUtils;
|
import org.jackhuang.hellominecraft.util.StrUtils;
|
||||||
import org.jackhuang.hellominecraft.util.Utils;
|
|
||||||
import org.jackhuang.hellominecraft.util.ui.DropShadowBorder;
|
import org.jackhuang.hellominecraft.util.ui.DropShadowBorder;
|
||||||
import org.jackhuang.hellominecraft.util.ui.TintablePanel;
|
import org.jackhuang.hellominecraft.util.ui.TintablePanel;
|
||||||
import org.jackhuang.hellominecraft.util.ui.BasicColors;
|
import org.jackhuang.hellominecraft.util.ui.BasicColors;
|
||||||
|
import org.jackhuang.hellominecraft.util.ui.SwingUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -168,7 +168,7 @@ public final class MainFrame extends DraggableFrame {
|
|||||||
|
|
||||||
ImageIcon headerIcon = Main.getIcon("icon.png");
|
ImageIcon headerIcon = Main.getIcon("icon.png");
|
||||||
this.setIconImage(headerIcon.getImage());
|
this.setIconImage(headerIcon.getImage());
|
||||||
headerIcon = Utils.scaleImage(headerIcon, 16, 16);
|
headerIcon = SwingUtils.scaleImage(headerIcon, 16, 16);
|
||||||
JLabel headerLabel = new JLabel(headerIcon);
|
JLabel headerLabel = new JLabel(headerIcon);
|
||||||
headerLabel.setBorder(BorderFactory.createEmptyBorder(0, 8, 0, 0));
|
headerLabel.setBorder(BorderFactory.createEmptyBorder(0, 8, 0, 0));
|
||||||
header.add(headerLabel);
|
header.add(headerLabel);
|
||||||
@@ -318,7 +318,7 @@ public final class MainFrame extends DraggableFrame {
|
|||||||
ImageIcon background;
|
ImageIcon background;
|
||||||
|
|
||||||
public void loadBackground() {
|
public void loadBackground() {
|
||||||
background = Utils.searchBackgroundImage(Main.getIcon(Settings.getInstance().getTheme().settings.get("Customized.MainFrame.background_image")), Settings.getInstance().getBgpath(), 800, 480);
|
background = SwingUtils.searchBackgroundImage(Main.getIcon(Settings.getInstance().getTheme().settings.get("Customized.MainFrame.background_image")), Settings.getInstance().getBgpath(), 800, 480);
|
||||||
if (background != null)
|
if (background != null)
|
||||||
if (backgroundLabel == null) {
|
if (backgroundLabel == null) {
|
||||||
backgroundLabel = new JLabel(background);
|
backgroundLabel = new JLabel(background);
|
||||||
|
|||||||
@@ -19,19 +19,13 @@ package org.jackhuang.hellominecraft.util;
|
|||||||
|
|
||||||
import org.jackhuang.hellominecraft.util.logging.HMCLog;
|
import org.jackhuang.hellominecraft.util.logging.HMCLog;
|
||||||
import com.sun.management.OperatingSystemMXBean;
|
import com.sun.management.OperatingSystemMXBean;
|
||||||
import java.awt.Image;
|
|
||||||
import java.awt.Toolkit;
|
import java.awt.Toolkit;
|
||||||
import java.awt.datatransfer.StringSelection;
|
import java.awt.datatransfer.StringSelection;
|
||||||
import java.io.File;
|
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
import java.lang.management.ManagementFactory;
|
import java.lang.management.ManagementFactory;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLClassLoader;
|
import java.net.URLClassLoader;
|
||||||
import java.net.URLDecoder;
|
|
||||||
import java.util.Random;
|
|
||||||
import javax.swing.ImageIcon;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author huangyuhui
|
* @author huangyuhui
|
||||||
@@ -52,18 +46,6 @@ public final class Utils {
|
|||||||
return ((URLClassLoader) Utils.class.getClassLoader()).getURLs();
|
return ((URLClassLoader) Utils.class.getClassLoader()).getURLs();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String[] getURLString() {
|
|
||||||
URL[] urls = ((URLClassLoader) Utils.class.getClassLoader()).getURLs();
|
|
||||||
String[] urlStrings = new String[urls.length];
|
|
||||||
for (int i = 0; i < urlStrings.length; i++)
|
|
||||||
try {
|
|
||||||
urlStrings[i] = URLDecoder.decode(urls[i].getPath(), "UTF-8");
|
|
||||||
} catch (UnsupportedEncodingException ex) {
|
|
||||||
HMCLog.warn("Unsupported UTF-8 encoding", ex);
|
|
||||||
}
|
|
||||||
return urlStrings;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getSuggestedMemorySize() {
|
public static int getSuggestedMemorySize() {
|
||||||
try {
|
try {
|
||||||
OperatingSystemMXBean osmb = (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean();
|
OperatingSystemMXBean osmb = (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean();
|
||||||
@@ -80,65 +62,6 @@ public final class Utils {
|
|||||||
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(text), null);
|
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(text), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ImageIcon scaleImage(ImageIcon i, int x, int y) {
|
|
||||||
return new ImageIcon(i.getImage().getScaledInstance(x, y, Image.SCALE_SMOOTH));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ImageIcon searchBackgroundImage(ImageIcon init, String bgpath, int width, int height) {
|
|
||||||
Random r = new Random();
|
|
||||||
boolean loaded = false;
|
|
||||||
ImageIcon background = init;
|
|
||||||
|
|
||||||
// bgpath
|
|
||||||
if (StrUtils.isNotBlank(bgpath) && !loaded) {
|
|
||||||
String[] backgroundPath = bgpath.split(";");
|
|
||||||
if (backgroundPath.length > 0) {
|
|
||||||
int index = r.nextInt(backgroundPath.length);
|
|
||||||
background = new ImageIcon(Toolkit.getDefaultToolkit().getImage(backgroundPath[index]).getScaledInstance(width, height, Image.SCALE_DEFAULT));
|
|
||||||
HMCLog.log("Prepared background image in bgpath.");
|
|
||||||
loaded = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// bgskin
|
|
||||||
if (!loaded) {
|
|
||||||
File backgroundImageFile = new File("bg");
|
|
||||||
if (backgroundImageFile.exists() && backgroundImageFile.isDirectory()) {
|
|
||||||
String[] backgroundPath = backgroundImageFile.list();
|
|
||||||
if (backgroundPath.length > 0) {
|
|
||||||
int index = r.nextInt(backgroundPath.length);
|
|
||||||
background = new ImageIcon(Toolkit.getDefaultToolkit().getImage("bg" + File.separator + backgroundPath[index]).getScaledInstance(width, height, Image.SCALE_DEFAULT));
|
|
||||||
HMCLog.log("Prepared background image in bgskin folder.");
|
|
||||||
loaded = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// background.png
|
|
||||||
if (!loaded) {
|
|
||||||
File backgroundImageFile = new File("background.png");
|
|
||||||
if (backgroundImageFile.exists()) {
|
|
||||||
loaded = true;
|
|
||||||
background = new ImageIcon(Toolkit.getDefaultToolkit().getImage(backgroundImageFile.getAbsolutePath()).getScaledInstance(width, height, Image.SCALE_DEFAULT));
|
|
||||||
HMCLog.log("Prepared background image in background.png.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// background.jpg
|
|
||||||
if (!loaded) {
|
|
||||||
File backgroundImageFile = new File("background.jpg");
|
|
||||||
if (backgroundImageFile.exists()) {
|
|
||||||
//loaded = true;
|
|
||||||
background = new ImageIcon(Toolkit.getDefaultToolkit().getImage(backgroundImageFile.getAbsolutePath()).getScaledInstance(width, height, Image.SCALE_DEFAULT));
|
|
||||||
HMCLog.log("Prepared background image in background.jpg.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (background == null)
|
|
||||||
return init;
|
|
||||||
return background;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* In order to fight against the permission manager by Minecraft Forge.
|
* In order to fight against the permission manager by Minecraft Forge.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -54,6 +54,15 @@ public class IOUtils {
|
|||||||
return path + File.separatorChar;
|
return path + File.separatorChar;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String addURLSeparator(String path) {
|
||||||
|
if (path == null || path.trim().length() == 0)
|
||||||
|
return "";
|
||||||
|
if (path.charAt(path.length() - 1) == '/')
|
||||||
|
return path;
|
||||||
|
else
|
||||||
|
return path + '/';
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isSeparator(char ch) {
|
public static boolean isSeparator(char ch) {
|
||||||
return ch == File.separatorChar || ch == '/' || ch == '\\';
|
return ch == File.separatorChar || ch == '/' || ch == '\\';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
* Hello Minecraft! Launcher.
|
||||||
|
* Copyright (C) 2013 huangyuhui <[email protected]>
|
||||||
|
*
|
||||||
|
* 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 org.jackhuang.hellominecraft.util.tasks;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author huangyuhui
|
||||||
|
*/
|
||||||
|
public class DeleteFileTask extends Task {
|
||||||
|
|
||||||
|
File f;
|
||||||
|
|
||||||
|
public DeleteFileTask(File f) {
|
||||||
|
this.f = f;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void executeTask() throws Throwable {
|
||||||
|
f.delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getInfo() {
|
||||||
|
return "Delete: " + f.getAbsolutePath();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -20,7 +20,8 @@ package org.jackhuang.hellominecraft.util.ui;
|
|||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
import java.awt.EventQueue;
|
import java.awt.EventQueue;
|
||||||
import java.awt.FontMetrics;
|
import java.awt.FontMetrics;
|
||||||
import java.awt.Frame;
|
import java.awt.Image;
|
||||||
|
import java.awt.Toolkit;
|
||||||
import java.awt.Window;
|
import java.awt.Window;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -28,7 +29,9 @@ import java.net.URI;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Random;
|
||||||
import javax.swing.DefaultListModel;
|
import javax.swing.DefaultListModel;
|
||||||
|
import javax.swing.ImageIcon;
|
||||||
import javax.swing.JComboBox;
|
import javax.swing.JComboBox;
|
||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
@@ -302,4 +305,63 @@ public class SwingUtils {
|
|||||||
else
|
else
|
||||||
thisFrame.dispose();
|
thisFrame.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static ImageIcon scaleImage(ImageIcon i, int x, int y) {
|
||||||
|
return new ImageIcon(i.getImage().getScaledInstance(x, y, Image.SCALE_SMOOTH));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ImageIcon searchBackgroundImage(ImageIcon init, String bgpath, int width, int height) {
|
||||||
|
Random r = new Random();
|
||||||
|
boolean loaded = false;
|
||||||
|
ImageIcon background = init;
|
||||||
|
|
||||||
|
// bgpath
|
||||||
|
if (StrUtils.isNotBlank(bgpath) && !loaded) {
|
||||||
|
String[] backgroundPath = bgpath.split(";");
|
||||||
|
if (backgroundPath.length > 0) {
|
||||||
|
int index = r.nextInt(backgroundPath.length);
|
||||||
|
background = new ImageIcon(Toolkit.getDefaultToolkit().getImage(backgroundPath[index]).getScaledInstance(width, height, Image.SCALE_DEFAULT));
|
||||||
|
HMCLog.log("Prepared background image in bgpath.");
|
||||||
|
loaded = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// bgskin
|
||||||
|
if (!loaded) {
|
||||||
|
File backgroundImageFile = new File("bg");
|
||||||
|
if (backgroundImageFile.exists() && backgroundImageFile.isDirectory()) {
|
||||||
|
String[] backgroundPath = backgroundImageFile.list();
|
||||||
|
if (backgroundPath.length > 0) {
|
||||||
|
int index = r.nextInt(backgroundPath.length);
|
||||||
|
background = new ImageIcon(Toolkit.getDefaultToolkit().getImage("bg" + File.separator + backgroundPath[index]).getScaledInstance(width, height, Image.SCALE_DEFAULT));
|
||||||
|
HMCLog.log("Prepared background image in bgskin folder.");
|
||||||
|
loaded = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// background.png
|
||||||
|
if (!loaded) {
|
||||||
|
File backgroundImageFile = new File("background.png");
|
||||||
|
if (backgroundImageFile.exists()) {
|
||||||
|
loaded = true;
|
||||||
|
background = new ImageIcon(Toolkit.getDefaultToolkit().getImage(backgroundImageFile.getAbsolutePath()).getScaledInstance(width, height, Image.SCALE_DEFAULT));
|
||||||
|
HMCLog.log("Prepared background image in background.png.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// background.jpg
|
||||||
|
if (!loaded) {
|
||||||
|
File backgroundImageFile = new File("background.jpg");
|
||||||
|
if (backgroundImageFile.exists()) {
|
||||||
|
//loaded = true;
|
||||||
|
background = new ImageIcon(Toolkit.getDefaultToolkit().getImage(backgroundImageFile.getAbsolutePath()).getScaledInstance(width, height, Image.SCALE_DEFAULT));
|
||||||
|
HMCLog.log("Prepared background image in background.jpg.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (background == null)
|
||||||
|
return init;
|
||||||
|
return background;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user