HMCL 2.3.2

This commit is contained in:
huanghongxun
2015-06-22 16:47:05 +08:00
parent 0693d12f6b
commit 0656227183
358 changed files with 35670 additions and 0 deletions

View File

@@ -0,0 +1,65 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.jackhuang.hellominecraft.svrmgr;
import java.awt.Font;
import java.io.PrintWriter;
import java.io.StringWriter;
import javax.swing.UIManager;
import org.jackhuang.hellominecraft.utils.functions.DoneListener0;
import org.jackhuang.hellominecraft.HMCLog;
import org.jackhuang.hellominecraft.views.LogWindow;
import org.jackhuang.hellominecraft.svrmgr.settings.SettingsManager;
import org.jackhuang.hellominecraft.utils.UpdateChecker;
import org.jackhuang.hellominecraft.svrmgr.views.MainWindow;
import org.jackhuang.hellominecraft.utils.VersionNumber;
import org.jackhuang.hellominecraft.lookandfeel.HelloMinecraftLookAndFeel;
/**
*
* @author hyh
*/
public class Main {
public static String launcherName = "Hello Minecraft! Server Manager";
public static final String PUBLISH_URL = "http://www.mcbbs.net/thread-171239-1-1.html";
public static byte firstVer = 0, secondVer = 8, thirdVer = 6;
public static String makeTitle() {
return launcherName + ' ' + firstVer + '.' + secondVer + '.' + thirdVer;
}
public static void main(String[] args) {
try {
SettingsManager.load();
try {
javax.swing.UIManager.setLookAndFeel(new HelloMinecraftLookAndFeel());
UIManager.getLookAndFeelDefaults().put("defaultFont", new Font("微软雅黑", Font.PLAIN, 12));
} catch (Throwable ex) {
HMCLog.warn("Failed to set look and feel", ex);
}
new UpdateChecker(new VersionNumber(firstVer, secondVer, thirdVer), "hmcsm", SettingsManager.settings.checkUpdate, new DoneListener0() {
@Override
public void onDone() {
SettingsManager.settings.checkUpdate = false;
}
}).start();
new MainWindow().setVisible(true);
} catch(Throwable t) {
HMCLog.err("There's something wrong when running server holder.", t);
LogWindow.instance.clean();
LogWindow.instance.log("开服器崩溃了QAQ");
StringWriter trace = new StringWriter();
t.printStackTrace(new PrintWriter(trace));
LogWindow.instance.log(trace.toString());
LogWindow.instance.setVisible(true);
System.exit(-1);
}
}
}

View File

@@ -0,0 +1,37 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.jackhuang.hellominecraft.svrmgr.cbplugins;
import java.util.List;
/**
*
* @author hyh
*/
public class BukkitPlugin {
public String description, plugin_name, slug;
public List<PluginVersion> versions;
public String getLatestVersion() {
if(versions != null) {
PluginVersion v = versions.get(0);
return v.version;
}
return null;
}
public String getLatestBukkit() {
if(versions != null) {
PluginVersion v = versions.get(0);
List<String> al = v.game_versions;
if(al != null && !al.isEmpty()) {
return al.get(0);
}
}
return "";
}
}

View File

@@ -0,0 +1,14 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.jackhuang.hellominecraft.svrmgr.cbplugins;
/**
*
* @author hyh
*/
public class Category {
public double count;
public String name;
}

View File

@@ -0,0 +1,18 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.jackhuang.hellominecraft.svrmgr.cbplugins;
import java.util.List;
/**
*
* @author hyh
*/
public class PluginInfo {
public String website, dbo_page, description, slug, plugin_name,
link, stage, main;
public List<String> authors, categories;
public List<PluginVersion> versions;
}

View File

@@ -0,0 +1,15 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.jackhuang.hellominecraft.svrmgr.cbplugins;
/**
*
* @author hyh
*/
public class PluginInformation {
public String name, version, author, description;
}

View File

@@ -0,0 +1,86 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.jackhuang.hellominecraft.svrmgr.cbplugins;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import java.io.File;
import java.io.InputStream;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import org.ho.yaml.Yaml;
import org.jackhuang.hellominecraft.utils.NetUtils;
import org.jackhuang.hellominecraft.utils.StrUtils;
/**
*
* @author hyh
*/
public class PluginManager {
public static PluginInformation getPluginYML(File f) {
try {
ZipFile file = new ZipFile(f);
ZipEntry plg = file.getEntry("plugin.yml");
InputStream is = file.getInputStream(plg);
return Yaml.loadType(is, PluginInformation.class);
} catch (Exception ex) {
Logger.getLogger(PluginManager.class.getName()).log(Level.SEVERE, null, ex);
}
return null;
}
public static List<BukkitPlugin> getPlugins() throws Exception {
String result = NetUtils.doGet("http://api.bukget.org/3//plugins?fields=slug,plugin_name,description,versions.version,versions.game_versions");
Gson gson = new Gson();
List<BukkitPlugin> list = gson.fromJson(result, new TypeToken<List<BukkitPlugin>>(){}.getType());
return list;
}
public static final String CATEGORY_ADMIN_TOOLS = "Admin Tools",
CATEGORY_DEVELOPER_TOOLS = "Developer Tools",
CATEGORY_FUN = "Fun",
CATEGORY_GENERAL = "General",
CATEGORY_ANTI_GRIEFING_TOOLS = "Anti Griefing Tools",
CATEGORY_MECHAICS = "Mechanics",
CATEGORY_Fixes = "Fixes",
CATEGORY_ROLE_PLAYING = "Role Playing",
CATEGORY_WORLD_EDITING_AND_MANAGEMENT = "World Editing and Management",
CATEGORY_TELEPORTATION = "Teleportation",
CATEGORY_INFORMATIONAL = "Informational",
CATEGORY_ECONOMY = "Economy",
CATEGORY_CHAT_RELATED = "Chat Related",
CATEGORY_MISCELLANEOUS = "Miscellaneous",
CATEGORY_WORLD_GENERATORS = "World Generators",
CATEGORY_WEBSITE_ADMINISTRATION = "Website Administration";
public static List<BukkitPlugin> getPluginsByCategory(String category) throws Exception {
String result = NetUtils.doGet("http://api.bukget.org/3//categories/" + category + "?fields=slug,plugin_name,description,versions.version,versions.game_versions");
Gson gson = new Gson();
List<BukkitPlugin> list = gson.fromJson(result, new TypeToken<List<BukkitPlugin>>(){}.getType());
return list;
}
public static List<Category> getCategories() throws Exception {
String result = NetUtils.doGet("http://api.bukget.org/3//categories/");
Gson gson = new Gson();
List<Category> list = gson.fromJson(result, new TypeToken<List<Category>>(){}.getType());
return list;
}
public static PluginInfo getPluginInfo(String slug) throws Exception {
if(StrUtils.isNotBlank(slug)) {
String result = NetUtils.doGet("http://api.bukget.org/3//plugins/bukkit/" + slug.toLowerCase());
if(StrUtils.isNotBlank(result)) {
if(!result.equals("null")) {
PluginInfo info = new Gson().fromJson(result, PluginInfo.class);
return info;
}
}
}
return null;
}
}

View File

@@ -0,0 +1,19 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.jackhuang.hellominecraft.svrmgr.cbplugins;
import java.util.List;
/**
*
* @author hyh
*/
public class PluginVersion {
public long date;
public String download, link, version;
public List<String> game_versions;
public String filename, type;
}

View File

@@ -0,0 +1,80 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.jackhuang.hellominecraft.svrmgr.installer.bukkit;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.jackhuang.hellominecraft.DoneListener1;
import org.jackhuang.hellominecraft.HMCLog;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
/**
*
* @author hyh
*/
public class BukkitFormatThread extends Thread {
DoneListener1<List<BukkitVersion>> lis;
List<BukkitVersion> formattedList;
String url;
public BukkitFormatThread(String url, DoneListener1<List<BukkitVersion>> lis) {
this.lis = lis;
this.url = url;
}
public void format(String url) {
formattedList = new ArrayList<BukkitVersion>();
try {
Document doc = Jsoup.connect(url).get();
Elements versionsTable = doc.getElementsByClass("versionsTable");
Elements allforge = new Elements();
for(Element table : versionsTable)
allforge.addAll(table.getElementsByTag("tr"));
for(Element e : allforge) {
Elements tds = e.getElementsByTag("td");
if(tds.isEmpty()) continue;
BukkitVersion v = new BukkitVersion();
Elements ths = e.getElementsByTag("th");
v.buildNumber = v.infoLink = null;
if(ths.size() > 0) {
Elements a = ths.get(0).getElementsByTag("a");
if(a.size() > 0) {
v.buildNumber = a.get(0).text();
v.infoLink = a.get(0).attr("href");
}
}
v.version = tds.get(0).text();
v.type = tds.get(1).text();
if(tds.get(2).getElementsByTag("a").isEmpty()) continue;
v.downloadLink = "http://dl.bukkit.org" + tds.get(2).getElementsByTag("a").get(0).attr("href");
formattedList.add(v);
}
} catch (IOException ex) {
HMCLog.warn("Failed to get bukkit list", ex);
BukkitVersion v = new BukkitVersion();
v.type = v.version = "获取失败";
v.buildNumber = v.infoLink = null;
formattedList.add(v);
}
}
@Override
public void run() {
List<BukkitVersion> al = null;
format(url);
if(lis != null)
lis.onDone(formattedList);
}
}

View File

@@ -0,0 +1,17 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.jackhuang.hellominecraft.svrmgr.installer.bukkit;
/**
*
* @author hyh
*/
public class BukkitVersion {
public String buildNumber, version, type, downloadLink, infoLink;
}

View File

@@ -0,0 +1,97 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.jackhuang.hellominecraft.svrmgr.installer.cauldron;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.jackhuang.hellominecraft.DoneListener1;
import org.jackhuang.hellominecraft.HMCLog;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
/**
*
* @author hyh
*/
public class ForgeFormatThread extends Thread {
DoneListener1<Map<String, List<ForgeVersion>>> lis;
Map<String, List<ForgeVersion>> formattedList;
public ForgeFormatThread(DoneListener1<Map<String, List<ForgeVersion>>> lis) {
this.lis = lis;
}
public void formatNew() {
formattedList = new HashMap();
try {
Document doc = Jsoup.connect("http://files.minecraftforge.net/").get();
Elements allbuilds = doc.getElementsByClass("builds");
Elements tables = new Elements();
for(Element build : allbuilds)
tables.addAll(build.getElementsByTag("table"));
Elements allforge = new Elements();
for(Element table : tables)
allforge.addAll(table.getElementsByTag("tr"));
for(Element e : allforge) {
Elements tds = e.getElementsByTag("td");
if(tds.isEmpty()) continue;
ForgeVersion v = new ForgeVersion();
v.ver = tds.get(0).text();
v.mcver = tds.get(1).text();
v.releasetime = tds.get(2).text();
v.installer = new String[2];
v.universal = new String[2];
v.javadoc = new String[2];
v.src = new String[2];
v.userdev = new String[2];
Elements a = tds.get(3).getElementsByTag("a");
String prev = null;
for(Element e2 : a) {
String href = e2.attributes().get("href").toLowerCase();
if(e2.text().toLowerCase().contains("changelog")) {
v.changelog = href;
} else if(prev != null) {
int index;
if(href.contains("adf.ly")) index = 0;
else index = 1;
if(prev.toLowerCase().contains("installer")) {
v.installer[index] = href;
} else
if(prev.toLowerCase().contains("server")) {
v.universal[index] = href;
}
}
prev = e2.text();
}
if(!formattedList.containsKey(v.mcver))
formattedList.put(v.mcver, new ArrayList<ForgeVersion>());
formattedList.get(v.mcver).add(v);
}
} catch (IOException ex) {
HMCLog.warn("Failed to get forge list", ex);
ForgeVersion v = new ForgeVersion();
v.mcver = v.ver = "获取失败";
formattedList.put(v.mcver, new ArrayList<ForgeVersion>());
formattedList.get(v.mcver).add(v);
}
}
@Override
public void run() {
formatNew();
if(lis != null)
lis.onDone(formattedList);
}
}

View File

