add precalled command

This commit is contained in:
huanghongxun 2015-08-17 13:40:24 +08:00
parent 9ae9b5b912
commit 9fc1470a63
11 changed files with 41 additions and 37 deletions

View File

@ -25,7 +25,7 @@ if (!hasProperty('mainClass')) {
ext.mainClass = 'org.jackhuang.hellominecraft.launcher.Main' ext.mainClass = 'org.jackhuang.hellominecraft.launcher.Main'
} }
def buildnumber = System.getenv("BUILD_NUMBER") == null ? "" : "."+System.getenv("BUILD_NUMBER") def buildnumber = System.getenv("BUILD_NUMBER") == null ? ".12" : "."+System.getenv("BUILD_NUMBER")
String mavenGroupId = 'HMCL' String mavenGroupId = 'HMCL'
String mavenVersion = '2.3.4' + buildnumber String mavenVersion = '2.3.4' + buildnumber
@ -66,7 +66,6 @@ retrolambda {
} }
jar { jar {
//jar.classifier = 'base'
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } } from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
manifest { manifest {
@ -121,7 +120,7 @@ launch4j {
mainClassName = mainClass mainClassName = mainClass
icon = new File(project.buildDir, '../icon.ico').absolutePath icon = new File(project.buildDir, '../icon.ico').absolutePath
version = mavenVersion + '.0' version = mavenVersion
downloadUrl = 'http://java.com/download' downloadUrl = 'http://java.com/download'
copyright = "Copyright(c) 2013-2015 huangyuhui." copyright = "Copyright(c) 2013-2015 huangyuhui."
@ -135,7 +134,3 @@ processResources {
exclude 'icon.icns' exclude 'icon.icns'
} }
} }
//build.dependsOn proguard
//makeExecutable.dependsOn proguard
//build.dependsOn makeExecutable

View File

