mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-03-31 18:10:26 +08:00
Fixed Issue #1 & Added proxy support
This commit is contained in:
parent
7bfe7c3432
commit
e5621d1a58
@ -89,13 +89,13 @@ task proguard(type: proguard.gradle.ProGuardTask, dependsOn: jar) {
|
||||
launch4j {
|
||||
launch4jCmd = 'D:\\Develop\\Java\\Launch4j\\launch4j.exe'
|
||||
supportUrl = 'http://www.mcbbs.net/thread-142335-1-1.html'
|
||||
jreMinVersion = '1.6.0'
|
||||
jreMinVersion = '1.7.0'
|
||||
|
||||
mainClassName = mainClass
|
||||
icon = new File(project.buildDir, '../icon.ico').absolutePath
|
||||
version = mavenVersion + '.0'
|
||||
downloadUrl = 'http://java.com/download'
|
||||
copyright = "Copyright(c) 2013-2014 huangyuhui."
|
||||
copyright = "Copyright(c) 2013-2015 huangyuhui."
|
||||
|
||||
jar = new File(project.buildDir, 'libs/' + mavenGroupId + '-' + mavenVersion + '.jar').absolutePath
|
||||
outfile = mavenGroupId + '-' + mavenVersion + '.exe'
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 573 KiB |
BIN
HMCL/image/A.jpg
BIN
HMCL/image/A.jpg
Binary file not shown.
Before Width: | Height: | Size: 63 KiB |
Binary file not shown.
Before Width: | Height: | Size: 309 KiB |
Binary file not shown.
Before Width: | Height: | Size: 248 KiB |
Binary file not shown.
Before Width: | Height: | Size: 657 KiB |
Binary file not shown.
Before Width: | Height: | Size: 78 KiB |
@ -1,41 +0,0 @@
|
||||
<launch4jConfig>
|
||||
<dontWrapJar>false</dontWrapJar>
|
||||
<headerType>gui</headerType>
|
||||
<jar>F:\Documents\NetBeansProjects\HMCL\HMCL\build\libs\HMCL-2.1.3.jar</jar>
|
||||
<outfile>F:\Documents\NetBeansProjects\HMCL\HMCL\build\libs\HMCL-2.1.3-Launch4j.exe</outfile>
|
||||
<errTitle></errTitle>
|
||||
<cmdLine></cmdLine>
|
||||
<chdir></chdir>
|
||||
<priority>normal</priority>
|
||||
<downloadUrl>http://java.com/download</downloadUrl>
|
||||
<supportUrl></supportUrl>
|
||||
<stayAlive>false</stayAlive>
|
||||
<manifest></manifest>
|
||||
<icon>F:\Documents\NetBeansProjects\HMCL\HMCL\icon.ico</icon>
|
||||
<jre>
|
||||
<path></path>
|
||||
<bundledJre64Bit>false</bundledJre64Bit>
|
||||
<minVersion>1.6.0</minVersion>
|
||||
<maxVersion></maxVersion>
|
||||
<jdkPreference>preferJre</jdkPreference>
|
||||
</jre>
|
||||
<versionInfo>
|
||||
<fileVersion>2.1.3.0</fileVersion>
|
||||
<txtFileVersion>2.1.3.0</txtFileVersion>
|
||||
<fileDescription>Hello Minecraft! Launcher</fileDescription>
|
||||
<copyright>Copyright(c) 2013~2014 huangyuhui</copyright>
|
||||
<productVersion>2.1.3.0</productVersion>
|
||||
<txtProductVersion>2.1.3.0</txtProductVersion>
|
||||
<productName>Hello Minecraft! Launcher</productName>
|
||||
<companyName></companyName>
|
||||
<internalName>Hello Minecraft! Launcher</internalName>
|
||||
<originalFilename>HMCL-2.1.3.exe</originalFilename>
|
||||
</versionInfo>
|
||||
<messages>
|
||||
<startupErr>启动程序时出现错误</startupErr>
|
||||
<bundledJreErr>未找到内置Java</bundledJreErr>
|
||||
<jreVersionErr>此程序需要Java</jreVersionErr>
|
||||
<launcherErr>未找到Java</launcherErr>
|
||||
<instanceAlreadyExistsMsg>已存在一个程序实例</instanceAlreadyExistsMsg>
|
||||
</messages>
|
||||
</launch4jConfig>
|
6
HMCL/proguard.pro
vendored
6
HMCL/proguard.pro
vendored
@ -1,6 +1,6 @@
|
||||
-libraryjars D:\Develop\Java\jdk1.6.0_45\jre\lib\rt.jar
|
||||
-libraryjars D:\Develop\Java\jdk1.6.0_45\jre\lib\jce.jar
|
||||
-libraryjars D:\Develop\Java\jdk1.6.0_45\jre\lib\jsse.jar
|
||||
-libraryjars <java.home>/lib/rt.jar
|
||||
-libraryjars <java.home>/lib/jce.jar
|
||||
-libraryjars <java.home>/lib/jsse.jar
|
||||
|
||||
-dontoptimize
|
||||
-dontshrink
|
||||
|
@ -22,9 +22,14 @@ import java.awt.datatransfer.StringSelection;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.Authenticator;
|
||||
import java.net.PasswordAuthentication;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.text.ParseException;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.UnsupportedLookAndFeelException;
|
||||
import org.jackhuang.hellominecraft.C;
|
||||
import org.jackhuang.hellominecraft.utils.functions.DoneListener0;
|
||||
import org.jackhuang.hellominecraft.HMCLog;
|
||||
@ -38,6 +43,7 @@ import org.jackhuang.hellominecraft.launcher.utils.settings.Settings;
|
||||
import org.jackhuang.hellominecraft.launcher.views.MainFrame;
|
||||
import org.jackhuang.hellominecraft.lookandfeel.HelloMinecraftLookAndFeel;
|
||||
import org.jackhuang.hellominecraft.utils.MessageBox;
|
||||
import org.jackhuang.hellominecraft.utils.StrUtils;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -90,12 +96,24 @@ public final class Main implements DoneListener0 {
|
||||
|
||||
try {
|
||||
UIManager.setLookAndFeel(new HelloMinecraftLookAndFeel());
|
||||
} catch (Throwable ex) {
|
||||
} catch (ParseException | UnsupportedLookAndFeelException ex) {
|
||||
HMCLog.warn("Failed to set look and feel...", ex);
|
||||
}
|
||||
|
||||
Settings.UPDATE_CHECKER.start();
|
||||
|
||||
if (StrUtils.isNotBlank(Settings.s().getProxyHost()) && StrUtils.isNotBlank(Settings.s().getProxyPort())) {
|
||||
System.setProperty("http.proxyHost", Settings.s().getProxyHost());
|
||||
System.setProperty("http.proxyPort", Settings.s().getProxyPort());
|
||||
if (StrUtils.isNotBlank(Settings.s().getProxyUserName()) && StrUtils.isNotBlank(Settings.s().getProxyPassword()))
|
||||
Authenticator.setDefault(new Authenticator() {
|
||||
@Override
|
||||
protected PasswordAuthentication getPasswordAuthentication() {
|
||||
return new PasswordAuthentication(Settings.s().getProxyUserName(), Settings.s().getProxyPassword().toCharArray());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
MainFrame.showMainFrame(Settings.isFirstLoad());
|
||||
}
|
||||
}
|
||||
@ -111,7 +129,7 @@ public final class Main implements DoneListener0 {
|
||||
MessageBox.YES_NO_OPTION) == MessageBox.YES_OPTION)
|
||||
try {
|
||||
java.awt.Desktop.getDesktop().browse(new URI(C.URL_PUBLISH));
|
||||
} catch (Throwable e) {
|
||||
} catch (URISyntaxException | IOException e) {
|
||||
HMCLog.warn("Failed to browse uri: " + C.URL_PUBLISH, e);
|
||||
|
||||
Clipboard cb = Toolkit.getDefaultToolkit().getSystemClipboard();
|
||||
|
@ -46,8 +46,7 @@ public class DefaultGameLauncher extends GameLauncher {
|
||||
downloadLibrariesEvent.register((sender, t) -> {
|
||||
final TaskWindow dw = TaskWindow.getInstance();
|
||||
ParallelTask parallelTask = new ParallelTask();
|
||||
for (DownloadLibraryJob o : t) {
|
||||
final DownloadLibraryJob s = (DownloadLibraryJob) o;
|
||||
for (DownloadLibraryJob s : t) {
|
||||
parallelTask.addDependsTask(new FileDownloadTask(s.url, s.path).setTag(s.name));
|
||||
}
|
||||
dw.addTask(parallelTask);
|
||||
|
@ -26,7 +26,6 @@ import org.jackhuang.hellominecraft.utils.tinystream.CollectionUtils;
|
||||
import org.jackhuang.hellominecraft.utils.Event;
|
||||
import org.jackhuang.hellominecraft.utils.JavaProcess;
|
||||
import org.jackhuang.hellominecraft.utils.MessageBox;
|
||||
import org.jackhuang.hellominecraft.utils.functions.Predicate;
|
||||
import org.jackhuang.hellominecraft.utils.ProcessThread;
|
||||
import org.jackhuang.hellominecraft.utils.StrUtils;
|
||||
import org.jackhuang.hellominecraft.views.LogWindow;
|
||||
@ -37,57 +36,44 @@ import org.jackhuang.hellominecraft.views.LogWindow;
|
||||
*/
|
||||
public class LaunchFinisher implements Event<List<String>> {
|
||||
|
||||
private final HashSet<Thread> al = new HashSet<Thread>();
|
||||
private final HashSet<Thread> al = new HashSet<>();
|
||||
|
||||
@Override
|
||||
public boolean call(Object sender, List<String> str) {
|
||||
final GameLauncher obj = (GameLauncher) sender;
|
||||
obj.launchEvent.register(new Event<JavaProcess>() {
|
||||
@Override
|
||||
public boolean call(Object sender, JavaProcess p) {
|
||||
if (obj.getProfile().getLauncherVisibility() == 0 && !LogWindow.instance.isVisible())
|
||||
System.exit(0);
|
||||
else if (obj.getProfile().getLauncherVisibility() == 2)
|
||||
MainFrame.instance.closeMessage();
|
||||
else {
|
||||
if (LogWindow.instance.isVisible())
|
||||
LogWindow.instance.setExit(TrueDoneListener.instance);
|
||||
MainFrame.instance.dispose();
|
||||
}
|
||||
Event<JavaProcess> event = new Event<JavaProcess>() {
|
||||
@Override
|
||||
public boolean call(Object sender, JavaProcess t) {
|
||||
processThreadStopped((ProcessThread) sender, obj, t, false);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
ProcessThread a = new ProcessThread(p, true, true);
|
||||
a.stopEvent.register(new Event<JavaProcess>() {
|
||||
@Override
|
||||
public boolean call(Object sender, JavaProcess p) {
|
||||
if (p.getExitCode() != 0 && p.getStdErrLines().size() > 0 && StrUtils.containsOne(p.getStdErrLines(),
|
||||
Arrays.asList("Could not create the Java Virtual Machine.",
|
||||
"Error occurred during initialization of VM",
|
||||
"A fatal exception has occurred. Program will exit.")))
|
||||
MessageBox.Show(C.i18n("launch.cannot_create_jvm"));
|
||||
processThreadStopped((ProcessThread) sender, obj, p, false);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
a.start();
|
||||
al.add(a);
|
||||
|
||||
a = new ProcessThread(p, false, true);
|
||||
a.stopEvent.register(event);
|
||||
a.start();
|
||||
al.add(a);
|
||||
|
||||
a = new ProcessThread(p, false, false);
|
||||
a.stopEvent.register(event);
|
||||
a.start();
|
||||
al.add(a);
|
||||
return true;
|
||||
obj.launchEvent.register((sender1, p) -> {
|
||||
if (obj.getProfile().getLauncherVisibility() == 0 && !LogWindow.instance.isVisible())
|
||||
System.exit(0);
|
||||
else if (obj.getProfile().getLauncherVisibility() == 2)
|
||||
MainFrame.instance.closeMessage();
|
||||
else {
|
||||
if (LogWindow.instance.isVisible())
|
||||
LogWindow.instance.setExit(TrueDoneListener.instance);
|
||||
MainFrame.instance.dispose();
|
||||
}
|
||||
Event<JavaProcess> event = (sender2, t) -> {
|
||||
processThreadStopped((ProcessThread) sender2, obj, t, false);
|
||||
return true;
|
||||
};
|
||||
ProcessThread a = new ProcessThread(p, true, true);
|
||||
a.stopEvent.register((sender3, p1) -> {
|
||||
if (p1.getExitCode() != 0 && p1.getStdErrLines().size() > 0 && StrUtils.containsOne(p1.getStdErrLines(), Arrays.asList("Could not create the Java Virtual Machine.",
|
||||
"Error occurred during initialization of VM",
|
||||
"A fatal exception has occurred. Program will exit."))) MessageBox.Show(C.i18n("launch.cannot_create_jvm"));
|
||||
processThreadStopped((ProcessThread) sender3, obj, p1, false);
|
||||
return true;
|
||||
});
|
||||
a.start();
|
||||
al.add(a);
|
||||
a = new ProcessThread(p, false, true);
|
||||
a.stopEvent.register(event);
|
||||
a.start();
|
||||
al.add(a);
|
||||
a = new ProcessThread(p, false, false);
|
||||
a.stopEvent.register(event);
|
||||
a.start();
|
||||
al.add(a);
|
||||
return true;
|
||||
});
|
||||
obj.launch(str);
|
||||
return true;
|
||||
@ -95,14 +81,7 @@ public class LaunchFinisher implements Event<List<String>> {
|
||||
|
||||
void processThreadStopped(ProcessThread t, GameLauncher obj, JavaProcess p, boolean forceTermintate) {
|
||||
al.remove(t);
|
||||
al.removeAll(CollectionUtils.sortOut(al, new Predicate<Thread>() {
|
||||
|
||||
@Override
|
||||
public boolean apply(Thread t) {
|
||||
return !t.isAlive();
|
||||
}
|
||||
|
||||
}));
|
||||
al.removeAll(CollectionUtils.sortOut(al, t1 -> !t1.isAlive()));
|
||||
if (al.isEmpty() || forceTermintate) {
|
||||
for (Thread a : al) a.interrupt();
|
||||
al.clear();
|
||||
|
@ -35,7 +35,8 @@ public final class Config {
|
||||
@SerializedName("username")
|
||||
private String username;
|
||||
@SerializedName("clientToken")
|
||||
private String clientToken;
|
||||
private final String clientToken;
|
||||
private String proxyHost, proxyPort, proxyUserName, proxyPassword;
|
||||
@SerializedName("enableShadow")
|
||||
private boolean enableShadow;
|
||||
@SerializedName("theme")
|
||||
@ -160,4 +161,40 @@ public final class Config {
|
||||
if(downloadtype >= DownloadType.values().length || downloadtype < 0) return null;
|
||||
return DownloadType.values()[downloadtype];
|
||||
}
|
||||
|
||||
public String getProxyHost() {
|
||||
return proxyHost == null ? "" : proxyHost;
|
||||
}
|
||||
|
||||
public void setProxyHost(String proxyHost) {
|
||||
this.proxyHost = proxyHost;
|
||||
Settings.save();
|
||||
}
|
||||
|
||||
public String getProxyPort() {
|
||||
return proxyPort == null ? "" : proxyPort;
|
||||
}
|
||||
|
||||
public void setProxyPort(String proxyPort) {
|
||||
this.proxyPort = proxyPort;
|
||||
Settings.save();
|
||||
}
|
||||
|
||||
public String getProxyUserName() {
|
||||
return proxyUserName == null ? "" : proxyUserName;
|
||||
}
|
||||
|
||||
public void setProxyUserName(String proxyUserName) {
|
||||
this.proxyUserName = proxyUserName;
|
||||
Settings.save();
|
||||
}
|
||||
|
||||
public String getProxyPassword() {
|
||||
return proxyPassword == null ? "" : proxyPassword;
|
||||
}
|
||||
|
||||
public void setProxyPassword(String proxyPassword) {
|
||||
this.proxyPassword = proxyPassword;
|
||||
Settings.save();
|
||||
}
|
||||
}
|
||||
|
@ -16,12 +16,13 @@
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.launcher.utils.settings;
|
||||
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import org.jackhuang.hellominecraft.C;
|
||||
import org.jackhuang.hellominecraft.utils.functions.DoneListener0;
|
||||
import org.jackhuang.hellominecraft.HMCLog;
|
||||
import org.jackhuang.hellominecraft.launcher.Main;
|
||||
import org.jackhuang.hellominecraft.utils.tinystream.CollectionUtils;
|
||||
@ -40,7 +41,7 @@ public final class Settings {
|
||||
public static final File settingsFile = new File(IOUtils.currentDir(), "hmcl.json");
|
||||
|
||||
private static boolean isFirstLoad;
|
||||
private static Config settings;
|
||||
private static final Config settings;
|
||||
public static final UpdateChecker UPDATE_CHECKER;
|
||||
|
||||
public static Config s() {
|
||||
@ -52,50 +53,39 @@ public final class Settings {
|
||||
}
|
||||
|
||||
static {
|
||||
settings = initSettings();
|
||||
isFirstLoad = StrUtils.isBlank(settings.getUsername());
|
||||
if(!getVersions().containsKey("Default"))
|
||||
getVersions().put("Default", new Profile());
|
||||
|
||||
UPDATE_CHECKER = new UpdateChecker(new VersionNumber(Main.firstVer, Main.secondVer, Main.thirdVer),
|
||||
"hmcl", settings.isCheckUpdate(), () -> Main.invokeUpdate());
|
||||
}
|
||||
|
||||
private static Config initSettings() {
|
||||
Config c = new Config();
|
||||
if (settingsFile.exists()) {
|
||||
try {
|
||||
String str = FileUtils.readFileToString(settingsFile);
|
||||
if (str == null || str.trim().equals("")) {
|
||||
init();
|
||||
|
||||
HMCLog.log("Settings file is empty, use the default settings.");
|
||||
} else {
|
||||
settings = C.gsonPrettyPrinting.fromJson(str, Config.class);
|
||||
Config d = C.gsonPrettyPrinting.fromJson(str, Config.class);
|
||||
if(d != null) c = d;
|
||||
}
|
||||
HMCLog.log("Initialized settings.");
|
||||
} catch (Exception e) {
|
||||
} catch (IOException | JsonSyntaxException e) {
|
||||
HMCLog.warn("Something happened wrongly when load settings.", e);
|
||||
if (MessageBox.Show(C.i18n("settings.failed_load"), MessageBox.YES_NO_OPTION) == MessageBox.YES_OPTION) {
|
||||
init();
|
||||
} else {
|
||||
if (MessageBox.Show(C.i18n("settings.failed_load"), MessageBox.YES_NO_OPTION) == MessageBox.NO_OPTION) {
|
||||
HMCLog.err("Cancelled loading settings.");
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
HMCLog.log("No settings file here, may be first loading.");
|
||||
|
||||
isFirstLoad = true;
|
||||
init();
|
||||
}
|
||||
if(settings == null) init();
|
||||
isFirstLoad = StrUtils.isBlank(settings.getUsername());
|
||||
if(!settings.getConfigurations().containsKey("Default")) {
|
||||
settings.getConfigurations().put("Default", new Profile());
|
||||
}
|
||||
|
||||
UPDATE_CHECKER = new UpdateChecker(new VersionNumber(Main.firstVer, Main.secondVer, Main.thirdVer), "hmcl", settings.isCheckUpdate(), new DoneListener0() {
|
||||
|
||||
@Override
|
||||
public void onDone() {
|
||||
Main.invokeUpdate();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void init() {
|
||||
settings = new Config();
|
||||
save();
|
||||
return c;
|
||||
}
|
||||
|
||||
public static void save() {
|
||||
@ -107,13 +97,7 @@ public final class Settings {
|
||||
}
|
||||
|
||||
public static Profile getVersion(String name) {
|
||||
if (settings == null) {
|
||||
return null;
|
||||
}
|
||||
if (settings.getConfigurations() == null) {
|
||||
return null;
|
||||
}
|
||||
return settings.getConfigurations().get(name);
|
||||
return getVersions().get(name);
|
||||
}
|
||||
|
||||
public static Map<String, Profile> getVersions() {
|
||||
@ -121,31 +105,22 @@ public final class Settings {
|
||||
}
|
||||
|
||||
public static void setVersion(Profile ver) {
|
||||
if (ver == null) {
|
||||
return;
|
||||
}
|
||||
settings.getConfigurations().put(ver.getName(), ver);
|
||||
Objects.requireNonNull(ver);
|
||||
getVersions().put(ver.getName(), ver);
|
||||
}
|
||||
|
||||
public static Collection<Profile> getProfiles() {
|
||||
return CollectionUtils.sortOut(settings.getConfigurations().values(), (t) -> t != null && t.getName() != null);
|
||||
return CollectionUtils.sortOut(getVersions().values(), (t) -> t != null && t.getName() != null);
|
||||
}
|
||||
|
||||
public static Profile getOneProfile() {
|
||||
if(settings.getConfigurations().size() == 0) {
|
||||
settings.getConfigurations().put("Default", new Profile());
|
||||
}
|
||||
return settings.getConfigurations().firstEntry().getValue();
|
||||
}
|
||||
|
||||
public static boolean trySetVersion(Profile ver) {
|
||||
if (ver == null || ver.getName() == null) {
|
||||
if (ver == null || ver.getName() == null || getVersions().containsKey(ver.getName()))
|
||||
return false;
|
||||
}
|
||||
if (settings.getConfigurations().containsKey(ver.getName())) {
|
||||
return false;
|
||||
}
|
||||
settings.getConfigurations().put(ver.getName(), ver);
|
||||
getVersions().put(ver.getName(), ver);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -154,7 +129,6 @@ public final class Settings {
|
||||
}
|
||||
|
||||
public static void delVersion(String ver) {
|
||||
if (settings == null) return;
|
||||
settings.getConfigurations().remove(ver);
|
||||
getVersions().remove(ver);
|
||||
}
|
||||
}
|
||||
|
@ -19,22 +19,14 @@
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<Component id="jLabel4" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="chkEnableShadow" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
<Component id="btnCheckUpdate" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jLabel7" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jLabel1" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jLabel14" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jLabel2" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<Component id="txtBackgroundPath" max="32767" attributes="0"/>
|
||||
@ -43,8 +35,34 @@
|
||||
</Group>
|
||||
<Component id="cboDownloadSource" alignment="1" max="32767" attributes="0"/>
|
||||
<Component id="cboTheme" alignment="1" max="32767" attributes="0"/>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="jLabel3" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="txtProxyHost" min="-2" pref="80" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jLabel5" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="txtProxyPort" min="-2" pref="80" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jLabel6" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="txtProxyUsername" min="-2" pref="80" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jLabel8" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="txtProxyPassword" min="-2" pref="80" max="-2" attributes="0"/>
|
||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</Group>
|
||||
<Group type="102" attributes="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jLabel4" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="chkEnableShadow" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="btnCheckUpdate" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
@ -70,11 +88,22 @@
|
||||
<Component id="cboTheme" alignment="3" min="-2" pref="26" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="chkEnableShadow" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="btnCheckUpdate" alignment="0" min="-2" pref="26" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="txtProxyHost" alignment="3" min="-2" pref="26" max="-2" attributes="0"/>
|
||||
<Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="txtProxyPort" alignment="3" min="-2" pref="26" max="-2" attributes="0"/>
|
||||
<Component id="jLabel5" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="txtProxyUsername" alignment="3" min="-2" pref="26" max="-2" attributes="0"/>
|
||||
<Component id="jLabel6" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="txtProxyPassword" alignment="3" min="-2" pref="26" max="-2" attributes="0"/>
|
||||
<Component id="jLabel8" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace pref="119" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="chkEnableShadow" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="btnCheckUpdate" min="-2" pref="26" max="-2" attributes="0"/>
|
||||
<EmptySpace pref="71" max="32767" attributes="0"/>
|
||||
<Component id="jLabel4" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
@ -174,5 +203,60 @@
|
||||
<EventHandler event="itemStateChanged" listener="java.awt.event.ItemListener" parameters="java.awt.event.ItemEvent" handler="cboThemeItemStateChanged"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel2">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="org/jackhuang/hellominecraft/launcher/I18N.properties" key="launcher.proxy" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JTextField" name="txtProxyHost">
|
||||
<Events>
|
||||
<EventHandler event="focusLost" listener="java.awt.event.FocusListener" parameters="java.awt.event.FocusEvent" handler="txtProxyHostFocusLost"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel3">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="org/jackhuang/hellominecraft/launcher/I18N.properties" key="proxy.host" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JTextField" name="txtProxyPort">
|
||||
<Events>
|
||||
<EventHandler event="focusLost" listener="java.awt.event.FocusListener" parameters="java.awt.event.FocusEvent" handler="txtProxyPortFocusLost"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel5">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="org/jackhuang/hellominecraft/launcher/I18N.properties" key="proxy.port" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel6">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="org/jackhuang/hellominecraft/launcher/I18N.properties" key="proxy.username" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JTextField" name="txtProxyUsername">
|
||||
<Events>
|
||||
<EventHandler event="focusLost" listener="java.awt.event.FocusListener" parameters="java.awt.event.FocusEvent" handler="txtProxyUsernameFocusLost"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JTextField" name="txtProxyPassword">
|
||||
<Events>
|
||||
<EventHandler event="focusLost" listener="java.awt.event.FocusListener" parameters="java.awt.event.FocusEvent" handler="txtProxyPasswordFocusLost"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel8">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="org/jackhuang/hellominecraft/launcher/I18N.properties" key="proxy.password" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Form>
|
||||
|
@ -39,6 +39,10 @@ public class LauncherSettingsPanel extends javax.swing.JPanel {
|
||||
initComponents();
|
||||
|
||||
txtBackgroundPath.setText(Settings.s().getBgpath());
|
||||
txtProxyHost.setText(Settings.s().getProxyHost());
|
||||
txtProxyPort.setText(Settings.s().getProxyPort());
|
||||
txtProxyUsername.setText(Settings.s().getProxyUserName());
|
||||
txtProxyPassword.setText(Settings.s().getProxyPassword());
|
||||
cboDownloadSource.setSelectedIndex(Settings.s().getDownloadType());
|
||||
cboTheme.setSelectedIndex(Settings.s().getTheme());
|
||||
chkEnableShadow.setSelected(Settings.s().isEnableShadow());
|
||||
@ -66,6 +70,15 @@ public class LauncherSettingsPanel extends javax.swing.JPanel {
|
||||
chkEnableShadow = new javax.swing.JCheckBox();
|
||||
jLabel1 = new javax.swing.JLabel();
|
||||
cboTheme = new javax.swing.JComboBox();
|
||||
jLabel2 = new javax.swing.JLabel();
|
||||
txtProxyHost = new javax.swing.JTextField();
|
||||
jLabel3 = new javax.swing.JLabel();
|
||||
txtProxyPort = new javax.swing.JTextField();
|
||||
jLabel5 = new javax.swing.JLabel();
|
||||
jLabel6 = new javax.swing.JLabel();
|
||||
txtProxyUsername = new javax.swing.JTextField();
|
||||
txtProxyPassword = new javax.swing.JTextField();
|
||||
jLabel8 = new javax.swing.JLabel();
|
||||
|
||||
cboDownloadSource.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Mojang", "BMCLAPI(By bangbang93)" }));
|
||||
cboDownloadSource.addItemListener(new java.awt.event.ItemListener() {
|
||||
@ -119,6 +132,40 @@ public class LauncherSettingsPanel extends javax.swing.JPanel {
|
||||
}
|
||||
});
|
||||
|
||||
jLabel2.setText(bundle.getString("launcher.proxy")); // NOI18N
|
||||
|
||||
txtProxyHost.addFocusListener(new java.awt.event.FocusAdapter() {
|
||||
public void focusLost(java.awt.event.FocusEvent evt) {
|
||||
txtProxyHostFocusLost(evt);
|
||||
}
|
||||
});
|
||||
|
||||
jLabel3.setText(bundle.getString("proxy.host")); // NOI18N
|
||||
|
||||
txtProxyPort.addFocusListener(new java.awt.event.FocusAdapter() {
|
||||
public void focusLost(java.awt.event.FocusEvent evt) {
|
||||
txtProxyPortFocusLost(evt);
|
||||
}
|
||||
});
|
||||
|
||||
jLabel5.setText(bundle.getString("proxy.port")); // NOI18N
|
||||
|
||||
jLabel6.setText(bundle.getString("proxy.username")); // NOI18N
|
||||
|
||||
txtProxyUsername.addFocusListener(new java.awt.event.FocusAdapter() {
|
||||
public void focusLost(java.awt.event.FocusEvent evt) {
|
||||
txtProxyUsernameFocusLost(evt);
|
||||
}
|
||||
});
|
||||
|
||||
txtProxyPassword.addFocusListener(new java.awt.event.FocusAdapter() {
|
||||
public void focusLost(java.awt.event.FocusEvent evt) {
|
||||
txtProxyPasswordFocusLost(evt);
|
||||
}
|
||||
});
|
||||
|
||||
jLabel8.setText(bundle.getString("proxy.password")); // NOI18N
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||
this.setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
@ -127,17 +174,11 @@ public class LauncherSettingsPanel extends javax.swing.JPanel {
|
||||
.addContainerGap()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(0, 0, Short.MAX_VALUE))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(chkEnableShadow)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(btnCheckUpdate))
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jLabel7)
|
||||
.addComponent(jLabel1)
|
||||
.addComponent(jLabel14))
|
||||
.addComponent(jLabel14)
|
||||
.addComponent(jLabel2))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
@ -145,7 +186,30 @@ public class LauncherSettingsPanel extends javax.swing.JPanel {
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(btnSelBackgroundPath))
|
||||
.addComponent(cboDownloadSource, javax.swing.GroupLayout.Alignment.TRAILING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(cboTheme, javax.swing.GroupLayout.Alignment.TRAILING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
|
||||
.addComponent(cboTheme, javax.swing.GroupLayout.Alignment.TRAILING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(jLabel3)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(txtProxyHost, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jLabel5)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(txtProxyPort, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jLabel6)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(txtProxyUsername, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jLabel8)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(txtProxyPassword, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(0, 0, Short.MAX_VALUE))))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(chkEnableShadow)
|
||||
.addComponent(btnCheckUpdate))
|
||||
.addGap(0, 0, Short.MAX_VALUE)))
|
||||
.addContainerGap())
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
@ -165,10 +229,21 @@ public class LauncherSettingsPanel extends javax.swing.JPanel {
|
||||
.addComponent(jLabel1)
|
||||
.addComponent(cboTheme, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(chkEnableShadow)
|
||||
.addComponent(btnCheckUpdate, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 119, Short.MAX_VALUE)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(txtProxyHost, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(jLabel2)
|
||||
.addComponent(jLabel3)
|
||||
.addComponent(txtProxyPort, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(jLabel5)
|
||||
.addComponent(txtProxyUsername, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(jLabel6)
|
||||
.addComponent(txtProxyPassword, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(jLabel8))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(chkEnableShadow)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(btnCheckUpdate, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 71, Short.MAX_VALUE)
|
||||
.addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addContainerGap())
|
||||
);
|
||||
@ -200,8 +275,7 @@ public class LauncherSettingsPanel extends javax.swing.JPanel {
|
||||
}//GEN-LAST:event_btnSelBackgroundPathActionPerformed
|
||||
|
||||
private void txtBackgroundPathFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtBackgroundPathFocusLost
|
||||
String path = txtBackgroundPath.getText();
|
||||
Settings.s().setBgpath(path);
|
||||
Settings.s().setBgpath(txtBackgroundPath.getText());
|
||||
MainFrame.instance.loadBackground();
|
||||
}//GEN-LAST:event_txtBackgroundPathFocusLost
|
||||
|
||||
@ -219,6 +293,22 @@ public class LauncherSettingsPanel extends javax.swing.JPanel {
|
||||
MainFrame.instance.reloadColor();
|
||||
}//GEN-LAST:event_cboThemeItemStateChanged
|
||||
|
||||
private void txtProxyHostFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtProxyHostFocusLost
|
||||
Settings.s().setProxyHost(txtProxyHost.getText());
|
||||
}//GEN-LAST:event_txtProxyHostFocusLost
|
||||
|
||||
private void txtProxyPortFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtProxyPortFocusLost
|
||||
Settings.s().setProxyPort(txtProxyPort.getText());
|
||||
}//GEN-LAST:event_txtProxyPortFocusLost
|
||||
|
||||
private void txtProxyUsernameFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtProxyUsernameFocusLost
|
||||
Settings.s().setProxyUserName(txtProxyUsername.getText());
|
||||
}//GEN-LAST:event_txtProxyUsernameFocusLost
|
||||
|
||||
private void txtProxyPasswordFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtProxyPasswordFocusLost
|
||||
Settings.s().setProxyPassword(txtProxyPassword.getText());
|
||||
}//GEN-LAST:event_txtProxyPasswordFocusLost
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JButton btnCheckUpdate;
|
||||
private javax.swing.JButton btnSelBackgroundPath;
|
||||
@ -227,8 +317,17 @@ public class LauncherSettingsPanel extends javax.swing.JPanel {
|
||||
private javax.swing.JCheckBox chkEnableShadow;
|
||||
private javax.swing.JLabel jLabel1;
|
||||
private javax.swing.JLabel jLabel14;
|
||||
private javax.swing.JLabel jLabel2;
|
||||
private javax.swing.JLabel jLabel3;
|
||||
private javax.swing.JLabel jLabel4;
|
||||
private javax.swing.JLabel jLabel5;
|
||||
private javax.swing.JLabel jLabel6;
|
||||
private javax.swing.JLabel jLabel7;
|
||||
private javax.swing.JLabel jLabel8;
|
||||
private javax.swing.JTextField txtBackgroundPath;
|
||||
private javax.swing.JTextField txtProxyHost;
|
||||
private javax.swing.JTextField txtProxyPassword;
|
||||
private javax.swing.JTextField txtProxyPort;
|
||||
private javax.swing.JTextField txtProxyUsername;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
||||
|
@ -34,6 +34,7 @@ public final class C {
|
||||
|
||||
public static final String URL_PUBLISH = "http://www.mcbbs.net/thread-142335-1-1.html";
|
||||
public static final String URL_TIEBA = "http://tieba.baidu.com/f?kw=hellominecraftlauncher";
|
||||
public static final String URL_GITHUB = "https://github.com/huanghongxun/HMCL/issues";
|
||||
public static final String URL_MINECRAFTFORUM = "http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-tools/1265720-hello-minecraft-launcher-1-9-3-mc-1-7-4-auto";
|
||||
|
||||
public static final String FILE_MINECRAFT_VERSIONS = "versions";
|
||||
|
@ -41,8 +41,9 @@ public class Compressor {
|
||||
/**
|
||||
* 功能:把 sourceDir 目录下的所有文件进行 zip 格式的压缩,保存为指定 zip 文件
|
||||
*
|
||||
* @param sourceDir
|
||||
* @param zipFile
|
||||
* @param sourceDir 源文件夹
|
||||
* @param zipFile 压缩生成的zip文件路径。
|
||||
* @throws java.io.IOException 压缩失败或无法读取
|
||||
*/
|
||||
public static void zip(File sourceDir, File zipFile) throws IOException {
|
||||
FileOutputStream os;
|
||||
@ -65,7 +66,7 @@ public class Compressor {
|
||||
*
|
||||
* @param source zip文件路径
|
||||
* @param basePath 待压缩文件根目录
|
||||
* @param zos
|
||||
* @param zos zip文件的os
|
||||
*/
|
||||
private static void zipFile(File source, String basePath,
|
||||
ZipOutputStream zos) throws IOException {
|
||||
@ -115,6 +116,7 @@ public class Compressor {
|
||||
* @param zipFileName zip文件路径
|
||||
* @param extPlace 待压缩文件根目录
|
||||
* @param without 带前缀的不解压
|
||||
* @throws java.io.IOException 解压失败或无法写入
|
||||
*/
|
||||
public static void unzip(File zipFileName, File extPlace, String[] without) throws IOException {
|
||||
extPlace.mkdirs();
|
||||
@ -164,6 +166,7 @@ public class Compressor {
|
||||
*
|
||||
* @param destFile zip1
|
||||
* @param srcFile zip2
|
||||
* @throws java.io.IOException 无法写入或读取
|
||||
*/
|
||||
public static void merge(File destFile, File srcFile) throws IOException {
|
||||
try (ZipOutputStream os = new ZipOutputStream(new FileOutputStream(destFile))) {
|
||||
|
@ -42,12 +42,16 @@ public class Stream<T> {
|
||||
protected Stream() {
|
||||
}
|
||||
|
||||
protected static <T> Stream<T> of(List<T> a) {
|
||||
protected static <T> Stream<T> noneCopyOf(List<T> a) {
|
||||
Stream<T> b = new Stream<>();
|
||||
b.internal = a;
|
||||
return b;
|
||||
}
|
||||
|
||||
protected static <T> Stream<T> of(Collection<T> a) {
|
||||
return new Stream<>(a);
|
||||
}
|
||||
|
||||
public Stream<T> forEach(Consumer<? super T> p) {
|
||||
for (T t : internal) p.accept(t);
|
||||
return this;
|
||||
@ -88,15 +92,25 @@ public class Stream<T> {
|
||||
}
|
||||
|
||||
public boolean anyMatch(Predicate<? super T> p) {
|
||||
return map(t -> p.apply(t)).reduce(false, (accumulator, _item) -> accumulator | _item);
|
||||
return map(t -> p.apply(t)).<Boolean>reduce(false, (a, b) -> a | b);
|
||||
}
|
||||
|
||||
public boolean allMatch(Predicate<? super T> p) {
|
||||
return map(t -> p.apply(t)).reduce(true, (accumulator, _item) -> accumulator & _item);
|
||||
return map(t -> p.apply(t)).<Boolean>reduce(true, (a, b) -> a & b);
|
||||
}
|
||||
|
||||
public T findFirst() {
|
||||
return internal.isEmpty() ? null : internal.get(0);
|
||||
}
|
||||
|
||||
public Stream<T> skip(int c) {
|
||||
internal = internal.subList(c+1, internal.size());
|
||||
return this;
|
||||
}
|
||||
|
||||
public Stream<T> limit(int c) {
|
||||
internal = internal.subList(0, c);
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -37,6 +37,8 @@
|
||||
<Component id="btnMCBBS" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="btnMCF" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="btnGitHub" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
<Component id="btnTerminateGame" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
@ -46,7 +48,7 @@
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="btnClose" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Component id="lblCrash" alignment="0" pref="639" max="32767" attributes="0"/>
|
||||
<Component id="lblCrash" alignment="0" pref="674" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
@ -68,6 +70,7 @@
|
||||
<Component id="btnTieBa" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="btnMCF" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="btnTerminateGame" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="btnGitHub" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
@ -164,5 +167,13 @@
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnTerminateGameActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="btnGitHub">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="GitHub"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnGitHubActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Form>
|
||||
|
@ -73,6 +73,7 @@ public class LogWindow extends javax.swing.JFrame {
|
||||
btnTieBa = new javax.swing.JButton();
|
||||
btnMCF = new javax.swing.JButton();
|
||||
btnTerminateGame = new javax.swing.JButton();
|
||||
btnGitHub = new javax.swing.JButton();
|
||||
|
||||
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
|
||||
setTitle("Log");
|
||||
@ -139,6 +140,13 @@ public class LogWindow extends javax.swing.JFrame {
|
||||
}
|
||||
});
|
||||
|
||||
btnGitHub.setText("GitHub");
|
||||
btnGitHub.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
btnGitHubActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
@ -153,6 +161,8 @@ public class LogWindow extends javax.swing.JFrame {
|
||||
.addComponent(btnMCBBS)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(btnMCF)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(btnGitHub)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(btnTerminateGame)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
@ -161,7 +171,7 @@ public class LogWindow extends javax.swing.JFrame {
|
||||
.addComponent(btnClear)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(btnClose))
|
||||
.addComponent(lblCrash, javax.swing.GroupLayout.DEFAULT_SIZE, 639, Short.MAX_VALUE))
|
||||
.addComponent(lblCrash, javax.swing.GroupLayout.DEFAULT_SIZE, 674, Short.MAX_VALUE))
|
||||
.addContainerGap())
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
@ -179,7 +189,8 @@ public class LogWindow extends javax.swing.JFrame {
|
||||
.addComponent(btnMCBBS)
|
||||
.addComponent(btnTieBa)
|
||||
.addComponent(btnMCF)
|
||||
.addComponent(btnTerminateGame))
|
||||
.addComponent(btnTerminateGame)
|
||||
.addComponent(btnGitHub))
|
||||
.addContainerGap())
|
||||
);
|
||||
|
||||
@ -219,6 +230,10 @@ public class LogWindow extends javax.swing.JFrame {
|
||||
terminateGameListener.onDone();
|
||||
}//GEN-LAST:event_btnTerminateGameActionPerformed
|
||||
|
||||
private void btnGitHubActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGitHubActionPerformed
|
||||
Utils.openLink(C.URL_GITHUB);
|
||||
}//GEN-LAST:event_btnGitHubActionPerformed
|
||||
|
||||
public void log(String status) {
|
||||
String text = txtLog.getText();
|
||||
text += status + System.getProperty("line.separator");
|
||||
@ -286,6 +301,7 @@ public class LogWindow extends javax.swing.JFrame {
|
||||
private javax.swing.JButton btnClear;
|
||||
private javax.swing.JButton btnClose;
|
||||
private javax.swing.JButton btnCopy;
|
||||
private javax.swing.JButton btnGitHub;
|
||||
private javax.swing.JButton btnMCBBS;
|
||||
private javax.swing.JButton btnMCF;
|
||||
private javax.swing.JButton btnTerminateGame;
|
||||
|
@ -73,6 +73,11 @@ login.type=\u767b\u5f55
|
||||
login.username=\u540d\u5b57
|
||||
login.account=\u90ae\u7bb1
|
||||
|
||||
proxy.username=\u8d26\u6237
|
||||
proxy.password=\u5bc6\u7801
|
||||
proxy.host=\u4e3b\u673a
|
||||
proxy.port=\u7aef\u53e3
|
||||
|
||||
login.failed.connect_authentication_server=\u65e0\u6cd5\u8fde\u63a5\u8ba4\u8bc1\u670d\u52a1\u5668,\u53ef\u80fd\u662f\u7f51\u7edc\u95ee\u9898
|
||||
|
||||
login.profile.not_logged_in=\u65e0\u6cd5\u4fee\u6539\u6e38\u620f\u8d44\u6599\u540c\u65f6\u672a\u767b\u5f55
|
||||
@ -144,7 +149,7 @@ ui.message.making=\u751f\u6210\u4e2d
|
||||
ui.message.sure_remove=\u771f\u7684\u8981\u5220\u9664\u914d\u7f6e%s\u5417\uff1f
|
||||
|
||||
ui.label.settings=\u9009\u9879
|
||||
ui.label.crashing=<html>Hello Minecraft! Launcher\u9047\u5230\u4e86\u65e0\u6cd5\u5904\u7406\u7684\u9519\u8bef\uff0c\u8bf7\u590d\u5236\u4e0b\u5217\u5185\u5bb9\u5e76\u901a\u8fc7mcbbs\u3001\u8d34\u5427\u6216Minecraft Forum\u53cd\u9988bug\u3002</html>
|
||||
ui.label.crashing=<html>Hello Minecraft! Launcher\u9047\u5230\u4e86\u65e0\u6cd5\u5904\u7406\u7684\u9519\u8bef\uff0c\u8bf7\u590d\u5236\u4e0b\u5217\u5185\u5bb9\u5e76\u901a\u8fc7mcbbs\u3001\u8d34\u5427\u3001Github\u6216Minecraft Forum\u53cd\u9988bug\u3002</html>
|
||||
ui.label.crashing_out_dated=<html>Hello Minecraft! Launcher\u9047\u5230\u4e86\u65e0\u6cd5\u5904\u7406\u7684\u9519\u8bef\uff0c\u5df2\u68c0\u6d4b\u5230\u60a8\u7684\u542f\u52a8\u5668\u4e0d\u662f\u6700\u65b0\u7248\u672c\uff0c\u8bf7\u66f4\u65b0\u540e\u518d\u8bd5\uff01</html>
|
||||
ui.label.failed_set=\u8bbe\u7f6e\u5931\u8d25\uff1a
|
||||
|
||||
@ -221,6 +226,7 @@ launcher.background_tooltip=<html>\n<body>\n\u542f\u52a8\u5668\u9ed8\u8ba4\u4f7f
|
||||
launcher.update_launcher=\u68c0\u67e5\u66f4\u65b0
|
||||
launcher.enable_shadow=\u542f\u7528\u7a97\u53e3\u9634\u5f71(\u91cd\u542f\u542f\u52a8\u5668\u751f\u6548,\u53ef\u52a0\u5feb\u6e32\u67d3\u901f\u5ea6)
|
||||
launcher.theme=\u4e3b\u9898
|
||||
launcher.proxy=\u4ee3\u7406
|
||||
|
||||
launcher.title.game=\u6e38\u620f\u8bbe\u7f6e
|
||||
launcher.title.main=\u4e3b\u9875
|
||||
|
@ -50,7 +50,7 @@ configure(install.repositories.mavenInstaller) {
|
||||
dependencies {
|
||||
compile project(":HMCLAPI")
|
||||
compile project(":MetroLookAndFeel")
|
||||
compile files("../../../../repo/org/ho/jyaml/1.3/jyaml-1.3.jar")
|
||||
compile ('org.jyaml:jyaml:1.3')
|
||||
compile ("org.tukaani:xz:1.5")
|
||||
compile ('org.jsoup:jsoup:1.7.2')
|
||||
}
|
||||
|
6
HMCSM/proguard.pro
vendored
6
HMCSM/proguard.pro
vendored
@ -1,6 +1,6 @@
|
||||
-libraryjars D:\Java\jdk1.6.0_45\jre\lib\rt.jar
|
||||
-libraryjars D:\Java\jdk1.6.0_45\jre\lib\jce.jar
|
||||
-libraryjars D:\Java\jdk1.6.0_45\jre\lib\jsse.jar
|
||||
-libraryjars <java.home>/lib/rt.jar
|
||||
-libraryjars <java.home>/lib/jce.jar
|
||||
-libraryjars <java.home>/lib/jsse.jar
|
||||
|
||||
-dontoptimize
|
||||
-dontwarn
|
||||
|
@ -9,8 +9,8 @@ package org.jackhuang.hellominecraft.svrmgr.installer.bukkit;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.jackhuang.hellominecraft.DoneListener1;
|
||||
import org.jackhuang.hellominecraft.HMCLog;
|
||||
import org.jackhuang.hellominecraft.utils.functions.Consumer;
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.jsoup.nodes.Element;
|
||||
@ -22,18 +22,18 @@ import org.jsoup.select.Elements;
|
||||
*/
|
||||
public class BukkitFormatThread extends Thread {
|
||||
|
||||
DoneListener1<List<BukkitVersion>> lis;
|
||||
Consumer<List<BukkitVersion>> lis;
|
||||
List<BukkitVersion> formattedList;
|
||||
String url;
|
||||
|
||||
public BukkitFormatThread(String url, DoneListener1<List<BukkitVersion>> lis) {
|
||||
public BukkitFormatThread(String url, Consumer<List<BukkitVersion>> lis) {
|
||||
this.lis = lis;
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public void format(String url) {
|
||||
|
||||
formattedList = new ArrayList<BukkitVersion>();
|
||||
formattedList = new ArrayList<>();
|
||||
|
||||
try {
|
||||
Document doc = Jsoup.connect(url).get();
|
||||
@ -74,7 +74,7 @@ public class BukkitFormatThread extends Thread {
|
||||
List<BukkitVersion> al = null;
|
||||
format(url);
|
||||
if(lis != null)
|
||||
lis.onDone(formattedList);
|
||||
lis.accept(formattedList);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.jackhuang.hellominecraft.DoneListener1;
|
||||
import org.jackhuang.hellominecraft.utils.functions.Consumer;
|
||||
import org.jackhuang.hellominecraft.HMCLog;
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
@ -22,10 +22,10 @@ import org.jsoup.select.Elements;
|
||||
*/
|
||||
public class ForgeFormatThread extends Thread {
|
||||
|
||||
DoneListener1<Map<String, List<ForgeVersion>>> lis;
|
||||
Consumer<Map<String, List<ForgeVersion>>> lis;
|
||||
Map<String, List<ForgeVersion>> formattedList;
|
||||
|
||||
public ForgeFormatThread(DoneListener1<Map<String, List<ForgeVersion>>> lis) {
|
||||
public ForgeFormatThread(Consumer<Map<String, List<ForgeVersion>>> lis) {
|
||||
this.lis = lis;
|
||||
}
|
||||
|
||||
@ -75,14 +75,14 @@ public class ForgeFormatThread extends Thread {
|
||||
}
|
||||
|
||||
if(!formattedList.containsKey(v.mcver))
|
||||
formattedList.put(v.mcver, new ArrayList<ForgeVersion>());
|
||||
formattedList.put(v.mcver, new ArrayList<>());
|
||||
formattedList.get(v.mcver).add(v);
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
HMCLog.warn("Failed to get forge list", ex);
|
||||
ForgeVersion v = new ForgeVersion();
|
||||
v.mcver = v.ver = "获取失败";
|
||||
formattedList.put(v.mcver, new ArrayList<ForgeVersion>());
|
||||
formattedList.put(v.mcver, new ArrayList<>());
|
||||
formattedList.get(v.mcver).add(v);
|
||||
}
|
||||
}
|
||||
@ -91,7 +91,7 @@ public class ForgeFormatThread extends Thread {
|
||||
public void run() {
|
||||
formatNew();
|
||||
if(lis != null)
|
||||
lis.onDone(formattedList);
|
||||
lis.accept(formattedList);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -22,8 +22,6 @@ import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import org.jackhuang.hellominecraft.utils.functions.DoneListener0;
|
||||
import org.jackhuang.hellominecraft.DoneListener1;
|
||||
import org.jackhuang.hellominecraft.HMCLog;
|
||||
import org.jackhuang.hellominecraft.utils.IOUtils;
|
||||
import org.jackhuang.hellominecraft.utils.MessageBox;
|
||||
@ -34,12 +32,15 @@ import org.jackhuang.hellominecraft.svrmgr.settings.SettingsManager;
|
||||
import org.jackhuang.hellominecraft.svrmgr.threads.MonitorThread;
|
||||
import org.jackhuang.hellominecraft.svrmgr.threads.WaitForThread;
|
||||
import org.jackhuang.hellominecraft.svrmgr.utils.Utilities;
|
||||
import org.jackhuang.hellominecraft.utils.Event;
|
||||
import org.jackhuang.hellominecraft.utils.EventHandler;
|
||||
import org.jackhuang.hellominecraft.utils.functions.Consumer;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author hyh
|
||||
*/
|
||||
public class Server implements DoneListener1<Integer>, MonitorThread.MonitorThreadListener,
|
||||
public class Server implements Event<Integer>, MonitorThread.MonitorThreadListener,
|
||||
ActionListener {
|
||||
|
||||
private static Server instance;
|
||||
@ -61,10 +62,11 @@ public class Server implements DoneListener1<Integer>, MonitorThread.MonitorThre
|
||||
Process server;
|
||||
MonitorThread threadA, threadB;
|
||||
WaitForThread threadC;
|
||||
DoneListener1<Pair<String, String[]>> gettingPlayerNumber;
|
||||
Consumer<Pair<String, String[]>> gettingPlayerNumber;
|
||||
ArrayList<MonitorThread.MonitorThreadListener> listeners;
|
||||
ArrayList<DoneListener1<Integer>> listenersC;
|
||||
ArrayList<DoneListener0> listenersBegin, listenersDone;
|
||||
ArrayList<Event<Integer>> listenersC;
|
||||
//ArrayList<DoneListener0> listenersBegin, listenersDone;
|
||||
public final EventHandler<Void> startedEvent = new EventHandler<>(this), stoppedEvent = new EventHandler<>(this);
|
||||
ArrayList<TimerTask> timerTasks;
|
||||
ArrayList<Schedule> schedules;
|
||||
BufferedWriter bw;
|
||||
@ -78,30 +80,20 @@ public class Server implements DoneListener1<Integer>, MonitorThread.MonitorThre
|
||||
this.jar = jar;
|
||||
this.memory = memory;
|
||||
isRestart = isDone = false;
|
||||
listeners = new ArrayList<MonitorThread.MonitorThreadListener>();
|
||||
listenersC = new ArrayList<DoneListener1<Integer>>();
|
||||
listenersBegin = new ArrayList<DoneListener0>();
|
||||
listenersDone = new ArrayList<DoneListener0>();
|
||||
schedules = new ArrayList<Schedule>();
|
||||
timerTasks = new ArrayList<TimerTask>();
|
||||
listeners = new ArrayList<>();
|
||||
listenersC = new ArrayList<>();
|
||||
schedules = new ArrayList<>();
|
||||
timerTasks = new ArrayList<>();
|
||||
}
|
||||
|
||||
public void addListener(MonitorThread.MonitorThreadListener l) {
|
||||
listeners.add(l);
|
||||
}
|
||||
|
||||
public void addListener(DoneListener1<Integer> l) {
|
||||
public void addListener(Event<Integer> l) {
|
||||
listenersC.add(l);
|
||||
}
|
||||
|
||||
public void addServerStartedListener(DoneListener0 l) {
|
||||
listenersBegin.add(l);
|
||||
}
|
||||
|
||||
public void addServerDoneListener(DoneListener0 l) {
|
||||
listenersDone.add(l);
|
||||
}
|
||||
|
||||
public void run() throws IOException {
|
||||
String jvmPath;
|
||||
if (StrUtils.isBlank(SettingsManager.settings.javaDir)) {
|
||||
@ -133,9 +125,7 @@ public class Server implements DoneListener1<Integer>, MonitorThread.MonitorThre
|
||||
bw = new BufferedWriter(new OutputStreamWriter(server.getOutputStream()));
|
||||
}
|
||||
isRunning = true;
|
||||
for (DoneListener0 d : listenersBegin) {
|
||||
d.onDone();
|
||||
}
|
||||
startedEvent.execute(null);
|
||||
sendStatus("*** 启动服务端中 ***");
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(Server.class.getName()).log(Level.SEVERE, null, ex);
|
||||
@ -156,7 +146,7 @@ public class Server implements DoneListener1<Integer>, MonitorThread.MonitorThre
|
||||
}
|
||||
}
|
||||
|
||||
public void getPlayerNumber(DoneListener1<Pair<String, String[]>> d) {
|
||||
public void getPlayerNumber(Consumer<Pair<String, String[]>> d) {
|
||||
isGettingPlayerNumber = 1;
|
||||
gettingPlayerNumber = d;
|
||||
sendCommand("list");
|
||||
@ -210,15 +200,13 @@ public class Server implements DoneListener1<Integer>, MonitorThread.MonitorThre
|
||||
|
||||
private void registerThreadC(Process p) {
|
||||
threadC = new WaitForThread(p);
|
||||
for (DoneListener1<Integer> l : listenersC) {
|
||||
threadC.addListener(l);
|
||||
}
|
||||
threadC.addListener(this);
|
||||
for (Event<Integer> l : listenersC) threadC.event.register(l);
|
||||
threadC.event.register(this);
|
||||
threadC.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDone(Integer t) {
|
||||
public boolean call(Object sender, Integer t) {
|
||||
if (t == 0) {
|
||||
sendStatus("*** 服务端已停止 ***");
|
||||
System.out.println("Server stopped successfully");
|
||||
@ -227,17 +215,9 @@ public class Server implements DoneListener1<Integer>, MonitorThread.MonitorThre
|
||||
System.err.println("Server crashed(exit code: " + t + ")");
|
||||
}
|
||||
isRunning = false;
|
||||
for (int i = 0; i < schedules.size(); i++) {
|
||||
if (schedules.get(i).timeType == Schedule.TIME_TYPE_SERVER_STOPPED) {
|
||||
ScheduleTranslator.translate(this, schedules.get(i)).run();
|
||||
}
|
||||
}
|
||||
if (timer != null) {
|
||||
timer.cancel();
|
||||
}
|
||||
if (pastTimer != null) {
|
||||
pastTimer.stop();
|
||||
}
|
||||
for (Schedule schedule : schedules) if (schedule.timeType == Schedule.TIME_TYPE_SERVER_STOPPED) ScheduleTranslator.translate(this, schedule).run();
|
||||
if (timer != null) timer.cancel();
|
||||
if (pastTimer != null) pastTimer.stop();
|
||||
restoreMods();
|
||||
if (isRestart) {
|
||||
try {
|
||||
@ -248,6 +228,7 @@ public class Server implements DoneListener1<Integer>, MonitorThread.MonitorThre
|
||||
}
|
||||
isRestart = false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void disactiveMods(ArrayList<String> inactiveExtMods,
|
||||
@ -270,58 +251,49 @@ public class Server implements DoneListener1<Integer>, MonitorThread.MonitorThre
|
||||
System.out.println("没有文件: " + paramString);
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < files.length; i++) {
|
||||
File file = files[i];
|
||||
if (!file.isDirectory()) {
|
||||
String name = file.getName();
|
||||
|
||||
if ((!paramArrayOfString.contains(name))
|
||||
|| ((!name.toLowerCase().endsWith(".zip")) && (!name.toLowerCase().endsWith(".jar")))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String newName = name + "X";
|
||||
File newFile = new File(file.getParentFile(), newName);
|
||||
|
||||
if (newFile.exists()) {
|
||||
newFile.delete();
|
||||
}
|
||||
if (file.renameTo(newFile)) {
|
||||
System.out.println("已禁用: " + name + ", 新名称: " + newFile.getName());
|
||||
} else {
|
||||
System.out.println("无法禁用: " + name);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (File file : files) if (!file.isDirectory()) {
|
||||
String name = file.getName();
|
||||
|
||||
if ((!paramArrayOfString.contains(name))
|
||||
|| ((!name.toLowerCase().endsWith(".zip")) && (!name.toLowerCase().endsWith(".jar")))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String newName = name + "X";
|
||||
File newFile = new File(file.getParentFile(), newName);
|
||||
|
||||
if (newFile.exists()) {
|
||||
newFile.delete();
|
||||
}
|
||||
if (file.renameTo(newFile)) {
|
||||
System.out.println("已禁用: " + name + ", 新名称: " + newFile.getName());
|
||||
} else {
|
||||
System.out.println("无法禁用: " + name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void restoreModsByType(String paramString) {
|
||||
System.out.println("还原被禁用的文件: " + paramString);
|
||||
File[] files = new File(Utilities.getGameDir(), paramString).listFiles();
|
||||
if (files == null) {
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < files.length; i++) {
|
||||
File file = files[i];
|
||||
if (file.isDirectory()) {
|
||||
continue;
|
||||
}
|
||||
String name = file.getName();
|
||||
String lowName = name.toLowerCase();
|
||||
if ((!lowName.endsWith(".zipx")) && (!lowName.endsWith(".jarx"))) {
|
||||
continue;
|
||||
}
|
||||
String newName = name.substring(0, name.length() - 1);
|
||||
|
||||
File newFile = new File(file.getParentFile(), newName);
|
||||
if (newFile.exists()) {
|
||||
file.delete();
|
||||
} else {
|
||||
if (!file.renameTo(newFile)) {
|
||||
System.out.println("无法重命名: " + file.getName() + " 到: " + newFile.getName() + " 在: " + file.getParent());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (files == null) return;
|
||||
for (File file : files) if (!file.isDirectory()) {
|
||||
String name = file.getName();
|
||||
String lowName = name.toLowerCase();
|
||||
if ((!lowName.endsWith(".zipx")) && (!lowName.endsWith(".jarx"))) {
|
||||
continue;
|
||||
}
|
||||
String newName = name.substring(0, name.length() - 1);
|
||||
|
||||
File newFile = new File(file.getParentFile(), newName);
|
||||
if (newFile.exists()) {
|
||||
file.delete();
|
||||
} else {
|
||||
if (!file.renameTo(newFile)) {
|
||||
System.out.println("无法重命名: " + file.getName() + " 到: " + newFile.getName() + " 在: " + file.getParent());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void restoreMods() {
|
||||
@ -360,18 +332,16 @@ public class Server implements DoneListener1<Integer>, MonitorThread.MonitorThre
|
||||
} else {
|
||||
s = new String[0];
|
||||
}
|
||||
Pair<String, String[]> p = new Pair<String, String[]>(playerNumber, s);
|
||||
Pair<String, String[]> p = new Pair<>(playerNumber, s);
|
||||
isGettingPlayerNumber = 0;
|
||||
gettingPlayerNumber.onDone(p);
|
||||
gettingPlayerNumber.accept(p);
|
||||
return;
|
||||
}
|
||||
if (isDone == false) {
|
||||
Pattern p = Pattern.compile("\\[INFO\\] Done \\([0-9]*\\.[0-9]*s\\)! For help, type \"help\" or \"\\?\"");
|
||||
Matcher m = p.matcher(status);
|
||||
if (m.find()) {
|
||||
for (DoneListener0 d : listenersDone) {
|
||||
d.onDone();
|
||||
}
|
||||
stoppedEvent.execute(null);
|
||||
timer = new Timer();
|
||||
timerTasks.clear();
|
||||
for (int i = 0; i < schedules.size(); i++) {
|
||||
@ -379,9 +349,7 @@ public class Server implements DoneListener1<Integer>, MonitorThread.MonitorThre
|
||||
ScheduleTranslator.translate(this, schedules.get(i)).run();
|
||||
continue;
|
||||
}
|
||||
if (schedules.get(i).timeType != Schedule.TIME_TYPE_PER) {
|
||||
continue;
|
||||
}
|
||||
if (schedules.get(i).timeType != Schedule.TIME_TYPE_PER) continue;
|
||||
long mill = (long) Math.floor(schedules.get(i).per * 60 * 1000);
|
||||
timerTasks.add(ScheduleTranslator.translate(this, schedules.get(i)));
|
||||
timer.schedule(timerTasks.get(i), mill, mill);
|
||||
@ -395,11 +363,7 @@ public class Server implements DoneListener1<Integer>, MonitorThread.MonitorThre
|
||||
}
|
||||
if (status.length() > 20) {
|
||||
if (status.substring(20).contains("[SEVERE] This crash report has been saved to: ")) {
|
||||
for (int i = 0; i < schedules.size(); i++) {
|
||||
if (schedules.get(i).timeType == Schedule.TIME_TYPE_SERVER_CRASHED) {
|
||||
ScheduleTranslator.translate(this, schedules.get(i)).run();
|
||||
}
|
||||
}
|
||||
for (Schedule schedule : schedules) if (schedule.timeType == Schedule.TIME_TYPE_SERVER_CRASHED) ScheduleTranslator.translate(this, schedule).run();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -409,23 +373,15 @@ public class Server implements DoneListener1<Integer>, MonitorThread.MonitorThre
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
c.setTime(new Date());
|
||||
if (c.get(Calendar.SECOND) != 0) {
|
||||
return;
|
||||
}
|
||||
if (c.get(Calendar.SECOND) != 0) return;
|
||||
int minute = c.get(Calendar.MINUTE);
|
||||
for (int i = 0; i < schedules.size(); i++) {
|
||||
if (schedules.get(i).timeType != Schedule.TIME_TYPE_PAST_HOUR) {
|
||||
continue;
|
||||
}
|
||||
if (schedules.get(i).per == minute) {
|
||||
ScheduleTranslator.translate(this, schedules.get(i)).run();
|
||||
}
|
||||
}
|
||||
for (Schedule schedule : schedules) {
|
||||
if (schedule.timeType != Schedule.TIME_TYPE_PAST_HOUR) continue;
|
||||
if (schedule.per == minute) ScheduleTranslator.translate(this, schedule).run();
|
||||
}
|
||||
}
|
||||
|
||||
private void sendStatus(String status) {
|
||||
for (MonitorThread.MonitorThreadListener l : listeners) {
|
||||
l.onStatus(status);
|
||||
}
|
||||
for (MonitorThread.MonitorThreadListener l : listeners) l.onStatus(status);
|
||||
}
|
||||
}
|
||||
|
@ -4,10 +4,9 @@
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.svrmgr.threads;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.jackhuang.hellominecraft.DoneListener1;
|
||||
import org.jackhuang.hellominecraft.utils.EventHandler;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -15,30 +14,21 @@ import org.jackhuang.hellominecraft.DoneListener1;
|
||||
*/
|
||||
public class WaitForThread extends Thread {
|
||||
|
||||
public ArrayList<DoneListener1<Integer>> al;
|
||||
public final EventHandler<Integer> event = new EventHandler<>(this);
|
||||
Process p;
|
||||
|
||||
public WaitForThread(Process p) {
|
||||
this.p = p;
|
||||
al = new ArrayList<DoneListener1<Integer>>();
|
||||
}
|
||||
|
||||
public void addListener(DoneListener1<Integer> dl) {
|
||||
al.add(dl);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
int exitCode = p.waitFor();
|
||||
for(DoneListener1<Integer> dl : al)
|
||||
if(dl != null)
|
||||
dl.onDone(exitCode);
|
||||
event.execute(exitCode);
|
||||
} catch (InterruptedException ex) {
|
||||
Logger.getLogger(WaitForThread.class.getName()).log(Level.SEVERE, null, ex);
|
||||
for(DoneListener1<Integer> dl : al)
|
||||
if(dl != null)
|
||||
dl.onDone(-1);
|
||||
event.execute(-1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,9 +8,9 @@ package org.jackhuang.hellominecraft.svrmgr.utils;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import org.jackhuang.hellominecraft.DoneListener1;
|
||||
import org.jackhuang.hellominecraft.HMCLog;
|
||||
import org.jackhuang.hellominecraft.utils.NetUtils;
|
||||
import org.jackhuang.hellominecraft.utils.functions.Consumer;
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.jsoup.select.Elements;
|
||||
@ -21,7 +21,7 @@ import org.jsoup.select.Elements;
|
||||
*/
|
||||
public class IPGet extends Thread {
|
||||
|
||||
public DoneListener1<String> dl;
|
||||
public Consumer<String> dl;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
@ -37,11 +37,11 @@ public class IPGet extends Thread {
|
||||
while(m.find()) {
|
||||
s += m.group() + ",";
|
||||
}
|
||||
dl.onDone(s.substring(0, s.length()-1));
|
||||
dl.accept(s.substring(0, s.length()-1));
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
HMCLog.warn("Failed to get ip from ip138.", ex);
|
||||
dl.onDone("获取失败");
|
||||
dl.accept("获取失败");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -34,8 +34,6 @@ import javax.swing.JPopupMenu;
|
||||
import javax.swing.filechooser.FileNameExtensionFilter;
|
||||
import javax.swing.table.DefaultTableModel;
|
||||
import org.jackhuang.hellominecraft.C;
|
||||
import org.jackhuang.hellominecraft.utils.functions.DoneListener0;
|
||||
import org.jackhuang.hellominecraft.DoneListener1;
|
||||
import org.jackhuang.hellominecraft.HMCLog;
|
||||
import org.jackhuang.hellominecraft.tasks.Task;
|
||||
import org.jackhuang.hellominecraft.tasks.TaskWindow;
|
||||
@ -48,7 +46,6 @@ import org.jackhuang.hellominecraft.utils.MessageBox;
|
||||
import org.jackhuang.hellominecraft.svrmgr.utils.ModType;
|
||||
import org.jackhuang.hellominecraft.svrmgr.utils.MonitorInfoBean;
|
||||
import org.jackhuang.hellominecraft.svrmgr.utils.MonitorServiceImpl;
|
||||
import org.jackhuang.hellominecraft.utils.Pair;
|
||||
import org.jackhuang.hellominecraft.version.MinecraftRemoteVersions;
|
||||
import org.jackhuang.hellominecraft.svrmgr.Main;
|
||||
import org.jackhuang.hellominecraft.svrmgr.cbplugins.BukkitPlugin;
|
||||
@ -78,13 +75,14 @@ import org.jackhuang.hellominecraft.svrmgr.utils.Utilities;
|
||||
import org.jackhuang.hellominecraft.utils.SwingUtils;
|
||||
import org.jackhuang.hellominecraft.version.MinecraftRemoteVersion;
|
||||
import org.jackhuang.hellominecraft.lookandfeel.components.ConstomButton;
|
||||
import org.jackhuang.hellominecraft.utils.Event;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author hyh
|
||||
*/
|
||||
public final class MainWindow extends javax.swing.JFrame
|
||||
implements MonitorThread.MonitorThreadListener, DoneListener1<Integer> {
|
||||
implements MonitorThread.MonitorThreadListener, Event<Integer> {
|
||||
|
||||
ImageIcon background = new ImageIcon(getClass().getResource("/background.jpg"));
|
||||
JLabel backgroundLabel;
|
||||
@ -144,11 +142,10 @@ public final class MainWindow extends javax.swing.JFrame
|
||||
|
||||
setTitle(Main.makeTitle());
|
||||
String mainjar = SettingsManager.settings.mainjar;
|
||||
if (!Utilities.isEmpty(mainjar)) {
|
||||
if (!Utilities.isEmpty(mainjar))
|
||||
ServerProperties.init(new File(mainjar).getParent());
|
||||
}
|
||||
txtMainJar.setText(mainjar);
|
||||
commandSet = new ArrayList<String>();
|
||||
commandSet = new ArrayList<>();
|
||||
btnStop.setEnabled(false);
|
||||
btnShutdown.setEnabled(false);
|
||||
btnCommand.setEnabled(false);
|
||||
@ -480,9 +477,8 @@ public final class MainWindow extends javax.swing.JFrame
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
InputDialog id = new InputDialog(MainWindow.this, true, new String[]{"玩家", "物品ID", "数量"});
|
||||
id.setVisible(true);
|
||||
if (id.result != null) {
|
||||
if (id.result != null)
|
||||
Server.getInstance().sendCommand("give " + id.result[0] + " " + id.result[1] + " " + id.result[2]);
|
||||
}
|
||||
}
|
||||
});
|
||||
ppmBasically.add(itm);
|
||||
@ -2896,23 +2892,21 @@ public final class MainWindow extends javax.swing.JFrame
|
||||
|
||||
void loadFromServerProperties() {
|
||||
ServerProperties sp = ServerProperties.getInstance();
|
||||
if (sp == null) {
|
||||
if (sp == null)
|
||||
return;
|
||||
}
|
||||
txtServerPort.setValue(sp.getPropertyInt("server-port", 25565));
|
||||
txtServerName.setText(sp.getProperty("server-name"));
|
||||
cboGameMode.setSelectedIndex(sp.getPropertyInt("gamemode", 0));
|
||||
cboDifficulty.setSelectedIndex(sp.getPropertyInt("difficulty", 1));
|
||||
String wt = sp.getProperty("level-type");
|
||||
if (wt.equals("LARGEBIOMES")) {
|
||||
if (wt.equals("LARGEBIOMES"))
|
||||
cboWorldType.setSelectedIndex(2);
|
||||
} else if (wt.equals("FLAT")) {
|
||||
else if (wt.equals("FLAT"))
|
||||
cboWorldType.setSelectedIndex(1);
|
||||
} else if (wt.equals("DEFAULT")) {
|
||||
else if (wt.equals("DEFAULT"))
|
||||
cboWorldType.setSelectedIndex(0);
|
||||
} else {
|
||||
else
|
||||
cboWorldType.setSelectedIndex(0);
|
||||
}
|
||||
txtMaxPlayer.setValue(sp.getPropertyInt("max-players", 20));
|
||||
chkAllowFlight.setSelected(sp.getPropertyBoolean("allow-flight", false));
|
||||
chkAllowNether.setSelected(sp.getPropertyBoolean("allow-nether", true));
|
||||
@ -2932,82 +2926,64 @@ public final class MainWindow extends javax.swing.JFrame
|
||||
|
||||
void loadFromOPs() {
|
||||
File mainjar = new File(SettingsManager.settings.mainjar);
|
||||
if (!mainjar.exists()) {
|
||||
return;
|
||||
}
|
||||
if (!mainjar.exists()) return;
|
||||
File folder = mainjar.getParentFile();
|
||||
op = new Op();
|
||||
op.initByBoth(new File(folder, "ops.txt"), new File(folder, "ops.json"));
|
||||
for (Op.Operator ss : op.op) {
|
||||
lstOPModel.addElement(ss.name);
|
||||
}
|
||||
for (Op.Operator ss : op.op) lstOPModel.addElement(ss.name);
|
||||
lstOP.setModel(lstOPModel);
|
||||
}
|
||||
|
||||
void loadFromWhiteList() {
|
||||
File mainjar = new File(SettingsManager.settings.mainjar);
|
||||
if (!mainjar.exists()) {
|
||||
return;
|
||||
}
|
||||
if (!mainjar.exists()) return;
|
||||
File folder = mainjar.getParentFile();
|
||||
whitelist = new WhiteList();
|
||||
whitelist.initByBoth(new File(folder, "white-list.txt"), new File(folder, "white-list.json"));
|
||||
for (WhiteList.WhiteListPlayer ss : whitelist.op) {
|
||||
lstWhiteListModel.addElement(ss.name);
|
||||
}
|
||||
for (WhiteList.WhiteListPlayer ss : whitelist.op) lstWhiteListModel.addElement(ss.name);
|
||||
lstWhiteList.setModel(lstWhiteListModel);
|
||||
}
|
||||
|
||||
void loadFromBannedPlayers() {
|
||||
File mainjar = new File(SettingsManager.settings.mainjar);
|
||||
if (!mainjar.exists()) {
|
||||
return;
|
||||
}
|
||||
if (!mainjar.exists()) return;
|
||||
File folder = mainjar.getParentFile();
|
||||
banned = new BannedPlayers();
|
||||
banned.initByBoth(new File(folder, "banned-players.txt"), new File(folder, "banned-players.json"));
|
||||
for (BannedPlayers.BannedPlayer ss : banned.op) {
|
||||
for (BannedPlayers.BannedPlayer ss : banned.op)
|
||||
lstBannedModel.addElement(ss.name);
|
||||
}
|
||||
lstBanned.setModel(lstBannedModel);
|
||||
}
|
||||
|
||||
void loadLocalMods() {
|
||||
String path = Utilities.getPath("mods");
|
||||
if (path == null) {
|
||||
return;
|
||||
}
|
||||
if (path == null) return;
|
||||
ArrayList<String> sl = Utilities.findAllFile(new File(path));
|
||||
DefaultTableModel model = (DefaultTableModel) lstExternalMods.getModel();
|
||||
while (model.getRowCount() > 0) {
|
||||
while (model.getRowCount() > 0)
|
||||
model.removeRow(0);
|
||||
}
|
||||
for (String s : sl) {
|
||||
for (String s : sl)
|
||||
model.addRow(new Object[]{!SettingsManager.settings.inactiveExtMods.contains(s), s, ModType.getModTypeShowName(ModType.getModType(Utilities.addSeparator(path) + s))});
|
||||
}
|
||||
|
||||
lstExternalMods.updateUI();
|
||||
}
|
||||
|
||||
void loadLocalPlugins() {
|
||||
String path = Utilities.getPath("plugins");
|
||||
if (path == null) {
|
||||
if (path == null)
|
||||
return;
|
||||
}
|
||||
ArrayList<String> sl = Utilities.findAllFile(new File(path));
|
||||
DefaultTableModel model = (DefaultTableModel) lstPlugins.getModel();
|
||||
while (model.getRowCount() > 0) {
|
||||
while (model.getRowCount() > 0)
|
||||
model.removeRow(0);
|
||||
}
|
||||
for (String s : sl) {
|
||||
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,
|
||||
"", "", "", ""});
|
||||
} else {
|
||||
else
|
||||
model.addRow(new Object[]{!SettingsManager.settings.inactivePlugins.contains(s), s,
|
||||
p.name, p.version, p.author, p.description});
|
||||
}
|
||||
}
|
||||
|
||||
lstPlugins.updateUI();
|
||||
@ -3015,17 +2991,14 @@ public final class MainWindow extends javax.swing.JFrame
|
||||
|
||||
void loadLocalCoreMods() {
|
||||
String path = Utilities.getPath("coremods");
|
||||
if (path == null) {
|
||||
if (path == null)
|
||||
return;
|
||||
}
|
||||
ArrayList<String> sl = Utilities.findAllFile(new File(path));
|
||||
DefaultTableModel model = (DefaultTableModel) lstCoreMods.getModel();
|
||||
while (model.getRowCount() > 0) {
|
||||
while (model.getRowCount() > 0)
|
||||
model.removeRow(0);
|
||||
}
|
||||
for (String s : sl) {
|
||||
for (String s : sl)
|
||||
model.addRow(new Object[]{!SettingsManager.settings.inactiveCoreMods.contains(s), s, ModType.getModTypeShowName(ModType.getModType(Utilities.addSeparator(path) + s))});
|
||||
}
|
||||
|
||||
lstCoreMods.updateUI();
|
||||
}
|
||||
@ -3033,14 +3006,12 @@ public final class MainWindow extends javax.swing.JFrame
|
||||
void loadWorlds() {
|
||||
ArrayList<String> s = BackupManager.findAllWorlds();
|
||||
DefaultTableModel model = (DefaultTableModel) lstWorlds.getModel();
|
||||
if (SettingsManager.settings.inactiveWorlds == null) {
|
||||
SettingsManager.settings.inactiveWorlds = new ArrayList<String>();
|
||||
}
|
||||
for (String world : s) {
|
||||
if (SettingsManager.settings.inactiveWorlds == null)
|
||||
SettingsManager.settings.inactiveWorlds = new ArrayList<>();
|
||||
for (String world : s)
|
||||
model.addRow(new Object[]{
|
||||
world, Utilities.getGameDir() + world, !SettingsManager.settings.inactiveWorlds.contains(world)
|
||||
});
|
||||
}
|
||||
lstWorlds.updateUI();
|
||||
}
|
||||
|
||||
@ -3057,13 +3028,11 @@ public final class MainWindow extends javax.swing.JFrame
|
||||
}
|
||||
|
||||
void loadSchedules() {
|
||||
if (SettingsManager.settings.schedules == null) {
|
||||
SettingsManager.settings.schedules = new ArrayList<Schedule>();
|
||||
}
|
||||
if (SettingsManager.settings.schedules == null)
|
||||
SettingsManager.settings.schedules = new ArrayList<>();
|
||||
DefaultTableModel model = (DefaultTableModel) lstSchedules.getModel();
|
||||
for (Schedule s : SettingsManager.settings.schedules) {
|
||||
for (Schedule s : SettingsManager.settings.schedules)
|
||||
model.addRow(ScheduleTranslator.getRow(s));
|
||||
}
|
||||
lstSchedules.updateUI();
|
||||
}
|
||||
|
||||
@ -3073,67 +3042,46 @@ public final class MainWindow extends javax.swing.JFrame
|
||||
|
||||
void loadBukkits() {
|
||||
int idx = cboBukkitType.getSelectedIndex();
|
||||
if (idx == -1) {
|
||||
return;
|
||||
}
|
||||
String url = null;
|
||||
if (idx == -1) return;
|
||||
if (idx == 1) {
|
||||
BukkitFormatThread thread = new BukkitFormatThread(
|
||||
"http://dl.bukkit.org/downloads/craftbukkit/list/beta/",
|
||||
new DoneListener1<List<BukkitVersion>>() {
|
||||
@Override
|
||||
public void onDone(List<BukkitVersion> value) {
|
||||
craftBukkitBeta = value;
|
||||
reloadBukkitList();
|
||||
}
|
||||
"http://dl.bukkit.org/downloads/craftbukkit/list/beta/", value -> {
|
||||
craftBukkitBeta = value;
|
||||
reloadBukkitList();
|
||||
});
|
||||
thread.start();
|
||||
} else if (idx == 0) {
|
||||
BukkitFormatThread thread = new BukkitFormatThread(
|
||||
"http://dl.bukkit.org/downloads/craftbukkit/list/rb/",
|
||||
new DoneListener1<List<BukkitVersion>>() {
|
||||
@Override
|
||||
public void onDone(List<BukkitVersion> value) {
|
||||
craftBukkitRecommended = value;
|
||||
reloadBukkitList();
|
||||
}
|
||||
"http://dl.bukkit.org/downloads/craftbukkit/list/rb/", value -> {
|
||||
craftBukkitRecommended = value;
|
||||
reloadBukkitList();
|
||||
});
|
||||
thread.start();
|
||||
} else if (idx == 2) {
|
||||
BukkitFormatThread thread = new BukkitFormatThread(
|
||||
"http://dl.bukkit.org/downloads/craftbukkit/list/dev/",
|
||||
new DoneListener1<List<BukkitVersion>>() {
|
||||
@Override
|
||||
public void onDone(List<BukkitVersion> value) {
|
||||
craftBukkitDev = value;
|
||||
reloadBukkitList();
|
||||
}
|
||||
"http://dl.bukkit.org/downloads/craftbukkit/list/dev/", value -> {
|
||||
craftBukkitDev = value;
|
||||
reloadBukkitList();
|
||||
});
|
||||
thread.start();
|
||||
}
|
||||
}
|
||||
|
||||
void loadMCPCs() {
|
||||
ForgeFormatThread thread = new ForgeFormatThread(
|
||||
new DoneListener1<Map<String, List<ForgeVersion>>>() {
|
||||
@Override
|
||||
public void onDone(Map<String, List<ForgeVersion>> value) {
|
||||
mcpcPackages = value;
|
||||
reloadMCPCList();
|
||||
}
|
||||
});
|
||||
ForgeFormatThread thread = new ForgeFormatThread(value -> {
|
||||
mcpcPackages = value;
|
||||
reloadMCPCList();
|
||||
});
|
||||
thread.start();
|
||||
}
|
||||
|
||||
public void reloadMCPCList() {
|
||||
if (mcpcPackages == null) {
|
||||
if (mcpcPackages == null)
|
||||
return;
|
||||
}
|
||||
int cnt = cboCauldronMinecraft.getItemCount();
|
||||
cboCauldronMinecraft.removeAllItems();
|
||||
for (String s : mcpcPackages.keySet()) {
|
||||
for (String s : mcpcPackages.keySet())
|
||||
cboCauldronMinecraft.addItem(s);
|
||||
}
|
||||
|
||||
String mcver = (String) cboCauldronMinecraft.getSelectedItem();
|
||||
useMCPCVersions(mcver);
|
||||
@ -3141,9 +3089,8 @@ public final class MainWindow extends javax.swing.JFrame
|
||||
|
||||
public void useMCPCVersions(String ver) {
|
||||
DefaultTableModel model = (DefaultTableModel) lstMCPC.getModel();
|
||||
while (model.getRowCount() > 0) {
|
||||
while (model.getRowCount() > 0)
|
||||
model.removeRow(0);
|
||||
}
|
||||
for (ForgeVersion v : mcpcPackages.get(ver)) {
|
||||
Object[] row = new Object[]{
|
||||
v.mcver, v.ver, v.releasetime
|
||||
@ -3155,26 +3102,22 @@ public final class MainWindow extends javax.swing.JFrame
|
||||
|
||||
public void reloadBukkitList() {
|
||||
int idx = cboBukkitType.getSelectedIndex();
|
||||
if (idx == -1) {
|
||||
if (idx == -1)
|
||||
return;
|
||||
}
|
||||
if (idx == 1) {
|
||||
if (idx == 1)
|
||||
useBukkitVersions(craftBukkitBeta);
|
||||
} else if (idx == 0) {
|
||||
else if (idx == 0)
|
||||
useBukkitVersions(craftBukkitRecommended);
|
||||
} else if (idx == 2) {
|
||||
else if (idx == 2)
|
||||
useBukkitVersions(craftBukkitDev);
|
||||
}
|
||||
}
|
||||
|
||||
public void useBukkitVersions(List<BukkitVersion> list) {
|
||||
if (list == null) {
|
||||
if (list == null)
|
||||
return;
|
||||
}
|
||||
DefaultTableModel model = (DefaultTableModel) lstCraftbukkit.getModel();
|
||||
while (model.getRowCount() > 0) {
|
||||
while (model.getRowCount() > 0)
|
||||
model.removeRow(0);
|
||||
}
|
||||
for (BukkitVersion v : list) {
|
||||
Object[] row = new Object[]{
|
||||
v.buildNumber, v.version
|
||||
@ -3229,54 +3172,42 @@ public final class MainWindow extends javax.swing.JFrame
|
||||
void refreshInfos() {
|
||||
ArrayList<String> al = Utilities.findAllFile(new File(Utilities.getGameDir() + "infos-HMCSM"));
|
||||
DefaultTableModel model = (DefaultTableModel) lstInfos.getModel();
|
||||
for (String s : al) {
|
||||
for (String s : al)
|
||||
model.addRow(new Object[]{s, Utilities.trimExtension(s)});
|
||||
}
|
||||
lstInfos.updateUI();
|
||||
}
|
||||
|
||||
void refreshReports() {
|
||||
ArrayList<String> al = Utilities.findAllFile(new File(Utilities.getGameDir() + "crash-reports"));
|
||||
for (String s : al) {
|
||||
lstCrashReportsModel.addElement(s);
|
||||
}
|
||||
for (String s : al) lstCrashReportsModel.addElement(s);
|
||||
lstReports.setModel(lstCrashReportsModel);
|
||||
}
|
||||
|
||||
void getIP() {
|
||||
IPGet get = new IPGet();
|
||||
get.dl = new DoneListener1<String>() {
|
||||
|
||||
@Override
|
||||
public void onDone(String value) {
|
||||
lblIPAddress.setText("IP: " + value);
|
||||
}
|
||||
};
|
||||
get.dl = a -> lblIPAddress.setText("IP: " + a);;
|
||||
get.start();
|
||||
}
|
||||
|
||||
void loadBukkitPlugins() {
|
||||
final DefaultTableModel model = (DefaultTableModel) lstBukkitPlugins.getModel();
|
||||
while (model.getRowCount() > 0) {
|
||||
while (model.getRowCount() > 0)
|
||||
model.removeRow(0);
|
||||
}
|
||||
lstBukkitPlugins.updateUI();
|
||||
Thread t = new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
List<BukkitPlugin> l;
|
||||
if (cboCategory.getSelectedIndex() == 0) {
|
||||
if (cboCategory.getSelectedIndex() == 0)
|
||||
l = PluginManager.getPlugins();
|
||||
} else {
|
||||
else
|
||||
l = PluginManager.getPluginsByCategory(cboCategory.getSelectedItem().toString());
|
||||
}
|
||||
plugins = l;
|
||||
for (BukkitPlugin p : l) {
|
||||
for (BukkitPlugin p : l)
|
||||
model.addRow(new Object[]{
|
||||
p.plugin_name, p.description, p.getLatestVersion(), p.getLatestBukkit()
|
||||
});
|
||||
}
|
||||
lstBukkitPlugins.updateUI();
|
||||
} catch (Exception ex) {
|
||||
HMCLog.warn("Failed to get plugins", ex);
|
||||
@ -3294,9 +3225,8 @@ public final class MainWindow extends javax.swing.JFrame
|
||||
List<Category> l = PluginManager.getCategories();
|
||||
cboCategory.removeAllItems();
|
||||
cboCategory.addItem("所有");
|
||||
for (Category c : l) {
|
||||
for (Category c : l)
|
||||
cboCategory.addItem(c.name);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
HMCLog.warn("Failed to load bukkit categories.");
|
||||
}
|
||||
@ -3320,41 +3250,36 @@ public final class MainWindow extends javax.swing.JFrame
|
||||
|
||||
void loadPlayers() {
|
||||
Server s = Server.getInstance();
|
||||
if (s != null && s.isRunning) {
|
||||
s.getPlayerNumber(new DoneListener1<Pair<String, String[]>>() {
|
||||
@Override
|
||||
public void onDone(Pair<String, String[]> t) {
|
||||
lblPlayers.setText("在线人数" + t.key);
|
||||
lstPlayersModel.clear();
|
||||
for (String s : t.value) {
|
||||
lstPlayersModel.addElement(s);
|
||||
}
|
||||
lstPlayers.setModel(lstPlayersModel);
|
||||
}
|
||||
if (s != null && s.isRunning)
|
||||
s.getPlayerNumber(t -> {
|
||||
lblPlayers.setText("在线人数" + t.key);
|
||||
lstPlayersModel.clear();
|
||||
for (String s1 : t.value) lstPlayersModel.addElement(s1);
|
||||
lstPlayers.setModel(lstPlayersModel);
|
||||
});
|
||||
} else {
|
||||
else
|
||||
MessageBox.Show("服务器未开启!");
|
||||
}
|
||||
}
|
||||
|
||||
class ServerBeginListener implements DoneListener0 {
|
||||
class ServerBeginListener implements Event<Void> {
|
||||
|
||||
@Override
|
||||
public void onDone() {
|
||||
commandSet = new ArrayList<String>();
|
||||
public boolean call(Object sender, Void v) {
|
||||
commandSet = new ArrayList<>();
|
||||
txtMain.setText("");
|
||||
btnLaunch.setEnabled(false);
|
||||
btnStop.setEnabled(true);
|
||||
btnShutdown.setEnabled(true);
|
||||
btnCommand.setEnabled(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class ServerDoneListener implements DoneListener0 {
|
||||
class ServerDoneListener implements Event<Void> {
|
||||
|
||||
@Override
|
||||
public void onDone() {
|
||||
public boolean call(Object sender, Void v) {
|
||||
getPlayerNumberTimer = new Timer();
|
||||
getPlayerNumberTimer.schedule(new TimerTask() {
|
||||
|
||||
@ -3363,6 +3288,7 @@ public final class MainWindow extends javax.swing.JFrame
|
||||
loadPlayers();
|
||||
}
|
||||
}, 1000 * 60 * 10, 1000 * 60 * 10);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@ -3372,40 +3298,35 @@ public final class MainWindow extends javax.swing.JFrame
|
||||
if (!eula.exists()) {
|
||||
int option = JOptionPane.showConfirmDialog(null, "您是否确认新的EULA(https://account.mojang.com/documents/minecraft_eula)?如果拒绝会导致无法启动Minecraft 1.7.10或更高版本的服务端。");
|
||||
try {
|
||||
if (option == JOptionPane.YES_OPTION) {
|
||||
if (option == JOptionPane.YES_OPTION)
|
||||
FileUtils.write(eula, "eula=true");
|
||||
} else if (option == JOptionPane.NO_OPTION) {
|
||||
else if (option == JOptionPane.NO_OPTION)
|
||||
FileUtils.write(eula, "eula=false");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
MessageBox.Show("确认rula失败");
|
||||
}
|
||||
}
|
||||
File serverproperties = new File(new File(SettingsManager.settings.mainjar).getParentFile(), "server.properties");
|
||||
|
||||
if (!serverproperties.exists()) {
|
||||
if (!serverproperties.exists())
|
||||
try {
|
||||
FileUtils.write(serverproperties, ServerProperties.getDefault());
|
||||
} catch (IOException ex) {
|
||||
HMCLog.warn("Failed to save server.properties", ex);
|
||||
}
|
||||
}
|
||||
|
||||
Server.init(SettingsManager.settings.mainjar, String.valueOf(SettingsManager.settings.maxMemory));
|
||||
Server.getInstance()
|
||||
.addListener((MonitorThread.MonitorThreadListener) this);
|
||||
Server.getInstance()
|
||||
.addListener((DoneListener1<Integer>) this);
|
||||
.addListener((Event<Integer>) this);
|
||||
Server.getInstance()
|
||||
.clearSchedule();
|
||||
for (Schedule s : SettingsManager.settings.schedules) {
|
||||
for (Schedule s : SettingsManager.settings.schedules)
|
||||
Server.getInstance().addSchedule(s);
|
||||
}
|
||||
|
||||
Server.getInstance()
|
||||
.addServerStartedListener(new ServerBeginListener());
|
||||
Server.getInstance()
|
||||
.addServerDoneListener(new ServerDoneListener());
|
||||
Server.getInstance().startedEvent.register(new ServerBeginListener());
|
||||
Server.getInstance().startedEvent.register(new ServerDoneListener());
|
||||
try {
|
||||
Server.getInstance().run();
|
||||
} catch (IOException ex) {
|
||||
@ -3434,18 +3355,15 @@ public final class MainWindow extends javax.swing.JFrame
|
||||
} else if (evt.getKeyCode() == KeyEvent.VK_DOWN) {
|
||||
newCommandIndex++;
|
||||
type = 1;
|
||||
} else if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
|
||||
} else if (evt.getKeyCode() == KeyEvent.VK_ENTER)
|
||||
type = 2;
|
||||
}
|
||||
if (type == 1) {
|
||||
if (outOfCommandSet(newCommandIndex)) {
|
||||
if (outOfCommandSet(newCommandIndex))
|
||||
return;
|
||||
}
|
||||
commandIndex = newCommandIndex;
|
||||
txtCommand.setText(commandSet.get(commandIndex));
|
||||
} else if (type == 2) {
|
||||
} else if (type == 2)
|
||||
sendCommand();
|
||||
}
|
||||
}//GEN-LAST:event_txtCommandKeyPressed
|
||||
|
||||
private void btnSendCommandActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSendCommandActionPerformed
|
||||
@ -3530,13 +3448,12 @@ public final class MainWindow extends javax.swing.JFrame
|
||||
private void cboWorldTypeItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cboWorldTypeItemStateChanged
|
||||
int OAO = cboWorldType.getSelectedIndex();
|
||||
String type = "DEFAULT";
|
||||
if (OAO == 0) {
|
||||
if (OAO == 0)
|
||||
type = "DEFAULT";
|
||||
} else if (OAO == 1) {
|
||||
else if (OAO == 1)
|
||||
type = "FLAT";
|
||||
} else if (OAO == 2) {
|
||||
else if (OAO == 2)
|
||||
type = "LARGEBIMOES";
|
||||
}
|
||||
ServerProperties.getInstance().setLevelType(type);
|
||||
}//GEN-LAST:event_cboWorldTypeItemStateChanged
|
||||
|
||||
@ -3560,9 +3477,9 @@ public final class MainWindow extends javax.swing.JFrame
|
||||
lstOPModel.addElement(txtOPName.getText());
|
||||
lstOP.updateUI();
|
||||
|
||||
if (Server.isInstanceRunning()) {
|
||||
if (Server.isInstanceRunning())
|
||||
Server.getInstance().sendCommand("op " + txtOPName.getText());
|
||||
} else {
|
||||
else {
|
||||
Op.Operator operator = new Op.Operator(txtOPName.getText());
|
||||
op.op.add(operator);
|
||||
File dir = new File(SettingsManager.settings.mainjar).getParentFile();
|
||||
@ -3580,9 +3497,9 @@ public final class MainWindow extends javax.swing.JFrame
|
||||
lstOPModel.removeElement(lstOP.getSelectedIndex());
|
||||
lstOP.updateUI();
|
||||
|
||||
if (Server.isInstanceRunning()) {
|
||||
if (Server.isInstanceRunning())
|
||||
Server.getInstance().sendCommand("deop " + txtOPName.getText());
|
||||
} else {
|
||||
else {
|
||||
Op.Operator operator = new Op.Operator(s);
|
||||
op.op.remove(operator);
|
||||
File dir = new File(SettingsManager.settings.mainjar).getParentFile();
|
||||
@ -3599,9 +3516,9 @@ public final class MainWindow extends javax.swing.JFrame
|
||||
lstWhiteListModel.addElement(txtWhiteName.getText());
|
||||
lstWhiteList.updateUI();
|
||||
|
||||
if (Server.isInstanceRunning()) {
|
||||
if (Server.isInstanceRunning())
|
||||
Server.getInstance().sendCommand("whitelist add " + txtWhiteName.getText());
|
||||
} else {
|
||||
else {
|
||||
WhiteList.WhiteListPlayer player = new WhiteList.WhiteListPlayer(txtWhiteName.getText());
|
||||
whitelist.op.add(player);
|
||||
File dir = new File(SettingsManager.settings.mainjar).getParentFile();
|
||||
@ -3619,9 +3536,9 @@ public final class MainWindow extends javax.swing.JFrame
|
||||
lstWhiteListModel.removeElement(lstWhiteList.getSelectedIndex());
|
||||
lstWhiteList.updateUI();
|
||||
|
||||
if (Server.isInstanceRunning()) {
|
||||
if (Server.isInstanceRunning())
|
||||
Server.getInstance().sendCommand("whitelist remove " + txtWhiteName.getText());
|
||||
} else {
|
||||
else {
|
||||
WhiteList.WhiteListPlayer player = new WhiteList.WhiteListPlayer(name);
|
||||
whitelist.op.remove(player);
|
||||
File dir = new File(SettingsManager.settings.mainjar).getParentFile();
|
||||
@ -3773,22 +3690,20 @@ public final class MainWindow extends javax.swing.JFrame
|
||||
Vector strings = ((DefaultTableModel) lstExternalMods.getModel()).getDataVector();
|
||||
for (Object s : strings) {
|
||||
Vector v = (Vector) s;
|
||||
if (!(Boolean) v.elementAt(0)) {
|
||||
if (!(Boolean) v.elementAt(0))
|
||||
arrayList.add((String) v.elementAt(1));
|
||||
}
|
||||
}
|
||||
SettingsManager.settings.inactiveExtMods = arrayList;
|
||||
SettingsManager.save();
|
||||
}//GEN-LAST:event_btnSaveExtModActionPerformed
|
||||
|
||||
private void btnSavePluginsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSavePluginsActionPerformed
|
||||
ArrayList<String> arrayList = new ArrayList<String>();
|
||||
ArrayList<String> arrayList = new ArrayList<>();
|
||||
Vector strings = ((DefaultTableModel) lstCoreMods.getModel()).getDataVector();
|
||||
for (Object s : strings) {
|
||||
Vector v = (Vector) s;
|
||||
if (!(Boolean) v.elementAt(0)) {
|
||||
if (!(Boolean) v.elementAt(0))
|
||||
arrayList.add((String) v.elementAt(1));
|
||||
}
|
||||
}
|
||||
SettingsManager.settings.inactiveCoreMods = arrayList;
|
||||
SettingsManager.save();
|
||||
@ -3798,9 +3713,9 @@ public final class MainWindow extends javax.swing.JFrame
|
||||
lstBannedModel.addElement(txtBanName.getText());
|
||||
lstBanned.updateUI();
|
||||
|
||||
if (Server.isInstanceRunning()) {
|
||||
if (Server.isInstanceRunning())
|
||||
Server.getInstance().sendCommand("ban " + txtBanName.getText());
|
||||
} else {
|
||||
else {
|
||||
BannedPlayers.BannedPlayer player = new BannedPlayers.BannedPlayer(txtBanName.getText());
|
||||
banned.op.add(player);
|
||||
File dir = new File(SettingsManager.settings.mainjar).getParentFile();
|
||||
@ -3818,9 +3733,9 @@ public final class MainWindow extends javax.swing.JFrame
|
||||
lstBannedModel.removeElement(lstBanned.getSelectedIndex());
|
||||
lstBanned.updateUI();
|
||||
|
||||
if (Server.isInstanceRunning()) {
|
||||
if (Server.isInstanceRunning())
|
||||
Server.getInstance().sendCommand("pardon " + txtBanName.getText());
|
||||
} else {
|
||||
else {
|
||||
BannedPlayers.BannedPlayer player = new BannedPlayers.BannedPlayer(s);
|
||||
banned.op.remove(player);
|
||||
File dir = new File(SettingsManager.settings.mainjar).getParentFile();
|
||||
@ -3905,12 +3820,10 @@ public final class MainWindow extends javax.swing.JFrame
|
||||
private void btnSaveWorldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSaveWorldActionPerformed
|
||||
|
||||
DefaultTableModel model = (DefaultTableModel) lstWorlds.getModel();
|
||||
SettingsManager.settings.inactiveWorlds = new ArrayList<String>();
|
||||
for (int i = 0; i < model.getRowCount(); i++) {
|
||||
if ((Boolean) model.getValueAt(i, 2) == false) {
|
||||
SettingsManager.settings.inactiveWorlds = new ArrayList<>();
|
||||
for (int i = 0; i < model.getRowCount(); i++)
|
||||
if ((Boolean) model.getValueAt(i, 2) == false)
|
||||
SettingsManager.settings.inactiveWorlds.add((String) model.getValueAt(i, 0));
|
||||
}
|
||||
}
|
||||
SettingsManager.save();
|
||||
}//GEN-LAST:event_btnSaveWorldActionPerformed
|
||||
|
||||
@ -3931,9 +3844,8 @@ public final class MainWindow extends javax.swing.JFrame
|
||||
|
||||
private void btnDeleteBackupActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDeleteBackupActionPerformed
|
||||
int index = lstBackups.getSelectedRow();
|
||||
if (index == -1) {
|
||||
if (index == -1)
|
||||
return;
|
||||
}
|
||||
DefaultTableModel model = (DefaultTableModel) lstBackups.getModel();
|
||||
Utilities.deleteAll(new File(BackupManager.backupDir()
|
||||
+ model.getValueAt(index, 0) + "+"
|
||||
@ -3944,9 +3856,8 @@ public final class MainWindow extends javax.swing.JFrame
|
||||
|
||||
private void btnRestoreBackupActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRestoreBackupActionPerformed
|
||||
int index = lstBackups.getSelectedRow();
|
||||
if (index == -1) {
|
||||
if (index == -1)
|
||||
return;
|
||||
}
|
||||
DefaultTableModel model = (DefaultTableModel) lstBackups.getModel();
|
||||
BackupManager.restoreBackup(BackupManager.backupDir()
|
||||
+ model.getValueAt(index, 0) + "+"
|
||||
@ -3977,9 +3888,8 @@ public final class MainWindow extends javax.swing.JFrame
|
||||
try {
|
||||
DefaultTableModel model = (DefaultTableModel) lstInfos.getModel();
|
||||
int index = lstInfos.getSelectedRow();
|
||||
if (index == -1) {
|
||||
if (index == -1)
|
||||
return;
|
||||
}
|
||||
String path = Utilities.getGameDir() + "infos-HMCSM" + File.separator + model.getValueAt(index, 0);
|
||||
String content = FileUtils.readFileToString(new File(path));
|
||||
txtInfo.setText(content);
|
||||
@ -3990,14 +3900,13 @@ public final class MainWindow extends javax.swing.JFrame
|
||||
|
||||
private void btnAutoSearchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAutoSearchActionPerformed
|
||||
ArrayList<String> al = Utilities.findAllFile(IOUtils.currentDir());
|
||||
for (String s : al) {
|
||||
for (String s : al)
|
||||
if (ServerChecker.isServerJar(new File(s))) {
|
||||
String path = IOUtils.tryGetCanonicalFilePath(new File(IOUtils.currentDir(), 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
|
||||
@ -4007,9 +3916,8 @@ public final class MainWindow extends javax.swing.JFrame
|
||||
private void btnShowPluginInfoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnShowPluginInfoActionPerformed
|
||||
try {
|
||||
int index = lstBukkitPlugins.getSelectedRow();
|
||||
if (index == -1) {
|
||||
if (index == -1)
|
||||
return;
|
||||
}
|
||||
PluginInfo pi = PluginManager.getPluginInfo(plugins.get(index).slug);
|
||||
PluginInfoDialog w = new PluginInfoDialog(this, true, pi);
|
||||
w.setVisible(true);
|
||||
@ -4025,9 +3933,8 @@ public final class MainWindow extends javax.swing.JFrame
|
||||
private void btnShowReportActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnShowReportActionPerformed
|
||||
try {
|
||||
int index = lstReports.getSelectedIndex();
|
||||
if (index == -1) {
|
||||
if (index == -1)
|
||||
return;
|
||||
}
|
||||
String path = Utilities.getGameDir() + "crash-reports" + File.separator + lstCrashReportsModel.get(index);
|
||||
String content = FileUtils.readFileToString(new File(path));
|
||||
txtCrashReport.setText(content);
|
||||
@ -4083,15 +3990,13 @@ public final class MainWindow extends javax.swing.JFrame
|
||||
|
||||
private void btnDownloadCraftbukkitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDownloadCraftbukkitActionPerformed
|
||||
int idx = lstCraftbukkit.getSelectedRow();
|
||||
if (idx == -1) {
|
||||
if (idx == -1)
|
||||
return;
|
||||
}
|
||||
String ext = "";
|
||||
List<BukkitVersion> cb = null;
|
||||
int idx2 = cboBukkitType.getSelectedIndex();
|
||||
if (idx2 == -1) {
|
||||
if (idx2 == -1)
|
||||
return;
|
||||
}
|
||||
switch (idx2) {
|
||||
case 0:
|
||||
ext = "rb";
|
||||
@ -4101,6 +4006,8 @@ public final class MainWindow extends javax.swing.JFrame
|
||||
ext = "beta";
|
||||
cb = craftBukkitBeta;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
BukkitVersion v = cb.get(idx);
|
||||
File file = new File(IOUtils.currentDir(), "craftbukkit-" + ext + "-" + v.version + ".jar");
|
||||
@ -4110,18 +4017,16 @@ public final class MainWindow extends javax.swing.JFrame
|
||||
|
||||
private void btnDownloadMCPCActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDownloadMCPCActionPerformed
|
||||
int idx = lstMCPC.getSelectedRow();
|
||||
if (idx == -1) {
|
||||
if (idx == -1)
|
||||
return;
|
||||
}
|
||||
ForgeVersion v = mcpcPackages.get(cboCauldronMinecraft.getSelectedItem().toString()).get(idx);
|
||||
String url;
|
||||
File filepath = new File(IOUtils.currentDir(), "forge-installer.jar");
|
||||
url = v.installer[1];
|
||||
if (!TaskWindow.getInstance().addTask(new FileDownloadTask(url, filepath).setTag("cauldron-" + v.ver)).start()) {
|
||||
if (!TaskWindow.getInstance().addTask(new FileDownloadTask(url, filepath).setTag("cauldron-" + v.ver)).start())
|
||||
MessageBox.Show(C.I18N.getString("install.failed_download_forge"));
|
||||
} else {
|
||||
else
|
||||
installMCPC(filepath);
|
||||
}
|
||||
}//GEN-LAST:event_btnDownloadMCPCActionPerformed
|
||||
|
||||
private void installMCPC(final File filepath) {
|
||||
@ -4144,18 +4049,16 @@ public final class MainWindow extends javax.swing.JFrame
|
||||
Vector strings = ((DefaultTableModel) lstPlugins.getModel()).getDataVector();
|
||||
for (Object s : strings) {
|
||||
Vector v = (Vector) s;
|
||||
if (!(Boolean) v.elementAt(0)) {
|
||||
if (!(Boolean) v.elementAt(0))
|
||||
arrayList.add((String) v.elementAt(1));
|
||||
}
|
||||
}
|
||||
SettingsManager.settings.inactivePlugins = arrayList;
|
||||
SettingsManager.save();
|
||||
}//GEN-LAST:event_btnSaveCoreModActionPerformed
|
||||
|
||||
private void cboCauldronMinecraftItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cboCauldronMinecraftItemStateChanged
|
||||
if (cboCauldronMinecraft.getItemCount() > 0 && mcpcPackages != null && mcpcPackages.containsKey(cboCauldronMinecraft.getSelectedItem().toString())) {
|
||||
if (cboCauldronMinecraft.getItemCount() > 0 && mcpcPackages != null && mcpcPackages.containsKey(cboCauldronMinecraft.getSelectedItem().toString()))
|
||||
useMCPCVersions(cboCauldronMinecraft.getSelectedItem().toString());
|
||||
}
|
||||
}//GEN-LAST:event_cboCauldronMinecraftItemStateChanged
|
||||
|
||||
private void btnInstallMCPCActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnInstallMCPCActionPerformed
|
||||
@ -4177,9 +4080,8 @@ public final class MainWindow extends javax.swing.JFrame
|
||||
}//GEN-LAST:event_jButton11ActionPerformed
|
||||
|
||||
private void btnCommandMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnCommandMouseClicked
|
||||
if (Server.getInstance() == null || !Server.getInstance().isRunning || !btnCommand.isEnabled()) {
|
||||
if (Server.getInstance() == null || !Server.getInstance().isRunning || !btnCommand.isEnabled())
|
||||
return;
|
||||
}
|
||||
ppmBasically.show(evt.getComponent(), evt.getPoint().x, evt.getPoint().y);
|
||||
}//GEN-LAST:event_btnCommandMouseClicked
|
||||
|
||||
@ -4192,9 +4094,8 @@ public final class MainWindow extends javax.swing.JFrame
|
||||
}//GEN-LAST:event_formWindowClosed
|
||||
|
||||
private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
|
||||
if (Server.getInstance() != null && Server.getInstance().isRunning) {
|
||||
if (Server.getInstance() != null && Server.getInstance().isRunning)
|
||||
Server.getInstance().stop();
|
||||
}
|
||||
}//GEN-LAST:event_formWindowClosing
|
||||
|
||||
private void txtMaxMemoryFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtMaxMemoryFocusLost
|
||||
@ -4212,7 +4113,7 @@ public final class MainWindow extends javax.swing.JFrame
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDone(Integer t) {
|
||||
public boolean call(Object sender, Integer t) {
|
||||
btnLaunch.setEnabled(true);
|
||||
btnStop.setEnabled(false);
|
||||
btnShutdown.setEnabled(false);
|
||||
@ -4229,30 +4130,28 @@ public final class MainWindow extends javax.swing.JFrame
|
||||
getPlayerNumberTimer.cancel();
|
||||
getPlayerNumberTimer = null;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void sendCommand() {
|
||||
String command = txtCommand.getText();
|
||||
boolean append = false;
|
||||
if (outOfCommandSet()) {
|
||||
if (outOfCommandSet())
|
||||
append = true;
|
||||
} else if (!command.equals(commandSet.get(commandIndex))) {
|
||||
else if (!command.equals(commandSet.get(commandIndex)))
|
||||
append = true;
|
||||
}
|
||||
if (Server.getInstance() != null) {
|
||||
if (Server.getInstance() != null)
|
||||
Server.getInstance().sendCommand(command);
|
||||
} else {
|
||||
else
|
||||
System.err.println("Server is null.");
|
||||
}
|
||||
System.out.println("Send command: " + command);
|
||||
onStatus(">" + command);
|
||||
txtCommand.setText("");
|
||||
if (append) {
|
||||
commandSet.add(command);
|
||||
commandIndex = commandSet.size();
|
||||
} else {
|
||||
} else
|
||||
commandIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
MonitorThread mainThread;
|
||||
|
Loading…
x
Reference in New Issue
Block a user