@@ -0,0 +1,239 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.jackhuang.hellominecraft.svrmgr.installer.cauldron;
import com.google.gson.Gson;
import java.io.BufferedOutputStream;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.jar.JarEntry;
import java.util.jar.JarInputStream;
import java.util.jar.JarOutputStream;
import java.util.jar.Pack200;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import javax.swing.JOptionPane;
import org.jackhuang.hellominecraft.HMCLog;
import org.jackhuang.hellominecraft.utils.DigestUtils;
import org.jackhuang.hellominecraft.utils.FileUtils;
import org.jackhuang.hellominecraft.utils.IOUtils;
import org.jackhuang.hellominecraft.utils.MessageBox;
import org.jackhuang.hellominecraft.utils.NetUtils;
import org.jackhuang.hellominecraft.utils.StrUtils;
import org.jackhuang.hellominecraft.tasks.TaskWindow;
import org.jackhuang.hellominecraft.tasks.download.FileDownloadTask;
import org.tukaani.xz.XZInputStream;
/**
*
* @author hyh
*/
public class ForgeInstaller {
private final Gson gson = new Gson();
public File gameDir, gameLibraries;
public File forgeInstaller;
public ForgeInstaller(File gameDir, File forgeInstaller) throws IOException {
this.gameDir = gameDir.getCanonicalFile();
this.forgeInstaller = forgeInstaller;
}
public void install() throws Exception {
HMCLog.log("Extracting install profiles...");
ZipFile zipFile = new ZipFile(forgeInstaller);
ZipEntry entry = zipFile.getEntry("install_profile.json");
String content = NetUtils.getStreamContent(zipFile.getInputStream(entry));
InstallProfile profile = gson.fromJson(content, InstallProfile.class);
HMCLog.log("Extracting cauldron server pack..." + profile.install.filePath);
entry = zipFile.getEntry(profile.install.filePath);
InputStream is = zipFile.getInputStream(entry);
//MinecraftLibrary forge = new MinecraftLibrary(profile.install.path);
//forge.format();
File file = new File(gameDir, profile.install.filePath);
file.getParentFile().mkdirs();
FileOutputStream fos = new FileOutputStream(file);
BufferedOutputStream bos = new BufferedOutputStream(fos);
int c;
while ((c = is.read()) != -1) {
bos.write((byte) c);
}
bos.close();
fos.close();
File minecraftserver = new File(gameDir, "minecraft_server." + profile.install.minecraft + ".jar");
TaskWindow tw = TaskWindow.getInstance();
if(minecraftserver.exists() && JOptionPane.showConfirmDialog(null, "已发现官方服务端文件,是否要重新下载?") == JOptionPane.YES_OPTION) {
tw.clean();
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())
MessageBox.Show("Minecraft官方服务端下载失败");
}
tw.clean();
for (MinecraftLibrary library : profile.versionInfo.libraries) {
library.init();
File lib = new File(gameDir, "libraries" + File.separator + library.formatted + ".pack.xz");
String libURL = "https://libraries.minecraft.net/";
if (StrUtils.isNotBlank(library.url)) {
libURL = library.url;
}
tw.addTask(new FileDownloadTask(libURL + library.formatted.replace("\\", "/"), lib).setTag(library.name));
}
tw.start();
if(!tw.areTasksFinished())
MessageBox.Show("压缩库下载失败!");
tw.clean();
for (MinecraftLibrary library : profile.versionInfo.libraries) {
File packxz = new File(gameDir, "libraries" + File.separator + library.formatted + ".pack.xz");
if(packxz.exists()) return;
File lib = new File(gameDir, "libraries" + File.separator + library.formatted);
lib.getParentFile().mkdirs();
String libURL = "https://libraries.minecraft.net/";
if (StrUtils.isNotBlank(library.url)) {
libURL = library.url;
}
tw.addTask(new FileDownloadTask(libURL + library.formatted.replace("\\", "/"), lib).setTag(library.name));
}
tw.start();
if(!tw.areTasksFinished())
MessageBox.Show("库下载失败!");
tw.clean();
ArrayList<String> badLibs = new ArrayList<String>();
for (MinecraftLibrary library : profile.versionInfo.libraries) {
File lib = new File(gameDir, "libraries" + File.separator + library.formatted);
File packFile = new File(gameDir, "libraries" + File.separator + library.formatted + ".pack.xz");
if (packFile.exists() && packFile.isFile()) {
try {
unpackLibrary(lib.getParentFile(), NetUtils.getBytesFromStream(FileUtils.openInputStream(packFile)));
if(!checksumValid(lib, Arrays.asList(library.checksums)))
badLibs.add(library.name);
} catch (IOException e) {
HMCLog.warn("Failed to unpack library: " + library.name);
badLibs.add(library.name);
}
}
}
if (badLibs.size() > 0) {
MessageBox.Show("这些库在解压的时候出现了问题" + badLibs.toString());
}
}
public static void unpackLibrary(File output, byte[] data)
throws IOException {
if (output.exists()) {
output.delete();
}
byte[] decompressed = IOUtils.readFully(new XZInputStream(new ByteArrayInputStream(data)));
String end = new String(decompressed, decompressed.length - 4, 4);
if (!end.equals("SIGN")) {
HMCLog.warn("Unpacking failed, signature missing " + end);
return;
}
int x = decompressed.length;
int len = decompressed[(x - 8)] & 0xFF | (decompressed[(x - 7)] & 0xFF) << 8 | (decompressed[(x - 6)] & 0xFF) << 16 | (decompressed[(x - 5)] & 0xFF) << 24;
byte[] checksums = Arrays.copyOfRange(decompressed, decompressed.length - len - 8, decompressed.length - 8);
FileOutputStream jarBytes = new FileOutputStream(output);
JarOutputStream jos = new JarOutputStream(jarBytes);
Pack200.newUnpacker().unpack(new ByteArrayInputStream(decompressed), jos);
jos.putNextEntry(new JarEntry("checksums.sha1"));
jos.write(checksums);
jos.closeEntry();
jos.close();
jarBytes.close();
}
private static boolean checksumValid(File libPath, List<String> checksums) {
try {
byte[] fileData = NetUtils.getBytesFromStream(FileUtils.openInputStream(libPath));
boolean valid = (checksums == null) || (checksums.isEmpty()) || (checksums.contains(DigestUtils.sha1Hex(fileData)));
if ((!valid) && (libPath.getName().endsWith(".jar"))) {
valid = validateJar(libPath, fileData, checksums);
}
return valid;
} catch (IOException e) {
HMCLog.warn("Failed to checksum valid: " + libPath, e);
}
return false;
}
private static boolean validateJar(File libPath, byte[] data, List<String> checksums) throws IOException {
System.out.println("Checking \"" + libPath.getAbsolutePath() + "\" internal checksums");
HashMap<String, String> files = new HashMap<String, String>();
String[] hashes = null;
JarInputStream jar = new JarInputStream(new ByteArrayInputStream(data));
JarEntry entry = jar.getNextJarEntry();
while (entry != null) {
byte[] eData = IOUtils.readFully(jar);
if (entry.getName().equals("checksums.sha1")) {
hashes = new String(eData, Charset.forName("UTF-8")).split("\n");
}
if (!entry.isDirectory()) {
files.put(entry.getName(), DigestUtils.sha1Hex(eData));
}
entry = jar.getNextJarEntry();
}
jar.close();
if (hashes != null) {
boolean failed = !checksums.contains(files.get("checksums.sha1"));
if (failed) {
System.out.println(" checksums.sha1 failed validation");
} else {
System.out.println(" checksums.sha1 validated successfully");
for (String hash : hashes) {
if ((!hash.trim().equals("")) && (hash.contains(" "))) {
String[] e = hash.split(" ");
String validChecksum = e[0];
String target = e[1];
String checksum = (String) files.get(target);
if ((!files.containsKey(target)) || (checksum == null)) {
System.out.println(" " + target + " : missing");
failed = true;
} else {
if (checksum.equals(validChecksum)) {
continue;
}
System.out.println(" " + target + " : failed (" + checksum + ", " + validChecksum + ")");
failed = true;
}
}
}
}
if (!failed) {
System.out.println(" Jar contents validated successfully");
}
return !failed;
}
System.out.println(" checksums.sha1 was not found, validation failed");
return false;
}
}

View File

@@ -0,0 +1,20 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.jackhuang.hellominecraft.svrmgr.installer.cauldron;
/**
*
* @author hyh
*/
public class ForgeVersion {
public String vername, ver, mcver, releasetime, changelog;
public String[] installer, javadoc, src, universal, userdev;
public int typeint;
@Override
public String toString() {
return "ForgeVersion{" + "vername=" + vername + ", ver=" + ver + ", mcver=" + mcver + ", releasetime=" + releasetime + ", changelog=" + changelog + ", installer=" + installer + ", javadoc=" + javadoc + ", src=" + src + ", universal=" + universal + ", userdev=" + userdev + ", typeint=" + typeint + '}';
}
}

View File

@@ -0,0 +1,15 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.jackhuang.hellominecraft.svrmgr.installer.cauldron;
/**
*
* @author hyh
*/
public class Install {
public String profileName, target, path, version, filePath, welcome, minecraft, mirrorList, logo;
}

View File

@@ -0,0 +1,16 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.jackhuang.hellominecraft.svrmgr.installer.cauldron;
/**
*
* @author hyh
*/
public class InstallProfile {
public Install install;
public MinecraftVersion versionInfo;
}

View File

@@ -0,0 +1,29 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.jackhuang.hellominecraft.svrmgr.installer.cauldron;
import java.io.File;
/**
*
* @author hyh
*/
public class MinecraftLibrary {
public String url, formatted=null, name;
//public boolean serverreq=true, clientreq=true;
public String[] checksums;
public void init() {
String str = name;
String[] s = str.split(":");
str = s[0];
str = str.replace('.', File.separatorChar);
str += File.separator + s[1] + File.separator + s[2]
+ File.separator + s[1] + '-' + s[2] + ".jar";
formatted = str;
}
}

View File

@@ -0,0 +1,21 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.jackhuang.hellominecraft.svrmgr.installer.cauldron;
import java.util.List;
/**
*
* @author hyh
*/
public class MinecraftVersion {
public String minecraftArguments, mainClass, time, id, type, processArguments,
releaseTime, assets, jar, inheritsFrom;
public int minimumLauncherVersion;
public List<MinecraftLibrary> libraries;
}

View File

@@ -0,0 +1,71 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.jackhuang.hellominecraft.svrmgr.server;
import java.util.TimerTask;
import org.jackhuang.hellominecraft.svrmgr.server.schedules.*;
import org.jackhuang.hellominecraft.svrmgr.settings.Schedule;
/**
*
* @author hyh
*/
public class ScheduleTranslator {
public static TimerTask translate(Server ser, Schedule s) {
switch(s.type) {
case Schedule.TYPE_AUTO_SAVE:
return new AutoSaveSchedule(s, ser);
case Schedule.TYPE_AUTO_RESTART:
return new AutoRestartSchedule(s, ser);
case Schedule.TYPE_AUTO_BACKUP:
return new AutoBackupSchedule(s, ser);
case Schedule.TYPE_AUTO_BROADCAST:
return new AutoBroadcastSchedule(s, ser);
case Schedule.TYPE_AUTO_SEND_COMMAND:
return new AutoBroadcastSchedule(s, ser);
}
return null;
}
public static String getName(Schedule s) {
switch(s.type) {
case Schedule.TYPE_AUTO_SAVE:
return "自动保存";
case Schedule.TYPE_AUTO_RESTART:
return "自动重启";
case Schedule.TYPE_AUTO_BACKUP:
return "自动备份";
case Schedule.TYPE_AUTO_BROADCAST:
return "自动广播";
case Schedule.TYPE_AUTO_SEND_COMMAND:
return "自动发送命令";
}
return "";
}
public static String getTimeTypeName(Schedule s) {
switch(s.timeType) {
case Schedule.TIME_TYPE_PER:
return "每x分钟";
case Schedule.TIME_TYPE_PAST_HOUR:
return "整点后x分钟";
case Schedule.TIME_TYPE_SERVER_STARTED:
return "当服务器启动";
case Schedule.TIME_TYPE_SERVER_STOPPED:
return "当服务器关闭";
case Schedule.TIME_TYPE_SERVER_CRASHED:
return "当服务器崩溃";
}
return "";
}
public static Object[] getRow(Schedule s) {
return new Object[] {
getName(s), getTimeTypeName(s), s.per, s.content
};
}
}

View File

