initializing modpack coding process

This commit is contained in:
huangyuhui
2016-01-23 12:23:56 +08:00
parent 0da589374a
commit 102205de40
151 changed files with 621 additions and 354 deletions

File diff suppressed because one or more lines are too long

View File

@@ -26,10 +26,10 @@ import java.net.URL;
import java.net.URLClassLoader; import java.net.URLClassLoader;
import java.util.ArrayList; import java.util.ArrayList;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import org.jackhuang.hellominecraft.C; import org.jackhuang.hellominecraft.utils.C;
import org.jackhuang.hellominecraft.HMCLog; import org.jackhuang.hellominecraft.utils.HMCLog;
import org.jackhuang.hellominecraft.utils.StrUtils; import org.jackhuang.hellominecraft.utils.StrUtils;
import org.jackhuang.hellominecraft.views.LogWindow; import org.jackhuang.hellominecraft.utils.views.LogWindow;
import org.jackhuang.hellominecraft.launcher.utils.MinecraftCrashAdvicer; import org.jackhuang.hellominecraft.launcher.utils.MinecraftCrashAdvicer;
import org.jackhuang.hellominecraft.utils.DoubleOutputStream; import org.jackhuang.hellominecraft.utils.DoubleOutputStream;
import org.jackhuang.hellominecraft.utils.LauncherPrintStream; import org.jackhuang.hellominecraft.utils.LauncherPrintStream;

View File

@@ -32,14 +32,14 @@ import javax.net.ssl.X509TrustManager;
import javax.swing.ImageIcon; import javax.swing.ImageIcon;
import javax.swing.UIManager; import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException; import javax.swing.UnsupportedLookAndFeelException;
import org.jackhuang.hellominecraft.HMCLog; import org.jackhuang.hellominecraft.utils.HMCLog;
import org.jackhuang.hellominecraft.launcher.api.PluginManager; import org.jackhuang.hellominecraft.launcher.api.PluginManager;
import org.jackhuang.hellominecraft.launcher.core.launch.GameLauncher; import org.jackhuang.hellominecraft.launcher.core.launch.GameLauncher;
import org.jackhuang.hellominecraft.launcher.utils.CrashReporter; import org.jackhuang.hellominecraft.launcher.utils.CrashReporter;
import org.jackhuang.hellominecraft.logging.Configuration; import org.jackhuang.hellominecraft.utils.logging.Configuration;
import org.jackhuang.hellominecraft.logging.appender.ConsoleAppender; import org.jackhuang.hellominecraft.utils.logging.appender.ConsoleAppender;
import org.jackhuang.hellominecraft.logging.layout.DefaultLayout; import org.jackhuang.hellominecraft.utils.logging.layout.DefaultLayout;
import org.jackhuang.hellominecraft.views.LogWindow; import org.jackhuang.hellominecraft.utils.views.LogWindow;
import org.jackhuang.hellominecraft.launcher.settings.Settings; import org.jackhuang.hellominecraft.launcher.settings.Settings;
import org.jackhuang.hellominecraft.launcher.utils.upgrade.IUpgrader; import org.jackhuang.hellominecraft.launcher.utils.upgrade.IUpgrader;
import org.jackhuang.hellominecraft.launcher.views.MainFrame; import org.jackhuang.hellominecraft.launcher.views.MainFrame;
@@ -47,6 +47,7 @@ import org.jackhuang.hellominecraft.lookandfeel.HelloMinecraftLookAndFeel;
import org.jackhuang.hellominecraft.utils.MathUtils; import org.jackhuang.hellominecraft.utils.MathUtils;
import org.jackhuang.hellominecraft.utils.StrUtils; import org.jackhuang.hellominecraft.utils.StrUtils;
import org.jackhuang.hellominecraft.utils.VersionNumber; import org.jackhuang.hellominecraft.utils.VersionNumber;
import org.jackhuang.hellominecraft.utils.system.Compressor;
import rx.concurrency.Schedulers; import rx.concurrency.Schedulers;
/** /**
@@ -87,7 +88,7 @@ public final class Main implements Runnable {
} }
public static final String LAUNCHER_NAME = "Hello Minecraft! Launcher"; public static final String LAUNCHER_NAME = "Hello Minecraft! Launcher";
public static final byte VERSION_FIRST = 2, VERSION_SECOND = 3, VERSION_THIRD = 5, VERSION_FORTH = 7; public static final byte VERSION_FIRST = 2, VERSION_SECOND = 3, VERSION_THIRD = 5, VERSION_FORTH = 8;
public static final int MINIMUM_LAUNCHER_VERSION = 16; public static final int MINIMUM_LAUNCHER_VERSION = 16;
//public static Proxy PROXY; //public static Proxy PROXY;
@@ -113,7 +114,7 @@ public final class Main implements Runnable {
public static HelloMinecraftLookAndFeel LOOK_AND_FEEL; public static HelloMinecraftLookAndFeel LOOK_AND_FEEL;
@SuppressWarnings({ "CallToPrintStackTrace", "UseSpecificCatch" }) @SuppressWarnings({ "CallToPrintStackTrace", "UseSpecificCatch" })
public static void main(String[] args) { public static void main(String[] args) throws IOException {
{ {
//PluginManager.getServerPlugin(); //PluginManager.getServerPlugin();

View File

@@ -17,7 +17,7 @@
*/ */
package org.jackhuang.hellominecraft.launcher.api; package org.jackhuang.hellominecraft.launcher.api;
import org.jackhuang.hellominecraft.HMCLog; import org.jackhuang.hellominecraft.utils.HMCLog;
import org.jackhuang.hellominecraft.launcher.settings.DefaultPlugin; import org.jackhuang.hellominecraft.launcher.settings.DefaultPlugin;
/** /**

View File

@@ -25,8 +25,8 @@ import java.io.InputStreamReader;
import java.util.List; import java.util.List;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
import java.util.zip.ZipFile; import java.util.zip.ZipFile;
import org.jackhuang.hellominecraft.C; import org.jackhuang.hellominecraft.utils.C;
import org.jackhuang.hellominecraft.HMCLog; import org.jackhuang.hellominecraft.utils.HMCLog;
import org.jackhuang.hellominecraft.utils.StrUtils; import org.jackhuang.hellominecraft.utils.StrUtils;
import org.jackhuang.hellominecraft.utils.system.FileUtils; import org.jackhuang.hellominecraft.utils.system.FileUtils;

View File

@@ -21,10 +21,10 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Map; import java.util.Map;
import org.jackhuang.hellominecraft.C; import org.jackhuang.hellominecraft.utils.C;
import org.jackhuang.hellominecraft.HMCLog; import org.jackhuang.hellominecraft.utils.HMCLog;
import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftAssetService; import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftAssetService;
import org.jackhuang.hellominecraft.tasks.Task; import org.jackhuang.hellominecraft.utils.tasks.Task;
import org.jackhuang.hellominecraft.utils.system.FileUtils; import org.jackhuang.hellominecraft.utils.system.FileUtils;
import org.jackhuang.hellominecraft.utils.system.IOUtils; import org.jackhuang.hellominecraft.utils.system.IOUtils;
import org.jackhuang.hellominecraft.utils.StrUtils; import org.jackhuang.hellominecraft.utils.StrUtils;

View File

@@ -23,13 +23,13 @@ import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import org.jackhuang.hellominecraft.C; import org.jackhuang.hellominecraft.utils.C;
import org.jackhuang.hellominecraft.HMCLog; import org.jackhuang.hellominecraft.utils.HMCLog;
import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftAssetService; import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftAssetService;
import org.jackhuang.hellominecraft.launcher.core.download.IDownloadProvider; import org.jackhuang.hellominecraft.launcher.core.download.IDownloadProvider;
import org.jackhuang.hellominecraft.launcher.core.version.MinecraftVersion; import org.jackhuang.hellominecraft.launcher.core.version.MinecraftVersion;
import org.jackhuang.hellominecraft.tasks.Task; import org.jackhuang.hellominecraft.utils.tasks.Task;
import org.jackhuang.hellominecraft.tasks.download.FileDownloadTask; import org.jackhuang.hellominecraft.utils.tasks.download.FileDownloadTask;
import org.jackhuang.hellominecraft.utils.code.DigestUtils; import org.jackhuang.hellominecraft.utils.code.DigestUtils;
import org.jackhuang.hellominecraft.utils.system.IOUtils; import org.jackhuang.hellominecraft.utils.system.IOUtils;
import org.jackhuang.hellominecraft.utils.NetUtils; import org.jackhuang.hellominecraft.utils.NetUtils;

View File

@@ -20,13 +20,13 @@ package org.jackhuang.hellominecraft.launcher.core.assets;
import com.google.gson.JsonSyntaxException; import com.google.gson.JsonSyntaxException;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import org.jackhuang.hellominecraft.C; import org.jackhuang.hellominecraft.utils.C;
import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftAssetService; import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftAssetService;
import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftService; import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftService;
import org.jackhuang.hellominecraft.launcher.core.version.MinecraftVersion; import org.jackhuang.hellominecraft.launcher.core.version.MinecraftVersion;
import org.jackhuang.hellominecraft.tasks.Task; import org.jackhuang.hellominecraft.utils.tasks.Task;
import org.jackhuang.hellominecraft.tasks.TaskWindow; import org.jackhuang.hellominecraft.utils.tasks.TaskWindow;
import org.jackhuang.hellominecraft.tasks.download.FileDownloadTask; import org.jackhuang.hellominecraft.utils.tasks.download.FileDownloadTask;
import org.jackhuang.hellominecraft.utils.system.FileUtils; import org.jackhuang.hellominecraft.utils.system.FileUtils;
import org.jackhuang.hellominecraft.utils.system.IOUtils; import org.jackhuang.hellominecraft.utils.system.IOUtils;
import rx.concurrency.Schedulers; import rx.concurrency.Schedulers;

View File

@@ -19,7 +19,7 @@ package org.jackhuang.hellominecraft.launcher.core.auth;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import org.jackhuang.hellominecraft.C; import org.jackhuang.hellominecraft.utils.C;
import org.jackhuang.hellominecraft.utils.StrUtils; import org.jackhuang.hellominecraft.utils.StrUtils;
import org.jackhuang.hellominecraft.utils.code.DigestUtils; import org.jackhuang.hellominecraft.utils.code.DigestUtils;

View File

@@ -17,10 +17,10 @@
*/ */
package org.jackhuang.hellominecraft.launcher.core.auth; package org.jackhuang.hellominecraft.launcher.core.auth;
import org.jackhuang.hellominecraft.C; import org.jackhuang.hellominecraft.utils.C;
import org.jackhuang.hellominecraft.utils.code.DigestUtils; import org.jackhuang.hellominecraft.utils.code.DigestUtils;
import org.jackhuang.hellominecraft.utils.NetUtils; import org.jackhuang.hellominecraft.utils.NetUtils;
import org.jackhuang.hellominecraft.views.Selector; import org.jackhuang.hellominecraft.utils.views.Selector;
/** /**
* *

View File

@@ -21,9 +21,9 @@ import com.google.gson.GsonBuilder;
import java.net.Proxy; import java.net.Proxy;
import java.util.Map; import java.util.Map;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import org.jackhuang.hellominecraft.C; import org.jackhuang.hellominecraft.utils.C;
import org.jackhuang.hellominecraft.utils.ArrayUtils; import org.jackhuang.hellominecraft.utils.ArrayUtils;
import org.jackhuang.hellominecraft.views.Selector; import org.jackhuang.hellominecraft.utils.views.Selector;
import org.jackhuang.hellominecraft.launcher.core.auth.yggdrasil.GameProfile; import org.jackhuang.hellominecraft.launcher.core.auth.yggdrasil.GameProfile;
import org.jackhuang.hellominecraft.launcher.core.auth.yggdrasil.PropertyMap; import org.jackhuang.hellominecraft.launcher.core.auth.yggdrasil.PropertyMap;
import org.jackhuang.hellominecraft.launcher.core.auth.yggdrasil.YggdrasilAuthentication; import org.jackhuang.hellominecraft.launcher.core.auth.yggdrasil.YggdrasilAuthentication;

View File

@@ -31,7 +31,7 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.jackhuang.hellominecraft.HMCLog; import org.jackhuang.hellominecraft.utils.HMCLog;
public class PropertyMap extends HashMap<String, Property> { public class PropertyMap extends HashMap<String, Property> {

View File

@@ -28,8 +28,8 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
import org.jackhuang.hellominecraft.C; import org.jackhuang.hellominecraft.utils.C;
import org.jackhuang.hellominecraft.HMCLog; import org.jackhuang.hellominecraft.utils.HMCLog;
import org.jackhuang.hellominecraft.utils.NetUtils; import org.jackhuang.hellominecraft.utils.NetUtils;
import org.jackhuang.hellominecraft.utils.StrUtils; import org.jackhuang.hellominecraft.utils.StrUtils;

View File

@@ -0,0 +1,31 @@
/*
* Hello Minecraft! Launcher.
* Copyright (C) 2013 huangyuhui <huanghongxun2008@126.com>
*
* 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.launcher.core.download;
/**
*
* @author huangyuhui
*/
public class CurseDownloadProvider extends MojangDownloadProvider {
@Override
public String getParsedLibraryDownloadURL(String str) {
return str == null ? null : str.replace("http://files.minecraftforge.net/maven", "http://ftb.cursecdn.com/FTB2/maven/");
}
}

