test for new launcher for java && forgot to add license...
This commit is contained in:
BIN
HMCL/HMCLauncher.exe
Normal file
BIN
HMCL/HMCLauncher.exe
Normal file
Binary file not shown.
@@ -88,29 +88,30 @@ task proguard(type: proguard.gradle.ProGuardTask, dependsOn: jar) {
|
||||
|
||||
configuration 'proguard.pro'
|
||||
}
|
||||
/*
|
||||
task makeExecutable(dependsOn: jar) {
|
||||
|
||||
task makeExecutable(dependsOn: jar) << {
|
||||
ext {
|
||||
def re = jar.classifier
|
||||
injar = jar.archivePath
|
||||
jar.classifier = ''
|
||||
outjar = jar.archivePath
|
||||
jar.classifier = re
|
||||
makeExecutableinjar = jar.archivePath
|
||||
jar.classifier = ''
|
||||
makeExecutableoutjar = jar.archivePath
|
||||
jar.classifier = ''
|
||||
}
|
||||
def fos = new FileOutputStream(outjar)
|
||||
def is = new FileInputStream('')
|
||||
def read
|
||||
def loc = new File(project.buildDir, "libs/" + makeExecutableoutjar.getName().substring(0, makeExecutableoutjar.getName().length()-4)+".exe")
|
||||
def fos = new FileOutputStream(loc)
|
||||
def is = new FileInputStream(new File(project.buildDir, '../HMCLauncher.exe'))
|
||||
int read
|
||||
def bytes = new byte[8192]
|
||||
while((read = is.read(bytes)) != -1)
|
||||
fos.write(bytes, 0, read);
|
||||
is.close()
|
||||
is = new FileInputStream(injar)
|
||||
is = new FileInputStream(makeExecutableinjar)
|
||||
while((read = is.read(bytes)) != -1)
|
||||
fos.write(bytes, 0, read);
|
||||
is.close()
|
||||
fos.close()
|
||||
}*/
|
||||
|
||||
}
|
||||
/*
|
||||
launch4j {
|
||||
launch4jCmd = 'D:\\Develop\\Java\\Launch4j\\launch4j.exe'
|
||||
supportUrl = 'http://www.mcbbs.net/thread-142335-1-1.html'
|
||||
@@ -125,7 +126,7 @@ launch4j {
|
||||
jar = new File(project.buildDir, 'libs/' + mavenGroupId + '-' + mavenVersion + '.jar').absolutePath
|
||||
outfile = mavenGroupId + '-' + mavenVersion + '.exe'
|
||||
messagesJreVersionError = 'This application requires a Java Runtime Environment installation, or the runtime is corrupted.\n\u6ca1\u6709\u627e\u5230\u004a\u0061\u0076\u0061\u8fd0\u884c\u65f6\uff0c\u8bf7\u4e0d\u8981\u4f7f\u7528\u7eff\u8272\u004a\u0061\u0076\u0061\uff0c\u8bf7\u4f7f\u7528\u5b89\u88c5\u7248\u7684\u004a\u0061\u0076\u0061\uff0c\u70b9\u51fb\u786e\u5b9a\u8fdb\u5165\u004a\u0061\u0076\u0061\u5b89\u88c5\u9875\u9762\u3002'
|
||||
}
|
||||
}*/
|
||||
|
||||
processResources {
|
||||
from(sourceSets.main.resources.srcDirs) {
|
||||
@@ -133,5 +134,5 @@ processResources {
|
||||
}
|
||||
}
|
||||
|
||||
build.dependsOn proguard
|
||||
//build.dependsOn makeExecutable
|
||||
makeExecutable.dependsOn proguard
|
||||
build.dependsOn makeExecutable
|
||||
@@ -101,8 +101,8 @@ ui.more=\u66f4\u591a
|
||||
|
||||
crash.advice.UnsupportedClassVersionError=\u8fd9\u53ef\u80fd\u662f\u56e0\u4e3a\u60a8\u7684Java\u7248\u672c\u8fc7\u4e8e\u8001\u65e7\uff0c\u53ef\u4ee5\u5c1d\u8bd5\u66f4\u6362\u6700\u65b0Java\u5e76\u5728\u7248\u672c\u8bbe\u7f6e\u7684Java\u8def\u5f84\u4e2d\u8bbe\u7f6e.
|
||||
crash.advice.ConcurrentModificationException=\u8fd9\u53ef\u80fd\u662f\u56e0\u4e3a\u60a8\u7684Java\u7248\u672c\u9ad8\u4e8eJava 1.8.0_11\u5bfc\u81f4\u7684,\u53ef\u4ee5\u5c1d\u8bd5\u5378\u8f7dJava8\u5b89\u88c5Java7\u3002
|
||||
crash.advice.ClassNotFoundException=Minecraft\u4e0d\u5b8c\u6574\u6216Mod\u51b2\u7a81\uff0c\u5982\u679c\u6709\u672a\u80fd\u4e0b\u8f7d\u7684\u6587\u4ef6\u8bf7\u4e0b\u8f7d\u6210\u529f\u540e\u91cd\u8bd5\u6216\u4e0b\u8f7d\u6574\u5408\u5305\u89e3\u51b3\u95ee\u9898\u3002
|
||||
crash.advice.NoSuchFieldError=Minecraft\u4e0d\u5b8c\u6574\u6216Mod\u51b2\u7a81\uff0c\u5982\u679c\u6709\u672a\u80fd\u4e0b\u8f7d\u7684\u6587\u4ef6\u8bf7\u4e0b\u8f7d\u6210\u529f\u540e\u91cd\u8bd5\u6216\u4e0b\u8f7d\u6574\u5408\u5305\u89e3\u51b3\u95ee\u9898\u3002
|
||||
crash.advice.ClassNotFoundException=Minecraft\u4e0d\u5b8c\u6574\u6216Mod\u51b2\u7a81\uff0c\u5982\u679c\u6709\u672a\u80fd\u4e0b\u8f7d\u7684\u6587\u4ef6\u8bf7\u4e0b\u8f7d\u6210\u529f\u540e\u91cd\u8bd5\u6216\u662f\u5ba2\u6237\u7aef\u635f\u574f\u8bf7\u91cd\u8bd5\u8bf7\u91cd\u65b0\u5236\u4f5c\u5ba2\u6237\u7aef\u6216\u4e0b\u8f7d\u6574\u5408\u5305\u89e3\u51b3\u95ee\u9898\u3002
|
||||
crash.advice.NoSuchFieldError=Minecraft\u4e0d\u5b8c\u6574\u6216Mod\u51b2\u7a81\uff0c\u5982\u679c\u6709\u672a\u80fd\u4e0b\u8f7d\u7684\u6587\u4ef6\u8bf7\u4e0b\u8f7d\u6210\u529f\u540e\u91cd\u8bd5\u6216\u662f\u5ba2\u6237\u7aef\u635f\u574f\u8bf7\u91cd\u8bd5\u8bf7\u91cd\u65b0\u5236\u4f5c\u5ba2\u6237\u7aef\u6216\u4e0b\u8f7d\u6574\u5408\u5305\u89e3\u51b3\u95ee\u9898\u3002
|
||||
crash.advice.LWJGLException=\u60a8\u7684\u7535\u8111\u4e0d\u6b63\u5e38\uff0c\u53ef\u80fd\u9700\u8981\u4f7f\u7528\u9a71\u52a8\u7cbe\u7075\u6216\u5176\u4ed6\u5b89\u88c5\u5668\u66f4\u65b0\u663e\u5361\u9a71\u52a8\u3002
|
||||
crash.advice.SecurityException=\u53ef\u80fd\u662f\u60a8\u4fee\u6539\u4e86minecraft.jar\u4f46\u672a\u5220\u9664META-INF\u6587\u4ef6\u5939\u7684\u539f\u56e0\u3002\u8bf7\u901a\u8fc7\u538b\u7f29\u8f6f\u4ef6\u5220\u9664jar\u4e2d\u7684META-INF\u6587\u4ef6\u5939\u3002
|
||||
crash.advice.OutOfMemoryError=\u5185\u5b58\u6ea2\u51fa\uff0c\u60a8\u8bbe\u7f6e\u7684Minecraft\u6700\u5927\u5185\u5b58\u8fc7\u5c0f\uff0c\u8bf7\u8c03\u5927\uff01
|
||||
|
||||
@@ -96,8 +96,8 @@ ui.more=\u66f4\u591a
|
||||
|
||||
crash.advice.UnsupportedClassVersionError=\u8fd9\u53ef\u80fd\u662f\u56e0\u4e3a\u60a8\u7684Java\u7248\u672c\u8fc7\u4e8e\u8001\u65e7\uff0c\u53ef\u4ee5\u5c1d\u8bd5\u66f4\u6362\u6700\u65b0Java\u5e76\u5728\u7248\u672c\u8bbe\u7f6e\u7684Java\u8def\u5f84\u4e2d\u8bbe\u7f6e.
|
||||
crash.advice.ConcurrentModificationException=\u8fd9\u53ef\u80fd\u662f\u56e0\u4e3a\u60a8\u7684Java\u7248\u672c\u9ad8\u4e8eJava 1.8.0_11\u5bfc\u81f4\u7684,\u53ef\u4ee5\u5c1d\u8bd5\u5378\u8f7dJava8\u5b89\u88c5Java7\u3002
|
||||
crash.advice.ClassNotFoundException=Minecraft\u4e0d\u5b8c\u6574\u6216Mod\u51b2\u7a81\uff0c\u5982\u679c\u6709\u672a\u80fd\u4e0b\u8f7d\u7684\u6587\u4ef6\u8bf7\u4e0b\u8f7d\u6210\u529f\u540e\u91cd\u8bd5\u4e0b\u8f7d\u6574\u5408\u5305\u89e3\u51b3\u95ee\u9898\u3002
|
||||
crash.advice.NoSuchFieldError=Minecraft\u4e0d\u5b8c\u6574\u6216Mod\u51b2\u7a81\uff0c\u5982\u679c\u6709\u672a\u80fd\u4e0b\u8f7d\u7684\u6587\u4ef6\u8bf7\u4e0b\u8f7d\u6210\u529f\u540e\u91cd\u8bd5\u6216\u4e0b\u8f7d\u6574\u5408\u5305\u89e3\u51b3\u95ee\u9898\u3002
|
||||
crash.advice.ClassNotFoundException=Minecraft\u4e0d\u5b8c\u6574\u6216Mod\u51b2\u7a81\uff0c\u5982\u679c\u6709\u672a\u80fd\u4e0b\u8f7d\u7684\u6587\u4ef6\u8bf7\u4e0b\u8f7d\u6210\u529f\u540e\u91cd\u8bd5\u6216\u662f\u5ba2\u6237\u7aef\u635f\u574f\u8bf7\u91cd\u65b0\u5236\u4f5c\u5ba2\u6237\u7aef\u6216\u4e0b\u8f7d\u6574\u5408\u5305\u89e3\u51b3\u95ee\u9898\u3002
|
||||
crash.advice.NoSuchFieldError=Minecraft\u4e0d\u5b8c\u6574\u6216Mod\u51b2\u7a81\uff0c\u5982\u679c\u6709\u672a\u80fd\u4e0b\u8f7d\u7684\u6587\u4ef6\u8bf7\u4e0b\u8f7d\u6210\u529f\u540e\u91cd\u8bd5\u6216\u662f\u5ba2\u6237\u7aef\u635f\u574f\u8bf7\u91cd\u8bd5\u8bf7\u91cd\u65b0\u5236\u4f5c\u5ba2\u6237\u7aef\u6216\u4e0b\u8f7d\u6574\u5408\u5305\u89e3\u51b3\u95ee\u9898\u3002
|
||||
crash.advice.LWJGLException=\u60a8\u7684\u7535\u8111\u4e0d\u6b63\u5e38\uff0c\u53ef\u80fd\u9700\u8981\u4f7f\u7528\u9a71\u52a8\u7cbe\u7075\u6216\u5176\u4ed6\u5b89\u88c5\u5668\u66f4\u65b0\u663e\u5361\u9a71\u52a8\u3002
|
||||
crash.advice.SecurityException=\u53ef\u80fd\u662f\u60a8\u4fee\u6539\u4e86minecraft.jar\u4f46\u672a\u5220\u9664META-INF\u6587\u4ef6\u5939\u7684\u539f\u56e0\u3002\u8bf7\u901a\u8fc7\u538b\u7f29\u8f6f\u4ef6\u5220\u9664jar\u4e2d\u7684META-INF\u6587\u4ef6\u5939\u3002
|
||||
crash.advice.OutOfMemoryError=\u5185\u5b58\u6ea2\u51fa\uff0c\u60a8\u8bbe\u7f6e\u7684Minecraft\u6700\u5927\u5185\u5b58\u8fc7\u5c0f\uff0c\u8bf7\u8c03\u5927\uff01
|
||||
|
||||
@@ -96,8 +96,8 @@ ui.more=\u66f4\u591a
|
||||
|
||||
crash.advice.UnsupportedClassVersionError=\u9019\u53ef\u80fd\u662f\u56e0\u70ba\u60a8\u7684Java\u7248\u672c\u904e\u65bc\u8001\u820a\uff0c\u53ef\u4ee5\u5617\u8a66\u66f4\u63db\u6700\u65b0Java\u4e26\u5728\u7248\u672c\u8a2d\u5b9a\u7684Java\u8def\u5f91\u4e2d\u8a2d\u5b9a.
|
||||
crash.advice.ConcurrentModificationException=\u9019\u53ef\u80fd\u662f\u56e0\u70ba\u60a8\u7684Java\u7248\u672c\u9ad8\u65bcJava 1.8.0_11\u5c0e\u81f4\u7684,\u53ef\u4ee5\u5617\u8a66\u5378\u8f09Java8\u5b89\u88ddJava7\u3002
|
||||
crash.advice.ClassNotFoundException=Minecraft\u4e0d\u5b8c\u6574\u6216Mod\u885d\u7a81\uff0c\u5982\u679c\u6709\u672a\u80fd\u4e0b\u8f7d\u7684\u6587\u4ef6\u8bf7\u4e0b\u8f7d\u6210\u529f\u540e\u91cd\u8bd5\u6216\u4e0b\u8f09\u6574\u5408\u5305\u89e3\u6c7a\u554f\u984c\u3002
|
||||
crash.advice.NoSuchFieldError=Minecraft\u4e0d\u5b8c\u6574\u6216Mod\u885d\u7a81\uff0c\u5982\u679c\u6709\u672a\u80fd\u4e0b\u8f7d\u7684\u6587\u4ef6\u8bf7\u4e0b\u8f7d\u6210\u529f\u540e\u91cd\u8bd5\u6216\u4e0b\u8f09\u6574\u5408\u5305\u89e3\u6c7a\u554f\u984c\u3002
|
||||
crash.advice.ClassNotFoundException=Minecraft\u4e0d\u5b8c\u6574\u6216Mod\u885d\u7a81\uff0c\u5982\u679c\u6709\u672a\u80fd\u4e0b\u8f7d\u7684\u6587\u4ef6\u8bf7\u4e0b\u8f7d\u6210\u529f\u540e\u91cd\u8bd5\u6216\u662f\u5ba2\u6237\u7aef\u635f\u574f\u8bf7\u91cd\u8bd5\u8bf7\u91cd\u65b0\u5236\u4f5c\u5ba2\u6237\u7aef\u6216\u4e0b\u8f09\u6574\u5408\u5305\u89e3\u6c7a\u554f\u984c\u3002
|
||||
crash.advice.NoSuchFieldError=Minecraft\u4e0d\u5b8c\u6574\u6216Mod\u885d\u7a81\uff0c\u5982\u679c\u6709\u672a\u80fd\u4e0b\u8f7d\u7684\u6587\u4ef6\u8bf7\u4e0b\u8f7d\u6210\u529f\u540e\u91cd\u8bd5\u6216\u662f\u5ba2\u6237\u7aef\u635f\u574f\u8bf7\u91cd\u8bd5\u8bf7\u91cd\u65b0\u5236\u4f5c\u5ba2\u6237\u7aef\u6216\u4e0b\u8f09\u6574\u5408\u5305\u89e3\u6c7a\u554f\u984c\u3002
|
||||
crash.advice.LWJGLException=\u60a8\u7684\u7535\u8111\u4e0d\u6b63\u5e38\uff0c\u53ef\u80fd\u9700\u8981\u4f7f\u7528\u9a71\u52a8\u7cbe\u7075\u6216\u5176\u4ed6\u5b89\u88c5\u5668\u66f4\u65b0\u663e\u5361\u9a71\u52a8\u3002
|
||||
crash.advice.SecurityException=\u53ef\u80fd\u662f\u60a8\u4fee\u6539\u4e86minecraft.jar\u4f46\u672a\u522a\u9664META-INF\u6587\u4ef6\u593e\u7684\u539f\u56e0\u3002\u8acb\u901a\u904e\u58d3\u7e2e\u8edf\u4ef6\u522a\u9664jar\u4e2d\u7684META-INF\u6587\u4ef6\u593e\u3002
|
||||
crash.advice.OutOfMemoryError=\u5185\u5b58\u6ea2\u51fa\uff0c\u60a8\u8bbe\u7f6e\u7684Minecraft\u6700\u5927\u5185\u5b58\u8fc7\u5c0f\uff0c\u8bf7\u8c03\u5927\uff01
|
||||
|
||||
@@ -1,16 +1,27 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
* Copyright 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 2 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.
|
||||
*/
|
||||
|
||||
package org.jackhuang.hellominecraft.svrmgr;
|
||||
|
||||
import java.awt.Font;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.text.ParseException;
|
||||
import javax.swing.UIManager;
|
||||
import org.jackhuang.hellominecraft.utils.functions.NonConsumer;
|
||||
import javax.swing.UnsupportedLookAndFeelException;
|
||||
import org.jackhuang.hellominecraft.HMCLog;
|
||||
import org.jackhuang.hellominecraft.views.LogWindow;
|
||||
import org.jackhuang.hellominecraft.svrmgr.settings.SettingsManager;
|
||||
@@ -28,6 +39,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 byte firstVer = 0, secondVer = 8, thirdVer = 6;
|
||||
|
||||
public static String makeTitle() {
|
||||
return launcherName + ' ' + firstVer + '.' + secondVer + '.' + thirdVer;
|
||||
}
|
||||
@@ -38,15 +50,11 @@ public class Main {
|
||||
try {
|
||||
javax.swing.UIManager.setLookAndFeel(new HelloMinecraftLookAndFeel());
|
||||
UIManager.getLookAndFeelDefaults().put("defaultFont", new Font("微软雅黑", Font.PLAIN, 12));
|
||||
} catch (Throwable ex) {
|
||||
} catch (ParseException | UnsupportedLookAndFeelException ex) {
|
||||
HMCLog.warn("Failed to set look and feel", ex);
|
||||
}
|
||||
new UpdateChecker(new VersionNumber(firstVer, secondVer, thirdVer), "hmcsm", SettingsManager.settings.checkUpdate, new NonConsumer() {
|
||||
|
||||
@Override
|
||||
public void onDone() {
|
||||
new UpdateChecker(new VersionNumber(firstVer, secondVer, thirdVer), "hmcsm", SettingsManager.settings.checkUpdate, () -> {
|
||||
SettingsManager.settings.checkUpdate = false;
|
||||
}
|
||||
}).start();
|
||||
new MainWindow().setVisible(true);
|
||||
} catch (Throwable t) {
|
||||
|
||||
@@ -1,6 +1,18 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
* Copyright 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 2 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.
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.svrmgr.cbplugins;
|
||||
|
||||
@@ -27,10 +39,9 @@ public class BukkitPlugin {
|
||||
if (versions != null) {
|
||||
PluginVersion v = versions.get(0);
|
||||
List<String> al = v.game_versions;
|
||||
if(al != null && !al.isEmpty()) {
|
||||
if (al != null && !al.isEmpty())
|
||||
return al.get(0);
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,18 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
* Copyright 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 2 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.
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.svrmgr.cbplugins;
|
||||
|
||||
@@ -9,6 +21,7 @@ package org.jackhuang.hellominecraft.svrmgr.cbplugins;
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public class Category {
|
||||
|
||||
public double count;
|
||||
public String name;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,18 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
* Copyright 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 2 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.
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.svrmgr.cbplugins;
|
||||
|
||||
|
||||
@@ -1,6 +1,18 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
* Copyright 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 2 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.
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.svrmgr.cbplugins;
|
||||
|
||||
|
||||
@@ -1,6 +1,18 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
* Copyright 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 2 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.
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.svrmgr.cbplugins;
|
||||
|
||||
@@ -38,7 +50,8 @@ public class PluginManager {
|
||||
public static List<BukkitPlugin> getPlugins() throws Exception {
|
||||
String result = NetUtils.doGet("http://api.bukget.org/3//plugins?fields=slug,plugin_name,description,versions.version,versions.game_versions");
|
||||
Gson gson = new Gson();
|
||||
List<BukkitPlugin> list = gson.fromJson(result, new TypeToken<List<BukkitPlugin>>(){}.getType());
|
||||
List<BukkitPlugin> list = gson.fromJson(result, new TypeToken<List<BukkitPlugin>>() {
|
||||
}.getType());
|
||||
return list;
|
||||
}
|
||||
|
||||
@@ -62,25 +75,28 @@ public class PluginManager {
|
||||
public static List<BukkitPlugin> getPluginsByCategory(String category) throws Exception {
|
||||
String result = NetUtils.doGet("http://api.bukget.org/3//categories/" + category + "?fields=slug,plugin_name,description,versions.version,versions.game_versions");
|
||||
Gson gson = new Gson();
|
||||
List<BukkitPlugin> list = gson.fromJson(result, new TypeToken<List<BukkitPlugin>>(){}.getType());
|
||||
List<BukkitPlugin> list = gson.fromJson(result, new TypeToken<List<BukkitPlugin>>() {
|
||||
}.getType());
|
||||
return list;
|
||||
}
|
||||
|
||||
public static List<Category> getCategories() throws Exception {
|
||||
String result = NetUtils.doGet("http://api.bukget.org/3//categories/");
|
||||
Gson gson = new Gson();
|
||||
List<Category> list = gson.fromJson(result, new TypeToken<List<Category>>(){}.getType());
|
||||
List<Category> list = gson.fromJson(result, new TypeToken<List<Category>>() {
|
||||
}.getType());
|
||||
return list;
|
||||
}
|
||||
|
||||
public static PluginInfo getPluginInfo(String slug) throws Exception {
|
||||
if (StrUtils.isNotBlank(slug)) {
|
||||
String result = NetUtils.doGet("http://api.bukget.org/3//plugins/bukkit/" + slug.toLowerCase());
|
||||
if(StrUtils.isNotBlank(result)) {
|
||||
if (StrUtils.isNotBlank(result))
|
||||
if (!result.equals("null")) {
|
||||
PluginInfo info = new Gson().fromJson(result, PluginInfo.class);
|
||||
return info;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,18 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
* Copyright 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 2 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.
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.svrmgr.cbplugins;
|
||||
|
||||
@@ -11,6 +23,7 @@ import java.util.List;
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public class PluginVersion {
|
||||
|
||||
public long date;
|
||||
public String download, link, version;
|
||||
public List<String> game_versions;
|
||||
|
||||
@@ -1,9 +1,19 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
* Copyright 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 2 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.
|
||||
*/
|
||||
|
||||
package org.jackhuang.hellominecraft.svrmgr.installer.bukkit;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -1,9 +1,19 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
* Copyright 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 2 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.
|
||||
*/
|
||||
|
||||
package org.jackhuang.hellominecraft.svrmgr.installer.bukkit;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,18 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
* Copyright 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 2 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.
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.svrmgr.installer.cauldron;
|
||||
|
||||
@@ -58,19 +70,17 @@ public class ForgeFormatThread extends Thread {
|
||||
String prev = null;
|
||||
for (Element e2 : a) {
|
||||
String href = e2.attributes().get("href").toLowerCase();
|
||||
if(e2.text().toLowerCase().contains("changelog")) {
|
||||
if (e2.text().toLowerCase().contains("changelog"))
|
||||
v.changelog = href;
|
||||
} else if(prev != null) {
|
||||
else if (prev != null) {
|
||||
int index;
|
||||
if (href.contains("adf.ly")) index = 0;
|
||||
else index = 1;
|
||||
if(prev.toLowerCase().contains("installer")) {
|
||||
if (prev.toLowerCase().contains("installer"))
|
||||
v.installer[index] = href;
|
||||
} else
|
||||
if(prev.toLowerCase().contains("server")) {
|
||||
else if (prev.toLowerCase().contains("server"))
|
||||
v.universal[index] = href;
|
||||
}
|
||||
}
|
||||
prev = e2.text();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,18 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
* Copyright 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 2 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.
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.svrmgr.installer.cauldron;
|
||||
|
||||
@@ -70,9 +81,8 @@ public class ForgeInstaller {
|
||||
FileOutputStream fos = new FileOutputStream(file);
|
||||
BufferedOutputStream bos = new BufferedOutputStream(fos);
|
||||
int c;
|
||||
while ((c = is.read()) != -1) {
|
||||
while ((c = is.read()) != -1)
|
||||
bos.write((byte) c);
|
||||
}
|
||||
bos.close();
|
||||
fos.close();
|
||||
|
||||
@@ -89,9 +99,8 @@ public class ForgeInstaller {
|
||||
library.init();
|
||||
File lib = new File(gameDir, "libraries" + File.separator + library.formatted + ".pack.xz");
|
||||
String libURL = "https://libraries.minecraft.net/";
|
||||
if (StrUtils.isNotBlank(library.url)) {
|
||||
if (StrUtils.isNotBlank(library.url))
|
||||
libURL = library.url;
|
||||
}
|
||||
tw.addTask(new FileDownloadTask(libURL + library.formatted.replace("\\", "/"), lib).setTag(library.name));
|
||||
}
|
||||
tw.start();
|
||||
@@ -104,9 +113,8 @@ public class ForgeInstaller {
|
||||
File lib = new File(gameDir, "libraries" + File.separator + library.formatted);
|
||||
lib.getParentFile().mkdirs();
|
||||
String libURL = "https://libraries.minecraft.net/";
|
||||
if (StrUtils.isNotBlank(library.url)) {
|
||||
if (StrUtils.isNotBlank(library.url))
|
||||
libURL = library.url;
|
||||
}
|
||||
tw.addTask(new FileDownloadTask(libURL + library.formatted.replace("\\", "/"), lib).setTag(library.name));
|
||||
}
|
||||
tw.start();
|
||||
@@ -117,7 +125,7 @@ public class ForgeInstaller {
|
||||
for (MinecraftLibrary library : profile.versionInfo.libraries) {
|
||||
File lib = new File(gameDir, "libraries" + File.separator + library.formatted);
|
||||
File packFile = new File(gameDir, "libraries" + File.separator + library.formatted + ".pack.xz");
|
||||
if (packFile.exists() && packFile.isFile()) {
|
||||
if (packFile.exists() && packFile.isFile())
|
||||
try {
|
||||
unpackLibrary(lib.getParentFile(), NetUtils.getBytesFromStream(FileUtils.openInputStream(packFile)));
|
||||
if (!checksumValid(lib, Arrays.asList(library.checksums)))
|
||||
@@ -127,17 +135,14 @@ public class ForgeInstaller {
|
||||
badLibs.add(library.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (badLibs.size() > 0) {
|
||||
if (badLibs.size() > 0)
|
||||
MessageBox.Show("这些库在解压的时候出现了问题" + badLibs.toString());
|
||||
}
|
||||
}
|
||||
|
||||
public static void unpackLibrary(File output, byte[] data)
|
||||
throws IOException {
|
||||
if (output.exists()) {
|
||||
if (output.exists())
|
||||
output.delete();
|
||||
}
|
||||
|
||||
byte[] decompressed = IOUtils.readFully(new XZInputStream(new ByteArrayInputStream(data)));
|
||||
|
||||
@@ -169,9 +174,8 @@ public class ForgeInstaller {
|
||||
try {
|
||||
byte[] fileData = NetUtils.getBytesFromStream(FileUtils.openInputStream(libPath));
|
||||
boolean valid = (checksums == null) || (checksums.isEmpty()) || (checksums.contains(DigestUtils.sha1Hex(fileData)));
|
||||
if ((!valid) && (libPath.getName().endsWith(".jar"))) {
|
||||
if ((!valid) && (libPath.getName().endsWith(".jar")))
|
||||
valid = validateJar(libPath, fileData, checksums);
|
||||
}
|
||||
return valid;
|
||||
} catch (IOException e) {
|
||||
HMCLog.warn("Failed to checksum valid: " + libPath, e);
|
||||
@@ -189,24 +193,22 @@ public class ForgeInstaller {
|
||||
while (entry != null) {
|
||||
byte[] eData = IOUtils.readFully(jar);
|
||||
|
||||
if (entry.getName().equals("checksums.sha1")) {
|
||||
if (entry.getName().equals("checksums.sha1"))
|
||||
hashes = new String(eData, Charset.forName("UTF-8")).split("\n");
|
||||
}
|
||||
|
||||
if (!entry.isDirectory()) {
|
||||
if (!entry.isDirectory())
|
||||
files.put(entry.getName(), DigestUtils.sha1Hex(eData));
|
||||
}
|
||||
entry = jar.getNextJarEntry();
|
||||
}
|
||||
jar.close();
|
||||
|
||||
if (hashes != null) {
|
||||
boolean failed = !checksums.contains(files.get("checksums.sha1"));
|
||||
if (failed) {
|
||||
if (failed)
|
||||
System.out.println(" checksums.sha1 failed validation");
|
||||
} else {
|
||||
else {
|
||||
System.out.println(" checksums.sha1 validated successfully");
|
||||
for (String hash : hashes) {
|
||||
for (String hash : hashes)
|
||||
if ((!hash.trim().equals("")) && (hash.contains(" "))) {
|
||||
String[] e = hash.split(" ");
|
||||
String validChecksum = e[0];
|
||||
@@ -217,18 +219,15 @@ public class ForgeInstaller {
|
||||
System.out.println(" " + target + " : missing");
|
||||
failed = true;
|
||||
} else {
|
||||
if (checksum.equals(validChecksum)) {
|
||||
if (checksum.equals(validChecksum))
|
||||
continue;
|
||||
}
|
||||
System.out.println(" " + target + " : failed (" + checksum + ", " + validChecksum + ")");
|
||||
failed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!failed) {
|
||||
if (!failed)
|
||||
System.out.println(" Jar contents validated successfully");
|
||||
}
|
||||
|
||||
return !failed;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,18 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
* Copyright 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 2 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.
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.svrmgr.installer.cauldron;
|
||||
|
||||
@@ -9,6 +21,7 @@ package org.jackhuang.hellominecraft.svrmgr.installer.cauldron;
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public class ForgeVersion {
|
||||
|
||||
public String vername, ver, mcver, releasetime, changelog;
|
||||
public String[] installer, javadoc, src, universal, userdev;
|
||||
public int typeint;
|
||||
|
||||
@@ -1,9 +1,19 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
* Copyright 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 2 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.
|
||||
*/
|
||||
|
||||
package org.jackhuang.hellominecraft.svrmgr.installer.cauldron;
|
||||
|
||||
/**
|
||||
@@ -11,5 +21,6 @@ package org.jackhuang.hellominecraft.svrmgr.installer.cauldron;
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public class Install {
|
||||
|
||||
public String profileName, target, path, version, filePath, welcome, minecraft, mirrorList, logo;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,19 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
* Copyright 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 2 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.
|
||||
*/
|
||||
|
||||
package org.jackhuang.hellominecraft.svrmgr.installer.cauldron;
|
||||
|
||||
/**
|
||||
@@ -11,6 +21,7 @@ package org.jackhuang.hellominecraft.svrmgr.installer.cauldron;
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public class InstallProfile {
|
||||
|
||||
public Install install;
|
||||
public MinecraftVersion versionInfo;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,18 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
* Copyright 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 2 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.
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.svrmgr.installer.cauldron;
|
||||
|
||||
|
||||
@@ -1,7 +1,18 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
* Copyright 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 2 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.
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.svrmgr.installer.cauldron;
|
||||
|
||||
|
||||
@@ -1,6 +1,18 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
* Copyright 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 2 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.
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.svrmgr.server;
|
||||
|
||||
|
||||
@@ -1,6 +1,18 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
* Copyright 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 2 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.
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.svrmgr.server;
|
||||
|
||||
@@ -96,11 +108,10 @@ public class Server implements Event<Integer>, MonitorThread.MonitorThreadListen
|
||||
|
||||
public void run() throws IOException {
|
||||
String jvmPath;
|
||||
if (StrUtils.isBlank(SettingsManager.settings.javaDir)) {
|
||||
if (StrUtils.isBlank(SettingsManager.settings.javaDir))
|
||||
jvmPath = IOUtils.getJavaDir();
|
||||
} else {
|
||||
else
|
||||
jvmPath = SettingsManager.settings.javaDir;
|
||||
}
|
||||
String[] puts = new String[]{
|
||||
jvmPath,
|
||||
"-Xmx" + memory + "m",
|
||||
@@ -134,7 +145,7 @@ public class Server implements Event<Integer>, MonitorThread.MonitorThreadListen
|
||||
}
|
||||
|
||||
public void sendCommand(String cmd) {
|
||||
if (isRunning) {
|
||||
if (isRunning)
|
||||
try {
|
||||
sendStatus("发送指令: " + cmd);
|
||||
bw.write(cmd);
|
||||
@@ -144,7 +155,6 @@ public class Server implements Event<Integer>, MonitorThread.MonitorThreadListen
|
||||
Logger.getLogger(Server.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void getPlayerNumber(Consumer<Pair<String, String[]>> d) {
|
||||
isGettingPlayerNumber = 1;
|
||||
@@ -158,16 +168,14 @@ public class Server implements Event<Integer>, MonitorThread.MonitorThreadListen
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
if (timer != null) {
|
||||
if (timer != null)
|
||||
timer.cancel();
|
||||
}
|
||||
sendCommand("stop");
|
||||
}
|
||||
|
||||
public void shutdown() {
|
||||
if (timer != null) {
|
||||
if (timer != null)
|
||||
timer.cancel();
|
||||
}
|
||||
server.destroy();
|
||||
}
|
||||
|
||||
@@ -181,9 +189,8 @@ public class Server implements Event<Integer>, MonitorThread.MonitorThreadListen
|
||||
|
||||
public void delSchedule(Schedule s) {
|
||||
int index = schedules.indexOf(s);
|
||||
if (index == -1) {
|
||||
if (index == -1)
|
||||
return;
|
||||
}
|
||||
schedules.remove(index);
|
||||
timerTasks.get(index).cancel();
|
||||
timerTasks.remove(index);
|
||||
@@ -191,9 +198,8 @@ public class Server implements Event<Integer>, MonitorThread.MonitorThreadListen
|
||||
|
||||
private void registerThread(MonitorThread thread, InputStream is) {
|
||||
thread = new MonitorThread(is);
|
||||
for (MonitorThread.MonitorThreadListener l : listeners) {
|
||||
for (MonitorThread.MonitorThreadListener l : listeners)
|
||||
thread.addListener(l);
|
||||
}
|
||||
thread.addListener(this);
|
||||
thread.start();
|
||||
}
|
||||
@@ -243,9 +249,8 @@ public class Server implements Event<Integer>, MonitorThread.MonitorThreadListen
|
||||
restoreModsByType(paramString);
|
||||
|
||||
System.out.println("禁用不活动的文件: " + paramString);
|
||||
if ((paramArrayOfString == null) || (paramArrayOfString.size() <= 0)) {
|
||||
if ((paramArrayOfString == null) || (paramArrayOfString.size() <= 0))
|
||||
return;
|
||||
}
|
||||
File[] files = new File(Utilities.getGameDir(), paramString).listFiles();
|
||||
if (files == null) {
|
||||
System.out.println("没有文件: " + paramString);
|
||||
@@ -255,23 +260,20 @@ public class Server implements Event<Integer>, MonitorThread.MonitorThreadListen
|
||||
String name = file.getName();
|
||||
|
||||
if ((!paramArrayOfString.contains(name))
|
||||
|| ((!name.toLowerCase().endsWith(".zip")) && (!name.toLowerCase().endsWith(".jar")))) {
|
||||
|| ((!name.toLowerCase().endsWith(".zip")) && (!name.toLowerCase().endsWith(".jar"))))
|
||||
continue;
|
||||
}
|
||||
|
||||
String newName = name + "X";
|
||||
File newFile = new File(file.getParentFile(), newName);
|
||||
|
||||
if (newFile.exists()) {
|
||||
if (newFile.exists())
|
||||
newFile.delete();
|
||||
}
|
||||
if (file.renameTo(newFile)) {
|
||||
if (file.renameTo(newFile))
|
||||
System.out.println("已禁用: " + name + ", 新名称: " + newFile.getName());
|
||||
} else {
|
||||
else
|
||||
System.out.println("无法禁用: " + name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void restoreModsByType(String paramString) {
|
||||
System.out.println("还原被禁用的文件: " + paramString);
|
||||
@@ -280,21 +282,18 @@ public class Server implements Event<Integer>, MonitorThread.MonitorThreadListen
|
||||
for (File file : files) if (!file.isDirectory()) {
|
||||
String name = file.getName();
|
||||
String lowName = name.toLowerCase();
|
||||
if ((!lowName.endsWith(".zipx")) && (!lowName.endsWith(".jarx"))) {
|
||||
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()) {
|
||||
if (newFile.exists())
|
||||
file.delete();
|
||||
} else {
|
||||
if (!file.renameTo(newFile)) {
|
||||
else
|
||||
if (!file.renameTo(newFile))
|
||||
System.out.println("无法重命名: " + file.getName() + " 到: " + newFile.getName() + " 在: " + file.getParent());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void restoreMods() {
|
||||
if (disactived) {
|
||||
@@ -311,9 +310,8 @@ public class Server implements Event<Integer>, MonitorThread.MonitorThreadListen
|
||||
if (isGettingPlayerNumber == 1) {
|
||||
Pattern p = Pattern.compile("There are [0-9]*/[0-9]* players online");
|
||||
Matcher m = p.matcher(status);
|
||||
if (!m.find()) {
|
||||
if (!m.find())
|
||||
return;
|
||||
}
|
||||
String s = m.group(0);
|
||||
s = s.substring(10, s.length() - 15);
|
||||
playerNumber = s;
|
||||
@@ -327,11 +325,10 @@ public class Server implements Event<Integer>, MonitorThread.MonitorThreadListen
|
||||
HMCLog.warn("Failed to substring status.", e);
|
||||
}
|
||||
String[] s;
|
||||
if(StrUtils.isNotBlank(status)) {
|
||||
if (StrUtils.isNotBlank(status))
|
||||
s = status.trim().split(", ");
|
||||
} else {
|
||||
else
|
||||
s = new String[0];
|
||||
}
|
||||
Pair<String, String[]> p = new Pair<>(playerNumber, s);
|
||||
isGettingPlayerNumber = 0;
|
||||
gettingPlayerNumber.accept(p);
|
||||
@@ -361,12 +358,10 @@ public class Server implements Event<Integer>, MonitorThread.MonitorThreadListen
|
||||
isDone = true;
|
||||
}
|
||||
}
|
||||
if (status.length() > 20) {
|
||||
if (status.substring(20).contains("[SEVERE] This crash report has been saved to: ")) {
|
||||
if (status.length() > 20)
|
||||
if (status.substring(20).contains("[SEVERE] This crash report has been saved to: "))
|
||||
for (Schedule schedule : schedules) if (schedule.timeType == Schedule.TIME_TYPE_SERVER_CRASHED) ScheduleTranslator.translate(this, schedule).run();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GregorianCalendar c = new GregorianCalendar();
|
||||
|
||||
|
||||
@@ -1,6 +1,18 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
* Copyright 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 2 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.
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.svrmgr.server;
|
||||
|
||||
@@ -23,12 +35,10 @@ public class ServerChecker {
|
||||
HMCLog.warn("", ex);
|
||||
return false;
|
||||
}
|
||||
if(file.getEntry("org/bukkit/craftbukkit/Main.class") != null) {
|
||||
if (file.getEntry("org/bukkit/craftbukkit/Main.class") != null)
|
||||
return true;
|
||||
}
|
||||
if(file.getEntry("net/minecraft/server/MinecraftServer.class") != null) {
|
||||
if (file.getEntry("net/minecraft/server/MinecraftServer.class") != null)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,18 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
* Copyright 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 2 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.
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.svrmgr.server.backups;
|
||||
|
||||
@@ -53,10 +65,9 @@ public class BackupManager {
|
||||
for (String folder : folders) {
|
||||
String worldPath = gameDir + folder + File.separator;
|
||||
ArrayList<String> files = Utilities.findAllFile(new File(worldPath));
|
||||
if(files.contains("level.dat")) {
|
||||
if (files.contains("level.dat"))
|
||||
result.add(folder);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -77,11 +88,10 @@ public class BackupManager {
|
||||
|
||||
public static void backupAllWorlds() {
|
||||
ArrayList<String> al = findAllWorlds();
|
||||
for(String world : al) {
|
||||
for (String world : al)
|
||||
if (!SettingsManager.settings.inactiveWorlds.contains(world))
|
||||
addWorldBackup(world);
|
||||
}
|
||||
}
|
||||
|
||||
public static void backupAllPlugins() {
|
||||
new File(backupDir()).mkdirs();
|
||||
|
||||
@@ -1,6 +1,18 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
* Copyright 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 2 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.
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.svrmgr.server.download;
|
||||
|
||||
@@ -9,5 +21,6 @@ package org.jackhuang.hellominecraft.svrmgr.server.download;
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public class ServerDownloadPackage {
|
||||
|
||||
public String mcversion, version, forgeversion, majorversion, file;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,18 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
* Copyright 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 2 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.
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.svrmgr.server.schedules;
|
||||
|
||||
|
||||
@@ -1,6 +1,18 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
* Copyright 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 2 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.
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.svrmgr.server.schedules;
|
||||
|
||||
|
||||
@@ -1,6 +1,18 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
* Copyright 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 2 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.
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.svrmgr.server.schedules;
|
||||
|
||||
@@ -15,6 +27,7 @@ import org.jackhuang.hellominecraft.svrmgr.settings.Schedule;
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public class AutoExecuteSchedule extends TimerTask {
|
||||
|
||||
Schedule main;
|
||||
Server server;
|
||||
|
||||
|
||||
@@ -1,6 +1,18 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
* Copyright 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 2 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.
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.svrmgr.server.schedules;
|
||||
|
||||
|
||||
@@ -1,6 +1,18 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
* Copyright 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 2 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.
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.svrmgr.server.schedules;
|
||||
|
||||
|
||||
@@ -1,6 +1,18 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
* Copyright 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 2 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.
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.svrmgr.server.schedules;
|
||||
|
||||
@@ -13,6 +25,7 @@ import org.jackhuang.hellominecraft.svrmgr.settings.Schedule;
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public abstract class AutoSchedule extends TimerTask {
|
||||
|
||||
Schedule main;
|
||||
Server server;
|
||||
|
||||
|
||||
@@ -1,6 +1,18 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
* Copyright 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 2 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.
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.svrmgr.server.schedules;
|
||||
|
||||
|
||||
@@ -1,9 +1,19 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
* Copyright 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 2 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.
|
||||
*/
|
||||
|
||||
package org.jackhuang.hellominecraft.svrmgr.settings;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
|
||||
@@ -1,7 +1,18 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
* Copyright 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 2 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.
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.svrmgr.settings;
|
||||
|
||||
|
||||
@@ -1,7 +1,18 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
* Copyright 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 2 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.
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.svrmgr.settings;
|
||||
|
||||
@@ -62,9 +73,8 @@ public abstract class PlayerList<T extends BasePlayer> {
|
||||
for (String l : lines) {
|
||||
if (l.startsWith("#")) continue;
|
||||
T player = newPlayer(l);
|
||||
if (StrUtils.isBlank(l)) {
|
||||
if (StrUtils.isBlank(l))
|
||||
continue;
|
||||
}
|
||||
op.add(player);
|
||||
}
|
||||
}
|
||||
@@ -86,7 +96,7 @@ public abstract class PlayerList<T extends BasePlayer> {
|
||||
}
|
||||
}*/
|
||||
op = null;
|
||||
if(txt.exists()) {
|
||||
if (txt.exists())
|
||||
try {
|
||||
initByText(FileUtils.readFileToStringIgnoreFileNotFound(txt));
|
||||
if (op != null)
|
||||
@@ -94,7 +104,6 @@ public abstract class PlayerList<T extends BasePlayer> {
|
||||
} catch (IOException e) {
|
||||
HMCLog.warn("Failed to load playerlist by txt", e);
|
||||
}
|
||||
}
|
||||
op = player;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,18 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
* Copyright 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 2 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.
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.svrmgr.settings;
|
||||
|
||||
@@ -9,19 +21,17 @@ package org.jackhuang.hellominecraft.svrmgr.settings;
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public class Schedule {
|
||||
public static final int
|
||||
TYPE_AUTO_SAVE = 0,
|
||||
|
||||
public static final int TYPE_AUTO_SAVE = 0,
|
||||
TYPE_AUTO_RESTART = 1,
|
||||
TYPE_AUTO_BACKUP = 2,
|
||||
TYPE_AUTO_BROADCAST = 3,
|
||||
TYPE_AUTO_SEND_COMMAND = 4,
|
||||
TYPE_AUTO_EXECUTE = 5;
|
||||
public static final int
|
||||
TYPE2_AUTO_BACKUP_PLUGINS = 1,
|
||||
public static final int TYPE2_AUTO_BACKUP_PLUGINS = 1,
|
||||
TYPE2_AUTH_BACKUP_CONFIG = 2,
|
||||
TYPE3_AUTH_BACKUP_WORLD = 3;
|
||||
public static final int
|
||||
TIME_TYPE_PER = 0,
|
||||
public static final int TIME_TYPE_PER = 0,
|
||||
TIME_TYPE_PAST_HOUR = 1,
|
||||
TIME_TYPE_SERVER_STARTED = 2,
|
||||
TIME_TYPE_SERVER_STOPPED = 3,
|
||||
|
||||
@@ -1,6 +1,18 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
* Copyright 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 2 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.
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.svrmgr.settings;
|
||||
|
||||
@@ -215,39 +227,39 @@ public class ServerProperties {
|
||||
}
|
||||
|
||||
public static String getDefault() {
|
||||
return "generator-settings=\n" +
|
||||
"op-permission-level=4\n" +
|
||||
"allow-nether=true\n" +
|
||||
"level-name=world\n" +
|
||||
"enable-query=false\n" +
|
||||
"allow-flight=false\n" +
|
||||
"announce-player-achievements=true\n" +
|
||||
"server-port=25565\n" +
|
||||
"level-type=DEFAULT\n" +
|
||||
"enable-rcon=false\n" +
|
||||
"force-gamemode=false\n" +
|
||||
"level-seed=\n" +
|
||||
"server-ip=\n" +
|
||||
"max-build-height=256\n" +
|
||||
"spawn-npcs=true\n" +
|
||||
"white-list=false\n" +
|
||||
"spawn-animals=true\n" +
|
||||
"hardcore=false\n" +
|
||||
"snooper-enabled=true\n" +
|
||||
"online-mode=false\n" +
|
||||
"resource-pack=\n" +
|
||||
"pvp=true\n" +
|
||||
"difficulty=1\n" +
|
||||
"server-name=Unknown Server\n" +
|
||||
"enable-command-block=false\n" +
|
||||
"gamemode=0\n" +
|
||||
"player-idle-timeout=0\n" +
|
||||
"max-players=20\n" +
|
||||
"spawn-monsters=true\n" +
|
||||
"generate-structures=true\n" +
|
||||
"view-distance=10\n" +
|
||||
"spawn-protection=16\n" +
|
||||
"motd=A Minecraft Server";
|
||||
return "generator-settings=\n"
|
||||
+ "op-permission-level=4\n"
|
||||
+ "allow-nether=true\n"
|
||||
+ "level-name=world\n"
|
||||
+ "enable-query=false\n"
|
||||
+ "allow-flight=false\n"
|
||||
+ "announce-player-achievements=true\n"
|
||||
+ "server-port=25565\n"
|
||||
+ "level-type=DEFAULT\n"
|
||||
+ "enable-rcon=false\n"
|
||||
+ "force-gamemode=false\n"
|
||||
+ "level-seed=\n"
|
||||
+ "server-ip=\n"
|
||||
+ "max-build-height=256\n"
|
||||
+ "spawn-npcs=true\n"
|
||||
+ "white-list=false\n"
|
||||
+ "spawn-animals=true\n"
|
||||
+ "hardcore=false\n"
|
||||
+ "snooper-enabled=true\n"
|
||||
+ "online-mode=false\n"
|
||||
+ "resource-pack=\n"
|
||||
+ "pvp=true\n"
|
||||
+ "difficulty=1\n"
|
||||
+ "server-name=Unknown Server\n"
|
||||
+ "enable-command-block=false\n"
|
||||
+ "gamemode=0\n"
|
||||
+ "player-idle-timeout=0\n"
|
||||
+ "max-players=20\n"
|
||||
+ "spawn-monsters=true\n"
|
||||
+ "generate-structures=true\n"
|
||||
+ "view-distance=10\n"
|
||||
+ "spawn-protection=16\n"
|
||||
+ "motd=A Minecraft Server";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,18 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
* Copyright 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 2 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.
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.svrmgr.settings;
|
||||
|
||||
@@ -22,12 +34,12 @@ public class Settings {
|
||||
public Settings() {
|
||||
maxMemory = "1024";
|
||||
checkUpdate = true;
|
||||
schedules = new ArrayList<Schedule>();
|
||||
schedules = new ArrayList<>();
|
||||
mainjar = bgPath = javaDir = javaArgs = "";
|
||||
inactiveExtMods = new ArrayList<String>();
|
||||
inactiveCoreMods = new ArrayList<String>();
|
||||
inactivePlugins = new ArrayList<String>();
|
||||
inactiveWorlds = new ArrayList<String>();
|
||||
inactiveExtMods = new ArrayList<>();
|
||||
inactiveCoreMods = new ArrayList<>();
|
||||
inactivePlugins = new ArrayList<>();
|
||||
inactiveWorlds = new ArrayList<>();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,18 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
* Copyright 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 2 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.
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.svrmgr.settings;
|
||||
|
||||
@@ -28,18 +40,17 @@ public class SettingsManager {
|
||||
public static void load() {
|
||||
gson = new Gson();
|
||||
File file = new File(IOUtils.currentDir(), "hmcsm.json");
|
||||
if (file.exists()) {
|
||||
if (file.exists())
|
||||
try {
|
||||
String str = FileUtils.readFileToString(file);
|
||||
if (str == null || str.trim().equals("")) {
|
||||
if (str == null || str.trim().equals(""))
|
||||
init();
|
||||
} else {
|
||||
else
|
||||
settings = gson.fromJson(str, Settings.class);
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
init();
|
||||
}
|
||||
} else {
|
||||
else {
|
||||
settings = new Settings();
|
||||
save();
|
||||
}
|
||||
|
||||
@@ -1,9 +1,19 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
* Copyright 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 2 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.
|
||||
*/
|
||||
|
||||
package org.jackhuang.hellominecraft.svrmgr.settings;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,18 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
* Copyright 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 2 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.
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.svrmgr.threads;
|
||||
|
||||
@@ -27,7 +39,7 @@ public class MonitorThread extends Thread {
|
||||
ArrayList<MonitorThreadListener> listeners;
|
||||
|
||||
public MonitorThread(InputStream is) {
|
||||
this.listeners = new ArrayList<MonitorThreadListener>(5);
|
||||
this.listeners = new ArrayList<>(5);
|
||||
try {
|
||||
br = new BufferedReader(new InputStreamReader(is, System.getProperty("sun.jnu.encoding", "gbk")));
|
||||
} catch (UnsupportedEncodingException ex) {
|
||||
|
||||
@@ -1,6 +1,18 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
* Copyright 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 2 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.
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.svrmgr.threads;
|
||||
|
||||
|
||||
@@ -1,6 +1,18 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
* Copyright 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 2 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.
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.svrmgr.utils;
|
||||
|
||||
@@ -26,18 +38,23 @@ public class FolderOpener {
|
||||
public static void openResourcePacks(String gameDir) {
|
||||
open(gameDir + "resourcepacks");
|
||||
}
|
||||
|
||||
public static void openTextutrePacks(String gameDir) {
|
||||
open(gameDir + "texturepacks");
|
||||
}
|
||||
|
||||
public static void openMods() {
|
||||
open(Utilities.try2GetPath("mods"));
|
||||
}
|
||||
|
||||
public static void openCoreMods() {
|
||||
open(Utilities.try2GetPath("coremods"));
|
||||
}
|
||||
|
||||
public static void openPlugins() {
|
||||
open(Utilities.try2GetPath("plugins"));
|
||||
}
|
||||
|
||||
public static void openConfig() {
|
||||
open(Utilities.try2GetPath("config"));
|
||||
}
|
||||
|
||||
@@ -1,6 +1,18 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
* Copyright 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 2 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.
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.svrmgr.utils;
|
||||
|
||||
|
||||
@@ -1,9 +1,19 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
* Copyright 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 2 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.
|
||||
*/
|
||||
|
||||
package org.jackhuang.hellominecraft.svrmgr.utils;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
@@ -34,9 +44,8 @@ public class IPGet extends Thread {
|
||||
Pattern p = Pattern.compile("\\[(\\d|[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5])){3}\\]");
|
||||
Matcher m = p.matcher(s);
|
||||
s = "";
|
||||
while(m.find()) {
|
||||
while (m.find())
|
||||
s += m.group() + ",";
|
||||
}
|
||||
dl.accept(s.substring(0, s.length() - 1));
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
|
||||
@@ -1,6 +1,18 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
* Copyright 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 2 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.
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.svrmgr.utils;
|
||||
|
||||
@@ -13,6 +25,7 @@ import java.util.zip.ZipFile;
|
||||
|
||||
/**
|
||||
* 判断mod类型
|
||||
*
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public class ModType {
|
||||
@@ -35,8 +48,7 @@ public class ModType {
|
||||
zipFile = new ZipFile(path);
|
||||
String gbkPath;
|
||||
java.util.Enumeration e = zipFile.entries();
|
||||
while (e.hasMoreElements())
|
||||
{
|
||||
while (e.hasMoreElements()) {
|
||||
ZipEntry zipEnt = (ZipEntry) e.nextElement();
|
||||
if (zipEnt.isDirectory()) continue;
|
||||
gbkPath = zipEnt.getName();
|
||||
|
||||
@@ -1,6 +1,18 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
* Copyright 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 2 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.
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.svrmgr.utils;
|
||||
|
||||
|
||||
@@ -1,6 +1,18 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
* Copyright 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 2 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.
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.svrmgr.utils;
|
||||
|
||||
@@ -56,11 +68,10 @@ public class MonitorServiceImpl implements IMonitorService {
|
||||
for (parentThread = Thread.currentThread().getThreadGroup(); parentThread.getParent() != null; parentThread = parentThread.getParent());
|
||||
int totalThread = parentThread.activeCount();
|
||||
double cpuRatio = 0;
|
||||
if (osName.toLowerCase().startsWith("windows")) {
|
||||
if (osName.toLowerCase().startsWith("windows"))
|
||||
cpuRatio = this.getCpuRatioForWindows();
|
||||
} else {
|
||||
else
|
||||
cpuRatio = getCpuRateForLinux();
|
||||
}
|
||||
// 构造返回对象
|
||||
MonitorInfoBean infoBean = new MonitorInfoBean();
|
||||
infoBean.setFreeMemory(freeMemory);
|
||||
@@ -135,15 +146,12 @@ public class MonitorServiceImpl implements IMonitorService {
|
||||
private static void freeResource(InputStream is, InputStreamReader isr,
|
||||
BufferedReader br) {
|
||||
try {
|
||||
if (is != null) {
|
||||
if (is != null)
|
||||
is.close();
|
||||
}
|
||||
if (isr != null) {
|
||||
if (isr != null)
|
||||
isr.close();
|
||||
}
|
||||
if (br != null) {
|
||||
if (br != null)
|
||||
br.close();
|
||||
}
|
||||
} catch (IOException ioe) {
|
||||
System.out.println(ioe.getMessage());
|
||||
}
|
||||
@@ -166,9 +174,8 @@ public class MonitorServiceImpl implements IMonitorService {
|
||||
long idletime = c1[0] - c0[0];
|
||||
long busytime = c1[1] - c0[1];
|
||||
return (double) PERCENT * (busytime) / (busytime + idletime);
|
||||
} else {
|
||||
} else
|
||||
return 0.0;
|
||||
}
|
||||
} catch (IOException | InterruptedException ex) {
|
||||
ex.printStackTrace();
|
||||
return 0.0;
|
||||
@@ -189,9 +196,8 @@ public class MonitorServiceImpl implements IMonitorService {
|
||||
InputStreamReader ir = new InputStreamReader(proc.getInputStream());
|
||||
LineNumberReader input = new LineNumberReader(ir);
|
||||
String line = input.readLine();
|
||||
if (line == null || line.length() < FAULTLENGTH) {
|
||||
if (line == null || line.length() < FAULTLENGTH)
|
||||
return null;
|
||||
}
|
||||
int capidx = line.indexOf("Caption");
|
||||
int cmdidx = line.indexOf("CommandLine");
|
||||
int rocidx = line.indexOf("ReadOperationCount");
|
||||
@@ -202,34 +208,28 @@ public class MonitorServiceImpl implements IMonitorService {
|
||||
long kneltime = 0;
|
||||
long usertime = 0;
|
||||
while ((line = input.readLine()) != null) {
|
||||
if (line.length() < wocidx) {
|
||||
if (line.length() < wocidx)
|
||||
continue;
|
||||
}
|
||||
// 字段出现顺序:Caption,CommandLine,KernelModeTime,ReadOperationCount,
|
||||
// ThreadCount,UserModeTime,WriteOperation
|
||||
String caption = StrUtils.substring(line, capidx, cmdidx - 1).trim();
|
||||
String cmd = StrUtils.substring(line, cmdidx, kmtidx - 1).trim();
|
||||
if (cmd.contains("wmic.exe")) {
|
||||
if (cmd.contains("wmic.exe"))
|
||||
continue;
|
||||
}
|
||||
String s1 = StrUtils.substring(line, kmtidx, rocidx - 1).trim();
|
||||
String s2 = StrUtils.substring(line, umtidx, wocidx - 1).trim();
|
||||
if (caption.equals("System Idle Process") || caption.equals("System")) {
|
||||
if (s1.length() > 0) {
|
||||
if (s1.length() > 0)
|
||||
idletime += Long.parseLong(s1);
|
||||
}
|
||||
if (s2.length() > 0) {
|
||||
if (s2.length() > 0)
|
||||
idletime += Long.parseLong(s2);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (s1.length() > 0) {
|
||||
if (s1.length() > 0)
|
||||
kneltime += Long.parseLong(s1);
|
||||
}
|
||||
if (s2.length() > 0) {
|
||||
if (s2.length() > 0)
|
||||
usertime += Long.parseLong(s2);
|
||||
}
|
||||
}
|
||||
retn[0] = idletime;
|
||||
retn[1] = kneltime + usertime;
|
||||
return retn;
|
||||
|
||||
@@ -1,6 +1,18 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
* Copyright 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 2 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.
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.svrmgr.utils;
|
||||
|
||||
@@ -51,7 +63,7 @@ public class Utilities {
|
||||
}
|
||||
|
||||
public static ArrayList<String> findAllFile(File f) {
|
||||
ArrayList<String> arr = new ArrayList<String>();
|
||||
ArrayList<String> arr = new ArrayList<>();
|
||||
if (!f.exists()) {
|
||||
return arr;
|
||||
}
|
||||
@@ -68,7 +80,7 @@ public class Utilities {
|
||||
}
|
||||
|
||||
public static ArrayList<String> findAllDir(File f) {
|
||||
ArrayList<String> arr = new ArrayList<String>();
|
||||
ArrayList<String> arr = new ArrayList<>();
|
||||
if (f.isDirectory()) {
|
||||
File[] f1 = f.listFiles();
|
||||
int len = f1.length;
|
||||
@@ -104,10 +116,7 @@ public class Utilities {
|
||||
|
||||
public static boolean is16Folder(String path) {
|
||||
path = Utilities.addSeparator(path);
|
||||
if (new File(path + "versions").exists()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return new File(path + "versions").exists();
|
||||
}
|
||||
|
||||
public static boolean isEmpty(String s) {
|
||||
@@ -184,11 +193,11 @@ public class Utilities {
|
||||
dp.browse(uri);
|
||||
isBrowsed = true;
|
||||
}
|
||||
} catch (java.lang.NullPointerException e) {
|
||||
} catch (java.lang.NullPointerException | java.io.IOException e) {
|
||||
//此为uri为空时抛出异常
|
||||
} catch (java.io.IOException e) {
|
||||
//此为无法获取系统默认浏览器
|
||||
}
|
||||
|
||||
}
|
||||
return isBrowsed;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,18 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
* Copyright 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 2 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.
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.svrmgr.views;
|
||||
|
||||
|
||||
@@ -1,6 +1,18 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
* Copyright 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 2 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.
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.svrmgr.views;
|
||||
|
||||
@@ -31,30 +43,25 @@ public class InputDialog extends javax.swing.JDialog {
|
||||
super(parent, modal);
|
||||
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
|
||||
|
||||
textFields = new ArrayList<JTextField>();
|
||||
panels = new ArrayList<JPanel>();
|
||||
textFields = new ArrayList<>();
|
||||
panels = new ArrayList<>();
|
||||
jButton1 = new javax.swing.JButton();
|
||||
jButton1.setText("确认");
|
||||
jButton1.addActionListener(new ActionListener() {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
jButton1.addActionListener((ActionEvent e) -> {
|
||||
result = new String[textFields.size()];
|
||||
for (int i = 0; i < textFields.size(); i++)
|
||||
result[i] = textFields.get(i).getText();
|
||||
InputDialog.this.dispose();
|
||||
}
|
||||
});
|
||||
for(String s : messages) {
|
||||
for (String s : messages)
|
||||
makeNewField(s);
|
||||
}
|
||||
makeLayout();
|
||||
Dimension scrSize = Toolkit.getDefaultToolkit().getScreenSize();
|
||||
setLocation((scrSize.width - this.getWidth()) / 2,
|
||||
(scrSize.height - this.getHeight()) / 2);
|
||||
}
|
||||
|
||||
void makeNewField(String message) {
|
||||
final void makeNewField(String message) {
|
||||
JLabel label = new JLabel();
|
||||
label.setText(message);
|
||||
JTextField textField = new JTextField();
|
||||
@@ -87,7 +94,7 @@ public class InputDialog extends javax.swing.JDialog {
|
||||
panels.add(panel);
|
||||
}
|
||||
|
||||
void makeLayout() {
|
||||
final void makeLayout() {
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
GroupLayout.ParallelGroup g = layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING);
|
||||
|
||||
@@ -1,6 +1,18 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
* Copyright 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 2 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.
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.svrmgr.views;
|
||||
|
||||
|
||||
@@ -1,6 +1,18 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
* Copyright 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 2 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.
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.svrmgr.views;
|
||||
|
||||
@@ -36,12 +48,11 @@ public class PluginInfoDialog extends javax.swing.JDialog {
|
||||
lblWebsite.setText(pi.link);
|
||||
//SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
DefaultTableModel model = (DefaultTableModel) lstPluginInfo.getModel();
|
||||
for (PluginVersion v : pi.versions) {
|
||||
for (PluginVersion v : pi.versions)
|
||||
model.addRow(new Object[]{
|
||||
v.date, v.version, v.filename, StrUtils.parseParams("", v.game_versions.toArray(), ", "),
|
||||
v.type
|
||||
});
|
||||
}
|
||||
lstPluginInfo.updateUI();
|
||||
}
|
||||
|
||||
@@ -216,9 +227,8 @@ public class PluginInfoDialog extends javax.swing.JDialog {
|
||||
|
||||
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
|
||||
int index = lstPluginInfo.getSelectedRow();
|
||||
if (index == -1) {
|
||||
if (index == -1)
|
||||
return;
|
||||
}
|
||||
String url = pi.versions.get(index).download;
|
||||
TaskWindow.getInstance()
|
||||
.addTask(new FileDownloadTask(url, new File(Utilities.getGameDir() + "plugins"
|
||||
|
||||
Reference in New Issue
Block a user