@@ -0,0 +1,431 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.jackhuang.hellominecraft.svrmgr.server;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedWriter;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Timer;
import java.util.TimerTask;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.jackhuang.hellominecraft.utils.functions.DoneListener0;
import org.jackhuang.hellominecraft.DoneListener1;
import org.jackhuang.hellominecraft.HMCLog;
import org.jackhuang.hellominecraft.utils.IOUtils;
import org.jackhuang.hellominecraft.utils.MessageBox;
import org.jackhuang.hellominecraft.utils.Pair;
import org.jackhuang.hellominecraft.utils.StrUtils;
import org.jackhuang.hellominecraft.svrmgr.settings.Schedule;
import org.jackhuang.hellominecraft.svrmgr.settings.SettingsManager;
import org.jackhuang.hellominecraft.svrmgr.threads.MonitorThread;
import org.jackhuang.hellominecraft.svrmgr.threads.WaitForThread;
import org.jackhuang.hellominecraft.svrmgr.utils.Utilities;
/**
*
* @author hyh
*/
public class Server implements DoneListener1<Integer>, MonitorThread.MonitorThreadListener,
ActionListener {
private static Server instance;
private static boolean disactived = false;
public static Server getInstance() {
return instance;
}
public static boolean isInstanceRunning() {
return instance != null && instance.isRunning;
}
public static void init(String jar, String memory) {
instance = new Server(jar, memory);
}
String jar, memory;
Process server;
MonitorThread threadA, threadB;
WaitForThread threadC;
DoneListener1<Pair<String, String[]>> gettingPlayerNumber;
ArrayList<MonitorThread.MonitorThreadListener> listeners;
ArrayList<DoneListener1<Integer>> listenersC;
ArrayList<DoneListener0> listenersBegin, listenersDone;
ArrayList<TimerTask> timerTasks;
ArrayList<Schedule> schedules;
BufferedWriter bw;
Timer timer;
javax.swing.Timer pastTimer;
public boolean isRunning, isRestart, isDone;
int isGettingPlayerNumber;
String playerNumber;
private Server(String jar, String memory) {
this.jar = jar;
this.memory = memory;
isRestart = isDone = false;
listeners = new ArrayList<MonitorThread.MonitorThreadListener>();
listenersC = new ArrayList<DoneListener1<Integer>>();
listenersBegin = new ArrayList<DoneListener0>();
listenersDone = new ArrayList<DoneListener0>();
schedules = new ArrayList<Schedule>();
timerTasks = new ArrayList<TimerTask>();
}
public void addListener(MonitorThread.MonitorThreadListener l) {
listeners.add(l);
}
public void addListener(DoneListener1<Integer> l) {
listenersC.add(l);
}
public void addServerStartedListener(DoneListener0 l) {
listenersBegin.add(l);
}
public void addServerDoneListener(DoneListener0 l) {
listenersDone.add(l);
}
public void run() throws IOException {
String jvmPath;
if (StrUtils.isBlank(SettingsManager.settings.javaDir)) {
jvmPath = IOUtils.getJavaDir();
} else {
jvmPath = SettingsManager.settings.javaDir;
}
String[] puts = new String[]{
jvmPath,
"-Xmx" + memory + "m",
"-jar",
SettingsManager.settings.mainjar,
"nogui",
"-nojline"
};
ProcessBuilder pb = new ProcessBuilder(puts);
pb.directory(new File(SettingsManager.settings.mainjar).getParentFile());
try {
disactiveMods(SettingsManager.settings.inactiveExtMods,
SettingsManager.settings.inactiveCoreMods,
SettingsManager.settings.inactivePlugins);
server = pb.start();
registerThread(threadA, server.getInputStream());
registerThread(threadB, server.getErrorStream());
registerThreadC(server);
try {
bw = new BufferedWriter(new OutputStreamWriter(server.getOutputStream(), System.getProperty("sun.jnu.encoding", "utf-8")));
} catch (UnsupportedEncodingException ex) {
bw = new BufferedWriter(new OutputStreamWriter(server.getOutputStream()));
}
isRunning = true;
for (DoneListener0 d : listenersBegin) {
d.onDone();
}
sendStatus("*** 启动服务端中 ***");
} catch (IOException ex) {
Logger.getLogger(Server.class.getName()).log(Level.SEVERE, null, ex);
isRunning = false;
}
}
public void sendCommand(String cmd) {
if (isRunning) {
try {
sendStatus("发送指令: " + cmd);
bw.write(cmd);
bw.newLine();
bw.flush();
} catch (IOException ex) {
Logger.getLogger(Server.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
public void getPlayerNumber(DoneListener1<Pair<String, String[]>> d) {
isGettingPlayerNumber = 1;
gettingPlayerNumber = d;
sendCommand("list");
}
public void restart() {
isRestart = true;
stop();
}
public void stop() {
if (timer != null) {
timer.cancel();
}
sendCommand("stop");
}
public void shutdown() {
if (timer != null) {
timer.cancel();
}
server.destroy();
}
public void clearSchedule() {
schedules.clear();
}
public void addSchedule(Schedule s) {
schedules.add(s);
}
public void delSchedule(Schedule s) {
int index = schedules.indexOf(s);
if (index == -1) {
return;
}
schedules.remove(index);
timerTasks.get(index).cancel();
timerTasks.remove(index);
}
private void registerThread(MonitorThread thread, InputStream is) {
thread = new MonitorThread(is);
for (MonitorThread.MonitorThreadListener l : listeners) {
thread.addListener(l);
}
thread.addListener(this);
thread.start();
}
private void registerThreadC(Process p) {
threadC = new WaitForThread(p);
for (DoneListener1<Integer> l : listenersC) {
threadC.addListener(l);
}
threadC.addListener(this);
threadC.start();
}
@Override
public void onDone(Integer t) {
if (t == 0) {
sendStatus("*** 服务端已停止 ***");
System.out.println("Server stopped successfully");
} else {
sendStatus("*** 服务端崩溃了!(错误码:" + t + ") ***");
System.err.println("Server crashed(exit code: " + t + ")");
}
isRunning = false;
for (int i = 0; i < schedules.size(); i++) {
if (schedules.get(i).timeType == Schedule.TIME_TYPE_SERVER_STOPPED) {
ScheduleTranslator.translate(this, schedules.get(i)).run();
}
}
if (timer != null) {
timer.cancel();
}
if (pastTimer != null) {
pastTimer.stop();
}
restoreMods();
if (isRestart) {
try {
run();
} catch (IOException ex) {
MessageBox.Show("重启失败!");
HMCLog.warn("Failed to launch!", ex);
}
isRestart = false;
}
}
private static void disactiveMods(ArrayList<String> inactiveExtMods,
ArrayList<String> inactiveCoreMods, ArrayList<String> inactivePlugins) {
disactiveModsByType(inactiveExtMods, "mods");
disactiveModsByType(inactiveCoreMods, "coremods");
disactiveModsByType(inactivePlugins, "plugins");
disactived = true;
}
private static void disactiveModsByType(ArrayList<String> paramArrayOfString, String paramString) {
restoreModsByType(paramString);
System.out.println("禁用不活动的文件: " + paramString);
if ((paramArrayOfString == null) || (paramArrayOfString.size() <= 0)) {
return;
}
File[] files = new File(Utilities.getGameDir(), paramString).listFiles();
if (files == null) {
System.out.println("没有文件: " + paramString);
return;
}
for (int i = 0; i < files.length; i++) {
File file = files[i];
if (!file.isDirectory()) {
String name = file.getName();
if ((!paramArrayOfString.contains(name))
|| ((!name.toLowerCase().endsWith(".zip")) && (!name.toLowerCase().endsWith(".jar")))) {
continue;
}
String newName = name + "X";
File newFile = new File(file.getParentFile(), newName);
if (newFile.exists()) {
newFile.delete();
}
if (file.renameTo(newFile)) {
System.out.println("已禁用: " + name + ", 新名称: " + newFile.getName());
} else {
System.out.println("无法禁用: " + name);
}
}
}
}
private static void restoreModsByType(String paramString) {
System.out.println("还原被禁用的文件: " + paramString);
File[] files = new File(Utilities.getGameDir(), paramString).listFiles();
if (files == null) {
return;
}
for (int i = 0; i < files.length; i++) {
File file = files[i];
if (file.isDirectory()) {
continue;
}
String name = file.getName();
String lowName = name.toLowerCase();
if ((!lowName.endsWith(".zipx")) && (!lowName.endsWith(".jarx"))) {
continue;
}
String newName = name.substring(0, name.length() - 1);
File newFile = new File(file.getParentFile(), newName);
if (newFile.exists()) {
file.delete();
} else {
if (!file.renameTo(newFile)) {
System.out.println("无法重命名: " + file.getName() + " 到: " + newFile.getName() + " 在: " + file.getParent());
}
}
}
}
static void restoreMods() {
if (disactived) {
restoreModsByType("mods");
restoreModsByType("coremods");
restoreModsByType("plugins");
disactived = false;
}
}
@Override
public void onStatus(String status) {
System.out.println(status);
if (isGettingPlayerNumber == 1) {
Pattern p = Pattern.compile("There are [0-9]*/[0-9]* players online");
Matcher m = p.matcher(status);
if (!m.find()) {
return;
}
String s = m.group(0);
s = s.substring(10, s.length() - 15);
playerNumber = s;
isGettingPlayerNumber = 2;
return;
} else if (isGettingPlayerNumber == 2) {
try {
status = status.substring(status.lastIndexOf("]")+1);
status = status.substring(status.indexOf(":")+1);
} catch(Exception e) {
HMCLog.warn("Failed to substring status.", e);
}
String[] s;
if(StrUtils.isNotBlank(status)) {
s = status.trim().split(", ");
} else {
s = new String[0];
}
Pair<String, String[]> p = new Pair<String, String[]>(playerNumber, s);
isGettingPlayerNumber = 0;
gettingPlayerNumber.onDone(p);
return;
}
if (isDone == false) {
Pattern p = Pattern.compile("\\[INFO\\] Done \\([0-9]*\\.[0-9]*s\\)! For help, type \"help\" or \"\\?\"");
Matcher m = p.matcher(status);
if (m.find()) {
for (DoneListener0 d : listenersDone) {
d.onDone();
}
timer = new Timer();
timerTasks.clear();
for (int i = 0; i < schedules.size(); i++) {
if (schedules.get(i).timeType == Schedule.TIME_TYPE_SERVER_STARTED) {
ScheduleTranslator.translate(this, schedules.get(i)).run();
continue;
}
if (schedules.get(i).timeType != Schedule.TIME_TYPE_PER) {
continue;
}
long mill = (long) Math.floor(schedules.get(i).per * 60 * 1000);
timerTasks.add(ScheduleTranslator.translate(this, schedules.get(i)));
timer.schedule(timerTasks.get(i), mill, mill);
}
pastTimer = new javax.swing.Timer(1000, this);
pastTimer.start();
System.out.println("Server started!");
sendStatus("*** 服务端已启动完成 ***");
isDone = true;
}
}
if (status.length() > 20) {
if (status.substring(20).contains("[SEVERE] This crash report has been saved to: ")) {
for (int i = 0; i < schedules.size(); i++) {
if (schedules.get(i).timeType == Schedule.TIME_TYPE_SERVER_CRASHED) {
ScheduleTranslator.translate(this, schedules.get(i)).run();
}
}
}
}
}
GregorianCalendar c = new GregorianCalendar();
@Override
public void actionPerformed(ActionEvent e) {
c.setTime(new Date());
if (c.get(Calendar.SECOND) != 0) {
return;
}
int minute = c.get(Calendar.MINUTE);
for (int i = 0; i < schedules.size(); i++) {
if (schedules.get(i).timeType != Schedule.TIME_TYPE_PAST_HOUR) {
continue;
}
if (schedules.get(i).per == minute) {
ScheduleTranslator.translate(this, schedules.get(i)).run();
}
}
}
private void sendStatus(String status) {
for (MonitorThread.MonitorThreadListener l : listeners) {
l.onStatus(status);
}
}
}

View File

@@ -0,0 +1,35 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.jackhuang.hellominecraft.svrmgr.server;
import java.io.File;
import java.io.IOException;
import java.util.zip.ZipFile;
import org.jackhuang.hellominecraft.HMCLog;
/**
*
* @author hyh
*/
public class ServerChecker {
public static boolean isServerJar(File f) {
ZipFile file;
try {
file = new ZipFile(f);
} catch (IOException ex) {
HMCLog.warn("", ex);
return false;
}
if(file.getEntry("org/bukkit/craftbukkit/Main.class") != null) {
return true;
}
if(file.getEntry("net/minecraft/server/MinecraftServer.class") != null) {
return true;
}
return false;
}
}

View File

@@ -0,0 +1,103 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.jackhuang.hellominecraft.svrmgr.server.backups;
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import org.jackhuang.hellominecraft.HMCLog;
import org.jackhuang.hellominecraft.utils.Compressor;
import org.jackhuang.hellominecraft.svrmgr.settings.SettingsManager;
import org.jackhuang.hellominecraft.svrmgr.utils.Utilities;
/**
*
* @author hyh
*/
public class BackupManager {
public static String backupDir() {
return Utilities.getGameDir() + "backups-HMCSM" + File.separator;
}
public static ArrayList<String> getBackupList() {
String gameDir = backupDir();
return Utilities.findAllFile(new File(gameDir));
}
public static void addWorldBackup(final String folder) {
new File(backupDir()).mkdirs();
Thread t = new Thread() {
@Override
public void run() {
try {
SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd HH-mm-ss");
Compressor.zip(Utilities.getGameDir() + folder + File.separator,
backupDir() + "world+" + f.format(new Date()) + "+" + folder + ".zip");
} catch (IOException ex) {
HMCLog.warn("Failed to compress world pack.", ex);
}
}
};
t.start();
}
public static ArrayList<String> findAllWorlds() {
String gameDir = Utilities.getGameDir();
ArrayList<String> folders = Utilities.findAllDir(new File(gameDir));
ArrayList<String> result = new ArrayList<String>();
for(String folder : folders) {
String worldPath = gameDir + folder + File.separator;
ArrayList<String> files = Utilities.findAllFile(new File(worldPath));
if(files.contains("level.dat")) {
result.add(folder);
}
}
return result;
}
public static void restoreBackup(String backupFile) {
try {
File file = new File(backupFile);
String name = Utilities.trimExtension(file.getName());
String[] info = name.split("\\+");
String folder = info[2];
File world = new File(Utilities.getGameDir() + folder + File.separator);
Utilities.deleteAll(world);
world.mkdirs();
Compressor.unzip(backupFile, world.getAbsolutePath());
} catch (IOException ex) {
HMCLog.warn("Failed to decompress world pack.", ex);
}
}
public static void backupAllWorlds() {
ArrayList<String> al = findAllWorlds();
for(String world : al) {
if(!SettingsManager.settings.inactiveWorlds.contains(world))
addWorldBackup(world);
}
}
public static void backupAllPlugins() {
new File(backupDir()).mkdirs();
Thread t = new Thread() {
@Override
public void run() {
try {
SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd HH-mm-ss");
Compressor.zip(Utilities.getGameDir() + "plugins" + File.separator,
backupDir() + "plugin+" + f.format(new Date()) + "+plugins.zip");
} catch (IOException ex) {
HMCLog.warn("Failed to compress world pack with plugins.", ex);
}
}
};
t.start();
}
}

View File

@@ -0,0 +1,13 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.jackhuang.hellominecraft.svrmgr.server.download;
/**
*
* @author hyh
*/
public class ServerDownloadPackage {
public String mcversion, version, forgeversion, majorversion, file;
}

View File

@@ -0,0 +1,33 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.jackhuang.hellominecraft.svrmgr.server.schedules;
import java.util.TimerTask;
import org.jackhuang.hellominecraft.svrmgr.server.Server;
import org.jackhuang.hellominecraft.svrmgr.server.backups.BackupManager;
import org.jackhuang.hellominecraft.svrmgr.settings.Schedule;
/**
*
* @author hyh
*/
public class AutoBackupSchedule extends TimerTask {
Schedule main;
Server server;
public AutoBackupSchedule(Schedule s, Server s2) {
main = s;
server = s2;
}
@Override
public void run() {
System.out.println("Backup");
Server.getInstance().sendCommand("say 自动备份完毕");
BackupManager.backupAllWorlds();
}
}

View File

@@ -0,0 +1,29 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.jackhuang.hellominecraft.svrmgr.server.schedules;
import java.util.TimerTask;
import org.jackhuang.hellominecraft.svrmgr.server.Server;
import org.jackhuang.hellominecraft.svrmgr.settings.Schedule;
/**
*
* @author hyh
*/
public class AutoBroadcastSchedule extends TimerTask {
Schedule main;
Server server;
public AutoBroadcastSchedule(Schedule s, Server s2) {
main = s;
server = s2;
}
@Override
public void run() {
server.sendCommand("say " + main.content);
}
}

View File

@@ -0,0 +1,34 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.jackhuang.hellominecraft.svrmgr.server.schedules;
import java.io.IOException;
import java.util.TimerTask;
import org.jackhuang.hellominecraft.HMCLog;
import org.jackhuang.hellominecraft.svrmgr.server.Server;
import org.jackhuang.hellominecraft.svrmgr.settings.Schedule;
/**
*
* @author hyh
*/
public class AutoExecuteSchedule extends TimerTask {
Schedule main;
Server server;
public AutoExecuteSchedule(Schedule s, Server s2) {
main = s;
server = s2;
}
@Override
public void run() {
try {
Runtime.getRuntime().exec(main.content);
} catch (IOException ex) {
HMCLog.err("Failed to exec command: " + main.content, ex);
}
}
}

View File

@@ -0,0 +1,28 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.jackhuang.hellominecraft.svrmgr.server.schedules;
import java.util.TimerTask;
import org.jackhuang.hellominecraft.svrmgr.server.Server;
import org.jackhuang.hellominecraft.svrmgr.settings.Schedule;
/**
*
* @author hyh
*/
public class AutoRestartSchedule extends TimerTask {
Schedule main;
Server server;
public AutoRestartSchedule(Schedule s, Server s2) {
main = s;
server = s2;
}
@Override
public void run() {
server.restart();
}
}

View File

@@ -0,0 +1,31 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.jackhuang.hellominecraft.svrmgr.server.schedules;
import java.util.TimerTask;
import org.jackhuang.hellominecraft.svrmgr.server.Server;
import org.jackhuang.hellominecraft.svrmgr.settings.Schedule;
/**
*
* @author hyh
*/
public class AutoSaveSchedule extends TimerTask {
Schedule main;
Server server;
public AutoSaveSchedule(Schedule s, Server s2) {
main = s;
server = s2;
}
@Override
public void run() {
System.out.println("auto save");
server.sendCommand("save-all");
}
}

View File

@@ -0,0 +1,23 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.jackhuang.hellominecraft.svrmgr.server.schedules;
import java.util.TimerTask;
import org.jackhuang.hellominecraft.svrmgr.server.Server;
import org.jackhuang.hellominecraft.svrmgr.settings.Schedule;
/**
*
* @author hyh
*/
public abstract class AutoSchedule extends TimerTask {
Schedule main;
Server server;
public AutoSchedule(Schedule s, Server s2) {
main = s;
server = s2;
}
}

View File

@@ -0,0 +1,24 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.jackhuang.hellominecraft.svrmgr.server.schedules;
import org.jackhuang.hellominecraft.svrmgr.server.Server;
import org.jackhuang.hellominecraft.svrmgr.settings.Schedule;
/**
*
* @author hyh
*/
public class AutoSendCommandSchedule extends AutoSchedule {
public AutoSendCommandSchedule(Schedule s, Server s2) {
super(s, s2);
}
@Override
public void run() {
server.sendCommand(main.content);
}
}

View File

@@ -0,0 +1,36 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.jackhuang.hellominecraft.svrmgr.settings;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
*
* @author hyh
*/
public class BannedPlayers extends PlayerList<BannedPlayers.BannedPlayer> {
@Override
protected BannedPlayer newPlayer(String name) {
return new BannedPlayer(name);
}
public static class BannedPlayer extends PlayerList.BasePlayer {
public String source, expires, reason, created;
public BannedPlayer(String name) {
super(name);
created = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss +0800").format(new Date());
source = "Server";
expires = "forever";
reason = "你已经被服务器封禁";
}
}
}

View File

@@ -0,0 +1,28 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.jackhuang.hellominecraft.svrmgr.settings;
/**
*
* @author hyh
*/
public class Op extends PlayerList<Op.Operator> {
@Override
protected Op.Operator newPlayer(String name) {
return new Op.Operator(name);
}
public static class Operator extends PlayerList.BasePlayer {
public int level;
public Operator(String name) {
super(name);
level = 4;
}
}
}

View File

@@ -0,0 +1,113 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.jackhuang.hellominecraft.svrmgr.settings;
import com.google.gson.Gson;
import java.io.File;
import java.io.IOException;
import java.util.HashSet;
import java.util.UUID;
import org.jackhuang.hellominecraft.HMCLog;
import org.jackhuang.hellominecraft.utils.FileUtils;
import org.jackhuang.hellominecraft.utils.StrUtils;
import org.jackhuang.hellominecraft.svrmgr.settings.PlayerList.BasePlayer;
/**
*
* @author hyh
* @param <T> Player type.
*/
public abstract class PlayerList<T extends BasePlayer> {
public static class BasePlayer {
public String uuid, name;
public BasePlayer(String name) {
uuid = UUID.randomUUID().toString();
this.name = name;
}
@Override
public boolean equals(Object obj) {
if (obj instanceof PlayerList.BasePlayer) {
BasePlayer player = (BasePlayer) obj;
return player.name.equals(name);
}
return false;
}
@Override
public int hashCode() {
return this.name.hashCode();
}
@Override
public String toString() {
return name;
}
}
public HashSet<T> op;
protected abstract T newPlayer(String name);
public void initByText(String s) {
String[] lines = s.split("\n");
op = new HashSet<T>();
for (String l : lines) {
if(l.startsWith("#")) continue;
T player = newPlayer(l);
if (StrUtils.isBlank(l)) {
continue;
}
op.add(player);
}
}
public void initByJson(String s) {
op = new Gson().<HashSet<T>>fromJson(s, HashSet.class);
}
public void initByBoth(File txt, File json) {
HashSet<T> player = new HashSet<T>();
/*op = null;
if(json.exists()) {
try {
initByJson(FileUtils.readFileToStringIgnoreFileNotFound(json));
if(op != null)
player.addAll(op);
} catch(IOException e) {
HMCLLog.warn("Failed to load playerlist by json", e);
}
}*/
op = null;
if(txt.exists()) {
try {
initByText(FileUtils.readFileToStringIgnoreFileNotFound(txt));
if(op != null)
player.addAll(op);
} catch(IOException e) {
HMCLog.warn("Failed to load playerlist by txt", e);
}
}
op = player;
}
public void saveAsText(File file) throws IOException {
FileUtils.write(file, StrUtils.parseParams("", op, System.getProperty("line.separator")));
}
public void saveAsJson(File file) throws IOException {
FileUtils.write(file, new Gson().toJson(op));
}
public void saveAsBoth(File txt, File json) throws IOException {
saveAsText(txt);
saveAsJson(json);
}
}

View File

@@ -0,0 +1,33 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.jackhuang.hellominecraft.svrmgr.settings;
/**
*
* @author hyh
*/
public class Schedule {
public static final int
TYPE_AUTO_SAVE = 0,
TYPE_AUTO_RESTART = 1,
TYPE_AUTO_BACKUP = 2,
TYPE_AUTO_BROADCAST = 3,
TYPE_AUTO_SEND_COMMAND = 4,
TYPE_AUTO_EXECUTE = 5;
public static final int
TYPE2_AUTO_BACKUP_PLUGINS = 1,
TYPE2_AUTH_BACKUP_CONFIG = 2,
TYPE3_AUTH_BACKUP_WORLD = 3;
public static final int
TIME_TYPE_PER = 0,
TIME_TYPE_PAST_HOUR = 1,
TIME_TYPE_SERVER_STARTED = 2,
TIME_TYPE_SERVER_STOPPED = 3,
TIME_TYPE_SERVER_CRASHED = 4;
public int type, type2, timeType;
public String content;
public double per;
}

View File

@@ -0,0 +1,253 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.jackhuang.hellominecraft.svrmgr.settings;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Properties;
import org.jackhuang.hellominecraft.HMCLog;
/**
*
* @author jack
*/
public class ServerProperties {
public static ServerProperties getInstance() {
return instance;
}
private static ServerProperties instance;
public static void init(String path) {
instance = new ServerProperties(path);
}
String path;
InputStream is;
Properties p;
public ServerProperties(String path) {
this.path = path;
}
public String getProperty(String key) {
return getProperty(key, "");
}
public String getProperty(String key, String defaultValue) {
try {
is = new FileInputStream(new File(path, "server.properties"));
p = new Properties();
p.load(is);
return p.getProperty(key, defaultValue);
} catch (IOException ex) {
HMCLog.warn("Failed to get property in server.properties", ex);
return "";
} finally {
try {
if(is != null)
is.close();
} catch (IOException ex) {
HMCLog.warn("Failed to close InputStream for server.properties", ex);
}
}
}
public int getPropertyInt(String key, int defaultValue) {
try {
return Integer.parseInt(getProperty(key, String.valueOf(defaultValue)));
} catch(NumberFormatException e) {
return defaultValue;
}
}
public boolean getPropertyBoolean(String key, boolean defaultValue) {
return getProperty(key, String.valueOf(defaultValue)).equals("true");
}
public void setProperty(String key, String value) {
try {
is = new FileInputStream(new File(path, "server.properties"));
p = new Properties();
p.load(is);
p.setProperty(key, value);
SimpleDateFormat f = new SimpleDateFormat("E M d HH:mm:ss z y");
p.store(new FileOutputStream(new File(path, "server.properties")),
"Minecraft server properties\n" + f.format(new Date()));
} catch (IOException ex) {
HMCLog.warn("Failed to set property in server.properties", ex);
} finally {
try {
if(is != null)
is.close();
} catch (IOException ex) {
HMCLog.warn("Failed to close OutputStream for server.properties", ex);
}
}
}
public void setProperty(String key, boolean value) {
setProperty(key, value ? "true" : "false");
}
public void setProperty(String key, int value) {
setProperty(key, String.valueOf(value));
}
public void setGeneratorSettings(String string) {
setProperty("generator-settings", string);
}
public void setAllowNether(boolean bool) {
setProperty("allow-nether", bool);
}
public void setLevelName(String string) {
setProperty("level-name", string);
}
public void setEnableQuery(boolean bool) {
setProperty("enable-query", bool);
}
public void setAllowFlight(boolean bool) {
setProperty("allow-flight", bool);
}
public void setServerPort(int integer) {
setProperty("server-port", integer);
}
public void setLevelType(String string) {
setProperty("level-type", string);
}
public void setEnableRcon(boolean bool) {
setProperty("enable-rcon", bool);
}
public void setForceGameMode(boolean bool) {
setProperty("force-gamemode", bool);
}
public void setLevelSeed(String string) {
setProperty("level-seed", string);
}
public void setServerIP(String string) {
setProperty("server-ip", string);
}
public void setMaxBuildHeight(int integer) {
setProperty("max-build-height", integer);
}
public void setSpawnNPCs(boolean bool) {
setProperty("spawn-npcs", bool);
}
public void setWhiteList(boolean bool) {
setProperty("white-list", bool);
}
public void setSpawnAnimals(boolean bool) {
setProperty("spawn-animals", bool);
}
public void setTexturePack(String string) {
setProperty("texture-pack", string);
}
public void setSnooperEnabled(boolean bool) {
setProperty("snooper-enabled", bool);
}
public void setHardCore(boolean bool) {
setProperty("hardcore", bool);
}
public void setOnlineMode(boolean bool) {
setProperty("online-mode", bool);
}
public void setPVP(boolean bool) {
setProperty("pvp", bool);
}
public void setDifficulty(int integer) {
setProperty("difficulty", integer);
}
public void setServerName(String string) {
setProperty("server-name", string);
}
public void setGameMode(int integer) {
setProperty("gamemode", integer);
}
public void setMaxPlayers(int integer) {
setProperty("max-players", integer);
}
public void setSpawnMonsters(boolean bool) {
setProperty("spawn-monsters", bool);
}
public void setViewDistence(int integer) {
setProperty("view-distance", integer);
}
public void setGenerateStructures(boolean bool) {
setProperty("generate-structures", bool);
}
public void setMotd(String string) {
setProperty("motd", string);
}
public static String getDefault() {
return "generator-settings=\n" +
"op-permission-level=4\n" +
"allow-nether=true\n" +
"level-name=world\n" +
"enable-query=false\n" +
"allow-flight=false\n" +
"announce-player-achievements=true\n" +
"server-port=25565\n" +
"level-type=DEFAULT\n" +
"enable-rcon=false\n" +
"force-gamemode=false\n" +
"level-seed=\n" +
"server-ip=\n" +
"max-build-height=256\n" +
"spawn-npcs=true\n" +
"white-list=false\n" +
"spawn-animals=true\n" +
"hardcore=false\n" +
"snooper-enabled=true\n" +
"online-mode=false\n" +
"resource-pack=\n" +
"pvp=true\n" +
"difficulty=1\n" +
"server-name=Unknown Server\n" +
"enable-command-block=false\n" +
"gamemode=0\n" +
"player-idle-timeout=0\n" +
"max-players=20\n" +
"spawn-monsters=true\n" +
"generate-structures=true\n" +
"view-distance=10\n" +
"spawn-protection=16\n" +
"motd=A Minecraft Server";
}
}

View File

@@ -0,0 +1,33 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.jackhuang.hellominecraft.svrmgr.settings;
import java.util.ArrayList;
/**
*
* @author hyh
*/
public class Settings {
public boolean checkUpdate;
public String maxMemory;
public String mainjar, bgPath, javaDir, javaArgs;
public ArrayList<String> inactiveExtMods, inactiveCoreMods, inactivePlugins,
inactiveWorlds;
public ArrayList<Schedule> schedules;
public Settings() {
maxMemory = "1024";
checkUpdate = true;
schedules = new ArrayList<Schedule>();
mainjar = bgPath = javaDir = javaArgs = "";
inactiveExtMods = new ArrayList<String>();
inactiveCoreMods = new ArrayList<String>();
inactivePlugins = new ArrayList<String>();
inactiveWorlds = new ArrayList<String>();
}
}

View File

@@ -0,0 +1,62 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.jackhuang.hellominecraft.svrmgr.settings;
/**
*
* @author hyh
*/
import com.google.gson.Gson;
import java.io.File;
import java.io.IOException;
import org.jackhuang.hellominecraft.HMCLog;
import org.jackhuang.hellominecraft.utils.FileUtils;
import org.jackhuang.hellominecraft.utils.IOUtils;
/**
*
* @author hyh
*/
public class SettingsManager {
public static Settings settings;
public static boolean isFirstLoad = false;
static Gson gson;
public static void load() {
gson = new Gson();
File file = new File(IOUtils.currentDir(), "hmcsm.json");
if (file.exists()) {
try {
String str = FileUtils.readFileToString(file);
if (str == null || str.trim().equals("")) {
init();
} else {
settings = gson.fromJson(str, Settings.class);
}
} catch (IOException ex) {
init();
}
} else {
settings = new Settings();
save();
}
}
public static void init() {
settings = new Settings();
isFirstLoad = true;
save();
}
public static void save() {
File f = new File(IOUtils.currentDir(), "hmcsm.json");
try {
FileUtils.write(f, gson.toJson(settings));
} catch (IOException ex) {
HMCLog.err("Failed to save settings.", ex);
}
}
}

View File

@@ -0,0 +1,28 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.jackhuang.hellominecraft.svrmgr.settings;
/**
*
* @author hyh
*/
public class WhiteList extends PlayerList<WhiteList.WhiteListPlayer> {
@Override
protected WhiteList.WhiteListPlayer newPlayer(String name) {
return new WhiteList.WhiteListPlayer(name);
}
public static class WhiteListPlayer extends PlayerList.BasePlayer {
public WhiteListPlayer(String name) {
super(name);
}
}
}

View File

@@ -0,0 +1,56 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.jackhuang.hellominecraft.svrmgr.threads;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import org.jackhuang.hellominecraft.HMCLog;
/**
*
* @author hyh
*/
public class MonitorThread extends Thread {
public interface MonitorThreadListener {
void onStatus(String status);
}
InputStream is;
BufferedReader br;
ArrayList<MonitorThreadListener> listeners;
public MonitorThread(InputStream is) {
this.listeners = new ArrayList<MonitorThreadListener>(5);
try {
br = new BufferedReader(new InputStreamReader(is, System.getProperty("sun.jnu.encoding", "gbk")));
} catch (UnsupportedEncodingException ex) {
br = new BufferedReader(new InputStreamReader(is));
}
}
public void addListener(MonitorThreadListener l) {
listeners.add(l);
}
@Override
public void run() {
String line;
try {
while((line = br.readLine()) != null) {
for(MonitorThreadListener l : listeners)
if(l != null)
l.onStatus(line);
}
} catch (IOException ex) {
HMCLog.warn("Failed to monitor threads.", ex);
}
}
}

View File

@@ -0,0 +1,45 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.jackhuang.hellominecraft.svrmgr.threads;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.jackhuang.hellominecraft.DoneListener1;
/**
*
* @author jack
*/
public class WaitForThread extends Thread {
public ArrayList<DoneListener1<Integer>> al;
Process p;
public WaitForThread(Process p) {
this.p = p;
al = new ArrayList<DoneListener1<Integer>>();
}
public void addListener(DoneListener1<Integer> dl) {
al.add(dl);
}
@Override
public void run() {
try {
int exitCode = p.waitFor();
for(DoneListener1<Integer> dl : al)
if(dl != null)
dl.onDone(exitCode);
} catch (InterruptedException ex) {
Logger.getLogger(WaitForThread.class.getName()).log(Level.SEVERE, null, ex);
for(DoneListener1<Integer> dl : al)
if(dl != null)
dl.onDone(-1);
}
}
}

View File

@@ -0,0 +1,45 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.jackhuang.hellominecraft.svrmgr.utils;
import java.io.File;
import org.jackhuang.hellominecraft.utils.MessageBox;
/**
*
* @author jack
*/
public class FolderOpener {
public static void open(String s) {
try {
File f = new File(s);
f.mkdirs();
java.awt.Desktop.getDesktop().open(f);
} catch (Exception ex) {
MessageBox.Show("无法打开资源管理器: " + ex.getMessage());
}
}
public static void openResourcePacks(String gameDir) {
open(gameDir + "resourcepacks");
}
public static void openTextutrePacks(String gameDir) {
open(gameDir + "texturepacks");
}
public static void openMods() {
open(Utilities.try2GetPath("mods"));
}
public static void openCoreMods() {
open(Utilities.try2GetPath("coremods"));
}
public static void openPlugins() {
open(Utilities.try2GetPath("plugins"));
}
public static void openConfig() {
open(Utilities.try2GetPath("config"));
}
}

View File

@@ -0,0 +1,20 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.jackhuang.hellominecraft.svrmgr.utils;
/**
*
* @author hyh
*/
public interface IMonitorService {
/**
* 获得当前的监控对象.
*
* @return 返回构造好的监控对象
* @throws Exception
*/
public MonitorInfoBean getMonitorInfoBean() throws Exception;
}

View File

@@ -0,0 +1,48 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.jackhuang.hellominecraft.svrmgr.utils;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.jackhuang.hellominecraft.DoneListener1;
import org.jackhuang.hellominecraft.HMCLog;
import org.jackhuang.hellominecraft.utils.NetUtils;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;
/**
*
* @author hyh
*/
public class IPGet extends Thread {
public DoneListener1<String> dl;
@Override
public void run() {
try {
Document d = Jsoup.connect("http://www.ip138.com").get();
Elements iframe = d.getElementsByTag("iframe");
if(iframe.size() > 0) {
String url = iframe.get(0).attr("src");
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}\\]");
Matcher m = p.matcher(s);
s = "";
while(m.find()) {
s += m.group() + ",";
}
dl.onDone(s.substring(0, s.length()-1));
}
} catch (Exception ex) {
HMCLog.warn("Failed to get ip from ip138.", ex);
dl.onDone("获取失败");
}
}
}

View File

@@ -0,0 +1,86 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.jackhuang.hellominecraft.svrmgr.utils;
import java.io.File;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
/**
* 判断mod类型
* @author hyh
*/
public class ModType {
public static final int ForgeMod = 0;
public static final int ModLoaderMod = 1;
public static final int Forge = 2;
public static final int ModLoader = 3;
public static final int Unknown = 4;
public static int getModType(String path) {
return getModType(new File(path));
}
public static int getModType(File path) {
boolean isModLoader = false;
ZipFile zipFile = null;
try {
if (path.exists()) {
zipFile = new ZipFile(path);
String gbkPath;
java.util.Enumeration e = zipFile.entries();
while (e.hasMoreElements())
{
ZipEntry zipEnt = (ZipEntry) e.nextElement();
if(zipEnt.isDirectory()) continue;
gbkPath = zipEnt.getName();
if("mcmod.info".equals(gbkPath))
return ForgeMod;
else if("mcpmod.info".equals(gbkPath))
return Forge;
else if("ModLoader.class".equals(gbkPath))
isModLoader = true;
else if(gbkPath.trim().startsWith("mod_"))
return ModLoaderMod;
}
}
} catch(Exception e) {
} finally {
try {
if(zipFile != null)
zipFile.close();
} catch (IOException ex) {
Logger.getLogger(ModType.class.getName()).log(Level.SEVERE, null, ex);
} catch (Throwable t) {
}
}
if(isModLoader)
return ModLoaderMod;
else
return Unknown;
}
public static String getModTypeShowName(int type) {
java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("org/jackhuang/hellominecraftlauncher/I18N"); // NOI18N
switch(type) {
case ForgeMod:
return bundle.getString("ForgeMod");
case Forge:
return bundle.getString("Forge");
case ModLoader:
return bundle.getString("ModLoader");
case ModLoaderMod:
return bundle.getString("ModLoaderMod");
default:
return bundle.getString("Unknown");
}
}
}

View File

@@ -0,0 +1,121 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.jackhuang.hellominecraft.svrmgr.utils;
/**
*
* @author hyh
*/
public class MonitorInfoBean {
/**
* 可使用内存.
*/
private long totalMemory;
/**
* 剩余内存.
*/
private long freeMemory;
/**
* 最大可使用内存.
*/
private long maxMemory;
/**
* 操作系统.
*/
private String osName;
/**
* 总的物理内存.
*/
private long totalMemorySize;
/**
* 剩余的物理内存.
*/
private long freePhysicalMemorySize;
/**
* 已使用的物理内存.
*/
private long usedMemory;
/**
* 线程总数.
*/
private int totalThread;
/**
* cpu使用率.
*/
private double cpuRatio;
public long getFreeMemory() {
return freeMemory;
}
public void setFreeMemory(long freeMemory) {
this.freeMemory = freeMemory;
}
public long getFreePhysicalMemorySize() {
return freePhysicalMemorySize;
}
public void setFreePhysicalMemorySize(long freePhysicalMemorySize) {
this.freePhysicalMemorySize = freePhysicalMemorySize;
}
public long getMaxMemory() {
return maxMemory;
}
public void setMaxMemory(long maxMemory) {
this.maxMemory = maxMemory;
}
public String getOsName() {
return osName;
}
public void setOsName(String osName) {
this.osName = osName;
}
public long getTotalMemory() {
return totalMemory;
}
public void setTotalMemory(long totalMemory) {
this.totalMemory = totalMemory;
}
public long getTotalMemorySize() {
return totalMemorySize;
}
public void setTotalMemorySize(long totalMemorySize) {
this.totalMemorySize = totalMemorySize;
}
public int getTotalThread() {
return totalThread;
}
public void setTotalThread(int totalThread) {
this.totalThread = totalThread;
}
public long getUsedMemory() {
return usedMemory;
}
public void setUsedMemory(long usedMemory) {
this.usedMemory = usedMemory;
}
public double getCpuRatio() {
return cpuRatio;
}
public void setCpuRatio(double cpuRatio) {
this.cpuRatio = cpuRatio;
}
}

View File

@@ -0,0 +1,267 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.jackhuang.hellominecraft.svrmgr.utils;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.LineNumberReader;
import java.util.StringTokenizer;
import com.sun.management.OperatingSystemMXBean;
import org.jackhuang.hellominecraft.utils.Bytes;
/**
*
* 获取系统信息的业务逻辑实现类.
*
* @author GuoHuang
*/
public class MonitorServiceImpl implements IMonitorService {
private static final int CPUTIME = 30;
private static final int PERCENT = 100;
private static final int FAULTLENGTH = 10;
private static String linuxVersion = null;
/**
* 获得当前的监控对象.
*
* @return 返回构造好的监控对象
* @throws Exception
* @author GuoHuang
*/
public MonitorInfoBean getMonitorInfoBean() throws Exception {
int kb = 1024;
// 可使用内存
long totalMemory = Runtime.getRuntime().totalMemory() / kb;
// 剩余内存
long freeMemory = Runtime.getRuntime().freeMemory() / kb;
// 最大可使用内存
long maxMemory = Runtime.getRuntime().maxMemory() / kb;
OperatingSystemMXBean osmxb = (OperatingSystemMXBean) java.lang.management.ManagementFactory.getOperatingSystemMXBean();
// 操作系统
String osName = System.getProperty("os.name");
// 总的物理内存
long totalMemorySize = osmxb.getTotalPhysicalMemorySize() / kb;
// 剩余的物理内存
long freePhysicalMemorySize = osmxb.getFreePhysicalMemorySize() / kb;
// 已使用的物理内存
long usedMemory = (osmxb.getTotalPhysicalMemorySize() - osmxb.getFreePhysicalMemorySize()) / kb;
// 获得线程总数
ThreadGroup parentThread;
for (parentThread = Thread.currentThread().getThreadGroup(); parentThread.getParent() != null; parentThread = parentThread.getParent());
int totalThread = parentThread.activeCount();
double cpuRatio = 0;
if (osName.toLowerCase().startsWith("windows")) {
cpuRatio = this.getCpuRatioForWindows();
} else {
cpuRatio = getCpuRateForLinux();
}
// 构造返回对象
MonitorInfoBean infoBean = new MonitorInfoBean();
infoBean.setFreeMemory(freeMemory);
infoBean.setFreePhysicalMemorySize(freePhysicalMemorySize);
infoBean.setMaxMemory(maxMemory);
infoBean.setOsName(osName);
infoBean.setTotalMemory(totalMemory);
infoBean.setTotalMemorySize(totalMemorySize);
infoBean.setTotalThread(totalThread);
infoBean.setUsedMemory(usedMemory);
infoBean.setCpuRatio(cpuRatio);
return infoBean;
}
private static double getCpuRateForLinux() {
InputStream is = null;
InputStreamReader isr = null;
BufferedReader brStat = null;
StringTokenizer tokenStat = null;
try {
System.out.println("Getting usage rate of CPU , linux version: " + linuxVersion);
Process process = Runtime.getRuntime().exec("top -b -n 1");
is = process.getInputStream();
isr = new InputStreamReader(is);
brStat = new BufferedReader(isr);
if (linuxVersion == null || linuxVersion.equals("2.4")) {
brStat.readLine();
brStat.readLine();
brStat.readLine();
brStat.readLine();
tokenStat = new StringTokenizer(brStat.readLine());
tokenStat.nextToken();
tokenStat.nextToken();
String user = tokenStat.nextToken();
tokenStat.nextToken();
String system = tokenStat.nextToken();
tokenStat.nextToken();
String nice = tokenStat.nextToken();
System.out.println(user + " , " + system + " , " + nice);
user = user.substring(0, user.indexOf("%"));
system = system.substring(0, system.indexOf("%"));
nice = nice.substring(0, nice.indexOf("%"));
float userUsage = new Float(user).floatValue();
float systemUsage = new Float(system).floatValue();
float niceUsage = new Float(nice).floatValue();
return (userUsage + systemUsage + niceUsage) / 100;
} else {
brStat.readLine();
brStat.readLine();
tokenStat = new StringTokenizer(brStat.readLine());
tokenStat.nextToken();
tokenStat.nextToken();
tokenStat.nextToken();
tokenStat.nextToken();
tokenStat.nextToken();
tokenStat.nextToken();
tokenStat.nextToken();
String cpuUsage = tokenStat.nextToken();
System.out.println("CPU idle : " + cpuUsage);
Float usage = new Float(cpuUsage.substring(0, cpuUsage.indexOf("%")));
return (1 - usage.floatValue() / 100);
}
} catch (IOException ioe) {
System.out.println(ioe.getMessage());
freeResource(is, isr, brStat);
return 1;
} finally {
freeResource(is, isr, brStat);
}
}
private static void freeResource(InputStream is, InputStreamReader isr,
BufferedReader br) {
try {
if (is != null) {
is.close();
}
if (isr != null) {
isr.close();
}
if (br != null) {
br.close();
}
} catch (IOException ioe) {
System.out.println(ioe.getMessage());
}
}
/**
* 获得CPU使用率.
*
* @return 返回cpu使用率
* @author GuoHuang
*/
private double getCpuRatioForWindows() {
try {
String procCmd = System.getenv("windir") + "\\system32\\wbem\\wmic.exe process get Caption,CommandLine,KernelModeTime,ReadOperationCount,ThreadCount,UserModeTime,WriteOperationCount";
// 取进程信息
long[] c0 = readCpu(Runtime.getRuntime().exec(procCmd));
Thread.sleep(CPUTIME);
long[] c1 = readCpu(Runtime.getRuntime().exec(procCmd));
if (c0 != null && c1 != null) {
long idletime = c1[0] - c0[0];
long busytime = c1[1] - c0[1];
return Double.valueOf(PERCENT * (busytime) / (busytime + idletime)).doubleValue();
} else {
return 0.0;
}
} catch (Exception ex) {
ex.printStackTrace();
return 0.0;
}
}
/**
* 读取CPU信息.
*
* @param proc
* @return
* @author GuoHuang
*/
private long[] readCpu(final Process proc) {
long[] retn = new long[2];
try {
proc.getOutputStream().close();
InputStreamReader ir = new InputStreamReader(proc.getInputStream());
LineNumberReader input = new LineNumberReader(ir);
String line = input.readLine();
if (line == null || line.length() < FAULTLENGTH) {
return null;
}
int capidx = line.indexOf("Caption");
int cmdidx = line.indexOf("CommandLine");
int rocidx = line.indexOf("ReadOperationCount");
int umtidx = line.indexOf("UserModeTime");
int kmtidx = line.indexOf("KernelModeTime");
int wocidx = line.indexOf("WriteOperationCount");
long idletime = 0;
long kneltime = 0;
long usertime = 0;
while ((line = input.readLine()) != null) {
if (line.length() < wocidx) {
continue;
}
// 字段出现顺序Caption,CommandLine,KernelModeTime,ReadOperationCount,
// ThreadCount,UserModeTime,WriteOperation
String caption = Bytes.substring(line, capidx, cmdidx - 1).trim();
String cmd = Bytes.substring(line, cmdidx, kmtidx - 1).trim();
if (cmd.indexOf("wmic.exe") >= 0) {
continue;
}
String s1 = Bytes.substring(line, kmtidx, rocidx - 1).trim();
String s2 = Bytes.substring(line, umtidx, wocidx - 1).trim();
if (caption.equals("System Idle Process") || caption.equals("System")) {
if (s1.length() > 0) {
idletime += Long.parseLong(s1);
}
if (s2.length() > 0) {
idletime += Long.parseLong(s2);
}
continue;
}
if (s1.length() > 0) {
kneltime += Long.parseLong(s1);
}
if (s2.length() > 0) {
usertime += Long.parseLong(s2);
}
}
retn[0] = idletime;
retn[1] = kneltime + usertime;
return retn;
} catch (Exception ex) {
ex.printStackTrace();
} finally {
try {
proc.getInputStream().close();
} catch (Exception e) {
e.printStackTrace();
}
}
return null;
}
/**
* 测试方法.
*
* @param args
* @throws Exception
* @author GuoHuang
*/
public static void main(String[] args) throws Exception {
IMonitorService service = new MonitorServiceImpl();
MonitorInfoBean monitorInfo = service.getMonitorInfoBean();
System.out.println("cpu占有率=" + monitorInfo.getCpuRatio());
System.out.println("可使用内存=" + monitorInfo.getTotalMemory());
System.out.println("剩余内存=" + monitorInfo.getFreeMemory());
System.out.println("最大可使用内存=" + monitorInfo.getMaxMemory());
System.out.println("操作系统=" + monitorInfo.getOsName());
System.out.println("总的物理内存=" + monitorInfo.getTotalMemorySize() + "kb");
System.out.println("剩余的物理内存=" + monitorInfo.getFreeMemory() + "kb");
System.out.println("已使用的物理内存=" + monitorInfo.getUsedMemory() + "kb");
System.out.println("线程总数=" + monitorInfo.getTotalThread() + "kb");
}
}

View File

@@ -0,0 +1,195 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.jackhuang.hellominecraft.svrmgr.utils;
import java.io.File;
import java.util.ArrayList;
import org.jackhuang.hellominecraft.svrmgr.settings.SettingsManager;
/**
*
* @author hyh
*/
public class Utilities {
public static String addSeparator(String path) {
if (path == null || path.trim().length() == 0) {
return "";
}
if (path.charAt(path.length() - 1) == File.separatorChar) {
return path;
} else {
return path + File.separatorChar;
}
}
public static boolean isSeparator(char ch) {
return ch == File.separatorChar || ch == '/' || ch == '\\';
}
public static String removeLastSeparator(String dir) {
String t = dir.trim();
char ch = t.charAt(t.length() - 1);
if (isSeparator(ch)) {
return t.substring(0, t.length() - 1);
}
return t;
}
public static String extractLastDirectory(String dir) {
String t = removeLastSeparator(dir);
int i = t.length() - 1;
while (i >= 0 && !isSeparator(dir.charAt(i))) {
i--;
}
if (i < 0) {
return t;
}
return t.substring(i + 1, (t.length() - i) + (i + 1) - 1);
}
public static ArrayList<String> findAllFile(File f) {
ArrayList<String> arr = new ArrayList<String>();
if (!f.exists()) {
return arr;
}
if (f.isDirectory()) {
File[] f1 = f.listFiles();
int len = f1.length;
for (int i = 0; i < len; i++) {
if (f1[i].isFile()) {
arr.add(f1[i].getName());
}
}
}
return arr;
}
public static ArrayList<String> findAllDir(File f) {
ArrayList<String> arr = new ArrayList<String>();
if (f.isDirectory()) {
File[] f1 = f.listFiles();
int len = f1.length;
for (int i = 0; i < len; i++) {
if (f1[i].isDirectory()) {
arr.add(f1[i].getName());
}
}
}
return arr;
}
public static void deleteAll(File f) {
if (f == null || !f.exists()) {
return;
}
if (f.isFile()) {
f.delete();
} else {
File f1[] = f.listFiles();
int len = f1.length;
for (int i = 0; i < len; i++) {
deleteAll(f1[i]);
}
f.delete();
}
}
public static String extractFileName(String fileName) {
File file = new File(fileName);
return file.getName();
}
public static boolean is16Folder(String path) {
path = Utilities.addSeparator(path);
if (new File(path + "versions").exists()) {
return true;
}
return false;
}
public static boolean isEmpty(String s) {
return s == null || s.trim().equals("");
}
public static int parseInt(String s, int def) {
try {
return Integer.parseInt(s);
} catch (Exception e) {
return def;
}
}
public static int tryParseInteger(String integer, int def) {
try {
return Integer.parseInt(integer);
} catch (NumberFormatException localNumberFormatException) {
return def;
}
}
public static boolean isEquals(String base, String to) {
if (base == null) {
return (to == null);
} else {
return base.equals(to);
}
}
public static String getGameDir() {
String path = new File(SettingsManager.settings.mainjar).getParent();
path = Utilities.addSeparator(path);
return path;
}
public static String getPath(String lastFolder) {
String path = getGameDir();
File file = new File((new StringBuilder()).append(path).append(lastFolder).toString());
if (file.exists()) {
return file.getPath();
} else {
return null;
}
}
public static String try2GetPath(String lastFolder) {
String path = getGameDir();
return (new StringBuilder()).append(path).append(lastFolder).toString();
}
public static String trimExtension(String filename) {
if ((filename != null) && (filename.length() > 0)) {
int i = filename.lastIndexOf('.');
if ((i > -1) && (i < (filename.length()))) {
return filename.substring(0, i);
}
}
return filename;
}
public static boolean openLink(String url) {
boolean isBrowsed = false;
//判断当前系统是否支持Java AWT Desktop扩展
if (java.awt.Desktop.isDesktopSupported()) {
try {
//创建一个URI实例
java.net.URI uri = java.net.URI.create(url);
//获取当前系统桌面扩展
java.awt.Desktop dp = java.awt.Desktop.getDesktop();
//判断系统桌面是否支持要执行的功能
if (dp.isSupported(java.awt.Desktop.Action.BROWSE)) {
//获取系统默认浏览器打开链接
dp.browse(uri);
isBrowsed = true;
}
} catch (java.lang.NullPointerException e) {
//此为uri为空时抛出异常
} catch (java.io.IOException e) {
//此为无法获取系统默认浏览器
}
}
return isBrowsed;
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,147 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.3" maxVersion="1.8" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
<Properties>
<Property name="defaultCloseOperation" type="int" value="2"/>
</Properties>
<SyntheticProperties>
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
</SyntheticProperties>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jPanel1" alignment="0" max="32767" attributes="0"/>
<Component id="jPanel2" alignment="0" max="32767" attributes="0"/>
<Group type="102" alignment="1" attributes="0">
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
<Component id="jButton1" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="jPanel1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jPanel2" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="107" max="32767" attributes="0"/>
<Component id="jButton1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Container class="javax.swing.JPanel" name="jPanel1">
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
<Component id="jTextField1" max="32767" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jTextField1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="jLabel1">
<Properties>
<Property name="text" type="java.lang.String" value="jLabel1"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="jTextField1">
<Properties>
<Property name="text" type="java.lang.String" value="jTextField1"/>
</Properties>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="jPanel2">
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
<Component id="jTextField2" alignment="0" pref="360" max="32767" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jTextField2" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="jLabel2">
<Properties>
<Property name="text" type="java.lang.String" value="jLabel1"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="jTextField2">
<Properties>
<Property name="text" type="java.lang.String" value="jTextField1"/>
</Properties>
</Component>
</SubComponents>
</Container>
<Component class="javax.swing.JButton" name="jButton1">
<Properties>
<Property name="text" type="java.lang.String" value="jButton1"/>
</Properties>
</Component>
</SubComponents>
</Form>

View File

@@ -0,0 +1,234 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.jackhuang.hellominecraft.svrmgr.views;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import javax.swing.GroupLayout;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
/**
*
* @author hyh
*/
public class InputDialog extends javax.swing.JDialog {
ArrayList<JTextField> textFields;
ArrayList<JPanel> panels;
public String[] result;
/**
* Creates new form InputDialog
*/
public InputDialog(java.awt.Frame parent, boolean modal, String[] messages) {
super(parent, modal);
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
textFields = new ArrayList<JTextField>();
panels = new ArrayList<JPanel>();
jButton1 = new javax.swing.JButton();
jButton1.setText("确认");
jButton1.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
result = new String[textFields.size()];
for(int i = 0; i < textFields.size(); i++)
result[i] = textFields.get(i).getText();
InputDialog.this.dispose();
}
});
for(String s : messages) {
makeNewField(s);
}
makeLayout();
Dimension scrSize = Toolkit.getDefaultToolkit().getScreenSize();
setLocation((scrSize.width - this.getWidth()) / 2,
(scrSize.height - this.getHeight()) / 2);
}
void makeNewField(String message) {
JLabel label = new JLabel();
label.setText(message);
JTextField textField = new JTextField();
textField.setText("");
JPanel panel = new JPanel();
javax.swing.GroupLayout jPanelLayout = new javax.swing.GroupLayout(panel);
panel.setLayout(jPanelLayout);
jPanelLayout.setHorizontalGroup(
jPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanelLayout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanelLayout.createSequentialGroup()
.addComponent(label)
.addGap(0, 0, Short.MAX_VALUE))
.addComponent(textField))
.addContainerGap())
);
jPanelLayout.setVerticalGroup(
jPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanelLayout.createSequentialGroup()
.addContainerGap()
.addComponent(label)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(textField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
textFields.add(textField);
panels.add(panel);
}
void makeLayout() {
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
GroupLayout.ParallelGroup g = layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING);
for(JPanel p : panels)
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()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(jButton1));
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(g)
.addContainerGap())
);
GroupLayout.SequentialGroup g2 = layout.createSequentialGroup()
.addContainerGap();
for(JPanel p : panels)
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);
g2 = g2.addComponent(jButton1)
.addContainerGap();
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(g2)
);
pack();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jPanel1 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
jTextField1 = new javax.swing.JTextField();
jPanel2 = new javax.swing.JPanel();
jLabel2 = new javax.swing.JLabel();
jTextField2 = new javax.swing.JTextField();
jButton1 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
jLabel1.setText("jLabel1");
jTextField1.setText("jTextField1");
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jLabel1)
.addGap(0, 0, Short.MAX_VALUE))
.addComponent(jTextField1))
.addContainerGap())
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jLabel2.setText("jLabel1");
jTextField2.setText("jTextField1");
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(jLabel2)
.addGap(0, 0, Short.MAX_VALUE))
.addComponent(jTextField2, javax.swing.GroupLayout.DEFAULT_SIZE, 360, Short.MAX_VALUE))
.addContainerGap())
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jButton1.setText("jButton1");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(jButton1)))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 107, Short.MAX_VALUE)
.addComponent(jButton1)
.addContainerGap())
);
pack();
}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JTextField jTextField1;
private javax.swing.JTextField jTextField2;
// End of variables declaration//GEN-END:variables
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,226 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.5" maxVersion="1.8" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
<Properties>
<Property name="defaultCloseOperation" type="int" value="2"/>
</Properties>
<SyntheticProperties>
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
</SyntheticProperties>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jScrollPane1" alignment="0" pref="368" max="32767" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="lblName" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel3" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="lblDescription" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel5" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="lblAuthors" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel6" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="lblCategories" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel9" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="lblStatus" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel11" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="lblWebsite" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace max="32767" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="jButton1" alignment="1" max="32767" attributes="0"/>
<Component id="jButton2" alignment="1" max="32767" attributes="0"/>
</Group>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblName" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblDescription" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel5" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblAuthors" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel6" alignment="3" min="-2" pref="11" max="-2" attributes="0"/>
<Component id="lblCategories" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel9" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblStatus" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel11" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblWebsite" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<Group type="102" attributes="0">
<Component id="jButton1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jButton2" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Component id="jScrollPane1" pref="159" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="lblAuthors">
<Properties>
<Property name="text" type="java.lang.String" value="jLabel7"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel3">
<Properties>
<Property name="text" type="java.lang.String" value="&#x63cf;&#x8ff0;"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel6">
<Properties>
<Property name="text" type="java.lang.String" value="&#x5206;&#x7c7b;"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel9">
<Properties>
<Property name="text" type="java.lang.String" value="&#x72b6;&#x6001;"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="lblCategories">
<Properties>
<Property name="text" type="java.lang.String" value="jLabel8"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel11">
<Properties>
<Property name="text" type="java.lang.String" value="&#x7f51;&#x5740;"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="lblStatus">
<Properties>
<Property name="text" type="java.lang.String" value="jLabel10"/>
</Properties>
</Component>
<Container class="javax.swing.JScrollPane" name="jScrollPane1">
<AuxValues>
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
</AuxValues>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
<Component class="javax.swing.JTable" name="lstPluginInfo">
<Properties>
<Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.editors2.TableModelEditor">
<Table columnCount="5" rowCount="0">
<Column editable="true" title="&#x65e5;&#x671f;" type="java.lang.String"/>
<Column editable="true" title="&#x7248;&#x672c;" type="java.lang.String"/>
<Column editable="true" title="&#x6587;&#x4ef6;" type="java.lang.String"/>
<Column editable="true" title="Bukkit&#x7248;&#x672c;" type="java.lang.String"/>
<Column editable="true" title="&#x7c7b;&#x578b;" type="java.lang.String"/>
</Table>
</Property>
<Property name="tableHeader" type="javax.swing.table.JTableHeader" editor="org.netbeans.modules.form.editors2.JTableHeaderEditor">
<TableHeader reorderingAllowed="true" resizingAllowed="true"/>
</Property>
</Properties>
</Component>
</SubComponents>
</Container>
<Component class="javax.swing.JLabel" name="lblWebsite">
<Properties>
<Property name="text" type="java.lang.String" value="jLabel12"/>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="jButton1">
<Properties>
<Property name="text" type="java.lang.String" value="&#x5b89;&#x88c5;&#x9009;&#x4e2d;"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton1ActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="jButton2">
<Properties>
<Property name="text" type="java.lang.String" value="&#x5173;&#x95ed;&#x7a97;&#x53e3;"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton2ActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="lblDescription">
<Properties>
<Property name="text" type="java.lang.String" value="jLabel4"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel1">
<Properties>
<Property name="text" type="java.lang.String" value="&#x540d;&#x5b57;"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel5">
<Properties>
<Property name="text" type="java.lang.String" value="&#x4f5c;&#x8005;"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="lblName">
<Properties>
<Property name="text" type="java.lang.String" value="jLabel2"/>
</Properties>
</Component>
</SubComponents>
</Form>

