Skip to content

Commit

Permalink
[commit] #1071 fix stop with npe
Browse files Browse the repository at this point in the history
  • Loading branch information
magiclu550 committed Sep 1, 2019
1 parent 0974f6d commit 46412c2
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions JPLS/src/main/java/cn/jsmod2/Register.java
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}


Expand Down
30 changes: 30 additions & 0 deletions JPLS/src/main/java/cn/jsmod2/command/ServerCommand.java
Original file line number Diff line number Diff line change
@@ -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;
}
}

0 comments on commit 46412c2

Please sign in to comment.