View File

@@ -17,7 +17,7 @@
*/ */
package org.jackhuang.hellominecraft.launcher.core.download; package org.jackhuang.hellominecraft.launcher.core.download;
import org.jackhuang.hellominecraft.C; import org.jackhuang.hellominecraft.utils.C;
/** /**
* *
@@ -27,7 +27,8 @@ public enum DownloadType {
Mojang(C.i18n("download.mojang"), new MojangDownloadProvider()), Mojang(C.i18n("download.mojang"), new MojangDownloadProvider()),
BMCL(C.i18n("download.BMCL"), new BMCLAPIDownloadProvider()), BMCL(C.i18n("download.BMCL"), new BMCLAPIDownloadProvider()),
RapidData(C.i18n("download.rapid_data"), new RapidDataDownloadProvider()); RapidData(C.i18n("download.rapid_data"), new RapidDataDownloadProvider()),
Curse("Curse CDN", new CurseDownloadProvider());
private final String name; private final String name;
private final IDownloadProvider provider; private final IDownloadProvider provider;

View File

@@ -22,20 +22,20 @@ import com.google.gson.JsonSyntaxException;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.jackhuang.hellominecraft.C; import org.jackhuang.hellominecraft.utils.C;
import org.jackhuang.hellominecraft.HMCLog; import org.jackhuang.hellominecraft.utils.HMCLog;
import org.jackhuang.hellominecraft.launcher.core.GameException; import org.jackhuang.hellominecraft.launcher.core.GameException;
import org.jackhuang.hellominecraft.launcher.core.launch.GameLauncher; import org.jackhuang.hellominecraft.launcher.core.launch.GameLauncher;
import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftService; import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftService;
import org.jackhuang.hellominecraft.launcher.core.version.IMinecraftLibrary; import org.jackhuang.hellominecraft.launcher.core.version.IMinecraftLibrary;
import org.jackhuang.hellominecraft.launcher.core.version.MinecraftVersion; import org.jackhuang.hellominecraft.launcher.core.version.MinecraftVersion;
import org.jackhuang.hellominecraft.tasks.TaskWindow; import org.jackhuang.hellominecraft.utils.tasks.TaskWindow;
import org.jackhuang.hellominecraft.tasks.download.FileDownloadTask; import org.jackhuang.hellominecraft.utils.tasks.download.FileDownloadTask;
import org.jackhuang.hellominecraft.utils.NetUtils; import org.jackhuang.hellominecraft.utils.NetUtils;
import org.jackhuang.hellominecraft.utils.system.FileUtils; import org.jackhuang.hellominecraft.utils.system.FileUtils;
import org.jackhuang.hellominecraft.utils.system.IOUtils; import org.jackhuang.hellominecraft.utils.system.IOUtils;
import org.jackhuang.hellominecraft.version.MinecraftRemoteVersion; import org.jackhuang.hellominecraft.utils.version.MinecraftRemoteVersion;
import org.jackhuang.hellominecraft.version.MinecraftRemoteVersions; import org.jackhuang.hellominecraft.utils.version.MinecraftRemoteVersions;
import rx.Observable; import rx.Observable;
/** /**

View File

@@ -26,10 +26,10 @@ import org.jackhuang.hellominecraft.launcher.core.installers.liteloader.LiteLoad
import org.jackhuang.hellominecraft.launcher.core.installers.liteloader.LiteLoaderVersionList; import org.jackhuang.hellominecraft.launcher.core.installers.liteloader.LiteLoaderVersionList;
import org.jackhuang.hellominecraft.launcher.core.installers.optifine.OptiFineInstaller; import org.jackhuang.hellominecraft.launcher.core.installers.optifine.OptiFineInstaller;
import org.jackhuang.hellominecraft.launcher.core.installers.optifine.vanilla.OptiFineDownloadFormatter; import org.jackhuang.hellominecraft.launcher.core.installers.optifine.vanilla.OptiFineDownloadFormatter;
import org.jackhuang.hellominecraft.tasks.Task; import org.jackhuang.hellominecraft.utils.tasks.Task;
import org.jackhuang.hellominecraft.tasks.TaskInfo; import org.jackhuang.hellominecraft.utils.tasks.TaskInfo;
import org.jackhuang.hellominecraft.tasks.TaskWindow; import org.jackhuang.hellominecraft.utils.tasks.TaskWindow;
import org.jackhuang.hellominecraft.tasks.download.FileDownloadTask; import org.jackhuang.hellominecraft.utils.tasks.download.FileDownloadTask;
import org.jackhuang.hellominecraft.utils.system.IOUtils; import org.jackhuang.hellominecraft.utils.system.IOUtils;
/** /**

View File

@@ -24,11 +24,11 @@ import java.io.FileOutputStream;
import java.io.InputStream; import java.io.InputStream;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
import java.util.zip.ZipFile; import java.util.zip.ZipFile;
import org.jackhuang.hellominecraft.C; import org.jackhuang.hellominecraft.utils.C;
import org.jackhuang.hellominecraft.HMCLog; import org.jackhuang.hellominecraft.utils.HMCLog;
import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftService; import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftService;
import org.jackhuang.hellominecraft.launcher.core.installers.InstallerVersionList.InstallerVersion; import org.jackhuang.hellominecraft.launcher.core.installers.InstallerVersionList.InstallerVersion;
import org.jackhuang.hellominecraft.tasks.Task; import org.jackhuang.hellominecraft.utils.tasks.Task;
import org.jackhuang.hellominecraft.utils.system.FileUtils; import org.jackhuang.hellominecraft.utils.system.FileUtils;
import org.jackhuang.hellominecraft.utils.NetUtils; import org.jackhuang.hellominecraft.utils.NetUtils;
import org.jackhuang.hellominecraft.launcher.core.version.MinecraftLibrary; import org.jackhuang.hellominecraft.launcher.core.version.MinecraftLibrary;

View File

@@ -22,7 +22,7 @@ import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.jackhuang.hellominecraft.C; import org.jackhuang.hellominecraft.utils.C;
import org.jackhuang.hellominecraft.launcher.core.download.DownloadType; import org.jackhuang.hellominecraft.launcher.core.download.DownloadType;
import org.jackhuang.hellominecraft.utils.StrUtils; import org.jackhuang.hellominecraft.utils.StrUtils;
import org.jackhuang.hellominecraft.launcher.core.installers.InstallerVersionList; import org.jackhuang.hellominecraft.launcher.core.installers.InstallerVersionList;

View File

@@ -20,12 +20,12 @@ package org.jackhuang.hellominecraft.launcher.core.installers.liteloader;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import org.jackhuang.hellominecraft.C; import org.jackhuang.hellominecraft.utils.C;
import org.jackhuang.hellominecraft.HMCLog; import org.jackhuang.hellominecraft.utils.HMCLog;
import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftService; import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftService;
import org.jackhuang.hellominecraft.tasks.Task; import org.jackhuang.hellominecraft.utils.tasks.Task;
import org.jackhuang.hellominecraft.tasks.communication.PreviousResult; import org.jackhuang.hellominecraft.utils.tasks.communication.PreviousResult;
import org.jackhuang.hellominecraft.tasks.communication.PreviousResultRegistrar; import org.jackhuang.hellominecraft.utils.tasks.communication.PreviousResultRegistrar;
import org.jackhuang.hellominecraft.utils.system.FileUtils; import org.jackhuang.hellominecraft.utils.system.FileUtils;
import org.jackhuang.hellominecraft.launcher.core.version.MinecraftLibrary; import org.jackhuang.hellominecraft.launcher.core.version.MinecraftLibrary;
import org.jackhuang.hellominecraft.launcher.core.version.MinecraftVersion; import org.jackhuang.hellominecraft.launcher.core.version.MinecraftVersion;

View File

@@ -23,7 +23,7 @@ import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.jackhuang.hellominecraft.C; import org.jackhuang.hellominecraft.utils.C;
import org.jackhuang.hellominecraft.launcher.core.version.MinecraftLibrary; import org.jackhuang.hellominecraft.launcher.core.version.MinecraftLibrary;
import org.jackhuang.hellominecraft.launcher.core.installers.InstallerVersionList; import org.jackhuang.hellominecraft.launcher.core.installers.InstallerVersionList;
import org.jackhuang.hellominecraft.launcher.core.installers.InstallerVersionList.InstallerVersion; import org.jackhuang.hellominecraft.launcher.core.installers.InstallerVersionList.InstallerVersion;

View File

@@ -20,12 +20,12 @@ package org.jackhuang.hellominecraft.launcher.core.installers.optifine;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.zip.ZipFile; import java.util.zip.ZipFile;
import org.jackhuang.hellominecraft.C; import org.jackhuang.hellominecraft.utils.C;
import org.jackhuang.hellominecraft.launcher.core.installers.InstallerVersionList; import org.jackhuang.hellominecraft.launcher.core.installers.InstallerVersionList;
import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftService; import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftService;
import org.jackhuang.hellominecraft.tasks.Task; import org.jackhuang.hellominecraft.utils.tasks.Task;
import org.jackhuang.hellominecraft.tasks.communication.PreviousResult; import org.jackhuang.hellominecraft.utils.tasks.communication.PreviousResult;
import org.jackhuang.hellominecraft.tasks.communication.PreviousResultRegistrar; import org.jackhuang.hellominecraft.utils.tasks.communication.PreviousResultRegistrar;
import org.jackhuang.hellominecraft.utils.system.FileUtils; import org.jackhuang.hellominecraft.utils.system.FileUtils;
import org.jackhuang.hellominecraft.launcher.core.version.MinecraftLibrary; import org.jackhuang.hellominecraft.launcher.core.version.MinecraftLibrary;
import org.jackhuang.hellominecraft.launcher.core.version.MinecraftVersion; import org.jackhuang.hellominecraft.launcher.core.version.MinecraftVersion;

View File

@@ -25,7 +25,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import org.jackhuang.hellominecraft.C; import org.jackhuang.hellominecraft.utils.C;
import org.jackhuang.hellominecraft.utils.ArrayUtils; import org.jackhuang.hellominecraft.utils.ArrayUtils;
import org.jackhuang.hellominecraft.launcher.core.installers.InstallerVersionList; import org.jackhuang.hellominecraft.launcher.core.installers.InstallerVersionList;
import org.jackhuang.hellominecraft.launcher.core.installers.optifine.OptiFineVersion; import org.jackhuang.hellominecraft.launcher.core.installers.optifine.OptiFineVersion;

View File

@@ -19,9 +19,9 @@ package org.jackhuang.hellominecraft.launcher.core.installers.optifine.vanilla;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import org.jackhuang.hellominecraft.C; import org.jackhuang.hellominecraft.utils.C;
import org.jackhuang.hellominecraft.tasks.Task; import org.jackhuang.hellominecraft.utils.tasks.Task;
import org.jackhuang.hellominecraft.tasks.communication.PreviousResult; import org.jackhuang.hellominecraft.utils.tasks.communication.PreviousResult;
import org.jackhuang.hellominecraft.utils.NetUtils; import org.jackhuang.hellominecraft.utils.NetUtils;
/** /**

View File

@@ -23,8 +23,8 @@ import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import org.jackhuang.hellominecraft.C; import org.jackhuang.hellominecraft.utils.C;
import org.jackhuang.hellominecraft.HMCLog; import org.jackhuang.hellominecraft.utils.HMCLog;
import org.jackhuang.hellominecraft.launcher.Launcher; import org.jackhuang.hellominecraft.launcher.Launcher;
import org.jackhuang.hellominecraft.launcher.core.GameException; import org.jackhuang.hellominecraft.launcher.core.GameException;
import org.jackhuang.hellominecraft.launcher.core.auth.UserProfileProvider; import org.jackhuang.hellominecraft.launcher.core.auth.UserProfileProvider;

View File

@@ -18,16 +18,17 @@
package org.jackhuang.hellominecraft.launcher.core.launch; package org.jackhuang.hellominecraft.launcher.core.launch;
import java.io.IOException; import java.io.IOException;
import org.jackhuang.hellominecraft.C; import org.jackhuang.hellominecraft.utils.C;
import org.jackhuang.hellominecraft.HMCLog; import org.jackhuang.hellominecraft.utils.HMCLog;
import org.jackhuang.hellominecraft.launcher.core.auth.IAuthenticator; import org.jackhuang.hellominecraft.launcher.core.auth.IAuthenticator;
import org.jackhuang.hellominecraft.launcher.core.auth.LoginInfo; import org.jackhuang.hellominecraft.launcher.core.auth.LoginInfo;
import org.jackhuang.hellominecraft.launcher.core.download.DownloadLibraryJob; import org.jackhuang.hellominecraft.launcher.core.download.DownloadLibraryJob;
import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftService; import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftService;
import org.jackhuang.hellominecraft.tasks.ParallelTask; import org.jackhuang.hellominecraft.utils.tasks.ParallelTask;
import org.jackhuang.hellominecraft.tasks.TaskWindow; import org.jackhuang.hellominecraft.utils.tasks.TaskWindow;
import org.jackhuang.hellominecraft.utils.system.Compressor; import org.jackhuang.hellominecraft.utils.system.Compressor;
import org.jackhuang.hellominecraft.utils.MessageBox; import org.jackhuang.hellominecraft.utils.MessageBox;
import org.jackhuang.hellominecraft.utils.StrUtils;
public class DefaultGameLauncher extends GameLauncher { public class DefaultGameLauncher extends GameLauncher {
@@ -55,7 +56,8 @@ public class DefaultGameLauncher extends GameLauncher {
return false; return false;
for (int i = 0; i < value.decompressFiles.length; i++) for (int i = 0; i < value.decompressFiles.length; i++)
try { try {
Compressor.unzip(value.decompressFiles[i], value.decompressTo, value.extractRules[i]); String[] rules = value.extractRules[i];
Compressor.unzip(value.decompressFiles[i], value.decompressTo, t -> !StrUtils.startsWithOne(rules, t));
} catch (IOException ex) { } catch (IOException ex) {
HMCLog.err("Unable to decompress library file: " + value.decompressFiles[i] + " to " + value.decompressTo, ex); HMCLog.err("Unable to decompress library file: " + value.decompressFiles[i] + " to " + value.decompressTo, ex);
} }

View File

@@ -26,8 +26,8 @@ import java.io.IOException;
import java.io.OutputStreamWriter; import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.util.List; import java.util.List;
import org.jackhuang.hellominecraft.C; import org.jackhuang.hellominecraft.utils.C;
import org.jackhuang.hellominecraft.HMCLog; import org.jackhuang.hellominecraft.utils.HMCLog;
import org.jackhuang.hellominecraft.launcher.api.PluginManager; import org.jackhuang.hellominecraft.launcher.api.PluginManager;
import org.jackhuang.hellominecraft.launcher.core.GameException; import org.jackhuang.hellominecraft.launcher.core.GameException;
import org.jackhuang.hellominecraft.launcher.core.auth.IAuthenticator; import org.jackhuang.hellominecraft.launcher.core.auth.IAuthenticator;

View File

@@ -27,10 +27,10 @@ import java.util.Arrays;
import java.util.jar.JarEntry; import java.util.jar.JarEntry;
import java.util.jar.JarOutputStream; import java.util.jar.JarOutputStream;
import java.util.jar.Pack200; import java.util.jar.Pack200;
import org.jackhuang.hellominecraft.C; import org.jackhuang.hellominecraft.utils.C;
import org.jackhuang.hellominecraft.HMCLog; import org.jackhuang.hellominecraft.utils.HMCLog;
import org.jackhuang.hellominecraft.launcher.core.download.DownloadLibraryJob; import org.jackhuang.hellominecraft.launcher.core.download.DownloadLibraryJob;
import org.jackhuang.hellominecraft.tasks.download.FileDownloadTask; import org.jackhuang.hellominecraft.utils.tasks.download.FileDownloadTask;
import org.jackhuang.hellominecraft.utils.system.IOUtils; import org.jackhuang.hellominecraft.utils.system.IOUtils;
import org.tukaani.xz.XZInputStream; import org.tukaani.xz.XZInputStream;

View File

@@ -23,8 +23,8 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.jackhuang.hellominecraft.C; import org.jackhuang.hellominecraft.utils.C;
import org.jackhuang.hellominecraft.HMCLog; import org.jackhuang.hellominecraft.utils.HMCLog;
import org.jackhuang.hellominecraft.launcher.Main; import org.jackhuang.hellominecraft.launcher.Main;
import org.jackhuang.hellominecraft.launcher.core.GameException; import org.jackhuang.hellominecraft.launcher.core.GameException;
import org.jackhuang.hellominecraft.launcher.core.auth.UserProfileProvider; import org.jackhuang.hellominecraft.launcher.core.auth.UserProfileProvider;
@@ -35,7 +35,7 @@ import org.jackhuang.hellominecraft.launcher.core.assets.IAssetsHandler;
import org.jackhuang.hellominecraft.launcher.core.download.DownloadType; import org.jackhuang.hellominecraft.launcher.core.download.DownloadType;
import org.jackhuang.hellominecraft.utils.system.OS; import org.jackhuang.hellominecraft.utils.system.OS;
import org.jackhuang.hellominecraft.launcher.core.version.MinecraftLibrary; import org.jackhuang.hellominecraft.launcher.core.version.MinecraftLibrary;
import org.jackhuang.hellominecraft.tasks.TaskWindow; import org.jackhuang.hellominecraft.utils.tasks.TaskWindow;
import org.jackhuang.hellominecraft.utils.system.FileUtils; import org.jackhuang.hellominecraft.utils.system.FileUtils;
import org.jackhuang.hellominecraft.utils.MessageBox; import org.jackhuang.hellominecraft.utils.MessageBox;
import org.jackhuang.hellominecraft.utils.StrUtils; import org.jackhuang.hellominecraft.utils.StrUtils;

View File

@@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see {http://www.gnu.org/licenses/}. * along with this program. If not, see {http://www.gnu.org/licenses/}.
*/ */
package org.jackhuang.hellominecraft.launcher.core.version; package org.jackhuang.hellominecraft.launcher.core.mod;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
@@ -25,7 +25,7 @@ import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.jackhuang.hellominecraft.HMCLog; import org.jackhuang.hellominecraft.utils.HMCLog;
import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftModService; import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftModService;
import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftService; import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftService;
import org.jackhuang.hellominecraft.launcher.core.ModInfo; import org.jackhuang.hellominecraft.launcher.core.ModInfo;