View File

@@ -0,0 +1,247 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.jackhuang.hellominecraft.svrmgr.views;
import java.io.File;
import javax.swing.table.DefaultTableModel;
import org.jackhuang.hellominecraft.tasks.TaskWindow;
import org.jackhuang.hellominecraft.tasks.download.FileDownloadTask;
import org.jackhuang.hellominecraft.utils.StrUtils;
import org.jackhuang.hellominecraft.svrmgr.cbplugins.PluginInfo;
import org.jackhuang.hellominecraft.svrmgr.cbplugins.PluginVersion;
import org.jackhuang.hellominecraft.svrmgr.utils.Utilities;
/**
*
* @author hyh
*/
public class PluginInfoDialog extends javax.swing.JDialog {
PluginInfo pi;
/**
* Creates new form PluginInfoDialog
*/
public PluginInfoDialog(java.awt.Frame parent, boolean modal, PluginInfo pi) {
super(parent, modal);
initComponents();
this.pi = pi;
lblName.setText(pi.plugin_name);
lblDescription.setText(pi.description);
lblStatus.setText(pi.stage);
lblAuthors.setText(StrUtils.parseParams("", pi.authors.toArray(), ", "));
lblCategories.setText(StrUtils.parseParams("", pi.categories.toArray(), ", "));
lblWebsite.setText(pi.link);
//SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
DefaultTableModel model = (DefaultTableModel) lstPluginInfo.getModel();
for (PluginVersion v : pi.versions) {
model.addRow(new Object[]{
v.date, v.version, v.filename, StrUtils.parseParams("", v.game_versions.toArray(), ", "),
v.type
});
}
lstPluginInfo.updateUI();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
lblAuthors = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jLabel9 = new javax.swing.JLabel();
lblCategories = new javax.swing.JLabel();
jLabel11 = new javax.swing.JLabel();
lblStatus = new javax.swing.JLabel();
jScrollPane1 = new javax.swing.JScrollPane();
lstPluginInfo = new javax.swing.JTable();
lblWebsite = new javax.swing.JLabel();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
lblDescription = new javax.swing.JLabel();
jLabel1 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
lblName = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
lblAuthors.setText("jLabel7");
jLabel3.setText("描述");
jLabel6.setText("分类");
jLabel9.setText("状态");
lblCategories.setText("jLabel8");
jLabel11.setText("网址");
lblStatus.setText("jLabel10");
lstPluginInfo.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
},
new String [] {
"日期", "版本", "文件", "Bukkit版本", "类型"
}
) {
Class[] types = new Class [] {
java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class
};
public Class getColumnClass(int columnIndex) {
return types [columnIndex];
}
});
jScrollPane1.setViewportView(lstPluginInfo);
lblWebsite.setText("jLabel12");
jButton1.setText("安装选中");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jButton2.setText("关闭窗口");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
lblDescription.setText("jLabel4");
jLabel1.setText("名字");
jLabel5.setText("作者");
lblName.setText("jLabel2");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 368, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(lblName))
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel3)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(lblDescription))
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel5)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(lblAuthors))
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel6)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(lblCategories))
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel9)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(lblStatus))
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel11)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(lblWebsite)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jButton1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1)
.addComponent(lblName))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3)
.addComponent(lblDescription))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel5)
.addComponent(lblAuthors))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 11, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblCategories))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel9)
.addComponent(lblStatus))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel11)
.addComponent(lblWebsite)))
.addGroup(layout.createSequentialGroup()
.addComponent(jButton1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton2)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 159, Short.MAX_VALUE)
.addContainerGap())
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
this.dispose();
}//GEN-LAST:event_jButton2ActionPerformed
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
int index = lstPluginInfo.getSelectedRow();
if (index == -1) {
return;
}
String url = pi.versions.get(index).download;
TaskWindow.getInstance()
.addTask(new FileDownloadTask(url, new File(Utilities.getGameDir() + "plugins"
+ File.separator + pi.versions.get(index).filename)))
.start();
}//GEN-LAST:event_jButton1ActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel9;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JLabel lblAuthors;
private javax.swing.JLabel lblCategories;
private javax.swing.JLabel lblDescription;
private javax.swing.JLabel lblName;
private javax.swing.JLabel lblStatus;
private javax.swing.JLabel lblWebsite;
private javax.swing.JTable lstPluginInfo;
// End of variables declaration//GEN-END:variables
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

