mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-09-17 07:47:57 -04:00
reconstruct codes
This commit is contained in:
parent
f32ce42af3
commit
d207fa3dfb
@ -17,7 +17,7 @@
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.launcher.api;
|
||||
|
||||
import org.jackhuang.hellominecraft.launcher.launch.IMinecraftProvider;
|
||||
import org.jackhuang.hellominecraft.launcher.launch.IMinecraftService;
|
||||
import org.jackhuang.hellominecraft.launcher.settings.Profile;
|
||||
import org.jackhuang.hellominecraft.launcher.utils.auth.AuthenticationException;
|
||||
import org.jackhuang.hellominecraft.launcher.utils.auth.IAuthenticator;
|
||||
@ -38,7 +38,7 @@ public interface IPlugin {
|
||||
* @return For example, you can implement IMinecraftProvider to support
|
||||
* MultiMC
|
||||
*/
|
||||
IMinecraftProvider provideMinecraftProvider(Profile profile);
|
||||
IMinecraftService provideMinecraftService(Profile profile);
|
||||
|
||||
/**
|
||||
* Register authenticators by calling IAuthenticator.LOGINS.add.
|
||||
|
@ -46,16 +46,16 @@ public abstract class AbstractMinecraftLoader implements IMinecraftLoader {
|
||||
protected Profile v;
|
||||
protected UserProfileProvider lr;
|
||||
protected File gameDir;
|
||||
protected IMinecraftProvider provider;
|
||||
protected IMinecraftService service;
|
||||
protected final MinecraftVersion version;
|
||||
|
||||
public AbstractMinecraftLoader(Profile ver, IMinecraftProvider provider, UserProfileProvider lr) {
|
||||
public AbstractMinecraftLoader(Profile ver, IMinecraftService provider, UserProfileProvider lr) throws GameException {
|
||||
this.lr = lr;
|
||||
|
||||
v = ver;
|
||||
this.provider = provider;
|
||||
service = provider;
|
||||
gameDir = v.getCanonicalGameDirFile();
|
||||
version = provider.getSelectedVersion().resolve(provider);
|
||||
version = service.version().getSelectedVersion().resolve(service.version());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -134,7 +134,7 @@ public abstract class AbstractMinecraftLoader implements IMinecraftLoader {
|
||||
res.add(a);
|
||||
}
|
||||
|
||||
res.add("-Djava.library.path=" + provider.getDecompressNativesToLocation(version).getPath());
|
||||
res.add("-Djava.library.path=" + service.version().getDecompressNativesToLocation(version).getPath());
|
||||
res.add("-Dfml.ignoreInvalidMinecraftCertificates=true");
|
||||
res.add("-Dfml.ignorePatchDiscrepancies=true");
|
||||
|
||||
|
@ -0,0 +1,78 @@
|
||||
/*
|
||||
* 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.launch;
|
||||
|
||||
import org.jackhuang.hellominecraft.launcher.settings.Profile;
|
||||
import org.jackhuang.hellominecraft.launcher.utils.installers.MinecraftInstallerService;
|
||||
import org.jackhuang.hellominecraft.launcher.version.MinecraftAssetService;
|
||||
import org.jackhuang.hellominecraft.launcher.version.MinecraftDownloadService;
|
||||
import org.jackhuang.hellominecraft.launcher.version.MinecraftModService;
|
||||
import org.jackhuang.hellominecraft.launcher.version.MinecraftVersionManager;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public class DefaultMinecraftService extends IMinecraftService {
|
||||
|
||||
public DefaultMinecraftService(Profile p) {
|
||||
super(p);
|
||||
this.provider = new MinecraftVersionManager(this);
|
||||
provider.initializeMiencraft();
|
||||
this.mms = new MinecraftModService(this);
|
||||
this.mds = new MinecraftDownloadService(this);
|
||||
this.mas = new MinecraftAssetService(this);
|
||||
this.mis = new MinecraftInstallerService(this);
|
||||
}
|
||||
|
||||
protected IMinecraftProvider provider;
|
||||
|
||||
@Override
|
||||
public IMinecraftProvider version() {
|
||||
return provider;
|
||||
}
|
||||
|
||||
protected MinecraftModService mms;
|
||||
|
||||
@Override
|
||||
public IMinecraftModService mod() {
|
||||
return mms;
|
||||
}
|
||||
|
||||
protected MinecraftDownloadService mds;
|
||||
|
||||
@Override
|
||||
public IMinecraftDownloadService download() {
|
||||
return mds;
|
||||
}
|
||||
|
||||
final MinecraftAssetService mas;
|
||||
|
||||
@Override
|
||||
public IMinecraftAssetService asset() {
|
||||
return mas;
|
||||
}
|
||||
|
||||
protected MinecraftInstallerService mis;
|
||||
|
||||
@Override
|
||||
public IMinecraftInstallerService install() {
|
||||
return mis;
|
||||
}
|
||||
|
||||
}
|
@ -25,7 +25,6 @@ import org.jackhuang.hellominecraft.launcher.utils.auth.OfflineAuthenticator;
|
||||
import org.jackhuang.hellominecraft.launcher.utils.auth.SkinmeAuthenticator;
|
||||
import org.jackhuang.hellominecraft.launcher.utils.auth.UserProfileProvider;
|
||||
import org.jackhuang.hellominecraft.launcher.utils.auth.YggdrasilAuthenticator;
|
||||
import org.jackhuang.hellominecraft.launcher.version.MinecraftVersionManager;
|
||||
import org.jackhuang.hellominecraft.launcher.views.MainFrame;
|
||||
import org.jackhuang.hellominecraft.utils.functions.Consumer;
|
||||
|
||||
@ -40,8 +39,8 @@ public class DefaultPlugin implements IPlugin {
|
||||
protected static SkinmeAuthenticator SKINME_LOGIN;
|
||||
|
||||
@Override
|
||||
public IMinecraftProvider provideMinecraftProvider(Profile profile) {
|
||||
return new MinecraftVersionManager(profile);
|
||||
public IMinecraftService provideMinecraftService(Profile profile) {
|
||||
return new DefaultMinecraftService(profile);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -23,8 +23,19 @@ package org.jackhuang.hellominecraft.launcher.launch;
|
||||
*/
|
||||
public class GameException extends Exception {
|
||||
|
||||
public GameException() {
|
||||
}
|
||||
|
||||
public GameException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public GameException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public GameException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -31,6 +31,7 @@ import org.jackhuang.hellominecraft.launcher.utils.auth.IAuthenticator;
|
||||
import org.jackhuang.hellominecraft.launcher.utils.auth.LoginInfo;
|
||||
import org.jackhuang.hellominecraft.launcher.utils.auth.UserProfileProvider;
|
||||
import org.jackhuang.hellominecraft.launcher.settings.Profile;
|
||||
import org.jackhuang.hellominecraft.launcher.utils.auth.AuthenticationException;
|
||||
import org.jackhuang.hellominecraft.utils.system.FileUtils;
|
||||
import org.jackhuang.hellominecraft.utils.system.IOUtils;
|
||||
import org.jackhuang.hellominecraft.utils.system.JavaProcess;
|
||||
@ -44,11 +45,10 @@ public class GameLauncher {
|
||||
|
||||
public static final ProcessManager PROCESS_MANAGER = new ProcessManager();
|
||||
Profile get;
|
||||
IMinecraftProvider provider;
|
||||
IMinecraftService provider;
|
||||
LoginInfo info;
|
||||
UserProfileProvider result;
|
||||
IAuthenticator login;
|
||||
public final EventHandler<String> failEvent = new EventHandler(this);
|
||||
public final EventHandler<List<DownloadLibraryJob>> downloadLibrariesEvent = new EventHandler(this);
|
||||
public final EventHandler<List<String>> successEvent = new EventHandler(this);
|
||||
public final EventHandler<JavaProcess> launchEvent = new EventHandler(this);
|
||||
@ -56,7 +56,7 @@ public class GameLauncher {
|
||||
|
||||
public GameLauncher(Profile version, LoginInfo info, IAuthenticator lg) {
|
||||
this.get = version;
|
||||
this.provider = get.getMinecraftProvider();
|
||||
this.provider = get.service();
|
||||
this.info = info;
|
||||
this.login = lg;
|
||||
}
|
||||
@ -65,63 +65,33 @@ public class GameLauncher {
|
||||
return get;
|
||||
}
|
||||
|
||||
public IMinecraftLoader makeLaunchCommand() {
|
||||
public IMinecraftLoader makeLaunchCommand() throws AuthenticationException, GameException {
|
||||
HMCLog.log("Logging in...");
|
||||
IMinecraftLoader loader;
|
||||
try {
|
||||
if (info != null)
|
||||
result = login.login(info);
|
||||
else
|
||||
result = login.loginBySettings();
|
||||
if (result == null)
|
||||
throw new GameException("Result can not be null.");
|
||||
PluginManager.NOW_PLUGIN.onProcessingLoginResult(result);
|
||||
} catch (Throwable e) {
|
||||
String error = C.i18n("login.failed") + e.getMessage();
|
||||
HMCLog.warn("Login failed by method: " + login.getName(), e);
|
||||
failEvent.execute(error);
|
||||
return null;
|
||||
}
|
||||
if (info != null)
|
||||
result = login.login(info);
|
||||
else
|
||||
result = login.loginBySettings();
|
||||
if (result == null)
|
||||
throw new AuthenticationException("Result can not be null.");
|
||||
PluginManager.NOW_PLUGIN.onProcessingLoginResult(result);
|
||||
|
||||
try {
|
||||
loader = provider.provideMinecraftLoader(result);
|
||||
} catch (GameException e) {
|
||||
failEvent.execute(C.i18n("launch.failed") + ", " + e.getMessage());
|
||||
return null;
|
||||
}
|
||||
loader = provider.version().provideMinecraftLoader(result);
|
||||
|
||||
File file = provider.getDecompressNativesToLocation(loader.getMinecraftVersion());
|
||||
File file = provider.version().getDecompressNativesToLocation(loader.getMinecraftVersion());
|
||||
if (file != null)
|
||||
FileUtils.cleanDirectoryQuietly(file);
|
||||
|
||||
HMCLog.log("Detecting libraries...");
|
||||
if (!downloadLibrariesEvent.execute(provider.getDownloadService().getDownloadLibraries())) {
|
||||
failEvent.execute(C.i18n("launch.failed"));
|
||||
return null;
|
||||
}
|
||||
if (!downloadLibrariesEvent.execute(provider.download().getDownloadLibraries(loader.getMinecraftVersion())))
|
||||
throw new GameException("Failed to download libraries");
|
||||
|
||||
HMCLog.log("Unpacking natives...");
|
||||
DecompressLibraryJob job = null;
|
||||
try {
|
||||
job = provider.getDecompressLibraries(loader.getMinecraftVersion());
|
||||
} catch (GameException e) {
|
||||
failEvent.execute(C.i18n("launch.failed") + ", " + e.getMessage());
|
||||
return null;
|
||||
}
|
||||
if (!decompressNativesEvent.execute(job)) {
|
||||
failEvent.execute(C.i18n("launch.failed"));
|
||||
return null;
|
||||
}
|
||||
DecompressLibraryJob job = provider.version().getDecompressLibraries(loader.getMinecraftVersion());
|
||||
if (!decompressNativesEvent.execute(job))
|
||||
throw new GameException("Failed to decompress natives");
|
||||
|
||||
List<String> lst;
|
||||
try {
|
||||
lst = loader.makeLaunchingCommand();
|
||||
} catch (Exception e) {
|
||||
failEvent.execute(C.i18n("launch.failed"));
|
||||
HMCLog.err("Failed to launch game", e);
|
||||
return null;
|
||||
}
|
||||
successEvent.execute(lst);
|
||||
successEvent.execute(loader.makeLaunchingCommand());
|
||||
return loader;
|
||||
}
|
||||
|
||||
@ -129,33 +99,30 @@ public class GameLauncher {
|
||||
* Launch the game "as soon as possible".
|
||||
*
|
||||
* @param str launch command
|
||||
*
|
||||
* @throws IOException failed creating process
|
||||
*/
|
||||
public void launch(List str) {
|
||||
try {
|
||||
if (!provider.onLaunch())
|
||||
return;
|
||||
if (StrUtils.isNotBlank(getProfile().getPrecalledCommand())) {
|
||||
Process p = Runtime.getRuntime().exec(getProfile().getPrecalledCommand());
|
||||
try {
|
||||
if (p != null && p.isAlive())
|
||||
p.waitFor();
|
||||
} catch (InterruptedException ex) {
|
||||
HMCLog.warn("Failed to invoke precalled command", ex);
|
||||
}
|
||||
public void launch(List str) throws IOException {
|
||||
if (!provider.version().onLaunch())
|
||||
return;
|
||||
if (StrUtils.isNotBlank(getProfile().getPrecalledCommand())) {
|
||||
Process p = Runtime.getRuntime().exec(getProfile().getPrecalledCommand());
|
||||
try {
|
||||
if (p != null && p.isAlive())
|
||||
p.waitFor();
|
||||
} catch (InterruptedException ex) {
|
||||
HMCLog.warn("Failed to invoke precalled command", ex);
|
||||
}
|
||||
HMCLog.log("Starting process");
|
||||
ProcessBuilder builder = new ProcessBuilder(str);
|
||||
if (get == null || provider.getSelectedVersion() == null || StrUtils.isBlank(get.getCanonicalGameDir()))
|
||||
throw new Error("Fucking bug!");
|
||||
builder.directory(provider.getRunDirectory(provider.getSelectedVersion().id))
|
||||
.environment().put("APPDATA", get.getCanonicalGameDir());
|
||||
JavaProcess jp = new JavaProcess(str, builder.start(), PROCESS_MANAGER);
|
||||
HMCLog.log("The game process have been started");
|
||||
launchEvent.execute(jp);
|
||||
} catch (Exception e) {
|
||||
failEvent.execute(C.i18n("launch.failed_creating_process") + "\n" + e.getMessage());
|
||||
HMCLog.err("Failed to launch when creating a new process.", e);
|
||||
}
|
||||
HMCLog.log("Starting process");
|
||||
ProcessBuilder builder = new ProcessBuilder(str);
|
||||
if (get == null || provider.version().getSelectedVersion() == null || StrUtils.isBlank(get.getCanonicalGameDir()))
|
||||
throw new Error("Fucking bug!");
|
||||
builder.directory(provider.version().getRunDirectory(provider.version().getSelectedVersion().id))
|
||||
.environment().put("APPDATA", get.getCanonicalGameDir());
|
||||
JavaProcess jp = new JavaProcess(str, builder.start(), PROCESS_MANAGER);
|
||||
HMCLog.log("The game process have been started");
|
||||
launchEvent.execute(jp);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -170,7 +137,7 @@ public class GameLauncher {
|
||||
*/
|
||||
public File makeLauncher(String launcherName, List str) throws IOException {
|
||||
HMCLog.log("Making shell launcher...");
|
||||
provider.onLaunch();
|
||||
provider.version().onLaunch();
|
||||
boolean isWin = OS.os() == OS.WINDOWS;
|
||||
File f = new File(launcherName + (isWin ? ".bat" : ".sh"));
|
||||
if (!f.exists())
|
||||
|
@ -19,16 +19,15 @@ package org.jackhuang.hellominecraft.launcher.launch;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import org.jackhuang.hellominecraft.launcher.settings.Profile;
|
||||
import org.jackhuang.hellominecraft.tasks.Task;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public abstract class IMinecraftAssetService extends IMinecraftService {
|
||||
public abstract class IMinecraftAssetService extends IMinecraftBasicService {
|
||||
|
||||
public IMinecraftAssetService(Profile profile) {
|
||||
public IMinecraftAssetService(IMinecraftService profile) {
|
||||
super(profile);
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,32 @@
|
||||
/*
|
||||
* 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.launch;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public abstract class IMinecraftBasicService {
|
||||
|
||||
public IMinecraftService service;
|
||||
|
||||
public IMinecraftBasicService(IMinecraftService service) {
|
||||
this.service = service;
|
||||
}
|
||||
|
||||
}
|
@ -18,7 +18,7 @@
|
||||
package org.jackhuang.hellominecraft.launcher.launch;
|
||||
|
||||
import java.util.List;
|
||||
import org.jackhuang.hellominecraft.launcher.settings.Profile;
|
||||
import org.jackhuang.hellominecraft.launcher.utils.download.DownloadType;
|
||||
import org.jackhuang.hellominecraft.launcher.version.MinecraftVersion;
|
||||
import org.jackhuang.hellominecraft.version.MinecraftRemoteVersion;
|
||||
import rx.Observable;
|
||||
@ -27,9 +27,9 @@ import rx.Observable;
|
||||
*
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public abstract class IMinecraftDownloadService extends IMinecraftService {
|
||||
public abstract class IMinecraftDownloadService extends IMinecraftBasicService {
|
||||
|
||||
public IMinecraftDownloadService(Profile profile) {
|
||||
public IMinecraftDownloadService(IMinecraftService profile) {
|
||||
super(profile);
|
||||
}
|
||||
|
||||
@ -44,16 +44,7 @@ public abstract class IMinecraftDownloadService extends IMinecraftService {
|
||||
*
|
||||
* @return the library collection
|
||||
*/
|
||||
public abstract List<GameLauncher.DownloadLibraryJob> getDownloadLibraries();
|
||||
|
||||
/**
|
||||
* Install a new version to this profile.
|
||||
*
|
||||
* @param version the new version name
|
||||
*
|
||||
* @return Is the action successful?
|
||||
*/
|
||||
public abstract boolean install(String version);
|
||||
public abstract List<GameLauncher.DownloadLibraryJob> getDownloadLibraries(MinecraftVersion mv) throws GameException;
|
||||
|
||||
public abstract Observable<MinecraftRemoteVersion> getRemoteVersions();
|
||||
|
||||
|
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* 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.launch;
|
||||
|
||||
import org.jackhuang.hellominecraft.launcher.launch.IMinecraftBasicService;
|
||||
import org.jackhuang.hellominecraft.launcher.launch.IMinecraftService;
|
||||
import org.jackhuang.hellominecraft.launcher.utils.installers.InstallerType;
|
||||
import org.jackhuang.hellominecraft.launcher.utils.installers.InstallerVersionList;
|
||||
import org.jackhuang.hellominecraft.tasks.Task;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public abstract class IMinecraftInstallerService extends IMinecraftBasicService {
|
||||
|
||||
public IMinecraftInstallerService(IMinecraftService service) {
|
||||
super(service);
|
||||
}
|
||||
|
||||
public abstract Task download(InstallerVersionList.InstallerVersion v, InstallerType type);
|
||||
|
||||
public abstract Task downloadForge(InstallerVersionList.InstallerVersion v);
|
||||
|
||||
public abstract Task downloadOptifine(InstallerVersionList.InstallerVersion v);
|
||||
|
||||
public abstract Task downloadLiteLoader(InstallerVersionList.InstallerVersion v);
|
||||
|
||||
}
|
@ -19,16 +19,15 @@ package org.jackhuang.hellominecraft.launcher.launch;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import org.jackhuang.hellominecraft.launcher.settings.Profile;
|
||||
import org.jackhuang.hellominecraft.launcher.utils.ModInfo;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public abstract class IMinecraftModService extends IMinecraftService {
|
||||
public abstract class IMinecraftModService extends IMinecraftBasicService {
|
||||
|
||||
public IMinecraftModService(Profile profile) {
|
||||
public IMinecraftModService(IMinecraftService profile) {
|
||||
super(profile);
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@ package org.jackhuang.hellominecraft.launcher.launch;
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
import org.jackhuang.hellominecraft.launcher.utils.auth.UserProfileProvider;
|
||||
import org.jackhuang.hellominecraft.launcher.settings.Profile;
|
||||
import org.jackhuang.hellominecraft.launcher.version.GameDirType;
|
||||
import org.jackhuang.hellominecraft.launcher.version.MinecraftVersion;
|
||||
import org.jackhuang.hellominecraft.utils.StrUtils;
|
||||
|
||||
@ -32,10 +32,10 @@ import org.jackhuang.hellominecraft.utils.StrUtils;
|
||||
*/
|
||||
public abstract class IMinecraftProvider {
|
||||
|
||||
protected Profile profile;
|
||||
protected IMinecraftService service;
|
||||
|
||||
public IMinecraftProvider(Profile profile) {
|
||||
this.profile = profile;
|
||||
public IMinecraftProvider(IMinecraftService service) {
|
||||
this.service = service;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -53,16 +53,19 @@ public abstract class IMinecraftProvider {
|
||||
public abstract File getRunDirectory(String id);
|
||||
|
||||
public File getRunDirectory(String id, String subFolder) {
|
||||
return new File(getRunDirectory(getSelectedVersion().id), subFolder);
|
||||
return new File(getRunDirectory(id), subFolder);
|
||||
}
|
||||
|
||||
public abstract void open(String version, String folder);
|
||||
|
||||
public abstract IMinecraftModService getModService();
|
||||
|
||||
public abstract IMinecraftDownloadService getDownloadService();
|
||||
|
||||
public abstract IMinecraftAssetService getAssetService();
|
||||
/**
|
||||
* Install a new version to this profile.
|
||||
*
|
||||
* @param version the new version name
|
||||
*
|
||||
* @return Is the action successful?
|
||||
*/
|
||||
public abstract boolean install(String version);
|
||||
|
||||
/**
|
||||
* Returns the thing like ".minecraft/resourcepacks".
|
||||
@ -103,6 +106,12 @@ public abstract class IMinecraftProvider {
|
||||
*/
|
||||
public abstract IMinecraftLoader provideMinecraftLoader(UserProfileProvider p) throws GameException;
|
||||
|
||||
protected GameDirType gameDirType = GameDirType.ROOT_FOLDER;
|
||||
|
||||
public void setGameDirType(GameDirType gameDirType) {
|
||||
this.gameDirType = gameDirType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Rename version
|
||||
*
|
||||
@ -122,17 +131,6 @@ public abstract class IMinecraftProvider {
|
||||
*/
|
||||
public abstract boolean removeVersionFromDisk(String a);
|
||||
|
||||
/**
|
||||
* Redownload the Minecraft json of the given version.
|
||||
*
|
||||
* @param id the given version name
|
||||
*
|
||||
* @return Is the action successful?
|
||||
*/
|
||||
public boolean refreshJson(String id) {
|
||||
return getDownloadService().downloadMinecraftVersionJson(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Choose a version randomly.
|
||||
*
|
||||
@ -157,14 +155,14 @@ public abstract class IMinecraftProvider {
|
||||
public abstract MinecraftVersion getVersionById(String id);
|
||||
|
||||
public MinecraftVersion getSelectedVersion() {
|
||||
String versionName = profile.getSelectedMinecraftVersionName();
|
||||
String versionName = service.profile.getSelectedMinecraftVersionName();
|
||||
MinecraftVersion v = null;
|
||||
if (StrUtils.isNotBlank(versionName))
|
||||
v = getVersionById(versionName);
|
||||
if (v == null)
|
||||
v = getOneVersion();
|
||||
if (v != null)
|
||||
profile.setSelectedMinecraftVersion(v.id);
|
||||
service.profile.setSelectedMinecraftVersion(v.id);
|
||||
return v;
|
||||
}
|
||||
|
||||
|
21
HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/launch/IMinecraftService.java
Executable file → Normal file
21
HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/launch/IMinecraftService.java
Executable file → Normal file
@ -17,7 +17,10 @@
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.launcher.launch;
|
||||
|
||||
import java.io.File;
|
||||
import org.jackhuang.hellominecraft.launcher.settings.Profile;
|
||||
import org.jackhuang.hellominecraft.launcher.settings.Settings;
|
||||
import org.jackhuang.hellominecraft.launcher.utils.download.DownloadType;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -25,10 +28,26 @@ import org.jackhuang.hellominecraft.launcher.settings.Profile;
|
||||
*/
|
||||
public abstract class IMinecraftService {
|
||||
|
||||
public Profile profile;
|
||||
public final Profile profile;
|
||||
public final File baseFolder;
|
||||
|
||||
public IMinecraftService(Profile profile) {
|
||||
this.profile = profile;
|
||||
this.baseFolder = profile.getCanonicalGameDirFile();
|
||||
}
|
||||
|
||||
public DownloadType getDownloadType() {
|
||||
return Settings.getInstance().getDownloadSource();
|
||||
}
|
||||
|
||||
public abstract IMinecraftAssetService asset();
|
||||
|
||||
public abstract IMinecraftDownloadService download();
|
||||
|
||||
public abstract IMinecraftModService mod();
|
||||
|
||||
public abstract IMinecraftProvider version();
|
||||
|
||||
public abstract IMinecraftInstallerService install();
|
||||
|
||||
}
|
||||
|
@ -26,7 +26,6 @@ import org.jackhuang.hellominecraft.C;
|
||||
import org.jackhuang.hellominecraft.HMCLog;
|
||||
import org.jackhuang.hellominecraft.launcher.Main;
|
||||
import org.jackhuang.hellominecraft.launcher.utils.auth.UserProfileProvider;
|
||||
import org.jackhuang.hellominecraft.launcher.settings.Profile;
|
||||
import org.jackhuang.hellominecraft.utils.system.IOUtils;
|
||||
import org.jackhuang.hellominecraft.launcher.utils.assets.AssetsIndex;
|
||||
import org.jackhuang.hellominecraft.launcher.utils.assets.AssetsObject;
|
||||
@ -48,8 +47,8 @@ public class MinecraftLoader extends AbstractMinecraftLoader {
|
||||
DownloadType dt;
|
||||
String text;
|
||||
|
||||
public MinecraftLoader(Profile ver, IMinecraftProvider provider, UserProfileProvider lr) throws GameException {
|
||||
super(ver, provider, lr);
|
||||
public MinecraftLoader(IMinecraftService provider, UserProfileProvider lr) throws GameException {
|
||||
super(provider.profile, provider, lr);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -60,7 +59,7 @@ public class MinecraftLoader extends AbstractMinecraftLoader {
|
||||
if (l.allow() && !l.isRequiredToUnzip())
|
||||
library += l.getFilePath(gameDir).getAbsolutePath() + File.pathSeparator;
|
||||
}
|
||||
library += IOUtils.tryGetCanonicalFilePath(version.getJar(provider.getBaseFolder())) + File.pathSeparator;
|
||||
library += IOUtils.tryGetCanonicalFilePath(version.getJar(v.getCanonicalGameDirFile())) + File.pathSeparator;
|
||||
library = library.substring(0, library.length() - File.pathSeparator.length());
|
||||
if (v.isCanceledWrapper())
|
||||
res.add("-cp");
|
||||
@ -68,14 +67,14 @@ public class MinecraftLoader extends AbstractMinecraftLoader {
|
||||
String mainClass = version.mainClass;
|
||||
res.add((v.isCanceledWrapper() ? "" : "-mainClass=") + mainClass);
|
||||
|
||||
String arg = provider.getSelectedVersion().minecraftArguments;
|
||||
String arg = service.version().getSelectedVersion().minecraftArguments;
|
||||
String[] splitted = StrUtils.tokenize(arg);
|
||||
|
||||
if (!checkAssetsExist())
|
||||
if (MessageBox.Show(C.i18n("assets.no_assets"), MessageBox.YES_NO_OPTION) == MessageBox.YES_OPTION) {
|
||||
IAssetsHandler.ASSETS_HANDLER.getList(version, provider).subscribe(a -> {
|
||||
IAssetsHandler.ASSETS_HANDLER.getList(version, service.asset()).subscribe(a -> {
|
||||
});
|
||||
TaskWindow.getInstance().addTask(IAssetsHandler.ASSETS_HANDLER.getDownloadTask(provider.profile.getDownloadType().getProvider())).start();
|
||||
TaskWindow.getInstance().addTask(IAssetsHandler.ASSETS_HANDLER.getDownloadTask(service.getDownloadType().getProvider())).start();
|
||||
}
|
||||
|
||||
String game_assets = reconstructAssets().getAbsolutePath();
|
||||
@ -85,10 +84,10 @@ public class MinecraftLoader extends AbstractMinecraftLoader {
|
||||
t = t.replace("${auth_session}", lr.getSession());
|
||||
t = t.replace("${auth_uuid}", lr.getUserId());
|
||||
t = t.replace("${version_name}", Main.makeTitle());
|
||||
t = t.replace("${profile_name}", provider.profile.getName());
|
||||
t = t.replace("${game_directory}", provider.getRunDirectory(version.id).getAbsolutePath());
|
||||
t = t.replace("${profile_name}", v.getName());
|
||||
t = t.replace("${game_directory}", service.version().getRunDirectory(version.id).getAbsolutePath());
|
||||
t = t.replace("${game_assets}", game_assets);
|
||||
t = t.replace("${assets_root}", provider.getAssetService().getAssets().getAbsolutePath());
|
||||
t = t.replace("${assets_root}", service.asset().getAssets().getAbsolutePath());
|
||||
t = t.replace("${auth_access_token}", lr.getAccessToken());
|
||||
t = t.replace("${user_type}", lr.getUserType());
|
||||
t = t.replace("${assets_index_name}", version.getAssets());
|
||||
@ -108,7 +107,7 @@ public class MinecraftLoader extends AbstractMinecraftLoader {
|
||||
|
||||
try {
|
||||
if (OS.os() == OS.OSX) {
|
||||
list.add("-Xdock:icon=" + provider.getAssetService().getAssetObject(version.assets, "icons/minecraft.icns").getAbsolutePath());
|
||||
list.add("-Xdock:icon=" + service.asset().getAssetObject(version.assets, "icons/minecraft.icns").getAbsolutePath());
|
||||
list.add("-Xdock:name=Minecraft");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
@ -117,7 +116,7 @@ public class MinecraftLoader extends AbstractMinecraftLoader {
|
||||
}
|
||||
|
||||
private boolean checkAssetsExist() {
|
||||
File assetsDir = new File(provider.getBaseFolder(), "assets");
|
||||
File assetsDir = new File(service.baseFolder, "assets");
|
||||
File indexDir = new File(assetsDir, "indexes");
|
||||
File objectDir = new File(assetsDir, "objects");
|
||||
File indexFile = new File(indexDir, version.getAssets() + ".json");
|
||||
@ -140,7 +139,7 @@ public class MinecraftLoader extends AbstractMinecraftLoader {
|
||||
}
|
||||
|
||||
private File reconstructAssets() {
|
||||
File assetsDir = new File(provider.getBaseFolder(), "assets");
|
||||
File assetsDir = new File(service.baseFolder, "assets");
|
||||
File indexDir = new File(assetsDir, "indexes");
|
||||
File objectDir = new File(assetsDir, "objects");
|
||||
String assetVersion = version.getAssets();
|
||||
|
@ -60,6 +60,7 @@ public final class Config {
|
||||
}
|
||||
|
||||
public transient final EventHandler<Theme> themeChangedEvent = new EventHandler<>(this);
|
||||
public transient final EventHandler<DownloadType> downloadTypeChangedEvent = new EventHandler<>(this);
|
||||
|
||||
public Theme getTheme() {
|
||||
return Theme.values()[theme];
|
||||
@ -140,6 +141,7 @@ public final class Config {
|
||||
|
||||
public void setDownloadType(int downloadtype) {
|
||||
this.downloadtype = downloadtype;
|
||||
downloadTypeChangedEvent.execute(getDownloadSource());
|
||||
Settings.save();
|
||||
}
|
||||
|
||||
|
@ -19,11 +19,9 @@ package org.jackhuang.hellominecraft.launcher.settings;
|
||||
|
||||
import java.io.File;
|
||||
import org.jackhuang.hellominecraft.launcher.api.PluginManager;
|
||||
import org.jackhuang.hellominecraft.launcher.launch.IMinecraftProvider;
|
||||
import org.jackhuang.hellominecraft.launcher.launch.IMinecraftService;
|
||||
import org.jackhuang.hellominecraft.utils.system.IOUtils;
|
||||
import org.jackhuang.hellominecraft.launcher.utils.MCUtils;
|
||||
import org.jackhuang.hellominecraft.launcher.utils.download.DownloadType;
|
||||
import org.jackhuang.hellominecraft.launcher.utils.installers.InstallerService;
|
||||
import org.jackhuang.hellominecraft.launcher.version.GameDirType;
|
||||
import org.jackhuang.hellominecraft.utils.StrUtils;
|
||||
import org.jackhuang.hellominecraft.utils.Utils;
|
||||
@ -54,7 +52,7 @@ public final class Profile {
|
||||
*/
|
||||
private int gameDirType;
|
||||
|
||||
protected transient IMinecraftProvider minecraftProvider;
|
||||
protected transient IMinecraftService service;
|
||||
|
||||
public Profile() {
|
||||
this("Default");
|
||||
@ -97,12 +95,10 @@ public final class Profile {
|
||||
serverIp = v.serverIp;
|
||||
}
|
||||
|
||||
public IMinecraftProvider getMinecraftProvider() {
|
||||
if (minecraftProvider == null) {
|
||||
minecraftProvider = PluginManager.NOW_PLUGIN.provideMinecraftProvider(this);
|
||||
minecraftProvider.initializeMiencraft();
|
||||
}
|
||||
return minecraftProvider;
|
||||
public IMinecraftService service() {
|
||||
if (service == null)
|
||||
service = PluginManager.NOW_PLUGIN.provideMinecraftService(this);
|
||||
return service;
|
||||
}
|
||||
|
||||
public String getSelectedMinecraftVersionName() {
|
||||
@ -137,7 +133,7 @@ public final class Profile {
|
||||
|
||||
public Profile setGameDir(String gameDir) {
|
||||
this.gameDir = gameDir;
|
||||
getMinecraftProvider().refreshVersions();
|
||||
service().version().refreshVersions();
|
||||
Settings.save();
|
||||
return this;
|
||||
}
|
||||
@ -191,9 +187,9 @@ public final class Profile {
|
||||
}
|
||||
|
||||
public File getFolder(String folder) {
|
||||
if (getMinecraftProvider().getSelectedVersion() == null)
|
||||
if (service().version().getSelectedVersion() == null)
|
||||
return new File(getCanonicalGameDirFile(), folder);
|
||||
return getMinecraftProvider().getRunDirectory(getMinecraftProvider().getSelectedVersion().id, folder);
|
||||
return service().version().getRunDirectory(service().version().getSelectedVersion().id, folder);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
@ -296,6 +292,7 @@ public final class Profile {
|
||||
|
||||
public void setGameDirType(GameDirType gameDirType) {
|
||||
this.gameDirType = gameDirType.ordinal();
|
||||
service().version().setGameDirType(getGameDirType());
|
||||
Settings.save();
|
||||
}
|
||||
|
||||
@ -355,14 +352,4 @@ public final class Profile {
|
||||
public void checkFormat() {
|
||||
gameDir = gameDir.replace('/', OS.os().fileSeparator).replace('\\', OS.os().fileSeparator);
|
||||
}
|
||||
|
||||
transient final InstallerService is = new InstallerService(this);
|
||||
|
||||
public InstallerService getInstallerService() {
|
||||
return is;
|
||||
}
|
||||
|
||||
public DownloadType getDownloadType() {
|
||||
return Settings.getInstance().getDownloadSource();
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
import org.jackhuang.hellominecraft.C;
|
||||
import org.jackhuang.hellominecraft.HMCLog;
|
||||
import org.jackhuang.hellominecraft.launcher.launch.IMinecraftAssetService;
|
||||
import org.jackhuang.hellominecraft.launcher.launch.IMinecraftProvider;
|
||||
import org.jackhuang.hellominecraft.tasks.Task;
|
||||
import org.jackhuang.hellominecraft.utils.system.FileUtils;
|
||||
@ -45,17 +46,17 @@ public class AssetsMojangLoader extends IAssetsHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Observable<String[]> getList(MinecraftVersion mv, IMinecraftProvider mp) {
|
||||
public Observable<String[]> getList(MinecraftVersion mv, IMinecraftAssetService mp) {
|
||||
return Observable.<String[]>createWithEmptySubscription((Observer<String[]> t1) -> {
|
||||
if (mv == null) {
|
||||
t1.onError(null);
|
||||
return;
|
||||
}
|
||||
String assetsId = mv.assets == null ? "legacy" : mv.assets;
|
||||
File assets = mp.getAssetService().getAssets();
|
||||
File assets = mp.getAssets();
|
||||
HMCLog.log("Get index: " + assetsId);
|
||||
File f = IOUtils.tryGetCanonicalFile(new File(assets, "indexes/" + assetsId + ".json"));
|
||||
if (!f.exists() && !mp.getAssetService().downloadMinecraftAssetsIndex(assetsId)) {
|
||||
if (!f.exists() && !mp.downloadMinecraftAssetsIndex(assetsId)) {
|
||||
t1.onError(null);
|
||||
return;
|
||||
}
|
||||
|
@ -25,12 +25,11 @@ import java.util.Collection;
|
||||
import java.util.List;
|
||||
import org.jackhuang.hellominecraft.C;
|
||||
import org.jackhuang.hellominecraft.HMCLog;
|
||||
import org.jackhuang.hellominecraft.launcher.launch.IMinecraftProvider;
|
||||
import org.jackhuang.hellominecraft.launcher.launch.IMinecraftAssetService;
|
||||
import org.jackhuang.hellominecraft.launcher.utils.download.IDownloadProvider;
|
||||
import org.jackhuang.hellominecraft.launcher.version.MinecraftVersion;
|
||||
import org.jackhuang.hellominecraft.tasks.Task;
|
||||
import org.jackhuang.hellominecraft.tasks.download.FileDownloadTask;
|
||||
import org.jackhuang.hellominecraft.utils.functions.Consumer;
|
||||
import org.jackhuang.hellominecraft.utils.code.DigestUtils;
|
||||
import org.jackhuang.hellominecraft.utils.system.IOUtils;
|
||||
import org.jackhuang.hellominecraft.utils.NetUtils;
|
||||
@ -71,10 +70,10 @@ public abstract class IAssetsHandler {
|
||||
* All the files assets needed
|
||||
*
|
||||
* @param mv The version that needs assets
|
||||
* @param mp The Minecraft Provider
|
||||
* @param mp Asset Service
|
||||
* @param x finished event
|
||||
*/
|
||||
public abstract Observable<String[]> getList(MinecraftVersion mv, IMinecraftProvider mp);
|
||||
public abstract Observable<String[]> getList(MinecraftVersion mv, IMinecraftAssetService mp);
|
||||
|
||||
/**
|
||||
* Will be invoked when the user invoked "Download all assets".
|
||||
|
@ -17,8 +17,10 @@
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.launcher.utils.installers;
|
||||
|
||||
import org.jackhuang.hellominecraft.launcher.launch.IMinecraftInstallerService;
|
||||
import java.io.File;
|
||||
import org.jackhuang.hellominecraft.launcher.settings.Profile;
|
||||
import org.jackhuang.hellominecraft.launcher.launch.IMinecraftBasicService;
|
||||
import org.jackhuang.hellominecraft.launcher.launch.IMinecraftService;
|
||||
import org.jackhuang.hellominecraft.launcher.utils.installers.InstallerVersionList.InstallerVersion;
|
||||
import org.jackhuang.hellominecraft.launcher.utils.installers.forge.ForgeInstaller;
|
||||
import org.jackhuang.hellominecraft.launcher.utils.installers.liteloader.LiteLoaderInstaller;
|
||||
@ -35,14 +37,13 @@ import org.jackhuang.hellominecraft.utils.system.IOUtils;
|
||||
*
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public final class InstallerService {
|
||||
public final class MinecraftInstallerService extends IMinecraftInstallerService {
|
||||
|
||||
Profile p;
|
||||
|
||||
public InstallerService(Profile p) {
|
||||
this.p = p;
|
||||
public MinecraftInstallerService(IMinecraftService service) {
|
||||
super(service);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Task download(InstallerVersion v, InstallerType type) {
|
||||
switch (type) {
|
||||
case Forge:
|
||||
@ -56,6 +57,7 @@ public final class InstallerService {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Task downloadForge(InstallerVersion v) {
|
||||
return new TaskInfo("Forge Downloader") {
|
||||
@Override
|
||||
@ -63,13 +65,14 @@ public final class InstallerService {
|
||||
File filepath = IOUtils.tryGetCanonicalFile(IOUtils.currentDirWithSeparator() + "forge-installer.jar");
|
||||
if (v.installer != null)
|
||||
TaskWindow.getInstance()
|
||||
.addTask(new FileDownloadTask(p.getDownloadType().getProvider().getParsedLibraryDownloadURL(v.installer), filepath).setTag("forge"))
|
||||
.addTask(new ForgeInstaller(p.getMinecraftProvider(), filepath, v))
|
||||
.addTask(new FileDownloadTask(service.getDownloadType().getProvider().getParsedLibraryDownloadURL(v.installer), filepath).setTag("forge"))
|
||||
.addTask(new ForgeInstaller(service, filepath, v))
|
||||
.start();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public Task downloadOptifine(InstallerVersion v) {
|
||||
return new TaskInfo("OptiFine Downloader") {
|
||||
@Override
|
||||
@ -79,13 +82,14 @@ public final class InstallerService {
|
||||
OptiFineDownloadFormatter task = new OptiFineDownloadFormatter(v.installer);
|
||||
TaskWindow.getInstance().addTask(task)
|
||||
.addTask(new FileDownloadTask(filepath).registerPreviousResult(task).setTag("optifine"))
|
||||
.addTask(new OptiFineInstaller(p, v.selfVersion, filepath))
|
||||
.addTask(new OptiFineInstaller(service, v.selfVersion, filepath))
|
||||
.start();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public Task downloadLiteLoader(InstallerVersion v) {
|
||||
return new TaskInfo("LiteLoader Downloader") {
|
||||
@Override
|
||||
@ -93,7 +97,7 @@ public final class InstallerService {
|
||||
File filepath = IOUtils.tryGetCanonicalFile(IOUtils.currentDirWithSeparator() + "liteloader-universal.jar");
|
||||
FileDownloadTask task = (FileDownloadTask) new FileDownloadTask(v.universal, filepath).setTag("LiteLoader");
|
||||
TaskWindow.getInstance()
|
||||
.addTask(task).addTask(new LiteLoaderInstaller(p, (LiteLoaderVersionList.LiteLoaderInstallerVersion) v).registerPreviousResult(task))
|
||||
.addTask(task).addTask(new LiteLoaderInstaller(service, (LiteLoaderVersionList.LiteLoaderInstallerVersion) v).registerPreviousResult(task))
|
||||
.start();
|
||||
}
|
||||
};
|
@ -26,7 +26,7 @@ import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
import org.jackhuang.hellominecraft.C;
|
||||
import org.jackhuang.hellominecraft.HMCLog;
|
||||
import org.jackhuang.hellominecraft.launcher.launch.IMinecraftProvider;
|
||||
import org.jackhuang.hellominecraft.launcher.launch.IMinecraftService;
|
||||
import org.jackhuang.hellominecraft.launcher.utils.installers.InstallerVersionList.InstallerVersion;
|
||||
import org.jackhuang.hellominecraft.tasks.Task;
|
||||
import org.jackhuang.hellominecraft.utils.system.FileUtils;
|
||||
@ -42,11 +42,11 @@ public class ForgeInstaller extends Task {
|
||||
|
||||
public File gameDir;
|
||||
public File forgeInstaller;
|
||||
public IMinecraftProvider mp;
|
||||
public IMinecraftService mp;
|
||||
public InstallerVersion installerVersion;
|
||||
|
||||
public ForgeInstaller(IMinecraftProvider mp, File forgeInstaller, InstallerVersion installerVersion) {
|
||||
this.gameDir = mp.getBaseFolder();
|
||||
public ForgeInstaller(IMinecraftService mp, File forgeInstaller, InstallerVersion installerVersion) {
|
||||
this.gameDir = mp.baseFolder;
|
||||
this.forgeInstaller = forgeInstaller;
|
||||
this.mp = mp;
|
||||
this.installerVersion = installerVersion;
|
||||
@ -64,7 +64,7 @@ public class ForgeInstaller extends Task {
|
||||
File from = new File(gameDir, "versions" + File.separator + profile.install.minecraft);
|
||||
if (!from.exists())
|
||||
if (MessageBox.Show(C.i18n("install.no_version_if_intall")) == MessageBox.YES_OPTION) {
|
||||
if (!mp.getDownloadService().install(profile.install.minecraft))
|
||||
if (!mp.version().install(profile.install.minecraft))
|
||||
throw new IllegalStateException(C.i18n("install.no_version"));
|
||||
} else
|
||||
throw new IllegalStateException(C.i18n("install.no_version"));
|
||||
|
@ -22,10 +22,10 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import org.jackhuang.hellominecraft.C;
|
||||
import org.jackhuang.hellominecraft.HMCLog;
|
||||
import org.jackhuang.hellominecraft.launcher.launch.IMinecraftService;
|
||||
import org.jackhuang.hellominecraft.tasks.Task;
|
||||
import org.jackhuang.hellominecraft.tasks.communication.PreviousResult;
|
||||
import org.jackhuang.hellominecraft.tasks.communication.PreviousResultRegistrar;
|
||||
import org.jackhuang.hellominecraft.launcher.settings.Profile;
|
||||
import org.jackhuang.hellominecraft.utils.system.FileUtils;
|
||||
import org.jackhuang.hellominecraft.launcher.version.MinecraftLibrary;
|
||||
import org.jackhuang.hellominecraft.launcher.version.MinecraftVersion;
|
||||
@ -38,27 +38,27 @@ public class LiteLoaderInstaller extends Task implements PreviousResultRegistrar
|
||||
|
||||
public LiteLoaderVersionList.LiteLoaderInstallerVersion version;
|
||||
public File installer;
|
||||
public Profile profile;
|
||||
public IMinecraftService service;
|
||||
|
||||
public LiteLoaderInstaller(Profile profile, LiteLoaderVersionList.LiteLoaderInstallerVersion v) {
|
||||
this(profile, v, null);
|
||||
public LiteLoaderInstaller(IMinecraftService service, LiteLoaderVersionList.LiteLoaderInstallerVersion v) {
|
||||
this(service, v, null);
|
||||
}
|
||||
|
||||
public LiteLoaderInstaller(Profile profile, LiteLoaderVersionList.LiteLoaderInstallerVersion v, File installer) {
|
||||
this.profile = profile;
|
||||
public LiteLoaderInstaller(IMinecraftService service, LiteLoaderVersionList.LiteLoaderInstallerVersion v, File installer) {
|
||||
this.service = service;
|
||||
this.version = v;
|
||||
this.installer = installer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeTask() throws Exception {
|
||||
if (profile == null || profile.getMinecraftProvider().getSelectedVersion() == null)
|
||||
if (service.version().getSelectedVersion() == null)
|
||||
throw new IllegalStateException(C.i18n("install.no_version"));
|
||||
if (pre.size() != 1 && installer == null)
|
||||
throw new IllegalStateException("No registered previous task.");
|
||||
if (installer == null)
|
||||
installer = pre.get(pre.size() - 1).getResult();
|
||||
MinecraftVersion mv = (MinecraftVersion) profile.getMinecraftProvider().getSelectedVersion().clone();
|
||||
MinecraftVersion mv = (MinecraftVersion) service.version().getSelectedVersion().clone();
|
||||
mv.inheritsFrom = mv.id;
|
||||
mv.jar = mv.jar == null ? mv.id : mv.jar;
|
||||
mv.libraries = new ArrayList(Arrays.asList(version.libraries));
|
||||
@ -66,13 +66,13 @@ public class LiteLoaderInstaller extends Task implements PreviousResultRegistrar
|
||||
MinecraftLibrary ml = new MinecraftLibrary("com.mumfrey:liteloader:" + version.selfVersion);
|
||||
//ml.url = "http://dl.liteloader.com/versions/com/mumfrey/liteloader/" + version.mcVersion + "/liteloader-" + version.selfVersion + ".jar";
|
||||
mv.libraries.add(0, ml);
|
||||
FileUtils.copyFile(installer, new File(profile.getCanonicalGameDir(), "libraries/com/mumfrey/liteloader/" + version.selfVersion + "/liteloader-" + version.selfVersion + ".jar"));
|
||||
FileUtils.copyFile(installer, new File(service.baseFolder, "libraries/com/mumfrey/liteloader/" + version.selfVersion + "/liteloader-" + version.selfVersion + ".jar"));
|
||||
|
||||
mv.id += "-LiteLoader" + version.selfVersion;
|
||||
|
||||
mv.mainClass = "net.minecraft.launchwrapper.Launch";
|
||||
mv.minecraftArguments += " --tweakClass " + version.tweakClass;
|
||||
File folder = new File(profile.getCanonicalGameDir(), "versions/" + mv.id);
|
||||
File folder = new File(service.baseFolder, "versions/" + mv.id);
|
||||
folder.mkdirs();
|
||||
File json = new File(folder, mv.id + ".json");
|
||||
HMCLog.log("Creating new version profile..." + mv.id + ".json");
|
||||
|
@ -21,7 +21,7 @@ import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.zip.ZipFile;
|
||||
import org.jackhuang.hellominecraft.C;
|
||||
import org.jackhuang.hellominecraft.launcher.settings.Profile;
|
||||
import org.jackhuang.hellominecraft.launcher.launch.IMinecraftService;
|
||||
import org.jackhuang.hellominecraft.tasks.Task;
|
||||
import org.jackhuang.hellominecraft.tasks.communication.PreviousResult;
|
||||
import org.jackhuang.hellominecraft.tasks.communication.PreviousResultRegistrar;
|
||||
@ -36,29 +36,29 @@ import org.jackhuang.hellominecraft.launcher.version.MinecraftVersion;
|
||||
public class OptiFineInstaller extends Task implements PreviousResultRegistrar<File> {
|
||||
|
||||
public File installer;
|
||||
public Profile profile;
|
||||
public IMinecraftService service;
|
||||
public String version;
|
||||
|
||||
public OptiFineInstaller(Profile profile, String version) {
|
||||
this(profile, version, null);
|
||||
public OptiFineInstaller(IMinecraftService service, String version) {
|
||||
this(service, version, null);
|
||||
}
|
||||
|
||||
public OptiFineInstaller(Profile profile, String version, File installer) {
|
||||
this.profile = profile;
|
||||
public OptiFineInstaller(IMinecraftService service, String version, File installer) {
|
||||
this.service = service;
|
||||
this.installer = installer;
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeTask() throws Exception {
|
||||
if (profile == null || profile.getMinecraftProvider().getSelectedVersion() == null)
|
||||
if (service.version().getSelectedVersion() == null)
|
||||
throw new Exception(C.i18n("install.no_version"));
|
||||
MinecraftVersion mv = (MinecraftVersion) profile.getMinecraftProvider().getSelectedVersion().clone();
|
||||
MinecraftVersion mv = (MinecraftVersion) service.version().getSelectedVersion().clone();
|
||||
mv.inheritsFrom = mv.id;
|
||||
mv.jar = mv.jar == null ? mv.id : mv.jar;
|
||||
mv.libraries.clear();
|
||||
mv.libraries.add(0, new MinecraftLibrary("optifine:OptiFine:" + version));
|
||||
FileUtils.copyFile(installer, new File(profile.getCanonicalGameDir(), "libraries/optifine/OptiFine/" + version + "/OptiFine-" + version + ".jar"));
|
||||
FileUtils.copyFile(installer, new File(service.baseFolder, "libraries/optifine/OptiFine/" + version + "/OptiFine-" + version + ".jar"));
|
||||
|
||||
mv.id += "-" + version;
|
||||
if (new ZipFile(installer).getEntry("optifine/OptiFineTweaker.class") != null) {
|
||||
@ -68,7 +68,7 @@ public class OptiFineInstaller extends Task implements PreviousResultRegistrar<F
|
||||
}
|
||||
mv.minecraftArguments += " --tweakClass optifine.OptiFineTweaker";
|
||||
}
|
||||
File loc = new File(profile.getCanonicalGameDir(), "versions/" + mv.id);
|
||||
File loc = new File(service.baseFolder, "versions/" + mv.id);
|
||||
loc.mkdirs();
|
||||
File json = new File(loc, mv.id + ".json");
|
||||
FileUtils.writeStringToFile(json, C.gsonPrettyPrinting.toJson(mv, MinecraftVersion.class));
|
||||
|
@ -22,7 +22,7 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import org.jackhuang.hellominecraft.C;
|
||||
import org.jackhuang.hellominecraft.launcher.launch.IMinecraftAssetService;
|
||||
import org.jackhuang.hellominecraft.launcher.settings.Profile;
|
||||
import org.jackhuang.hellominecraft.launcher.launch.IMinecraftService;
|
||||
import org.jackhuang.hellominecraft.launcher.utils.assets.AssetsIndex;
|
||||
import org.jackhuang.hellominecraft.launcher.utils.assets.AssetsObject;
|
||||
import org.jackhuang.hellominecraft.launcher.utils.assets.IAssetsHandler;
|
||||
@ -39,12 +39,8 @@ import rx.concurrency.Schedulers;
|
||||
*/
|
||||
public class MinecraftAssetService extends IMinecraftAssetService {
|
||||
|
||||
MinecraftVersionManager mgr;
|
||||
|
||||
public MinecraftAssetService(Profile profile, MinecraftVersionManager mvm) {
|
||||
public MinecraftAssetService(IMinecraftService profile) {
|
||||
super(profile);
|
||||
|
||||
mgr = mvm;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -54,10 +50,10 @@ public class MinecraftAssetService extends IMinecraftAssetService {
|
||||
@Override
|
||||
public void executeTask() throws Throwable {
|
||||
IAssetsHandler type = IAssetsHandler.ASSETS_HANDLER;
|
||||
type.getList(profile.getMinecraftProvider().getVersionById(mcVersion), profile.getMinecraftProvider())
|
||||
type.getList(service.version().getVersionById(mcVersion), service.asset())
|
||||
.subscribeOn(Schedulers.newThread())
|
||||
.observeOn(Schedulers.eventQueue())
|
||||
.subscribe((value) -> TaskWindow.getInstance().addTask(type.getDownloadTask(profile.getDownloadType().getProvider())).start());
|
||||
.subscribe((t) -> TaskWindow.getInstance().addTask(type.getDownloadTask(service.getDownloadType().getProvider())).start());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -69,7 +65,7 @@ public class MinecraftAssetService extends IMinecraftAssetService {
|
||||
|
||||
@Override
|
||||
public boolean refreshAssetsIndex(String id) {
|
||||
MinecraftVersion mv = mgr.getVersionById(id);
|
||||
MinecraftVersion mv = service.version().getVersionById(id);
|
||||
if (mv == null)
|
||||
return false;
|
||||
return downloadMinecraftAssetsIndex(mv.assets);
|
||||
@ -77,7 +73,7 @@ public class MinecraftAssetService extends IMinecraftAssetService {
|
||||
|
||||
@Override
|
||||
public boolean downloadMinecraftAssetsIndex(String assetsId) {
|
||||
String aurl = profile.getDownloadType().getProvider().getIndexesDownloadURL();
|
||||
String aurl = service.getDownloadType().getProvider().getIndexesDownloadURL();
|
||||
|
||||
File assetsLocation = getAssets();
|
||||
assetsLocation.mkdirs();
|
||||
@ -101,7 +97,7 @@ public class MinecraftAssetService extends IMinecraftAssetService {
|
||||
|
||||
@Override
|
||||
public File getAssets() {
|
||||
return new File(profile.getCanonicalGameDirFile(), "assets");
|
||||
return new File(service.profile.getCanonicalGameDirFile(), "assets");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -24,8 +24,9 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.jackhuang.hellominecraft.C;
|
||||
import org.jackhuang.hellominecraft.HMCLog;
|
||||
import org.jackhuang.hellominecraft.launcher.launch.GameException;
|
||||
import org.jackhuang.hellominecraft.launcher.launch.GameLauncher;
|
||||
import org.jackhuang.hellominecraft.launcher.settings.Profile;
|
||||
import org.jackhuang.hellominecraft.launcher.launch.IMinecraftService;
|
||||
import org.jackhuang.hellominecraft.tasks.TaskWindow;
|
||||
import org.jackhuang.hellominecraft.tasks.download.FileDownloadTask;
|
||||
import org.jackhuang.hellominecraft.utils.NetUtils;
|
||||
@ -41,27 +42,24 @@ import rx.Observable;
|
||||
*/
|
||||
public class MinecraftDownloadService extends IMinecraftDownloadService {
|
||||
|
||||
MinecraftVersionManager mgr;
|
||||
|
||||
public MinecraftDownloadService(Profile p, MinecraftVersionManager mgr) {
|
||||
super(p);
|
||||
this.mgr = mgr;
|
||||
public MinecraftDownloadService(IMinecraftService profile) {
|
||||
super(profile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GameLauncher.DownloadLibraryJob> getDownloadLibraries() {
|
||||
public List<GameLauncher.DownloadLibraryJob> getDownloadLibraries(MinecraftVersion mv) throws GameException {
|
||||
ArrayList<GameLauncher.DownloadLibraryJob> downloadLibraries = new ArrayList<>();
|
||||
if (mgr.getSelectedVersion() == null)
|
||||
if (mv == null)
|
||||
return downloadLibraries;
|
||||
MinecraftVersion v = mgr.getSelectedVersion().resolve(mgr);
|
||||
MinecraftVersion v = mv.resolve(service.version());
|
||||
if (v.libraries != null)
|
||||
for (IMinecraftLibrary l : v.libraries) {
|
||||
l.init();
|
||||
if (l.allow()) {
|
||||
File ff = l.getFilePath(profile.getCanonicalGameDirFile());
|
||||
File ff = l.getFilePath(service.baseFolder);
|
||||
if (!ff.exists()) {
|
||||
String libURL = profile.getDownloadType().getProvider().getLibraryDownloadURL() + "/";
|
||||
libURL = profile.getDownloadType().getProvider().getParsedLibraryDownloadURL(l.getDownloadURL(libURL, profile.getDownloadType()));
|
||||
String libURL = service.getDownloadType().getProvider().getLibraryDownloadURL() + "/";
|
||||
libURL = service.getDownloadType().getProvider().getParsedLibraryDownloadURL(l.getDownloadURL(libURL, service.getDownloadType()));
|
||||
if (libURL != null)
|
||||
downloadLibraries.add(new GameLauncher.DownloadLibraryJob(l.name, libURL, ff));
|
||||
}
|
||||
@ -70,20 +68,10 @@ public class MinecraftDownloadService extends IMinecraftDownloadService {
|
||||
return downloadLibraries;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean install(String id) {
|
||||
MinecraftVersion v = downloadMinecraft(id);
|
||||
if (v != null) {
|
||||
mgr.versions.put(v.id, v);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MinecraftVersion downloadMinecraft(String id) {
|
||||
String vurl = profile.getDownloadType().getProvider().getVersionsDownloadURL() + id + "/";
|
||||
File vpath = new File(profile.getCanonicalGameDirFile(), "versions/" + id);
|
||||
String vurl = service.getDownloadType().getProvider().getVersionsDownloadURL() + id + "/";
|
||||
File vpath = new File(service.baseFolder, "versions/" + id);
|
||||
File mvt = new File(vpath, id + ".json");
|
||||
File mvj = new File(vpath, id + ".jar");
|
||||
vpath.mkdirs();
|
||||
@ -106,8 +94,8 @@ public class MinecraftDownloadService extends IMinecraftDownloadService {
|
||||
|
||||
@Override
|
||||
public boolean downloadMinecraftJar(String id) {
|
||||
String vurl = profile.getDownloadType().getProvider().getVersionsDownloadURL() + id + "/";
|
||||
File vpath = new File(profile.getCanonicalGameDirFile(), "versions/" + id);
|
||||
String vurl = service.getDownloadType().getProvider().getVersionsDownloadURL() + id + "/";
|
||||
File vpath = new File(service.baseFolder, "versions/" + id);
|
||||
File mvv = new File(vpath, id + ".jar"), moved = null;
|
||||
if (mvv.exists()) {
|
||||
moved = new File(vpath, id + "-renamed.jar");
|
||||
@ -131,8 +119,8 @@ public class MinecraftDownloadService extends IMinecraftDownloadService {
|
||||
|
||||
@Override
|
||||
public boolean downloadMinecraftVersionJson(String id) {
|
||||
String vurl = profile.getDownloadType().getProvider().getVersionsDownloadURL() + id + "/";
|
||||
File vpath = new File(profile.getCanonicalGameDirFile(), "versions/" + id);
|
||||
String vurl = service.getDownloadType().getProvider().getVersionsDownloadURL() + id + "/";
|
||||
File vpath = new File(service.baseFolder, "versions/" + id);
|
||||
File mvv = new File(vpath, id + ".json"), moved = null;
|
||||
if (mvv.exists()) {
|
||||
moved = new File(vpath, id + "-renamed.json");
|
||||
@ -156,7 +144,7 @@ public class MinecraftDownloadService extends IMinecraftDownloadService {
|
||||
|
||||
@Override
|
||||
public Observable<MinecraftRemoteVersion> getRemoteVersions() {
|
||||
return NetUtils.getRx(profile.getDownloadType().getProvider().getVersionsListDownloadURL())
|
||||
return NetUtils.getRx(service.getDownloadType().getProvider().getVersionsListDownloadURL())
|
||||
.map(r -> C.gson.fromJson(r, MinecraftRemoteVersions.class))
|
||||
.filter(r -> r != null && r.versions != null)
|
||||
.flatMap(r -> Observable.from(r.versions));
|
||||
|
@ -25,7 +25,7 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import org.jackhuang.hellominecraft.HMCLog;
|
||||
import org.jackhuang.hellominecraft.launcher.launch.IMinecraftModService;
|
||||
import org.jackhuang.hellominecraft.launcher.settings.Profile;
|
||||
import org.jackhuang.hellominecraft.launcher.launch.IMinecraftService;
|
||||
import org.jackhuang.hellominecraft.launcher.utils.ModInfo;
|
||||
import org.jackhuang.hellominecraft.utils.code.DigestUtils;
|
||||
import org.jackhuang.hellominecraft.utils.system.FileUtils;
|
||||
@ -36,15 +36,12 @@ import org.jackhuang.hellominecraft.utils.system.FileUtils;
|
||||
*/
|
||||
public class MinecraftModService extends IMinecraftModService {
|
||||
|
||||
MinecraftVersionManager mgr;
|
||||
|
||||
public MinecraftModService(Profile p, MinecraftVersionManager mgr) {
|
||||
super(p);
|
||||
this.mgr = mgr;
|
||||
}
|
||||
|
||||
List<ModInfo> modCache;
|
||||
|
||||
public MinecraftModService(IMinecraftService profile) {
|
||||
super(profile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ModInfo> getMods() {
|
||||
if (modCache == null)
|
||||
@ -55,9 +52,9 @@ public class MinecraftModService extends IMinecraftModService {
|
||||
|
||||
@Override
|
||||
public List<ModInfo> recacheMods() {
|
||||
if (mgr.getSelectedVersion() == null)
|
||||
if (service.version().getSelectedVersion() == null)
|
||||
return modCache = new ArrayList<>();
|
||||
File modsFolder = mgr.getRunDirectory(mgr.getSelectedVersion().id, "mods");
|
||||
File modsFolder = service.version().getRunDirectory(service.version().getSelectedVersion().id, "mods");
|
||||
ArrayList<ModInfo> mods = new ArrayList<>();
|
||||
File[] fs = modsFolder.listFiles();
|
||||
if (fs != null)
|
||||
@ -83,11 +80,11 @@ public class MinecraftModService extends IMinecraftModService {
|
||||
@Override
|
||||
public boolean addMod(File f) {
|
||||
try {
|
||||
if (mgr.getSelectedVersion() == null)
|
||||
if (service.version().getSelectedVersion() == null)
|
||||
return false;
|
||||
if (!ModInfo.isFileMod(f))
|
||||
return false;
|
||||
File modsFolder = mgr.getRunDirectory(mgr.getSelectedVersion().id, "mods");
|
||||
File modsFolder = service.version().getRunDirectory(service.version().getSelectedVersion().id, "mods");
|
||||
if (modsFolder == null)
|
||||
return false;
|
||||
modsFolder.mkdirs();
|
||||
|
@ -72,23 +72,23 @@ public class MinecraftVersion implements Cloneable, Comparable<MinecraftVersion>
|
||||
return new MinecraftVersion(minecraftArguments, mainClass, time, id, type, processArguments, releaseTime, assets, jar, inheritsFrom, minimumLauncherVersion, libraries, hidden);
|
||||
}
|
||||
|
||||
public MinecraftVersion resolve(IMinecraftProvider manager) throws GameException {
|
||||
return resolve(manager, new HashSet<>());
|
||||
public MinecraftVersion resolve(IMinecraftProvider provider) throws GameException {
|
||||
return resolve(provider, new HashSet<>());
|
||||
}
|
||||
|
||||
protected MinecraftVersion resolve(IMinecraftProvider manager, Set<String> resolvedSoFar) throws GameException {
|
||||
protected MinecraftVersion resolve(IMinecraftProvider provider, Set<String> resolvedSoFar) throws GameException {
|
||||
if (inheritsFrom == null)
|
||||
return this;
|
||||
if (!resolvedSoFar.add(id))
|
||||
throw new GameException(C.i18n("launch.circular_dependency_versions"));
|
||||
|
||||
MinecraftVersion parent = manager.getVersionById(inheritsFrom);
|
||||
MinecraftVersion parent = provider.getVersionById(inheritsFrom);
|
||||
if (parent == null) {
|
||||
if (!manager.getDownloadService().install(inheritsFrom))
|
||||
if (!provider.install(inheritsFrom))
|
||||
return this;
|
||||
parent = manager.getVersionById(inheritsFrom);
|
||||
parent = provider.getVersionById(inheritsFrom);
|
||||
}
|
||||
parent = parent.resolve(manager, resolvedSoFar);
|
||||
parent = parent.resolve(provider, resolvedSoFar);
|
||||
MinecraftVersion result = new MinecraftVersion(
|
||||
this.minecraftArguments != null ? this.minecraftArguments : parent.minecraftArguments,
|
||||
this.mainClass != null ? this.mainClass : parent.mainClass,
|
||||
|
@ -28,16 +28,13 @@ import org.jackhuang.hellominecraft.C;
|
||||
import org.jackhuang.hellominecraft.HMCLog;
|
||||
import org.jackhuang.hellominecraft.launcher.launch.GameException;
|
||||
import org.jackhuang.hellominecraft.launcher.launch.GameLauncher;
|
||||
import org.jackhuang.hellominecraft.launcher.launch.IMinecraftAssetService;
|
||||
import org.jackhuang.hellominecraft.launcher.launch.IMinecraftDownloadService;
|
||||
import org.jackhuang.hellominecraft.launcher.launch.IMinecraftLoader;
|
||||
import org.jackhuang.hellominecraft.launcher.launch.IMinecraftModService;
|
||||
import org.jackhuang.hellominecraft.launcher.launch.IMinecraftProvider;
|
||||
import org.jackhuang.hellominecraft.launcher.launch.IMinecraftService;
|
||||
import org.jackhuang.hellominecraft.launcher.launch.MinecraftLoader;
|
||||
import org.jackhuang.hellominecraft.utils.system.FileUtils;
|
||||
import org.jackhuang.hellominecraft.launcher.utils.MCUtils;
|
||||
import org.jackhuang.hellominecraft.launcher.utils.auth.UserProfileProvider;
|
||||
import org.jackhuang.hellominecraft.launcher.settings.Profile;
|
||||
import org.jackhuang.hellominecraft.tasks.DecompressTask;
|
||||
import org.jackhuang.hellominecraft.tasks.TaskWindow;
|
||||
import org.jackhuang.hellominecraft.tasks.download.FileDownloadTask;
|
||||
@ -58,11 +55,8 @@ public class MinecraftVersionManager extends IMinecraftProvider {
|
||||
*
|
||||
* @param p
|
||||
*/
|
||||
public MinecraftVersionManager(Profile p) {
|
||||
public MinecraftVersionManager(IMinecraftService p) {
|
||||
super(p);
|
||||
mms = new MinecraftModService(p, this);
|
||||
mds = new MinecraftDownloadService(p, this);
|
||||
mas = new MinecraftAssetService(p, this);
|
||||
}
|
||||
|
||||
public File getFolder() {
|
||||
@ -81,7 +75,7 @@ public class MinecraftVersionManager extends IMinecraftProvider {
|
||||
|
||||
@Override
|
||||
public void refreshVersions() {
|
||||
baseFolder = profile.getCanonicalGameDirFile();
|
||||
baseFolder = service.profile.getCanonicalGameDirFile();
|
||||
try {
|
||||
MCUtils.tryWriteProfile(baseFolder);
|
||||
} catch (IOException ex) {
|
||||
@ -131,7 +125,7 @@ public class MinecraftVersionManager extends IMinecraftProvider {
|
||||
} catch (IOException | GameException e) {
|
||||
HMCLog.warn("Found wrong format json, try to fix it.", e);
|
||||
if (MessageBox.Show(C.i18n("launcher.versions_json_not_formatted", id), MessageBox.YES_NO_OPTION) == MessageBox.YES_OPTION) {
|
||||
refreshJson(id);
|
||||
service.download().downloadMinecraftVersionJson(id);
|
||||
try {
|
||||
mcVersion = C.gson.fromJson(FileUtils.readFileToString(jsonFile), MinecraftVersion.class);
|
||||
if (mcVersion == null)
|
||||
@ -194,7 +188,7 @@ public class MinecraftVersionManager extends IMinecraftProvider {
|
||||
|
||||
@Override
|
||||
public File getRunDirectory(String id) {
|
||||
switch (profile.getGameDirType()) {
|
||||
switch (gameDirType) {
|
||||
case VERSION_FOLDER:
|
||||
return new File(baseFolder, "versions/" + id + "/");
|
||||
default:
|
||||
@ -202,6 +196,16 @@ public class MinecraftVersionManager extends IMinecraftProvider {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean install(String id) {
|
||||
MinecraftVersion v = service.download().downloadMinecraft(id);
|
||||
if (v != null) {
|
||||
refreshVersions();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open(String mv, String name) {
|
||||
SwingUtils.openFolder((name == null) ? getRunDirectory(mv) : new File(getRunDirectory(mv), name));
|
||||
@ -225,7 +229,7 @@ public class MinecraftVersionManager extends IMinecraftProvider {
|
||||
|
||||
@Override
|
||||
public File getDecompressNativesToLocation(MinecraftVersion v) {
|
||||
return v == null ? null : v.getNatives(profile.getCanonicalGameDirFile());
|
||||
return v == null ? null : v.getNatives(baseFolder);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -236,7 +240,7 @@ public class MinecraftVersionManager extends IMinecraftProvider {
|
||||
@Override
|
||||
public IMinecraftLoader provideMinecraftLoader(UserProfileProvider p)
|
||||
throws GameException {
|
||||
return new MinecraftLoader(profile, this, p);
|
||||
return new MinecraftLoader(service, p);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -251,7 +255,7 @@ public class MinecraftVersionManager extends IMinecraftProvider {
|
||||
|
||||
@Override
|
||||
public File getResourcePacks() {
|
||||
return new File(profile.getCanonicalGameDirFile(), "resourcepacks");
|
||||
return new File(baseFolder, "resourcepacks");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -270,7 +274,7 @@ public class MinecraftVersionManager extends IMinecraftProvider {
|
||||
@Override
|
||||
public void cleanFolder() {
|
||||
for (MinecraftVersion s : getVersions()) {
|
||||
FileUtils.deleteDirectoryQuietly(new File(profile.getGameDirFile(), "versions" + File.separator + s.id + File.separator + s.id + "-natives"));
|
||||
FileUtils.deleteDirectoryQuietly(new File(baseFolder, "versions" + File.separator + s.id + File.separator + s.id + "-natives"));
|
||||
File f = getRunDirectory(s.id);
|
||||
String[] dir = { "logs", "asm", "NVIDIA", "crash-reports", "server-resource-packs", "natives", "native" };
|
||||
for (String str : dir)
|
||||
@ -281,27 +285,6 @@ public class MinecraftVersionManager extends IMinecraftProvider {
|
||||
}
|
||||
}
|
||||
|
||||
final MinecraftModService mms;
|
||||
|
||||
@Override
|
||||
public IMinecraftModService getModService() {
|
||||
return mms;
|
||||
}
|
||||
|
||||
final MinecraftDownloadService mds;
|
||||
|
||||
@Override
|
||||
public IMinecraftDownloadService getDownloadService() {
|
||||
return mds;
|
||||
}
|
||||
|
||||
final MinecraftAssetService mas;
|
||||
|
||||
@Override
|
||||
public IMinecraftAssetService getAssetService() {
|
||||
return mas;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initializeMiencraft() {
|
||||
|
||||
|
@ -107,7 +107,7 @@ public class GameDownloadPanel extends AnimatedPanel implements Selectable {
|
||||
|
||||
public void refreshDownloads() {
|
||||
DefaultTableModel model = SwingUtils.clearDefaultTable(lstDownloads);
|
||||
gsp.getProfile().getMinecraftProvider().getDownloadService().getRemoteVersions()
|
||||
gsp.getProfile().service().download().getRemoteVersions()
|
||||
.observeOn(Schedulers.eventQueue()).subscribeOn(Schedulers.newThread())
|
||||
.subscribe((ver) -> model.addRow(new Object[] { ver.id, ver.time,
|
||||
StrUtils.equalsOne(ver.type, "old_beta", "old_alpha", "release", "snapshot") ? C.i18n("versions." + ver.type) : ver.type }),
|
||||
@ -123,7 +123,7 @@ public class GameDownloadPanel extends AnimatedPanel implements Selectable {
|
||||
return;
|
||||
}
|
||||
String id = (String) lstDownloads.getModel().getValueAt(lstDownloads.getSelectedRow(), 0);
|
||||
gsp.getProfile().getMinecraftProvider().getDownloadService().downloadMinecraft(id);
|
||||
gsp.getProfile().service().download().downloadMinecraft(id);
|
||||
}
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
|
@ -109,7 +109,7 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
getProfile().getMinecraftProvider().open(mcVersion, a);
|
||||
getProfile().service().version().open(mcVersion, a);
|
||||
}
|
||||
}
|
||||
JMenuItem itm;
|
||||
@ -140,7 +140,7 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
|
||||
if (mcVersion != null) {
|
||||
String newName = JOptionPane.showInputDialog(C.i18n("versions.manage.rename.message"), mcVersion);
|
||||
if (newName != null)
|
||||
if (getProfile().getMinecraftProvider().renameVersion(mcVersion, newName))
|
||||
if (getProfile().service().version().renameVersion(mcVersion, newName))
|
||||
refreshVersions();
|
||||
}
|
||||
});
|
||||
@ -148,20 +148,20 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
|
||||
itm = new JMenuItem(C.i18n("versions.manage.remove"));
|
||||
itm.addActionListener((e) -> {
|
||||
if (mcVersion != null && MessageBox.Show(C.i18n("versions.manage.remove.confirm") + mcVersion, MessageBox.YES_NO_OPTION) == MessageBox.YES_OPTION)
|
||||
if (getProfile().getMinecraftProvider().removeVersionFromDisk(mcVersion))
|
||||
if (getProfile().service().version().removeVersionFromDisk(mcVersion))
|
||||
refreshVersions();
|
||||
});
|
||||
ppmManage.add(itm);
|
||||
itm = new JMenuItem(C.i18n("versions.manage.redownload_json"));
|
||||
itm.addActionListener((e) -> {
|
||||
if (mcVersion != null)
|
||||
getProfile().getMinecraftProvider().refreshJson(mcVersion);
|
||||
getProfile().service().download().downloadMinecraftVersionJson(mcVersion);
|
||||
});
|
||||
ppmManage.add(itm);
|
||||
itm = new JMenuItem(C.i18n("versions.manage.redownload_assets_index"));
|
||||
itm.addActionListener((e) -> {
|
||||
if (mcVersion != null)
|
||||
getProfile().getMinecraftProvider().getAssetService().refreshAssetsIndex(mcVersion);
|
||||
getProfile().service().asset().refreshAssetsIndex(mcVersion);
|
||||
});
|
||||
ppmManage.add(itm);
|
||||
}
|
||||
@ -174,7 +174,7 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
|
||||
}
|
||||
lstExternalMods.getSelectionModel().addListSelectionListener(e -> {
|
||||
int row = lstExternalMods.getSelectedRow();
|
||||
List<ModInfo> mods = getProfile().getMinecraftProvider().getModService().getMods();
|
||||
List<ModInfo> mods = getProfile().service().mod().getMods();
|
||||
if (mods != null && 0 <= row && row < mods.size()) {
|
||||
ModInfo m = mods.get(row);
|
||||
boolean hasLink = m.url != null;
|
||||
@ -194,7 +194,7 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
|
||||
((DefaultTableModel) lstExternalMods.getModel()).addTableModelListener(e -> {
|
||||
if (e.getType() == TableModelEvent.UPDATE && e.getColumn() == 0) {
|
||||
int row = lstExternalMods.getSelectedRow();
|
||||
List<ModInfo> mods = getProfile().getMinecraftProvider().getModService().getMods();
|
||||
List<ModInfo> mods = getProfile().service().mod().getMods();
|
||||
if (mods != null && mods.size() > row && row >= 0)
|
||||
mods.get(row).reverseModState();
|
||||
}
|
||||
@ -885,7 +885,7 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
|
||||
// <editor-fold defaultstate="collapsed" desc="UI Events">
|
||||
private void cboProfilesItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cboProfilesItemStateChanged
|
||||
if (!isLoading) {
|
||||
if (getProfile().getMinecraftProvider().getVersionCount() <= 0)
|
||||
if (getProfile().service().version().getVersionCount() <= 0)
|
||||
versionChanged(null);
|
||||
prepare(getProfile());
|
||||
}
|
||||
@ -989,7 +989,7 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
|
||||
|
||||
private void btnDownloadAllAssetsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDownloadAllAssetsActionPerformed
|
||||
if (mcVersion != null)
|
||||
getProfile().getMinecraftProvider().getAssetService().downloadAssets(mcVersion).run();
|
||||
getProfile().service().asset().downloadAssets(mcVersion).run();
|
||||
}//GEN-LAST:event_btnDownloadAllAssetsActionPerformed
|
||||
|
||||
private void txtMaxMemoryFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtMaxMemoryFocusLost
|
||||
@ -1061,14 +1061,14 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
|
||||
return;
|
||||
boolean flag = true;
|
||||
for (File f : fc.getSelectedFiles())
|
||||
flag &= getProfile().getMinecraftProvider().getModService().addMod(f);
|
||||
flag &= getProfile().service().mod().addMod(f);
|
||||
reloadMods();
|
||||
if (!flag)
|
||||
MessageBox.Show(C.I18N.getString("mods.failed"));
|
||||
}//GEN-LAST:event_btnAddModActionPerformed
|
||||
|
||||
private void btnRemoveModActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRemoveModActionPerformed
|
||||
getProfile().getMinecraftProvider().getModService().removeMod(SwingUtils.getValueBySelectedRow(lstExternalMods, lstExternalMods.getSelectedRows(), 1));
|
||||
getProfile().service().mod().removeMod(SwingUtils.getValueBySelectedRow(lstExternalMods, lstExternalMods.getSelectedRows(), 1));
|
||||
reloadMods();
|
||||
}//GEN-LAST:event_btnRemoveModActionPerformed
|
||||
|
||||
@ -1079,8 +1079,8 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
|
||||
|
||||
private void lblModInfoMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblModInfoMouseClicked
|
||||
int idx = lstExternalMods.getSelectedRow();
|
||||
if (idx > 0 && idx < getProfile().getMinecraftProvider().getModService().getMods().size())
|
||||
getProfile().getMinecraftProvider().getModService().getMods().get(idx).showURL();
|
||||
if (idx > 0 && idx < getProfile().service().mod().getMods().size())
|
||||
getProfile().service().mod().getMods().get(idx).showURL();
|
||||
}//GEN-LAST:event_lblModInfoMouseClicked
|
||||
|
||||
private void btnChoosingGameDirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnChoosingGameDirActionPerformed
|
||||
@ -1102,7 +1102,7 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
|
||||
}//GEN-LAST:event_btnChoosingGameDirActionPerformed
|
||||
|
||||
private void btnCleanGameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCleanGameActionPerformed
|
||||
getProfile().getMinecraftProvider().cleanFolder();
|
||||
getProfile().service().version().cleanFolder();
|
||||
}//GEN-LAST:event_btnCleanGameActionPerformed
|
||||
|
||||
// </editor-fold>
|
||||
@ -1165,9 +1165,9 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
|
||||
isLoading = true;
|
||||
cboVersions.removeAllItems();
|
||||
int index = 0, i = 0;
|
||||
MinecraftVersion selVersion = getProfile().getMinecraftProvider().getSelectedVersion();
|
||||
MinecraftVersion selVersion = getProfile().service().version().getSelectedVersion();
|
||||
String selectedMC = selVersion == null ? null : selVersion.id;
|
||||
for (MinecraftVersion each : getProfile().getMinecraftProvider().getVersions()) {
|
||||
for (MinecraftVersion each : getProfile().service().version().getVersions()) {
|
||||
cboVersions.addItem(each.id);
|
||||
if (StrUtils.isEquals(each.id, selectedMC))
|
||||
index = i;
|
||||
@ -1181,7 +1181,7 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
|
||||
}
|
||||
|
||||
void loadMinecraftVersion() {
|
||||
loadMinecraftVersion(getProfile().getMinecraftProvider().getSelectedVersion());
|
||||
loadMinecraftVersion(getProfile().service().version().getSelectedVersion());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1210,7 +1210,7 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
|
||||
Transferable tr = dtde.getTransferable();
|
||||
List<File> files = (List<File>) tr.getTransferData(DataFlavor.javaFileListFlavor);
|
||||
for (File file : files)
|
||||
getProfile().getMinecraftProvider().getModService().addMod(file);
|
||||
getProfile().service().mod().addMod(file);
|
||||
} catch (Exception ex) {
|
||||
HMCLog.warn("Failed to drop file.", ex);
|
||||
}
|
||||
@ -1233,7 +1233,7 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
|
||||
}
|
||||
|
||||
void refreshVersions() {
|
||||
getProfile().getMinecraftProvider().refreshVersions();
|
||||
getProfile().service().version().refreshVersions();
|
||||
loadVersions();
|
||||
}
|
||||
|
||||
@ -1247,7 +1247,7 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
|
||||
reloadingMods = true;
|
||||
DefaultTableModel model = SwingUtils.clearDefaultTable(lstExternalMods);
|
||||
Observable.<List<ModInfo>>createWithEmptySubscription(
|
||||
t -> t.onNext(getProfile().getMinecraftProvider().getModService().recacheMods()))
|
||||
t -> t.onNext(getProfile().service().mod().recacheMods()))
|
||||
.subscribeOn(Schedulers.newThread()).observeOn(Schedulers.eventQueue())
|
||||
.subscribe(t -> {
|
||||
for (ModInfo x : t)
|
||||
@ -1266,7 +1266,7 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
|
||||
@Override
|
||||
public void onSelected() {
|
||||
loadProfiles();
|
||||
if (getProfile().getMinecraftProvider().getVersionCount() <= 0)
|
||||
if (getProfile().service().version().getVersionCount() <= 0)
|
||||
versionChanged(null);
|
||||
else
|
||||
versionChanged((String) cboVersions.getSelectedItem());
|
||||
|
@ -139,7 +139,7 @@ public class InstallerPanel extends AnimatedPanel implements Selectable {
|
||||
MessageBox.Show(C.i18n("install.not_refreshed"));
|
||||
return;
|
||||
}
|
||||
gsp.getProfile().getInstallerService().download(getVersion(idx), id).after(new TaskRunnable(this::refreshVersions)).run();
|
||||
gsp.getProfile().service().install().download(getVersion(idx), id).after(new TaskRunnable(this::refreshVersions)).run();
|
||||
}
|
||||
|
||||
public void loadVersions() {
|
||||
|
@ -30,6 +30,7 @@ import javax.swing.SwingUtilities;
|
||||
import org.jackhuang.hellominecraft.C;
|
||||
import org.jackhuang.hellominecraft.HMCLog;
|
||||
import org.jackhuang.hellominecraft.launcher.launch.DefaultGameLauncher;
|
||||
import org.jackhuang.hellominecraft.launcher.launch.GameException;
|
||||
import org.jackhuang.hellominecraft.launcher.utils.auth.IAuthenticator;
|
||||
import org.jackhuang.hellominecraft.launcher.utils.auth.LoginInfo;
|
||||
import org.jackhuang.hellominecraft.launcher.settings.Profile;
|
||||
@ -39,6 +40,7 @@ import org.jackhuang.hellominecraft.launcher.version.MinecraftVersion;
|
||||
import org.jackhuang.hellominecraft.launcher.launch.GameLauncher;
|
||||
import org.jackhuang.hellominecraft.launcher.settings.LauncherVisibility;
|
||||
import org.jackhuang.hellominecraft.launcher.settings.Settings;
|
||||
import org.jackhuang.hellominecraft.launcher.utils.auth.AuthenticationException;
|
||||
import org.jackhuang.hellominecraft.lookandfeel.GraphicsUtils;
|
||||
import org.jackhuang.hellominecraft.utils.Event;
|
||||
import org.jackhuang.hellominecraft.lookandfeel.components.ConstomButton;
|
||||
@ -388,7 +390,7 @@ public class MainPagePanel extends AnimatedPanel implements Event<String> {
|
||||
return;
|
||||
}
|
||||
final String name = (String) cboProfiles.getSelectedItem();
|
||||
if (StrUtils.isBlank(name) || getCurrentProfile().getMinecraftProvider().getSelectedVersion() == null) {
|
||||
if (StrUtils.isBlank(name) || getCurrentProfile().service().version().getSelectedVersion() == null) {
|
||||
HMCLog.warn("There's no selected version, rechoose a version.");
|
||||
MessageBox.ShowLocalized("minecraft.no_selected_version");
|
||||
return;
|
||||
@ -407,19 +409,18 @@ public class MainPagePanel extends AnimatedPanel implements Event<String> {
|
||||
public void run() {
|
||||
Thread.currentThread().setName("Game Launcher");
|
||||
DefaultGameLauncher gl = new DefaultGameLauncher(getCurrentProfile(), li, l);
|
||||
gl.failEvent.register((sender, s) -> {
|
||||
if (s != null)
|
||||
MessageBox.Show(s);
|
||||
MainFrame.INSTANCE.closeMessage();
|
||||
isLaunching = false;
|
||||
return true;
|
||||
});
|
||||
gl.successEvent.register((sender, s) -> {
|
||||
isLaunching = false;
|
||||
return true;
|
||||
});
|
||||
listener.accept(gl);
|
||||
gl.makeLaunchCommand();
|
||||
try {
|
||||
gl.makeLaunchCommand();
|
||||
} catch (GameException e) {
|
||||
failed(C.i18n("launch.failed") + ", " + e.getMessage());
|
||||
} catch (AuthenticationException e) {
|
||||
failed(C.i18n("login.failed") + e.getMessage());
|
||||
}
|
||||
}
|
||||
}.start();
|
||||
}
|
||||
@ -477,10 +478,10 @@ public class MainPagePanel extends AnimatedPanel implements Event<String> {
|
||||
cboVersions.removeAllItems();
|
||||
int index = 0, i = 0;
|
||||
getCurrentProfile().selectedVersionChangedEvent.register(this);
|
||||
getCurrentProfile().getMinecraftProvider().refreshVersions();
|
||||
MinecraftVersion selVersion = getCurrentProfile().getMinecraftProvider().getSelectedVersion();
|
||||
getCurrentProfile().service().version().refreshVersions();
|
||||
MinecraftVersion selVersion = getCurrentProfile().service().version().getSelectedVersion();
|
||||
String selectedMC = selVersion == null ? null : selVersion.id;
|
||||
if (getCurrentProfile().getMinecraftProvider().getVersions().isEmpty()) {
|
||||
if (getCurrentProfile().service().version().getVersions().isEmpty()) {
|
||||
if (!showedNoVersion)
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
if (MessageBox.Show(C.i18n("mainwindow.no_version"), MessageBox.YES_NO_OPTION) == MessageBox.YES_OPTION) {
|
||||
@ -490,7 +491,7 @@ public class MainPagePanel extends AnimatedPanel implements Event<String> {
|
||||
showedNoVersion = true;
|
||||
});
|
||||
} else {
|
||||
for (MinecraftVersion mcVersion : getCurrentProfile().getMinecraftProvider().getVersions()) {
|
||||
for (MinecraftVersion mcVersion : getCurrentProfile().service().version().getVersions()) {
|
||||
if (mcVersion.hidden)
|
||||
continue;
|
||||
cboVersions.addItem(mcVersion.id);
|
||||
@ -553,6 +554,13 @@ public class MainPagePanel extends AnimatedPanel implements Event<String> {
|
||||
});
|
||||
}
|
||||
|
||||
private void failed(String s) {
|
||||
if (s != null)
|
||||
MessageBox.Show(s);
|
||||
MainFrame.INSTANCE.closeMessage();
|
||||
isLaunching = false;
|
||||
}
|
||||
|
||||
public class LaunchFinisher implements Event<List<String>> {
|
||||
|
||||
@Override
|
||||
@ -590,7 +598,12 @@ public class MainPagePanel extends AnimatedPanel implements Event<String> {
|
||||
jpm.start();
|
||||
return true;
|
||||
});
|
||||
obj.launch(str);
|
||||
try {
|
||||
obj.launch(str);
|
||||
} catch (IOException e) {
|
||||
failed(C.i18n("launch.failed_creating_process") + "\n" + e.getMessage());
|
||||
HMCLog.err("Failed to launch when creating a new process.", e);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ public final class JdkVersion {
|
||||
if (StrUtils.isBlank(javaVersion))
|
||||
return UNKOWN;
|
||||
int a = UNKOWN;
|
||||
if (javaVersion.contains("1.9."))
|
||||
if (javaVersion.contains("1.9.") || javaVersion.startsWith("9"))
|
||||
a = JAVA_19;
|
||||
else if (javaVersion.contains("1.8."))
|
||||
a = JAVA_18;
|
||||
|
@ -18,9 +18,9 @@
|
||||
package org.jackhuang.hellominecraft.launcher.servers;
|
||||
|
||||
import org.jackhuang.hellominecraft.launcher.api.IPlugin;
|
||||
import org.jackhuang.hellominecraft.launcher.launch.IMinecraftProvider;
|
||||
import org.jackhuang.hellominecraft.launcher.servers.mfcraft.CheckModsMinecraftProvider;
|
||||
import org.jackhuang.hellominecraft.launcher.launch.IMinecraftService;
|
||||
import org.jackhuang.hellominecraft.launcher.servers.mfcraft.MFCraftAuthenticator;
|
||||
import org.jackhuang.hellominecraft.launcher.servers.mfcraft.MFCraftMinecraftService;
|
||||
import org.jackhuang.hellominecraft.launcher.servers.mfcraft.Servers;
|
||||
import org.jackhuang.hellominecraft.launcher.settings.Profile;
|
||||
import org.jackhuang.hellominecraft.launcher.settings.Settings;
|
||||
@ -44,8 +44,8 @@ public class ServerPlugin implements IPlugin {
|
||||
protected static MFCraftAuthenticator MFCRAFT_LOGIN;
|
||||
|
||||
@Override
|
||||
public IMinecraftProvider provideMinecraftProvider(Profile profile) {
|
||||
return new CheckModsMinecraftProvider(profile);
|
||||
public IMinecraftService provideMinecraftService(Profile profile) {
|
||||
return new MFCraftMinecraftService(profile);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -19,6 +19,7 @@ package org.jackhuang.hellominecraft.launcher.servers.mfcraft;
|
||||
|
||||
import java.io.IOException;
|
||||
import org.jackhuang.hellominecraft.HMCLog;
|
||||
import org.jackhuang.hellominecraft.launcher.launch.IMinecraftService;
|
||||
import org.jackhuang.hellominecraft.launcher.servers.ServerPlugin;
|
||||
import org.jackhuang.hellominecraft.launcher.settings.Profile;
|
||||
import org.jackhuang.hellominecraft.launcher.version.MinecraftModService;
|
||||
@ -31,7 +32,7 @@ import org.jackhuang.hellominecraft.utils.ArrayUtils;
|
||||
*/
|
||||
public class CheckModsMinecraftProvider extends MinecraftVersionManager {
|
||||
|
||||
public CheckModsMinecraftProvider(Profile p) {
|
||||
public CheckModsMinecraftProvider(IMinecraftService p) {
|
||||
super(p);
|
||||
}
|
||||
|
||||
@ -39,7 +40,7 @@ public class CheckModsMinecraftProvider extends MinecraftVersionManager {
|
||||
public boolean onLaunch() {
|
||||
try {
|
||||
super.onLaunch();
|
||||
String[] md5s = ((MinecraftModService) getModService()).checkMd5s();
|
||||
String[] md5s = ((MinecraftModService) service.mod()).checkMd5s();
|
||||
String[] md5 = ServerPlugin.lastServerInfo.md5;
|
||||
return ArrayUtils.equals(md5s, md5);
|
||||
} catch (IOException ex) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user