This commit is contained in:
huanghongxun
2015-11-17 12:51:04 +08:00
parent 39b6d68006
commit 159a992081
243 changed files with 2990 additions and 2836 deletions

View File

@@ -56,8 +56,8 @@ public class Main {
HMCLog.warn("Failed to set look and feel", ex);
}
new UpdateChecker(new VersionNumber(firstVer, secondVer, thirdVer), "hmcsm", () -> {
SwingUtilities.invokeLater(() -> MessageBox.Show("发现更新!"));
}).start();
SwingUtilities.invokeLater(() -> MessageBox.Show("发现更新!"));
}).start();
new MainWindow().setVisible(true);
} catch (Throwable t) {
HMCLog.err("There's something wrong when running server holder.", t);

View File

@@ -23,8 +23,9 @@ import java.util.List;
* @author huangyuhui
*/
public class PluginInfo {
public String website, dbo_page, description, slug, plugin_name,
link, stage, main;
link, stage, main;
public List<String> authors, categories;
public List<PluginVersion> versions;
}

View File

@@ -51,32 +51,32 @@ public class PluginManager {
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());
}.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";
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());
}.getType());
return list;
}
@@ -84,7 +84,7 @@ public class PluginManager {
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());
}.getType());
return list;
}

View File

@@ -53,7 +53,8 @@ public class BukkitFormatThread extends Thread {
allforge.addAll(table.getElementsByTag("tr"));
for (Element e : allforge) {
Elements tds = e.getElementsByTag("td");
if (tds.isEmpty()) continue;
if (tds.isEmpty())
continue;
BukkitVersion v = new BukkitVersion();
Elements ths = e.getElementsByTag("th");
v.buildNumber = v.infoLink = null;
@@ -66,7 +67,8 @@ public class BukkitFormatThread extends Thread {
}
v.version = tds.get(0).text();
v.type = tds.get(1).text();
if (tds.get(2).getElementsByTag("a").isEmpty()) continue;
if (tds.get(2).getElementsByTag("a").isEmpty())
continue;
v.downloadLink = "http://dl.bukkit.org" + tds.get(2).getElementsByTag("a").get(0).attr("href");
formattedList.add(v);
}

View File

@@ -21,7 +21,7 @@ package org.jackhuang.hellominecraft.svrmgr.installer.bukkit;
* @author huangyuhui
*/
public class BukkitVersion {
public String buildNumber, version, type, downloadLink, infoLink;
}

View File

@@ -56,7 +56,8 @@ public class ForgeFormatThread extends Thread {
allforge.addAll(table.getElementsByTag("tr"));
for (Element e : allforge) {
Elements tds = e.getElementsByTag("td");
if (tds.isEmpty()) continue;
if (tds.isEmpty())
continue;
ForgeVersion v = new ForgeVersion();
v.ver = tds.get(0).text();
v.mcver = tds.get(1).text();
@@ -74,8 +75,10 @@ public class ForgeFormatThread extends Thread {
v.changelog = href;
else if (prev != null) {
int index;
if (href.contains("adf.ly")) index = 0;
else index = 1;
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"))

View File

@@ -74,7 +74,7 @@ public class ForgeInstaller {
entry = zipFile.getEntry(profile.install.filePath);
InputStream is = zipFile.getInputStream(entry);
//MinecraftLibrary forge = new MinecraftLibrary(profile.install.path);
//MinecraftLibrary forge = new MinecraftLibrary(profile.install.path);
//forge.format();
File file = new File(gameDir, profile.install.filePath);
file.getParentFile().mkdirs();
@@ -85,11 +85,10 @@ public class ForgeInstaller {
}
File minecraftserver = new File(gameDir, "minecraft_server." + profile.install.minecraft + ".jar");
if (minecraftserver.exists() && JOptionPane.showConfirmDialog(null, "已发现官方服务端文件,是否要重新下载?") == JOptionPane.YES_OPTION) {
if (minecraftserver.exists() && JOptionPane.showConfirmDialog(null, "已发现官方服务端文件,是否要重新下载?") == JOptionPane.YES_OPTION)
if (!TaskWindow.getInstance().addTask(new FileDownloadTask("https://s3.amazonaws.com/Minecraft.Download/versions/{MCVER}/minecraft_server.{MCVER}.jar".replace("{MCVER}", profile.install.minecraft),
minecraftserver).setTag("minecraft_server")).start())
minecraftserver).setTag("minecraft_server")).start())
MessageBox.Show("Minecraft官方服务端下载失败");
}
TaskWindow.TaskWindowFactory tw = TaskWindow.getInstance();
for (MinecraftLibrary library : profile.versionInfo.libraries) {
library.init();
@@ -101,11 +100,12 @@ public class ForgeInstaller {
}
if (!tw.start())
MessageBox.Show("压缩库下载失败!");
tw = TaskWindow.getInstance();
for (MinecraftLibrary library : profile.versionInfo.libraries) {
File packxz = new File(gameDir, "libraries" + File.separator + library.formatted + ".pack.xz");
if (packxz.exists()) return;
if (packxz.exists())
return;
File lib = new File(gameDir, "libraries" + File.separator + library.formatted);
lib.getParentFile().mkdirs();
String libURL = "https://libraries.minecraft.net/";
@@ -115,7 +115,7 @@ public class ForgeInstaller {
}
if (!tw.start())
MessageBox.Show("库下载失败!");
ArrayList<String> badLibs = new ArrayList<>();
for (MinecraftLibrary library : profile.versionInfo.libraries) {
File lib = new File(gameDir, "libraries" + File.separator + library.formatted);
@@ -135,7 +135,7 @@ public class ForgeInstaller {
}
public static void unpackLibrary(File output, byte[] data)
throws IOException {
throws IOException {
if (output.exists())
output.delete();
@@ -153,13 +153,13 @@ public class ForgeInstaller {
byte[] checksums = Arrays.copyOfRange(decompressed, decompressed.length - len - 8, decompressed.length - 8);
try (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();
}
}
@@ -185,10 +185,10 @@ public class ForgeInstaller {
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();

View File

@@ -34,7 +34,7 @@ public class MinecraftLibrary {
str = s[0];
str = str.replace('.', File.separatorChar);
str += File.separator + s[1] + File.separator + s[2]
+ File.separator + s[1] + '-' + s[2] + ".jar";
+ File.separator + s[1] + '-' + s[2] + ".jar";
formatted = str;
}
}

View File

@@ -25,7 +25,7 @@ import java.util.List;
public class MinecraftVersion {
public String minecraftArguments, mainClass, time, id, type, processArguments,
releaseTime, assets, jar, inheritsFrom;
releaseTime, assets, jar, inheritsFrom;
public int minimumLauncherVersion;
public List<MinecraftLibrary> libraries;

View File

@@ -75,7 +75,7 @@ public class ScheduleTranslator {
}
public static Object[] getRow(Schedule s) {
return new Object[]{
return new Object[] {
getName(s), getTimeTypeName(s), s.per, s.content
};
}

View File

@@ -53,7 +53,7 @@ import org.jackhuang.hellominecraft.utils.functions.Consumer;
* @author huangyuhui
*/
public class Server implements Event<Integer>, MonitorThread.MonitorThreadListener,
ActionListener {
ActionListener {
private static Server instance;
private static boolean disactived = false;
@@ -112,7 +112,7 @@ public class Server implements Event<Integer>, MonitorThread.MonitorThreadListen
jvmPath = IOUtils.getJavaDir();
else
jvmPath = SettingsManager.settings.javaDir;
String[] puts = new String[]{
String[] puts = new String[] {
jvmPath,
"-Xmx" + memory + "m",
"-jar",
@@ -124,8 +124,8 @@ public class Server implements Event<Integer>, MonitorThread.MonitorThreadListen
pb.directory(new File(SettingsManager.settings.mainjar).getParentFile());
try {
disactiveMods(SettingsManager.settings.inactiveExtMods,
SettingsManager.settings.inactiveCoreMods,
SettingsManager.settings.inactivePlugins);
SettingsManager.settings.inactiveCoreMods,
SettingsManager.settings.inactivePlugins);
server = pb.start();
registerThread(threadA, server.getInputStream());
registerThread(threadB, server.getErrorStream());
@@ -206,7 +206,8 @@ public class Server implements Event<Integer>, MonitorThread.MonitorThreadListen
private void registerThreadC(Process p) {
threadC = new WaitForThread(p);
for (Event<Integer> l : listenersC) threadC.event.register(l);
for (Event<Integer> l : listenersC)
threadC.event.register(l);
threadC.event.register(this);
threadC.start();
}
@@ -221,9 +222,13 @@ public class Server implements Event<Integer>, MonitorThread.MonitorThreadListen
System.err.println("Server crashed(exit code: " + t + ")");
}
isRunning = false;
for (Schedule schedule : schedules) if (schedule.timeType == Schedule.TIME_TYPE_SERVER_STOPPED) ScheduleTranslator.translate(this, schedule).run();
if (timer != null) timer.cancel();
if (pastTimer != null) pastTimer.stop();
for (Schedule schedule : schedules)
if (schedule.timeType == Schedule.TIME_TYPE_SERVER_STOPPED)
ScheduleTranslator.translate(this, schedule).run();
if (timer != null)
timer.cancel();
if (pastTimer != null)
pastTimer.stop();
restoreMods();
if (isRestart) {
try {
@@ -238,7 +243,7 @@ public class Server implements Event<Integer>, MonitorThread.MonitorThreadListen
}
private static void disactiveMods(ArrayList<String> inactiveExtMods,
ArrayList<String> inactiveCoreMods, ArrayList<String> inactivePlugins) {
ArrayList<String> inactiveCoreMods, ArrayList<String> inactivePlugins) {
disactiveModsByType(inactiveExtMods, "mods");
disactiveModsByType(inactiveCoreMods, "coremods");
disactiveModsByType(inactivePlugins, "plugins");
@@ -256,11 +261,12 @@ public class Server implements Event<Integer>, MonitorThread.MonitorThreadListen
System.out.println("没有文件: " + paramString);
return;
}
for (File file : files) if (!file.isDirectory()) {
for (File file : files)
if (!file.isDirectory()) {
String name = file.getName();
if ((!paramArrayOfString.contains(name))
|| ((!name.toLowerCase().endsWith(".zip")) && (!name.toLowerCase().endsWith(".jar"))))
|| ((!name.toLowerCase().endsWith(".zip")) && (!name.toLowerCase().endsWith(".jar"))))
continue;
String newName = name + "X";
@@ -278,8 +284,10 @@ public class Server implements Event<Integer>, MonitorThread.MonitorThreadListen
private static void restoreModsByType(String paramString) {
System.out.println("还原被禁用的文件: " + paramString);
File[] files = new File(Utilities.getGameDir(), paramString).listFiles();
if (files == null) return;
for (File file : files) if (!file.isDirectory()) {
if (files == null)
return;
for (File file : files)
if (!file.isDirectory()) {
String name = file.getName();
String lowName = name.toLowerCase();
if ((!lowName.endsWith(".zipx")) && (!lowName.endsWith(".jarx")))
@@ -289,9 +297,8 @@ public class Server implements Event<Integer>, MonitorThread.MonitorThreadListen
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());
else if (!file.renameTo(newFile))
System.out.println("无法重命名: " + file.getName() + " 到: " + newFile.getName() + " 在: " + file.getParent());
}
}
@@ -346,7 +353,8 @@ public class Server implements Event<Integer>, MonitorThread.MonitorThreadListen
ScheduleTranslator.translate(this, schedules.get(i)).run();
continue;
}
if (schedules.get(i).timeType != Schedule.TIME_TYPE_PER) 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);
@@ -360,7 +368,9 @@ public class Server implements Event<Integer>, MonitorThread.MonitorThreadListen
}
if (status.length() > 20)
if (status.substring(20).contains("[SEVERE] This crash report has been saved to: "))
for (Schedule schedule : schedules) if (schedule.timeType == Schedule.TIME_TYPE_SERVER_CRASHED) ScheduleTranslator.translate(this, schedule).run();
for (Schedule schedule : schedules)
if (schedule.timeType == Schedule.TIME_TYPE_SERVER_CRASHED)
ScheduleTranslator.translate(this, schedule).run();
}
GregorianCalendar c = new GregorianCalendar();
@@ -368,15 +378,19 @@ public class Server implements Event<Integer>, MonitorThread.MonitorThreadListen
@Override
public void actionPerformed(ActionEvent e) {
c.setTime(new Date());
if (c.get(Calendar.SECOND) != 0) return;
if (c.get(Calendar.SECOND) != 0)
return;
int minute = c.get(Calendar.MINUTE);
for (Schedule schedule : schedules) {
if (schedule.timeType != Schedule.TIME_TYPE_PAST_HOUR) continue;
if (schedule.per == minute) ScheduleTranslator.translate(this, schedule).run();
if (schedule.timeType != Schedule.TIME_TYPE_PAST_HOUR)
continue;
if (schedule.per == minute)
ScheduleTranslator.translate(this, schedule).run();
}
}
private void sendStatus(String status) {
for (MonitorThread.MonitorThreadListener l : listeners) l.onStatus(status);
for (MonitorThread.MonitorThreadListener l : listeners)
l.onStatus(status);
}
}

View File

@@ -49,7 +49,7 @@ public class BackupManager {
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");
backupDir() + "world+" + f.format(new Date()) + "+" + folder + ".zip");
} catch (IOException ex) {
HMCLog.warn("Failed to compress world pack.", ex);
}
@@ -101,7 +101,7 @@ public class BackupManager {
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");
backupDir() + "plugin+" + f.format(new Date()) + "+plugins.zip");
} catch (IOException ex) {
HMCLog.warn("Failed to compress world pack with plugins.", ex);
}

View File

@@ -19,15 +19,16 @@ 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 huangyuhui
*/
public class AutoRestartSchedule extends TimerTask {
Schedule main;
Server server;
public AutoRestartSchedule(Schedule s, Server s2) {
main = s;
server = s2;

View File

@@ -71,7 +71,8 @@ public abstract class PlayerList<T extends BasePlayer> {
String[] lines = s.split("\n");
op = new HashSet<T>();
for (String l : lines) {
if (l.startsWith("#")) continue;
if (l.startsWith("#"))
continue;
T player = newPlayer(l);
if (StrUtils.isBlank(l))
continue;

View File

@@ -23,19 +23,19 @@ package org.jackhuang.hellominecraft.svrmgr.settings;
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;
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;
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;
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;

View File

@@ -228,38 +228,38 @@ public class ServerProperties {
public static String getDefault() {
return "generator-settings=\n"
+ "op-permission-level=4\n"
+ "allow-nether=true\n"
+ "level-name=world\n"
+ "enable-query=false\n"
+ "allow-flight=false\n"
+ "announce-player-achievements=true\n"
+ "server-port=25565\n"
+ "level-type=DEFAULT\n"
+ "enable-rcon=false\n"
+ "force-gamemode=false\n"
+ "level-seed=\n"
+ "server-ip=\n"
+ "max-build-height=256\n"
+ "spawn-npcs=true\n"
+ "white-list=false\n"
+ "spawn-animals=true\n"
+ "hardcore=false\n"
+ "snooper-enabled=true\n"
+ "online-mode=false\n"
+ "resource-pack=\n"
+ "pvp=true\n"
+ "difficulty=1\n"
+ "server-name=Unknown Server\n"
+ "enable-command-block=false\n"
+ "gamemode=0\n"
+ "player-idle-timeout=0\n"
+ "max-players=20\n"
+ "spawn-monsters=true\n"
+ "generate-structures=true\n"
+ "view-distance=10\n"
+ "spawn-protection=16\n"
+ "motd=A Minecraft Server";
+ "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

@@ -28,7 +28,7 @@ public class Settings {
public String maxMemory;
public String mainjar, bgPath, javaDir, javaArgs;
public ArrayList<String> inactiveExtMods, inactiveCoreMods, inactivePlugins,
inactiveWorlds;
inactiveWorlds;
public ArrayList<Schedule> schedules;
public Settings() {

View File

@@ -29,40 +29,40 @@ import org.jackhuang.hellominecraft.HMCLog;
* @author huangyuhui
*/
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<>(5);
try {
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)
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

@@ -26,7 +26,8 @@ public interface IMonitorService {
* 获得当前的监控对象.
*
* @return 返回构造好的监控对象
*
* @throws Exception
*/
public MonitorInfoBean getMonitorInfoBean() throws Exception;
}
}

View File

@@ -50,7 +50,8 @@ public class ModType {
java.util.Enumeration e = zipFile.entries();
while (e.hasMoreElements()) {
ZipEntry zipEnt = (ZipEntry) e.nextElement();
if (zipEnt.isDirectory()) continue;
if (zipEnt.isDirectory())
continue;
gbkPath = zipEnt.getName();
if ("mcmod.info".equals(gbkPath))
return ForgeMod;

View File

@@ -42,6 +42,7 @@ public class MonitorServiceImpl implements IMonitorService {
* 获得当前的监控对象.
*
* @return 返回构造好的监控对象
*
* @throws Exception
* @author GuoHuang
*/
@@ -144,7 +145,7 @@ public class MonitorServiceImpl implements IMonitorService {
}
private static void freeResource(InputStream is, InputStreamReader isr,
BufferedReader br) {
BufferedReader br) {
try {
if (is != null)
is.close();
@@ -161,6 +162,7 @@ public class MonitorServiceImpl implements IMonitorService {
* 获得CPU使用率.
*
* @return 返回cpu使用率
*
* @author GuoHuang
*/
private double getCpuRatioForWindows() {
@@ -186,7 +188,9 @@ public class MonitorServiceImpl implements IMonitorService {
* 读取CPU信息.
*
* @param proc
*
* @return
*
* @author GuoHuang
*/
private long[] readCpu(final Process proc) {
@@ -249,6 +253,7 @@ public class MonitorServiceImpl implements IMonitorService {
* 测试方法.
*
* @param args
*
* @throws Exception
* @author GuoHuang
*/

View File

@@ -27,14 +27,12 @@ import org.jackhuang.hellominecraft.svrmgr.settings.SettingsManager;
public class Utilities {
public static String addSeparator(String path) {
if (path == null || path.trim().length() == 0) {
if (path == null || path.trim().length() == 0)
return "";
}
if (path.charAt(path.length() - 1) == File.separatorChar) {
if (path.charAt(path.length() - 1) == File.separatorChar)
return path;
} else {
else
return path + File.separatorChar;
}
}
public static boolean isSeparator(char ch) {
@@ -44,37 +42,31 @@ public class Utilities {
public static String removeLastSeparator(String dir) {
String t = dir.trim();
char ch = t.charAt(t.length() - 1);
if (isSeparator(ch)) {
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))) {
while (i >= 0 && !isSeparator(dir.charAt(i)))
i--;
}
if (i < 0) {
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<>();
if (!f.exists()) {
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()) {
for (int i = 0; i < len; i++)
if (f1[i].isFile())
arr.add(f1[i].getName());
}
}
}
return arr;
}
@@ -84,27 +76,23 @@ public class Utilities {
if (f.isDirectory()) {
File[] f1 = f.listFiles();
int len = f1.length;
for (int i = 0; i < len; i++) {
if (f1[i].isDirectory()) {
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()) {
if (f == null || !f.exists())
return;
}
if (f.isFile()) {
if (f.isFile())
f.delete();
} else {
else {
File f1[] = f.listFiles();
int len = f1.length;
for (int i = 0; i < len; i++) {
for (int i = 0; i < len; i++)
deleteAll(f1[i]);
}
f.delete();
}
}
@@ -130,6 +118,7 @@ public class Utilities {
return def;
}
}
public static int tryParseInteger(String integer, int def) {
try {
return Integer.parseInt(integer);
@@ -139,11 +128,10 @@ public class Utilities {
}
public static boolean isEquals(String base, String to) {
if (base == null) {
if (base == null)
return (to == null);
} else {
else
return base.equals(to);
}
}
public static String getGameDir() {
@@ -155,11 +143,10 @@ public class Utilities {
public static String getPath(String lastFolder) {
String path = getGameDir();
File file = new File((new StringBuilder()).append(path).append(lastFolder).toString());
if (file.exists()) {
if (file.exists())
return file.getPath();
} else {
else
return null;
}
}
public static String try2GetPath(String lastFolder) {
@@ -171,9 +158,8 @@ public class Utilities {
public static String trimExtension(String filename) {
if ((filename != null) && (filename.length() > 0)) {
int i = filename.lastIndexOf('.');
if ((i > -1) && (i < (filename.length()))) {
if ((i > -1) && (i < (filename.length())))
return filename.substring(0, i);
}
}
return filename;
}
@@ -181,7 +167,7 @@ public class Utilities {
public static boolean openLink(String url) {
boolean isBrowsed = false;
//判断当前系统是否支持Java AWT Desktop扩展
if (java.awt.Desktop.isDesktopSupported()) {
if (java.awt.Desktop.isDesktopSupported())
try {
//创建一个URI实例
java.net.URI uri = java.net.URI.create(url);
@@ -197,8 +183,6 @@ public class Utilities {
//此为uri为空时抛出异常
//此为无法获取系统默认浏览器
}
}
return isBrowsed;
}
}

View File

@@ -58,7 +58,7 @@ public class InputDialog extends javax.swing.JDialog {
makeLayout();
Dimension scrSize = Toolkit.getDefaultToolkit().getScreenSize();
setLocation((scrSize.width - this.getWidth()) / 2,
(scrSize.height - this.getHeight()) / 2);
(scrSize.height - this.getHeight()) / 2);
}
final void makeNewField(String message) {
@@ -71,24 +71,24 @@ public class InputDialog extends javax.swing.JDialog {
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.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))
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);
@@ -101,25 +101,25 @@ public class InputDialog extends javax.swing.JDialog {
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));
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(jButton1));
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(g)
.addContainerGap())
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(g)
.addContainerGap())
);
GroupLayout.SequentialGroup g2 = layout.createSequentialGroup()
.addContainerGap();
.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);
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED);
g2 = g2.addComponent(jButton1)
.addContainerGap();
.addContainerGap();
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(g2)
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(g2)
);
pack();

View File

@@ -94,7 +94,7 @@ import org.jackhuang.hellominecraft.utils.Event;
* @author huangyuhui
*/
public final class MainWindow extends javax.swing.JFrame
implements MonitorThread.MonitorThreadListener, Event<Integer> {
implements MonitorThread.MonitorThreadListener, Event<Integer> {
ImageIcon background = new ImageIcon(getClass().getResource("/background.jpg"));
JLabel backgroundLabel;
@@ -133,7 +133,7 @@ public final class MainWindow extends javax.swing.JFrame
Dimension scrSize = Toolkit.getDefaultToolkit().getScreenSize();
setLocation((scrSize.width - this.getWidth()) / 2,
(scrSize.height - this.getHeight()) / 2);
(scrSize.height - this.getHeight()) / 2);
this.setIconImage(new ImageIcon(getClass().getResource("/icon.png")).getImage());
@@ -258,7 +258,7 @@ public final class MainWindow extends javax.swing.JFrame
@Override
public void actionPerformed(ActionEvent e) {
InputDialog id = new InputDialog(MainWindow.this, true, new String[]{"玩家", "讯息"});
InputDialog id = new InputDialog(MainWindow.this, true, new String[] {"玩家", "讯息"});
id.setVisible(true);
Server.getInstance().sendCommand("tell " + id.result[0] + " " + id.result[1]);
}
@@ -432,7 +432,7 @@ public final class MainWindow extends javax.swing.JFrame
@Override
public void actionPerformed(ActionEvent e) {
InputDialog id = new InputDialog(MainWindow.this, true, new String[]{
InputDialog id = new InputDialog(MainWindow.this, true, new String[] {
"要调整的天气只能填clear[意思是取消所有天气]或rain[意思是下雨]或thunder[意思是打雷]",
"时间"
});
@@ -487,7 +487,7 @@ public final class MainWindow extends javax.swing.JFrame
@Override
public void actionPerformed(ActionEvent e) {
InputDialog id = new InputDialog(MainWindow.this, true, new String[]{"玩家", "物品ID", "数量"});
InputDialog id = new InputDialog(MainWindow.this, true, new String[] {"玩家", "物品ID", "数量"});
id.setVisible(true);
if (id.result != null)
Server.getInstance().sendCommand("give " + id.result[0] + " " + id.result[1] + " " + id.result[2]);
@@ -2938,27 +2938,32 @@ public final class MainWindow extends javax.swing.JFrame
void loadFromOPs() {
File mainjar = new File(SettingsManager.settings.mainjar);
if (!mainjar.exists()) return;
if (!mainjar.exists())
return;
File folder = mainjar.getParentFile();
op = new Op();
op.initByBoth(new File(folder, "ops.txt"), new File(folder, "ops.json"));
for (Op.Operator ss : op.op) lstOPModel.addElement(ss.name);
for (Op.Operator ss : op.op)
lstOPModel.addElement(ss.name);
lstOP.setModel(lstOPModel);
}
void loadFromWhiteList() {
File mainjar = new File(SettingsManager.settings.mainjar);
if (!mainjar.exists()) return;
if (!mainjar.exists())
return;
File folder = mainjar.getParentFile();
whitelist = new WhiteList();
whitelist.initByBoth(new File(folder, "white-list.txt"), new File(folder, "white-list.json"));
for (WhiteList.WhiteListPlayer ss : whitelist.op) lstWhiteListModel.addElement(ss.name);
for (WhiteList.WhiteListPlayer ss : whitelist.op)
lstWhiteListModel.addElement(ss.name);
lstWhiteList.setModel(lstWhiteListModel);
}
void loadFromBannedPlayers() {
File mainjar = new File(SettingsManager.settings.mainjar);
if (!mainjar.exists()) return;
if (!mainjar.exists())
return;
File folder = mainjar.getParentFile();
banned = new BannedPlayers();
banned.initByBoth(new File(folder, "banned-players.txt"), new File(folder, "banned-players.json"));
@@ -2969,13 +2974,14 @@ public final class MainWindow extends javax.swing.JFrame
void loadLocalMods() {
String path = Utilities.getPath("mods");
if (path == null) return;
if (path == null)
return;
ArrayList<String> sl = Utilities.findAllFile(new File(path));
DefaultTableModel model = (DefaultTableModel) lstExternalMods.getModel();
while (model.getRowCount() > 0)
model.removeRow(0);
for (String s : sl)
model.addRow(new Object[]{!SettingsManager.settings.inactiveExtMods.contains(s), s, ModType.getModTypeShowName(ModType.getModType(Utilities.addSeparator(path) + s))});
model.addRow(new Object[] {!SettingsManager.settings.inactiveExtMods.contains(s), s, ModType.getModTypeShowName(ModType.getModType(Utilities.addSeparator(path) + s))});
lstExternalMods.updateUI();
}
@@ -2991,11 +2997,11 @@ public final class MainWindow extends javax.swing.JFrame
for (String s : sl) {
PluginInformation p = PluginManager.getPluginYML(new File(Utilities.getGameDir() + "plugins" + File.separator + s));
if (p == null)
model.addRow(new Object[]{!SettingsManager.settings.inactivePlugins.contains(s), s,
"", "", "", ""});
model.addRow(new Object[] {!SettingsManager.settings.inactivePlugins.contains(s), s,
"", "", "", ""});
else
model.addRow(new Object[]{!SettingsManager.settings.inactivePlugins.contains(s), s,
p.name, p.version, p.author, p.description});
model.addRow(new Object[] {!SettingsManager.settings.inactivePlugins.contains(s), s,
p.name, p.version, p.author, p.description});
}
lstPlugins.updateUI();
@@ -3010,7 +3016,7 @@ public final class MainWindow extends javax.swing.JFrame
while (model.getRowCount() > 0)
model.removeRow(0);
for (String s : sl)
model.addRow(new Object[]{!SettingsManager.settings.inactiveCoreMods.contains(s), s, ModType.getModTypeShowName(ModType.getModType(Utilities.addSeparator(path) + s))});
model.addRow(new Object[] {!SettingsManager.settings.inactiveCoreMods.contains(s), s, ModType.getModTypeShowName(ModType.getModType(Utilities.addSeparator(path) + s))});
lstCoreMods.updateUI();
}
@@ -3021,7 +3027,7 @@ public final class MainWindow extends javax.swing.JFrame
if (SettingsManager.settings.inactiveWorlds == null)
SettingsManager.settings.inactiveWorlds = new ArrayList<>();
for (String world : s)
model.addRow(new Object[]{
model.addRow(new Object[] {
world, Utilities.getGameDir() + world, !SettingsManager.settings.inactiveWorlds.contains(world)
});
lstWorlds.updateUI();
@@ -3032,7 +3038,7 @@ public final class MainWindow extends javax.swing.JFrame
DefaultTableModel model = (DefaultTableModel) lstBackups.getModel();
for (String backup : al) {
String[] names = Utilities.trimExtension(backup).split("\\+");
model.addRow(new Object[]{
model.addRow(new Object[] {
names[0], names[1], names[2]
});
}
@@ -3054,27 +3060,28 @@ public final class MainWindow extends javax.swing.JFrame
void loadBukkits() {
int idx = cboBukkitType.getSelectedIndex();
if (idx == -1) return;
if (idx == -1)
return;
if (idx == 1) {
BukkitFormatThread thread = new BukkitFormatThread(
"http://dl.bukkit.org/downloads/craftbukkit/list/beta/", value -> {
craftBukkitBeta = value;
reloadBukkitList();
});
"http://dl.bukkit.org/downloads/craftbukkit/list/beta/", value -> {
craftBukkitBeta = value;
reloadBukkitList();
});
thread.start();
} else if (idx == 0) {
BukkitFormatThread thread = new BukkitFormatThread(
"http://dl.bukkit.org/downloads/craftbukkit/list/rb/", value -> {
craftBukkitRecommended = value;
reloadBukkitList();
});
"http://dl.bukkit.org/downloads/craftbukkit/list/rb/", value -> {
craftBukkitRecommended = value;
reloadBukkitList();
});
thread.start();
} else if (idx == 2) {
BukkitFormatThread thread = new BukkitFormatThread(
"http://dl.bukkit.org/downloads/craftbukkit/list/dev/", value -> {
craftBukkitDev = value;
reloadBukkitList();
});
"http://dl.bukkit.org/downloads/craftbukkit/list/dev/", value -> {
craftBukkitDev = value;
reloadBukkitList();
});
thread.start();
}
}
@@ -3104,7 +3111,7 @@ public final class MainWindow extends javax.swing.JFrame
while (model.getRowCount() > 0)
model.removeRow(0);
for (ForgeVersion v : mcpcPackages.get(ver)) {
Object[] row = new Object[]{
Object[] row = new Object[] {
v.mcver, v.ver, v.releasetime
};
model.addRow(row);
@@ -3131,7 +3138,7 @@ public final class MainWindow extends javax.swing.JFrame
while (model.getRowCount() > 0)
model.removeRow(0);
for (BukkitVersion v : list) {
Object[] row = new Object[]{
Object[] row = new Object[] {
v.buildNumber, v.version
};
model.addRow(row);
@@ -3185,13 +3192,14 @@ public final class MainWindow extends javax.swing.JFrame
ArrayList<String> al = Utilities.findAllFile(new File(Utilities.getGameDir() + "infos-HMCSM"));
DefaultTableModel model = (DefaultTableModel) lstInfos.getModel();
for (String s : al)
model.addRow(new Object[]{s, Utilities.trimExtension(s)});
model.addRow(new Object[] {s, Utilities.trimExtension(s)});
lstInfos.updateUI();
}
void refreshReports() {
ArrayList<String> al = Utilities.findAllFile(new File(Utilities.getGameDir() + "crash-reports"));
for (String s : al) lstCrashReportsModel.addElement(s);
for (String s : al)
lstCrashReportsModel.addElement(s);
lstReports.setModel(lstCrashReportsModel);
}
@@ -3217,7 +3225,7 @@ public final class MainWindow extends javax.swing.JFrame
l = PluginManager.getPluginsByCategory(cboCategory.getSelectedItem().toString());
plugins = l;
for (BukkitPlugin p : l)
model.addRow(new Object[]{
model.addRow(new Object[] {
p.plugin_name, p.description, p.getLatestVersion(), p.getLatestBukkit()
});
lstBukkitPlugins.updateUI();
@@ -3266,7 +3274,8 @@ public final class MainWindow extends javax.swing.JFrame
s.getPlayerNumber(t -> {
lblPlayers.setText("在线人数" + t.key);
lstPlayersModel.clear();
for (String s1 : t.value) lstPlayersModel.addElement(s1);
for (String s1 : t.value)
lstPlayersModel.addElement(s1);
lstPlayers.setModel(lstPlayersModel);
});
else
@@ -3329,11 +3338,11 @@ public final class MainWindow extends javax.swing.JFrame
Server.init(SettingsManager.settings.mainjar, String.valueOf(SettingsManager.settings.maxMemory));
Server.getInstance()
.addListener((MonitorThread.MonitorThreadListener) this);
.addListener((MonitorThread.MonitorThreadListener) this);
Server.getInstance()
.addListener((Event<Integer>) this);
.addListener((Event<Integer>) this);
Server.getInstance()
.clearSchedule();
.clearSchedule();
for (Schedule s : SettingsManager.settings.schedules)
Server.getInstance().addSchedule(s);
@@ -3583,7 +3592,7 @@ public final class MainWindow extends javax.swing.JFrame
FileUtils.copyFile(new File(path), newf);
DefaultTableModel model = (DefaultTableModel) lstExternalMods.getModel();
model.addRow(new Object[]{fc.getSelectedFile().getName(), ModType.getModTypeShowName(ModType.getModType(newf))});
model.addRow(new Object[] {fc.getSelectedFile().getName(), ModType.getModTypeShowName(ModType.getModType(newf))});
lstExternalMods.updateUI();
} catch (IOException e) {
MessageBox.Show(bundle.getString("添加失败"));
@@ -3624,7 +3633,7 @@ public final class MainWindow extends javax.swing.JFrame
DefaultTableModel model = (DefaultTableModel) lstCoreMods.getModel();
lstCoreMods.updateUI();
model.addRow(new Object[]{fc.getSelectedFile().getName(), ModType.getModTypeShowName(ModType.getModType(newf))});
model.addRow(new Object[] {fc.getSelectedFile().getName(), ModType.getModTypeShowName(ModType.getModType(newf))});
FileUtils.copyFile(new File(path), newf);
} catch (IOException e) {
MessageBox.Show(java.util.ResourceBundle.getBundle("org/jackhuang/hellominecraftlauncher/VersionSettingsWindow").getString("添加失败"));
@@ -3666,7 +3675,7 @@ public final class MainWindow extends javax.swing.JFrame
DefaultTableModel model = (DefaultTableModel) lstPlugins.getModel();
lstPlugins.updateUI();
model.addRow(new Object[]{fc.getSelectedFile().getName(), ModType.getModTypeShowName(ModType.getModType(newf))});
model.addRow(new Object[] {fc.getSelectedFile().getName(), ModType.getModTypeShowName(ModType.getModType(newf))});
FileUtils.copyFile(new File(path), newf);
} catch (IOException e) {
MessageBox.Show(java.util.ResourceBundle.getBundle("org/jackhuang/hellominecraftlauncher/VersionSettingsWindow").getString("添加失败"));
@@ -3860,9 +3869,9 @@ public final class MainWindow extends javax.swing.JFrame
return;
DefaultTableModel model = (DefaultTableModel) lstBackups.getModel();
Utilities.deleteAll(new File(BackupManager.backupDir()
+ model.getValueAt(index, 0) + "+"
+ model.getValueAt(index, 1) + "+"
+ model.getValueAt(index, 2) + ".zip"));
+ model.getValueAt(index, 0) + "+"
+ model.getValueAt(index, 1) + "+"
+ model.getValueAt(index, 2) + ".zip"));
model.removeRow(index);
}//GEN-LAST:event_btnDeleteBackupActionPerformed
@@ -3872,9 +3881,9 @@ public final class MainWindow extends javax.swing.JFrame
return;
DefaultTableModel model = (DefaultTableModel) lstBackups.getModel();
BackupManager.restoreBackup(BackupManager.backupDir()
+ model.getValueAt(index, 0) + "+"
+ model.getValueAt(index, 1) + "+"
+ model.getValueAt(index, 2) + ".zip");
+ model.getValueAt(index, 0) + "+"
+ model.getValueAt(index, 1) + "+"
+ model.getValueAt(index, 2) + ".zip");
}//GEN-LAST:event_btnRestoreBackupActionPerformed
private void btnRefreshDownloadsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRefreshDownloadsActionPerformed
@@ -4024,7 +4033,7 @@ public final class MainWindow extends javax.swing.JFrame
BukkitVersion v = cb.get(idx);
File file = new File(IOUtils.currentDir(), "craftbukkit-" + ext + "-" + v.version + ".jar");
TaskWindow.getInstance().addTask(new FileDownloadTask(v.downloadLink, IOUtils.tryGetCanonicalFile(file)).setTag("bukkit-" + ext + "-" + v.version))
.start();
.start();
}//GEN-LAST:event_btnDownloadCraftbukkitActionPerformed
private void btnDownloadMCPCActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDownloadMCPCActionPerformed
@@ -4133,8 +4142,8 @@ public final class MainWindow extends javax.swing.JFrame
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH-mm-ss");
try {
FileUtils.write(new File(Utilities.getGameDir() + "infos-HMCSM"
+ File.separator + format.format(new Date()) + ".txt"),
txtMain.getText());
+ File.separator + format.format(new Date()) + ".txt"),
txtMain.getText());
} catch (IOException ex) {
HMCLog.warn("Failed to save info", ex);
}
@@ -4168,10 +4177,10 @@ public final class MainWindow extends javax.swing.JFrame
MonitorThread mainThread;
DefaultListModel lstOPModel = new DefaultListModel(),
lstWhiteListModel = new DefaultListModel(),
lstBannedModel = new DefaultListModel(),
lstCrashReportsModel = new DefaultListModel(),
lstPlayersModel = new DefaultListModel();
lstWhiteListModel = new DefaultListModel(),
lstBannedModel = new DefaultListModel(),
lstCrashReportsModel = new DefaultListModel(),
lstPlayersModel = new DefaultListModel();
List<BukkitPlugin> plugins;
Map<String, List<ForgeVersion>> mcpcPackages;
List<BukkitVersion> craftBukkitRecommended, craftBukkitBeta, craftBukkitDev;

View File

@@ -49,7 +49,7 @@ public class PluginInfoDialog extends javax.swing.JDialog {
//SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
DefaultTableModel model = (DefaultTableModel) lstPluginInfo.getModel();
for (PluginVersion v : pi.versions)
model.addRow(new Object[]{
model.addRow(new Object[] {
v.date, v.version, v.filename, StrUtils.parseParams("", v.game_versions.toArray(), ", "),
v.type
});
@@ -231,9 +231,9 @@ public class PluginInfoDialog extends javax.swing.JDialog {
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();
.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

View File

@@ -11,6 +11,6 @@ and open the template in the editor.
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
</body>
</html>