From 46412c212801010e09462b1a12d87123aac58d9f Mon Sep 17 00:00:00 2001 From: magiclu550 <843983728@qq.com> Date: Sun, 1 Sep 2019 23:09:14 +0800 Subject: [PATCH] [commit] #1071 fix stop with npe --- JPLS/src/main/java/cn/jsmod2/Register.java | 1 + .../java/cn/jsmod2/command/ServerCommand.java | 30 +++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 JPLS/src/main/java/cn/jsmod2/command/ServerCommand.java diff --git a/JPLS/src/main/java/cn/jsmod2/Register.java b/JPLS/src/main/java/cn/jsmod2/Register.java index e1fdfedd..2ed18ce0 100644 --- a/JPLS/src/main/java/cn/jsmod2/Register.java +++ b/JPLS/src/main/java/cn/jsmod2/Register.java @@ -107,6 +107,7 @@ public void registerNativeCommand(){ nativeCommandMap.put("multi",new MultiCommand()); nativeCommandMap.put("download",new DownloadPluginCommand()); nativeCommandMap.put("register",new RegisterPanelCommand()); + nativeCommandMap.put("server",new ServerCommand()); } diff --git a/JPLS/src/main/java/cn/jsmod2/command/ServerCommand.java b/JPLS/src/main/java/cn/jsmod2/command/ServerCommand.java new file mode 100644 index 00000000..e93d472d --- /dev/null +++ b/JPLS/src/main/java/cn/jsmod2/command/ServerCommand.java @@ -0,0 +1,30 @@ +package cn.jsmod2.command; + +import cn.jsmod2.core.CommandSender; +import cn.jsmod2.core.Powers; +import cn.jsmod2.core.Server; +import cn.jsmod2.core.command.NativeCommand; +import cn.jsmod2.core.log.ServerLogger; + +import static cn.jsmod2.core.utils.Utils.contains; + +/** + * 用于调试服务器而定义的命令格式 + */ +public class ServerCommand extends NativeCommand { + + public ServerCommand() { + super("server", Powers.ADMIN,"the server debug command"); + } + + //-f getPlayers + @Override + public boolean execute(CommandSender commandSender, String[] strings) { + if(contains(strings,"-p")){ + ServerLogger.getLogger().multiInfo(getClass(),Server.getSender().getServer().getGameServer().getPlayers()==null?"isNull":"notNull","",""); + }else if(contains(strings,"-ip")){ + ServerLogger.getLogger().multiInfo(getClass(),Server.getSender().getServer().getGameServer().getIpAddress(),"",""); + } + return true; + } +}