View File

@@ -0,0 +1,125 @@
/*
* Hello Minecraft! Launcher.
* Copyright (C) 2013 huangyuhui <huanghongxun2008@126.com>
*
* 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.launcher.core.mod;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.file.FileAlreadyExistsException;
import java.nio.file.FileSystemException;
import java.util.concurrent.atomic.AtomicBoolean;
import org.jackhuang.hellominecraft.utils.C;
import org.jackhuang.hellominecraft.utils.HMCLog;
import org.jackhuang.hellominecraft.launcher.core.GameException;
import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftProvider;
import org.jackhuang.hellominecraft.launcher.core.version.MinecraftVersion;
import org.jackhuang.hellominecraft.utils.system.Compressor;
import org.jackhuang.hellominecraft.utils.system.FileUtils;
/**
* A mod pack(*.zip) includes these things:
* <ul>
* <li>sth created by the game automatically, including "mods", "scripts",
* "config", etc..
* <li>pack.json, the same as Minecraft version configuration file:
* "gameDir/versions/{MCVER}/{MCVER}.json", will be renamed to that one.
* <li>all things should be included in "minecraft" folder under the root
* folder.
* </ul>
*
* This class can manage mod packs, for example, importing and exporting, the
* format of game is the offical one.
* Not compatible with MultiMC(no instance.cfg) & FTB(not leaving mcversion in
* pack.json).
*
* @author huangyuhui
*/
public final class ModpackManager {
public static void install(File input, File installFolder, String id) throws IOException, FileAlreadyExistsException {
File versions = new File(installFolder, "versions");
File oldFile = new File(versions, "minecraft"), newFile = null;
if (oldFile.exists()) {
newFile = new File(versions, "minecraft-" + System.currentTimeMillis());
if (newFile.isDirectory())
FileUtils.deleteDirectory(newFile);
else if (newFile.isFile())
newFile.delete();
oldFile.renameTo(newFile);
}
try {
AtomicBoolean b = new AtomicBoolean(false);
HMCLog.log("Decompressing modpack");
Compressor.unzip(input, versions, t -> {
if (t.equals("minecraft/pack.json"))
b.set(true);
return true;
});
if (!b.get())
throw new FileNotFoundException("the mod pack is not in a correct format.");
File nowFile = new File(versions, id);
oldFile.renameTo(nowFile);
new File(nowFile, "pack.json").renameTo(new File(nowFile, id + ".json"));
} finally {
FileUtils.deleteDirectoryQuietly(oldFile);
if (newFile != null)
newFile.renameTo(oldFile);
}
}
/**
* Export the game to a mod pack file.
*
* @param output mod pack file.
* @param baseFolder if the game dir type is ROOT_FOLDER, use ".minecraft",
* or use ".minecraft/versions/{MCVER}/"
* @param version to locate version.json
*
* @throws IOException if create tmp directory failed
*/
public static void export(File output, IMinecraftProvider provider, String version) throws IOException, GameException {
File tmp = new File(System.getProperty("java.io.tmpdir"), "hmcl-modpack");
tmp.mkdirs();
File root = new File(tmp, "minecraft");
HMCLog.log("Copying files from game directory.");
FileUtils.copyDirectory(provider.getRunDirectory(version), root);
File pack = new File(root, "pack.json");
MinecraftVersion mv = provider.getVersionById(version).resolve(provider);
try {
FileUtils.writeStringToFile(pack, C.gsonPrettyPrinting.toJson(mv));
String[] blacklist = { "usernamecache.json", "asm", "logs", "backups", "versions", "assets", "usercache.json", "libraries", "crash-reports", "launcher_profiles.json", "NVIDIA", "TCNodeTracker" };
HMCLog.log("Removing files in blacklist, including files or directories: usernamecache.json, asm, logs, backups, versions, assets, usercache.json, libraries, crash-reports, launcher_profiles.json, NVIDIA, TCNodeTracker");
for (String s : blacklist) {
File f = new File(root, s);
if (f.isFile())
f.delete();
else if (f.isDirectory())
FileUtils.deleteDirectory(f);
}
HMCLog.log("Compressing game files");
Compressor.zip(tmp, output);
} finally {
FileUtils.deleteDirectory(tmp);
}
}
}

