Fixed compile errors in HMCSM
This commit is contained in:
@@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.jackhuang.hellominecraft.launcher.core.download;
|
package org.jackhuang.hellominecraft.launcher.core.download;
|
||||||
|
|
||||||
import org.jackhuang.hellominecraft.api.HMCLAPI;
|
import org.jackhuang.hellominecraft.api.HMCAPI;
|
||||||
import org.jackhuang.hellominecraft.launcher.api.event.config.DownloadTypeChangedEvent;
|
import org.jackhuang.hellominecraft.launcher.api.event.config.DownloadTypeChangedEvent;
|
||||||
import org.jackhuang.hellominecraft.util.C;
|
import org.jackhuang.hellominecraft.util.C;
|
||||||
import org.jackhuang.hellominecraft.util.task.TaskWindow;
|
import org.jackhuang.hellominecraft.util.task.TaskWindow;
|
||||||
@@ -62,6 +62,6 @@ public enum DownloadType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static {
|
static {
|
||||||
HMCLAPI.EVENT_BUS.channel(DownloadTypeChangedEvent.class).register(t -> setSuggestedDownloadType(t.getValue()));
|
HMCAPI.EVENT_BUS.channel(DownloadTypeChangedEvent.class).register(t -> setSuggestedDownloadType(t.getValue()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ package org.jackhuang.hellominecraft.launcher.core.launch;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.jackhuang.hellominecraft.api.HMCLAPI;
|
import org.jackhuang.hellominecraft.api.HMCAPI;
|
||||||
import org.jackhuang.hellominecraft.api.ResultedSimpleEvent;
|
import org.jackhuang.hellominecraft.api.ResultedSimpleEvent;
|
||||||
import org.jackhuang.hellominecraft.launcher.api.event.launch.DecompressLibrariesEvent;
|
import org.jackhuang.hellominecraft.launcher.api.event.launch.DecompressLibrariesEvent;
|
||||||
import org.jackhuang.hellominecraft.launcher.api.event.launch.DownloadLibrariesEvent;
|
import org.jackhuang.hellominecraft.launcher.api.event.launch.DownloadLibrariesEvent;
|
||||||
@@ -44,7 +44,7 @@ public class DefaultGameLauncher extends GameLauncher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void register() {
|
private void register() {
|
||||||
HMCLAPI.EVENT_BUS.channel(DownloadLibrariesEvent.class).register(t -> {
|
HMCAPI.EVENT_BUS.channel(DownloadLibrariesEvent.class).register(t -> {
|
||||||
ResultedSimpleEvent<List<DownloadLibraryJob>> event = (ResultedSimpleEvent) t;
|
ResultedSimpleEvent<List<DownloadLibraryJob>> event = (ResultedSimpleEvent) t;
|
||||||
final TaskWindow.TaskWindowFactory dw = TaskWindow.factory();
|
final TaskWindow.TaskWindowFactory dw = TaskWindow.factory();
|
||||||
ParallelTask parallelTask = new ParallelTask();
|
ParallelTask parallelTask = new ParallelTask();
|
||||||
@@ -63,7 +63,7 @@ public class DefaultGameLauncher extends GameLauncher {
|
|||||||
flag = true;
|
flag = true;
|
||||||
t.setResult(flag);
|
t.setResult(flag);
|
||||||
});
|
});
|
||||||
HMCLAPI.EVENT_BUS.channel(DecompressLibrariesEvent.class).register(t -> {
|
HMCAPI.EVENT_BUS.channel(DecompressLibrariesEvent.class).register(t -> {
|
||||||
if (t.getValue() == null) {
|
if (t.getValue() == null) {
|
||||||
t.setResult(false);
|
t.setResult(false);
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import java.io.FileOutputStream;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStreamWriter;
|
import java.io.OutputStreamWriter;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.jackhuang.hellominecraft.api.HMCLAPI;
|
import org.jackhuang.hellominecraft.api.HMCAPI;
|
||||||
import org.jackhuang.hellominecraft.launcher.api.event.launch.DecompressLibrariesEvent;
|
import org.jackhuang.hellominecraft.launcher.api.event.launch.DecompressLibrariesEvent;
|
||||||
import org.jackhuang.hellominecraft.launcher.api.event.launch.DecompressLibraryJob;
|
import org.jackhuang.hellominecraft.launcher.api.event.launch.DecompressLibraryJob;
|
||||||
import org.jackhuang.hellominecraft.launcher.api.event.launch.DownloadLibrariesEvent;
|
import org.jackhuang.hellominecraft.launcher.api.event.launch.DownloadLibrariesEvent;
|
||||||
@@ -90,7 +90,7 @@ public class GameLauncher {
|
|||||||
public void makeLaunchCommand() throws AuthenticationException, GameException, RuntimeGameException {
|
public void makeLaunchCommand() throws AuthenticationException, GameException, RuntimeGameException {
|
||||||
HMCLog.log("Building process");
|
HMCLog.log("Building process");
|
||||||
HMCLog.log("Logging in...");
|
HMCLog.log("Logging in...");
|
||||||
HMCLAPI.EVENT_BUS.fireChannel(new LaunchingStateChangedEvent(this, LaunchingState.LoggingIn));
|
HMCAPI.EVENT_BUS.fireChannel(new LaunchingStateChangedEvent(this, LaunchingState.LoggingIn));
|
||||||
IMinecraftLoader loader;
|
IMinecraftLoader loader;
|
||||||
if (info != null)
|
if (info != null)
|
||||||
result = login.login(info);
|
result = login.login(info);
|
||||||
@@ -98,9 +98,9 @@ public class GameLauncher {
|
|||||||
result = login.loginBySettings();
|
result = login.loginBySettings();
|
||||||
if (result == null)
|
if (result == null)
|
||||||
throw new AuthenticationException("Result can not be null.");
|
throw new AuthenticationException("Result can not be null.");
|
||||||
HMCLAPI.EVENT_BUS.fireChannel(new ProcessingLoginResultEvent(this, result));
|
HMCAPI.EVENT_BUS.fireChannel(new ProcessingLoginResultEvent(this, result));
|
||||||
|
|
||||||
HMCLAPI.EVENT_BUS.fireChannel(new LaunchingStateChangedEvent(this, LaunchingState.GeneratingLaunchingCodes));
|
HMCAPI.EVENT_BUS.fireChannel(new LaunchingStateChangedEvent(this, LaunchingState.GeneratingLaunchingCodes));
|
||||||
loader = service.launch(options, result);
|
loader = service.launch(options, result);
|
||||||
|
|
||||||
File file = service.version().getDecompressNativesToLocation(loader.getMinecraftVersion());
|
File file = service.version().getDecompressNativesToLocation(loader.getMinecraftVersion());
|
||||||
@@ -109,18 +109,18 @@ public class GameLauncher {
|
|||||||
|
|
||||||
if (!options.isNotCheckGame()) {
|
if (!options.isNotCheckGame()) {
|
||||||
HMCLog.log("Detecting libraries...");
|
HMCLog.log("Detecting libraries...");
|
||||||
HMCLAPI.EVENT_BUS.fireChannel(new LaunchingStateChangedEvent(this, LaunchingState.DownloadingLibraries));
|
HMCAPI.EVENT_BUS.fireChannel(new LaunchingStateChangedEvent(this, LaunchingState.DownloadingLibraries));
|
||||||
if (!HMCLAPI.EVENT_BUS.fireChannelResulted(new DownloadLibrariesEvent(this, service.download().getDownloadLibraries(loader.getMinecraftVersion()))))
|
if (!HMCAPI.EVENT_BUS.fireChannelResulted(new DownloadLibrariesEvent(this, service.download().getDownloadLibraries(loader.getMinecraftVersion()))))
|
||||||
throw new GameException("Failed to download libraries");
|
throw new GameException("Failed to download libraries");
|
||||||
}
|
}
|
||||||
|
|
||||||
HMCLog.log("Unpacking natives...");
|
HMCLog.log("Unpacking natives...");
|
||||||
HMCLAPI.EVENT_BUS.fireChannel(new LaunchingStateChangedEvent(this, LaunchingState.DecompressingNatives));
|
HMCAPI.EVENT_BUS.fireChannel(new LaunchingStateChangedEvent(this, LaunchingState.DecompressingNatives));
|
||||||
DecompressLibraryJob job = service.version().getDecompressLibraries(loader.getMinecraftVersion());
|
DecompressLibraryJob job = service.version().getDecompressLibraries(loader.getMinecraftVersion());
|
||||||
if (!HMCLAPI.EVENT_BUS.fireChannelResulted(new DecompressLibrariesEvent(this, job)))
|
if (!HMCAPI.EVENT_BUS.fireChannelResulted(new DecompressLibrariesEvent(this, job)))
|
||||||
throw new GameException("Failed to decompress natives");
|
throw new GameException("Failed to decompress natives");
|
||||||
|
|
||||||
HMCLAPI.EVENT_BUS.fireChannel(new LaunchSucceededEvent(this, loader.makeLaunchingCommand()));
|
HMCAPI.EVENT_BUS.fireChannel(new LaunchSucceededEvent(this, loader.makeLaunchingCommand()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -150,7 +150,7 @@ public class GameLauncher {
|
|||||||
.environment().put("APPDATA", service.baseDirectory().getAbsolutePath());
|
.environment().put("APPDATA", service.baseDirectory().getAbsolutePath());
|
||||||
JavaProcess jp = new JavaProcess(str, builder.start(), PROCESS_MANAGER);
|
JavaProcess jp = new JavaProcess(str, builder.start(), PROCESS_MANAGER);
|
||||||
HMCLog.log("Have started the process");
|
HMCLog.log("Have started the process");
|
||||||
HMCLAPI.EVENT_BUS.fireChannel(new LaunchEvent(this, jp));
|
HMCAPI.EVENT_BUS.fireChannel(new LaunchEvent(this, jp));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import com.google.gson.annotations.SerializedName;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import org.jackhuang.hellominecraft.api.HMCLAPI;
|
import org.jackhuang.hellominecraft.api.HMCAPI;
|
||||||
import org.jackhuang.hellominecraft.launcher.api.event.version.MinecraftLibraryPathEvent;
|
import org.jackhuang.hellominecraft.launcher.api.event.version.MinecraftLibraryPathEvent;
|
||||||
import org.jackhuang.hellominecraft.util.sys.OS;
|
import org.jackhuang.hellominecraft.util.sys.OS;
|
||||||
import org.jackhuang.hellominecraft.util.sys.Platform;
|
import org.jackhuang.hellominecraft.util.sys.Platform;
|
||||||
@@ -108,7 +108,7 @@ public class MinecraftLibrary extends IMinecraftLibrary {
|
|||||||
if (info == null)
|
if (info == null)
|
||||||
return null;
|
return null;
|
||||||
MinecraftLibraryPathEvent event = new MinecraftLibraryPathEvent(this, "libraries/" + info.path, new Wrapper<>(new File(gameDir, "libraries/" + info.path)));
|
MinecraftLibraryPathEvent event = new MinecraftLibraryPathEvent(this, "libraries/" + info.path, new Wrapper<>(new File(gameDir, "libraries/" + info.path)));
|
||||||
HMCLAPI.EVENT_BUS.fireChannel(event);
|
HMCAPI.EVENT_BUS.fireChannel(event);
|
||||||
return event.getFile().getValue();
|
return event.getFile().getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ 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.api.HMCLAPI;
|
import org.jackhuang.hellominecraft.api.HMCAPI;
|
||||||
import org.jackhuang.hellominecraft.launcher.api.event.version.LoadedOneVersionEvent;
|
import org.jackhuang.hellominecraft.launcher.api.event.version.LoadedOneVersionEvent;
|
||||||
import org.jackhuang.hellominecraft.launcher.api.event.version.RefreshedVersionsEvent;
|
import org.jackhuang.hellominecraft.launcher.api.event.version.RefreshedVersionsEvent;
|
||||||
import org.jackhuang.hellominecraft.launcher.api.event.version.RefreshingVersionsEvent;
|
import org.jackhuang.hellominecraft.launcher.api.event.version.RefreshingVersionsEvent;
|
||||||
@@ -72,7 +72,7 @@ public class MinecraftVersionManager extends IMinecraftProvider {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void refreshVersions() {
|
public synchronized void refreshVersions() {
|
||||||
HMCLAPI.EVENT_BUS.fireChannel(new RefreshingVersionsEvent(this, service));
|
HMCAPI.EVENT_BUS.fireChannel(new RefreshingVersionsEvent(this, service));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
MCUtils.tryWriteProfile(service.baseDirectory());
|
MCUtils.tryWriteProfile(service.baseDirectory());
|
||||||
@@ -142,12 +142,12 @@ public class MinecraftVersionManager extends IMinecraftProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
versions.put(id, mcVersion);
|
versions.put(id, mcVersion);
|
||||||
HMCLAPI.EVENT_BUS.fireChannel(new LoadedOneVersionEvent(this, id));
|
HMCAPI.EVENT_BUS.fireChannel(new LoadedOneVersionEvent(this, id));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
HMCLog.warn("Ignoring: " + dir + ", the json of this Minecraft is malformed.", e);
|
HMCLog.warn("Ignoring: " + dir + ", the json of this Minecraft is malformed.", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
HMCLAPI.EVENT_BUS.fireChannel(new RefreshedVersionsEvent(this, service));
|
HMCAPI.EVENT_BUS.fireChannel(new RefreshedVersionsEvent(this, service));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ import java.util.TreeMap;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import org.jackhuang.hellominecraft.launcher.core.auth.IAuthenticator;
|
import org.jackhuang.hellominecraft.launcher.core.auth.IAuthenticator;
|
||||||
import org.jackhuang.hellominecraft.lookandfeel.Theme;
|
import org.jackhuang.hellominecraft.lookandfeel.Theme;
|
||||||
import org.jackhuang.hellominecraft.api.HMCLAPI;
|
import org.jackhuang.hellominecraft.api.HMCAPI;
|
||||||
import org.jackhuang.hellominecraft.launcher.api.event.config.AuthenticatorChangedEvent;
|
import org.jackhuang.hellominecraft.launcher.api.event.config.AuthenticatorChangedEvent;
|
||||||
import org.jackhuang.hellominecraft.launcher.api.event.config.DownloadTypeChangedEvent;
|
import org.jackhuang.hellominecraft.launcher.api.event.config.DownloadTypeChangedEvent;
|
||||||
import org.jackhuang.hellominecraft.launcher.api.event.config.ThemeChangedEvent;
|
import org.jackhuang.hellominecraft.launcher.api.event.config.ThemeChangedEvent;
|
||||||
@@ -92,7 +92,7 @@ public final class Config implements Cloneable {
|
|||||||
|
|
||||||
public void setTheme(int theme) {
|
public void setTheme(int theme) {
|
||||||
this.theme = theme;
|
this.theme = theme;
|
||||||
HMCLAPI.EVENT_BUS.fireChannel(new ThemeChangedEvent(this, getTheme()));
|
HMCAPI.EVENT_BUS.fireChannel(new ThemeChangedEvent(this, getTheme()));
|
||||||
Settings.save();
|
Settings.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -182,7 +182,7 @@ public final class Config implements Cloneable {
|
|||||||
if (logintype < 0 || logintype >= IAuthenticator.LOGINS.size())
|
if (logintype < 0 || logintype >= IAuthenticator.LOGINS.size())
|
||||||
return;
|
return;
|
||||||
this.logintype = logintype;
|
this.logintype = logintype;
|
||||||
HMCLAPI.EVENT_BUS.fireChannel(new AuthenticatorChangedEvent(this, IAuthenticator.LOGINS.get(logintype)));
|
HMCAPI.EVENT_BUS.fireChannel(new AuthenticatorChangedEvent(this, IAuthenticator.LOGINS.get(logintype)));
|
||||||
Settings.save();
|
Settings.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -192,7 +192,7 @@ public final class Config implements Cloneable {
|
|||||||
|
|
||||||
public void setDownloadType(int downloadtype) {
|
public void setDownloadType(int downloadtype) {
|
||||||
this.downloadtype = downloadtype;
|
this.downloadtype = downloadtype;
|
||||||
HMCLAPI.EVENT_BUS.fireChannel(new DownloadTypeChangedEvent(this, getDownloadSource()));
|
HMCAPI.EVENT_BUS.fireChannel(new DownloadTypeChangedEvent(this, getDownloadSource()));
|
||||||
Settings.save();
|
Settings.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ import org.jackhuang.hellominecraft.launcher.Main;
|
|||||||
import org.jackhuang.hellominecraft.launcher.core.MCUtils;
|
import org.jackhuang.hellominecraft.launcher.core.MCUtils;
|
||||||
import org.jackhuang.hellominecraft.launcher.core.download.DownloadType;
|
import org.jackhuang.hellominecraft.launcher.core.download.DownloadType;
|
||||||
import org.jackhuang.hellominecraft.util.CollectionUtils;
|
import org.jackhuang.hellominecraft.util.CollectionUtils;
|
||||||
import org.jackhuang.hellominecraft.api.HMCLAPI;
|
import org.jackhuang.hellominecraft.api.HMCAPI;
|
||||||
import org.jackhuang.hellominecraft.launcher.api.event.config.ProfileChangedEvent;
|
import org.jackhuang.hellominecraft.launcher.api.event.config.ProfileChangedEvent;
|
||||||
import org.jackhuang.hellominecraft.launcher.api.event.config.ProfileLoadingEvent;
|
import org.jackhuang.hellominecraft.launcher.api.event.config.ProfileLoadingEvent;
|
||||||
import org.jackhuang.hellominecraft.util.sys.FileUtils;
|
import org.jackhuang.hellominecraft.util.sys.FileUtils;
|
||||||
@@ -161,12 +161,12 @@ public final class Settings {
|
|||||||
Profile p = getLastProfile();
|
Profile p = getLastProfile();
|
||||||
if (p == null)
|
if (p == null)
|
||||||
throw new Error("No profiles here, it should not happen");
|
throw new Error("No profiles here, it should not happen");
|
||||||
HMCLAPI.EVENT_BUS.fireChannel(new ProfileChangedEvent(SETTINGS, p.getName()));
|
HMCAPI.EVENT_BUS.fireChannel(new ProfileChangedEvent(SETTINGS, p.getName()));
|
||||||
p.onSelected();
|
p.onSelected();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void onProfileLoading() {
|
public static void onProfileLoading() {
|
||||||
HMCLAPI.EVENT_BUS.fireChannel(new ProfileLoadingEvent(SETTINGS));
|
HMCAPI.EVENT_BUS.fireChannel(new ProfileLoadingEvent(SETTINGS));
|
||||||
onProfileChanged();
|
onProfileChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ 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.table.DefaultTableModel;
|
import javax.swing.table.DefaultTableModel;
|
||||||
import org.jackhuang.hellominecraft.api.HMCLAPI;
|
import org.jackhuang.hellominecraft.api.HMCAPI;
|
||||||
import org.jackhuang.hellominecraft.launcher.api.event.config.ProfileChangedEvent;
|
import org.jackhuang.hellominecraft.launcher.api.event.config.ProfileChangedEvent;
|
||||||
import org.jackhuang.hellominecraft.launcher.api.event.config.ProfileLoadingEvent;
|
import org.jackhuang.hellominecraft.launcher.api.event.config.ProfileLoadingEvent;
|
||||||
import org.jackhuang.hellominecraft.launcher.api.event.version.RefreshedVersionsEvent;
|
import org.jackhuang.hellominecraft.launcher.api.event.version.RefreshedVersionsEvent;
|
||||||
@@ -86,7 +86,7 @@ public final class GameSettingsPanel extends RepaintPage implements DropTargetLi
|
|||||||
final InstallerPanel installerPanels[] = new InstallerPanel[InstallerType.values().length];
|
final InstallerPanel installerPanels[] = new InstallerPanel[InstallerType.values().length];
|
||||||
|
|
||||||
public GameSettingsPanel() {
|
public GameSettingsPanel() {
|
||||||
HMCLAPI.EVENT_BUS.channel(RefreshedVersionsEvent.class).register(t -> {
|
HMCAPI.EVENT_BUS.channel(RefreshedVersionsEvent.class).register(t -> {
|
||||||
if (Settings.getLastProfile().service() == t.getValue() && t.getValue().version().getVersions().isEmpty())
|
if (Settings.getLastProfile().service() == t.getValue() && t.getValue().version().getVersions().isEmpty())
|
||||||
if (!showedNoVersion && Settings.getLastProfile().service().checkingModpack) {
|
if (!showedNoVersion && Settings.getLastProfile().service().checkingModpack) {
|
||||||
showedNoVersion = true;
|
showedNoVersion = true;
|
||||||
@@ -123,9 +123,9 @@ public final class GameSettingsPanel extends RepaintPage implements DropTargetLi
|
|||||||
cboJava.addItem(j.getLocalizedName());
|
cboJava.addItem(j.getLocalizedName());
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
|
|
||||||
HMCLAPI.EVENT_BUS.channel(ProfileLoadingEvent.class).register(onLoadingProfiles);
|
HMCAPI.EVENT_BUS.channel(ProfileLoadingEvent.class).register(onLoadingProfiles);
|
||||||
HMCLAPI.EVENT_BUS.channel(ProfileChangedEvent.class).register(onSelectedProfilesChanged);
|
HMCAPI.EVENT_BUS.channel(ProfileChangedEvent.class).register(onSelectedProfilesChanged);
|
||||||
HMCLAPI.EVENT_BUS.channel(RefreshedVersionsEvent.class).register(onRefreshedVersions);
|
HMCAPI.EVENT_BUS.channel(RefreshedVersionsEvent.class).register(onRefreshedVersions);
|
||||||
}
|
}
|
||||||
|
|
||||||
void initExplorationMenu() {
|
void initExplorationMenu() {
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ package org.jackhuang.hellominecraft.launcher.ui;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
import org.jackhuang.hellominecraft.api.HMCLAPI;
|
import org.jackhuang.hellominecraft.api.HMCAPI;
|
||||||
import org.jackhuang.hellominecraft.api.event.process.JVMLaunchFailedEvent;
|
import org.jackhuang.hellominecraft.api.event.process.JVMLaunchFailedEvent;
|
||||||
import org.jackhuang.hellominecraft.api.event.process.JavaProcessExitedAbnormallyEvent;
|
import org.jackhuang.hellominecraft.api.event.process.JavaProcessExitedAbnormallyEvent;
|
||||||
import org.jackhuang.hellominecraft.api.event.process.JavaProcessStoppedEvent;
|
import org.jackhuang.hellominecraft.api.event.process.JavaProcessStoppedEvent;
|
||||||
@@ -49,8 +49,8 @@ import org.jackhuang.hellominecraft.util.net.WebFrame;
|
|||||||
public class LaunchingUIDaemon {
|
public class LaunchingUIDaemon {
|
||||||
|
|
||||||
public LaunchingUIDaemon() {
|
public LaunchingUIDaemon() {
|
||||||
HMCLAPI.EVENT_BUS.channel(LaunchingStateChangedEvent.class).register(LAUNCHING_STATE_CHANGED);
|
HMCAPI.EVENT_BUS.channel(LaunchingStateChangedEvent.class).register(LAUNCHING_STATE_CHANGED);
|
||||||
HMCLAPI.EVENT_BUS.channel(LaunchEvent.class).register(p -> {
|
HMCAPI.EVENT_BUS.channel(LaunchEvent.class).register(p -> {
|
||||||
GameLauncher obj = (GameLauncher) p.getSource();
|
GameLauncher obj = (GameLauncher) p.getSource();
|
||||||
HMCLGameLauncher.GameLauncherTag tag = (HMCLGameLauncher.GameLauncherTag) obj.getTag();
|
HMCLGameLauncher.GameLauncherTag tag = (HMCLGameLauncher.GameLauncherTag) obj.getTag();
|
||||||
if (tag.launcherVisibility == LauncherVisibility.CLOSE && !LogWindow.INSTANCE.isVisible()) {
|
if (tag.launcherVisibility == LauncherVisibility.CLOSE && !LogWindow.INSTANCE.isVisible()) {
|
||||||
@@ -69,15 +69,15 @@ public class LaunchingUIDaemon {
|
|||||||
monitor.setTag(tag.launcherVisibility);
|
monitor.setTag(tag.launcherVisibility);
|
||||||
monitor.start();
|
monitor.start();
|
||||||
});
|
});
|
||||||
HMCLAPI.EVENT_BUS.channel(LaunchSucceededEvent.class).register(p -> {
|
HMCAPI.EVENT_BUS.channel(LaunchSucceededEvent.class).register(p -> {
|
||||||
int state = ((HMCLGameLauncher.GameLauncherTag) ((GameLauncher) p.getSource()).getTag()).state;
|
int state = ((HMCLGameLauncher.GameLauncherTag) ((GameLauncher) p.getSource()).getTag()).state;
|
||||||
if (state == 1)
|
if (state == 1)
|
||||||
LAUNCH_FINISHER.accept(p);
|
LAUNCH_FINISHER.accept(p);
|
||||||
else if (state == 2)
|
else if (state == 2)
|
||||||
LAUNCH_SCRIPT_FINISHER.accept(p);
|
LAUNCH_SCRIPT_FINISHER.accept(p);
|
||||||
});
|
});
|
||||||
HMCLAPI.EVENT_BUS.channel(JavaProcessStoppedEvent.class).register(event -> checkExit((LauncherVisibility) ((JavaProcessMonitor) event.getSource()).getTag()));
|
HMCAPI.EVENT_BUS.channel(JavaProcessStoppedEvent.class).register(event -> checkExit((LauncherVisibility) ((JavaProcessMonitor) event.getSource()).getTag()));
|
||||||
HMCLAPI.EVENT_BUS.channel(JavaProcessExitedAbnormallyEvent.class).register(event -> {
|
HMCAPI.EVENT_BUS.channel(JavaProcessExitedAbnormallyEvent.class).register(event -> {
|
||||||
int exitCode = event.getValue().getExitCode();
|
int exitCode = event.getValue().getExitCode();
|
||||||
HMCLog.err("The game exited abnormally, exit code: " + exitCode);
|
HMCLog.err("The game exited abnormally, exit code: " + exitCode);
|
||||||
String[] logs = event.getValue().getStdOutLines().toArray(new String[0]);
|
String[] logs = event.getValue().getStdOutLines().toArray(new String[0]);
|
||||||
@@ -98,7 +98,7 @@ public class LaunchingUIDaemon {
|
|||||||
f.setVisible(true);
|
f.setVisible(true);
|
||||||
checkExit((LauncherVisibility) ((JavaProcessMonitor) event.getSource()).getTag());
|
checkExit((LauncherVisibility) ((JavaProcessMonitor) event.getSource()).getTag());
|
||||||
});
|
});
|
||||||
HMCLAPI.EVENT_BUS.channel(JVMLaunchFailedEvent.class).register(event -> {
|
HMCAPI.EVENT_BUS.channel(JVMLaunchFailedEvent.class).register(event -> {
|
||||||
int exitCode = event.getValue().getExitCode();
|
int exitCode = event.getValue().getExitCode();
|
||||||
HMCLog.err("Cannot create jvm, exit code: " + exitCode);
|
HMCLog.err("Cannot create jvm, exit code: " + exitCode);
|
||||||
WebFrame f = new WebFrame(event.getValue().getStdOutLines().toArray(new String[0]));
|
WebFrame f = new WebFrame(event.getValue().getStdOutLines().toArray(new String[0]));
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ import javax.swing.JComponent;
|
|||||||
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.api.HMCLAPI;
|
import org.jackhuang.hellominecraft.api.HMCAPI;
|
||||||
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.api.event.config.ThemeChangedEvent;
|
import org.jackhuang.hellominecraft.launcher.api.event.config.ThemeChangedEvent;
|
||||||
@@ -159,7 +159,7 @@ public final class MainFrame extends DraggableFrame implements IRepaint {
|
|||||||
}
|
}
|
||||||
((JPanel) getContentPane()).setOpaque(true);
|
((JPanel) getContentPane()).setOpaque(true);
|
||||||
|
|
||||||
HMCLAPI.EVENT_BUS.channel(ThemeChangedEvent.class).register(x -> reloadColor(x.getValue()));
|
HMCAPI.EVENT_BUS.channel(ThemeChangedEvent.class).register(x -> reloadColor(x.getValue()));
|
||||||
|
|
||||||
SwingUtilities.invokeLater(() -> selectTab("main"));
|
SwingUtilities.invokeLater(() -> selectTab("main"));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ import javax.swing.DefaultComboBoxModel;
|
|||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
import javax.swing.SwingUtilities;
|
import javax.swing.SwingUtilities;
|
||||||
import javax.swing.filechooser.FileNameExtensionFilter;
|
import javax.swing.filechooser.FileNameExtensionFilter;
|
||||||
import org.jackhuang.hellominecraft.api.HMCLAPI;
|
import org.jackhuang.hellominecraft.api.HMCAPI;
|
||||||
import org.jackhuang.hellominecraft.launcher.api.event.config.AuthenticatorChangedEvent;
|
import org.jackhuang.hellominecraft.launcher.api.event.config.AuthenticatorChangedEvent;
|
||||||
import org.jackhuang.hellominecraft.launcher.api.event.config.ProfileChangedEvent;
|
import org.jackhuang.hellominecraft.launcher.api.event.config.ProfileChangedEvent;
|
||||||
import org.jackhuang.hellominecraft.launcher.api.event.config.ProfileLoadingEvent;
|
import org.jackhuang.hellominecraft.launcher.api.event.config.ProfileLoadingEvent;
|
||||||
@@ -97,12 +97,12 @@ public class MainPagePanel extends Page {
|
|||||||
|
|
||||||
((RepaintPage) pnlMore).setRepainter(pnlRoot);
|
((RepaintPage) pnlMore).setRepainter(pnlRoot);
|
||||||
|
|
||||||
HMCLAPI.EVENT_BUS.channel(AuthenticatorChangedEvent.class).register(onAuthChanged);
|
HMCAPI.EVENT_BUS.channel(AuthenticatorChangedEvent.class).register(onAuthChanged);
|
||||||
HMCLAPI.EVENT_BUS.channel(ProfileLoadingEvent.class).register(onLoadingProfiles);
|
HMCAPI.EVENT_BUS.channel(ProfileLoadingEvent.class).register(onLoadingProfiles);
|
||||||
HMCLAPI.EVENT_BUS.channel(ProfileChangedEvent.class).register(onSelectedProfilesChanged);
|
HMCAPI.EVENT_BUS.channel(ProfileChangedEvent.class).register(onSelectedProfilesChanged);
|
||||||
HMCLAPI.EVENT_BUS.channel(RefreshedVersionsEvent.class).register(onRefreshedVersions);
|
HMCAPI.EVENT_BUS.channel(RefreshedVersionsEvent.class).register(onRefreshedVersions);
|
||||||
HMCLAPI.EVENT_BUS.channel(LaunchingStateChangedEvent.class).register(launchingStateChanged);
|
HMCAPI.EVENT_BUS.channel(LaunchingStateChangedEvent.class).register(launchingStateChanged);
|
||||||
HMCLAPI.EVENT_BUS.channel(LaunchSucceededEvent.class).register(this::prepareAuths);
|
HMCAPI.EVENT_BUS.channel(LaunchSucceededEvent.class).register(this::prepareAuths);
|
||||||
|
|
||||||
prepareAuths();
|
prepareAuths();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ import org.jackhuang.hellominecraft.launcher.core.launch.LaunchOptions;
|
|||||||
import org.jackhuang.hellominecraft.launcher.setting.Profile;
|
import org.jackhuang.hellominecraft.launcher.setting.Profile;
|
||||||
import org.jackhuang.hellominecraft.launcher.setting.Settings;
|
import org.jackhuang.hellominecraft.launcher.setting.Settings;
|
||||||
import org.jackhuang.hellominecraft.util.C;
|
import org.jackhuang.hellominecraft.util.C;
|
||||||
import org.jackhuang.hellominecraft.api.HMCLAPI;
|
import org.jackhuang.hellominecraft.api.HMCAPI;
|
||||||
import org.jackhuang.hellominecraft.launcher.api.event.launch.LaunchSucceededEvent;
|
import org.jackhuang.hellominecraft.launcher.api.event.launch.LaunchSucceededEvent;
|
||||||
import org.jackhuang.hellominecraft.launcher.api.event.launch.LaunchingState;
|
import org.jackhuang.hellominecraft.launcher.api.event.launch.LaunchingState;
|
||||||
import org.jackhuang.hellominecraft.launcher.api.event.launch.LaunchingStateChangedEvent;
|
import org.jackhuang.hellominecraft.launcher.api.event.launch.LaunchingStateChangedEvent;
|
||||||
@@ -50,12 +50,12 @@ public class HMCLGameLauncher {
|
|||||||
public HMCLGameLauncher(Profile p) {
|
public HMCLGameLauncher(Profile p) {
|
||||||
this.profile = p;
|
this.profile = p;
|
||||||
|
|
||||||
HMCLAPI.EVENT_BUS.channel(LaunchSucceededEvent.class).register(() -> setLaunching(false));
|
HMCAPI.EVENT_BUS.channel(LaunchSucceededEvent.class).register(() -> setLaunching(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
void setLaunching(boolean isLaunching) {
|
void setLaunching(boolean isLaunching) {
|
||||||
if (isLaunching != this.isLaunching)
|
if (isLaunching != this.isLaunching)
|
||||||
HMCLAPI.EVENT_BUS.fireChannel(new LaunchingStateChangedEvent(this, isLaunching ? LaunchingState.Starting : LaunchingState.Done));
|
HMCAPI.EVENT_BUS.fireChannel(new LaunchingStateChangedEvent(this, isLaunching ? LaunchingState.Starting : LaunchingState.Done));
|
||||||
this.isLaunching = isLaunching;
|
this.isLaunching = isLaunching;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,7 +85,7 @@ public class HMCLGameLauncher {
|
|||||||
Thread.currentThread().setName("Game Launcher");
|
Thread.currentThread().setName("Game Launcher");
|
||||||
try {
|
try {
|
||||||
LaunchOptions options = profile.getSelectedVersionSetting().createLaunchOptions(profile.getCanonicalGameDirFile());
|
LaunchOptions options = profile.getSelectedVersionSetting().createLaunchOptions(profile.getCanonicalGameDirFile());
|
||||||
HMCLAPI.EVENT_BUS.fireChannel(new ProcessingLaunchOptionsEvent(this, options));
|
HMCAPI.EVENT_BUS.fireChannel(new ProcessingLaunchOptionsEvent(this, options));
|
||||||
DefaultGameLauncher gl = new DefaultGameLauncher(options, profile.service(), li, l);
|
DefaultGameLauncher gl = new DefaultGameLauncher(options, profile.service(), li, l);
|
||||||
GameLauncherTag tag = new GameLauncherTag();
|
GameLauncherTag tag = new GameLauncherTag();
|
||||||
tag.launcherVisibility = profile.getSelectedVersionSetting().getLauncherVisibility();
|
tag.launcherVisibility = profile.getSelectedVersionSetting().getLauncherVisibility();
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
package org.jackhuang.hellominecraft.launcher.util;
|
package org.jackhuang.hellominecraft.launcher.util;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import org.jackhuang.hellominecraft.api.HMCLAPI;
|
import org.jackhuang.hellominecraft.api.HMCAPI;
|
||||||
import org.jackhuang.hellominecraft.launcher.api.event.version.MinecraftLibraryPathEvent;
|
import org.jackhuang.hellominecraft.launcher.api.event.version.MinecraftLibraryPathEvent;
|
||||||
import org.jackhuang.hellominecraft.launcher.core.version.GameDirType;
|
import org.jackhuang.hellominecraft.launcher.core.version.GameDirType;
|
||||||
import org.jackhuang.hellominecraft.launcher.core.version.MinecraftVersionManager;
|
import org.jackhuang.hellominecraft.launcher.core.version.MinecraftVersionManager;
|
||||||
@@ -34,7 +34,7 @@ public class HMCLGameProvider extends MinecraftVersionManager {
|
|||||||
public HMCLGameProvider(HMCLMinecraftService p) {
|
public HMCLGameProvider(HMCLMinecraftService p) {
|
||||||
super(p);
|
super(p);
|
||||||
|
|
||||||
HMCLAPI.EVENT_BUS.channel(MinecraftLibraryPathEvent.class).register(t -> {
|
HMCAPI.EVENT_BUS.channel(MinecraftLibraryPathEvent.class).register(t -> {
|
||||||
if (!t.getFile().getValue().exists())
|
if (!t.getFile().getValue().exists())
|
||||||
t.getFile().setValue(new File(Settings.getInstance().getCommonpath(), t.getLocation()));
|
t.getFile().setValue(new File(Settings.getInstance().getCommonpath(), t.getLocation()));
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import java.io.File;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import javax.swing.SwingUtilities;
|
import javax.swing.SwingUtilities;
|
||||||
import org.jackhuang.hellominecraft.api.HMCLAPI;
|
import org.jackhuang.hellominecraft.api.HMCAPI;
|
||||||
import org.jackhuang.hellominecraft.launcher.api.event.version.LoadedOneVersionEvent;
|
import org.jackhuang.hellominecraft.launcher.api.event.version.LoadedOneVersionEvent;
|
||||||
import org.jackhuang.hellominecraft.launcher.api.event.version.RefreshedVersionsEvent;
|
import org.jackhuang.hellominecraft.launcher.api.event.version.RefreshedVersionsEvent;
|
||||||
import org.jackhuang.hellominecraft.launcher.api.event.version.RefreshingVersionsEvent;
|
import org.jackhuang.hellominecraft.launcher.api.event.version.RefreshingVersionsEvent;
|
||||||
@@ -57,8 +57,8 @@ public class HMCLMinecraftService extends IMinecraftService {
|
|||||||
this.p = p;
|
this.p = p;
|
||||||
this.provider = new HMCLGameProvider(this);
|
this.provider = new HMCLGameProvider(this);
|
||||||
provider.initializeMiencraft();
|
provider.initializeMiencraft();
|
||||||
HMCLAPI.EVENT_BUS.channel(RefreshingVersionsEvent.class).register(versionSettings::clear);
|
HMCAPI.EVENT_BUS.channel(RefreshingVersionsEvent.class).register(versionSettings::clear);
|
||||||
HMCLAPI.EVENT_BUS.channel(RefreshedVersionsEvent.class).registerFirst(() -> {
|
HMCAPI.EVENT_BUS.channel(RefreshedVersionsEvent.class).registerFirst(() -> {
|
||||||
if (!checkingModpack) {
|
if (!checkingModpack) {
|
||||||
checkingModpack = true;
|
checkingModpack = true;
|
||||||
if (version().getVersionCount() == 0) {
|
if (version().getVersionCount() == 0) {
|
||||||
@@ -72,7 +72,7 @@ public class HMCLMinecraftService extends IMinecraftService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
HMCLAPI.EVENT_BUS.channel(LoadedOneVersionEvent.class).register(e -> loadVersionSetting(e.getValue()));
|
HMCAPI.EVENT_BUS.channel(LoadedOneVersionEvent.class).register(e -> loadVersionSetting(e.getValue()));
|
||||||
this.mms = new MinecraftModService(this);
|
this.mms = new MinecraftModService(this);
|
||||||
this.mds = new MinecraftDownloadService(this);
|
this.mds = new MinecraftDownloadService(this);
|
||||||
this.mas = new HMCLAssetService(this);
|
this.mas = new HMCLAssetService(this);
|
||||||
|
|||||||
@@ -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.svrmgr.api;
|
||||||
|
|
||||||
|
import java.util.EventObject;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author huang
|
||||||
|
*/
|
||||||
|
public class ServerStartedEvent extends EventObject {
|
||||||
|
|
||||||
|
public ServerStartedEvent(Object source) {
|
||||||
|
super(source);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -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.svrmgr.api;
|
||||||
|
|
||||||
|
import java.util.EventObject;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author huang
|
||||||
|
*/
|
||||||
|
public class ServerStoppedEvent extends EventObject {
|
||||||
|
|
||||||
|
public ServerStoppedEvent(Object source) {
|
||||||
|
super(source);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -34,6 +34,8 @@ import java.util.logging.Level;
|
|||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
import org.jackhuang.hellominecraft.api.HMCAPI;
|
||||||
|
import org.jackhuang.hellominecraft.api.SimpleEvent;
|
||||||
import org.jackhuang.hellominecraft.util.log.HMCLog;
|
import org.jackhuang.hellominecraft.util.log.HMCLog;
|
||||||
import org.jackhuang.hellominecraft.util.sys.IOUtils;
|
import org.jackhuang.hellominecraft.util.sys.IOUtils;
|
||||||
import org.jackhuang.hellominecraft.util.MessageBox;
|
import org.jackhuang.hellominecraft.util.MessageBox;
|
||||||
@@ -44,8 +46,8 @@ import org.jackhuang.hellominecraft.svrmgr.setting.SettingsManager;
|
|||||||
import org.jackhuang.hellominecraft.svrmgr.util.MonitorThread;
|
import org.jackhuang.hellominecraft.svrmgr.util.MonitorThread;
|
||||||
import org.jackhuang.hellominecraft.svrmgr.util.WaitForThread;
|
import org.jackhuang.hellominecraft.svrmgr.util.WaitForThread;
|
||||||
import org.jackhuang.hellominecraft.svrmgr.util.Utilities;
|
import org.jackhuang.hellominecraft.svrmgr.util.Utilities;
|
||||||
import org.jackhuang.hellominecraft.api.Event;
|
import org.jackhuang.hellominecraft.svrmgr.api.ServerStartedEvent;
|
||||||
import org.jackhuang.hellominecraft.api.EventHandler;
|
import org.jackhuang.hellominecraft.svrmgr.api.ServerStoppedEvent;
|
||||||
import org.jackhuang.hellominecraft.util.code.Charsets;
|
import org.jackhuang.hellominecraft.util.code.Charsets;
|
||||||
import org.jackhuang.hellominecraft.util.func.Consumer;
|
import org.jackhuang.hellominecraft.util.func.Consumer;
|
||||||
|
|
||||||
@@ -53,7 +55,7 @@ import org.jackhuang.hellominecraft.util.func.Consumer;
|
|||||||
*
|
*
|
||||||
* @author huangyuhui
|
* @author huangyuhui
|
||||||
*/
|
*/
|
||||||
public class Server implements Event<Integer>, MonitorThread.MonitorThreadListener,
|
public class Server implements Consumer<SimpleEvent<Integer>>, MonitorThread.MonitorThreadListener,
|
||||||
ActionListener {
|
ActionListener {
|
||||||
|
|
||||||
private static Server instance;
|
private static Server instance;
|
||||||
@@ -77,9 +79,7 @@ public class Server implements Event<Integer>, MonitorThread.MonitorThreadListen
|
|||||||
WaitForThread threadC;
|
WaitForThread threadC;
|
||||||
Consumer<Pair<String, String[]>> gettingPlayerNumber;
|
Consumer<Pair<String, String[]>> gettingPlayerNumber;
|
||||||
ArrayList<MonitorThread.MonitorThreadListener> listeners;
|
ArrayList<MonitorThread.MonitorThreadListener> listeners;
|
||||||
ArrayList<Event<Integer>> listenersC;
|
ArrayList<Consumer<SimpleEvent<Integer>>> listenersC;
|
||||||
//ArrayList<DoneListener0> listenersBegin, listenersDone;
|
|
||||||
public final EventHandler<Void> startedEvent = new EventHandler<>(this), stoppedEvent = new EventHandler<>(this);
|
|
||||||
ArrayList<TimerTask> timerTasks;
|
ArrayList<TimerTask> timerTasks;
|
||||||
ArrayList<Schedule> schedules;
|
ArrayList<Schedule> schedules;
|
||||||
BufferedWriter bw;
|
BufferedWriter bw;
|
||||||
@@ -103,7 +103,7 @@ public class Server implements Event<Integer>, MonitorThread.MonitorThreadListen
|
|||||||
listeners.add(l);
|
listeners.add(l);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addListener(Event<Integer> l) {
|
public void addListener(Consumer<SimpleEvent<Integer>> l) {
|
||||||
listenersC.add(l);
|
listenersC.add(l);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,7 +133,7 @@ public class Server implements Event<Integer>, MonitorThread.MonitorThreadListen
|
|||||||
registerThreadC(server);
|
registerThreadC(server);
|
||||||
bw = new BufferedWriter(new OutputStreamWriter(server.getOutputStream(), Charsets.toCharset()));
|
bw = new BufferedWriter(new OutputStreamWriter(server.getOutputStream(), Charsets.toCharset()));
|
||||||
isRunning = true;
|
isRunning = true;
|
||||||
startedEvent.fire(null);
|
HMCAPI.EVENT_BUS.fireChannel(new ServerStartedEvent(this));
|
||||||
sendStatus("*** 启动服务端中 ***");
|
sendStatus("*** 启动服务端中 ***");
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
Logger.getLogger(Server.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(Server.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
@@ -203,14 +203,15 @@ public class Server implements Event<Integer>, MonitorThread.MonitorThreadListen
|
|||||||
|
|
||||||
private void registerThreadC(Process p) {
|
private void registerThreadC(Process p) {
|
||||||
threadC = new WaitForThread(p);
|
threadC = new WaitForThread(p);
|
||||||
for (Event<Integer> l : listenersC)
|
for (Consumer<SimpleEvent<Integer>> l : listenersC)
|
||||||
threadC.event.register(l);
|
threadC.event.register(l);
|
||||||
threadC.event.register(this);
|
threadC.event.register(this);
|
||||||
threadC.start();
|
threadC.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean call(Object sender, Integer t) {
|
public void accept(SimpleEvent<Integer> event) {
|
||||||
|
int t = event.getValue();
|
||||||
if (t == 0) {
|
if (t == 0) {
|
||||||
sendStatus("*** 服务端已停止 ***");
|
sendStatus("*** 服务端已停止 ***");
|
||||||
System.out.println("Server stopped successfully");
|
System.out.println("Server stopped successfully");
|
||||||
@@ -236,7 +237,6 @@ public class Server implements Event<Integer>, MonitorThread.MonitorThreadListen
|
|||||||
}
|
}
|
||||||
isRestart = false;
|
isRestart = false;
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void disactiveMods(ArrayList<String> inactiveExtMods,
|
private static void disactiveMods(ArrayList<String> inactiveExtMods,
|
||||||
@@ -342,7 +342,7 @@ public class Server implements Event<Integer>, MonitorThread.MonitorThreadListen
|
|||||||
Pattern p = Pattern.compile("\\[INFO\\] Done \\([0-9]*\\.[0-9]*s\\)! For help, type \"help\" or \"\\?\"");
|
Pattern p = Pattern.compile("\\[INFO\\] Done \\([0-9]*\\.[0-9]*s\\)! For help, type \"help\" or \"\\?\"");
|
||||||
Matcher m = p.matcher(status);
|
Matcher m = p.matcher(status);
|
||||||
if (m.find()) {
|
if (m.find()) {
|
||||||
stoppedEvent.fire(null);
|
HMCAPI.EVENT_BUS.fireChannel(new ServerStoppedEvent(this));
|
||||||
timer = new Timer();
|
timer = new Timer();
|
||||||
timerTasks.clear();
|
timerTasks.clear();
|
||||||
for (int i = 0; i < schedules.size(); i++) {
|
for (int i = 0; i < schedules.size(); i++) {
|
||||||
|
|||||||
@@ -87,15 +87,19 @@ import org.jackhuang.hellominecraft.svrmgr.util.Utilities;
|
|||||||
import org.jackhuang.hellominecraft.util.ui.SwingUtils;
|
import org.jackhuang.hellominecraft.util.ui.SwingUtils;
|
||||||
import org.jackhuang.hellominecraft.svrmgr.util.version.MinecraftRemoteVersion;
|
import org.jackhuang.hellominecraft.svrmgr.util.version.MinecraftRemoteVersion;
|
||||||
import org.jackhuang.hellominecraft.lookandfeel.ConstomButton;
|
import org.jackhuang.hellominecraft.lookandfeel.ConstomButton;
|
||||||
import org.jackhuang.hellominecraft.api.Event;
|
import org.jackhuang.hellominecraft.api.HMCAPI;
|
||||||
|
import org.jackhuang.hellominecraft.api.SimpleEvent;
|
||||||
|
import org.jackhuang.hellominecraft.svrmgr.api.ServerStartedEvent;
|
||||||
|
import org.jackhuang.hellominecraft.svrmgr.api.ServerStoppedEvent;
|
||||||
import org.jackhuang.hellominecraft.util.StrUtils;
|
import org.jackhuang.hellominecraft.util.StrUtils;
|
||||||
|
import org.jackhuang.hellominecraft.util.func.Consumer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author huangyuhui
|
* @author huangyuhui
|
||||||
*/
|
*/
|
||||||
public final class MainWindow extends javax.swing.JFrame
|
public final class MainWindow extends javax.swing.JFrame
|
||||||
implements MonitorThread.MonitorThreadListener, Event<Integer> {
|
implements MonitorThread.MonitorThreadListener, Consumer<SimpleEvent<Integer>> {
|
||||||
|
|
||||||
ImageIcon background = new ImageIcon(getClass().getResource("/background.jpg"));
|
ImageIcon background = new ImageIcon(getClass().getResource("/background.jpg"));
|
||||||
JLabel backgroundLabel;
|
JLabel backgroundLabel;
|
||||||
@@ -134,7 +138,7 @@ public final class MainWindow extends javax.swing.JFrame
|
|||||||
|
|
||||||
Dimension scrSize = Toolkit.getDefaultToolkit().getScreenSize();
|
Dimension scrSize = Toolkit.getDefaultToolkit().getScreenSize();
|
||||||
setLocation((scrSize.width - this.getWidth()) / 2,
|
setLocation((scrSize.width - this.getWidth()) / 2,
|
||||||
(scrSize.height - this.getHeight()) / 2);
|
(scrSize.height - this.getHeight()) / 2);
|
||||||
|
|
||||||
this.setIconImage(new ImageIcon(getClass().getResource("/icon.png")).getImage());
|
this.setIconImage(new ImageIcon(getClass().getResource("/icon.png")).getImage());
|
||||||
|
|
||||||
@@ -2711,18 +2715,18 @@ public final class MainWindow extends javax.swing.JFrame
|
|||||||
cboDifficulty.setSelectedIndex(sp.getPropertyInt("difficulty", 1));
|
cboDifficulty.setSelectedIndex(sp.getPropertyInt("difficulty", 1));
|
||||||
String wt = sp.getProperty("level-type");
|
String wt = sp.getProperty("level-type");
|
||||||
switch (wt) {
|
switch (wt) {
|
||||||
case "LARGEBIOMES":
|
case "LARGEBIOMES":
|
||||||
cboWorldType.setSelectedIndex(2);
|
cboWorldType.setSelectedIndex(2);
|
||||||
break;
|
break;
|
||||||
case "FLAT":
|
case "FLAT":
|
||||||
cboWorldType.setSelectedIndex(1);
|
cboWorldType.setSelectedIndex(1);
|
||||||
break;
|
break;
|
||||||
case "DEFAULT":
|
case "DEFAULT":
|
||||||
cboWorldType.setSelectedIndex(0);
|
cboWorldType.setSelectedIndex(0);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
cboWorldType.setSelectedIndex(0);
|
cboWorldType.setSelectedIndex(0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
txtMaxPlayer.setValue(sp.getPropertyInt("max-players", 20));
|
txtMaxPlayer.setValue(sp.getPropertyInt("max-players", 20));
|
||||||
chkAllowFlight.setSelected(sp.getPropertyBoolean("allow-flight", false));
|
chkAllowFlight.setSelected(sp.getPropertyBoolean("allow-flight", false));
|
||||||
@@ -2785,7 +2789,7 @@ public final class MainWindow extends javax.swing.JFrame
|
|||||||
while (model.getRowCount() > 0)
|
while (model.getRowCount() > 0)
|
||||||
model.removeRow(0);
|
model.removeRow(0);
|
||||||
IOUtils.findAllFile(new File(path), s
|
IOUtils.findAllFile(new File(path), s
|
||||||
-> model.addRow(new Object[] { !SettingsManager.settings.inactiveExtMods.contains(s), s, ModType.getModTypeShowName(ModType.getModType(IOUtils.addSeparator(path) + s)) })
|
-> model.addRow(new Object[] { !SettingsManager.settings.inactiveExtMods.contains(s), s, ModType.getModTypeShowName(ModType.getModType(IOUtils.addSeparator(path) + s)) })
|
||||||
);
|
);
|
||||||
lstExternalMods.updateUI();
|
lstExternalMods.updateUI();
|
||||||
}
|
}
|
||||||
@@ -2798,14 +2802,14 @@ public final class MainWindow extends javax.swing.JFrame
|
|||||||
while (model.getRowCount() > 0)
|
while (model.getRowCount() > 0)
|
||||||
model.removeRow(0);
|
model.removeRow(0);
|
||||||
IOUtils.findAllFile(new File(path), s -> {
|
IOUtils.findAllFile(new File(path), s -> {
|
||||||
PluginInformation p = PluginManager.getPluginYML(new File(Utilities.getGameDir() + "plugins" + File.separator + s));
|
PluginInformation p = PluginManager.getPluginYML(new File(Utilities.getGameDir() + "plugins" + File.separator + s));
|
||||||
if (p == null)
|
if (p == null)
|
||||||
model.addRow(new Object[] { !SettingsManager.settings.inactivePlugins.contains(s), s,
|
model.addRow(new Object[] { !SettingsManager.settings.inactivePlugins.contains(s), s,
|
||||||
"", "", "", "" });
|
"", "", "", "" });
|
||||||
else
|
else
|
||||||
model.addRow(new Object[] { !SettingsManager.settings.inactivePlugins.contains(s), s,
|
model.addRow(new Object[] { !SettingsManager.settings.inactivePlugins.contains(s), s,
|
||||||
p.name, p.version, p.author, p.description });
|
p.name, p.version, p.author, p.description });
|
||||||
});
|
});
|
||||||
|
|
||||||
lstPlugins.updateUI();
|
lstPlugins.updateUI();
|
||||||
}
|
}
|
||||||
@@ -2818,7 +2822,7 @@ public final class MainWindow extends javax.swing.JFrame
|
|||||||
while (model.getRowCount() > 0)
|
while (model.getRowCount() > 0)
|
||||||
model.removeRow(0);
|
model.removeRow(0);
|
||||||
IOUtils.findAllFile(new File(path), s
|
IOUtils.findAllFile(new File(path), s
|
||||||
-> model.addRow(new Object[] { !SettingsManager.settings.inactiveCoreMods.contains(s), s, ModType.getModTypeShowName(ModType.getModType(IOUtils.addSeparator(path) + s)) }));
|
-> model.addRow(new Object[] { !SettingsManager.settings.inactiveCoreMods.contains(s), s, ModType.getModTypeShowName(ModType.getModType(IOUtils.addSeparator(path) + s)) }));
|
||||||
|
|
||||||
lstCoreMods.updateUI();
|
lstCoreMods.updateUI();
|
||||||
}
|
}
|
||||||
@@ -2865,32 +2869,32 @@ public final class MainWindow extends javax.swing.JFrame
|
|||||||
return;
|
return;
|
||||||
BukkitFormatThread thread;
|
BukkitFormatThread thread;
|
||||||
switch (idx) {
|
switch (idx) {
|
||||||
case 1:
|
case 1:
|
||||||
thread = new BukkitFormatThread(
|
thread = new BukkitFormatThread(
|
||||||
"http://dl.bukkit.org/downloads/craftbukkit/list/beta/", value -> {
|
"http://dl.bukkit.org/downloads/craftbukkit/list/beta/", value -> {
|
||||||
craftBukkitBeta = value;
|
craftBukkitBeta = value;
|
||||||
reloadBukkitList();
|
reloadBukkitList();
|
||||||
});
|
});
|
||||||
thread.start();
|
thread.start();
|
||||||
break;
|
break;
|
||||||
case 0:
|
case 0:
|
||||||
thread = new BukkitFormatThread(
|
thread = new BukkitFormatThread(
|
||||||
"http://dl.bukkit.org/downloads/craftbukkit/list/rb/", value -> {
|
"http://dl.bukkit.org/downloads/craftbukkit/list/rb/", value -> {
|
||||||
craftBukkitRecommended = value;
|
craftBukkitRecommended = value;
|
||||||
reloadBukkitList();
|
reloadBukkitList();
|
||||||
});
|
});
|
||||||
thread.start();
|
thread.start();
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
thread = new BukkitFormatThread(
|
thread = new BukkitFormatThread(
|
||||||
"http://dl.bukkit.org/downloads/craftbukkit/list/dev/", value -> {
|
"http://dl.bukkit.org/downloads/craftbukkit/list/dev/", value -> {
|
||||||
craftBukkitDev = value;
|
craftBukkitDev = value;
|
||||||
reloadBukkitList();
|
reloadBukkitList();
|
||||||
});
|
});
|
||||||
thread.start();
|
thread.start();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2932,17 +2936,17 @@ public final class MainWindow extends javax.swing.JFrame
|
|||||||
if (idx == -1)
|
if (idx == -1)
|
||||||
return;
|
return;
|
||||||
switch (idx) {
|
switch (idx) {
|
||||||
case 1:
|
case 1:
|
||||||
useBukkitVersions(craftBukkitBeta);
|
useBukkitVersions(craftBukkitBeta);
|
||||||
break;
|
break;
|
||||||
case 0:
|
case 0:
|
||||||
useBukkitVersions(craftBukkitRecommended);
|
useBukkitVersions(craftBukkitRecommended);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
useBukkitVersions(craftBukkitDev);
|
useBukkitVersions(craftBukkitDev);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3095,25 +3099,24 @@ public final class MainWindow extends javax.swing.JFrame
|
|||||||
MessageBox.show("服务器未开启!");
|
MessageBox.show("服务器未开启!");
|
||||||
}
|
}
|
||||||
|
|
||||||
class ServerBeginListener implements Event<Void> {
|
class ServerBeginListener implements Runnable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean call(Object sender, Void v) {
|
public void run() {
|
||||||
commandSet = new ArrayList<>();
|
commandSet = new ArrayList<>();
|
||||||
txtMain.setText("");
|
txtMain.setText("");
|
||||||
btnLaunch.setEnabled(false);
|
btnLaunch.setEnabled(false);
|
||||||
btnStop.setEnabled(true);
|
btnStop.setEnabled(true);
|
||||||
btnShutdown.setEnabled(true);
|
btnShutdown.setEnabled(true);
|
||||||
btnCommand.setEnabled(true);
|
btnCommand.setEnabled(true);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class ServerDoneListener implements Event<Void> {
|
class ServerDoneListener implements Runnable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean call(Object sender, Void v) {
|
public void run() {
|
||||||
getPlayerNumberTimer = new Timer();
|
getPlayerNumberTimer = new Timer();
|
||||||
getPlayerNumberTimer.schedule(new TimerTask() {
|
getPlayerNumberTimer.schedule(new TimerTask() {
|
||||||
|
|
||||||
@@ -3122,7 +3125,6 @@ public final class MainWindow extends javax.swing.JFrame
|
|||||||
loadPlayers();
|
loadPlayers();
|
||||||
}
|
}
|
||||||
}, 1000 * 60 * 10, 1000 * 60 * 10);
|
}, 1000 * 60 * 10, 1000 * 60 * 10);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -3151,16 +3153,16 @@ public final class MainWindow extends javax.swing.JFrame
|
|||||||
|
|
||||||
Server.init(SettingsManager.settings.mainjar, String.valueOf(SettingsManager.settings.maxMemory));
|
Server.init(SettingsManager.settings.mainjar, String.valueOf(SettingsManager.settings.maxMemory));
|
||||||
Server.getInstance()
|
Server.getInstance()
|
||||||
.addListener((MonitorThread.MonitorThreadListener) this);
|
.addListener((MonitorThread.MonitorThreadListener) this);
|
||||||
Server.getInstance()
|
Server.getInstance()
|
||||||
.addListener((Event<Integer>) this);
|
.addListener((Consumer<SimpleEvent<Integer>>) this);
|
||||||
Server.getInstance()
|
Server.getInstance()
|
||||||
.clearSchedule();
|
.clearSchedule();
|
||||||
for (Schedule s : SettingsManager.settings.schedules)
|
for (Schedule s : SettingsManager.settings.schedules)
|
||||||
Server.getInstance().addSchedule(s);
|
Server.getInstance().addSchedule(s);
|
||||||
|
|
||||||
Server.getInstance().startedEvent.register(new ServerBeginListener());
|
HMCAPI.EVENT_BUS.channel(ServerStartedEvent.class).register(new ServerBeginListener());
|
||||||
Server.getInstance().startedEvent.register(new ServerDoneListener());
|
HMCAPI.EVENT_BUS.channel(ServerStoppedEvent.class).register(new ServerDoneListener());
|
||||||
try {
|
try {
|
||||||
Server.getInstance().run();
|
Server.getInstance().run();
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
@@ -3184,19 +3186,19 @@ public final class MainWindow extends javax.swing.JFrame
|
|||||||
int newCommandIndex = commandIndex;
|
int newCommandIndex = commandIndex;
|
||||||
int type = 0;
|
int type = 0;
|
||||||
switch (evt.getKeyCode()) {
|
switch (evt.getKeyCode()) {
|
||||||
case KeyEvent.VK_UP:
|
case KeyEvent.VK_UP:
|
||||||
newCommandIndex--;
|
newCommandIndex--;
|
||||||
type = 1;
|
type = 1;
|
||||||
break;
|
break;
|
||||||
case KeyEvent.VK_DOWN:
|
case KeyEvent.VK_DOWN:
|
||||||
newCommandIndex++;
|
newCommandIndex++;
|
||||||
type = 1;
|
type = 1;
|
||||||
break;
|
break;
|
||||||
case KeyEvent.VK_ENTER:
|
case KeyEvent.VK_ENTER:
|
||||||
type = 2;
|
type = 2;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (type == 1) {
|
if (type == 1) {
|
||||||
if (outOfCommandSet(newCommandIndex))
|
if (outOfCommandSet(newCommandIndex))
|
||||||
@@ -3290,17 +3292,17 @@ public final class MainWindow extends javax.swing.JFrame
|
|||||||
int OAO = cboWorldType.getSelectedIndex();
|
int OAO = cboWorldType.getSelectedIndex();
|
||||||
String type = "DEFAULT";
|
String type = "DEFAULT";
|
||||||
switch (OAO) {
|
switch (OAO) {
|
||||||
case 0:
|
case 0:
|
||||||
type = "DEFAULT";
|
type = "DEFAULT";
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
type = "FLAT";
|
type = "FLAT";
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
type = "LARGEBIMOES";
|
type = "LARGEBIMOES";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ServerProperties.getInstance().setLevelType(type);
|
ServerProperties.getInstance().setLevelType(type);
|
||||||
}//GEN-LAST:event_cboWorldTypeItemStateChanged
|
}//GEN-LAST:event_cboWorldTypeItemStateChanged
|
||||||
@@ -3671,12 +3673,12 @@ public final class MainWindow extends javax.swing.JFrame
|
|||||||
|
|
||||||
private void btnBackupActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBackupActionPerformed
|
private void btnBackupActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBackupActionPerformed
|
||||||
switch (cboBackupTypes.getSelectedIndex()) {
|
switch (cboBackupTypes.getSelectedIndex()) {
|
||||||
case 0:
|
case 0:
|
||||||
BackupManager.backupAllWorlds();
|
BackupManager.backupAllWorlds();
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
BackupManager.backupAllPlugins();
|
BackupManager.backupAllPlugins();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}//GEN-LAST:event_btnBackupActionPerformed
|
}//GEN-LAST:event_btnBackupActionPerformed
|
||||||
|
|
||||||
@@ -3687,9 +3689,9 @@ public final class MainWindow extends javax.swing.JFrame
|
|||||||
File getBackupFile(int index) {
|
File getBackupFile(int index) {
|
||||||
DefaultTableModel model = (DefaultTableModel) lstBackups.getModel();
|
DefaultTableModel model = (DefaultTableModel) lstBackups.getModel();
|
||||||
return new File(BackupManager.backupDir()
|
return new File(BackupManager.backupDir()
|
||||||
+ model.getValueAt(index, 0) + "+"
|
+ model.getValueAt(index, 0) + "+"
|
||||||
+ model.getValueAt(index, 1) + "+"
|
+ model.getValueAt(index, 1) + "+"
|
||||||
+ model.getValueAt(index, 2) + ".zip");
|
+ model.getValueAt(index, 2) + ".zip");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnDeleteBackupActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDeleteBackupActionPerformed
|
private void btnDeleteBackupActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDeleteBackupActionPerformed
|
||||||
@@ -3743,13 +3745,13 @@ public final class MainWindow extends javax.swing.JFrame
|
|||||||
|
|
||||||
private void btnAutoSearchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAutoSearchActionPerformed
|
private void btnAutoSearchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAutoSearchActionPerformed
|
||||||
IOUtils.findAllFile(new File("."), s -> {
|
IOUtils.findAllFile(new File("."), s -> {
|
||||||
if (ServerChecker.isServerJar(new File(s))) {
|
if (ServerChecker.isServerJar(new File(s))) {
|
||||||
String path = IOUtils.tryGetCanonicalFilePath(new File(s));
|
String path = IOUtils.tryGetCanonicalFilePath(new File(s));
|
||||||
txtMainJar.setText(path);
|
txtMainJar.setText(path);
|
||||||
SettingsManager.settings.mainjar = path;
|
SettingsManager.settings.mainjar = path;
|
||||||
SettingsManager.save();
|
SettingsManager.save();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}//GEN-LAST:event_btnAutoSearchActionPerformed
|
}//GEN-LAST:event_btnAutoSearchActionPerformed
|
||||||
|
|
||||||
private void cboCategoryItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cboCategoryItemStateChanged
|
private void cboCategoryItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cboCategoryItemStateChanged
|
||||||
@@ -3841,21 +3843,21 @@ public final class MainWindow extends javax.swing.JFrame
|
|||||||
if (idx2 == -1)
|
if (idx2 == -1)
|
||||||
return;
|
return;
|
||||||
switch (idx2) {
|
switch (idx2) {
|
||||||
case 0:
|
case 0:
|
||||||
ext = "rb";
|
ext = "rb";
|
||||||
cb = craftBukkitRecommended;
|
cb = craftBukkitRecommended;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
ext = "beta";
|
ext = "beta";
|
||||||
cb = craftBukkitBeta;
|
cb = craftBukkitBeta;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
BukkitVersion v = cb.get(idx);
|
BukkitVersion v = cb.get(idx);
|
||||||
File file = new File("craftbukkit-" + ext + "-" + v.version + ".jar");
|
File file = new File("craftbukkit-" + ext + "-" + v.version + ".jar");
|
||||||
TaskWindow.factory().append(new FileDownloadTask(v.downloadLink, IOUtils.tryGetCanonicalFile(file)).setTag("bukkit-" + ext + "-" + v.version))
|
TaskWindow.factory().append(new FileDownloadTask(v.downloadLink, IOUtils.tryGetCanonicalFile(file)).setTag("bukkit-" + ext + "-" + v.version))
|
||||||
.execute();
|
.execute();
|
||||||
}//GEN-LAST:event_btnDownloadCraftbukkitActionPerformed
|
}//GEN-LAST:event_btnDownloadCraftbukkitActionPerformed
|
||||||
|
|
||||||
private void btnDownloadMCPCActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDownloadMCPCActionPerformed
|
private void btnDownloadMCPCActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDownloadMCPCActionPerformed
|
||||||
@@ -3956,7 +3958,7 @@ public final class MainWindow extends javax.swing.JFrame
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean call(Object sender, Integer t) {
|
public void accept(SimpleEvent<Integer> event) {
|
||||||
btnLaunch.setEnabled(true);
|
btnLaunch.setEnabled(true);
|
||||||
btnStop.setEnabled(false);
|
btnStop.setEnabled(false);
|
||||||
btnShutdown.setEnabled(false);
|
btnShutdown.setEnabled(false);
|
||||||
@@ -3964,8 +3966,8 @@ public final class MainWindow extends javax.swing.JFrame
|
|||||||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH-mm-ss");
|
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH-mm-ss");
|
||||||
try {
|
try {
|
||||||
FileUtils.write(new File(Utilities.getGameDir() + "infos-HMCSM"
|
FileUtils.write(new File(Utilities.getGameDir() + "infos-HMCSM"
|
||||||
+ File.separator + format.format(new Date()) + ".txt"),
|
+ File.separator + format.format(new Date()) + ".txt"),
|
||||||
txtMain.getText());
|
txtMain.getText());
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
HMCLog.warn("Failed to save info", ex);
|
HMCLog.warn("Failed to save info", ex);
|
||||||
}
|
}
|
||||||
@@ -3973,7 +3975,6 @@ public final class MainWindow extends javax.swing.JFrame
|
|||||||
getPlayerNumberTimer.cancel();
|
getPlayerNumberTimer.cancel();
|
||||||
getPlayerNumberTimer = null;
|
getPlayerNumberTimer = null;
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendCommand() {
|
private void sendCommand() {
|
||||||
@@ -3999,10 +4000,10 @@ public final class MainWindow extends javax.swing.JFrame
|
|||||||
|
|
||||||
MonitorThread mainThread;
|
MonitorThread mainThread;
|
||||||
DefaultListModel lstOPModel = new DefaultListModel(),
|
DefaultListModel lstOPModel = new DefaultListModel(),
|
||||||
lstWhiteListModel = new DefaultListModel(),
|
lstWhiteListModel = new DefaultListModel(),
|
||||||
lstBannedModel = new DefaultListModel(),
|
lstBannedModel = new DefaultListModel(),
|
||||||
lstCrashReportsModel = new DefaultListModel(),
|
lstCrashReportsModel = new DefaultListModel(),
|
||||||
lstPlayersModel = new DefaultListModel();
|
lstPlayersModel = new DefaultListModel();
|
||||||
List<BukkitPlugin> plugins;
|
List<BukkitPlugin> plugins;
|
||||||
Map<String, List<ForgeVersion>> mcpcPackages;
|
Map<String, List<ForgeVersion>> mcpcPackages;
|
||||||
List<BukkitVersion> craftBukkitRecommended, craftBukkitBeta, craftBukkitDev;
|
List<BukkitVersion> craftBukkitRecommended, craftBukkitBeta, craftBukkitDev;
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
package org.jackhuang.hellominecraft.svrmgr.util;
|
package org.jackhuang.hellominecraft.svrmgr.util;
|
||||||
|
|
||||||
import org.jackhuang.hellominecraft.api.EventHandler;
|
import org.jackhuang.hellominecraft.api.EventHandler;
|
||||||
|
import org.jackhuang.hellominecraft.api.SimpleEvent;
|
||||||
import org.jackhuang.hellominecraft.util.log.HMCLog;
|
import org.jackhuang.hellominecraft.util.log.HMCLog;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -26,7 +27,7 @@ import org.jackhuang.hellominecraft.util.log.HMCLog;
|
|||||||
*/
|
*/
|
||||||
public class WaitForThread extends Thread {
|
public class WaitForThread extends Thread {
|
||||||
|
|
||||||
public final EventHandler<Integer> event = new EventHandler<>(this);
|
public final EventHandler<SimpleEvent<Integer>> event = new EventHandler<>();
|
||||||
Process p;
|
Process p;
|
||||||
|
|
||||||
public WaitForThread(Process p) {
|
public WaitForThread(Process p) {
|
||||||
@@ -37,10 +38,10 @@ public class WaitForThread extends Thread {
|
|||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
int exitCode = p.waitFor();
|
int exitCode = p.waitFor();
|
||||||
event.fire(exitCode);
|
event.fire(new SimpleEvent<>(this, exitCode));
|
||||||
} catch (InterruptedException ex) {
|
} catch (InterruptedException ex) {
|
||||||
HMCLog.err("Game has been interrupted.", ex);
|
HMCLog.err("Game has been interrupted.", ex);
|
||||||
event.fire(-1);
|
event.fire(new SimpleEvent<>(this, -1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ package org.jackhuang.hellominecraft.api;
|
|||||||
*
|
*
|
||||||
* @author huang
|
* @author huang
|
||||||
*/
|
*/
|
||||||
public class HMCLAPI {
|
public class HMCAPI {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Events.
|
* Events.
|
||||||
@@ -23,7 +23,7 @@ import com.google.gson.JsonSyntaxException;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import org.jackhuang.hellominecraft.util.log.HMCLog;
|
import org.jackhuang.hellominecraft.util.log.HMCLog;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import org.jackhuang.hellominecraft.api.HMCLAPI;
|
import org.jackhuang.hellominecraft.api.HMCAPI;
|
||||||
import org.jackhuang.hellominecraft.api.SimpleEvent;
|
import org.jackhuang.hellominecraft.api.SimpleEvent;
|
||||||
import org.jackhuang.hellominecraft.api.event.OutOfDateEvent;
|
import org.jackhuang.hellominecraft.api.event.OutOfDateEvent;
|
||||||
|
|
||||||
@@ -98,7 +98,7 @@ public final class UpdateChecker implements IUpdateChecker {
|
|||||||
@Override
|
@Override
|
||||||
public void checkOutdate() {
|
public void checkOutdate() {
|
||||||
if (outOfDate)
|
if (outOfDate)
|
||||||
if (HMCLAPI.EVENT_BUS.fireChannelResulted(new OutOfDateEvent(this, getNewVersion())))
|
if (HMCAPI.EVENT_BUS.fireChannelResulted(new OutOfDateEvent(this, getNewVersion())))
|
||||||
upgrade.fire(new SimpleEvent<>(this, getNewVersion()));
|
upgrade.fire(new SimpleEvent<>(this, getNewVersion()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import java.util.Arrays;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import org.jackhuang.hellominecraft.util.CollectionUtils;
|
import org.jackhuang.hellominecraft.util.CollectionUtils;
|
||||||
import org.jackhuang.hellominecraft.api.EventHandler;
|
import org.jackhuang.hellominecraft.api.EventHandler;
|
||||||
import org.jackhuang.hellominecraft.api.HMCLAPI;
|
import org.jackhuang.hellominecraft.api.HMCAPI;
|
||||||
import org.jackhuang.hellominecraft.api.event.process.JVMLaunchFailedEvent;
|
import org.jackhuang.hellominecraft.api.event.process.JVMLaunchFailedEvent;
|
||||||
import org.jackhuang.hellominecraft.api.event.process.JavaProcessExitedAbnormallyEvent;
|
import org.jackhuang.hellominecraft.api.event.process.JavaProcessExitedAbnormallyEvent;
|
||||||
import org.jackhuang.hellominecraft.api.event.process.JavaProcessStartingEvent;
|
import org.jackhuang.hellominecraft.api.event.process.JavaProcessStartingEvent;
|
||||||
@@ -59,21 +59,21 @@ public class JavaProcessMonitor {
|
|||||||
|
|
||||||
|
|
||||||
public void start() {
|
public void start() {
|
||||||
HMCLAPI.EVENT_BUS.fireChannel(new JavaProcessStartingEvent(this, p));
|
HMCAPI.EVENT_BUS.fireChannel(new JavaProcessStartingEvent(this, p));
|
||||||
ProcessThread a = new ProcessThread(p);
|
ProcessThread a = new ProcessThread(p);
|
||||||
a.stopEvent.register(event -> {
|
a.stopEvent.register(event -> {
|
||||||
HMCLog.log("Process exit code: " + p.getExitCode());
|
HMCLog.log("Process exit code: " + p.getExitCode());
|
||||||
if (p.getExitCode() != 0 || StrUtils.containsOne(p.getStdOutLines(),
|
if (p.getExitCode() != 0 || StrUtils.containsOne(p.getStdOutLines(),
|
||||||
Arrays.asList("Unable to launch"),
|
Arrays.asList("Unable to launch"),
|
||||||
x -> Level.guessLevel(x, Level.INFO).lessOrEqual(Level.ERROR)))
|
x -> Level.guessLevel(x, Level.INFO).lessOrEqual(Level.ERROR)))
|
||||||
HMCLAPI.EVENT_BUS.fireChannel(new JavaProcessExitedAbnormallyEvent(JavaProcessMonitor.this, p));
|
HMCAPI.EVENT_BUS.fireChannel(new JavaProcessExitedAbnormallyEvent(JavaProcessMonitor.this, p));
|
||||||
if (p.getExitCode() != 0 && StrUtils.containsOne(p.getStdOutLines(),
|
if (p.getExitCode() != 0 && StrUtils.containsOne(p.getStdOutLines(),
|
||||||
Arrays.asList("Could not create the Java Virtual Machine.",
|
Arrays.asList("Could not create the Java Virtual Machine.",
|
||||||
"Error occurred during initialization of VM",
|
"Error occurred during initialization of VM",
|
||||||
"A fatal exception has occurred. Program will exit.",
|
"A fatal exception has occurred. Program will exit.",
|
||||||
"Unable to launch"),
|
"Unable to launch"),
|
||||||
x -> Level.guessLevel(x, Level.INFO).lessOrEqual(Level.ERROR)))
|
x -> Level.guessLevel(x, Level.INFO).lessOrEqual(Level.ERROR)))
|
||||||
HMCLAPI.EVENT_BUS.fireChannel(new JVMLaunchFailedEvent(JavaProcessMonitor.this, p));
|
HMCAPI.EVENT_BUS.fireChannel(new JVMLaunchFailedEvent(JavaProcessMonitor.this, p));
|
||||||
processThreadStopped((ProcessThread) event.getSource(), false);
|
processThreadStopped((ProcessThread) event.getSource(), false);
|
||||||
});
|
});
|
||||||
a.start();
|
a.start();
|
||||||
@@ -86,7 +86,7 @@ public class JavaProcessMonitor {
|
|||||||
for (Thread a : al)
|
for (Thread a : al)
|
||||||
a.interrupt();
|
a.interrupt();
|
||||||
al.clear();
|
al.clear();
|
||||||
HMCLAPI.EVENT_BUS.fireChannel(new JavaProcessStoppedEvent(this, p));
|
HMCAPI.EVENT_BUS.fireChannel(new JavaProcessStoppedEvent(this, p));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user