View File

@@ -0,0 +1,16 @@
<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
<head>
<title>Hello Minecraft! 开服器</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
</body>
</html>

View File

@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN" packages="net.teamtf,org.jackhuang">
<Appenders>
<Console name="SysOut" target="SYSTEM_OUT">
<PatternLayout pattern="[%d{HH:mm:ss}] [%t/%level]: %msg%n" />
</Console>
<RollingRandomAccessFile name="File" fileName="hmcsm.log" filePattern="hmcllogs/%d{yyyy-MM-dd}-%i.log.gz">
<PatternLayout pattern="[%d{HH:mm:ss}] [%t/%level]: %msg%n" />
<Policies>
<TimeBasedTriggeringPolicy />
<OnStartupTriggeringPolicy />
</Policies>
</RollingRandomAccessFile>
</Appenders>
<Loggers>
<Root level="info">
<filters>
<MarkerFilter marker="NETWORK_PACKETS" onMatch="DENY" onMismatch="NEUTRAL" />
</filters>
<AppenderRef ref="SysOut"/>
<AppenderRef ref="File"/>
</Root>
</Loggers>
</Configuration>

View File

@@ -0,0 +1,48 @@
\u540d\u79f0=\u540d\u79f0
\u4fdd\u5b58\u5931\u8d25=\u4fdd\u5b58\u5931\u8d25
\u4fdd\u5b58\u538b\u7f29\u5305\u5230=\u4fdd\u5b58\u538b\u7f29\u5305\u5230
\u9009\u62e9\u6750\u8d28\u5305=\u9009\u62e9\u6750\u8d28\u5305
\u9009\u62e9\u8d44\u6e90\u5305=\u9009\u62e9\u8d44\u6e90\u5305
\u9009\u62e9\u5e93/\u6a21\u7ec4=\u9009\u62e9\u5e93/\u6a21\u7ec4
\u6ca1\u6709\u9009\u4e2d\u4efb\u4f55\u4e00\u4e2a\u5e93/\u6a21\u7ec4\u3002=\u6ca1\u6709\u9009\u4e2d\u4efb\u4f55\u4e00\u4e2a\u5e93/\u6a21\u7ec4\u3002
\u5220\u9664\u5931\u8d25=\u5220\u9664\u5931\u8d25
\u6dfb\u52a0\u5931\u8d25=\u6dfb\u52a0\u5931\u8d25
\u9009\u62e9\u6a21\u7ec4=\u9009\u62e9\u6a21\u7ec4
\u7248\u672c\u540d\u79f0\u4e0d\u80fd\u4e3a\u7a7a=\u7248\u672c\u540d\u79f0\u4e0d\u80fd\u4e3a\u7a7a
\u5907\u4efd\u5230=\u5907\u4efd\u5230
\u662fCOREODS\u6587\u4ef6\u5939\u5185\u7684\u6240\u6709\u6838\u5fc3\u6a21\u7ec4=\u662fCoremods\u6587\u4ef6\u5939\u5185\u7684\u6240\u6709\u6838\u5fc3\u6a21\u7ec4
\u662fMODS\u6587\u4ef6\u5939\u5185\u7684\u6240\u6709\u6a21\u7ec4=\u662fMods\u6587\u4ef6\u5939\u5185\u7684\u6240\u6709\u6a21\u7ec4
\u901a\u5e38\u662f\u6a21\u7ec4=\u901a\u5e38\u662f\u6a21\u7ec4
\u4e0b\u79fb=\u4e0b\u79fb
\u4e0a\u79fb=\u4e0a\u79fb
\u5220\u9664=\u5220\u9664
\u589e\u52a0=\u589e\u52a0
\u901a\u5e38\u662fFORGE,MODLOADER\u4ee5\u53caMINECRAFT\u6240\u4f9d\u8d56\u7684\u5e93=\u901a\u5e38\u662fForge,Modloader\u4ee5\u53caMinecraft\u6240\u4f9d\u8d56\u7684\u5e93
\u9644\u52a0\u542f\u52a8\u53c2\u6570=\u9644\u52a0\u542f\u52a8\u53c2\u6570
\u81ea\u5b9a\u4e49\u5e93\u6587\u4ef6\u5939(LIBRARIES\u6587\u4ef6\u5939)=\u81ea\u5b9a\u4e49\u5e93\u6587\u4ef6\u5939(libraries\u6587\u4ef6\u5939)
\u4e3b\u7c7b=\u4e3b\u7c7b
\u81ea\u5b9a\u4e49\u8d44\u6e90\u6587\u4ef6\u5939(ASSETS\u6587\u4ef6\u5939)=\u81ea\u5b9a\u4e49\u8d44\u6e90\u6587\u4ef6\u5939(assets\u6587\u4ef6\u5939)
\u624b\u52a8\u8bbe\u7f6e=\u624b\u52a8\u8bbe\u7f6e
\u4e0d\u5f3a\u5236=\u4e0d\u5f3a\u5236
32\u4f4d=32\u4f4d
64\u4f4d=64\u4f4d
\u542f\u52a8\u6a21\u5f0f=\u542f\u52a8\u6a21\u5f0f
\u73a9\u5bb6\u540d=\u73a9\u5bb6\u540d
1.6\u53ca\u4ee5\u4e0a\u7248\u672c\u4ee5\u53ca\u5bfc\u5165\u7684\u65e7\u7248\u672c=1.6\u53ca\u4ee5\u4e0a\u7248\u672c\u4ee5\u53ca\u5bfc\u5165\u7684\u65e7\u7248\u672c
\u6700\u5927\u5185\u5b58=\u6700\u5927\u5185\u5b58
JAVA\u865a\u62df\u673a\u53c2\u6570=Java\u865a\u62df\u673a\u53c2\u6570
JAVA\u8def\u5f84=Java\u8def\u5f84
\u5168\u5c4f=\u5168\u5c4f
\u5206\u8fa8\u7387=\u5206\u8fa8\u7387
\u6e38\u620f\u8def\u5f84=\u6e38\u620f\u8def\u5f84
\u4ee5\u4e0b\u8bbe\u7f6e\u5b57\u6bb5\u4e3a\u7a7a\u4ee3\u8868\u7740\u4f7f\u7528\u9ed8\u8ba4\u8bbe\u7f6e=\u9664\u540d\u79f0\u4ee5\u4e0b\u5b57\u6bb5\u53ef\u4ee5\u4e0d\u586b
\u53d6\u6d88=\u53d6\u6d88
\u786e\u5b9a=\u786e\u5b9a
game_download=\u6e38\u620f\u4e0b\u8f7d
public_settings=\u5168\u5c40\u8bbe\u7f6e
invalid=\u65e0\u6548\u7684
invalid_jar=\u65e0\u6548\u7684jar\u5305
not_a_file=\u4e0d\u662f\u6587\u4ef6
not_found=\u627e\u4e0d\u5230minecraft.jar
not_readable=minecraft.jar\u4e0d\u53ef\u8bfb
modified=(\u4fee\u6539\u7684!)