View File

@@ -19,7 +19,7 @@ package org.jackhuang.hellominecraft.launcher.core.service;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import org.jackhuang.hellominecraft.tasks.Task; import org.jackhuang.hellominecraft.utils.tasks.Task;
/** /**
* *

View File

@@ -21,7 +21,7 @@ import java.util.List;
import org.jackhuang.hellominecraft.launcher.core.GameException; import org.jackhuang.hellominecraft.launcher.core.GameException;
import org.jackhuang.hellominecraft.launcher.core.download.DownloadLibraryJob; import org.jackhuang.hellominecraft.launcher.core.download.DownloadLibraryJob;
import org.jackhuang.hellominecraft.launcher.core.version.MinecraftVersion; import org.jackhuang.hellominecraft.launcher.core.version.MinecraftVersion;
import org.jackhuang.hellominecraft.version.MinecraftRemoteVersion; import org.jackhuang.hellominecraft.utils.version.MinecraftRemoteVersion;
import rx.Observable; import rx.Observable;
/** /**

View File

@@ -19,7 +19,7 @@ package org.jackhuang.hellominecraft.launcher.core.service;
import org.jackhuang.hellominecraft.launcher.core.installers.InstallerType; import org.jackhuang.hellominecraft.launcher.core.installers.InstallerType;
import org.jackhuang.hellominecraft.launcher.core.installers.InstallerVersionList; import org.jackhuang.hellominecraft.launcher.core.installers.InstallerVersionList;
import org.jackhuang.hellominecraft.tasks.Task; import org.jackhuang.hellominecraft.utils.tasks.Task;
/** /**
* *

View File

@@ -22,7 +22,7 @@ import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import org.jackhuang.hellominecraft.C; import org.jackhuang.hellominecraft.utils.C;
import org.jackhuang.hellominecraft.launcher.core.GameException; import org.jackhuang.hellominecraft.launcher.core.GameException;
import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftProvider; import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftProvider;
import org.jackhuang.hellominecraft.launcher.core.assets.AssetsIndex; import org.jackhuang.hellominecraft.launcher.core.assets.AssetsIndex;

View File

@@ -24,20 +24,20 @@ import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Map; import java.util.Map;
import java.util.TreeMap; import java.util.TreeMap;
import org.jackhuang.hellominecraft.C; import org.jackhuang.hellominecraft.utils.C;
import org.jackhuang.hellominecraft.HMCLog; import org.jackhuang.hellominecraft.utils.HMCLog;
import org.jackhuang.hellominecraft.launcher.core.GameException; import org.jackhuang.hellominecraft.launcher.core.GameException;
import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftProvider; import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftProvider;
import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftService; import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftService;
import org.jackhuang.hellominecraft.utils.system.FileUtils; import org.jackhuang.hellominecraft.utils.system.FileUtils;
import org.jackhuang.hellominecraft.launcher.core.MCUtils; import org.jackhuang.hellominecraft.launcher.core.MCUtils;
import org.jackhuang.hellominecraft.tasks.DecompressTask; import org.jackhuang.hellominecraft.utils.tasks.DecompressTask;
import org.jackhuang.hellominecraft.tasks.TaskWindow; import org.jackhuang.hellominecraft.utils.tasks.TaskWindow;
import org.jackhuang.hellominecraft.tasks.download.FileDownloadTask; import org.jackhuang.hellominecraft.utils.tasks.download.FileDownloadTask;
import org.jackhuang.hellominecraft.utils.system.IOUtils; import org.jackhuang.hellominecraft.utils.system.IOUtils;
import org.jackhuang.hellominecraft.utils.MessageBox; import org.jackhuang.hellominecraft.utils.MessageBox;
import org.jackhuang.hellominecraft.utils.functions.Consumer; import org.jackhuang.hellominecraft.utils.functions.Consumer;
import org.jackhuang.hellominecraft.views.SwingUtils; import org.jackhuang.hellominecraft.utils.views.SwingUtils;
/** /**
* *

View File

@@ -21,7 +21,7 @@ import java.io.File;
import java.util.HashMap; import java.util.HashMap;
import javax.swing.Icon; import javax.swing.Icon;
import javax.swing.ImageIcon; import javax.swing.ImageIcon;
import org.jackhuang.hellominecraft.tasks.download.FileDownloadTask; import org.jackhuang.hellominecraft.utils.tasks.download.FileDownloadTask;
import org.jackhuang.hellominecraft.utils.Utils; import org.jackhuang.hellominecraft.utils.Utils;
/** /**

View File

@@ -19,8 +19,8 @@ package org.jackhuang.hellominecraft.launcher.settings;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import org.jackhuang.hellominecraft.C; import org.jackhuang.hellominecraft.utils.C;
import org.jackhuang.hellominecraft.HMCLog; import org.jackhuang.hellominecraft.utils.HMCLog;
import org.jackhuang.hellominecraft.launcher.Main; import org.jackhuang.hellominecraft.launcher.Main;
import org.jackhuang.hellominecraft.launcher.api.PluginManager; import org.jackhuang.hellominecraft.launcher.api.PluginManager;
import org.jackhuang.hellominecraft.launcher.core.LauncherVisibility; import org.jackhuang.hellominecraft.launcher.core.LauncherVisibility;

View File

@@ -25,8 +25,8 @@ import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.jackhuang.hellominecraft.C; import org.jackhuang.hellominecraft.utils.C;
import org.jackhuang.hellominecraft.HMCLog; import org.jackhuang.hellominecraft.utils.HMCLog;
import org.jackhuang.hellominecraft.launcher.Main; import org.jackhuang.hellominecraft.launcher.Main;
import org.jackhuang.hellominecraft.launcher.core.download.DownloadType; import org.jackhuang.hellominecraft.launcher.core.download.DownloadType;
import org.jackhuang.hellominecraft.utils.CollectionUtils; import org.jackhuang.hellominecraft.utils.CollectionUtils;

View File

@@ -23,15 +23,15 @@ import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import org.jackhuang.hellominecraft.C; import org.jackhuang.hellominecraft.utils.C;
import org.jackhuang.hellominecraft.HMCLog; import org.jackhuang.hellominecraft.utils.HMCLog;
import org.jackhuang.hellominecraft.launcher.Main; import org.jackhuang.hellominecraft.launcher.Main;
import org.jackhuang.hellominecraft.launcher.settings.Settings; import org.jackhuang.hellominecraft.launcher.settings.Settings;
import org.jackhuang.hellominecraft.utils.NetUtils; import org.jackhuang.hellominecraft.utils.NetUtils;
import org.jackhuang.hellominecraft.utils.MessageBox; import org.jackhuang.hellominecraft.utils.MessageBox;
import org.jackhuang.hellominecraft.utils.StrUtils; import org.jackhuang.hellominecraft.utils.StrUtils;
import org.jackhuang.hellominecraft.utils.system.OS; import org.jackhuang.hellominecraft.utils.system.OS;
import org.jackhuang.hellominecraft.views.LogWindow; import org.jackhuang.hellominecraft.utils.views.LogWindow;
/** /**
* *

View File

@@ -33,7 +33,7 @@ import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftLoader;
import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftModService; import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftModService;
import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftProvider; import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftProvider;
import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftService; import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftService;
import org.jackhuang.hellominecraft.launcher.core.version.MinecraftModService; import org.jackhuang.hellominecraft.launcher.core.mod.MinecraftModService;
import org.jackhuang.hellominecraft.launcher.core.version.MinecraftVersionManager; import org.jackhuang.hellominecraft.launcher.core.version.MinecraftVersionManager;
/** /**

View File

@@ -17,7 +17,7 @@
*/ */
package org.jackhuang.hellominecraft.launcher.utils; package org.jackhuang.hellominecraft.launcher.utils;
import org.jackhuang.hellominecraft.C; import org.jackhuang.hellominecraft.utils.C;
/** /**
* Give the advice to solve the Minecraft crashing. * Give the advice to solve the Minecraft crashing.

View File

@@ -34,12 +34,12 @@ import java.util.jar.JarFile;
import java.util.jar.JarOutputStream; import java.util.jar.JarOutputStream;
import java.util.jar.Pack200; import java.util.jar.Pack200;
import java.util.zip.GZIPInputStream; import java.util.zip.GZIPInputStream;
import org.jackhuang.hellominecraft.C; import org.jackhuang.hellominecraft.utils.C;
import org.jackhuang.hellominecraft.HMCLog; import org.jackhuang.hellominecraft.utils.HMCLog;
import org.jackhuang.hellominecraft.launcher.core.MCUtils; import org.jackhuang.hellominecraft.launcher.core.MCUtils;
import org.jackhuang.hellominecraft.tasks.Task; import org.jackhuang.hellominecraft.utils.tasks.Task;
import org.jackhuang.hellominecraft.tasks.TaskWindow; import org.jackhuang.hellominecraft.utils.tasks.TaskWindow;
import org.jackhuang.hellominecraft.tasks.download.FileDownloadTask; import org.jackhuang.hellominecraft.utils.tasks.download.FileDownloadTask;
import org.jackhuang.hellominecraft.utils.ArrayUtils; import org.jackhuang.hellominecraft.utils.ArrayUtils;
import org.jackhuang.hellominecraft.utils.MessageBox; import org.jackhuang.hellominecraft.utils.MessageBox;
import org.jackhuang.hellominecraft.utils.UpdateChecker; import org.jackhuang.hellominecraft.utils.UpdateChecker;

View File

@@ -21,9 +21,9 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.jackhuang.hellominecraft.HMCLog; import org.jackhuang.hellominecraft.utils.HMCLog;
import org.jackhuang.hellominecraft.tasks.TaskWindow; import org.jackhuang.hellominecraft.utils.tasks.TaskWindow;
import org.jackhuang.hellominecraft.tasks.download.FileDownloadTask; import org.jackhuang.hellominecraft.utils.tasks.download.FileDownloadTask;
import org.jackhuang.hellominecraft.utils.ArrayUtils; import org.jackhuang.hellominecraft.utils.ArrayUtils;
import org.jackhuang.hellominecraft.utils.VersionNumber; import org.jackhuang.hellominecraft.utils.VersionNumber;
import org.jackhuang.hellominecraft.utils.system.FileUtils; import org.jackhuang.hellominecraft.utils.system.FileUtils;

View File

@@ -18,11 +18,11 @@
package org.jackhuang.hellominecraft.launcher.views; package org.jackhuang.hellominecraft.launcher.views;
import javax.swing.table.DefaultTableModel; import javax.swing.table.DefaultTableModel;
import org.jackhuang.hellominecraft.C; import org.jackhuang.hellominecraft.utils.C;
import org.jackhuang.hellominecraft.HMCLog; import org.jackhuang.hellominecraft.utils.HMCLog;
import org.jackhuang.hellominecraft.utils.MessageBox; import org.jackhuang.hellominecraft.utils.MessageBox;
import org.jackhuang.hellominecraft.utils.StrUtils; import org.jackhuang.hellominecraft.utils.StrUtils;
import org.jackhuang.hellominecraft.views.SwingUtils; import org.jackhuang.hellominecraft.utils.views.SwingUtils;
import rx.concurrency.Schedulers; import rx.concurrency.Schedulers;
/** /**

View File

@@ -88,7 +88,10 @@
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0"> <Group type="102" attributes="0">
<Component id="btnDownloadAllAssets" min="-2" max="-2" attributes="0"/> <Component id="btnDownloadAllAssets" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/> <EmptySpace max="32767" attributes="0"/>
<Component id="btnImportModpack" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="btnExportModpack" min="-2" max="-2" attributes="0"/>
</Group> </Group>
<Group type="102" alignment="0" attributes="0"> <Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
@@ -109,7 +112,7 @@
<Component id="lblDimensionX" min="-2" max="-2" attributes="0"/> <Component id="lblDimensionX" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="txtHeight" min="-2" pref="100" max="-2" attributes="0"/> <Component id="txtHeight" min="-2" pref="100" max="-2" attributes="0"/>
<EmptySpace pref="425" max="32767" attributes="0"/> <EmptySpace pref="444" max="32767" attributes="0"/>
<Component id="chkFullscreen" min="-2" max="-2" attributes="0"/> <Component id="chkFullscreen" min="-2" max="-2" attributes="0"/>
</Group> </Group>
<Group type="102" alignment="1" attributes="0"> <Group type="102" alignment="1" attributes="0">
@@ -177,7 +180,11 @@
<Component id="txtWidth" alignment="3" min="-2" pref="26" max="-2" attributes="0"/> <Component id="txtWidth" alignment="3" min="-2" pref="26" max="-2" attributes="0"/>
</Group> </Group>
<EmptySpace pref="113" max="32767" attributes="0"/> <EmptySpace pref="113" max="32767" attributes="0"/>
<Component id="btnDownloadAllAssets" min="-2" max="-2" attributes="0"/> <Group type="103" groupAlignment="3" attributes="0">
<Component id="btnDownloadAllAssets" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="btnExportModpack" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="btnImportModpack" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
</Group> </Group>
</Group> </Group>
@@ -337,6 +344,22 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnChoosingGameDirActionPerformed"/> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnChoosingGameDirActionPerformed"/>
</Events> </Events>
</Component> </Component>
<Component class="javax.swing.JButton" name="btnExportModpack">
<Properties>
<Property name="text" type="java.lang.String" value="&#x5bfc;&#x51fa;&#x6574;&#x5408;&#x5305;"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnExportModpackActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="btnImportModpack">
<Properties>
<Property name="text" type="java.lang.String" value="&#x5bfc;&#x5165;&#x6574;&#x5408;&#x5305;"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnImportModpackActionPerformed"/>
</Events>
</Component>
</SubComponents> </SubComponents>
</Container> </Container>
<Container class="javax.swing.JPanel" name="pnlAdvancedSettings"> <Container class="javax.swing.JPanel" name="pnlAdvancedSettings">

View File

@@ -33,6 +33,8 @@ import java.awt.event.KeyEvent;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFileChooser; import javax.swing.JFileChooser;
import javax.swing.JMenuItem; import javax.swing.JMenuItem;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
@@ -40,24 +42,29 @@ import javax.swing.JPopupMenu;
import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener; import javax.swing.event.ChangeListener;
import javax.swing.event.TableModelEvent; import javax.swing.event.TableModelEvent;
import javax.swing.filechooser.FileNameExtensionFilter;
import javax.swing.table.DefaultTableModel; import javax.swing.table.DefaultTableModel;
import org.jackhuang.hellominecraft.C; import org.jackhuang.hellominecraft.utils.C;
import org.jackhuang.hellominecraft.HMCLog; import org.jackhuang.hellominecraft.utils.HMCLog;
import org.jackhuang.hellominecraft.launcher.core.GameException;
import org.jackhuang.hellominecraft.launcher.core.LauncherVisibility; import org.jackhuang.hellominecraft.launcher.core.LauncherVisibility;
import org.jackhuang.hellominecraft.launcher.settings.Profile; import org.jackhuang.hellominecraft.launcher.settings.Profile;
import org.jackhuang.hellominecraft.launcher.settings.Settings; import org.jackhuang.hellominecraft.launcher.settings.Settings;
import org.jackhuang.hellominecraft.launcher.utils.FileNameFilter; import org.jackhuang.hellominecraft.launcher.utils.FileNameFilter;
import org.jackhuang.hellominecraft.launcher.core.ModInfo; import org.jackhuang.hellominecraft.launcher.core.ModInfo;
import org.jackhuang.hellominecraft.launcher.core.installers.InstallerType; import org.jackhuang.hellominecraft.launcher.core.installers.InstallerType;
import org.jackhuang.hellominecraft.launcher.core.mod.ModpackManager;
import org.jackhuang.hellominecraft.launcher.core.version.GameDirType; import org.jackhuang.hellominecraft.launcher.core.version.GameDirType;
import org.jackhuang.hellominecraft.launcher.core.version.MinecraftVersion; import org.jackhuang.hellominecraft.launcher.core.version.MinecraftVersion;
import org.jackhuang.hellominecraft.utils.tasks.TaskRunnable;
import org.jackhuang.hellominecraft.utils.tasks.TaskWindow;
import org.jackhuang.hellominecraft.utils.Event; import org.jackhuang.hellominecraft.utils.Event;
import org.jackhuang.hellominecraft.utils.system.IOUtils; import org.jackhuang.hellominecraft.utils.system.IOUtils;
import org.jackhuang.hellominecraft.utils.MessageBox; import org.jackhuang.hellominecraft.utils.MessageBox;
import org.jackhuang.hellominecraft.version.MinecraftVersionRequest; import org.jackhuang.hellominecraft.utils.version.MinecraftVersionRequest;
import org.jackhuang.hellominecraft.utils.system.OS; import org.jackhuang.hellominecraft.utils.system.OS;
import org.jackhuang.hellominecraft.utils.StrUtils; import org.jackhuang.hellominecraft.utils.StrUtils;
import org.jackhuang.hellominecraft.views.SwingUtils; import org.jackhuang.hellominecraft.utils.views.SwingUtils;
import org.jackhuang.hellominecraft.utils.system.Java; import org.jackhuang.hellominecraft.utils.system.Java;
import rx.Observable; import rx.Observable;
import rx.concurrency.Schedulers; import rx.concurrency.Schedulers;
@@ -254,6 +261,8 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
btnChoosingJavaDir = new javax.swing.JButton(); btnChoosingJavaDir = new javax.swing.JButton();
cboJava = new javax.swing.JComboBox(); cboJava = new javax.swing.JComboBox();
btnChoosingGameDir = new javax.swing.JButton(); btnChoosingGameDir = new javax.swing.JButton();
btnExportModpack = new javax.swing.JButton();
btnImportModpack = new javax.swing.JButton();
pnlAdvancedSettings = new AnimatedPanel(); pnlAdvancedSettings = new AnimatedPanel();
chkDebug = new javax.swing.JCheckBox(); chkDebug = new javax.swing.JCheckBox();
lblJavaArgs = new javax.swing.JLabel(); lblJavaArgs = new javax.swing.JLabel();
@@ -394,6 +403,20 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
} }
}); });
btnExportModpack.setText("导出整合包");
btnExportModpack.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnExportModpackActionPerformed(evt);
}
});
btnImportModpack.setText("导入整合包");
btnImportModpack.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnImportModpackActionPerformed(evt);
}
});
javax.swing.GroupLayout pnlSettingsLayout = new javax.swing.GroupLayout(pnlSettings); javax.swing.GroupLayout pnlSettingsLayout = new javax.swing.GroupLayout(pnlSettings);
pnlSettings.setLayout(pnlSettingsLayout); pnlSettings.setLayout(pnlSettingsLayout);
pnlSettingsLayout.setHorizontalGroup( pnlSettingsLayout.setHorizontalGroup(
@@ -403,7 +426,10 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
.addGroup(pnlSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(pnlSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(pnlSettingsLayout.createSequentialGroup() .addGroup(pnlSettingsLayout.createSequentialGroup()
.addComponent(btnDownloadAllAssets) .addComponent(btnDownloadAllAssets)
.addGap(0, 0, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(btnImportModpack)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnExportModpack))
.addGroup(pnlSettingsLayout.createSequentialGroup() .addGroup(pnlSettingsLayout.createSequentialGroup()
.addGroup(pnlSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(pnlSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lblJavaDir) .addComponent(lblJavaDir)
@@ -422,7 +448,7 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
.addComponent(lblDimensionX) .addComponent(lblDimensionX)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txtHeight, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(txtHeight, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 425, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 444, Short.MAX_VALUE)
.addComponent(chkFullscreen)) .addComponent(chkFullscreen))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlSettingsLayout.createSequentialGroup() .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlSettingsLayout.createSequentialGroup()
.addComponent(txtMaxMemory) .addComponent(txtMaxMemory)
@@ -475,7 +501,10 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
.addComponent(lblDimension) .addComponent(lblDimension)
.addComponent(txtWidth, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(txtWidth, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 113, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 113, Short.MAX_VALUE)
.addComponent(btnDownloadAllAssets) .addGroup(pnlSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(btnDownloadAllAssets)
.addComponent(btnExportModpack)
.addComponent(btnImportModpack))
.addContainerGap()) .addContainerGap())
); );
@@ -1105,6 +1134,44 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
getProfile().service().version().cleanFolder(); getProfile().service().version().cleanFolder();
}//GEN-LAST:event_btnCleanGameActionPerformed }//GEN-LAST:event_btnCleanGameActionPerformed
private void btnImportModpackActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnImportModpackActionPerformed
JFileChooser fc = new JFileChooser();
fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
fc.setDialogTitle(C.i18n("settings.modpack.choose"));
fc.setMultiSelectionEnabled(false);
fc.setFileFilter(new FileNameExtensionFilter(C.i18n("settings.modpack"), ".zip"));
fc.showOpenDialog(this);
if (fc.getSelectedFile() == null)
return;
TaskWindow.getInstance().addTask(new TaskRunnable(C.i18n("settings.modpack"), () -> {
try {
ModpackManager.install(fc.getSelectedFile(), getProfile().getCanonicalGameDirFile(), fc.getSelectedFile().getName());
} catch (IOException ex) {
MessageBox.Show(C.i18n("settings.modpack.install_error"));
HMCLog.err("Failed to install modpack", ex);
}
})).start();
}//GEN-LAST:event_btnImportModpackActionPerformed
private void btnExportModpackActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnExportModpackActionPerformed
JFileChooser fc = new JFileChooser();
fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
fc.setDialogTitle(C.i18n("settings.modpack.save"));
fc.setMultiSelectionEnabled(false);
fc.setFileFilter(new FileNameExtensionFilter(C.i18n("settings.modpack"), ".zip"));
fc.showSaveDialog(this);
if (fc.getSelectedFile() == null)
return;
TaskWindow.getInstance().addTask(new TaskRunnable(C.i18n("settings.modpack"), () -> {
try {
ModpackManager.export(fc.getSelectedFile(), getProfile().service().version(), getProfile().getSelectedVersion());
} catch (IOException | GameException ex) {
MessageBox.Show(C.i18n("settings.modpack.export_error"));
HMCLog.err("Failed to export modpack", ex);
}
})).start();
}//GEN-LAST:event_btnExportModpackActionPerformed
// </editor-fold> // </editor-fold>
// <editor-fold defaultstate="collapsed" desc="Load"> // <editor-fold defaultstate="collapsed" desc="Load">
private void loadProfiles() { private void loadProfiles() {
@@ -1286,6 +1353,8 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
private javax.swing.JButton btnCleanGame; private javax.swing.JButton btnCleanGame;
private javax.swing.JButton btnDownloadAllAssets; private javax.swing.JButton btnDownloadAllAssets;
private javax.swing.JButton btnExplore; private javax.swing.JButton btnExplore;
private javax.swing.JButton btnExportModpack;
private javax.swing.JButton btnImportModpack;
private javax.swing.JButton btnIncludeMinecraft; private javax.swing.JButton btnIncludeMinecraft;
private javax.swing.JButton btnModify; private javax.swing.JButton btnModify;
private javax.swing.JButton btnNewProfile; private javax.swing.JButton btnNewProfile;

View File

@@ -20,17 +20,17 @@ package org.jackhuang.hellominecraft.launcher.views;
import java.util.List; import java.util.List;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import javax.swing.table.DefaultTableModel; import javax.swing.table.DefaultTableModel;
import org.jackhuang.hellominecraft.C; import org.jackhuang.hellominecraft.utils.C;
import org.jackhuang.hellominecraft.launcher.settings.Settings; import org.jackhuang.hellominecraft.launcher.settings.Settings;
import org.jackhuang.hellominecraft.launcher.core.installers.InstallerType; import org.jackhuang.hellominecraft.launcher.core.installers.InstallerType;
import org.jackhuang.hellominecraft.launcher.core.installers.InstallerVersionList; import org.jackhuang.hellominecraft.launcher.core.installers.InstallerVersionList;
import org.jackhuang.hellominecraft.tasks.TaskRunnable; import org.jackhuang.hellominecraft.utils.tasks.TaskRunnable;
import org.jackhuang.hellominecraft.tasks.TaskRunnableArg1; import org.jackhuang.hellominecraft.utils.tasks.TaskRunnableArg1;
import org.jackhuang.hellominecraft.tasks.TaskWindow; import org.jackhuang.hellominecraft.utils.tasks.TaskWindow;
import org.jackhuang.hellominecraft.tasks.communication.DefaultPreviousResult; import org.jackhuang.hellominecraft.utils.tasks.communication.DefaultPreviousResult;
import org.jackhuang.hellominecraft.utils.MessageBox; import org.jackhuang.hellominecraft.utils.MessageBox;
import org.jackhuang.hellominecraft.utils.StrUtils; import org.jackhuang.hellominecraft.utils.StrUtils;
import org.jackhuang.hellominecraft.views.SwingUtils; import org.jackhuang.hellominecraft.utils.views.SwingUtils;
/** /**
* *

View File

@@ -22,13 +22,13 @@ import java.io.IOException;
import javax.swing.DefaultComboBoxModel; import javax.swing.DefaultComboBoxModel;
import javax.swing.JFileChooser; import javax.swing.JFileChooser;
import javax.swing.filechooser.FileNameExtensionFilter; import javax.swing.filechooser.FileNameExtensionFilter;
import org.jackhuang.hellominecraft.C; import org.jackhuang.hellominecraft.utils.C;
import org.jackhuang.hellominecraft.HMCLog; import org.jackhuang.hellominecraft.utils.HMCLog;
import org.jackhuang.hellominecraft.launcher.settings.Settings; import org.jackhuang.hellominecraft.launcher.settings.Settings;
import org.jackhuang.hellominecraft.launcher.core.download.DownloadType; import org.jackhuang.hellominecraft.launcher.core.download.DownloadType;
import org.jackhuang.hellominecraft.utils.system.IOUtils; import org.jackhuang.hellominecraft.utils.system.IOUtils;
import org.jackhuang.hellominecraft.utils.MessageBox; import org.jackhuang.hellominecraft.utils.MessageBox;
import org.jackhuang.hellominecraft.views.SwingUtils; import org.jackhuang.hellominecraft.utils.views.SwingUtils;
import rx.Observable; import rx.Observable;
/** /**

View File

@@ -40,8 +40,8 @@ import javax.swing.JButton;
import javax.swing.JLabel; import javax.swing.JLabel;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import org.jackhuang.hellominecraft.C; import org.jackhuang.hellominecraft.utils.C;
import org.jackhuang.hellominecraft.HMCLog; import org.jackhuang.hellominecraft.utils.HMCLog;
import org.jackhuang.hellominecraft.launcher.Main; import org.jackhuang.hellominecraft.launcher.Main;
import org.jackhuang.hellominecraft.launcher.settings.Settings; import org.jackhuang.hellominecraft.launcher.settings.Settings;
import org.jackhuang.hellominecraft.launcher.core.auth.IAuthenticator; import org.jackhuang.hellominecraft.launcher.core.auth.IAuthenticator;
@@ -49,9 +49,9 @@ import org.jackhuang.hellominecraft.lookandfeel.GraphicsUtils;
import org.jackhuang.hellominecraft.lookandfeel.Theme; import org.jackhuang.hellominecraft.lookandfeel.Theme;
import org.jackhuang.hellominecraft.utils.StrUtils; import org.jackhuang.hellominecraft.utils.StrUtils;
import org.jackhuang.hellominecraft.utils.Utils; import org.jackhuang.hellominecraft.utils.Utils;
import org.jackhuang.hellominecraft.views.DropShadowBorder; import org.jackhuang.hellominecraft.utils.views.DropShadowBorder;
import org.jackhuang.hellominecraft.views.TintablePanel; import org.jackhuang.hellominecraft.utils.views.TintablePanel;
import org.jackhuang.hellominecraft.views.BasicColors; import org.jackhuang.hellominecraft.utils.views.BasicColors;
/** /**
* *

View File

@@ -27,8 +27,8 @@ import java.io.IOException;
import java.util.List; import java.util.List;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import org.jackhuang.hellominecraft.C; import org.jackhuang.hellominecraft.utils.C;
import org.jackhuang.hellominecraft.HMCLog; import org.jackhuang.hellominecraft.utils.HMCLog;
import org.jackhuang.hellominecraft.launcher.core.launch.DefaultGameLauncher; import org.jackhuang.hellominecraft.launcher.core.launch.DefaultGameLauncher;
import org.jackhuang.hellominecraft.launcher.core.GameException; import org.jackhuang.hellominecraft.launcher.core.GameException;
import org.jackhuang.hellominecraft.launcher.core.auth.IAuthenticator; import org.jackhuang.hellominecraft.launcher.core.auth.IAuthenticator;
@@ -46,7 +46,7 @@ import org.jackhuang.hellominecraft.utils.Event;
import org.jackhuang.hellominecraft.lookandfeel.components.ConstomButton; import org.jackhuang.hellominecraft.lookandfeel.components.ConstomButton;
import org.jackhuang.hellominecraft.utils.functions.Consumer; import org.jackhuang.hellominecraft.utils.functions.Consumer;
import org.jackhuang.hellominecraft.utils.system.JavaProcessMonitor; import org.jackhuang.hellominecraft.utils.system.JavaProcessMonitor;
import org.jackhuang.hellominecraft.views.LogWindow; import org.jackhuang.hellominecraft.utils.views.LogWindow;
/** /**
* *

View File

@@ -17,7 +17,7 @@
*/ */
package org.jackhuang.hellominecraft.launcher.views; package org.jackhuang.hellominecraft.launcher.views;
import org.jackhuang.hellominecraft.C; import org.jackhuang.hellominecraft.utils.C;
import org.jackhuang.hellominecraft.launcher.settings.Profile; import org.jackhuang.hellominecraft.launcher.settings.Profile;
import org.jackhuang.hellominecraft.launcher.settings.Settings; import org.jackhuang.hellominecraft.launcher.settings.Settings;
import org.jackhuang.hellominecraft.utils.StrUtils; import org.jackhuang.hellominecraft.utils.StrUtils;

