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'
|
configuration 'proguard.pro'
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
task makeExecutable(dependsOn: jar) {
|
task makeExecutable(dependsOn: jar) << {
|
||||||
ext {
|
ext {
|
||||||
def re = jar.classifier
|
|
||||||
injar = jar.archivePath
|
|
||||||
jar.classifier = ''
|
jar.classifier = ''
|
||||||
outjar = jar.archivePath
|
makeExecutableinjar = jar.archivePath
|
||||||
jar.classifier = re
|
jar.classifier = ''
|
||||||
|
makeExecutableoutjar = jar.archivePath
|
||||||
|
jar.classifier = ''
|
||||||
}
|
}
|
||||||
def fos = new FileOutputStream(outjar)
|
def loc = new File(project.buildDir, "libs/" + makeExecutableoutjar.getName().substring(0, makeExecutableoutjar.getName().length()-4)+".exe")
|
||||||
def is = new FileInputStream('')
|
def fos = new FileOutputStream(loc)
|
||||||
def read
|
def is = new FileInputStream(new File(project.buildDir, '../HMCLauncher.exe'))
|
||||||
|
int read
|
||||||
def bytes = new byte[8192]
|
def bytes = new byte[8192]
|
||||||
while((read = is.read(bytes)) != -1)
|
while((read = is.read(bytes)) != -1)
|
||||||
fos.write(bytes, 0, read);
|
fos.write(bytes, 0, read);
|
||||||
is.close()
|
is.close()
|
||||||
is = new FileInputStream(injar)
|
is = new FileInputStream(makeExecutableinjar)
|
||||||
while((read = is.read(bytes)) != -1)
|
while((read = is.read(bytes)) != -1)
|
||||||
fos.write(bytes, 0, read);
|
fos.write(bytes, 0, read);
|
||||||
is.close()
|
is.close()
|
||||||
fos.close()
|
fos.close()
|
||||||
}*/
|
}
|
||||||
|
/*
|
||||||
launch4j {
|
launch4j {
|
||||||
launch4jCmd = 'D:\\Develop\\Java\\Launch4j\\launch4j.exe'
|
launch4jCmd = 'D:\\Develop\\Java\\Launch4j\\launch4j.exe'
|
||||||
supportUrl = 'http://www.mcbbs.net/thread-142335-1-1.html'
|
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
|
jar = new File(project.buildDir, 'libs/' + mavenGroupId + '-' + mavenVersion + '.jar').absolutePath
|
||||||
outfile = mavenGroupId + '-' + mavenVersion + '.exe'
|
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'
|
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 {
|
processResources {
|
||||||
from(sourceSets.main.resources.srcDirs) {
|
from(sourceSets.main.resources.srcDirs) {
|
||||||
@@ -133,5 +134,5 @@ processResources {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
build.dependsOn proguard
|
makeExecutable.dependsOn proguard
|
||||||
//build.dependsOn makeExecutable
|
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.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.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.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\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.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.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
|
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.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.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.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\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.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.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
|
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.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.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.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\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.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.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
|
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.
|
* Copyright 2013 huangyuhui <huanghongxun2008@126.com>
|
||||||
* To change this template file, choose Tools | Templates
|
*
|
||||||
* and open the template in the editor.
|
* 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;
|
package org.jackhuang.hellominecraft.svrmgr;
|
||||||
|
|
||||||
import java.awt.Font;
|
import java.awt.Font;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
|
import java.text.ParseException;
|
||||||
import javax.swing.UIManager;
|
import javax.swing.UIManager;
|
||||||
import org.jackhuang.hellominecraft.utils.functions.NonConsumer;
|
import javax.swing.UnsupportedLookAndFeelException;
|
||||||
import org.jackhuang.hellominecraft.HMCLog;
|
import org.jackhuang.hellominecraft.HMCLog;
|
||||||
import org.jackhuang.hellominecraft.views.LogWindow;
|
import org.jackhuang.hellominecraft.views.LogWindow;
|
||||||
import org.jackhuang.hellominecraft.svrmgr.settings.SettingsManager;
|
import org.jackhuang.hellominecraft.svrmgr.settings.SettingsManager;
|
||||||
@@ -28,6 +39,7 @@ public class Main {
|
|||||||
public static String launcherName = "Hello Minecraft! Server Manager";
|
public static String launcherName = "Hello Minecraft! Server Manager";
|
||||||
public static final String PUBLISH_URL = "http://www.mcbbs.net/thread-171239-1-1.html";
|
public static final String PUBLISH_URL = "http://www.mcbbs.net/thread-171239-1-1.html";
|
||||||
public static byte firstVer = 0, secondVer = 8, thirdVer = 6;
|
public static byte firstVer = 0, secondVer = 8, thirdVer = 6;
|
||||||
|
|
||||||
public static String makeTitle() {
|
public static String makeTitle() {
|
||||||
return launcherName + ' ' + firstVer + '.' + secondVer + '.' + thirdVer;
|
return launcherName + ' ' + firstVer + '.' + secondVer + '.' + thirdVer;
|
||||||
}
|
}
|
||||||
@@ -38,18 +50,14 @@ public class Main {
|
|||||||
try {
|
try {
|
||||||
javax.swing.UIManager.setLookAndFeel(new HelloMinecraftLookAndFeel());
|
javax.swing.UIManager.setLookAndFeel(new HelloMinecraftLookAndFeel());
|
||||||
UIManager.getLookAndFeelDefaults().put("defaultFont", new Font("微软雅黑", Font.PLAIN, 12));
|
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);
|
HMCLog.warn("Failed to set look and feel", ex);
|
||||||
}
|
}
|
||||||
new UpdateChecker(new VersionNumber(firstVer, secondVer, thirdVer), "hmcsm", SettingsManager.settings.checkUpdate, new NonConsumer() {
|
new UpdateChecker(new VersionNumber(firstVer, secondVer, thirdVer), "hmcsm", SettingsManager.settings.checkUpdate, () -> {
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDone() {
|
|
||||||
SettingsManager.settings.checkUpdate = false;
|
SettingsManager.settings.checkUpdate = false;
|
||||||
}
|
|
||||||
}).start();
|
}).start();
|
||||||
new MainWindow().setVisible(true);
|
new MainWindow().setVisible(true);
|
||||||
} catch(Throwable t) {
|
} catch (Throwable t) {
|
||||||
HMCLog.err("There's something wrong when running server holder.", t);
|
HMCLog.err("There's something wrong when running server holder.", t);
|
||||||
|
|
||||||
LogWindow.instance.clean();
|
LogWindow.instance.clean();
|
||||||
|
|||||||
@@ -1,6 +1,18 @@
|
|||||||
/*
|
/*
|
||||||
* To change this template, choose Tools | Templates
|
* Copyright 2013 huangyuhui <huanghongxun2008@126.com>
|
||||||
* and open the template in the editor.
|
*
|
||||||
|
* 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;
|
package org.jackhuang.hellominecraft.svrmgr.cbplugins;
|
||||||
|
|
||||||
@@ -16,7 +28,7 @@ public class BukkitPlugin {
|
|||||||
public List<PluginVersion> versions;
|
public List<PluginVersion> versions;
|
||||||
|
|
||||||
public String getLatestVersion() {
|
public String getLatestVersion() {
|
||||||
if(versions != null) {
|
if (versions != null) {
|
||||||
PluginVersion v = versions.get(0);
|
PluginVersion v = versions.get(0);
|
||||||
return v.version;
|
return v.version;
|
||||||
}
|
}
|
||||||
@@ -24,13 +36,12 @@ public class BukkitPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getLatestBukkit() {
|
public String getLatestBukkit() {
|
||||||
if(versions != null) {
|
if (versions != null) {
|
||||||
PluginVersion v = versions.get(0);
|
PluginVersion v = versions.get(0);
|
||||||
List<String> al = v.game_versions;
|
List<String> al = v.game_versions;
|
||||||
if(al != null && !al.isEmpty()) {
|
if (al != null && !al.isEmpty())
|
||||||
return al.get(0);
|
return al.get(0);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,18 @@
|
|||||||
/*
|
/*
|
||||||
* To change this template, choose Tools | Templates
|
* Copyright 2013 huangyuhui <huanghongxun2008@126.com>
|
||||||
* and open the template in the editor.
|
*
|
||||||
|
* 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;
|
package org.jackhuang.hellominecraft.svrmgr.cbplugins;
|
||||||
|
|
||||||
@@ -9,6 +21,7 @@ package org.jackhuang.hellominecraft.svrmgr.cbplugins;
|
|||||||
* @author huangyuhui
|
* @author huangyuhui
|
||||||
*/
|
*/
|
||||||
public class Category {
|
public class Category {
|
||||||
|
|
||||||
public double count;
|
public double count;
|
||||||
public String name;
|
public String name;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,18 @@
|
|||||||
/*
|
/*
|
||||||
* To change this template, choose Tools | Templates
|
* Copyright 2013 huangyuhui <huanghongxun2008@126.com>
|
||||||
* and open the template in the editor.
|
*
|
||||||
|
* 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;
|
package org.jackhuang.hellominecraft.svrmgr.cbplugins;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,18 @@
|
|||||||
/*
|
/*
|
||||||
* To change this template, choose Tools | Templates
|
* Copyright 2013 huangyuhui <huanghongxun2008@126.com>
|
||||||
* and open the template in the editor.
|
*
|
||||||
|
* 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;
|
package org.jackhuang.hellominecraft.svrmgr.cbplugins;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,18 @@
|
|||||||
/*
|
/*
|
||||||
* To change this template, choose Tools | Templates
|
* Copyright 2013 huangyuhui <huanghongxun2008@126.com>
|
||||||
* and open the template in the editor.
|
*
|
||||||
|
* 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;
|
package org.jackhuang.hellominecraft.svrmgr.cbplugins;
|
||||||
|
|
||||||
@@ -38,7 +50,8 @@ public class PluginManager {
|
|||||||
public static List<BukkitPlugin> getPlugins() throws Exception {
|
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");
|
String result = NetUtils.doGet("http://api.bukget.org/3//plugins?fields=slug,plugin_name,description,versions.version,versions.game_versions");
|
||||||
Gson gson = new Gson();
|
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;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,25 +75,28 @@ public class PluginManager {
|
|||||||
public static List<BukkitPlugin> getPluginsByCategory(String category) throws Exception {
|
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");
|
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();
|
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;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<Category> getCategories() throws Exception {
|
public static List<Category> getCategories() throws Exception {
|
||||||
String result = NetUtils.doGet("http://api.bukget.org/3//categories/");
|
String result = NetUtils.doGet("http://api.bukget.org/3//categories/");
|
||||||
Gson gson = new Gson();
|
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;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PluginInfo getPluginInfo(String slug) throws Exception {
|
public static PluginInfo getPluginInfo(String slug) throws Exception {
|
||||||
if(StrUtils.isNotBlank(slug)) {
|
if (StrUtils.isNotBlank(slug)) {
|
||||||
String result = NetUtils.doGet("http://api.bukget.org/3//plugins/bukkit/" + slug.toLowerCase());
|
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")) {
|
if (!result.equals("null")) {
|
||||||
PluginInfo info = new Gson().fromJson(result, PluginInfo.class);
|
PluginInfo info = new Gson().fromJson(result, PluginInfo.class);
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,18 @@
|
|||||||
/*
|
/*
|
||||||
* To change this template, choose Tools | Templates
|
* Copyright 2013 huangyuhui <huanghongxun2008@126.com>
|
||||||
* and open the template in the editor.
|
*
|
||||||
|
* 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;
|
package org.jackhuang.hellominecraft.svrmgr.cbplugins;
|
||||||
|
|
||||||
@@ -11,6 +23,7 @@ import java.util.List;
|
|||||||
* @author huangyuhui
|
* @author huangyuhui
|
||||||
*/
|
*/
|
||||||
public class PluginVersion {
|
public class PluginVersion {
|
||||||
|
|
||||||
public long date;
|
public long date;
|
||||||
public String download, link, version;
|
public String download, link, version;
|
||||||
public List<String> game_versions;
|
public List<String> game_versions;
|
||||||
|
|||||||
@@ -1,9 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
* Copyright 2013 huangyuhui <huanghongxun2008@126.com>
|
||||||
* To change this template file, choose Tools | Templates
|
*
|
||||||
* and open the template in the editor.
|
* 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;
|
package org.jackhuang.hellominecraft.svrmgr.installer.bukkit;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -39,24 +49,24 @@ public class BukkitFormatThread extends Thread {
|
|||||||
Document doc = Jsoup.connect(url).get();
|
Document doc = Jsoup.connect(url).get();
|
||||||
Elements versionsTable = doc.getElementsByClass("versionsTable");
|
Elements versionsTable = doc.getElementsByClass("versionsTable");
|
||||||
Elements allforge = new Elements();
|
Elements allforge = new Elements();
|
||||||
for(Element table : versionsTable)
|
for (Element table : versionsTable)
|
||||||
allforge.addAll(table.getElementsByTag("tr"));
|
allforge.addAll(table.getElementsByTag("tr"));
|
||||||
for(Element e : allforge) {
|
for (Element e : allforge) {
|
||||||
Elements tds = e.getElementsByTag("td");
|
Elements tds = e.getElementsByTag("td");
|
||||||
if(tds.isEmpty()) continue;
|
if (tds.isEmpty()) continue;
|
||||||
BukkitVersion v = new BukkitVersion();
|
BukkitVersion v = new BukkitVersion();
|
||||||
Elements ths = e.getElementsByTag("th");
|
Elements ths = e.getElementsByTag("th");
|
||||||
v.buildNumber = v.infoLink = null;
|
v.buildNumber = v.infoLink = null;
|
||||||
if(ths.size() > 0) {
|
if (ths.size() > 0) {
|
||||||
Elements a = ths.get(0).getElementsByTag("a");
|
Elements a = ths.get(0).getElementsByTag("a");
|
||||||
if(a.size() > 0) {
|
if (a.size() > 0) {
|
||||||
v.buildNumber = a.get(0).text();
|
v.buildNumber = a.get(0).text();
|
||||||
v.infoLink = a.get(0).attr("href");
|
v.infoLink = a.get(0).attr("href");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
v.version = tds.get(0).text();
|
v.version = tds.get(0).text();
|
||||||
v.type = tds.get(1).text();
|
v.type = tds.get(1).text();
|
||||||
if(tds.get(2).getElementsByTag("a").isEmpty()) continue;
|
if (tds.get(2).getElementsByTag("a").isEmpty()) continue;
|
||||||
v.downloadLink = "http://dl.bukkit.org" + tds.get(2).getElementsByTag("a").get(0).attr("href");
|
v.downloadLink = "http://dl.bukkit.org" + tds.get(2).getElementsByTag("a").get(0).attr("href");
|
||||||
formattedList.add(v);
|
formattedList.add(v);
|
||||||
}
|
}
|
||||||
@@ -73,7 +83,7 @@ public class BukkitFormatThread extends Thread {
|
|||||||
public void run() {
|
public void run() {
|
||||||
List<BukkitVersion> al = null;
|
List<BukkitVersion> al = null;
|
||||||
format(url);
|
format(url);
|
||||||
if(lis != null)
|
if (lis != null)
|
||||||
lis.accept(formattedList);
|
lis.accept(formattedList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
* Copyright 2013 huangyuhui <huanghongxun2008@126.com>
|
||||||
* To change this template file, choose Tools | Templates
|
*
|
||||||
* and open the template in the editor.
|
* 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;
|
package org.jackhuang.hellominecraft.svrmgr.installer.bukkit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,6 +1,18 @@
|
|||||||
/*
|
/*
|
||||||
* To change this template, choose Tools | Templates
|
* Copyright 2013 huangyuhui <huanghongxun2008@126.com>
|
||||||
* and open the template in the editor.
|
*
|
||||||
|
* 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;
|
package org.jackhuang.hellominecraft.svrmgr.installer.cauldron;
|
||||||
|
|
||||||
@@ -37,14 +49,14 @@ public class ForgeFormatThread extends Thread {
|
|||||||
Document doc = Jsoup.connect("http://files.minecraftforge.net/").get();
|
Document doc = Jsoup.connect("http://files.minecraftforge.net/").get();
|
||||||
Elements allbuilds = doc.getElementsByClass("builds");
|
Elements allbuilds = doc.getElementsByClass("builds");
|
||||||
Elements tables = new Elements();
|
Elements tables = new Elements();
|
||||||
for(Element build : allbuilds)
|
for (Element build : allbuilds)
|
||||||
tables.addAll(build.getElementsByTag("table"));
|
tables.addAll(build.getElementsByTag("table"));
|
||||||
Elements allforge = new Elements();
|
Elements allforge = new Elements();
|
||||||
for(Element table : tables)
|
for (Element table : tables)
|
||||||
allforge.addAll(table.getElementsByTag("tr"));
|
allforge.addAll(table.getElementsByTag("tr"));
|
||||||
for(Element e : allforge) {
|
for (Element e : allforge) {
|
||||||
Elements tds = e.getElementsByTag("td");
|
Elements tds = e.getElementsByTag("td");
|
||||||
if(tds.isEmpty()) continue;
|
if (tds.isEmpty()) continue;
|
||||||
ForgeVersion v = new ForgeVersion();
|
ForgeVersion v = new ForgeVersion();
|
||||||
v.ver = tds.get(0).text();
|
v.ver = tds.get(0).text();
|
||||||
v.mcver = tds.get(1).text();
|
v.mcver = tds.get(1).text();
|
||||||
@@ -56,25 +68,23 @@ public class ForgeFormatThread extends Thread {
|
|||||||
v.userdev = new String[2];
|
v.userdev = new String[2];
|
||||||
Elements a = tds.get(3).getElementsByTag("a");
|
Elements a = tds.get(3).getElementsByTag("a");
|
||||||
String prev = null;
|
String prev = null;
|
||||||
for(Element e2 : a) {
|
for (Element e2 : a) {
|
||||||
String href = e2.attributes().get("href").toLowerCase();
|
String href = e2.attributes().get("href").toLowerCase();
|
||||||
if(e2.text().toLowerCase().contains("changelog")) {
|
if (e2.text().toLowerCase().contains("changelog"))
|
||||||
v.changelog = href;
|
v.changelog = href;
|
||||||
} else if(prev != null) {
|
else if (prev != null) {
|
||||||
int index;
|
int index;
|
||||||
if(href.contains("adf.ly")) index = 0;
|
if (href.contains("adf.ly")) index = 0;
|
||||||
else index = 1;
|
else index = 1;
|
||||||
if(prev.toLowerCase().contains("installer")) {
|
if (prev.toLowerCase().contains("installer"))
|
||||||
v.installer[index] = href;
|
v.installer[index] = href;
|
||||||
} else
|
else if (prev.toLowerCase().contains("server"))
|
||||||
if(prev.toLowerCase().contains("server")) {
|
|
||||||
v.universal[index] = href;
|
v.universal[index] = href;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
prev = e2.text();
|
prev = e2.text();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!formattedList.containsKey(v.mcver))
|
if (!formattedList.containsKey(v.mcver))
|
||||||
formattedList.put(v.mcver, new ArrayList<>());
|
formattedList.put(v.mcver, new ArrayList<>());
|
||||||
formattedList.get(v.mcver).add(v);
|
formattedList.get(v.mcver).add(v);
|
||||||
}
|
}
|
||||||
@@ -90,7 +100,7 @@ public class ForgeFormatThread extends Thread {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
formatNew();
|
formatNew();
|
||||||
if(lis != null)
|
if (lis != null)
|
||||||
lis.accept(formattedList);
|
lis.accept(formattedList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,18 @@
|
|||||||
/*
|
/*
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
* Copyright 2013 huangyuhui <huanghongxun2008@126.com>
|
||||||
* To change this template file, choose Tools | Templates
|
*
|
||||||
* and open the template in the editor.
|
* 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;
|
package org.jackhuang.hellominecraft.svrmgr.installer.cauldron;
|
||||||
|
|
||||||
@@ -70,17 +81,16 @@ public class ForgeInstaller {
|
|||||||
FileOutputStream fos = new FileOutputStream(file);
|
FileOutputStream fos = new FileOutputStream(file);
|
||||||
BufferedOutputStream bos = new BufferedOutputStream(fos);
|
BufferedOutputStream bos = new BufferedOutputStream(fos);
|
||||||
int c;
|
int c;
|
||||||
while ((c = is.read()) != -1) {
|
while ((c = is.read()) != -1)
|
||||||
bos.write((byte) c);
|
bos.write((byte) c);
|
||||||
}
|
|
||||||
bos.close();
|
bos.close();
|
||||||
fos.close();
|
fos.close();
|
||||||
|
|
||||||
File minecraftserver = new File(gameDir, "minecraft_server." + profile.install.minecraft + ".jar");
|
File minecraftserver = new File(gameDir, "minecraft_server." + profile.install.minecraft + ".jar");
|
||||||
TaskWindow tw = TaskWindow.getInstance();
|
TaskWindow tw = TaskWindow.getInstance();
|
||||||
if(minecraftserver.exists() && JOptionPane.showConfirmDialog(null, "已发现官方服务端文件,是否要重新下载?") == JOptionPane.YES_OPTION) {
|
if (minecraftserver.exists() && JOptionPane.showConfirmDialog(null, "已发现官方服务端文件,是否要重新下载?") == JOptionPane.YES_OPTION) {
|
||||||
tw.clean();
|
tw.clean();
|
||||||
if(!tw.addTask(new FileDownloadTask("https://s3.amazonaws.com/Minecraft.Download/versions/{MCVER}/minecraft_server.{MCVER}.jar".replace("{MCVER}", profile.install.minecraft),
|
if (!tw.addTask(new FileDownloadTask("https://s3.amazonaws.com/Minecraft.Download/versions/{MCVER}/minecraft_server.{MCVER}.jar".replace("{MCVER}", profile.install.minecraft),
|
||||||
minecraftserver).setTag("minecraft_server")).start())
|
minecraftserver).setTag("minecraft_server")).start())
|
||||||
MessageBox.Show("Minecraft官方服务端下载失败!");
|
MessageBox.Show("Minecraft官方服务端下载失败!");
|
||||||
}
|
}
|
||||||
@@ -89,55 +99,50 @@ public class ForgeInstaller {
|
|||||||
library.init();
|
library.init();
|
||||||
File lib = new File(gameDir, "libraries" + File.separator + library.formatted + ".pack.xz");
|
File lib = new File(gameDir, "libraries" + File.separator + library.formatted + ".pack.xz");
|
||||||
String libURL = "https://libraries.minecraft.net/";
|
String libURL = "https://libraries.minecraft.net/";
|
||||||
if (StrUtils.isNotBlank(library.url)) {
|
if (StrUtils.isNotBlank(library.url))
|
||||||
libURL = library.url;
|
libURL = library.url;
|
||||||
}
|
|
||||||
tw.addTask(new FileDownloadTask(libURL + library.formatted.replace("\\", "/"), lib).setTag(library.name));
|
tw.addTask(new FileDownloadTask(libURL + library.formatted.replace("\\", "/"), lib).setTag(library.name));
|
||||||
}
|
}
|
||||||
tw.start();
|
tw.start();
|
||||||
if(!tw.areTasksFinished())
|
if (!tw.areTasksFinished())
|
||||||
MessageBox.Show("压缩库下载失败!");
|
MessageBox.Show("压缩库下载失败!");
|
||||||
tw.clean();
|
tw.clean();
|
||||||
for (MinecraftLibrary library : profile.versionInfo.libraries) {
|
for (MinecraftLibrary library : profile.versionInfo.libraries) {
|
||||||
File packxz = new File(gameDir, "libraries" + File.separator + library.formatted + ".pack.xz");
|
File packxz = new File(gameDir, "libraries" + File.separator + library.formatted + ".pack.xz");
|
||||||
if(packxz.exists()) return;
|
if (packxz.exists()) return;
|
||||||
File lib = new File(gameDir, "libraries" + File.separator + library.formatted);
|
File lib = new File(gameDir, "libraries" + File.separator + library.formatted);
|
||||||
lib.getParentFile().mkdirs();
|
lib.getParentFile().mkdirs();
|
||||||
String libURL = "https://libraries.minecraft.net/";
|
String libURL = "https://libraries.minecraft.net/";
|
||||||
if (StrUtils.isNotBlank(library.url)) {
|
if (StrUtils.isNotBlank(library.url))
|
||||||
libURL = library.url;
|
libURL = library.url;
|
||||||
}
|
|
||||||
tw.addTask(new FileDownloadTask(libURL + library.formatted.replace("\\", "/"), lib).setTag(library.name));
|
tw.addTask(new FileDownloadTask(libURL + library.formatted.replace("\\", "/"), lib).setTag(library.name));
|
||||||
}
|
}
|
||||||
tw.start();
|
tw.start();
|
||||||
if(!tw.areTasksFinished())
|
if (!tw.areTasksFinished())
|
||||||
MessageBox.Show("库下载失败!");
|
MessageBox.Show("库下载失败!");
|
||||||
tw.clean();
|
tw.clean();
|
||||||
ArrayList<String> badLibs = new ArrayList<String>();
|
ArrayList<String> badLibs = new ArrayList<String>();
|
||||||
for (MinecraftLibrary library : profile.versionInfo.libraries) {
|
for (MinecraftLibrary library : profile.versionInfo.libraries) {
|
||||||
File lib = new File(gameDir, "libraries" + File.separator + library.formatted);
|
File lib = new File(gameDir, "libraries" + File.separator + library.formatted);
|
||||||
File packFile = new File(gameDir, "libraries" + File.separator + library.formatted + ".pack.xz");
|
File packFile = new File(gameDir, "libraries" + File.separator + library.formatted + ".pack.xz");
|
||||||
if (packFile.exists() && packFile.isFile()) {
|
if (packFile.exists() && packFile.isFile())
|
||||||
try {
|
try {
|
||||||
unpackLibrary(lib.getParentFile(), NetUtils.getBytesFromStream(FileUtils.openInputStream(packFile)));
|
unpackLibrary(lib.getParentFile(), NetUtils.getBytesFromStream(FileUtils.openInputStream(packFile)));
|
||||||
if(!checksumValid(lib, Arrays.asList(library.checksums)))
|
if (!checksumValid(lib, Arrays.asList(library.checksums)))
|
||||||
badLibs.add(library.name);
|
badLibs.add(library.name);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
HMCLog.warn("Failed to unpack library: " + library.name);
|
HMCLog.warn("Failed to unpack library: " + library.name);
|
||||||
badLibs.add(library.name);
|
badLibs.add(library.name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
if (badLibs.size() > 0)
|
||||||
if (badLibs.size() > 0) {
|
|
||||||
MessageBox.Show("这些库在解压的时候出现了问题" + badLibs.toString());
|
MessageBox.Show("这些库在解压的时候出现了问题" + badLibs.toString());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static void unpackLibrary(File output, byte[] data)
|
public static void unpackLibrary(File output, byte[] data)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
if (output.exists()) {
|
if (output.exists())
|
||||||
output.delete();
|
output.delete();
|
||||||
}
|
|
||||||
|
|
||||||
byte[] decompressed = IOUtils.readFully(new XZInputStream(new ByteArrayInputStream(data)));
|
byte[] decompressed = IOUtils.readFully(new XZInputStream(new ByteArrayInputStream(data)));
|
||||||
|
|
||||||
@@ -169,9 +174,8 @@ public class ForgeInstaller {
|
|||||||
try {
|
try {
|
||||||
byte[] fileData = NetUtils.getBytesFromStream(FileUtils.openInputStream(libPath));
|
byte[] fileData = NetUtils.getBytesFromStream(FileUtils.openInputStream(libPath));
|
||||||
boolean valid = (checksums == null) || (checksums.isEmpty()) || (checksums.contains(DigestUtils.sha1Hex(fileData)));
|
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);
|
valid = validateJar(libPath, fileData, checksums);
|
||||||
}
|
|
||||||
return valid;
|
return valid;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
HMCLog.warn("Failed to checksum valid: " + libPath, e);
|
HMCLog.warn("Failed to checksum valid: " + libPath, e);
|
||||||
@@ -189,24 +193,22 @@ public class ForgeInstaller {
|
|||||||
while (entry != null) {
|
while (entry != null) {
|
||||||
byte[] eData = IOUtils.readFully(jar);
|
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");
|
hashes = new String(eData, Charset.forName("UTF-8")).split("\n");
|
||||||
}
|
|
||||||
|
|
||||||
if (!entry.isDirectory()) {
|
if (!entry.isDirectory())
|
||||||
files.put(entry.getName(), DigestUtils.sha1Hex(eData));
|
files.put(entry.getName(), DigestUtils.sha1Hex(eData));
|
||||||
}
|
|
||||||
entry = jar.getNextJarEntry();
|
entry = jar.getNextJarEntry();
|
||||||
}
|
}
|
||||||
jar.close();
|
jar.close();
|
||||||
|
|
||||||
if (hashes != null) {
|
if (hashes != null) {
|
||||||
boolean failed = !checksums.contains(files.get("checksums.sha1"));
|
boolean failed = !checksums.contains(files.get("checksums.sha1"));
|
||||||
if (failed) {
|
if (failed)
|
||||||
System.out.println(" checksums.sha1 failed validation");
|
System.out.println(" checksums.sha1 failed validation");
|
||||||
} else {
|
else {
|
||||||
System.out.println(" checksums.sha1 validated successfully");
|
System.out.println(" checksums.sha1 validated successfully");
|
||||||
for (String hash : hashes) {
|
for (String hash : hashes)
|
||||||
if ((!hash.trim().equals("")) && (hash.contains(" "))) {
|
if ((!hash.trim().equals("")) && (hash.contains(" "))) {
|
||||||
String[] e = hash.split(" ");
|
String[] e = hash.split(" ");
|
||||||
String validChecksum = e[0];
|
String validChecksum = e[0];
|
||||||
@@ -217,18 +219,15 @@ public class ForgeInstaller {
|
|||||||
System.out.println(" " + target + " : missing");
|
System.out.println(" " + target + " : missing");
|
||||||
failed = true;
|
failed = true;
|
||||||
} else {
|
} else {
|
||||||
if (checksum.equals(validChecksum)) {
|
if (checksum.equals(validChecksum))
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
System.out.println(" " + target + " : failed (" + checksum + ", " + validChecksum + ")");
|
System.out.println(" " + target + " : failed (" + checksum + ", " + validChecksum + ")");
|
||||||
failed = true;
|
failed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
if (!failed)
|
||||||
if (!failed) {
|
|
||||||
System.out.println(" Jar contents validated successfully");
|
System.out.println(" Jar contents validated successfully");
|
||||||
}
|
|
||||||
|
|
||||||
return !failed;
|
return !failed;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,18 @@
|
|||||||
/*
|
/*
|
||||||
* To change this template, choose Tools | Templates
|
* Copyright 2013 huangyuhui <huanghongxun2008@126.com>
|
||||||
* and open the template in the editor.
|
*
|
||||||
|
* 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;
|
package org.jackhuang.hellominecraft.svrmgr.installer.cauldron;
|
||||||
|
|
||||||
@@ -9,6 +21,7 @@ package org.jackhuang.hellominecraft.svrmgr.installer.cauldron;
|
|||||||
* @author huangyuhui
|
* @author huangyuhui
|
||||||
*/
|
*/
|
||||||
public class ForgeVersion {
|
public class ForgeVersion {
|
||||||
|
|
||||||
public String vername, ver, mcver, releasetime, changelog;
|
public String vername, ver, mcver, releasetime, changelog;
|
||||||
public String[] installer, javadoc, src, universal, userdev;
|
public String[] installer, javadoc, src, universal, userdev;
|
||||||
public int typeint;
|
public int typeint;
|
||||||
|
|||||||
@@ -1,9 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
* Copyright 2013 huangyuhui <huanghongxun2008@126.com>
|
||||||
* To change this template file, choose Tools | Templates
|
*
|
||||||
* and open the template in the editor.
|
* 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;
|
package org.jackhuang.hellominecraft.svrmgr.installer.cauldron;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -11,5 +21,6 @@ package org.jackhuang.hellominecraft.svrmgr.installer.cauldron;
|
|||||||
* @author huangyuhui
|
* @author huangyuhui
|
||||||
*/
|
*/
|
||||||
public class Install {
|
public class Install {
|
||||||
|
|
||||||
public String profileName, target, path, version, filePath, welcome, minecraft, mirrorList, logo;
|
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.
|
* Copyright 2013 huangyuhui <huanghongxun2008@126.com>
|
||||||
* To change this template file, choose Tools | Templates
|
*
|
||||||
* and open the template in the editor.
|
* 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;
|
package org.jackhuang.hellominecraft.svrmgr.installer.cauldron;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -11,6 +21,7 @@ package org.jackhuang.hellominecraft.svrmgr.installer.cauldron;
|
|||||||
* @author huangyuhui
|
* @author huangyuhui
|
||||||
*/
|
*/
|
||||||
public class InstallProfile {
|
public class InstallProfile {
|
||||||
|
|
||||||
public Install install;
|
public Install install;
|
||||||
public MinecraftVersion versionInfo;
|
public MinecraftVersion versionInfo;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,18 @@
|
|||||||
/*
|
/*
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
* Copyright 2013 huangyuhui <huanghongxun2008@126.com>
|
||||||
* To change this template file, choose Tools | Templates
|
*
|
||||||
* and open the template in the editor.
|
* 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;
|
package org.jackhuang.hellominecraft.svrmgr.installer.cauldron;
|
||||||
|
|
||||||
@@ -13,7 +24,7 @@ import java.io.File;
|
|||||||
*/
|
*/
|
||||||
public class MinecraftLibrary {
|
public class MinecraftLibrary {
|
||||||
|
|
||||||
public String url, formatted=null, name;
|
public String url, formatted = null, name;
|
||||||
//public boolean serverreq=true, clientreq=true;
|
//public boolean serverreq=true, clientreq=true;
|
||||||
public String[] checksums;
|
public String[] checksums;
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,18 @@
|
|||||||
/*
|
/*
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
* Copyright 2013 huangyuhui <huanghongxun2008@126.com>
|
||||||
* To change this template file, choose Tools | Templates
|
*
|
||||||
* and open the template in the editor.
|
* 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;
|
package org.jackhuang.hellominecraft.svrmgr.installer.cauldron;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,18 @@
|
|||||||
/*
|
/*
|
||||||
* To change this template, choose Tools | Templates
|
* Copyright 2013 huangyuhui <huanghongxun2008@126.com>
|
||||||
* and open the template in the editor.
|
*
|
||||||
|
* 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;
|
package org.jackhuang.hellominecraft.svrmgr.server;
|
||||||
|
|
||||||
@@ -15,7 +27,7 @@ import org.jackhuang.hellominecraft.svrmgr.settings.Schedule;
|
|||||||
public class ScheduleTranslator {
|
public class ScheduleTranslator {
|
||||||
|
|
||||||
public static TimerTask translate(Server ser, Schedule s) {
|
public static TimerTask translate(Server ser, Schedule s) {
|
||||||
switch(s.type) {
|
switch (s.type) {
|
||||||
case Schedule.TYPE_AUTO_SAVE:
|
case Schedule.TYPE_AUTO_SAVE:
|
||||||
return new AutoSaveSchedule(s, ser);
|
return new AutoSaveSchedule(s, ser);
|
||||||
case Schedule.TYPE_AUTO_RESTART:
|
case Schedule.TYPE_AUTO_RESTART:
|
||||||
@@ -31,7 +43,7 @@ public class ScheduleTranslator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String getName(Schedule s) {
|
public static String getName(Schedule s) {
|
||||||
switch(s.type) {
|
switch (s.type) {
|
||||||
case Schedule.TYPE_AUTO_SAVE:
|
case Schedule.TYPE_AUTO_SAVE:
|
||||||
return "自动保存";
|
return "自动保存";
|
||||||
case Schedule.TYPE_AUTO_RESTART:
|
case Schedule.TYPE_AUTO_RESTART:
|
||||||
@@ -47,7 +59,7 @@ public class ScheduleTranslator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String getTimeTypeName(Schedule s) {
|
public static String getTimeTypeName(Schedule s) {
|
||||||
switch(s.timeType) {
|
switch (s.timeType) {
|
||||||
case Schedule.TIME_TYPE_PER:
|
case Schedule.TIME_TYPE_PER:
|
||||||
return "每x分钟";
|
return "每x分钟";
|
||||||
case Schedule.TIME_TYPE_PAST_HOUR:
|
case Schedule.TIME_TYPE_PAST_HOUR:
|
||||||
@@ -63,7 +75,7 @@ public class ScheduleTranslator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Object[] getRow(Schedule s) {
|
public static Object[] getRow(Schedule s) {
|
||||||
return new Object[] {
|
return new Object[]{
|
||||||
getName(s), getTimeTypeName(s), s.per, s.content
|
getName(s), getTimeTypeName(s), s.per, s.content
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,18 @@
|
|||||||
/*
|
/*
|
||||||
* To change this template, choose Tools | Templates
|
* Copyright 2013 huangyuhui <huanghongxun2008@126.com>
|
||||||
* and open the template in the editor.
|
*
|
||||||
|
* 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;
|
package org.jackhuang.hellominecraft.svrmgr.server;
|
||||||
|
|
||||||
@@ -96,11 +108,10 @@ public class Server implements Event<Integer>, MonitorThread.MonitorThreadListen
|
|||||||
|
|
||||||
public void run() throws IOException {
|
public void run() throws IOException {
|
||||||
String jvmPath;
|
String jvmPath;
|
||||||
if (StrUtils.isBlank(SettingsManager.settings.javaDir)) {
|
if (StrUtils.isBlank(SettingsManager.settings.javaDir))
|
||||||
jvmPath = IOUtils.getJavaDir();
|
jvmPath = IOUtils.getJavaDir();
|
||||||
} else {
|
else
|
||||||
jvmPath = SettingsManager.settings.javaDir;
|
jvmPath = SettingsManager.settings.javaDir;
|
||||||
}
|
|
||||||
String[] puts = new String[]{
|
String[] puts = new String[]{
|
||||||
jvmPath,
|
jvmPath,
|
||||||
"-Xmx" + memory + "m",
|
"-Xmx" + memory + "m",
|
||||||
@@ -134,7 +145,7 @@ public class Server implements Event<Integer>, MonitorThread.MonitorThreadListen
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void sendCommand(String cmd) {
|
public void sendCommand(String cmd) {
|
||||||
if (isRunning) {
|
if (isRunning)
|
||||||
try {
|
try {
|
||||||
sendStatus("发送指令: " + cmd);
|
sendStatus("发送指令: " + cmd);
|
||||||
bw.write(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);
|
Logger.getLogger(Server.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void getPlayerNumber(Consumer<Pair<String, String[]>> d) {
|
public void getPlayerNumber(Consumer<Pair<String, String[]>> d) {
|
||||||
isGettingPlayerNumber = 1;
|
isGettingPlayerNumber = 1;
|
||||||
@@ -158,16 +168,14 @@ public class Server implements Event<Integer>, MonitorThread.MonitorThreadListen
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void stop() {
|
public void stop() {
|
||||||
if (timer != null) {
|
if (timer != null)
|
||||||
timer.cancel();
|
timer.cancel();
|
||||||
}
|
|
||||||
sendCommand("stop");
|
sendCommand("stop");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void shutdown() {
|
public void shutdown() {
|
||||||
if (timer != null) {
|
if (timer != null)
|
||||||
timer.cancel();
|
timer.cancel();
|
||||||
}
|
|
||||||
server.destroy();
|
server.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -181,9 +189,8 @@ public class Server implements Event<Integer>, MonitorThread.MonitorThreadListen
|
|||||||
|
|
||||||
public void delSchedule(Schedule s) {
|
public void delSchedule(Schedule s) {
|
||||||
int index = schedules.indexOf(s);
|
int index = schedules.indexOf(s);
|
||||||
if (index == -1) {
|
if (index == -1)
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
schedules.remove(index);
|
schedules.remove(index);
|
||||||
timerTasks.get(index).cancel();
|
timerTasks.get(index).cancel();
|
||||||
timerTasks.remove(index);
|
timerTasks.remove(index);
|
||||||
@@ -191,9 +198,8 @@ public class Server implements Event<Integer>, MonitorThread.MonitorThreadListen
|
|||||||
|
|
||||||
private void registerThread(MonitorThread thread, InputStream is) {
|
private void registerThread(MonitorThread thread, InputStream is) {
|
||||||
thread = new MonitorThread(is);
|
thread = new MonitorThread(is);
|
||||||
for (MonitorThread.MonitorThreadListener l : listeners) {
|
for (MonitorThread.MonitorThreadListener l : listeners)
|
||||||
thread.addListener(l);
|
thread.addListener(l);
|
||||||
}
|
|
||||||
thread.addListener(this);
|
thread.addListener(this);
|
||||||
thread.start();
|
thread.start();
|
||||||
}
|
}
|
||||||
@@ -243,9 +249,8 @@ public class Server implements Event<Integer>, MonitorThread.MonitorThreadListen
|
|||||||
restoreModsByType(paramString);
|
restoreModsByType(paramString);
|
||||||
|
|
||||||
System.out.println("禁用不活动的文件: " + paramString);
|
System.out.println("禁用不活动的文件: " + paramString);
|
||||||
if ((paramArrayOfString == null) || (paramArrayOfString.size() <= 0)) {
|
if ((paramArrayOfString == null) || (paramArrayOfString.size() <= 0))
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
File[] files = new File(Utilities.getGameDir(), paramString).listFiles();
|
File[] files = new File(Utilities.getGameDir(), paramString).listFiles();
|
||||||
if (files == null) {
|
if (files == null) {
|
||||||
System.out.println("没有文件: " + paramString);
|
System.out.println("没有文件: " + paramString);
|
||||||
@@ -255,23 +260,20 @@ public class Server implements Event<Integer>, MonitorThread.MonitorThreadListen
|
|||||||
String name = file.getName();
|
String name = file.getName();
|
||||||
|
|
||||||
if ((!paramArrayOfString.contains(name))
|
if ((!paramArrayOfString.contains(name))
|
||||||
|| ((!name.toLowerCase().endsWith(".zip")) && (!name.toLowerCase().endsWith(".jar")))) {
|
|| ((!name.toLowerCase().endsWith(".zip")) && (!name.toLowerCase().endsWith(".jar"))))
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
|
|
||||||
String newName = name + "X";
|
String newName = name + "X";
|
||||||
File newFile = new File(file.getParentFile(), newName);
|
File newFile = new File(file.getParentFile(), newName);
|
||||||
|
|
||||||
if (newFile.exists()) {
|
if (newFile.exists())
|
||||||
newFile.delete();
|
newFile.delete();
|
||||||
}
|
if (file.renameTo(newFile))
|
||||||
if (file.renameTo(newFile)) {
|
|
||||||
System.out.println("已禁用: " + name + ", 新名称: " + newFile.getName());
|
System.out.println("已禁用: " + name + ", 新名称: " + newFile.getName());
|
||||||
} else {
|
else
|
||||||
System.out.println("无法禁用: " + name);
|
System.out.println("无法禁用: " + name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private static void restoreModsByType(String paramString) {
|
private static void restoreModsByType(String paramString) {
|
||||||
System.out.println("还原被禁用的文件: " + paramString);
|
System.out.println("还原被禁用的文件: " + paramString);
|
||||||
@@ -280,21 +282,18 @@ public class Server implements Event<Integer>, MonitorThread.MonitorThreadListen
|
|||||||
for (File file : files) if (!file.isDirectory()) {
|
for (File file : files) if (!file.isDirectory()) {
|
||||||
String name = file.getName();
|
String name = file.getName();
|
||||||
String lowName = name.toLowerCase();
|
String lowName = name.toLowerCase();
|
||||||
if ((!lowName.endsWith(".zipx")) && (!lowName.endsWith(".jarx"))) {
|
if ((!lowName.endsWith(".zipx")) && (!lowName.endsWith(".jarx")))
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
String newName = name.substring(0, name.length() - 1);
|
String newName = name.substring(0, name.length() - 1);
|
||||||
|
|
||||||
File newFile = new File(file.getParentFile(), newName);
|
File newFile = new File(file.getParentFile(), newName);
|
||||||
if (newFile.exists()) {
|
if (newFile.exists())
|
||||||
file.delete();
|
file.delete();
|
||||||
} else {
|
else
|
||||||
if (!file.renameTo(newFile)) {
|
if (!file.renameTo(newFile))
|
||||||
System.out.println("无法重命名: " + file.getName() + " 到: " + newFile.getName() + " 在: " + file.getParent());
|
System.out.println("无法重命名: " + file.getName() + " 到: " + newFile.getName() + " 在: " + file.getParent());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void restoreMods() {
|
static void restoreMods() {
|
||||||
if (disactived) {
|
if (disactived) {
|
||||||
@@ -311,9 +310,8 @@ public class Server implements Event<Integer>, MonitorThread.MonitorThreadListen
|
|||||||
if (isGettingPlayerNumber == 1) {
|
if (isGettingPlayerNumber == 1) {
|
||||||
Pattern p = Pattern.compile("There are [0-9]*/[0-9]* players online");
|
Pattern p = Pattern.compile("There are [0-9]*/[0-9]* players online");
|
||||||
Matcher m = p.matcher(status);
|
Matcher m = p.matcher(status);
|
||||||
if (!m.find()) {
|
if (!m.find())
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
String s = m.group(0);
|
String s = m.group(0);
|
||||||
s = s.substring(10, s.length() - 15);
|
s = s.substring(10, s.length() - 15);
|
||||||
playerNumber = s;
|
playerNumber = s;
|
||||||
@@ -321,17 +319,16 @@ public class Server implements Event<Integer>, MonitorThread.MonitorThreadListen
|
|||||||
return;
|
return;
|
||||||
} else if (isGettingPlayerNumber == 2) {
|
} else if (isGettingPlayerNumber == 2) {
|
||||||
try {
|
try {
|
||||||
status = status.substring(status.lastIndexOf("]")+1);
|
status = status.substring(status.lastIndexOf("]") + 1);
|
||||||
status = status.substring(status.indexOf(":")+1);
|
status = status.substring(status.indexOf(":") + 1);
|
||||||
} catch(Exception e) {
|
} catch (Exception e) {
|
||||||
HMCLog.warn("Failed to substring status.", e);
|
HMCLog.warn("Failed to substring status.", e);
|
||||||
}
|
}
|
||||||
String[] s;
|
String[] s;
|
||||||
if(StrUtils.isNotBlank(status)) {
|
if (StrUtils.isNotBlank(status))
|
||||||
s = status.trim().split(", ");
|
s = status.trim().split(", ");
|
||||||
} else {
|
else
|
||||||
s = new String[0];
|
s = new String[0];
|
||||||
}
|
|
||||||
Pair<String, String[]> p = new Pair<>(playerNumber, s);
|
Pair<String, String[]> p = new Pair<>(playerNumber, s);
|
||||||
isGettingPlayerNumber = 0;
|
isGettingPlayerNumber = 0;
|
||||||
gettingPlayerNumber.accept(p);
|
gettingPlayerNumber.accept(p);
|
||||||
@@ -361,12 +358,10 @@ public class Server implements Event<Integer>, MonitorThread.MonitorThreadListen
|
|||||||
isDone = true;
|
isDone = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (status.length() > 20) {
|
if (status.length() > 20)
|
||||||
if (status.substring(20).contains("[SEVERE] This crash report has been saved to: ")) {
|
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();
|
for (Schedule schedule : schedules) if (schedule.timeType == Schedule.TIME_TYPE_SERVER_CRASHED) ScheduleTranslator.translate(this, schedule).run();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
GregorianCalendar c = new GregorianCalendar();
|
GregorianCalendar c = new GregorianCalendar();
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,18 @@
|
|||||||
/*
|
/*
|
||||||
* To change this template, choose Tools | Templates
|
* Copyright 2013 huangyuhui <huanghongxun2008@126.com>
|
||||||
* and open the template in the editor.
|
*
|
||||||
|
* 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;
|
package org.jackhuang.hellominecraft.svrmgr.server;
|
||||||
|
|
||||||
@@ -23,12 +35,10 @@ public class ServerChecker {
|
|||||||
HMCLog.warn("", ex);
|
HMCLog.warn("", ex);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(file.getEntry("org/bukkit/craftbukkit/Main.class") != null) {
|
if (file.getEntry("org/bukkit/craftbukkit/Main.class") != null)
|
||||||
return true;
|
return true;
|
||||||
}
|
if (file.getEntry("net/minecraft/server/MinecraftServer.class") != null)
|
||||||
if(file.getEntry("net/minecraft/server/MinecraftServer.class") != null) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,18 @@
|
|||||||
/*
|
/*
|
||||||
* To change this template, choose Tools | Templates
|
* Copyright 2013 huangyuhui <huanghongxun2008@126.com>
|
||||||
* and open the template in the editor.
|
*
|
||||||
|
* 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;
|
package org.jackhuang.hellominecraft.svrmgr.server.backups;
|
||||||
|
|
||||||
@@ -50,13 +62,12 @@ public class BackupManager {
|
|||||||
String gameDir = Utilities.getGameDir();
|
String gameDir = Utilities.getGameDir();
|
||||||
ArrayList<String> folders = Utilities.findAllDir(new File(gameDir));
|
ArrayList<String> folders = Utilities.findAllDir(new File(gameDir));
|
||||||
ArrayList<String> result = new ArrayList<String>();
|
ArrayList<String> result = new ArrayList<String>();
|
||||||
for(String folder : folders) {
|
for (String folder : folders) {
|
||||||
String worldPath = gameDir + folder + File.separator;
|
String worldPath = gameDir + folder + File.separator;
|
||||||
ArrayList<String> files = Utilities.findAllFile(new File(worldPath));
|
ArrayList<String> files = Utilities.findAllFile(new File(worldPath));
|
||||||
if(files.contains("level.dat")) {
|
if (files.contains("level.dat"))
|
||||||
result.add(folder);
|
result.add(folder);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,11 +88,10 @@ public class BackupManager {
|
|||||||
|
|
||||||
public static void backupAllWorlds() {
|
public static void backupAllWorlds() {
|
||||||
ArrayList<String> al = findAllWorlds();
|
ArrayList<String> al = findAllWorlds();
|
||||||
for(String world : al) {
|
for (String world : al)
|
||||||
if(!SettingsManager.settings.inactiveWorlds.contains(world))
|
if (!SettingsManager.settings.inactiveWorlds.contains(world))
|
||||||
addWorldBackup(world);
|
addWorldBackup(world);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static void backupAllPlugins() {
|
public static void backupAllPlugins() {
|
||||||
new File(backupDir()).mkdirs();
|
new File(backupDir()).mkdirs();
|
||||||
|
|||||||
@@ -1,6 +1,18 @@
|
|||||||
/*
|
/*
|
||||||
* To change this template, choose Tools | Templates
|
* Copyright 2013 huangyuhui <huanghongxun2008@126.com>
|
||||||
* and open the template in the editor.
|
*
|
||||||
|
* 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;
|
package org.jackhuang.hellominecraft.svrmgr.server.download;
|
||||||
|
|
||||||
@@ -9,5 +21,6 @@ package org.jackhuang.hellominecraft.svrmgr.server.download;
|
|||||||
* @author huangyuhui
|
* @author huangyuhui
|
||||||
*/
|
*/
|
||||||
public class ServerDownloadPackage {
|
public class ServerDownloadPackage {
|
||||||
|
|
||||||
public String mcversion, version, forgeversion, majorversion, file;
|
public String mcversion, version, forgeversion, majorversion, file;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,18 @@
|
|||||||
/*
|
/*
|
||||||
* To change this template, choose Tools | Templates
|
* Copyright 2013 huangyuhui <huanghongxun2008@126.com>
|
||||||
* and open the template in the editor.
|
*
|
||||||
|
* 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;
|
package org.jackhuang.hellominecraft.svrmgr.server.schedules;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,18 @@
|
|||||||
/*
|
/*
|
||||||
* To change this template, choose Tools | Templates
|
* Copyright 2013 huangyuhui <huanghongxun2008@126.com>
|
||||||
* and open the template in the editor.
|
*
|
||||||
|
* 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;
|
package org.jackhuang.hellominecraft.svrmgr.server.schedules;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,18 @@
|
|||||||
/*
|
/*
|
||||||
* To change this template, choose Tools | Templates
|
* Copyright 2013 huangyuhui <huanghongxun2008@126.com>
|
||||||
* and open the template in the editor.
|
*
|
||||||
|
* 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;
|
package org.jackhuang.hellominecraft.svrmgr.server.schedules;
|
||||||
|
|
||||||
@@ -15,6 +27,7 @@ import org.jackhuang.hellominecraft.svrmgr.settings.Schedule;
|
|||||||
* @author huangyuhui
|
* @author huangyuhui
|
||||||
*/
|
*/
|
||||||
public class AutoExecuteSchedule extends TimerTask {
|
public class AutoExecuteSchedule extends TimerTask {
|
||||||
|
|
||||||
Schedule main;
|
Schedule main;
|
||||||
Server server;
|
Server server;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,18 @@
|
|||||||
/*
|
/*
|
||||||
* To change this template, choose Tools | Templates
|
* Copyright 2013 huangyuhui <huanghongxun2008@126.com>
|
||||||
* and open the template in the editor.
|
*
|
||||||
|
* 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;
|
package org.jackhuang.hellominecraft.svrmgr.server.schedules;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,18 @@
|
|||||||
/*
|
/*
|
||||||
* To change this template, choose Tools | Templates
|
* Copyright 2013 huangyuhui <huanghongxun2008@126.com>
|
||||||
* and open the template in the editor.
|
*
|
||||||
|
* 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;
|
package org.jackhuang.hellominecraft.svrmgr.server.schedules;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,18 @@
|
|||||||
/*
|
/*
|
||||||
* To change this template, choose Tools | Templates
|
* Copyright 2013 huangyuhui <huanghongxun2008@126.com>
|
||||||
* and open the template in the editor.
|
*
|
||||||
|
* 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;
|
package org.jackhuang.hellominecraft.svrmgr.server.schedules;
|
||||||
|
|
||||||
@@ -13,6 +25,7 @@ import org.jackhuang.hellominecraft.svrmgr.settings.Schedule;
|
|||||||
* @author huangyuhui
|
* @author huangyuhui
|
||||||
*/
|
*/
|
||||||
public abstract class AutoSchedule extends TimerTask {
|
public abstract class AutoSchedule extends TimerTask {
|
||||||
|
|
||||||
Schedule main;
|
Schedule main;
|
||||||
Server server;
|
Server server;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,18 @@
|
|||||||
/*
|
/*
|
||||||
* To change this template, choose Tools | Templates
|
* Copyright 2013 huangyuhui <huanghongxun2008@126.com>
|
||||||
* and open the template in the editor.
|
*
|
||||||
|
* 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;
|
package org.jackhuang.hellominecraft.svrmgr.server.schedules;
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
* Copyright 2013 huangyuhui <huanghongxun2008@126.com>
|
||||||
* To change this template file, choose Tools | Templates
|
*
|
||||||
* and open the template in the editor.
|
* 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;
|
package org.jackhuang.hellominecraft.svrmgr.settings;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
|||||||
@@ -1,7 +1,18 @@
|
|||||||
/*
|
/*
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
* Copyright 2013 huangyuhui <huanghongxun2008@126.com>
|
||||||
* To change this template file, choose Tools | Templates
|
*
|
||||||
* and open the template in the editor.
|
* 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;
|
package org.jackhuang.hellominecraft.svrmgr.settings;
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,18 @@
|
|||||||
/*
|
/*
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
* Copyright 2013 huangyuhui <huanghongxun2008@126.com>
|
||||||
* To change this template file, choose Tools | Templates
|
*
|
||||||
* and open the template in the editor.
|
* 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;
|
package org.jackhuang.hellominecraft.svrmgr.settings;
|
||||||
|
|
||||||
@@ -60,11 +71,10 @@ public abstract class PlayerList<T extends BasePlayer> {
|
|||||||
String[] lines = s.split("\n");
|
String[] lines = s.split("\n");
|
||||||
op = new HashSet<T>();
|
op = new HashSet<T>();
|
||||||
for (String l : lines) {
|
for (String l : lines) {
|
||||||
if(l.startsWith("#")) continue;
|
if (l.startsWith("#")) continue;
|
||||||
T player = newPlayer(l);
|
T player = newPlayer(l);
|
||||||
if (StrUtils.isBlank(l)) {
|
if (StrUtils.isBlank(l))
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
op.add(player);
|
op.add(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -86,15 +96,14 @@ public abstract class PlayerList<T extends BasePlayer> {
|
|||||||
}
|
}
|
||||||
}*/
|
}*/
|
||||||
op = null;
|
op = null;
|
||||||
if(txt.exists()) {
|
if (txt.exists())
|
||||||
try {
|
try {
|
||||||
initByText(FileUtils.readFileToStringIgnoreFileNotFound(txt));
|
initByText(FileUtils.readFileToStringIgnoreFileNotFound(txt));
|
||||||
if(op != null)
|
if (op != null)
|
||||||
player.addAll(op);
|
player.addAll(op);
|
||||||
} catch(IOException e) {
|
} catch (IOException e) {
|
||||||
HMCLog.warn("Failed to load playerlist by txt", e);
|
HMCLog.warn("Failed to load playerlist by txt", e);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
op = player;
|
op = player;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,18 @@
|
|||||||
/*
|
/*
|
||||||
* To change this template, choose Tools | Templates
|
* Copyright 2013 huangyuhui <huanghongxun2008@126.com>
|
||||||
* and open the template in the editor.
|
*
|
||||||
|
* 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;
|
package org.jackhuang.hellominecraft.svrmgr.settings;
|
||||||
|
|
||||||
@@ -9,19 +21,17 @@ package org.jackhuang.hellominecraft.svrmgr.settings;
|
|||||||
* @author huangyuhui
|
* @author huangyuhui
|
||||||
*/
|
*/
|
||||||
public class Schedule {
|
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_RESTART = 1,
|
||||||
TYPE_AUTO_BACKUP = 2,
|
TYPE_AUTO_BACKUP = 2,
|
||||||
TYPE_AUTO_BROADCAST = 3,
|
TYPE_AUTO_BROADCAST = 3,
|
||||||
TYPE_AUTO_SEND_COMMAND = 4,
|
TYPE_AUTO_SEND_COMMAND = 4,
|
||||||
TYPE_AUTO_EXECUTE = 5;
|
TYPE_AUTO_EXECUTE = 5;
|
||||||
public static final int
|
public static final int TYPE2_AUTO_BACKUP_PLUGINS = 1,
|
||||||
TYPE2_AUTO_BACKUP_PLUGINS = 1,
|
|
||||||
TYPE2_AUTH_BACKUP_CONFIG = 2,
|
TYPE2_AUTH_BACKUP_CONFIG = 2,
|
||||||
TYPE3_AUTH_BACKUP_WORLD = 3;
|
TYPE3_AUTH_BACKUP_WORLD = 3;
|
||||||
public static final int
|
public static final int TIME_TYPE_PER = 0,
|
||||||
TIME_TYPE_PER = 0,
|
|
||||||
TIME_TYPE_PAST_HOUR = 1,
|
TIME_TYPE_PAST_HOUR = 1,
|
||||||
TIME_TYPE_SERVER_STARTED = 2,
|
TIME_TYPE_SERVER_STARTED = 2,
|
||||||
TIME_TYPE_SERVER_STOPPED = 3,
|
TIME_TYPE_SERVER_STOPPED = 3,
|
||||||
|
|||||||
@@ -1,6 +1,18 @@
|
|||||||
/*
|
/*
|
||||||
* To change this template, choose Tools | Templates
|
* Copyright 2013 huangyuhui <huanghongxun2008@126.com>
|
||||||
* and open the template in the editor.
|
*
|
||||||
|
* 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;
|
package org.jackhuang.hellominecraft.svrmgr.settings;
|
||||||
|
|
||||||
@@ -53,7 +65,7 @@ public class ServerProperties {
|
|||||||
return "";
|
return "";
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
if(is != null)
|
if (is != null)
|
||||||
is.close();
|
is.close();
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
HMCLog.warn("Failed to close InputStream for server.properties", ex);
|
HMCLog.warn("Failed to close InputStream for server.properties", ex);
|
||||||
@@ -64,7 +76,7 @@ public class ServerProperties {
|
|||||||
public int getPropertyInt(String key, int defaultValue) {
|
public int getPropertyInt(String key, int defaultValue) {
|
||||||
try {
|
try {
|
||||||
return Integer.parseInt(getProperty(key, String.valueOf(defaultValue)));
|
return Integer.parseInt(getProperty(key, String.valueOf(defaultValue)));
|
||||||
} catch(NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -86,7 +98,7 @@ public class ServerProperties {
|
|||||||
HMCLog.warn("Failed to set property in server.properties", ex);
|
HMCLog.warn("Failed to set property in server.properties", ex);
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
if(is != null)
|
if (is != null)
|
||||||
is.close();
|
is.close();
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
HMCLog.warn("Failed to close OutputStream for server.properties", ex);
|
HMCLog.warn("Failed to close OutputStream for server.properties", ex);
|
||||||
@@ -215,39 +227,39 @@ public class ServerProperties {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String getDefault() {
|
public static String getDefault() {
|
||||||
return "generator-settings=\n" +
|
return "generator-settings=\n"
|
||||||
"op-permission-level=4\n" +
|
+ "op-permission-level=4\n"
|
||||||
"allow-nether=true\n" +
|
+ "allow-nether=true\n"
|
||||||
"level-name=world\n" +
|
+ "level-name=world\n"
|
||||||
"enable-query=false\n" +
|
+ "enable-query=false\n"
|
||||||
"allow-flight=false\n" +
|
+ "allow-flight=false\n"
|
||||||
"announce-player-achievements=true\n" +
|
+ "announce-player-achievements=true\n"
|
||||||
"server-port=25565\n" +
|
+ "server-port=25565\n"
|
||||||
"level-type=DEFAULT\n" +
|
+ "level-type=DEFAULT\n"
|
||||||
"enable-rcon=false\n" +
|
+ "enable-rcon=false\n"
|
||||||
"force-gamemode=false\n" +
|
+ "force-gamemode=false\n"
|
||||||
"level-seed=\n" +
|
+ "level-seed=\n"
|
||||||
"server-ip=\n" +
|
+ "server-ip=\n"
|
||||||
"max-build-height=256\n" +
|
+ "max-build-height=256\n"
|
||||||
"spawn-npcs=true\n" +
|
+ "spawn-npcs=true\n"
|
||||||
"white-list=false\n" +
|
+ "white-list=false\n"
|
||||||
"spawn-animals=true\n" +
|
+ "spawn-animals=true\n"
|
||||||
"hardcore=false\n" +
|
+ "hardcore=false\n"
|
||||||
"snooper-enabled=true\n" +
|
+ "snooper-enabled=true\n"
|
||||||
"online-mode=false\n" +
|
+ "online-mode=false\n"
|
||||||
"resource-pack=\n" +
|
+ "resource-pack=\n"
|
||||||
"pvp=true\n" +
|
+ "pvp=true\n"
|
||||||
"difficulty=1\n" +
|
+ "difficulty=1\n"
|
||||||
"server-name=Unknown Server\n" +
|
+ "server-name=Unknown Server\n"
|
||||||
"enable-command-block=false\n" +
|
+ "enable-command-block=false\n"
|
||||||
"gamemode=0\n" +
|
+ "gamemode=0\n"
|
||||||
"player-idle-timeout=0\n" +
|
+ "player-idle-timeout=0\n"
|
||||||
"max-players=20\n" +
|
+ "max-players=20\n"
|
||||||
"spawn-monsters=true\n" +
|
+ "spawn-monsters=true\n"
|
||||||
"generate-structures=true\n" +
|
+ "generate-structures=true\n"
|
||||||
"view-distance=10\n" +
|
+ "view-distance=10\n"
|
||||||
"spawn-protection=16\n" +
|
+ "spawn-protection=16\n"
|
||||||
"motd=A Minecraft Server";
|
+ "motd=A Minecraft Server";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,18 @@
|
|||||||
/*
|
/*
|
||||||
* To change this template, choose Tools | Templates
|
* Copyright 2013 huangyuhui <huanghongxun2008@126.com>
|
||||||
* and open the template in the editor.
|
*
|
||||||
|
* 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;
|
package org.jackhuang.hellominecraft.svrmgr.settings;
|
||||||
|
|
||||||
@@ -22,12 +34,12 @@ public class Settings {
|
|||||||
public Settings() {
|
public Settings() {
|
||||||
maxMemory = "1024";
|
maxMemory = "1024";
|
||||||
checkUpdate = true;
|
checkUpdate = true;
|
||||||
schedules = new ArrayList<Schedule>();
|
schedules = new ArrayList<>();
|
||||||
mainjar = bgPath = javaDir = javaArgs = "";
|
mainjar = bgPath = javaDir = javaArgs = "";
|
||||||
inactiveExtMods = new ArrayList<String>();
|
inactiveExtMods = new ArrayList<>();
|
||||||
inactiveCoreMods = new ArrayList<String>();
|
inactiveCoreMods = new ArrayList<>();
|
||||||
inactivePlugins = new ArrayList<String>();
|
inactivePlugins = new ArrayList<>();
|
||||||
inactiveWorlds = new ArrayList<String>();
|
inactiveWorlds = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,18 @@
|
|||||||
/*
|
/*
|
||||||
* To change this template, choose Tools | Templates
|
* Copyright 2013 huangyuhui <huanghongxun2008@126.com>
|
||||||
* and open the template in the editor.
|
*
|
||||||
|
* 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;
|
package org.jackhuang.hellominecraft.svrmgr.settings;
|
||||||
|
|
||||||
@@ -28,18 +40,17 @@ public class SettingsManager {
|
|||||||
public static void load() {
|
public static void load() {
|
||||||
gson = new Gson();
|
gson = new Gson();
|
||||||
File file = new File(IOUtils.currentDir(), "hmcsm.json");
|
File file = new File(IOUtils.currentDir(), "hmcsm.json");
|
||||||
if (file.exists()) {
|
if (file.exists())
|
||||||
try {
|
try {
|
||||||
String str = FileUtils.readFileToString(file);
|
String str = FileUtils.readFileToString(file);
|
||||||
if (str == null || str.trim().equals("")) {
|
if (str == null || str.trim().equals(""))
|
||||||
init();
|
init();
|
||||||
} else {
|
else
|
||||||
settings = gson.fromJson(str, Settings.class);
|
settings = gson.fromJson(str, Settings.class);
|
||||||
}
|
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
} else {
|
else {
|
||||||
settings = new Settings();
|
settings = new Settings();
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
* Copyright 2013 huangyuhui <huanghongxun2008@126.com>
|
||||||
* To change this template file, choose Tools | Templates
|
*
|
||||||
* and open the template in the editor.
|
* 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;
|
package org.jackhuang.hellominecraft.svrmgr.settings;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,6 +1,18 @@
|
|||||||
/*
|
/*
|
||||||
* To change this template, choose Tools | Templates
|
* Copyright 2013 huangyuhui <huanghongxun2008@126.com>
|
||||||
* and open the template in the editor.
|
*
|
||||||
|
* 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;
|
package org.jackhuang.hellominecraft.svrmgr.threads;
|
||||||
|
|
||||||
@@ -27,7 +39,7 @@ public class MonitorThread extends Thread {
|
|||||||
ArrayList<MonitorThreadListener> listeners;
|
ArrayList<MonitorThreadListener> listeners;
|
||||||
|
|
||||||
public MonitorThread(InputStream is) {
|
public MonitorThread(InputStream is) {
|
||||||
this.listeners = new ArrayList<MonitorThreadListener>(5);
|
this.listeners = new ArrayList<>(5);
|
||||||
try {
|
try {
|
||||||
br = new BufferedReader(new InputStreamReader(is, System.getProperty("sun.jnu.encoding", "gbk")));
|
br = new BufferedReader(new InputStreamReader(is, System.getProperty("sun.jnu.encoding", "gbk")));
|
||||||
} catch (UnsupportedEncodingException ex) {
|
} catch (UnsupportedEncodingException ex) {
|
||||||
|
|||||||
@@ -1,6 +1,18 @@
|
|||||||
/*
|
/*
|
||||||
* To change this template, choose Tools | Templates
|
* Copyright 2013 huangyuhui <huanghongxun2008@126.com>
|
||||||
* and open the template in the editor.
|
*
|
||||||
|
* 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;
|
package org.jackhuang.hellominecraft.svrmgr.threads;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,18 @@
|
|||||||
/*
|
/*
|
||||||
* To change this template, choose Tools | Templates
|
* Copyright 2013 huangyuhui <huanghongxun2008@126.com>
|
||||||
* and open the template in the editor.
|
*
|
||||||
|
* 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;
|
package org.jackhuang.hellominecraft.svrmgr.utils;
|
||||||
|
|
||||||
@@ -26,18 +38,23 @@ public class FolderOpener {
|
|||||||
public static void openResourcePacks(String gameDir) {
|
public static void openResourcePacks(String gameDir) {
|
||||||
open(gameDir + "resourcepacks");
|
open(gameDir + "resourcepacks");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void openTextutrePacks(String gameDir) {
|
public static void openTextutrePacks(String gameDir) {
|
||||||
open(gameDir + "texturepacks");
|
open(gameDir + "texturepacks");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void openMods() {
|
public static void openMods() {
|
||||||
open(Utilities.try2GetPath("mods"));
|
open(Utilities.try2GetPath("mods"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void openCoreMods() {
|
public static void openCoreMods() {
|
||||||
open(Utilities.try2GetPath("coremods"));
|
open(Utilities.try2GetPath("coremods"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void openPlugins() {
|
public static void openPlugins() {
|
||||||
open(Utilities.try2GetPath("plugins"));
|
open(Utilities.try2GetPath("plugins"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void openConfig() {
|
public static void openConfig() {
|
||||||
open(Utilities.try2GetPath("config"));
|
open(Utilities.try2GetPath("config"));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,18 @@
|
|||||||
/*
|
/*
|
||||||
* To change this template, choose Tools | Templates
|
* Copyright 2013 huangyuhui <huanghongxun2008@126.com>
|
||||||
* and open the template in the editor.
|
*
|
||||||
|
* 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;
|
package org.jackhuang.hellominecraft.svrmgr.utils;
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
* Copyright 2013 huangyuhui <huanghongxun2008@126.com>
|
||||||
* To change this template file, choose Tools | Templates
|
*
|
||||||
* and open the template in the editor.
|
* 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;
|
package org.jackhuang.hellominecraft.svrmgr.utils;
|
||||||
|
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
@@ -28,16 +38,15 @@ public class IPGet extends Thread {
|
|||||||
try {
|
try {
|
||||||
Document d = Jsoup.connect("http://www.ip138.com").get();
|
Document d = Jsoup.connect("http://www.ip138.com").get();
|
||||||
Elements iframe = d.getElementsByTag("iframe");
|
Elements iframe = d.getElementsByTag("iframe");
|
||||||
if(iframe.size() > 0) {
|
if (iframe.size() > 0) {
|
||||||
String url = iframe.get(0).attr("src");
|
String url = iframe.get(0).attr("src");
|
||||||
String s = NetUtils.doGet(url, "GBK");
|
String s = NetUtils.doGet(url, "GBK");
|
||||||
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}\\]");
|
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);
|
Matcher m = p.matcher(s);
|
||||||
s = "";
|
s = "";
|
||||||
while(m.find()) {
|
while (m.find())
|
||||||
s += m.group() + ",";
|
s += m.group() + ",";
|
||||||
}
|
dl.accept(s.substring(0, s.length() - 1));
|
||||||
dl.accept(s.substring(0, s.length()-1));
|
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
HMCLog.warn("Failed to get ip from ip138.", ex);
|
HMCLog.warn("Failed to get ip from ip138.", ex);
|
||||||
|
|||||||
@@ -1,6 +1,18 @@
|
|||||||
/*
|
/*
|
||||||
* To change this template, choose Tools | Templates
|
* Copyright 2013 huangyuhui <huanghongxun2008@126.com>
|
||||||
* and open the template in the editor.
|
*
|
||||||
|
* 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;
|
package org.jackhuang.hellominecraft.svrmgr.utils;
|
||||||
|
|
||||||
@@ -13,6 +25,7 @@ import java.util.zip.ZipFile;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 判断mod类型
|
* 判断mod类型
|
||||||
|
*
|
||||||
* @author huangyuhui
|
* @author huangyuhui
|
||||||
*/
|
*/
|
||||||
public class ModType {
|
public class ModType {
|
||||||
@@ -35,26 +48,25 @@ public class ModType {
|
|||||||
zipFile = new ZipFile(path);
|
zipFile = new ZipFile(path);
|
||||||
String gbkPath;
|
String gbkPath;
|
||||||
java.util.Enumeration e = zipFile.entries();
|
java.util.Enumeration e = zipFile.entries();
|
||||||
while (e.hasMoreElements())
|
while (e.hasMoreElements()) {
|
||||||
{
|
|
||||||
ZipEntry zipEnt = (ZipEntry) e.nextElement();
|
ZipEntry zipEnt = (ZipEntry) e.nextElement();
|
||||||
if(zipEnt.isDirectory()) continue;
|
if (zipEnt.isDirectory()) continue;
|
||||||
gbkPath = zipEnt.getName();
|
gbkPath = zipEnt.getName();
|
||||||
if("mcmod.info".equals(gbkPath))
|
if ("mcmod.info".equals(gbkPath))
|
||||||
return ForgeMod;
|
return ForgeMod;
|
||||||
else if("mcpmod.info".equals(gbkPath))
|
else if ("mcpmod.info".equals(gbkPath))
|
||||||
return Forge;
|
return Forge;
|
||||||
else if("ModLoader.class".equals(gbkPath))
|
else if ("ModLoader.class".equals(gbkPath))
|
||||||
isModLoader = true;
|
isModLoader = true;
|
||||||
else if(gbkPath.trim().startsWith("mod_"))
|
else if (gbkPath.trim().startsWith("mod_"))
|
||||||
return ModLoaderMod;
|
return ModLoaderMod;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch(Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
if(zipFile != null)
|
if (zipFile != null)
|
||||||
zipFile.close();
|
zipFile.close();
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
Logger.getLogger(ModType.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(ModType.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
@@ -62,7 +74,7 @@ public class ModType {
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(isModLoader)
|
if (isModLoader)
|
||||||
return ModLoaderMod;
|
return ModLoaderMod;
|
||||||
else
|
else
|
||||||
return Unknown;
|
return Unknown;
|
||||||
@@ -70,7 +82,7 @@ public class ModType {
|
|||||||
|
|
||||||
public static String getModTypeShowName(int type) {
|
public static String getModTypeShowName(int type) {
|
||||||
java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("org/jackhuang/hellominecraftlauncher/I18N"); // NOI18N
|
java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("org/jackhuang/hellominecraftlauncher/I18N"); // NOI18N
|
||||||
switch(type) {
|
switch (type) {
|
||||||
case ForgeMod:
|
case ForgeMod:
|
||||||
return bundle.getString("ForgeMod");
|
return bundle.getString("ForgeMod");
|
||||||
case Forge:
|
case Forge:
|
||||||
|
|||||||
@@ -1,6 +1,18 @@
|
|||||||
/*
|
/*
|
||||||
* To change this template, choose Tools | Templates
|
* Copyright 2013 huangyuhui <huanghongxun2008@126.com>
|
||||||
* and open the template in the editor.
|
*
|
||||||
|
* 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;
|
package org.jackhuang.hellominecraft.svrmgr.utils;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,18 @@
|
|||||||
/*
|
/*
|
||||||
* To change this template, choose Tools | Templates
|
* Copyright 2013 huangyuhui <huanghongxun2008@126.com>
|
||||||
* and open the template in the editor.
|
*
|
||||||
|
* 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;
|
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());
|
for (parentThread = Thread.currentThread().getThreadGroup(); parentThread.getParent() != null; parentThread = parentThread.getParent());
|
||||||
int totalThread = parentThread.activeCount();
|
int totalThread = parentThread.activeCount();
|
||||||
double cpuRatio = 0;
|
double cpuRatio = 0;
|
||||||
if (osName.toLowerCase().startsWith("windows")) {
|
if (osName.toLowerCase().startsWith("windows"))
|
||||||
cpuRatio = this.getCpuRatioForWindows();
|
cpuRatio = this.getCpuRatioForWindows();
|
||||||
} else {
|
else
|
||||||
cpuRatio = getCpuRateForLinux();
|
cpuRatio = getCpuRateForLinux();
|
||||||
}
|
|
||||||
// 构造返回对象
|
// 构造返回对象
|
||||||
MonitorInfoBean infoBean = new MonitorInfoBean();
|
MonitorInfoBean infoBean = new MonitorInfoBean();
|
||||||
infoBean.setFreeMemory(freeMemory);
|
infoBean.setFreeMemory(freeMemory);
|
||||||
@@ -135,15 +146,12 @@ public class MonitorServiceImpl implements IMonitorService {
|
|||||||
private static void freeResource(InputStream is, InputStreamReader isr,
|
private static void freeResource(InputStream is, InputStreamReader isr,
|
||||||
BufferedReader br) {
|
BufferedReader br) {
|
||||||
try {
|
try {
|
||||||
if (is != null) {
|
if (is != null)
|
||||||
is.close();
|
is.close();
|
||||||
}
|
if (isr != null)
|
||||||
if (isr != null) {
|
|
||||||
isr.close();
|
isr.close();
|
||||||
}
|
if (br != null)
|
||||||
if (br != null) {
|
|
||||||
br.close();
|
br.close();
|
||||||
}
|
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
System.out.println(ioe.getMessage());
|
System.out.println(ioe.getMessage());
|
||||||
}
|
}
|
||||||
@@ -166,9 +174,8 @@ public class MonitorServiceImpl implements IMonitorService {
|
|||||||
long idletime = c1[0] - c0[0];
|
long idletime = c1[0] - c0[0];
|
||||||
long busytime = c1[1] - c0[1];
|
long busytime = c1[1] - c0[1];
|
||||||
return (double) PERCENT * (busytime) / (busytime + idletime);
|
return (double) PERCENT * (busytime) / (busytime + idletime);
|
||||||
} else {
|
} else
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
|
||||||
} catch (IOException | InterruptedException ex) {
|
} catch (IOException | InterruptedException ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
return 0.0;
|
return 0.0;
|
||||||
@@ -189,9 +196,8 @@ public class MonitorServiceImpl implements IMonitorService {
|
|||||||
InputStreamReader ir = new InputStreamReader(proc.getInputStream());
|
InputStreamReader ir = new InputStreamReader(proc.getInputStream());
|
||||||
LineNumberReader input = new LineNumberReader(ir);
|
LineNumberReader input = new LineNumberReader(ir);
|
||||||
String line = input.readLine();
|
String line = input.readLine();
|
||||||
if (line == null || line.length() < FAULTLENGTH) {
|
if (line == null || line.length() < FAULTLENGTH)
|
||||||
return null;
|
return null;
|
||||||
}
|
|
||||||
int capidx = line.indexOf("Caption");
|
int capidx = line.indexOf("Caption");
|
||||||
int cmdidx = line.indexOf("CommandLine");
|
int cmdidx = line.indexOf("CommandLine");
|
||||||
int rocidx = line.indexOf("ReadOperationCount");
|
int rocidx = line.indexOf("ReadOperationCount");
|
||||||
@@ -202,34 +208,28 @@ public class MonitorServiceImpl implements IMonitorService {
|
|||||||
long kneltime = 0;
|
long kneltime = 0;
|
||||||
long usertime = 0;
|
long usertime = 0;
|
||||||
while ((line = input.readLine()) != null) {
|
while ((line = input.readLine()) != null) {
|
||||||
if (line.length() < wocidx) {
|
if (line.length() < wocidx)
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
// 字段出现顺序:Caption,CommandLine,KernelModeTime,ReadOperationCount,
|
// 字段出现顺序:Caption,CommandLine,KernelModeTime,ReadOperationCount,
|
||||||
// ThreadCount,UserModeTime,WriteOperation
|
// ThreadCount,UserModeTime,WriteOperation
|
||||||
String caption = StrUtils.substring(line, capidx, cmdidx - 1).trim();
|
String caption = StrUtils.substring(line, capidx, cmdidx - 1).trim();
|
||||||
String cmd = StrUtils.substring(line, cmdidx, kmtidx - 1).trim();
|
String cmd = StrUtils.substring(line, cmdidx, kmtidx - 1).trim();
|
||||||
if (cmd.contains("wmic.exe")) {
|
if (cmd.contains("wmic.exe"))
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
String s1 = StrUtils.substring(line, kmtidx, rocidx - 1).trim();
|
String s1 = StrUtils.substring(line, kmtidx, rocidx - 1).trim();
|
||||||
String s2 = StrUtils.substring(line, umtidx, wocidx - 1).trim();
|
String s2 = StrUtils.substring(line, umtidx, wocidx - 1).trim();
|
||||||
if (caption.equals("System Idle Process") || caption.equals("System")) {
|
if (caption.equals("System Idle Process") || caption.equals("System")) {
|
||||||
if (s1.length() > 0) {
|
if (s1.length() > 0)
|
||||||
idletime += Long.parseLong(s1);
|
idletime += Long.parseLong(s1);
|
||||||
}
|
if (s2.length() > 0)
|
||||||
if (s2.length() > 0) {
|
|
||||||
idletime += Long.parseLong(s2);
|
idletime += Long.parseLong(s2);
|
||||||
}
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (s1.length() > 0) {
|
if (s1.length() > 0)
|
||||||
kneltime += Long.parseLong(s1);
|
kneltime += Long.parseLong(s1);
|
||||||
}
|
if (s2.length() > 0)
|
||||||
if (s2.length() > 0) {
|
|
||||||
usertime += Long.parseLong(s2);
|
usertime += Long.parseLong(s2);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
retn[0] = idletime;
|
retn[0] = idletime;
|
||||||
retn[1] = kneltime + usertime;
|
retn[1] = kneltime + usertime;
|
||||||
return retn;
|
return retn;
|
||||||
|
|||||||
@@ -1,6 +1,18 @@
|
|||||||
/*
|
/*
|
||||||
* To change this template, choose Tools | Templates
|
* Copyright 2013 huangyuhui <huanghongxun2008@126.com>
|
||||||
* and open the template in the editor.
|
*
|
||||||
|
* 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;
|
package org.jackhuang.hellominecraft.svrmgr.utils;
|
||||||
|
|
||||||
@@ -51,7 +63,7 @@ public class Utilities {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static ArrayList<String> findAllFile(File f) {
|
public static ArrayList<String> findAllFile(File f) {
|
||||||
ArrayList<String> arr = new ArrayList<String>();
|
ArrayList<String> arr = new ArrayList<>();
|
||||||
if (!f.exists()) {
|
if (!f.exists()) {
|
||||||
return arr;
|
return arr;
|
||||||
}
|
}
|
||||||
@@ -68,7 +80,7 @@ public class Utilities {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static ArrayList<String> findAllDir(File f) {
|
public static ArrayList<String> findAllDir(File f) {
|
||||||
ArrayList<String> arr = new ArrayList<String>();
|
ArrayList<String> arr = new ArrayList<>();
|
||||||
if (f.isDirectory()) {
|
if (f.isDirectory()) {
|
||||||
File[] f1 = f.listFiles();
|
File[] f1 = f.listFiles();
|
||||||
int len = f1.length;
|
int len = f1.length;
|
||||||
@@ -104,10 +116,7 @@ public class Utilities {
|
|||||||
|
|
||||||
public static boolean is16Folder(String path) {
|
public static boolean is16Folder(String path) {
|
||||||
path = Utilities.addSeparator(path);
|
path = Utilities.addSeparator(path);
|
||||||
if (new File(path + "versions").exists()) {
|
return new File(path + "versions").exists();
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isEmpty(String s) {
|
public static boolean isEmpty(String s) {
|
||||||
@@ -184,11 +193,11 @@ public class Utilities {
|
|||||||
dp.browse(uri);
|
dp.browse(uri);
|
||||||
isBrowsed = true;
|
isBrowsed = true;
|
||||||
}
|
}
|
||||||
} catch (java.lang.NullPointerException e) {
|
} catch (java.lang.NullPointerException | java.io.IOException e) {
|
||||||
//此为uri为空时抛出异常
|
//此为uri为空时抛出异常
|
||||||
} catch (java.io.IOException e) {
|
|
||||||
//此为无法获取系统默认浏览器
|
//此为无法获取系统默认浏览器
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return isBrowsed;
|
return isBrowsed;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,18 @@
|
|||||||
/*
|
/*
|
||||||
* To change this template, choose Tools | Templates
|
* Copyright 2013 huangyuhui <huanghongxun2008@126.com>
|
||||||
* and open the template in the editor.
|
*
|
||||||
|
* 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;
|
package org.jackhuang.hellominecraft.svrmgr.views;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,18 @@
|
|||||||
/*
|
/*
|
||||||
* To change this template, choose Tools | Templates
|
* Copyright 2013 huangyuhui <huanghongxun2008@126.com>
|
||||||
* and open the template in the editor.
|
*
|
||||||
|
* 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;
|
package org.jackhuang.hellominecraft.svrmgr.views;
|
||||||
|
|
||||||
@@ -31,30 +43,25 @@ public class InputDialog extends javax.swing.JDialog {
|
|||||||
super(parent, modal);
|
super(parent, modal);
|
||||||
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
|
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
|
||||||
|
|
||||||
textFields = new ArrayList<JTextField>();
|
textFields = new ArrayList<>();
|
||||||
panels = new ArrayList<JPanel>();
|
panels = new ArrayList<>();
|
||||||
jButton1 = new javax.swing.JButton();
|
jButton1 = new javax.swing.JButton();
|
||||||
jButton1.setText("确认");
|
jButton1.setText("确认");
|
||||||
jButton1.addActionListener(new ActionListener() {
|
jButton1.addActionListener((ActionEvent e) -> {
|
||||||
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
result = new String[textFields.size()];
|
result = new String[textFields.size()];
|
||||||
for(int i = 0; i < textFields.size(); i++)
|
for (int i = 0; i < textFields.size(); i++)
|
||||||
result[i] = textFields.get(i).getText();
|
result[i] = textFields.get(i).getText();
|
||||||
InputDialog.this.dispose();
|
InputDialog.this.dispose();
|
||||||
}
|
|
||||||
});
|
});
|
||||||
for(String s : messages) {
|
for (String s : messages)
|
||||||
makeNewField(s);
|
makeNewField(s);
|
||||||
}
|
|
||||||
makeLayout();
|
makeLayout();
|
||||||
Dimension scrSize = Toolkit.getDefaultToolkit().getScreenSize();
|
Dimension scrSize = Toolkit.getDefaultToolkit().getScreenSize();
|
||||||
setLocation((scrSize.width - this.getWidth()) / 2,
|
setLocation((scrSize.width - this.getWidth()) / 2,
|
||||||
(scrSize.height - this.getHeight()) / 2);
|
(scrSize.height - this.getHeight()) / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void makeNewField(String message) {
|
final void makeNewField(String message) {
|
||||||
JLabel label = new JLabel();
|
JLabel label = new JLabel();
|
||||||
label.setText(message);
|
label.setText(message);
|
||||||
JTextField textField = new JTextField();
|
JTextField textField = new JTextField();
|
||||||
@@ -87,11 +94,11 @@ public class InputDialog extends javax.swing.JDialog {
|
|||||||
panels.add(panel);
|
panels.add(panel);
|
||||||
}
|
}
|
||||||
|
|
||||||
void makeLayout() {
|
final void makeLayout() {
|
||||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||||
getContentPane().setLayout(layout);
|
getContentPane().setLayout(layout);
|
||||||
GroupLayout.ParallelGroup g = layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING);
|
GroupLayout.ParallelGroup g = layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING);
|
||||||
for(JPanel p : panels)
|
for (JPanel p : panels)
|
||||||
g.addComponent(p, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE);
|
g.addComponent(p, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE);
|
||||||
g.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
g.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||||
.addGap(0, 0, Short.MAX_VALUE)
|
.addGap(0, 0, Short.MAX_VALUE)
|
||||||
@@ -105,7 +112,7 @@ public class InputDialog extends javax.swing.JDialog {
|
|||||||
);
|
);
|
||||||
GroupLayout.SequentialGroup g2 = layout.createSequentialGroup()
|
GroupLayout.SequentialGroup g2 = layout.createSequentialGroup()
|
||||||
.addContainerGap();
|
.addContainerGap();
|
||||||
for(JPanel p : panels)
|
for (JPanel p : panels)
|
||||||
g2 = g2.addComponent(p, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
g2 = g2.addComponent(p, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED);
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED);
|
||||||
g2 = g2.addComponent(jButton1)
|
g2 = g2.addComponent(jButton1)
|
||||||
|
|||||||
@@ -1,6 +1,18 @@
|
|||||||
/*
|
/*
|
||||||
* To change this template, choose Tools | Templates
|
* Copyright 2013 huangyuhui <huanghongxun2008@126.com>
|
||||||
* and open the template in the editor.
|
*
|
||||||
|
* 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;
|
package org.jackhuang.hellominecraft.svrmgr.views;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,18 @@
|
|||||||
/*
|
/*
|
||||||
* To change this template, choose Tools | Templates
|
* Copyright 2013 huangyuhui <huanghongxun2008@126.com>
|
||||||
* and open the template in the editor.
|
*
|
||||||
|
* 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;
|
package org.jackhuang.hellominecraft.svrmgr.views;
|
||||||
|
|
||||||
@@ -36,12 +48,11 @@ public class PluginInfoDialog extends javax.swing.JDialog {
|
|||||||
lblWebsite.setText(pi.link);
|
lblWebsite.setText(pi.link);
|
||||||
//SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
//SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
DefaultTableModel model = (DefaultTableModel) lstPluginInfo.getModel();
|
DefaultTableModel model = (DefaultTableModel) lstPluginInfo.getModel();
|
||||||
for (PluginVersion v : pi.versions) {
|
for (PluginVersion v : pi.versions)
|
||||||
model.addRow(new Object[]{
|
model.addRow(new Object[]{
|
||||||
v.date, v.version, v.filename, StrUtils.parseParams("", v.game_versions.toArray(), ", "),
|
v.date, v.version, v.filename, StrUtils.parseParams("", v.game_versions.toArray(), ", "),
|
||||||
v.type
|
v.type
|
||||||
});
|
});
|
||||||
}
|
|
||||||
lstPluginInfo.updateUI();
|
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
|
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
|
||||||
int index = lstPluginInfo.getSelectedRow();
|
int index = lstPluginInfo.getSelectedRow();
|
||||||
if (index == -1) {
|
if (index == -1)
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
String url = pi.versions.get(index).download;
|
String url = pi.versions.get(index).download;
|
||||||
TaskWindow.getInstance()
|
TaskWindow.getInstance()
|
||||||
.addTask(new FileDownloadTask(url, new File(Utilities.getGameDir() + "plugins"
|
.addTask(new FileDownloadTask(url, new File(Utilities.getGameDir() + "plugins"
|
||||||
|
|||||||
Reference in New Issue
Block a user