Fixed compile errors in HMCSM
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
*/
|
||||
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.util.C;
|
||||
import org.jackhuang.hellominecraft.util.task.TaskWindow;
|
||||
@@ -62,6 +62,6 @@ public enum DownloadType {
|
||||
}
|
||||
|
||||
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.util.HashSet;
|
||||
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.launcher.api.event.launch.DecompressLibrariesEvent;
|
||||
import org.jackhuang.hellominecraft.launcher.api.event.launch.DownloadLibrariesEvent;
|
||||
@@ -44,7 +44,7 @@ public class DefaultGameLauncher extends GameLauncher {
|
||||
}
|
||||
|
||||
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;
|
||||
final TaskWindow.TaskWindowFactory dw = TaskWindow.factory();
|
||||
ParallelTask parallelTask = new ParallelTask();
|
||||
@@ -63,7 +63,7 @@ public class DefaultGameLauncher extends GameLauncher {
|
||||
flag = true;
|
||||
t.setResult(flag);
|
||||
});
|
||||
HMCLAPI.EVENT_BUS.channel(DecompressLibrariesEvent.class).register(t -> {
|
||||
HMCAPI.EVENT_BUS.channel(DecompressLibrariesEvent.class).register(t -> {
|
||||
if (t.getValue() == null) {
|
||||
t.setResult(false);
|
||||
return;
|
||||
|
||||
@@ -23,7 +23,7 @@ import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStreamWriter;
|
||||
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.DecompressLibraryJob;
|
||||
import org.jackhuang.hellominecraft.launcher.api.event.launch.DownloadLibrariesEvent;
|
||||
@@ -90,7 +90,7 @@ public class GameLauncher {
|
||||
public void makeLaunchCommand() throws AuthenticationException, GameException, RuntimeGameException {
|
||||
HMCLog.log("Building process");
|
||||
HMCLog.log("Logging in...");
|
||||
HMCLAPI.EVENT_BUS.fireChannel(new LaunchingStateChangedEvent(this, LaunchingState.LoggingIn));
|
||||
HMCAPI.EVENT_BUS.fireChannel(new LaunchingStateChangedEvent(this, LaunchingState.LoggingIn));
|
||||
IMinecraftLoader loader;
|
||||
if (info != null)
|
||||
result = login.login(info);
|
||||
@@ -98,9 +98,9 @@ public class GameLauncher {
|
||||
result = login.loginBySettings();
|
||||
if (result == 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);
|
||||
|
||||
File file = service.version().getDecompressNativesToLocation(loader.getMinecraftVersion());
|
||||
@@ -109,18 +109,18 @@ public class GameLauncher {
|
||||
|
||||
if (!options.isNotCheckGame()) {
|
||||
HMCLog.log("Detecting libraries...");
|
||||
HMCLAPI.EVENT_BUS.fireChannel(new LaunchingStateChangedEvent(this, LaunchingState.DownloadingLibraries));
|
||||
if (!HMCLAPI.EVENT_BUS.fireChannelResulted(new DownloadLibrariesEvent(this, service.download().getDownloadLibraries(loader.getMinecraftVersion()))))
|
||||
HMCAPI.EVENT_BUS.fireChannel(new LaunchingStateChangedEvent(this, LaunchingState.DownloadingLibraries));
|
||||
if (!HMCAPI.EVENT_BUS.fireChannelResulted(new DownloadLibrariesEvent(this, service.download().getDownloadLibraries(loader.getMinecraftVersion()))))
|
||||
throw new GameException("Failed to download libraries");
|
||||
}
|
||||
|
||||
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());
|
||||
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");
|
||||
|
||||
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());
|
||||
JavaProcess jp = new JavaProcess(str, builder.start(), PROCESS_MANAGER);
|
||||
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.util.ArrayList;
|
||||
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.util.sys.OS;
|
||||
import org.jackhuang.hellominecraft.util.sys.Platform;
|
||||
@@ -108,7 +108,7 @@ public class MinecraftLibrary extends IMinecraftLibrary {
|
||||
if (info == null)
|
||||
return null;
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
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.RefreshedVersionsEvent;
|
||||
import org.jackhuang.hellominecraft.launcher.api.event.version.RefreshingVersionsEvent;
|
||||
@@ -72,7 +72,7 @@ public class MinecraftVersionManager extends IMinecraftProvider {
|
||||
|
||||
@Override
|
||||
public synchronized void refreshVersions() {
|
||||
HMCLAPI.EVENT_BUS.fireChannel(new RefreshingVersionsEvent(this, service));
|
||||
HMCAPI.EVENT_BUS.fireChannel(new RefreshingVersionsEvent(this, service));
|
||||
|
||||
try {
|
||||
MCUtils.tryWriteProfile(service.baseDirectory());
|
||||
@@ -142,12 +142,12 @@ public class MinecraftVersionManager extends IMinecraftProvider {
|
||||
}
|
||||
|
||||
versions.put(id, mcVersion);
|
||||
HMCLAPI.EVENT_BUS.fireChannel(new LoadedOneVersionEvent(this, id));
|
||||
HMCAPI.EVENT_BUS.fireChannel(new LoadedOneVersionEvent(this, id));
|
||||
} catch (Exception 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
|
||||
|
||||
@@ -27,7 +27,7 @@ import java.util.TreeMap;
|
||||
import java.util.UUID;
|
||||
import org.jackhuang.hellominecraft.launcher.core.auth.IAuthenticator;
|
||||
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.DownloadTypeChangedEvent;
|
||||
import org.jackhuang.hellominecraft.launcher.api.event.config.ThemeChangedEvent;
|
||||
@@ -92,7 +92,7 @@ public final class Config implements Cloneable {
|
||||
|
||||
public void setTheme(int theme) {
|
||||
this.theme = theme;
|
||||
HMCLAPI.EVENT_BUS.fireChannel(new ThemeChangedEvent(this, getTheme()));
|
||||
HMCAPI.EVENT_BUS.fireChannel(new ThemeChangedEvent(this, getTheme()));
|
||||
Settings.save();
|
||||
}
|
||||
|
||||
@@ -182,7 +182,7 @@ public final class Config implements Cloneable {
|
||||
if (logintype < 0 || logintype >= IAuthenticator.LOGINS.size())
|
||||
return;
|
||||
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();
|
||||
}
|
||||
|
||||
@@ -192,7 +192,7 @@ public final class Config implements Cloneable {
|
||||
|
||||
public void setDownloadType(int downloadtype) {
|
||||
this.downloadtype = downloadtype;
|
||||
HMCLAPI.EVENT_BUS.fireChannel(new DownloadTypeChangedEvent(this, getDownloadSource()));
|
||||
HMCAPI.EVENT_BUS.fireChannel(new DownloadTypeChangedEvent(this, getDownloadSource()));
|
||||
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.download.DownloadType;
|
||||
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.ProfileLoadingEvent;
|
||||
import org.jackhuang.hellominecraft.util.sys.FileUtils;
|
||||
@@ -161,12 +161,12 @@ public final class Settings {
|
||||
Profile p = getLastProfile();
|
||||
if (p == null)
|
||||
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();
|
||||
}
|
||||
|
||||
public static void onProfileLoading() {
|
||||
HMCLAPI.EVENT_BUS.fireChannel(new ProfileLoadingEvent(SETTINGS));
|
||||
HMCAPI.EVENT_BUS.fireChannel(new ProfileLoadingEvent(SETTINGS));
|
||||
onProfileChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ import javax.swing.event.ChangeEvent;
|
||||
import javax.swing.event.ChangeListener;
|
||||
import javax.swing.event.TableModelEvent;
|
||||
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.ProfileLoadingEvent;
|
||||
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];
|
||||
|
||||
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 (!showedNoVersion && Settings.getLastProfile().service().checkingModpack) {
|
||||
showedNoVersion = true;
|
||||
@@ -123,9 +123,9 @@ public final class GameSettingsPanel extends RepaintPage implements DropTargetLi
|
||||
cboJava.addItem(j.getLocalizedName());
|
||||
isLoading = false;
|
||||
|
||||
HMCLAPI.EVENT_BUS.channel(ProfileLoadingEvent.class).register(onLoadingProfiles);
|
||||
HMCLAPI.EVENT_BUS.channel(ProfileChangedEvent.class).register(onSelectedProfilesChanged);
|
||||
HMCLAPI.EVENT_BUS.channel(RefreshedVersionsEvent.class).register(onRefreshedVersions);
|
||||
HMCAPI.EVENT_BUS.channel(ProfileLoadingEvent.class).register(onLoadingProfiles);
|
||||
HMCAPI.EVENT_BUS.channel(ProfileChangedEvent.class).register(onSelectedProfilesChanged);
|
||||
HMCAPI.EVENT_BUS.channel(RefreshedVersionsEvent.class).register(onRefreshedVersions);
|
||||
}
|
||||
|
||||
void initExplorationMenu() {
|
||||
|
||||
@@ -20,7 +20,7 @@ package org.jackhuang.hellominecraft.launcher.ui;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
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.JavaProcessExitedAbnormallyEvent;
|
||||
import org.jackhuang.hellominecraft.api.event.process.JavaProcessStoppedEvent;
|
||||
@@ -49,8 +49,8 @@ import org.jackhuang.hellominecraft.util.net.WebFrame;
|
||||
public class LaunchingUIDaemon {
|
||||
|
||||
public LaunchingUIDaemon() {
|
||||
HMCLAPI.EVENT_BUS.channel(LaunchingStateChangedEvent.class).register(LAUNCHING_STATE_CHANGED);
|
||||
HMCLAPI.EVENT_BUS.channel(LaunchEvent.class).register(p -> {
|
||||
HMCAPI.EVENT_BUS.channel(LaunchingStateChangedEvent.class).register(LAUNCHING_STATE_CHANGED);
|
||||
HMCAPI.EVENT_BUS.channel(LaunchEvent.class).register(p -> {
|
||||
GameLauncher obj = (GameLauncher) p.getSource();
|
||||
HMCLGameLauncher.GameLauncherTag tag = (HMCLGameLauncher.GameLauncherTag) obj.getTag();
|
||||
if (tag.launcherVisibility == LauncherVisibility.CLOSE && !LogWindow.INSTANCE.isVisible()) {
|
||||
@@ -69,15 +69,15 @@ public class LaunchingUIDaemon {
|
||||
monitor.setTag(tag.launcherVisibility);
|
||||
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;
|
||||
if (state == 1)
|
||||
LAUNCH_FINISHER.accept(p);
|
||||
else if (state == 2)
|
||||
LAUNCH_SCRIPT_FINISHER.accept(p);
|
||||
});
|
||||
HMCLAPI.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(JavaProcessStoppedEvent.class).register(event -> checkExit((LauncherVisibility) ((JavaProcessMonitor) event.getSource()).getTag()));
|
||||
HMCAPI.EVENT_BUS.channel(JavaProcessExitedAbnormallyEvent.class).register(event -> {
|
||||
int exitCode = event.getValue().getExitCode();
|
||||
HMCLog.err("The game exited abnormally, exit code: " + exitCode);
|
||||
String[] logs = event.getValue().getStdOutLines().toArray(new String[0]);
|
||||
@@ -98,7 +98,7 @@ public class LaunchingUIDaemon {
|
||||
f.setVisible(true);
|
||||
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();
|
||||
HMCLog.err("Cannot create jvm, exit code: " + exitCode);
|
||||
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.JPanel;
|
||||
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.api.PluginManager;
|
||||
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);
|
||||
|
||||
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"));
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ import javax.swing.DefaultComboBoxModel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.SwingUtilities;
|
||||
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.ProfileChangedEvent;
|
||||
import org.jackhuang.hellominecraft.launcher.api.event.config.ProfileLoadingEvent;
|
||||
@@ -97,12 +97,12 @@ public class MainPagePanel extends Page {
|
||||
|
||||
((RepaintPage) pnlMore).setRepainter(pnlRoot);
|
||||
|
||||
HMCLAPI.EVENT_BUS.channel(AuthenticatorChangedEvent.class).register(onAuthChanged);
|
||||
HMCLAPI.EVENT_BUS.channel(ProfileLoadingEvent.class).register(onLoadingProfiles);
|
||||
HMCLAPI.EVENT_BUS.channel(ProfileChangedEvent.class).register(onSelectedProfilesChanged);
|
||||
HMCLAPI.EVENT_BUS.channel(RefreshedVersionsEvent.class).register(onRefreshedVersions);
|
||||
HMCLAPI.EVENT_BUS.channel(LaunchingStateChangedEvent.class).register(launchingStateChanged);
|
||||
HMCLAPI.EVENT_BUS.channel(LaunchSucceededEvent.class).register(this::prepareAuths);
|
||||
HMCAPI.EVENT_BUS.channel(AuthenticatorChangedEvent.class).register(onAuthChanged);
|
||||
HMCAPI.EVENT_BUS.channel(ProfileLoadingEvent.class).register(onLoadingProfiles);
|
||||
HMCAPI.EVENT_BUS.channel(ProfileChangedEvent.class).register(onSelectedProfilesChanged);
|
||||
HMCAPI.EVENT_BUS.channel(RefreshedVersionsEvent.class).register(onRefreshedVersions);
|
||||
HMCAPI.EVENT_BUS.channel(LaunchingStateChangedEvent.class).register(launchingStateChanged);
|
||||
HMCAPI.EVENT_BUS.channel(LaunchSucceededEvent.class).register(this::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.Settings;
|
||||
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.LaunchingState;
|
||||
import org.jackhuang.hellominecraft.launcher.api.event.launch.LaunchingStateChangedEvent;
|
||||
@@ -50,12 +50,12 @@ public class HMCLGameLauncher {
|
||||
public HMCLGameLauncher(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) {
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ public class HMCLGameLauncher {
|
||||
Thread.currentThread().setName("Game Launcher");
|
||||
try {
|
||||
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);
|
||||
GameLauncherTag tag = new GameLauncherTag();
|
||||
tag.launcherVisibility = profile.getSelectedVersionSetting().getLauncherVisibility();
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
package org.jackhuang.hellominecraft.launcher.util;
|
||||
|
||||
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.core.version.GameDirType;
|
||||
import org.jackhuang.hellominecraft.launcher.core.version.MinecraftVersionManager;
|
||||
@@ -34,7 +34,7 @@ public class HMCLGameProvider extends MinecraftVersionManager {
|
||||
public HMCLGameProvider(HMCLMinecraftService p) {
|
||||
super(p);
|
||||
|
||||
HMCLAPI.EVENT_BUS.channel(MinecraftLibraryPathEvent.class).register(t -> {
|
||||
HMCAPI.EVENT_BUS.channel(MinecraftLibraryPathEvent.class).register(t -> {
|
||||
if (!t.getFile().getValue().exists())
|
||||
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.Map;
|
||||
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.RefreshedVersionsEvent;
|
||||
import org.jackhuang.hellominecraft.launcher.api.event.version.RefreshingVersionsEvent;
|
||||
@@ -57,8 +57,8 @@ public class HMCLMinecraftService extends IMinecraftService {
|
||||
this.p = p;
|
||||
this.provider = new HMCLGameProvider(this);
|
||||
provider.initializeMiencraft();
|
||||
HMCLAPI.EVENT_BUS.channel(RefreshingVersionsEvent.class).register(versionSettings::clear);
|
||||
HMCLAPI.EVENT_BUS.channel(RefreshedVersionsEvent.class).registerFirst(() -> {
|
||||
HMCAPI.EVENT_BUS.channel(RefreshingVersionsEvent.class).register(versionSettings::clear);
|
||||
HMCAPI.EVENT_BUS.channel(RefreshedVersionsEvent.class).registerFirst(() -> {
|
||||
if (!checkingModpack) {
|
||||
checkingModpack = true;
|
||||
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.mds = new MinecraftDownloadService(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.regex.Matcher;
|
||||
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.sys.IOUtils;
|
||||
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.WaitForThread;
|
||||
import org.jackhuang.hellominecraft.svrmgr.util.Utilities;
|
||||
import org.jackhuang.hellominecraft.api.Event;
|
||||
import org.jackhuang.hellominecraft.api.EventHandler;
|
||||
import org.jackhuang.hellominecraft.svrmgr.api.ServerStartedEvent;
|
||||
import org.jackhuang.hellominecraft.svrmgr.api.ServerStoppedEvent;
|
||||
import org.jackhuang.hellominecraft.util.code.Charsets;
|
||||
import org.jackhuang.hellominecraft.util.func.Consumer;
|
||||
|
||||
@@ -53,7 +55,7 @@ import org.jackhuang.hellominecraft.util.func.Consumer;
|
||||
*
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public class Server implements Event<Integer>, MonitorThread.MonitorThreadListener,
|
||||
public class Server implements Consumer<SimpleEvent<Integer>>, MonitorThread.MonitorThreadListener,
|
||||
ActionListener {
|
||||
|
||||
private static Server instance;
|
||||
@@ -77,9 +79,7 @@ public class Server implements Event<Integer>, MonitorThread.MonitorThreadListen
|
||||
WaitForThread threadC;
|
||||
Consumer<Pair<String, String[]>> gettingPlayerNumber;
|
||||
ArrayList<MonitorThread.MonitorThreadListener> listeners;
|
||||
ArrayList<Event<Integer>> listenersC;
|
||||
//ArrayList<DoneListener0> listenersBegin, listenersDone;
|
||||
public final EventHandler<Void> startedEvent = new EventHandler<>(this), stoppedEvent = new EventHandler<>(this);
|
||||
ArrayList<Consumer<SimpleEvent<Integer>>> listenersC;
|
||||
ArrayList<TimerTask> timerTasks;
|
||||
ArrayList<Schedule> schedules;
|
||||
BufferedWriter bw;
|
||||
@@ -103,7 +103,7 @@ public class Server implements Event<Integer>, MonitorThread.MonitorThreadListen
|
||||
listeners.add(l);
|
||||
}
|
||||
|
||||
public void addListener(Event<Integer> l) {
|
||||
public void addListener(Consumer<SimpleEvent<Integer>> l) {
|
||||
listenersC.add(l);
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ public class Server implements Event<Integer>, MonitorThread.MonitorThreadListen
|
||||
registerThreadC(server);
|
||||
bw = new BufferedWriter(new OutputStreamWriter(server.getOutputStream(), Charsets.toCharset()));
|
||||
isRunning = true;
|
||||
startedEvent.fire(null);
|
||||
HMCAPI.EVENT_BUS.fireChannel(new ServerStartedEvent(this));
|
||||
sendStatus("*** 启动服务端中 ***");
|
||||
} catch (IOException 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) {
|
||||
threadC = new WaitForThread(p);
|
||||
for (Event<Integer> l : listenersC)
|
||||
for (Consumer<SimpleEvent<Integer>> l : listenersC)
|
||||
threadC.event.register(l);
|
||||
threadC.event.register(this);
|
||||
threadC.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean call(Object sender, Integer t) {
|
||||
public void accept(SimpleEvent<Integer> event) {
|
||||
int t = event.getValue();
|
||||
if (t == 0) {
|
||||
sendStatus("*** 服务端已停止 ***");
|
||||
System.out.println("Server stopped successfully");
|
||||
@@ -236,7 +237,6 @@ public class Server implements Event<Integer>, MonitorThread.MonitorThreadListen
|
||||
}
|
||||
isRestart = false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
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 \"\\?\"");
|
||||
Matcher m = p.matcher(status);
|
||||
if (m.find()) {
|
||||
stoppedEvent.fire(null);
|
||||
HMCAPI.EVENT_BUS.fireChannel(new ServerStoppedEvent(this));
|
||||
timer = new Timer();
|
||||
timerTasks.clear();
|
||||
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.svrmgr.util.version.MinecraftRemoteVersion;
|
||||
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.func.Consumer;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author huangyuhui
|
||||
*/
|
||||
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"));
|
||||
JLabel backgroundLabel;
|
||||
@@ -134,7 +138,7 @@ public final class MainWindow extends javax.swing.JFrame
|
||||
|
||||
Dimension scrSize = Toolkit.getDefaultToolkit().getScreenSize();
|
||||
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());
|
||||
|
||||
@@ -2711,18 +2715,18 @@ public final class MainWindow extends javax.swing.JFrame
|
||||
cboDifficulty.setSelectedIndex(sp.getPropertyInt("difficulty", 1));
|
||||
String wt = sp.getProperty("level-type");
|
||||
switch (wt) {
|
||||
case "LARGEBIOMES":
|
||||
cboWorldType.setSelectedIndex(2);
|
||||
break;
|
||||
case "FLAT":
|
||||
cboWorldType.setSelectedIndex(1);
|
||||
break;
|
||||
case "DEFAULT":
|
||||
cboWorldType.setSelectedIndex(0);
|
||||
break;
|
||||
default:
|
||||
cboWorldType.setSelectedIndex(0);
|
||||
break;
|
||||
case "LARGEBIOMES":
|
||||
cboWorldType.setSelectedIndex(2);
|
||||
break;
|
||||
case "FLAT":
|
||||
cboWorldType.setSelectedIndex(1);
|
||||
break;
|
||||
case "DEFAULT":
|
||||
cboWorldType.setSelectedIndex(0);
|
||||
break;
|
||||
default:
|
||||
cboWorldType.setSelectedIndex(0);
|
||||
break;
|
||||
}
|
||||
txtMaxPlayer.setValue(sp.getPropertyInt("max-players", 20));
|
||||
chkAllowFlight.setSelected(sp.getPropertyBoolean("allow-flight", false));
|
||||
@@ -2785,7 +2789,7 @@ public final class MainWindow extends javax.swing.JFrame
|
||||
while (model.getRowCount() > 0)
|
||||
model.removeRow(0);
|
||||
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();
|
||||
}
|
||||
@@ -2798,14 +2802,14 @@ public final class MainWindow extends javax.swing.JFrame
|
||||
while (model.getRowCount() > 0)
|
||||
model.removeRow(0);
|
||||
IOUtils.findAllFile(new File(path), s -> {
|
||||
PluginInformation p = PluginManager.getPluginYML(new File(Utilities.getGameDir() + "plugins" + File.separator + s));
|
||||
if (p == null)
|
||||
model.addRow(new Object[] { !SettingsManager.settings.inactivePlugins.contains(s), s,
|
||||
"", "", "", "" });
|
||||
else
|
||||
model.addRow(new Object[] { !SettingsManager.settings.inactivePlugins.contains(s), s,
|
||||
p.name, p.version, p.author, p.description });
|
||||
});
|
||||
PluginInformation p = PluginManager.getPluginYML(new File(Utilities.getGameDir() + "plugins" + File.separator + s));
|
||||
if (p == null)
|
||||
model.addRow(new Object[] { !SettingsManager.settings.inactivePlugins.contains(s), s,
|
||||
"", "", "", "" });
|
||||
else
|
||||
model.addRow(new Object[] { !SettingsManager.settings.inactivePlugins.contains(s), s,
|
||||
p.name, p.version, p.author, p.description });
|
||||
});
|
||||
|
||||
lstPlugins.updateUI();
|
||||
}
|
||||
@@ -2818,7 +2822,7 @@ public final class MainWindow extends javax.swing.JFrame
|
||||
while (model.getRowCount() > 0)
|
||||
model.removeRow(0);
|
||||
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();
|
||||
}
|
||||
@@ -2865,32 +2869,32 @@ public final class MainWindow extends javax.swing.JFrame
|
||||
return;
|
||||
BukkitFormatThread thread;
|
||||
switch (idx) {
|
||||
case 1:
|
||||
thread = new BukkitFormatThread(
|
||||
"http://dl.bukkit.org/downloads/craftbukkit/list/beta/", value -> {
|
||||
craftBukkitBeta = value;
|
||||
reloadBukkitList();
|
||||
});
|
||||
thread.start();
|
||||
break;
|
||||
case 0:
|
||||
thread = new BukkitFormatThread(
|
||||
"http://dl.bukkit.org/downloads/craftbukkit/list/rb/", value -> {
|
||||
craftBukkitRecommended = value;
|
||||
reloadBukkitList();
|
||||
});
|
||||
thread.start();
|
||||
break;
|
||||
case 2:
|
||||
thread = new BukkitFormatThread(
|
||||
"http://dl.bukkit.org/downloads/craftbukkit/list/dev/", value -> {
|
||||
craftBukkitDev = value;
|
||||
reloadBukkitList();
|
||||
});
|
||||
thread.start();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
case 1:
|
||||
thread = new BukkitFormatThread(
|
||||
"http://dl.bukkit.org/downloads/craftbukkit/list/beta/", value -> {
|
||||
craftBukkitBeta = value;
|
||||
reloadBukkitList();
|
||||
});
|
||||
thread.start();
|
||||
break;
|
||||
case 0:
|
||||
thread = new BukkitFormatThread(
|
||||
"http://dl.bukkit.org/downloads/craftbukkit/list/rb/", value -> {
|
||||
craftBukkitRecommended = value;
|
||||
reloadBukkitList();
|
||||
});
|
||||
thread.start();
|
||||
break;
|
||||
case 2:
|
||||
thread = new BukkitFormatThread(
|
||||
"http://dl.bukkit.org/downloads/craftbukkit/list/dev/", value -> {
|
||||
craftBukkitDev = value;
|
||||
reloadBukkitList();
|
||||
});
|
||||
thread.start();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2932,17 +2936,17 @@ public final class MainWindow extends javax.swing.JFrame
|
||||
if (idx == -1)
|
||||
return;
|
||||
switch (idx) {
|
||||
case 1:
|
||||
useBukkitVersions(craftBukkitBeta);
|
||||
break;
|
||||
case 0:
|
||||
useBukkitVersions(craftBukkitRecommended);
|
||||
break;
|
||||
case 2:
|
||||
useBukkitVersions(craftBukkitDev);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
case 1:
|
||||
useBukkitVersions(craftBukkitBeta);
|
||||
break;
|
||||
case 0:
|
||||
useBukkitVersions(craftBukkitRecommended);
|
||||
break;
|
||||
case 2:
|
||||
useBukkitVersions(craftBukkitDev);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3095,25 +3099,24 @@ public final class MainWindow extends javax.swing.JFrame
|
||||
MessageBox.show("服务器未开启!");
|
||||
}
|
||||
|
||||
class ServerBeginListener implements Event<Void> {
|
||||
class ServerBeginListener implements Runnable {
|
||||
|
||||
@Override
|
||||
public boolean call(Object sender, Void v) {
|
||||
public void run() {
|
||||
commandSet = new ArrayList<>();
|
||||
txtMain.setText("");
|
||||
btnLaunch.setEnabled(false);
|
||||
btnStop.setEnabled(true);
|
||||
btnShutdown.setEnabled(true);
|
||||
btnCommand.setEnabled(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class ServerDoneListener implements Event<Void> {
|
||||
class ServerDoneListener implements Runnable {
|
||||
|
||||
@Override
|
||||
public boolean call(Object sender, Void v) {
|
||||
public void run() {
|
||||
getPlayerNumberTimer = new Timer();
|
||||
getPlayerNumberTimer.schedule(new TimerTask() {
|
||||
|
||||
@@ -3122,7 +3125,6 @@ public final class MainWindow extends javax.swing.JFrame
|
||||
loadPlayers();
|
||||
}
|
||||
}, 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.getInstance()
|
||||
.addListener((MonitorThread.MonitorThreadListener) this);
|
||||
.addListener((MonitorThread.MonitorThreadListener) this);
|
||||
Server.getInstance()
|
||||
.addListener((Event<Integer>) this);
|
||||
.addListener((Consumer<SimpleEvent<Integer>>) this);
|
||||
Server.getInstance()
|
||||
.clearSchedule();
|
||||
.clearSchedule();
|
||||
for (Schedule s : SettingsManager.settings.schedules)
|
||||
Server.getInstance().addSchedule(s);
|
||||
|
||||
Server.getInstance().startedEvent.register(new ServerBeginListener());
|
||||
Server.getInstance().startedEvent.register(new ServerDoneListener());
|
||||
HMCAPI.EVENT_BUS.channel(ServerStartedEvent.class).register(new ServerBeginListener());
|
||||
HMCAPI.EVENT_BUS.channel(ServerStoppedEvent.class).register(new ServerDoneListener());
|
||||
try {
|
||||
Server.getInstance().run();
|
||||
} catch (IOException ex) {
|
||||
@@ -3184,19 +3186,19 @@ public final class MainWindow extends javax.swing.JFrame
|
||||
int newCommandIndex = commandIndex;
|
||||
int type = 0;
|
||||
switch (evt.getKeyCode()) {
|
||||
case KeyEvent.VK_UP:
|
||||
newCommandIndex--;
|
||||
type = 1;
|
||||
break;
|
||||
case KeyEvent.VK_DOWN:
|
||||
newCommandIndex++;
|
||||
type = 1;
|
||||
break;
|
||||
case KeyEvent.VK_ENTER:
|
||||
type = 2;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
case KeyEvent.VK_UP:
|
||||
newCommandIndex--;
|
||||
type = 1;
|
||||
break;
|
||||
case KeyEvent.VK_DOWN:
|
||||
newCommandIndex++;
|
||||
type = 1;
|
||||
break;
|
||||
case KeyEvent.VK_ENTER:
|
||||
type = 2;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (type == 1) {
|
||||
if (outOfCommandSet(newCommandIndex))
|
||||
@@ -3290,17 +3292,17 @@ public final class MainWindow extends javax.swing.JFrame
|
||||
int OAO = cboWorldType.getSelectedIndex();
|
||||
String type = "DEFAULT";
|
||||
switch (OAO) {
|
||||
case 0:
|
||||
type = "DEFAULT";
|
||||
break;
|
||||
case 1:
|
||||
type = "FLAT";
|
||||
break;
|
||||
case 2:
|
||||
type = "LARGEBIMOES";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
case 0:
|
||||
type = "DEFAULT";
|
||||
break;
|
||||
case 1:
|
||||
type = "FLAT";
|
||||
break;
|
||||
case 2:
|
||||
type = "LARGEBIMOES";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
ServerProperties.getInstance().setLevelType(type);
|
||||
}//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
|
||||
switch (cboBackupTypes.getSelectedIndex()) {
|
||||
case 0:
|
||||
BackupManager.backupAllWorlds();
|
||||
break;
|
||||
case 1:
|
||||
BackupManager.backupAllPlugins();
|
||||
break;
|
||||
case 0:
|
||||
BackupManager.backupAllWorlds();
|
||||
break;
|
||||
case 1:
|
||||
BackupManager.backupAllPlugins();
|
||||
break;
|
||||
}
|
||||
}//GEN-LAST:event_btnBackupActionPerformed
|
||||
|
||||
@@ -3687,9 +3689,9 @@ public final class MainWindow extends javax.swing.JFrame
|
||||
File getBackupFile(int index) {
|
||||
DefaultTableModel model = (DefaultTableModel) lstBackups.getModel();
|
||||
return new File(BackupManager.backupDir()
|
||||
+ model.getValueAt(index, 0) + "+"
|
||||
+ model.getValueAt(index, 1) + "+"
|
||||
+ model.getValueAt(index, 2) + ".zip");
|
||||
+ model.getValueAt(index, 0) + "+"
|
||||
+ model.getValueAt(index, 1) + "+"
|
||||
+ model.getValueAt(index, 2) + ".zip");
|
||||
}
|
||||
|
||||
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
|
||||
IOUtils.findAllFile(new File("."), s -> {
|
||||
if (ServerChecker.isServerJar(new File(s))) {
|
||||
String path = IOUtils.tryGetCanonicalFilePath(new File(s));
|
||||
txtMainJar.setText(path);
|
||||
SettingsManager.settings.mainjar = path;
|
||||
SettingsManager.save();
|
||||
}
|
||||
});
|
||||
if (ServerChecker.isServerJar(new File(s))) {
|
||||
String path = IOUtils.tryGetCanonicalFilePath(new File(s));
|
||||
txtMainJar.setText(path);
|
||||
SettingsManager.settings.mainjar = path;
|
||||
SettingsManager.save();
|
||||
}
|
||||
});
|
||||
}//GEN-LAST:event_btnAutoSearchActionPerformed
|
||||
|
||||
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)
|
||||
return;
|
||||
switch (idx2) {
|
||||
case 0:
|
||||
ext = "rb";
|
||||
cb = craftBukkitRecommended;
|
||||
break;
|
||||
case 1:
|
||||
ext = "beta";
|
||||
cb = craftBukkitBeta;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
case 0:
|
||||
ext = "rb";
|
||||
cb = craftBukkitRecommended;
|
||||
break;
|
||||
case 1:
|
||||
ext = "beta";
|
||||
cb = craftBukkitBeta;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
BukkitVersion v = cb.get(idx);
|
||||
File file = new File("craftbukkit-" + ext + "-" + v.version + ".jar");
|
||||
TaskWindow.factory().append(new FileDownloadTask(v.downloadLink, IOUtils.tryGetCanonicalFile(file)).setTag("bukkit-" + ext + "-" + v.version))
|
||||
.execute();
|
||||
.execute();
|
||||
}//GEN-LAST:event_btnDownloadCraftbukkitActionPerformed
|
||||
|
||||
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
|
||||
public boolean call(Object sender, Integer t) {
|
||||
public void accept(SimpleEvent<Integer> event) {
|
||||
btnLaunch.setEnabled(true);
|
||||
btnStop.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");
|
||||
try {
|
||||
FileUtils.write(new File(Utilities.getGameDir() + "infos-HMCSM"
|
||||
+ File.separator + format.format(new Date()) + ".txt"),
|
||||
txtMain.getText());
|
||||
+ File.separator + format.format(new Date()) + ".txt"),
|
||||
txtMain.getText());
|
||||
} catch (IOException ex) {
|
||||
HMCLog.warn("Failed to save info", ex);
|
||||
}
|
||||
@@ -3973,7 +3975,6 @@ public final class MainWindow extends javax.swing.JFrame
|
||||
getPlayerNumberTimer.cancel();
|
||||
getPlayerNumberTimer = null;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void sendCommand() {
|
||||
@@ -3999,10 +4000,10 @@ public final class MainWindow extends javax.swing.JFrame
|
||||
|
||||
MonitorThread mainThread;
|
||||
DefaultListModel lstOPModel = new DefaultListModel(),
|
||||
lstWhiteListModel = new DefaultListModel(),
|
||||
lstBannedModel = new DefaultListModel(),
|
||||
lstCrashReportsModel = new DefaultListModel(),
|
||||
lstPlayersModel = new DefaultListModel();
|
||||
lstWhiteListModel = new DefaultListModel(),
|
||||
lstBannedModel = new DefaultListModel(),
|
||||
lstCrashReportsModel = new DefaultListModel(),
|
||||
lstPlayersModel = new DefaultListModel();
|
||||
List<BukkitPlugin> plugins;
|
||||
Map<String, List<ForgeVersion>> mcpcPackages;
|
||||
List<BukkitVersion> craftBukkitRecommended, craftBukkitBeta, craftBukkitDev;
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
package org.jackhuang.hellominecraft.svrmgr.util;
|
||||
|
||||
import org.jackhuang.hellominecraft.api.EventHandler;
|
||||
import org.jackhuang.hellominecraft.api.SimpleEvent;
|
||||
import org.jackhuang.hellominecraft.util.log.HMCLog;
|
||||
|
||||
/**
|
||||
@@ -26,7 +27,7 @@ import org.jackhuang.hellominecraft.util.log.HMCLog;
|
||||
*/
|
||||
public class WaitForThread extends Thread {
|
||||
|
||||
public final EventHandler<Integer> event = new EventHandler<>(this);
|
||||
public final EventHandler<SimpleEvent<Integer>> event = new EventHandler<>();
|
||||
Process p;
|
||||
|
||||
public WaitForThread(Process p) {
|
||||
@@ -37,10 +38,10 @@ public class WaitForThread extends Thread {
|
||||
public void run() {
|
||||
try {
|
||||
int exitCode = p.waitFor();
|
||||
event.fire(exitCode);
|
||||
event.fire(new SimpleEvent<>(this, exitCode));
|
||||
} catch (InterruptedException 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
|
||||
*/
|
||||
public class HMCLAPI {
|
||||
public class HMCAPI {
|
||||
|
||||
/**
|
||||
* Events.
|
||||
@@ -23,7 +23,7 @@ import com.google.gson.JsonSyntaxException;
|
||||
import java.io.IOException;
|
||||
import org.jackhuang.hellominecraft.util.log.HMCLog;
|
||||
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.event.OutOfDateEvent;
|
||||
|
||||
@@ -98,7 +98,7 @@ public final class UpdateChecker implements IUpdateChecker {
|
||||
@Override
|
||||
public void checkOutdate() {
|
||||
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()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import org.jackhuang.hellominecraft.util.CollectionUtils;
|
||||
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.JavaProcessExitedAbnormallyEvent;
|
||||
import org.jackhuang.hellominecraft.api.event.process.JavaProcessStartingEvent;
|
||||
@@ -59,21 +59,21 @@ public class JavaProcessMonitor {
|
||||
|
||||
|
||||
public void start() {
|
||||
HMCLAPI.EVENT_BUS.fireChannel(new JavaProcessStartingEvent(this, p));
|
||||
HMCAPI.EVENT_BUS.fireChannel(new JavaProcessStartingEvent(this, p));
|
||||
ProcessThread a = new ProcessThread(p);
|
||||
a.stopEvent.register(event -> {
|
||||
HMCLog.log("Process exit code: " + p.getExitCode());
|
||||
if (p.getExitCode() != 0 || StrUtils.containsOne(p.getStdOutLines(),
|
||||
Arrays.asList("Unable to launch"),
|
||||
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(),
|
||||
Arrays.asList("Could not create the Java Virtual Machine.",
|
||||
"Error occurred during initialization of VM",
|
||||
"A fatal exception has occurred. Program will exit.",
|
||||
"Unable to launch"),
|
||||
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);
|
||||
});
|
||||
a.start();
|
||||
@@ -86,7 +86,7 @@ public class JavaProcessMonitor {
|
||||
for (Thread a : al)
|
||||
a.interrupt();
|
||||
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