Fixed null when invoking some server commands

This commit is contained in:
huangyuhui 2016-03-04 20:18:25 +08:00
parent 587df1f5bb
commit 5d4a3c1df6
3 changed files with 35 additions and 24 deletions

View File

@ -7,15 +7,17 @@ branches:
before_deploy: before_deploy:
- git config --global user.email ${GITHUB_EMAIL} - git config --global user.email ${GITHUB_EMAIL}
- git config --global user.name ${GITHUB_NAME} - git config --global user.name ${GITHUB_NAME}
- git tag ${VERSION_ROOT}.${TRAVIS_BUILD_NUMBER} - git tag ${TRAVIS_BUILD_NUMBER}
- git push -q ${REPO} --tags - git push -q ${REPO} --tags
deploy: deploy:
provider: releases provider: releases
api_key: api_key:
secure: lfFEwKtij/s9Ao/SKL7oVdsWcfASshZuwT27gllMrTx1ZQqLCG2I5mGJOp5ukx7lb3y4Tu316nFasLjy9NI3eLXSx9f0w4q+wMf0K5Yj9iOwu/TIn7JkLyHDMQ20qRwGxZplS2WUb669gIRg+l6jUHeTBW+dlTxr0mMa6WHIl8UDpHwfFrGC3i6dL4y6WlDwGl2rYktvOoA/iqvtglBcHuXaL2sDfhp5MXRcYULTIw+b9zmiQXP665DQN+Su5I3gwB4y5X8RH72GAacZn13fEIo5i8UUoHM7UQxM8y8DKSO3avyFCfpUle9+9sErQVW7b6JV1c+AoLWuAhNJLMlUTKarZE7UMqfjvoQHxX5hp2B2WHLEON/UJiGf25HJWx6VhJitE0/odujqnG/umesqki2jMTs6gPcxbc9iBjzUg+ZmFztdtC+Emnni7lpqVVl+Y5hsJRn3Z6rIiNgwmaE0r2OQgAm1vRYFc7jvOdRfyFG+uCRZF6nS56BzJ7dLc0WW8dTgSft6YFll4ZYL6hiI9qiIaBAK948y5HV+6VBWuO3xf/G2CUFbE1Y9qUCjToh3ahxNDzZvXB+rXqvlvNQOi5l8n594oQ61n45qIHSKlMBn9Bxhw29oWT5mo1aYIaNXbpzKam2w4mK0T3VrgTszu/3282wRbNr+VAwdGMfwW1s= secure: lfFEwKtij/s9Ao/SKL7oVdsWcfASshZuwT27gllMrTx1ZQqLCG2I5mGJOp5ukx7lb3y4Tu316nFasLjy9NI3eLXSx9f0w4q+wMf0K5Yj9iOwu/TIn7JkLyHDMQ20qRwGxZplS2WUb669gIRg+l6jUHeTBW+dlTxr0mMa6WHIl8UDpHwfFrGC3i6dL4y6WlDwGl2rYktvOoA/iqvtglBcHuXaL2sDfhp5MXRcYULTIw+b9zmiQXP665DQN+Su5I3gwB4y5X8RH72GAacZn13fEIo5i8UUoHM7UQxM8y8DKSO3avyFCfpUle9+9sErQVW7b6JV1c+AoLWuAhNJLMlUTKarZE7UMqfjvoQHxX5hp2B2WHLEON/UJiGf25HJWx6VhJitE0/odujqnG/umesqki2jMTs6gPcxbc9iBjzUg+ZmFztdtC+Emnni7lpqVVl+Y5hsJRn3Z6rIiNgwmaE0r2OQgAm1vRYFc7jvOdRfyFG+uCRZF6nS56BzJ7dLc0WW8dTgSft6YFll4ZYL6hiI9qiIaBAK948y5HV+6VBWuO3xf/G2CUFbE1Y9qUCjToh3ahxNDzZvXB+rXqvlvNQOi5l8n594oQ61n45qIHSKlMBn9Bxhw29oWT5mo1aYIaNXbpzKam2w4mK0T3VrgTszu/3282wRbNr+VAwdGMfwW1s=
file: file:
- HMCL/build/libs/HMCL-${VERSION_ROOT}.${TRAVIS_BUILD_NUMBER}.jar - HMCL/build/libs/HMCL-${HMCL_VERSION_ROOT}.${TRAVIS_BUILD_NUMBER}.jar
- HMCL/build/libs/HMCL-${VERSION_ROOT}.${TRAVIS_BUILD_NUMBER}.exe - HMCL/build/libs/HMCL-${HMCL_VERSION_ROOT}.${TRAVIS_BUILD_NUMBER}.exe
- HMCSM/build/libs/HMCSM-${HMCSM_VERSION_ROOT}.${TRAVIS_BUILD_NUMBER}.jar
- HMCSM/build/libs/HMCSM-${HMCSM_VERSION_ROOT}.${TRAVIS_BUILD_NUMBER}.exe
on: on:
repo: huanghongxun/HMCL repo: huanghongxun/HMCL
tags: false tags: false