View File

@@ -0,0 +1,46 @@
\u540d\u79f0=Name
\u4fdd\u5b58\u5931\u8d25=Failed to save
\u4fdd\u5b58\u538b\u7f29\u5305\u5230=Save zip file to
\u9009\u62e9\u6750\u8d28\u5305=Choose texture pack
\u9009\u62e9\u8d44\u6e90\u5305=Choose resource pack
\u9009\u62e9\u5e93/\u6a21\u7ec4=Choose library/mod
\u6ca1\u6709\u9009\u4e2d\u4efb\u4f55\u4e00\u4e2a\u5e93/\u6a21\u7ec4\u3002=Not selected any library/mod.
\u5220\u9664\u5931\u8d25=Failed to delete
\u6dfb\u52a0\u5931\u8d25=Failed to add
\u9009\u62e9\u6a21\u7ec4=Choose mod
\u7248\u672c\u540d\u79f0\u4e0d\u80fd\u4e3a\u7a7a=Version name cannot be empty.
\u5907\u4efd\u5230=Backup to
\u662fCOREODS\u6587\u4ef6\u5939\u5185\u7684\u6240\u6709\u6838\u5fc3\u6a21\u7ec4=They're all the core mods in coremods folder.
\u662fMODS\u6587\u4ef6\u5939\u5185\u7684\u6240\u6709\u6a21\u7ec4=They're all the mods in mods folder.
\u901a\u5e38\u662f\u6a21\u7ec4=Usually mods.
\u4e0b\u79fb=Down
\u4e0a\u79fb=Up
\u5220\u9664=Delete
\u589e\u52a0=Add
\u901a\u5e38\u662fFORGE,MODLOADER\u4ee5\u53caMINECRAFT\u6240\u4f9d\u8d56\u7684\u5e93=They're usually Forge, Modloader and libraries.
\u9644\u52a0\u542f\u52a8\u53c2\u6570=Addition launch arguments
\u81ea\u5b9a\u4e49\u5e93\u6587\u4ef6\u5939(LIBRARIES\u6587\u4ef6\u5939)=Custom libraries folder
\u4e3b\u7c7b=Main class
\u81ea\u5b9a\u4e49\u8d44\u6e90\u6587\u4ef6\u5939(ASSETS\u6587\u4ef6\u5939)=Custom assets folder
\u624b\u52a8\u8bbe\u7f6e=manually set
\u4e0d\u5f3a\u5236=Default
32\u4f4d=32\u4f4d
64\u4f4d=64\u4f4d
\u542f\u52a8\u6a21\u5f0f=Launch mode
\u73a9\u5bb6\u540d=Player name
1.6\u53ca\u4ee5\u4e0a\u7248\u672c\u4ee5\u53ca\u5bfc\u5165\u7684\u65e7\u7248\u672c=Version 1.6 and above, and imported the old version
\u6700\u5927\u5185\u5b58=Max memory
JAVA\u865a\u62df\u673a\u53c2\u6570=JVM arguments
JAVA\u8def\u5f84=Java path
\u5168\u5c4f=Fullscreen
\u5206\u8fa8\u7387=Resolution
\u6e38\u620f\u8def\u5f84=Game dir
\u4ee5\u4e0b\u8bbe\u7f6e\u5b57\u6bb5\u4e3a\u7a7a\u4ee3\u8868\u7740\u4f7f\u7528\u9ed8\u8ba4\u8bbe\u7f6e=These field could not fill except the name field.
\u53d6\u6d88=Cancel
\u786e\u5b9a=Ok
invalid=invalid
invalid_jar=invalid jar
not_a_file=not a file
not_found=not found
not_readable=not readable
modified=(modified!)