View File

@@ -21,7 +21,7 @@ import java.awt.Component;
import javax.swing.JLabel; import javax.swing.JLabel;
import javax.swing.JList; import javax.swing.JList;
import javax.swing.ListCellRenderer; import javax.swing.ListCellRenderer;
import org.jackhuang.hellominecraft.C; import org.jackhuang.hellominecraft.utils.C;
import org.jackhuang.hellominecraft.launcher.core.version.ServerInfo; import org.jackhuang.hellominecraft.launcher.core.version.ServerInfo;
/** /**

View File

@@ -20,7 +20,7 @@ package org.jackhuang.hellominecraft.launcher.views;
import java.awt.Color; import java.awt.Color;
import javax.swing.DefaultListModel; import javax.swing.DefaultListModel;
import javax.swing.JList; import javax.swing.JList;
import org.jackhuang.hellominecraft.C; import org.jackhuang.hellominecraft.utils.C;
import org.jackhuang.hellominecraft.launcher.core.version.ServerInfo; import org.jackhuang.hellominecraft.launcher.core.version.ServerInfo;
/** /**

View File

@@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see {http://www.gnu.org/licenses/}. * along with this program. If not, see {http://www.gnu.org/licenses/}.
*/ */
package org.jackhuang.hellominecraft; package org.jackhuang.hellominecraft.utils;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.GsonBuilder; import com.google.gson.GsonBuilder;

