From 5d4a3c1df66a6a4815b09a0d48d6c1678e4fcbb4 Mon Sep 17 00:00:00 2001 From: huangyuhui Date: Fri, 4 Mar 2016 20:18:25 +0800 Subject: [PATCH] Fixed null when invoking some server commands --- .travis.yml | 8 +-- .../jackhuang/hellominecraft/svrmgr/Main.java | 2 +- .../hellominecraft/svrmgr/ui/MainWindow.java | 49 +++++++++++-------- 3 files changed, 35 insertions(+), 24 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8202bc5c7..a32199dc9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,15 +7,17 @@ branches: before_deploy: - git config --global user.email ${GITHUB_EMAIL} - git config --global user.name ${GITHUB_NAME} - - git tag ${VERSION_ROOT}.${TRAVIS_BUILD_NUMBER} + - git tag ${TRAVIS_BUILD_NUMBER} - git push -q ${REPO} --tags deploy: provider: releases 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= file: - - HMCL/build/libs/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}.jar + - 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: repo: huanghongxun/HMCL tags: false diff --git a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/Main.java b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/Main.java index 5b6f53c55..2239ea798 100755 --- a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/Main.java +++ b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/Main.java @@ -40,7 +40,7 @@ public class Main { public static String launcherName = "Hello Minecraft! Server Manager"; public static final String PUBLISH_URL = "http://www.mcbbs.net/thread-171239-1-1.html"; - public static 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 String makeTitle() { diff --git a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/ui/MainWindow.java b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/ui/MainWindow.java index 25f13c728..ad312b862 100755 --- a/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/ui/MainWindow.java +++ b/HMCSM/src/main/java/org/jackhuang/hellominecraft/svrmgr/ui/MainWindow.java @@ -209,14 +209,23 @@ public final class MainWindow extends javax.swing.JFrame // class ActionListenerImpl implements ActionListener { - String s; + String s, q; public ActionListenerImpl(String s) { + this(s, null); + } + + public ActionListenerImpl(String s, String question) { this.s = s; + q = question; } @Override public void actionPerformed(ActionEvent e) { + String ans = q == null ? "" : JOptionPane.showInputDialog(q); + if (ans == null) + return; + s = s.replace("{}", ans); Server.getInstance().sendCommand(s); } @@ -233,9 +242,9 @@ public final class MainWindow extends javax.swing.JFrame itm.addActionListener(new ActionListenerImpl("time set 0")); ppmBasically.add(itm); itm = new JMenuItem("广播"); - itm.addActionListener(new ActionListenerImpl("say " + JOptionPane.showInputDialog("广播讯息"))); + itm.addActionListener(new ActionListenerImpl("say {}", JOptionPane.showInputDialog("广播讯息"))); itm = new JMenuItem("红字广播"); - itm.addActionListener(new ActionListenerImpl("me " + JOptionPane.showInputDialog("广播讯息"))); + itm.addActionListener(new ActionListenerImpl("me {}", JOptionPane.showInputDialog("广播讯息"))); itm = new JMenuItem("私聊"); itm.addActionListener(e -> { InputDialog id = new InputDialog(MainWindow.this, true, new String[] { "玩家", "讯息" }); @@ -244,16 +253,16 @@ public final class MainWindow extends javax.swing.JFrame }); ppmBasically.add(itm); itm = new JMenuItem("给予OP"); - itm.addActionListener(new ActionListenerImpl("op " + JOptionPane.showInputDialog("新OP的游戏名"))); + itm.addActionListener(new ActionListenerImpl("op {}", JOptionPane.showInputDialog("新OP的游戏名"))); ppmBasically.add(itm); itm = new JMenuItem("卸除OP"); - itm.addActionListener(new ActionListenerImpl("deop " + JOptionPane.showInputDialog("要卸除OP的游戏名"))); + itm.addActionListener(new ActionListenerImpl("deop {}", JOptionPane.showInputDialog("要卸除OP的游戏名"))); ppmBasically.add(itm); itm = new JMenuItem("给予玩家白名单"); - itm.addActionListener(new ActionListenerImpl("whitelist add " + JOptionPane.showInputDialog("要添入白名单的游戏名"))); + itm.addActionListener(new ActionListenerImpl("whitelist add {}", JOptionPane.showInputDialog("要添入白名单的游戏名"))); ppmBasically.add(itm); itm = new JMenuItem("解除玩家白名单"); - itm.addActionListener(new ActionListenerImpl("whitelist remove " + JOptionPane.showInputDialog("要解除白名单的游戏名"))); + itm.addActionListener(new ActionListenerImpl("whitelist remove {}", JOptionPane.showInputDialog("要解除白名单的游戏名"))); ppmBasically.add(itm); itm = new JMenuItem("启用白名单"); itm.addActionListener(new ActionListenerImpl("whitelist on")); @@ -265,31 +274,31 @@ public final class MainWindow extends javax.swing.JFrame itm.addActionListener(new ActionListenerImpl("whitelist list")); ppmBasically.add(itm); itm = new JMenuItem("封禁玩家"); - itm.addActionListener(new ActionListenerImpl("ban " + JOptionPane.showInputDialog("要封禁玩家的游戏名"))); + itm.addActionListener(new ActionListenerImpl("ban {}", JOptionPane.showInputDialog("要封禁玩家的游戏名"))); ppmBasically.add(itm); 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.addActionListener(new ActionListenerImpl("pardon " + JOptionPane.showInputDialog("要解封玩家的游戏名"))); + itm.addActionListener(new ActionListenerImpl("pardon {}", JOptionPane.showInputDialog("要解封玩家的游戏名"))); ppmBasically.add(itm); 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.addActionListener(new ActionListenerImpl("ban " + JOptionPane.showInputDialog("要封禁玩家的游戏名"))); + itm.addActionListener(new ActionListenerImpl("ban {}", JOptionPane.showInputDialog("要封禁玩家的游戏名"))); ppmBasically.add(itm); 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.addActionListener(new ActionListenerImpl("banlist")); ppmBasically.add(itm); itm = new JMenuItem("修改时间"); - itm.addActionListener(new ActionListenerImpl("time set " + JOptionPane.showInputDialog("要调整的时间值"))); + itm.addActionListener(new ActionListenerImpl("time set {}", JOptionPane.showInputDialog("要调整的时间值"))); ppmBasically.add(itm); itm = new JMenuItem("往后调整时间"); - itm.addActionListener(new ActionListenerImpl("time add " + JOptionPane.showInputDialog("要往后调整的时间值"))); + itm.addActionListener(new ActionListenerImpl("time add {}", JOptionPane.showInputDialog("要往后调整的时间值"))); ppmBasically.add(itm); 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); itm = new JMenuItem("调整一定时间的天气"); itm.addActionListener(e -> { @@ -305,10 +314,10 @@ public final class MainWindow extends javax.swing.JFrame }); ppmBasically.add(itm); itm = new JMenuItem("清除背包"); - itm.addActionListener(new ActionListenerImpl("clear" + JOptionPane.showInputDialog("要被清除背包的玩家"))); + itm.addActionListener(new ActionListenerImpl("clear {}", JOptionPane.showInputDialog("要被清除背包的玩家"))); ppmBasically.add(itm); itm = new JMenuItem("踢出玩家"); - itm.addActionListener(new ActionListenerImpl("kick " + JOptionPane.showInputDialog("要被踢出的玩家"))); + itm.addActionListener(new ActionListenerImpl("kick {}", JOptionPane.showInputDialog("要被踢出的玩家"))); ppmBasically.add(itm); itm = new JMenuItem("在线玩家"); itm.addActionListener(new ActionListenerImpl("list")); @@ -334,10 +343,10 @@ public final class MainWindow extends javax.swing.JFrame itm.addActionListener(new ActionListenerImpl("save-off")); ppmBasically.add(itm); itm = new JMenuItem("难度"); - itm.addActionListener(new ActionListenerImpl("difficulty " + JOptionPane.showInputDialog("难度"))); + itm.addActionListener(new ActionListenerImpl("difficulty {}", JOptionPane.showInputDialog("难度"))); ppmBasically.add(itm); itm = new JMenuItem("默认游戏模式"); - itm.addActionListener(new ActionListenerImpl("defaultgamemode " + JOptionPane.showInputDialog("默认游戏模式"))); + itm.addActionListener(new ActionListenerImpl("defaultgamemode {}", JOptionPane.showInputDialog("默认游戏模式"))); ppmBasically.add(itm); itm = new JMenuItem("地图种子"); itm.addActionListener(new ActionListenerImpl("seed"));