Fixed null when invoking some server commands
This commit is contained in:
@@ -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() {
|
||||
|
||||
@@ -209,14 +209,23 @@ public final class MainWindow extends javax.swing.JFrame
|
||||
//<editor-fold defaultstate="collapsed" desc="基本信息菜单">
|
||||
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"));
|
||||
|
||||
Reference in New Issue
Block a user