Compare commits

..
3 Commits
Author SHA1 Message Date
huangyuhui 7c2cfc171e Switch to CountDownLatch 2016-03-05 13:23:16 +08:00
huangyuhui 5d4a3c1df6 Fixed null when invoking some server commands 2016-03-04 20:18:25 +08:00
huangyuhui 587df1f5bb Fixed #45 2016-03-04 19:30:58 +08:00
15 changed files with 141 additions and 359 deletions

No files matched your search

+5 -3
View File
@@ -7,15 +7,17 @@ branches:
before_deploy:
- git config --global user.email ${GITHUB_EMAIL}
- git config --global user.name ${GITHUB_NAME}
- git tag ${VERSION_ROOT}.${TRAVIS_BUILD_NUMBER}
- git tag ${TRAVIS_BUILD_NUMBER}
- git push -q ${REPO} --tags
deploy:
provider: releases
api_key:
secure: lfFEwKtij/s9Ao/SKL7oVdsWcfASshZuwT27gllMrTx1ZQqLCG2I5mGJOp5ukx7lb3y4Tu316nFasLjy9NI3eLXSx9f0w4q+wMf0K5Yj9iOwu/TIn7JkLyHDMQ20qRwGxZplS2WUb669gIRg+l6jUHeTBW+dlTxr0mMa6WHIl8UDpHwfFrGC3i6dL4y6WlDwGl2rYktvOoA/iqvtglBcHuXaL2sDfhp5MXRcYULTIw+b9zmiQXP665DQN+Su5I3gwB4y5X8RH72GAacZn13fEIo5i8UUoHM7UQxM8y8DKSO3avyFCfpUle9+9sErQVW7b6JV1c+AoLWuAhNJLMlUTKarZE7UMqfjvoQHxX5hp2B2WHLEON/UJiGf25HJWx6VhJitE0/odujqnG/umesqki2jMTs6gPcxbc9iBjzUg+ZmFztdtC+Emnni7lpqVVl+Y5hsJRn3Z6rIiNgwmaE0r2OQgAm1vRYFc7jvOdRfyFG+uCRZF6nS56BzJ7dLc0WW8dTgSft6YFll4ZYL6hiI9qiIaBAK948y5HV+6VBWuO3xf/G2CUFbE1Y9qUCjToh3ahxNDzZvXB+rXqvlvNQOi5l8n594oQ61n45qIHSKlMBn9Bxhw29oWT5mo1aYIaNXbpzKam2w4mK0T3VrgTszu/3282wRbNr+VAwdGMfwW1s=
file:
- HMCL/build/libs/HMCL-${VERSION_ROOT}.${TRAVIS_BUILD_NUMBER}.jar
- HMCL/build/libs/HMCL-${VERSION_ROOT}.${TRAVIS_BUILD_NUMBER}.exe
- HMCL/build/libs/HMCL-${HMCL_VERSION_ROOT}.${TRAVIS_BUILD_NUMBER}.jar
- HMCL/build/libs/HMCL-${HMCL_VERSION_ROOT}.${TRAVIS_BUILD_NUMBER}.exe
- HMCSM/build/libs/HMCSM-${HMCSM_VERSION_ROOT}.${TRAVIS_BUILD_NUMBER}.jar
- HMCSM/build/libs/HMCSM-${HMCSM_VERSION_ROOT}.${TRAVIS_BUILD_NUMBER}.exe
on:
repo: huanghongxun/HMCL
tags: false
@@ -1,129 +0,0 @@
/*
* Hello Minecraft! Launcher.
* Copyright (C) 2013 huangyuhui <huanghongxun2008@126.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see {http://www.gnu.org/licenses/}.
*/
package org.jackhuang.hellominecraft.launcher;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.lang.reflect.Method;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.jackhuang.hellominecraft.util.C;
import org.jackhuang.hellominecraft.util.StrUtils;
import org.jackhuang.hellominecraft.launcher.util.MinecraftCrashAdvicer;
import org.jackhuang.hellominecraft.util.DoubleOutputStream;
import org.jackhuang.hellominecraft.util.LauncherPrintStream;
import org.jackhuang.hellominecraft.util.Utils;
/**
*
* @author huangyuhui
*/
public final class Launcher {
static final Logger LOGGER = Logger.getLogger(Launcher.class.getName());
static String classPath = "";
public static void main(String[] args) {
LOGGER.log(Level.INFO, "*** {0} ***", Main.makeTitle());
boolean showInfo = false;
String mainClass = "net.minecraft.client.Minecraft";
ArrayList<String> cmdList = new ArrayList<>();
for (String s : args)
if (s.startsWith("-cp="))
classPath = classPath.concat(s.substring("-cp=".length()));
else if (s.startsWith("-mainClass="))
mainClass = s.substring("-mainClass=".length());
else if (s.equals("-debug"))
showInfo = true;
else
cmdList.add(s);
String[] tokenized = StrUtils.tokenize(classPath, File.pathSeparator);
int len = tokenized.length;
if (showInfo) {
try {
File logFile = new File("hmclmc.log");
if (!logFile.exists() && !logFile.createNewFile())
LOGGER.info("Failed to create log file");
else {
FileOutputStream tc = new FileOutputStream(logFile);
DoubleOutputStream out = new DoubleOutputStream(tc, System.out);
System.setOut(new LauncherPrintStream(out));
DoubleOutputStream err = new DoubleOutputStream(tc, System.err);
System.setErr(new LauncherPrintStream(err));
}
} catch (IOException e) {
LOGGER.log(Level.SEVERE, "Failed to add log file appender.", e);
}
LOGGER.log(Level.INFO, "Arguments: '{'\n{0}\n'}'", StrUtils.parseParams(" ", args, "\n"));
LOGGER.log(Level.INFO, "Main Class: {0}", mainClass);
LOGGER.log(Level.INFO, "Class Path: '{'\n{0}\n'}'", StrUtils.parseParams(" ", tokenized, "\n"));
}
URL[] urls = new URL[len];
try {
for (int j = 0; j < len; j++)
urls[j] = new File(tokenized[j]).toURI().toURL();
} catch (Throwable e) {
LOGGER.log(Level.SEVERE, "Failed to get classpath.", e);
return;
}
Method minecraftMain;
URLClassLoader ucl = new URLClassLoader(urls, URLClassLoader.getSystemClassLoader().getParent());
Thread.currentThread().setContextClassLoader(ucl);
try {
minecraftMain = ucl.loadClass(mainClass).getMethod("main", String[].class);
} catch (ClassNotFoundException | NoSuchMethodException | SecurityException t) {
LOGGER.log(Level.SEVERE, "Minecraft main class not found.", t);
return;
}
LOGGER.info("*** Launching Game ***");
int flag = 0;
try {
minecraftMain.invoke(null, new Object[] { (String[]) cmdList.toArray(new String[cmdList.size()]) });
} catch (Throwable throwable) {
String trace = StrUtils.getStackTrace(throwable);
System.err.println(C.i18n("crash.minecraft"));
System.err.println(MinecraftCrashAdvicer.getAdvice(trace));
System.err.println(trace);
flag = 1;
}
LOGGER.info("*** Game Exited ***");
try {
Utils.shutdownForcely(flag);
} catch (Exception e) {
LOGGER.log(Level.SEVERE, "Failed to shut down this process...", e);
}
}
}
@@ -76,6 +76,8 @@ public class MojangDownloadProvider extends IDownloadProvider {
public String getParsedLibraryDownloadURL(String str) {
if (str == null)
return null;
else if (str.contains("scala-swing") || str.contains("scala-xml") || str.contains("scala-parser-combinators"))
return str.replace("http://files.minecraftforge.net/maven", "http://ftb.cursecdn.com/FTB2/maven/");
else if (str.contains("typesafe") || str.contains("scala"))
if (SupportedLocales.NOW_LOCALE.self == Locale.CHINA)
return str.replace("http://files.minecraftforge.net/maven", "http://maven.oschina.net/content/groups/public");
@@ -30,7 +30,6 @@ import org.jackhuang.hellominecraft.util.system.OS;
import org.jackhuang.hellominecraft.util.system.Platform;
import org.jackhuang.hellominecraft.util.StrUtils;
import org.jackhuang.hellominecraft.util.Utils;
import org.jackhuang.hellominecraft.launcher.Launcher;
import org.jackhuang.hellominecraft.launcher.core.GameException;
import org.jackhuang.hellominecraft.launcher.core.auth.UserProfileProvider;
import org.jackhuang.hellominecraft.launcher.core.version.MinecraftVersion;
@@ -130,12 +129,6 @@ public abstract class AbstractMinecraftLoader implements IMinecraftLoader {
if (OS.os() != OS.WINDOWS)
res.add("-Duser.home=" + gameDir.getParent());
if (!options.isCanceledWrapper()) {
res.add("-cp");
res.add(StrUtils.parseParams("", Utils.getURLString(), File.pathSeparator));
res.add(Launcher.class.getCanonicalName());
}
}
@Override
@@ -168,9 +161,6 @@ public abstract class AbstractMinecraftLoader implements IMinecraftLoader {
if (options.isFullscreen())
res.add("--fullscreen");
if (options.isDebug() && !options.isCanceledWrapper())
res.add("-debug");
if (StrUtils.isNotBlank(options.getProxyHost()) && StrUtils.isNotBlank(options.getProxyPort()) && MathUtils.canParseInt(options.getProxyPort())) {
res.add("--proxyHost");
res.add(options.getProxyHost());
@@ -30,7 +30,7 @@ public class LaunchOptions {
private String name, versionName, javaArgs, minecraftArgs, maxMemory, permSize, width, height, serverIp, wrapper;
private String proxyHost, proxyPort, proxyUser, proxyPass, javaDir, launchVersion, type, precalledCommand;
private boolean fullscreen, debug, noJVMArgs, canceledWrapper;
private boolean fullscreen, noJVMArgs;
private JdkVersion java;
private File gameDir;
private GameDirType gameDirType;
@@ -127,14 +127,6 @@ public class LaunchOptions {
this.fullscreen = fullscreen;
}
public boolean isDebug() {
return debug;
}
public void setDebug(boolean debug) {
this.debug = debug;
}
public GameDirType getGameDirType() {
return gameDirType;
}
@@ -167,14 +159,6 @@ public class LaunchOptions {
this.minecraftArgs = minecraftArgs;
}
public boolean isCanceledWrapper() {
return canceledWrapper;
}
public void setCanceledWrapper(boolean canceledWrapper) {
this.canceledWrapper = canceledWrapper;
}
public String getServerIp() {
return serverIp;
}
@@ -43,7 +43,7 @@ public class MinecraftLoader extends AbstractMinecraftLoader {
@Override
protected void makeSelf(List<String> res) throws GameException {
StringBuilder library = new StringBuilder(options.isCanceledWrapper() ? "" : "-cp=");
StringBuilder library = new StringBuilder("");
for (MinecraftLibrary l : version.libraries)
if (l.allow() && !l.isRequiredToUnzip())
library.append(l.getFilePath(gameDir).getAbsolutePath()).append(File.pathSeparator);
@@ -51,11 +51,9 @@ public class MinecraftLoader extends AbstractMinecraftLoader {
if (!f.exists())
throw new GameException("Minecraft jar does not exists");
library.append(IOUtils.tryGetCanonicalFilePath(f)).append(File.pathSeparator);
if (options.isCanceledWrapper())
res.add("-cp");
res.add("-cp");
res.add(library.toString().substring(0, library.length() - File.pathSeparator.length()));
String mainClass = version.mainClass;
res.add((options.isCanceledWrapper() ? "" : "-mainClass=") + mainClass);
res.add(version.mainClass);
String[] splitted = StrUtils.tokenize(version.minecraftArguments);
@@ -41,7 +41,7 @@ public class VersionSetting {
private String javaArgs, minecraftArgs, maxMemory, permSize, width, height;
private String javaDir, precalledCommand, serverIp, java, wrapper;
private boolean fullscreen, debug, noJVMArgs, canceledWrapper;
private boolean fullscreen, noJVMArgs;
/**
* 0 - Close the launcher when the game starts.<br/>
@@ -59,7 +59,7 @@ public class VersionSetting {
public transient final EventHandler<String> propertyChanged = new EventHandler<>(this);
public VersionSetting() {
debug = fullscreen = canceledWrapper = false;
fullscreen = false;
launcherVisibility = 1;
gameDirType = 0;
javaDir = java = minecraftArgs = serverIp = precalledCommand = wrapper = "";
@@ -76,11 +76,9 @@ public class VersionSetting {
fullscreen = v.fullscreen;
javaArgs = v.javaArgs;
javaDir = v.javaDir;
debug = v.debug;
minecraftArgs = v.minecraftArgs;
permSize = v.permSize;
gameDirType = v.gameDirType;
canceledWrapper = v.canceledWrapper;
noJVMArgs = v.noJVMArgs;
launcherVisibility = v.launcherVisibility;
precalledCommand = v.precalledCommand;
@@ -193,15 +191,6 @@ public class VersionSetting {
propertyChanged.execute("fullscreen");
}
public boolean isDebug() {
return debug;
}
public void setDebug(boolean debug) {
this.debug = debug;
propertyChanged.execute("debug");
}
public LauncherVisibility getLauncherVisibility() {
return LauncherVisibility.values()[launcherVisibility];
}
@@ -249,15 +238,6 @@ public class VersionSetting {
propertyChanged.execute("minecraftArgs");
}
public boolean isCanceledWrapper() {
return canceledWrapper;
}
public void setCanceledWrapper(boolean canceledWrapper) {
this.canceledWrapper = canceledWrapper;
propertyChanged.execute("canceledWrapper");
}
public String getPrecalledCommand() {
return precalledCommand;
}
@@ -287,8 +267,6 @@ public class VersionSetting {
public LaunchOptions createLaunchOptions(File gameDir) {
LaunchOptions x = new LaunchOptions();
x.setCanceledWrapper(isCanceledWrapper());
x.setDebug(isDebug());
x.setFullscreen(isFullscreen());
x.setWrapper(getWrapper());
x.setGameDir(gameDir);
@@ -388,52 +388,45 @@
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="0" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="txtWrapperLauncher" alignment="0" max="32767" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Component id="lblPrecalledCommand1" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
<Group type="103" alignment="0" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="txtPrecalledCommand" alignment="0" max="32767" attributes="0"/>
<Component id="txtServerIP" alignment="0" max="32767" attributes="0"/>
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="lblPrecalledCommand" alignment="0" min="-2" max="-2" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Component id="chkDebug" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="chkCancelWrapper" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="chkNoJVMArgs" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="lblServerIP" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="0" pref="263" max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="lblMinecraftArgs" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="lblPermSize" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="lblJavaArgs" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="txtJavaArgs" max="32767" attributes="0"/>
<Component id="txtMinecraftArgs" max="32767" attributes="0"/>
<Component id="txtPermSize" alignment="1" max="32767" attributes="0"/>
</Group>
<Component id="txtWrapperLauncher" alignment="0" max="32767" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Component id="lblPrecalledCommand1" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
<Component id="txtPrecalledCommand" alignment="0" max="32767" attributes="0"/>
<Component id="txtServerIP" alignment="0" max="32767" attributes="0"/>
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="lblPrecalledCommand" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="lblServerIP" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="0" pref="716" max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="lblMinecraftArgs" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="lblPermSize" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="lblJavaArgs" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="txtJavaArgs" max="32767" attributes="0"/>
<Component id="txtMinecraftArgs" max="32767" attributes="0"/>
<Component id="txtPermSize" alignment="1" max="32767" attributes="0"/>
</Group>
</Group>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="chkNoJVMArgs" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
@@ -467,27 +460,13 @@
<EmptySpace max="-2" attributes="0"/>
<Component id="txtServerIP" min="-2" pref="26" max="-2" attributes="0"/>
<EmptySpace pref="168" max="32767" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="chkDebug" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="chkNoJVMArgs" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="chkCancelWrapper" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="chkNoJVMArgs" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JCheckBox" name="chkDebug">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/jackhuang/hellominecraft/launcher/I18N.properties" key="advancedsettings.debug_mode" replaceFormat="C.i18n(&quot;{key}&quot;)"/>
</Property>
</Properties>
<Events>
<EventHandler event="itemStateChanged" listener="java.awt.event.ItemListener" parameters="java.awt.event.ItemEvent" handler="chkDebugItemStateChanged"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="lblJavaArgs">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
@@ -539,16 +518,6 @@
<EventHandler event="itemStateChanged" listener="java.awt.event.ItemListener" parameters="java.awt.event.ItemEvent" handler="chkNoJVMArgsItemStateChanged"/>
</Events>
</Component>
<Component class="javax.swing.JCheckBox" name="chkCancelWrapper">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/jackhuang/hellominecraft/launcher/I18N.properties" key="advancedsettings.cancel_wrapper_launcher" replaceFormat="C.i18n(&quot;{key}&quot;)"/>
</Property>
</Properties>
<Events>
<EventHandler event="itemStateChanged" listener="java.awt.event.ItemListener" parameters="java.awt.event.ItemEvent" handler="chkCancelWrapperItemStateChanged"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="lblPrecalledCommand">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
@@ -277,7 +277,6 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
btnChoosingGameDir = new javax.swing.JButton();
btnCleanGame = new javax.swing.JButton();
pnlAdvancedSettings = new AnimatedPanel();
chkDebug = new javax.swing.JCheckBox();
lblJavaArgs = new javax.swing.JLabel();
txtJavaArgs = new javax.swing.JTextField();
txtMinecraftArgs = new javax.swing.JTextField();
@@ -285,7 +284,6 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
lblPermSize = new javax.swing.JLabel();
txtPermSize = new javax.swing.JTextField();
chkNoJVMArgs = new javax.swing.JCheckBox();
chkCancelWrapper = new javax.swing.JCheckBox();
lblPrecalledCommand = new javax.swing.JLabel();
txtPrecalledCommand = new javax.swing.JTextField();
lblServerIP = new javax.swing.JLabel();
@@ -517,13 +515,6 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
tabVersionEdit.addTab(C.i18n("settings"), pnlSettings); // NOI18N
chkDebug.setText(C.i18n("advancedsettings.debug_mode")); // NOI18N
chkDebug.addItemListener(new java.awt.event.ItemListener() {
public void itemStateChanged(java.awt.event.ItemEvent evt) {
chkDebugItemStateChanged(evt);
}
});
lblJavaArgs.setText(C.i18n("advancedsettings.jvm_args")); // NOI18N
txtJavaArgs.setToolTipText(C.i18n("advancedsettings.java_args_default")); // NOI18N
@@ -556,13 +547,6 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
}
});
chkCancelWrapper.setText(C.i18n("advancedsettings.cancel_wrapper_launcher")); // NOI18N
chkCancelWrapper.addItemListener(new java.awt.event.ItemListener() {
public void itemStateChanged(java.awt.event.ItemEvent evt) {
chkCancelWrapperItemStateChanged(evt);
}
});
lblPrecalledCommand.setText(C.i18n("advancedsettings.precall_command")); // NOI18N
txtPrecalledCommand.addFocusListener(new java.awt.event.FocusAdapter() {
@@ -591,40 +575,35 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
pnlAdvancedSettings.setLayout(pnlAdvancedSettingsLayout);
pnlAdvancedSettingsLayout.setHorizontalGroup(
pnlAdvancedSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(pnlAdvancedSettingsLayout.createSequentialGroup()
.addGap(0, 0, 0)
.addGroup(pnlAdvancedSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(pnlAdvancedSettingsLayout.createSequentialGroup()
.addGroup(pnlAdvancedSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(txtWrapperLauncher)
.addGroup(pnlAdvancedSettingsLayout.createSequentialGroup()
.addComponent(lblPrecalledCommand1)
.addGap(0, 0, Short.MAX_VALUE)))
.addContainerGap())
.addGroup(pnlAdvancedSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(pnlAdvancedSettingsLayout.createSequentialGroup()
.addGroup(pnlAdvancedSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(txtPrecalledCommand)
.addComponent(txtServerIP)
.addComponent(txtWrapperLauncher)
.addGroup(pnlAdvancedSettingsLayout.createSequentialGroup()
.addGroup(pnlAdvancedSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lblPrecalledCommand)
.addGroup(pnlAdvancedSettingsLayout.createSequentialGroup()
.addComponent(chkDebug)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(chkCancelWrapper)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(chkNoJVMArgs))
.addComponent(lblServerIP))
.addGap(0, 263, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlAdvancedSettingsLayout.createSequentialGroup()
.addGroup(pnlAdvancedSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lblMinecraftArgs)
.addComponent(lblPermSize)
.addComponent(lblJavaArgs))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(pnlAdvancedSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(txtJavaArgs)
.addComponent(txtMinecraftArgs)
.addComponent(txtPermSize, javax.swing.GroupLayout.Alignment.TRAILING))))))
.addComponent(lblPrecalledCommand1)
.addGap(0, 0, Short.MAX_VALUE)))
.addContainerGap())
.addComponent(txtPrecalledCommand)
.addComponent(txtServerIP)
.addGroup(pnlAdvancedSettingsLayout.createSequentialGroup()
.addGroup(pnlAdvancedSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lblPrecalledCommand)
.addComponent(lblServerIP))
.addGap(0, 716, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlAdvancedSettingsLayout.createSequentialGroup()
.addGroup(pnlAdvancedSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lblMinecraftArgs)
.addComponent(lblPermSize)
.addComponent(lblJavaArgs))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(pnlAdvancedSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(txtJavaArgs)
.addComponent(txtMinecraftArgs)
.addComponent(txtPermSize, javax.swing.GroupLayout.Alignment.TRAILING))))
.addGroup(pnlAdvancedSettingsLayout.createSequentialGroup()
.addContainerGap()
.addComponent(chkNoJVMArgs)
.addGap(0, 0, Short.MAX_VALUE))
);
pnlAdvancedSettingsLayout.setVerticalGroup(
pnlAdvancedSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@@ -654,10 +633,7 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txtServerIP, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 168, Short.MAX_VALUE)
.addGroup(pnlAdvancedSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(chkDebug)
.addComponent(chkNoJVMArgs)
.addComponent(chkCancelWrapper))
.addComponent(chkNoJVMArgs)
.addContainerGap())
);
@@ -1138,16 +1114,6 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
Settings.getLastProfile().getSelectedVersionSetting().setFullscreen(chkFullscreen.isSelected());
}//GEN-LAST:event_chkFullscreenItemStateChanged
private void chkDebugItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_chkDebugItemStateChanged
if (!isLoading)
Settings.getLastProfile().getSelectedVersionSetting().setDebug(chkDebug.isSelected());
}//GEN-LAST:event_chkDebugItemStateChanged
private void chkCancelWrapperItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_chkCancelWrapperItemStateChanged
if (!isLoading)
Settings.getLastProfile().getSelectedVersionSetting().setCanceledWrapper(chkCancelWrapper.isSelected());
}//GEN-LAST:event_chkCancelWrapperItemStateChanged
private void chkNoJVMArgsItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_chkNoJVMArgsItemStateChanged
if (!isLoading)
Settings.getLastProfile().getSelectedVersionSetting().setNoJVMArgs(chkNoJVMArgs.isSelected());
@@ -1207,10 +1173,8 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
txtMinecraftArgs.setText(profile.getMinecraftArgs());
txtPrecalledCommand.setText(profile.getPrecalledCommand());
txtServerIP.setText(profile.getServerIp());
chkDebug.setSelected(profile.isDebug());
chkNoJVMArgs.setSelected(profile.isNoJVMArgs());
chkFullscreen.setSelected(profile.isFullscreen());
chkCancelWrapper.setSelected(profile.isCanceledWrapper());
cboLauncherVisibility.setSelectedIndex(profile.getLauncherVisibility().ordinal());
cboRunDirectory.setSelectedIndex(profile.getGameDirType().ordinal());
cboJava.setSelectedIndex(profile.getJavaIndexInAllJavas());
@@ -1360,8 +1324,6 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
private javax.swing.JComboBox cboProfiles;
private javax.swing.JComboBox cboRunDirectory;
private javax.swing.JComboBox cboVersions;
private javax.swing.JCheckBox chkCancelWrapper;
private javax.swing.JCheckBox chkDebug;
private javax.swing.JCheckBox chkFullscreen;
private javax.swing.JCheckBox chkNoJVMArgs;
private javax.swing.JScrollPane jScrollPane1;
@@ -17,6 +17,7 @@
*/
package org.jackhuang.hellominecraft.launcher.ui;
import java.io.File;
import java.io.IOException;
import java.util.List;
import javax.swing.JOptionPane;
@@ -25,11 +26,13 @@ import org.jackhuang.hellominecraft.launcher.core.launch.GameLauncher;
import org.jackhuang.hellominecraft.launcher.core.launch.LaunchingState;
import org.jackhuang.hellominecraft.launcher.setting.Profile;
import org.jackhuang.hellominecraft.launcher.setting.Settings;
import org.jackhuang.hellominecraft.launcher.util.MinecraftCrashAdvicer;
import org.jackhuang.hellominecraft.util.C;
import org.jackhuang.hellominecraft.util.Event;
import org.jackhuang.hellominecraft.util.MessageBox;
import org.jackhuang.hellominecraft.util.func.Consumer;
import org.jackhuang.hellominecraft.util.logging.HMCLog;
import org.jackhuang.hellominecraft.util.system.FileUtils;
import org.jackhuang.hellominecraft.util.system.JavaProcessMonitor;
import org.jackhuang.hellominecraft.util.ui.LogWindow;
import org.jackhuang.hellominecraft.util.ui.WebFrame;
@@ -95,8 +98,20 @@ public class LaunchingUIDaemon {
JavaProcessMonitor jpm = new JavaProcessMonitor(p);
jpm.applicationExitedAbnormallyEvent.register(t -> {
HMCLog.err("The game exited abnormally, exit code: " + t);
MessageBox.Show(C.i18n("launch.exited_abnormally") + " exit code: " + t);
WebFrame f = new WebFrame(jpm.getJavaProcess().getStdOutLines().toArray(new String[0]));
String[] logs = jpm.getJavaProcess().getStdOutLines().toArray(new String[0]);
String errorText = null;
for (String s : logs) {
int pos = s.lastIndexOf("#@!@#");
if (pos >= 0 && pos < s.length() - "#@!@#".length() - 1) {
errorText = s.substring(pos + "#@!@#".length()).trim();
break;
}
}
String msg = C.i18n("launch.exited_abnormally") + " exit code: " + t;
if (errorText != null)
msg += ", advice: " + MinecraftCrashAdvicer.getAdvice(FileUtils.readFileToStringQuietly(new File(errorText)));
MessageBox.Show(msg);
WebFrame f = new WebFrame(logs);
f.setModal(true);
f.setTitle("Game output");
f.setVisible(true);
@@ -123,6 +138,10 @@ public class LaunchingUIDaemon {
return true;
};
private static void getCrashReport() {
}
private static void checkExit(LauncherVisibility v) {
if (v != LauncherVisibility.KEEP && !LogWindow.INSTANCE.isVisible()) {
HMCLog.log("Launcher will exit now.");
@@ -32,6 +32,8 @@ public final class MinecraftCrashAdvicer {
}
public static String getAdvice(String trace, boolean selfCrash) {
if (trace == null)
return C.i18n("crash.advice.no");
trace = trace.toLowerCase(SupportedLocales.NOW_LOCALE.self);
if (trace.contains("pixel format not accelerated"))
return C.i18n("crash.advice.LWJGLException");
@@ -24,7 +24,7 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
@@ -72,12 +72,12 @@ public class TaskList extends Thread {
private class Invoker implements Runnable {
Task task;
Set<Invoker> s;
CountDownLatch latch;
AtomicBoolean bool;
public Invoker(Task task, Set<Invoker> ss, AtomicBoolean bool) {
public Invoker(Task task, CountDownLatch latch, AtomicBoolean bool) {
this.task = task;
s = ss;
this.latch = latch;
this.bool = bool;
}
@@ -85,7 +85,7 @@ public class TaskList extends Thread {
public void run() {
if (!executeTask(task))
bool.set(false);
s.remove(this);
latch.countDown();
}
}
@@ -99,22 +99,18 @@ public class TaskList extends Thread {
return true;
this.totTask += c.size();
AtomicBoolean bool = new AtomicBoolean(true);
Set<Invoker> runningThread = Collections.synchronizedSet(new HashSet<Invoker>());
CountDownLatch counter = new CountDownLatch(c.size());
for (Task t2 : c) {
t2.setParallelExecuting(true);
Invoker thread = new Invoker(t2, runningThread, bool);
runningThread.add(thread);
Invoker thread = new Invoker(t2, counter, bool);
invokers.add(thread);
if (!EXECUTOR_SERVICE.isShutdown() && !EXECUTOR_SERVICE.isTerminated())
futures.put(thread, EXECUTOR_SERVICE.submit(thread));
}
while (!runningThread.isEmpty())
try {
if (this.isInterrupted())
return false;
Thread.sleep(1);
} catch (InterruptedException ignore) {
}
try {
counter.await();
} catch (InterruptedException ignore) {
}
return bool.get();
}
+1 -1
View File
@@ -30,7 +30,7 @@ if (buildnumber == null)
def versionroot = System.getenv("VERSION_ROOT")
if (versionroot == null)
versionroot = "0.8.6"
versionroot = "0.8.7"
String mavenGroupId = 'HMCSM'
String mavenVersion = versionroot + '.' + buildnumber
@@ -40,7 +40,7 @@ public class Main {
public static String launcherName = "Hello Minecraft! Server Manager";
public static final String PUBLISH_URL = "http://www.mcbbs.net/thread-171239-1-1.html";
public static final byte VERSION_FIRST = 0, VERSION_SECOND = 8, VERSION_THIRD = 6;
public static final byte VERSION_FIRST = 0, VERSION_SECOND = 8, VERSION_THIRD = 7;
public static final UpdateChecker UPDATE_CHECKER = new UpdateChecker(new VersionNumber(VERSION_FIRST, VERSION_SECOND, VERSION_THIRD), "hmcsm");
public static String makeTitle() {
@@ -209,14 +209,23 @@ public final class MainWindow extends javax.swing.JFrame
//<editor-fold defaultstate="collapsed" desc="基本信息菜单">
class ActionListenerImpl implements ActionListener {
String s;
String s, q;
public ActionListenerImpl(String s) {
this(s, null);
}
public ActionListenerImpl(String s, String question) {
this.s = s;
q = question;
}
@Override
public void actionPerformed(ActionEvent e) {
String ans = q == null ? "" : JOptionPane.showInputDialog(q);
if (ans == null)
return;
s = s.replace("{}", ans);
Server.getInstance().sendCommand(s);
}
@@ -233,9 +242,9 @@ public final class MainWindow extends javax.swing.JFrame
itm.addActionListener(new ActionListenerImpl("time set 0"));
ppmBasically.add(itm);
itm = new JMenuItem("广播");
itm.addActionListener(new ActionListenerImpl("say " + JOptionPane.showInputDialog("广播讯息")));
itm.addActionListener(new ActionListenerImpl("say {}", JOptionPane.showInputDialog("广播讯息")));
itm = new JMenuItem("红字广播");
itm.addActionListener(new ActionListenerImpl("me " + JOptionPane.showInputDialog("广播讯息")));
itm.addActionListener(new ActionListenerImpl("me {}", JOptionPane.showInputDialog("广播讯息")));
itm = new JMenuItem("私聊");
itm.addActionListener(e -> {
InputDialog id = new InputDialog(MainWindow.this, true, new String[] { "玩家", "讯息" });
@@ -244,16 +253,16 @@ public final class MainWindow extends javax.swing.JFrame
});
ppmBasically.add(itm);
itm = new JMenuItem("给予OP");
itm.addActionListener(new ActionListenerImpl("op " + JOptionPane.showInputDialog("新OP的游戏名")));
itm.addActionListener(new ActionListenerImpl("op {}", JOptionPane.showInputDialog("新OP的游戏名")));
ppmBasically.add(itm);
itm = new JMenuItem("卸除OP");
itm.addActionListener(new ActionListenerImpl("deop " + JOptionPane.showInputDialog("要卸除OP的游戏名")));
itm.addActionListener(new ActionListenerImpl("deop {}", JOptionPane.showInputDialog("要卸除OP的游戏名")));
ppmBasically.add(itm);
itm = new JMenuItem("给予玩家白名单");
itm.addActionListener(new ActionListenerImpl("whitelist add " + JOptionPane.showInputDialog("要添入白名单的游戏名")));
itm.addActionListener(new ActionListenerImpl("whitelist add {}", JOptionPane.showInputDialog("要添入白名单的游戏名")));
ppmBasically.add(itm);
itm = new JMenuItem("解除玩家白名单");
itm.addActionListener(new ActionListenerImpl("whitelist remove " + JOptionPane.showInputDialog("要解除白名单的游戏名")));
itm.addActionListener(new ActionListenerImpl("whitelist remove {}", JOptionPane.showInputDialog("要解除白名单的游戏名")));
ppmBasically.add(itm);
itm = new JMenuItem("启用白名单");
itm.addActionListener(new ActionListenerImpl("whitelist on"));
@@ -265,31 +274,31 @@ public final class MainWindow extends javax.swing.JFrame
itm.addActionListener(new ActionListenerImpl("whitelist list"));
ppmBasically.add(itm);
itm = new JMenuItem("封禁玩家");
itm.addActionListener(new ActionListenerImpl("ban " + JOptionPane.showInputDialog("要封禁玩家的游戏名")));
itm.addActionListener(new ActionListenerImpl("ban {}", JOptionPane.showInputDialog("要封禁玩家的游戏名")));
ppmBasically.add(itm);
itm = new JMenuItem("封禁玩家IP");
itm.addActionListener(new ActionListenerImpl("ban-ip " + JOptionPane.showInputDialog("要封禁玩家IP的游戏名")));
itm.addActionListener(new ActionListenerImpl("ban-ip {}", JOptionPane.showInputDialog("要封禁玩家IP的游戏名")));
itm = new JMenuItem("解封玩家");
itm.addActionListener(new ActionListenerImpl("pardon " + JOptionPane.showInputDialog("要解封玩家的游戏名")));
itm.addActionListener(new ActionListenerImpl("pardon {}", JOptionPane.showInputDialog("要解封玩家的游戏名")));
ppmBasically.add(itm);
itm = new JMenuItem("解封玩家IP");
itm.addActionListener(new ActionListenerImpl("pardon-ip " + JOptionPane.showInputDialog("要解封玩家IP的游戏名")));
itm.addActionListener(new ActionListenerImpl("pardon-ip {}", JOptionPane.showInputDialog("要解封玩家IP的游戏名")));
itm = new JMenuItem("封禁玩家");
itm.addActionListener(new ActionListenerImpl("ban " + JOptionPane.showInputDialog("要封禁玩家的游戏名")));
itm.addActionListener(new ActionListenerImpl("ban {}", JOptionPane.showInputDialog("要封禁玩家的游戏名")));
ppmBasically.add(itm);
itm = new JMenuItem("封禁玩家IP");
itm.addActionListener(new ActionListenerImpl("ban-ip " + JOptionPane.showInputDialog("要封禁玩家IP的游戏名")));
itm.addActionListener(new ActionListenerImpl("ban-ip {}", JOptionPane.showInputDialog("要封禁玩家IP的游戏名")));
itm = new JMenuItem("封禁玩家列表");
itm.addActionListener(new ActionListenerImpl("banlist"));
ppmBasically.add(itm);
itm = new JMenuItem("修改时间");
itm.addActionListener(new ActionListenerImpl("time set " + JOptionPane.showInputDialog("要调整的时间值")));
itm.addActionListener(new ActionListenerImpl("time set {}", JOptionPane.showInputDialog("要调整的时间值")));
ppmBasically.add(itm);
itm = new JMenuItem("往后调整时间");
itm.addActionListener(new ActionListenerImpl("time add " + JOptionPane.showInputDialog("要往后调整的时间值")));
itm.addActionListener(new ActionListenerImpl("time add {}", JOptionPane.showInputDialog("要往后调整的时间值")));
ppmBasically.add(itm);
itm = new JMenuItem("调整天气");
itm.addActionListener(new ActionListenerImpl("weather " + JOptionPane.showInputDialog("要调整的天气(只能填:clear[意思是取消所有天气]或rain[意思是下雨]或thunder[意思是打雷]")));
itm.addActionListener(new ActionListenerImpl("weather {}", JOptionPane.showInputDialog("要调整的天气(只能填:clear[意思是取消所有天气]或rain[意思是下雨]或thunder[意思是打雷]")));
ppmBasically.add(itm);
itm = new JMenuItem("调整一定时间的天气");
itm.addActionListener(e -> {
@@ -305,10 +314,10 @@ public final class MainWindow extends javax.swing.JFrame
});
ppmBasically.add(itm);
itm = new JMenuItem("清除背包");
itm.addActionListener(new ActionListenerImpl("clear" + JOptionPane.showInputDialog("要被清除背包的玩家")));
itm.addActionListener(new ActionListenerImpl("clear {}", JOptionPane.showInputDialog("要被清除背包的玩家")));
ppmBasically.add(itm);
itm = new JMenuItem("踢出玩家");
itm.addActionListener(new ActionListenerImpl("kick " + JOptionPane.showInputDialog("要被踢出的玩家")));
itm.addActionListener(new ActionListenerImpl("kick {}", JOptionPane.showInputDialog("要被踢出的玩家")));
ppmBasically.add(itm);
itm = new JMenuItem("在线玩家");
itm.addActionListener(new ActionListenerImpl("list"));
@@ -334,10 +343,10 @@ public final class MainWindow extends javax.swing.JFrame
itm.addActionListener(new ActionListenerImpl("save-off"));
ppmBasically.add(itm);
itm = new JMenuItem("难度");
itm.addActionListener(new ActionListenerImpl("difficulty " + JOptionPane.showInputDialog("难度")));
itm.addActionListener(new ActionListenerImpl("difficulty {}", JOptionPane.showInputDialog("难度")));
ppmBasically.add(itm);
itm = new JMenuItem("默认游戏模式");
itm.addActionListener(new ActionListenerImpl("defaultgamemode " + JOptionPane.showInputDialog("默认游戏模式")));
itm.addActionListener(new ActionListenerImpl("defaultgamemode {}", JOptionPane.showInputDialog("默认游戏模式")));
ppmBasically.add(itm);
itm = new JMenuItem("地图种子");
itm.addActionListener(new ActionListenerImpl("seed"));