View File

@@ -0,0 +1,48 @@
\u540d\u79f0=\u540d\u79f0
\u4fdd\u5b58\u5931\u8d25=\u4fdd\u5b58\u5931\u8d25
\u4fdd\u5b58\u538b\u7f29\u5305\u5230=\u4fdd\u5b58\u538b\u7f29\u5305\u5230
\u9009\u62e9\u6750\u8d28\u5305=\u9009\u62e9\u6750\u8d28\u5305
\u9009\u62e9\u8d44\u6e90\u5305=\u9009\u62e9\u8d44\u6e90\u5305
\u9009\u62e9\u5e93/\u6a21\u7ec4=\u9009\u62e9\u5e93/\u6a21\u7ec4
\u6ca1\u6709\u9009\u4e2d\u4efb\u4f55\u4e00\u4e2a\u5e93/\u6a21\u7ec4\u3002=\u6ca1\u6709\u9009\u4e2d\u4efb\u4f55\u4e00\u4e2a\u5e93/\u6a21\u7ec4\u3002
\u5220\u9664\u5931\u8d25=\u5220\u9664\u5931\u8d25
\u6dfb\u52a0\u5931\u8d25=\u6dfb\u52a0\u5931\u8d25
\u9009\u62e9\u6a21\u7ec4=\u9009\u62e9\u6a21\u7ec4
\u7248\u672c\u540d\u79f0\u4e0d\u80fd\u4e3a\u7a7a=\u7248\u672c\u540d\u79f0\u4e0d\u80fd\u4e3a\u7a7a
\u5907\u4efd\u5230=\u5907\u4efd\u5230
\u662fCOREODS\u6587\u4ef6\u5939\u5185\u7684\u6240\u6709\u6838\u5fc3\u6a21\u7ec4=\u662fCoremods\u6587\u4ef6\u5939\u5185\u7684\u6240\u6709\u6838\u5fc3\u6a21\u7ec4
\u662fMODS\u6587\u4ef6\u5939\u5185\u7684\u6240\u6709\u6a21\u7ec4=\u662fMods\u6587\u4ef6\u5939\u5185\u7684\u6240\u6709\u6a21\u7ec4
\u901a\u5e38\u662f\u6a21\u7ec4=\u901a\u5e38\u662f\u6a21\u7ec4
\u4e0b\u79fb=\u4e0b\u79fb
\u4e0a\u79fb=\u4e0a\u79fb
\u5220\u9664=\u5220\u9664
\u589e\u52a0=\u589e\u52a0
\u901a\u5e38\u662fFORGE,MODLOADER\u4ee5\u53caMINECRAFT\u6240\u4f9d\u8d56\u7684\u5e93=\u901a\u5e38\u662fForge,Modloader\u4ee5\u53caMinecraft\u6240\u4f9d\u8d56\u7684\u5e93
\u9644\u52a0\u542f\u52a8\u53c2\u6570=\u9644\u52a0\u542f\u52a8\u53c2\u6570
\u81ea\u5b9a\u4e49\u5e93\u6587\u4ef6\u5939(LIBRARIES\u6587\u4ef6\u5939)=\u81ea\u5b9a\u4e49\u5e93\u6587\u4ef6\u5939(libraries\u6587\u4ef6\u5939)
\u4e3b\u7c7b=\u4e3b\u7c7b
\u81ea\u5b9a\u4e49\u8d44\u6e90\u6587\u4ef6\u5939(ASSETS\u6587\u4ef6\u5939)=\u81ea\u5b9a\u4e49\u8d44\u6e90\u6587\u4ef6\u5939(assets\u6587\u4ef6\u5939)
\u624b\u52a8\u8bbe\u7f6e=\u624b\u52a8\u8bbe\u7f6e
\u4e0d\u5f3a\u5236=\u4e0d\u5f3a\u5236
32\u4f4d=32\u4f4d
64\u4f4d=64\u4f4d
\u542f\u52a8\u6a21\u5f0f=\u542f\u52a8\u6a21\u5f0f
\u73a9\u5bb6\u540d=\u73a9\u5bb6\u540d
1.6\u53ca\u4ee5\u4e0a\u7248\u672c\u4ee5\u53ca\u5bfc\u5165\u7684\u65e7\u7248\u672c=1.6\u53ca\u4ee5\u4e0a\u7248\u672c\u4ee5\u53ca\u5bfc\u5165\u7684\u65e7\u7248\u672c
\u6700\u5927\u5185\u5b58=\u6700\u5927\u5185\u5b58
JAVA\u865a\u62df\u673a\u53c2\u6570=Java\u865a\u62df\u673a\u53c2\u6570
JAVA\u8def\u5f84=Java\u8def\u5f84
\u5168\u5c4f=\u5168\u5c4f
\u5206\u8fa8\u7387=\u5206\u8fa8\u7387
\u6e38\u620f\u8def\u5f84=\u6e38\u620f\u8def\u5f84
\u4ee5\u4e0b\u8bbe\u7f6e\u5b57\u6bb5\u4e3a\u7a7a\u4ee3\u8868\u7740\u4f7f\u7528\u9ed8\u8ba4\u8bbe\u7f6e=\u9664\u540d\u79f0\u4ee5\u4e0b\u5b57\u6bb5\u53ef\u4ee5\u4e0d\u586b
\u53d6\u6d88=\u53d6\u6d88
\u786e\u5b9a=\u786e\u5b9a
game_download=\u6e38\u620f\u4e0b\u8f7d
public_settings=\u5168\u5c40\u8bbe\u7f6e
invalid=\u65e0\u6548\u7684
invalid_jar=\u65e0\u6548\u7684jar\u5305
not_a_file=\u4e0d\u662f\u6587\u4ef6
not_found=\u627e\u4e0d\u5230minecraft.jar
not_readable=minecraft.jar\u4e0d\u53ef\u8bfb
modified=(\u4fee\u6539\u7684!)