View File

@ -40,7 +40,7 @@ public class Main {
public static String launcherName = "Hello Minecraft! Server Manager"; public static String launcherName = "Hello Minecraft! Server Manager";
public static final String PUBLISH_URL = "http://www.mcbbs.net/thread-171239-1-1.html"; public static final String PUBLISH_URL = "http://www.mcbbs.net/thread-171239-1-1.html";
public static final byte VERSION_FIRST = 0, VERSION_SECOND = 8, VERSION_THIRD = 6; public static final byte VERSION_FIRST = 0, VERSION_SECOND = 8, VERSION_THIRD = 7;
public static final UpdateChecker UPDATE_CHECKER = new UpdateChecker(new VersionNumber(VERSION_FIRST, VERSION_SECOND, VERSION_THIRD), "hmcsm"); public static final UpdateChecker UPDATE_CHECKER = new UpdateChecker(new VersionNumber(VERSION_FIRST, VERSION_SECOND, VERSION_THIRD), "hmcsm");
public static String makeTitle() { public static String makeTitle() {

View File

@ -209,14 +209,23 @@ public final class MainWindow extends javax.swing.JFrame
//<editor-fold defaultstate="collapsed" desc="基本信息菜单"> //<editor-fold defaultstate="collapsed" desc="基本信息菜单">
class ActionListenerImpl implements ActionListener { class ActionListenerImpl implements ActionListener {
String s; String s, q;
public ActionListenerImpl(String s) { public ActionListenerImpl(String s) {
this(s, null);
}
public ActionListenerImpl(String s, String question) {
this.s = s; this.s = s;
q = question;
} }
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
String ans = q == null ? "" : JOptionPane.showInputDialog(q);
if (ans == null)
return;
s = s.replace("{}", ans);
Server.getInstance().sendCommand(s); Server.getInstance().sendCommand(s);
} }
@ -233,9 +242,9 @@ public final class MainWindow extends javax.swing.JFrame
itm.addActionListener(new ActionListenerImpl("time set 0")); itm.addActionListener(new ActionListenerImpl("time set 0"));
ppmBasically.add(itm); ppmBasically.add(itm);
itm = new JMenuItem("广播"); itm = new JMenuItem("广播");
itm.addActionListener(new ActionListenerImpl("say " + JOptionPane.showInputDialog("广播讯息"))); itm.addActionListener(new ActionListenerImpl("say {}", JOptionPane.showInputDialog("广播讯息")));
itm = new JMenuItem("红字广播"); itm = new JMenuItem("红字广播");
itm.addActionListener(new ActionListenerImpl("me " + JOptionPane.showInputDialog("广播讯息"))); itm.addActionListener(new ActionListenerImpl("me {}", JOptionPane.showInputDialog("广播讯息")));
itm = new JMenuItem("私聊"); itm = new JMenuItem("私聊");
itm.addActionListener(e -> { itm.addActionListener(e -> {
InputDialog id = new InputDialog(MainWindow.this, true, new String[] { "玩家", "讯息" }); InputDialog id = new InputDialog(MainWindow.this, true, new String[] { "玩家", "讯息" });
@ -244,16 +253,16 @@ public final class MainWindow extends javax.swing.JFrame
}); });
ppmBasically.add(itm); ppmBasically.add(itm);
itm = new JMenuItem("给予OP"); itm = new JMenuItem("给予OP");
itm.addActionListener(new ActionListenerImpl("op " + JOptionPane.showInputDialog("新OP的游戏名"))); itm.addActionListener(new ActionListenerImpl("op {}", JOptionPane.showInputDialog("新OP的游戏名")));
ppmBasically.add(itm); ppmBasically.add(itm);
itm = new JMenuItem("卸除OP"); itm = new JMenuItem("卸除OP");
itm.addActionListener(new ActionListenerImpl("deop " + JOptionPane.showInputDialog("要卸除OP的游戏名"))); itm.addActionListener(new ActionListenerImpl("deop {}", JOptionPane.showInputDialog("要卸除OP的游戏名")));
ppmBasically.add(itm); ppmBasically.add(itm);
itm = new JMenuItem("给予玩家白名单"); itm = new JMenuItem("给予玩家白名单");
itm.addActionListener(new ActionListenerImpl("whitelist add " + JOptionPane.showInputDialog("要添入白名单的游戏名"))); itm.addActionListener(new ActionListenerImpl("whitelist add {}", JOptionPane.showInputDialog("要添入白名单的游戏名")));
ppmBasically.add(itm); ppmBasically.add(itm);
itm = new JMenuItem("解除玩家白名单"); itm = new JMenuItem("解除玩家白名单");
itm.addActionListener(new ActionListenerImpl("whitelist remove " + JOptionPane.showInputDialog("要解除白名单的游戏名"))); itm.addActionListener(new ActionListenerImpl("whitelist remove {}", JOptionPane.showInputDialog("要解除白名单的游戏名")));
ppmBasically.add(itm); ppmBasically.add(itm);
itm = new JMenuItem("启用白名单"); itm = new JMenuItem("启用白名单");
itm.addActionListener(new ActionListenerImpl("whitelist on")); itm.addActionListener(new ActionListenerImpl("whitelist on"));
@ -265,31 +274,31 @@ public final class MainWindow extends javax.swing.JFrame
itm.addActionListener(new ActionListenerImpl("whitelist list")); itm.addActionListener(new ActionListenerImpl("whitelist list"));
ppmBasically.add(itm); ppmBasically.add(itm);
itm = new JMenuItem("封禁玩家"); itm = new JMenuItem("封禁玩家");
itm.addActionListener(new ActionListenerImpl("ban " + JOptionPane.showInputDialog("要封禁玩家的游戏名"))); itm.addActionListener(new ActionListenerImpl("ban {}", JOptionPane.showInputDialog("要封禁玩家的游戏名")));
ppmBasically.add(itm); ppmBasically.add(itm);
itm = new JMenuItem("封禁玩家IP"); itm = new JMenuItem("封禁玩家IP");
itm.addActionListener(new ActionListenerImpl("ban-ip " + JOptionPane.showInputDialog("要封禁玩家IP的游戏名"))); itm.addActionListener(new ActionListenerImpl("ban-ip {}", JOptionPane.showInputDialog("要封禁玩家IP的游戏名")));
itm = new JMenuItem("解封玩家"); itm = new JMenuItem("解封玩家");
itm.addActionListener(new ActionListenerImpl("pardon " + JOptionPane.showInputDialog("要解封玩家的游戏名"))); itm.addActionListener(new ActionListenerImpl("pardon {}", JOptionPane.showInputDialog("要解封玩家的游戏名")));
ppmBasically.add(itm); ppmBasically.add(itm);
itm = new JMenuItem("解封玩家IP"); itm = new JMenuItem("解封玩家IP");
itm.addActionListener(new ActionListenerImpl("pardon-ip " + JOptionPane.showInputDialog("要解封玩家IP的游戏名"))); itm.addActionListener(new ActionListenerImpl("pardon-ip {}", JOptionPane.showInputDialog("要解封玩家IP的游戏名")));
itm = new JMenuItem("封禁玩家"); itm = new JMenuItem("封禁玩家");
itm.addActionListener(new ActionListenerImpl("ban " + JOptionPane.showInputDialog("要封禁玩家的游戏名"))); itm.addActionListener(new ActionListenerImpl("ban {}", JOptionPane.showInputDialog("要封禁玩家的游戏名")));
ppmBasically.add(itm); ppmBasically.add(itm);
itm = new JMenuItem("封禁玩家IP"); itm = new JMenuItem("封禁玩家IP");
itm.addActionListener(new ActionListenerImpl("ban-ip " + JOptionPane.showInputDialog("要封禁玩家IP的游戏名"))); itm.addActionListener(new ActionListenerImpl("ban-ip {}", JOptionPane.showInputDialog("要封禁玩家IP的游戏名")));
itm = new JMenuItem("封禁玩家列表"); itm = new JMenuItem("封禁玩家列表");
itm.addActionListener(new ActionListenerImpl("banlist")); itm.addActionListener(new ActionListenerImpl("banlist"));
ppmBasically.add(itm); ppmBasically.add(itm);
itm = new JMenuItem("修改时间"); itm = new JMenuItem("修改时间");
itm.addActionListener(new ActionListenerImpl("time set " + JOptionPane.showInputDialog("要调整的时间值"))); itm.addActionListener(new ActionListenerImpl("time set {}", JOptionPane.showInputDialog("要调整的时间值")));
ppmBasically.add(itm); ppmBasically.add(itm);
itm = new JMenuItem("往后调整时间"); itm = new JMenuItem("往后调整时间");
itm.addActionListener(new ActionListenerImpl("time add " + JOptionPane.showInputDialog("要往后调整的时间值"))); itm.addActionListener(new ActionListenerImpl("time add {}", JOptionPane.showInputDialog("要往后调整的时间值")));
ppmBasically.add(itm); ppmBasically.add(itm);
itm = new JMenuItem("调整天气"); itm = new JMenuItem("调整天气");
itm.addActionListener(new ActionListenerImpl("weather " + JOptionPane.showInputDialog("要调整的天气只能填clear[意思是取消所有天气]或rain[意思是下雨]或thunder[意思是打雷]"))); itm.addActionListener(new ActionListenerImpl("weather {}", JOptionPane.showInputDialog("要调整的天气只能填clear[意思是取消所有天气]或rain[意思是下雨]或thunder[意思是打雷]")));
ppmBasically.add(itm); ppmBasically.add(itm);
itm = new JMenuItem("调整一定时间的天气"); itm = new JMenuItem("调整一定时间的天气");
itm.addActionListener(e -> { itm.addActionListener(e -> {
@ -305,10 +314,10 @@ public final class MainWindow extends javax.swing.JFrame
}); });
ppmBasically.add(itm); ppmBasically.add(itm);
itm = new JMenuItem("清除背包"); itm = new JMenuItem("清除背包");
itm.addActionListener(new ActionListenerImpl("clear" + JOptionPane.showInputDialog("要被清除背包的玩家"))); itm.addActionListener(new ActionListenerImpl("clear {}", JOptionPane.showInputDialog("要被清除背包的玩家")));
ppmBasically.add(itm); ppmBasically.add(itm);
itm = new JMenuItem("踢出玩家"); itm = new JMenuItem("踢出玩家");
itm.addActionListener(new ActionListenerImpl("kick " + JOptionPane.showInputDialog("要被踢出的玩家"))); itm.addActionListener(new ActionListenerImpl("kick {}", JOptionPane.showInputDialog("要被踢出的玩家")));
ppmBasically.add(itm); ppmBasically.add(itm);
itm = new JMenuItem("在线玩家"); itm = new JMenuItem("在线玩家");
itm.addActionListener(new ActionListenerImpl("list")); itm.addActionListener(new ActionListenerImpl("list"));
@ -334,10 +343,10 @@ public final class MainWindow extends javax.swing.JFrame
itm.addActionListener(new ActionListenerImpl("save-off")); itm.addActionListener(new ActionListenerImpl("save-off"));
ppmBasically.add(itm); ppmBasically.add(itm);
itm = new JMenuItem("难度"); itm = new JMenuItem("难度");
itm.addActionListener(new ActionListenerImpl("difficulty " + JOptionPane.showInputDialog("难度"))); itm.addActionListener(new ActionListenerImpl("difficulty {}", JOptionPane.showInputDialog("难度")));
ppmBasically.add(itm); ppmBasically.add(itm);
itm = new JMenuItem("默认游戏模式"); itm = new JMenuItem("默认游戏模式");
itm.addActionListener(new ActionListenerImpl("defaultgamemode " + JOptionPane.showInputDialog("默认游戏模式"))); itm.addActionListener(new ActionListenerImpl("defaultgamemode {}", JOptionPane.showInputDialog("默认游戏模式")));
ppmBasically.add(itm); ppmBasically.add(itm);
itm = new JMenuItem("地图种子"); itm = new JMenuItem("地图种子");
itm.addActionListener(new ActionListenerImpl("seed")); itm.addActionListener(new ActionListenerImpl("seed"));