View File

@@ -15,9 +15,9 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see {http://www.gnu.org/licenses/}. * along with this program. If not, see {http://www.gnu.org/licenses/}.
*/ */
package org.jackhuang.hellominecraft; package org.jackhuang.hellominecraft.utils;
import org.jackhuang.hellominecraft.logging.logger.Logger; import org.jackhuang.hellominecraft.utils.logging.logger.Logger;
/** /**
* *

View File

@@ -17,9 +17,8 @@
*/ */
package org.jackhuang.hellominecraft.utils; package org.jackhuang.hellominecraft.utils;
import org.jackhuang.hellominecraft.views.SwingUtils; import org.jackhuang.hellominecraft.utils.views.SwingUtils;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import org.jackhuang.hellominecraft.C;
/** /**
* @author huangyuhui * @author huangyuhui

View File

@@ -27,7 +27,6 @@ import java.net.MalformedURLException;
import java.net.Proxy; import java.net.Proxy;
import java.net.URL; import java.net.URL;
import java.util.Map; import java.util.Map;
import org.jackhuang.hellominecraft.HMCLog;
import org.jackhuang.hellominecraft.utils.system.IOUtils; import org.jackhuang.hellominecraft.utils.system.IOUtils;
import rx.Observable; import rx.Observable;

View File

@@ -18,8 +18,6 @@
package org.jackhuang.hellominecraft.utils; package org.jackhuang.hellominecraft.utils;
import java.util.Map; import java.util.Map;
import org.jackhuang.hellominecraft.C;
import org.jackhuang.hellominecraft.HMCLog;
import rx.Observable; import rx.Observable;
/** /**

View File

@@ -31,7 +31,6 @@ import java.net.URLClassLoader;
import java.net.URLDecoder; import java.net.URLDecoder;
import java.util.Random; import java.util.Random;
import javax.swing.ImageIcon; import javax.swing.ImageIcon;
import org.jackhuang.hellominecraft.HMCLog;
/** /**
* @author huangyuhui * @author huangyuhui

View File

@@ -17,8 +17,6 @@
*/ */
package org.jackhuang.hellominecraft.utils; package org.jackhuang.hellominecraft.utils;
import org.jackhuang.hellominecraft.HMCLog;
/** /**
* *
* @author huangyuhui * @author huangyuhui

View File

@@ -15,9 +15,9 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see {http://www.gnu.org/licenses/}. * along with this program. If not, see {http://www.gnu.org/licenses/}.
*/ */
package org.jackhuang.hellominecraft.logging; package org.jackhuang.hellominecraft.utils.logging;
import org.jackhuang.hellominecraft.logging.appender.IAppender; import org.jackhuang.hellominecraft.utils.logging.appender.IAppender;
public class AppenderControl { public class AppenderControl {

View File

@@ -15,12 +15,12 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see {http://www.gnu.org/licenses/}. * along with this program. If not, see {http://www.gnu.org/licenses/}.
*/ */
package org.jackhuang.hellominecraft.logging; package org.jackhuang.hellominecraft.utils.logging;
import java.util.ArrayList; import java.util.ArrayList;
import org.jackhuang.hellominecraft.logging.appender.ConsoleAppender; import org.jackhuang.hellominecraft.utils.logging.appender.ConsoleAppender;
import org.jackhuang.hellominecraft.logging.appender.IAppender; import org.jackhuang.hellominecraft.utils.logging.appender.IAppender;
import org.jackhuang.hellominecraft.logging.layout.DefaultLayout; import org.jackhuang.hellominecraft.utils.logging.layout.DefaultLayout;
/** /**
* *

View File

@@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see {http://www.gnu.org/licenses/}. * along with this program. If not, see {http://www.gnu.org/licenses/}.
*/ */
package org.jackhuang.hellominecraft.logging; package org.jackhuang.hellominecraft.utils.logging;
import java.awt.Color; import java.awt.Color;
import java.util.regex.Matcher; import java.util.regex.Matcher;

View File

@@ -15,9 +15,9 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see {http://www.gnu.org/licenses/}. * along with this program. If not, see {http://www.gnu.org/licenses/}.
*/ */
package org.jackhuang.hellominecraft.logging; package org.jackhuang.hellominecraft.utils.logging;
import org.jackhuang.hellominecraft.logging.message.IMessage; import org.jackhuang.hellominecraft.utils.logging.message.IMessage;
/** /**
* *

View File

@@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see {http://www.gnu.org/licenses/}. * along with this program. If not, see {http://www.gnu.org/licenses/}.
*/ */
package org.jackhuang.hellominecraft.logging; package org.jackhuang.hellominecraft.utils.logging;
/** /**
* *

View File

@@ -15,10 +15,10 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see {http://www.gnu.org/licenses/}. * along with this program. If not, see {http://www.gnu.org/licenses/}.
*/ */
package org.jackhuang.hellominecraft.logging.appender; package org.jackhuang.hellominecraft.utils.logging.appender;
import java.io.Serializable; import java.io.Serializable;
import org.jackhuang.hellominecraft.logging.layout.ILayout; import org.jackhuang.hellominecraft.utils.logging.layout.ILayout;
/** /**
* *

View File

@@ -15,12 +15,12 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see {http://www.gnu.org/licenses/}. * along with this program. If not, see {http://www.gnu.org/licenses/}.
*/ */
package org.jackhuang.hellominecraft.logging.appender; package org.jackhuang.hellominecraft.utils.logging.appender;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.io.Serializable; import java.io.Serializable;
import org.jackhuang.hellominecraft.logging.layout.ILayout; import org.jackhuang.hellominecraft.utils.logging.layout.ILayout;
/** /**
* *

View File

@@ -15,11 +15,11 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see {http://www.gnu.org/licenses/}. * along with this program. If not, see {http://www.gnu.org/licenses/}.
*/ */
package org.jackhuang.hellominecraft.logging.appender; package org.jackhuang.hellominecraft.utils.logging.appender;
import java.io.Serializable; import java.io.Serializable;
import org.jackhuang.hellominecraft.logging.LogEvent; import org.jackhuang.hellominecraft.utils.logging.LogEvent;
import org.jackhuang.hellominecraft.logging.layout.ILayout; import org.jackhuang.hellominecraft.utils.logging.layout.ILayout;
/** /**
* *

View File

@@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see {http://www.gnu.org/licenses/}. * along with this program. If not, see {http://www.gnu.org/licenses/}.
*/ */
package org.jackhuang.hellominecraft.logging.appender; package org.jackhuang.hellominecraft.utils.logging.appender;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
@@ -23,9 +23,9 @@ import java.io.PrintStream;
import java.io.Serializable; import java.io.Serializable;
import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock;
import org.jackhuang.hellominecraft.logging.LogEvent; import org.jackhuang.hellominecraft.utils.logging.LogEvent;
import org.jackhuang.hellominecraft.logging.LoggingException; import org.jackhuang.hellominecraft.utils.logging.LoggingException;
import org.jackhuang.hellominecraft.logging.layout.ILayout; import org.jackhuang.hellominecraft.utils.logging.layout.ILayout;
/** /**
* *

View File

@@ -15,9 +15,9 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see {http://www.gnu.org/licenses/}. * along with this program. If not, see {http://www.gnu.org/licenses/}.
*/ */
package org.jackhuang.hellominecraft.logging.layout; package org.jackhuang.hellominecraft.utils.logging.layout;
import org.jackhuang.hellominecraft.logging.LogEvent; import org.jackhuang.hellominecraft.utils.logging.LogEvent;
/** /**
* *

View File

@@ -15,11 +15,11 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see {http://www.gnu.org/licenses/}. * along with this program. If not, see {http://www.gnu.org/licenses/}.
*/ */
package org.jackhuang.hellominecraft.logging.layout; package org.jackhuang.hellominecraft.utils.logging.layout;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import org.jackhuang.hellominecraft.logging.LogEvent; import org.jackhuang.hellominecraft.utils.logging.LogEvent;
/** /**
* *

View File

@@ -15,10 +15,10 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see {http://www.gnu.org/licenses/}. * along with this program. If not, see {http://www.gnu.org/licenses/}.
*/ */
package org.jackhuang.hellominecraft.logging.layout; package org.jackhuang.hellominecraft.utils.logging.layout;
import java.io.Serializable; import java.io.Serializable;
import org.jackhuang.hellominecraft.logging.LogEvent; import org.jackhuang.hellominecraft.utils.logging.LogEvent;
/** /**
* *

View File

@@ -15,13 +15,13 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see {http://www.gnu.org/licenses/}. * along with this program. If not, see {http://www.gnu.org/licenses/}.
*/ */
package org.jackhuang.hellominecraft.logging.logger; package org.jackhuang.hellominecraft.utils.logging.logger;
import org.jackhuang.hellominecraft.logging.Level; import org.jackhuang.hellominecraft.utils.logging.Level;
import org.jackhuang.hellominecraft.logging.message.IMessage; import org.jackhuang.hellominecraft.utils.logging.message.IMessage;
import org.jackhuang.hellominecraft.logging.message.IMessageFactory; import org.jackhuang.hellominecraft.utils.logging.message.IMessageFactory;
import org.jackhuang.hellominecraft.logging.message.ParameterizedMessageFactory; import org.jackhuang.hellominecraft.utils.logging.message.ParameterizedMessageFactory;
import org.jackhuang.hellominecraft.logging.message.StringFormattedMessage; import org.jackhuang.hellominecraft.utils.logging.message.StringFormattedMessage;
public abstract class AbstractLogger public abstract class AbstractLogger
implements ILogger { implements ILogger {

View File

@@ -15,10 +15,10 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see {http://www.gnu.org/licenses/}. * along with this program. If not, see {http://www.gnu.org/licenses/}.
*/ */
package org.jackhuang.hellominecraft.logging.logger; package org.jackhuang.hellominecraft.utils.logging.logger;
import org.jackhuang.hellominecraft.logging.Level; import org.jackhuang.hellominecraft.utils.logging.Level;
import org.jackhuang.hellominecraft.logging.message.IMessage; import org.jackhuang.hellominecraft.utils.logging.message.IMessage;
/** /**
* *

View File

@@ -15,18 +15,18 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see {http://www.gnu.org/licenses/}. * along with this program. If not, see {http://www.gnu.org/licenses/}.
*/ */
package org.jackhuang.hellominecraft.logging.logger; package org.jackhuang.hellominecraft.utils.logging.logger;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import org.jackhuang.hellominecraft.logging.AppenderControl; import org.jackhuang.hellominecraft.utils.logging.AppenderControl;
import org.jackhuang.hellominecraft.logging.Configuration; import org.jackhuang.hellominecraft.utils.logging.Configuration;
import org.jackhuang.hellominecraft.logging.Level; import org.jackhuang.hellominecraft.utils.logging.Level;
import org.jackhuang.hellominecraft.logging.LogEvent; import org.jackhuang.hellominecraft.utils.logging.LogEvent;
import org.jackhuang.hellominecraft.logging.appender.IAppender; import org.jackhuang.hellominecraft.utils.logging.appender.IAppender;
import org.jackhuang.hellominecraft.logging.message.IMessage; import org.jackhuang.hellominecraft.utils.logging.message.IMessage;
import org.jackhuang.hellominecraft.logging.message.IMessageFactory; import org.jackhuang.hellominecraft.utils.logging.message.IMessageFactory;
public class Logger extends AbstractLogger { public class Logger extends AbstractLogger {

View File

@@ -15,16 +15,16 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see {http://www.gnu.org/licenses/}. * along with this program. If not, see {http://www.gnu.org/licenses/}.
*/ */
package org.jackhuang.hellominecraft.logging.logger; package org.jackhuang.hellominecraft.utils.logging.logger;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.PrintStream; import java.io.PrintStream;
import java.text.DateFormat; import java.text.DateFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import org.jackhuang.hellominecraft.logging.Level; import org.jackhuang.hellominecraft.utils.logging.Level;
import org.jackhuang.hellominecraft.logging.message.IMessage; import org.jackhuang.hellominecraft.utils.logging.message.IMessage;
import org.jackhuang.hellominecraft.logging.message.IMessageFactory; import org.jackhuang.hellominecraft.utils.logging.message.IMessageFactory;
public class SimpleLogger extends AbstractLogger { public class SimpleLogger extends AbstractLogger {

View File

@@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see {http://www.gnu.org/licenses/}. * along with this program. If not, see {http://www.gnu.org/licenses/}.
*/ */
package org.jackhuang.hellominecraft.logging.message; package org.jackhuang.hellominecraft.utils.logging.message;
/** /**
* *

View File

@@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see {http://www.gnu.org/licenses/}. * along with this program. If not, see {http://www.gnu.org/licenses/}.
*/ */
package org.jackhuang.hellominecraft.logging.message; package org.jackhuang.hellominecraft.utils.logging.message;
import java.io.Serializable; import java.io.Serializable;

View File

@@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see {http://www.gnu.org/licenses/}. * along with this program. If not, see {http://www.gnu.org/licenses/}.
*/ */
package org.jackhuang.hellominecraft.logging.message; package org.jackhuang.hellominecraft.utils.logging.message;
/** /**
* *

View File

@@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see {http://www.gnu.org/licenses/}. * along with this program. If not, see {http://www.gnu.org/licenses/}.
*/ */
package org.jackhuang.hellominecraft.logging.message; package org.jackhuang.hellominecraft.utils.logging.message;
public class ObjectMessage public class ObjectMessage
implements IMessage { implements IMessage {

View File

@@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see {http://www.gnu.org/licenses/}. * along with this program. If not, see {http://www.gnu.org/licenses/}.
*/ */
package org.jackhuang.hellominecraft.logging.message; package org.jackhuang.hellominecraft.utils.logging.message;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Arrays; import java.util.Arrays;

View File

@@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see {http://www.gnu.org/licenses/}. * along with this program. If not, see {http://www.gnu.org/licenses/}.
*/ */
package org.jackhuang.hellominecraft.logging.message; package org.jackhuang.hellominecraft.utils.logging.message;
/** /**
* *

View File

@@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see {http://www.gnu.org/licenses/}. * along with this program. If not, see {http://www.gnu.org/licenses/}.
*/ */
package org.jackhuang.hellominecraft.logging.message; package org.jackhuang.hellominecraft.utils.logging.message;
/** /**
* *

View File

@@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see {http://www.gnu.org/licenses/}. * along with this program. If not, see {http://www.gnu.org/licenses/}.
*/ */
package org.jackhuang.hellominecraft.logging.message; package org.jackhuang.hellominecraft.utils.logging.message;
import java.util.Arrays; import java.util.Arrays;
import java.util.IllegalFormatException; import java.util.IllegalFormatException;

View File

@@ -25,9 +25,9 @@ import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import java.util.zip.ZipOutputStream; import java.util.zip.ZipOutputStream;
import org.jackhuang.hellominecraft.utils.StrUtils; import org.jackhuang.hellominecraft.utils.functions.Predicate;
import java.util.zip.ZipInputStream;
/** /**
* 文件压缩/解压类 * 文件压缩/解压类
@@ -69,6 +69,8 @@ public class Compressor {
* @param source zip文件路径 * @param source zip文件路径
* @param basePath 待压缩文件根目录 * @param basePath 待压缩文件根目录
* @param zos zip文件的os * @param zos zip文件的os
*
* @param callback if the file is allowed to be zipped.
*/ */
private static void zipFile(File source, String basePath, private static void zipFile(File source, String basePath,
ZipOutputStream zos) throws IOException { ZipOutputStream zos) throws IOException {
@@ -86,8 +88,6 @@ public class Compressor {
if (file.isDirectory()) { if (file.isDirectory()) {
pathName = file.getPath().substring(basePath.length() + 1) pathName = file.getPath().substring(basePath.length() + 1)
+ "/"; + "/";
if (file.getName().toLowerCase().contains("meta-inf"))
continue;
zos.putNextEntry(new ZipEntry(pathName)); zos.putNextEntry(new ZipEntry(pathName));
zipFile(file, basePath, zos); zipFile(file, basePath, zos);
} else { } else {
@@ -106,7 +106,7 @@ public class Compressor {
} }
public static void unzip(File zipFileName, File extPlace) throws IOException { public static void unzip(File zipFileName, File extPlace) throws IOException {
unzip(zipFileName, extPlace, new String[0]); unzip(zipFileName, extPlace, null);
} }
/** /**
@@ -114,30 +114,29 @@ public class Compressor {
* *
* @param zipFileName zip文件路径 * @param zipFileName zip文件路径
* @param extPlace 待压缩文件根目录 * @param extPlace 待压缩文件根目录
* @param without 带前缀的不解压 * @param callback will be called for every entry in the zip file,
* returns false if you dont want this file unzipped.
* *
* @throws java.io.IOException 解压失败或无法写入 * @throws java.io.IOException 解压失败或无法写入
*/ */
public static void unzip(File zipFileName, File extPlace, String[] without) throws IOException { public static void unzip(File zipFileName, File extPlace, Predicate<String> callback) throws IOException {
extPlace.mkdirs(); extPlace.mkdirs();
try (ZipFile zipFile = new ZipFile(zipFileName)) { try (ZipInputStream zipFile = new ZipInputStream(new FileInputStream(zipFileName))) {
if (zipFileName.exists()) { if (zipFileName.exists()) {
String strPath, gbkPath, strtemp; String strPath, gbkPath, strtemp;
strPath = extPlace.getAbsolutePath(); strPath = extPlace.getAbsolutePath();
java.util.Enumeration e = zipFile.entries(); ZipEntry zipEnt;
while (e.hasMoreElements()) { while ((zipEnt = zipFile.getNextEntry()) != null) {
ZipEntry zipEnt = (ZipEntry) e.nextElement();
gbkPath = zipEnt.getName(); gbkPath = zipEnt.getName();
if (StrUtils.startsWithOne(without, gbkPath)) if (callback != null)
continue; if (!callback.apply(gbkPath))
continue;
if (zipEnt.isDirectory()) { if (zipEnt.isDirectory()) {
strtemp = strPath + File.separator + gbkPath; strtemp = strPath + File.separator + gbkPath;
File dir = new File(strtemp); File dir = new File(strtemp);
dir.mkdirs(); dir.mkdirs();
} else { } else {
//读写文件 //读写文件
InputStream is = zipFile.getInputStream(zipEnt);
BufferedInputStream bis = new BufferedInputStream(is);
gbkPath = zipEnt.getName(); gbkPath = zipEnt.getName();
strtemp = strPath + File.separator + gbkPath; strtemp = strPath + File.separator + gbkPath;
//建目录 //建目录
@@ -151,7 +150,7 @@ public class Compressor {
} }
try (FileOutputStream fos = new FileOutputStream(strtemp); BufferedOutputStream bos = new BufferedOutputStream(fos)) { try (FileOutputStream fos = new FileOutputStream(strtemp); BufferedOutputStream bos = new BufferedOutputStream(fos)) {
int c; int c;
while ((c = bis.read()) != -1) while ((c = zipFile.read()) != -1)
bos.write((byte) c); bos.write((byte) c);
} }
} }
@@ -167,32 +166,35 @@ public class Compressor {
* @param srcFile zip2 * @param srcFile zip2
* *
* @throws java.io.IOException 无法写入或读取 * @throws java.io.IOException 无法写入或读取
*//*
* public static void merge(File destFile, File srcFile) throws IOException
* {
* try (ZipOutputStream os = new ZipOutputStream(new
* FileOutputStream(destFile))) {
* if (destFile.exists()) {
* File extPlace = new File(IOUtils.currentDir(), "HMCL-MERGE-TEMP");
* unzip(srcFile, extPlace);
* ZipFile zipFile = new ZipFile(srcFile);
* if (srcFile.exists()) {
* String gbkPath;//, strtemp, strPath;
* //strPath = extPlace.getAbsolutePath();
* java.util.Enumeration e = zipFile.entries();
* while (e.hasMoreElements()) {
* ZipEntry zipEnt = (ZipEntry) e.nextElement();
* //gbkPath = zipEnt.getName();
* if (zipEnt.isDirectory()) {
* //strtemp = strPath + File.separator + gbkPath;
* } else {
* gbkPath = zipEnt.getName();
* //strtemp = strPath + File.separator + gbkPath;
* os.putNextEntry(zipEnt);
* os.write(gbkPath.getBytes("UTF-8"));
* }
* }
* }
* }
* os.closeEntry();
* }
* }
*/ */
public static void merge(File destFile, File srcFile) throws IOException {
try (ZipOutputStream os = new ZipOutputStream(new FileOutputStream(destFile))) {
if (destFile.exists()) {
File extPlace = new File(IOUtils.currentDir(), "HMCL-MERGE-TEMP");
unzip(srcFile, extPlace);
ZipFile zipFile = new ZipFile(srcFile);
if (srcFile.exists()) {
String gbkPath;//, strtemp, strPath;
//strPath = extPlace.getAbsolutePath();
java.util.Enumeration e = zipFile.entries();
while (e.hasMoreElements()) {
ZipEntry zipEnt = (ZipEntry) e.nextElement();
//gbkPath = zipEnt.getName();
if (zipEnt.isDirectory()) {
//strtemp = strPath + File.separator + gbkPath;
} else {
gbkPath = zipEnt.getName();
//strtemp = strPath + File.separator + gbkPath;
os.putNextEntry(zipEnt);
os.write(gbkPath.getBytes("UTF-8"));
}
}
}
}
os.closeEntry();
}
}
} }

View File

@@ -27,7 +27,7 @@ import java.io.OutputStream;
import java.nio.channels.FileChannel; import java.nio.channels.FileChannel;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.jackhuang.hellominecraft.HMCLog; import org.jackhuang.hellominecraft.utils.HMCLog;
import org.jackhuang.hellominecraft.utils.NetUtils; import org.jackhuang.hellominecraft.utils.NetUtils;
/** /**

View File

@@ -37,7 +37,7 @@ import java.net.URL;
import java.net.UnknownHostException; import java.net.UnknownHostException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.jackhuang.hellominecraft.HMCLog; import org.jackhuang.hellominecraft.utils.HMCLog;
/** /**
* *

View File

@@ -22,8 +22,8 @@ import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import org.jackhuang.hellominecraft.C; import org.jackhuang.hellominecraft.utils.C;
import org.jackhuang.hellominecraft.HMCLog; import org.jackhuang.hellominecraft.utils.HMCLog;
/** /**
* *

View File

@@ -21,7 +21,7 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import org.jackhuang.hellominecraft.HMCLog; import org.jackhuang.hellominecraft.utils.HMCLog;
import org.jackhuang.hellominecraft.utils.StrUtils; import org.jackhuang.hellominecraft.utils.StrUtils;
/** /**

View File

@@ -25,7 +25,7 @@ import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.lang.management.ManagementFactory; import java.lang.management.ManagementFactory;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import org.jackhuang.hellominecraft.HMCLog; import org.jackhuang.hellominecraft.utils.HMCLog;
import org.jackhuang.hellominecraft.utils.StrUtils; import org.jackhuang.hellominecraft.utils.StrUtils;
/** /**

View File

@@ -20,7 +20,7 @@ package org.jackhuang.hellominecraft.utils.system;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import org.jackhuang.hellominecraft.HMCLog; import org.jackhuang.hellominecraft.utils.HMCLog;
import org.jackhuang.hellominecraft.utils.EventHandler; import org.jackhuang.hellominecraft.utils.EventHandler;
/** /**

View File

@@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see {http://www.gnu.org/licenses/}. * along with this program. If not, see {http://www.gnu.org/licenses/}.
*/ */
package org.jackhuang.hellominecraft.tasks; package org.jackhuang.hellominecraft.utils.tasks;
import java.io.File; import java.io.File;
import org.jackhuang.hellominecraft.utils.system.Compressor; import org.jackhuang.hellominecraft.utils.system.Compressor;

View File

@@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see {http://www.gnu.org/licenses/}. * along with this program. If not, see {http://www.gnu.org/licenses/}.
*/ */
package org.jackhuang.hellominecraft.tasks; package org.jackhuang.hellominecraft.utils.tasks;
/** /**
* *

View File

@@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see {http://www.gnu.org/licenses/}. * along with this program. If not, see {http://www.gnu.org/licenses/}.
*/ */
package org.jackhuang.hellominecraft.tasks; package org.jackhuang.hellominecraft.utils.tasks;
/** /**
* *

View File

@@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see {http://www.gnu.org/licenses/}. * along with this program. If not, see {http://www.gnu.org/licenses/}.
*/ */
package org.jackhuang.hellominecraft.tasks; package org.jackhuang.hellominecraft.utils.tasks;
import java.util.Collection; import java.util.Collection;
import java.util.HashSet; import java.util.HashSet;

View File

@@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see {http://www.gnu.org/licenses/}. * along with this program. If not, see {http://www.gnu.org/licenses/}.
*/ */
package org.jackhuang.hellominecraft.tasks; package org.jackhuang.hellominecraft.utils.tasks;
/** /**
* *

View File

@@ -15,11 +15,11 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see {http://www.gnu.org/licenses/}. * along with this program. If not, see {http://www.gnu.org/licenses/}.
*/ */
package org.jackhuang.hellominecraft.tasks; package org.jackhuang.hellominecraft.utils.tasks;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import org.jackhuang.hellominecraft.HMCLog; import org.jackhuang.hellominecraft.utils.HMCLog;
/** /**
* *

View File

@@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see {http://www.gnu.org/licenses/}. * along with this program. If not, see {http://www.gnu.org/licenses/}.
*/ */
package org.jackhuang.hellominecraft.tasks; package org.jackhuang.hellominecraft.utils.tasks;
/** /**
* *

View File

@@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see {http://www.gnu.org/licenses/}. * along with this program. If not, see {http://www.gnu.org/licenses/}.
*/ */
package org.jackhuang.hellominecraft.tasks; package org.jackhuang.hellominecraft.utils.tasks;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
@@ -24,7 +24,7 @@ import java.util.HashSet;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import org.jackhuang.hellominecraft.HMCLog; import org.jackhuang.hellominecraft.utils.HMCLog;
/** /**
* *

Some files were not shown because too many files have changed in this diff Show More