@ -91,7 +91,7 @@ public final class Main implements NonConsumer {
} }
public static String launcherName = "Hello Minecraft! Launcher"; public static String launcherName = "Hello Minecraft! Launcher";
public static byte firstVer = 2, secondVer = 3, thirdVer = 4, forthVer = 10; public static byte firstVer = 2, secondVer = 3, thirdVer = 4, forthVer = 12;
public static int minimumLauncherVersion = 16; public static int minimumLauncherVersion = 16;
/** /**
@ -100,7 +100,7 @@ public final class Main implements NonConsumer {
* @return the version: firstVer.secondVer.thirdVer * @return the version: firstVer.secondVer.thirdVer
*/ */
public static String makeVersion() { public static String makeVersion() {
return "" + firstVer + '.' + secondVer + '.' + thirdVer; return "" + firstVer + '.' + secondVer + '.' + thirdVer + '.' + forthVer;
} }
/** /**

View File

@ -57,9 +57,6 @@ public abstract class AbstractMinecraftLoader implements IMinecraftLoader {
public void makeHeadCommand(List<String> res) { public void makeHeadCommand(List<String> res) {
HMCLog.log("On making head command."); HMCLog.log("On making head command.");
if (StrUtils.isNotBlank(v.getWrapperLauncher()))
res.addAll(Arrays.asList(v.getWrapperLauncher().split(" ")));
String str = v.getJavaDir(); String str = v.getJavaDir();
JdkVersion jv = new JdkVersion(str); JdkVersion jv = new JdkVersion(str);
if (Settings.getInstance().getJava().contains(jv)) if (Settings.getInstance().getJava().contains(jv))

View File

@ -124,6 +124,15 @@ public class GameLauncher {
public void launch(List str) { public void launch(List str) {
try { try {
provider.onLaunch(); provider.onLaunch();
if (StrUtils.isNotBlank(getProfile().getPrecalledCommand())) {
Process p = Runtime.getRuntime().exec(getProfile().getPrecalledCommand());
try {
if (p != null && p.isAlive())
p.waitFor();
} catch (InterruptedException ex) {
HMCLog.warn("Failed to invoke precalled command", ex);
}
}
ProcessBuilder builder = new ProcessBuilder(str); ProcessBuilder builder = new ProcessBuilder(str);
builder.directory(provider.getRunDirectory(get.getSelectedMinecraftVersion().id)) builder.directory(provider.getRunDirectory(get.getSelectedMinecraftVersion().id))
.environment().put("APPDATA", get.getCanonicalGameDirFile().getPath()); .environment().put("APPDATA", get.getCanonicalGameDirFile().getPath());
@ -164,6 +173,10 @@ public class GameLauncher {
writer.newLine(); writer.newLine();
} }
} }
if (StrUtils.isNotBlank(getProfile().getPrecalledCommand())) {
writer.write(getProfile().getPrecalledCommand());
writer.newLine();
}
writer.write(StrUtils.makeCommand(str)); writer.write(StrUtils.makeCommand(str));
writer.close(); writer.close();
if (!isWin) if (!isWin)

View File

@ -35,7 +35,7 @@ import org.jackhuang.hellominecraft.utils.system.OS;
public final class Profile { public final class Profile {
private String name, selectedMinecraftVersion = "", javaArgs, minecraftArgs, maxMemory, permSize, width, height, userProperties; private String name, selectedMinecraftVersion = "", javaArgs, minecraftArgs, maxMemory, permSize, width, height, userProperties;
private String gameDir, javaDir, wrapperLauncher, serverIp, java; private String gameDir, javaDir, precalledCommand, serverIp, java;
private boolean fullscreen, debug, noJVMArgs, canceledWrapper; private boolean fullscreen, debug, noJVMArgs, canceledWrapper;
/** /**
@ -62,7 +62,7 @@ public final class Profile {
gameDir = MCUtils.getInitGameDir().getPath(); gameDir = MCUtils.getInitGameDir().getPath();
debug = fullscreen = canceledWrapper = false; debug = fullscreen = canceledWrapper = false;
launcherVisibility = gameDirType = 0; launcherVisibility = gameDirType = 0;
javaDir = java = minecraftArgs = serverIp = ""; javaDir = java = minecraftArgs = serverIp = precalledCommand = "";
} }
public Profile(Profile v) { public Profile(Profile v) {
@ -84,7 +84,7 @@ public final class Profile {
canceledWrapper = v.canceledWrapper; canceledWrapper = v.canceledWrapper;
noJVMArgs = v.noJVMArgs; noJVMArgs = v.noJVMArgs;
launcherVisibility = v.launcherVisibility; launcherVisibility = v.launcherVisibility;
wrapperLauncher = v.wrapperLauncher; precalledCommand = v.precalledCommand;
serverIp = v.serverIp; serverIp = v.serverIp;
} }
@ -311,12 +311,12 @@ public final class Profile {
Settings.save(); Settings.save();
} }
public String getWrapperLauncher() { public String getPrecalledCommand() {
return wrapperLauncher; return precalledCommand;
} }
public void setWrapperLauncher(String wrapperLauncher) { public void setPrecalledCommand(String precalledCommand) {
this.wrapperLauncher = wrapperLauncher; this.precalledCommand = precalledCommand;
Settings.save(); Settings.save();
} }

View File

@ -69,7 +69,7 @@ public final class Settings {
e.checkFormat(); e.checkFormat();
UPDATE_CHECKER = new UpdateChecker(new VersionNumber(Main.firstVer, Main.secondVer, Main.thirdVer), UPDATE_CHECKER = new UpdateChecker(new VersionNumber(Main.firstVer, Main.secondVer, Main.thirdVer),
"hmcl", settings.isCheckUpdate(), () -> Main.invokeUpdate()); "hmcl", settings.isCheckUpdate(), Main::invokeUpdate);
List<Java> temp = new ArrayList<>(); List<Java> temp = new ArrayList<>();
temp.add(new Java("Default", System.getProperty("java.home"))); temp.add(new Java("Default", System.getProperty("java.home")));

View File

@ -77,7 +77,7 @@ public class CrashReporter implements Thread.UncaughtExceptionHandler {
if (!s.contains("org.jackhuang.hellominecraft")) return; if (!s.contains("org.jackhuang.hellominecraft")) return;
try { try {
String text = "\n---- Hello Minecraft! Crash Report ----\n"; String text = "\n---- Hello Minecraft! Crash Report ----\n";
text += " Version: " + Main.makeVersion() + "." + Main.forthVer + "\n"; text += " Version: " + Main.makeVersion() + "\n";
text += " Time: " + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()) + "\n"; text += " Time: " + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()) + "\n";
text += " Thread: " + t.toString() + "\n"; text += " Thread: " + t.toString() + "\n";
text += "\n Content: \n "; text += "\n Content: \n ";

View File

@ -338,7 +338,7 @@
<Group type="102" attributes="0"> <Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Component id="txtWrapperLauncher" alignment="0" max="32767" attributes="0"/> <Component id="txtPrecalledCommand" alignment="0" max="32767" attributes="0"/>
<Component id="txtServerIP" alignment="0" max="32767" attributes="0"/> <Component id="txtServerIP" alignment="0" max="32767" attributes="0"/>
<Group type="102" attributes="0"> <Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
@ -393,7 +393,7 @@
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="jLabel30" min="-2" max="-2" attributes="0"/> <Component id="jLabel30" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="txtWrapperLauncher" min="-2" pref="26" max="-2" attributes="0"/> <Component id="txtPrecalledCommand" min="-2" pref="26" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="jLabel31" min="-2" max="-2" attributes="0"/> <Component id="jLabel31" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
@ -486,9 +486,9 @@
</Property> </Property>
</Properties> </Properties>
</Component> </Component>
<Component class="javax.swing.JTextField" name="txtWrapperLauncher"> <Component class="javax.swing.JTextField" name="txtPrecalledCommand">
<Events> <Events>
<EventHandler event="focusLost" listener="java.awt.event.FocusListener" parameters="java.awt.event.FocusEvent" handler="txtWrapperLauncherFocusLost"/> <EventHandler event="focusLost" listener="java.awt.event.FocusListener" parameters="java.awt.event.FocusEvent" handler="txtPrecalledCommandFocusLost"/>
</Events> </Events>
</Component> </Component>
<Component class="javax.swing.JLabel" name="jLabel31"> <Component class="javax.swing.JLabel" name="jLabel31">

View File

@ -292,7 +292,7 @@ public class GameSettingsPanel extends javax.swing.JPanel implements DropTargetL
chkNoJVMArgs = new javax.swing.JCheckBox(); chkNoJVMArgs = new javax.swing.JCheckBox();
chkCancelWrapper = new javax.swing.JCheckBox(); chkCancelWrapper = new javax.swing.JCheckBox();
jLabel30 = new javax.swing.JLabel(); jLabel30 = new javax.swing.JLabel();
txtWrapperLauncher = new javax.swing.JTextField(); txtPrecalledCommand = new javax.swing.JTextField();
jLabel31 = new javax.swing.JLabel(); jLabel31 = new javax.swing.JLabel();
txtServerIP = new javax.swing.JTextField(); txtServerIP = new javax.swing.JTextField();
jPanel6 = new javax.swing.JPanel(); jPanel6 = new javax.swing.JPanel();
@ -575,9 +575,9 @@ public class GameSettingsPanel extends javax.swing.JPanel implements DropTargetL
jLabel30.setText(bundle.getString("advancedsettings.wrapper_launcher")); // NOI18N jLabel30.setText(bundle.getString("advancedsettings.wrapper_launcher")); // NOI18N
txtWrapperLauncher.addFocusListener(new java.awt.event.FocusAdapter() { txtPrecalledCommand.addFocusListener(new java.awt.event.FocusAdapter() {
public void focusLost(java.awt.event.FocusEvent evt) { public void focusLost(java.awt.event.FocusEvent evt) {
txtWrapperLauncherFocusLost(evt); txtPrecalledCommandFocusLost(evt);
} }
}); });
@ -596,7 +596,7 @@ public class GameSettingsPanel extends javax.swing.JPanel implements DropTargetL
.addGroup(jPanel2Layout.createSequentialGroup() .addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap() .addContainerGap()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(txtWrapperLauncher) .addComponent(txtPrecalledCommand)
.addComponent(txtServerIP) .addComponent(txtServerIP)
.addGroup(jPanel2Layout.createSequentialGroup() .addGroup(jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@ -639,7 +639,7 @@ public class GameSettingsPanel extends javax.swing.JPanel implements DropTargetL
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel30) .addComponent(jLabel30)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txtWrapperLauncher, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(txtPrecalledCommand, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel31) .addComponent(jLabel31)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
@ -1252,9 +1252,9 @@ btnRefreshLiteLoader.addActionListener(new java.awt.event.ActionListener() {
profile.setCanceledWrapper(chkCancelWrapper.isSelected()); profile.setCanceledWrapper(chkCancelWrapper.isSelected());
}//GEN-LAST:event_chkCancelWrapperFocusLost }//GEN-LAST:event_chkCancelWrapperFocusLost
private void txtWrapperLauncherFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtWrapperLauncherFocusLost private void txtPrecalledCommandFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtPrecalledCommandFocusLost
profile.setWrapperLauncher(txtWrapperLauncher.getText()); profile.setPrecalledCommand(txtPrecalledCommand.getText());
}//GEN-LAST:event_txtWrapperLauncherFocusLost }//GEN-LAST:event_txtPrecalledCommandFocusLost
private void txtServerIPFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtServerIPFocusLost private void txtServerIPFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtServerIPFocusLost
profile.setServerIp(txtServerIP.getText()); profile.setServerIp(txtServerIP.getText());
@ -1475,7 +1475,7 @@ btnRefreshLiteLoader.addActionListener(new java.awt.event.ActionListener() {
txtJavaArgs.setText(profile.getJavaArgs()); txtJavaArgs.setText(profile.getJavaArgs());
txtMinecraftArgs.setText(profile.getMinecraftArgs()); txtMinecraftArgs.setText(profile.getMinecraftArgs());
txtJavaDir.setText(profile.getSettingsJavaDir()); txtJavaDir.setText(profile.getSettingsJavaDir());
txtWrapperLauncher.setText(profile.getWrapperLauncher()); txtPrecalledCommand.setText(profile.getPrecalledCommand());
txtServerIP.setText(profile.getServerIp()); txtServerIP.setText(profile.getServerIp());
chkDebug.setSelected(profile.isDebug()); chkDebug.setSelected(profile.isDebug());
chkNoJVMArgs.setSelected(profile.isNoJVMArgs()); chkNoJVMArgs.setSelected(profile.isNoJVMArgs());
@ -1824,9 +1824,9 @@ btnRefreshLiteLoader.addActionListener(new java.awt.event.ActionListener() {
private javax.swing.JTextField txtMinecraftArgs; private javax.swing.JTextField txtMinecraftArgs;
private javax.swing.JTextField txtMinecraftVersion; private javax.swing.JTextField txtMinecraftVersion;
private javax.swing.JTextField txtPermSize; private javax.swing.JTextField txtPermSize;
private javax.swing.JTextField txtPrecalledCommand;
private javax.swing.JTextField txtServerIP; private javax.swing.JTextField txtServerIP;
private javax.swing.JTextField txtWidth; private javax.swing.JTextField txtWidth;
private javax.swing.JTextField txtWrapperLauncher;
// End of variables declaration//GEN-END:variables // End of variables declaration//GEN-END:variables
// </editor-fold> // </editor-fold>
} }

View File

@ -21,7 +21,6 @@ import org.jackhuang.hellominecraft.utils.system.MessageBox;
import org.jackhuang.hellominecraft.C; import org.jackhuang.hellominecraft.C;
import org.jackhuang.hellominecraft.utils.functions.NonConsumer; import org.jackhuang.hellominecraft.utils.functions.NonConsumer;
import org.jackhuang.hellominecraft.HMCLog; import org.jackhuang.hellominecraft.HMCLog;
import org.jackhuang.hellominecraft.utils.system.OS;
/** /**
* *

View File

@ -222,7 +222,7 @@ advancedsettings.game_dir.default=\u9ed8\u8ba4(.minecraft/)
advancedsettings.game_dir.independent=\u5404\u7248\u672c\u72ec\u7acb(.minecraft/versions/<\u7248\u672c\u540d>/,\u9664assets,libraries) advancedsettings.game_dir.independent=\u5404\u7248\u672c\u72ec\u7acb(.minecraft/versions/<\u7248\u672c\u540d>/,\u9664assets,libraries)
advancedsettings.no_jvm_args=\u4e0d\u6dfb\u52a0JVM\u53c2\u6570(\u4f7f\u7528Java9\u65f6\u5fc5\u52fe) advancedsettings.no_jvm_args=\u4e0d\u6dfb\u52a0JVM\u53c2\u6570(\u4f7f\u7528Java9\u65f6\u5fc5\u52fe)
advancedsettings.java_args_default=\u542f\u52a8\u5668\u9ed8\u8ba4\u6dfb\u52a0\u7684\u53c2\u6570\uff08\u8bf7\u4e0d\u8981\u91cd\u590d\u6dfb\u52a0\uff09\uff1a-XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode -XX:-UseAdaptiveSizePolicy -XX:MaxPermSize=???m -Xmx???m -Dfml.ignoreInvalidMinecraftCertificates=true -Dfml.ignorePatchDiscrepancies=true advancedsettings.java_args_default=\u542f\u52a8\u5668\u9ed8\u8ba4\u6dfb\u52a0\u7684\u53c2\u6570\uff08\u8bf7\u4e0d\u8981\u91cd\u590d\u6dfb\u52a0\uff09\uff1a-XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode -XX:-UseAdaptiveSizePolicy -XX:MaxPermSize=???m -Xmx???m -Dfml.ignoreInvalidMinecraftCertificates=true -Dfml.ignorePatchDiscrepancies=true
advancedsettings.wrapper_launcher=\u524d\u7f6e\u542f\u52a8\u6307\u4ee4(\u4e0d\u5fc5\u586b\u5199\uff0c\u5185\u5bb9\u5c06\u52a0\u5728\u542f\u52a8\u811a\u672c\u6700\u524d\uff0c\u5982optirun...) advancedsettings.wrapper_launcher=\u542f\u52a8\u524d\u6267\u884c\u547d\u4ee4(\u4e0d\u5fc5\u586b\u5199\uff0c\u5c06\u5728\u6e38\u620f\u542f\u52a8\u524d\u8c03\u7528)
advancedsettings.server_ip=\u76f4\u5165\u670d\u52a1\u5668ip\u5730\u5740(\u4e0d\u5fc5\u586b\u5199\uff0c\u542f\u52a8\u6e38\u620f\u540e\u76f4\u63a5\u8fdb\u5165\u5bf9\u5e94\u670d\u52a1\u5668) advancedsettings.server_ip=\u76f4\u5165\u670d\u52a1\u5668ip\u5730\u5740(\u4e0d\u5fc5\u586b\u5199\uff0c\u542f\u52a8\u6e38\u620f\u540e\u76f4\u63a5\u8fdb\u5165\u5bf9\u5e94\u670d\u52a1\u5668)
mainwindow.show_log=\u67e5\u770b\u65e5\u5fd7 mainwindow.show_log=\u67e5\u770b\u65e5\u5fd7