View File

@@ -0,0 +1,48 @@
\u540d\u79f0=\u540d\u7a31
\u4fdd\u5b58\u5931\u8d25=\u4fdd\u5b58\u5931\u6557
\u4fdd\u5b58\u538b\u7f29\u5305\u5230=\u4fdd\u5b58\u58d3\u7e2e\u5305\u5230
\u9009\u62e9\u6750\u8d28\u5305=\u9078\u64c7\u6750\u8cea\u5305
\u9009\u62e9\u8d44\u6e90\u5305=\u9078\u64c7\u8cc7\u6e90\u5305
\u9009\u62e9\u5e93/\u6a21\u7ec4=\u9078\u64c7\u5eab/\u6a21\u7d44
\u6ca1\u6709\u9009\u4e2d\u4efb\u4f55\u4e00\u4e2a\u5e93/\u6a21\u7ec4\u3002=\u6c92\u6709\u9078\u4e2d\u4efb\u4f55\u4e00\u500b\u5eab/\u6a21\u7d44\u3002
\u5220\u9664\u5931\u8d25=\u522a\u9664\u5931\u6557
\u6dfb\u52a0\u5931\u8d25=\u6dfb\u52a0\u5931\u6557
\u9009\u62e9\u6a21\u7ec4=\u9078\u64c7\u6a21\u7d44
\u7248\u672c\u540d\u79f0\u4e0d\u80fd\u4e3a\u7a7a=\u7248\u672c\u540d\u7a31\u4e0d\u80fd\u70ba\u7a7a
\u5907\u4efd\u5230=\u5099\u4efd\u5230
\u662fCOREODS\u6587\u4ef6\u5939\u5185\u7684\u6240\u6709\u6838\u5fc3\u6a21\u7ec4=\u662fCoremods\u6587\u4ef6\u593e\u5167\u7684\u6240\u6709\u6838\u5fc3\u6a21\u7d44
\u662fMODS\u6587\u4ef6\u5939\u5185\u7684\u6240\u6709\u6a21\u7ec4=\u662fMods\u6587\u4ef6\u593e\u5167\u7684\u6240\u6709\u6a21\u7d44
\u901a\u5e38\u662f\u6a21\u7ec4=\u901a\u5e38\u662f\u6a21\u7d44
\u4e0b\u79fb=\u4e0b\u79fb
\u4e0a\u79fb=\u4e0a\u79fb
\u5220\u9664=\u522a\u9664
\u589e\u52a0=\u589e\u52a0
\u901a\u5e38\u662fFORGE,MODLOADER\u4ee5\u53caMINECRAFT\u6240\u4f9d\u8d56\u7684\u5e93=\u901a\u5e38\u662fForge,Modloader\u4ee5\u53caMinecraft\u6240\u4f9d\u8cf4\u7684\u5eab
\u9644\u52a0\u542f\u52a8\u53c2\u6570=\u9644\u52a0\u555f\u52d5\u53c3\u6578
\u81ea\u5b9a\u4e49\u5e93\u6587\u4ef6\u5939(LIBRARIES\u6587\u4ef6\u5939)=\u81ea\u5b9a\u7fa9\u5eab\u8cc7\u6599\u593e(libraries\u8cc7\u6599\u593e)
\u4e3b\u7c7b=\u4e3b\u7c7b
\u81ea\u5b9a\u4e49\u8d44\u6e90\u6587\u4ef6\u5939(ASSETS\u6587\u4ef6\u5939)=\u81ea\u5b9a\u7fa9\u8cc7\u6e90\u8cc7\u6599\u593e(assets\u8cc7\u6599\u593e)
\u624b\u52a8\u8bbe\u7f6e=\u624b\u52d5\u8a2d\u5b9a
\u4e0d\u5f3a\u5236=\u4e0d\u5f37\u5236
32\u4f4d=32\u4f4d
64\u4f4d=64\u4f4d
\u542f\u52a8\u6a21\u5f0f=\u555f\u52d5\u6a21\u5f0f
\u73a9\u5bb6\u540d=\u73a9\u5bb6\u540d
1.6\u53ca\u4ee5\u4e0a\u7248\u672c\u4ee5\u53ca\u5bfc\u5165\u7684\u65e7\u7248\u672c=1.6\u53ca\u4ee5\u4e0a\u7248\u672c\u4ee5\u53ca\u5c0e\u5165\u7684\u820a\u7248\u672c
\u6700\u5927\u5185\u5b58=\u6700\u5927\u5167\u5b58
JAVA\u865a\u62df\u673a\u53c2\u6570=Java\u865b\u64ec\u6a5f\u53c3\u6578
JAVA\u8def\u5f84=Java\u8def\u5f91
\u5168\u5c4f=\u5168\u5c4f
\u5206\u8fa8\u7387=\u5206\u8fa8\u7387
\u6e38\u620f\u8def\u5f84=\u904a\u6232\u8def\u5f91
\u4ee5\u4e0b\u8bbe\u7f6e\u5b57\u6bb5\u4e3a\u7a7a\u4ee3\u8868\u7740\u4f7f\u7528\u9ed8\u8ba4\u8bbe\u7f6e=\u9664\u540d\u7a31\u4ee5\u4e0b\u5b57\u6bb5\u53ef\u4ee5\u4e0d\u586b
\u53d6\u6d88=\u53d6\u6d88
\u786e\u5b9a=\u78ba\u5b9a
game_download=\u904a\u6232\u4e0b\u8f09
public_settings=\u5168\u5c40\u8a2d\u5b9a
invalid=\u7121\u6548\u7684
invalid_jar=\u7121\u6548\u7684jar\u5305
not_a_file=\u4e0d\u662f\u6587\u4ef6
not_found=\u627e\u4e0d\u5230minecraft.jar
not_readable=minecraft.jar\u4e0d\u53ef\u8b80
modified=(\u4fee\u6539\u7684!)