我对Java非常陌生,我正在尝试查看设置的参数是否为空,如果是,则向他们发送消息,然后终止脚本。但它似乎不起作用,因为我将参数留空,我仍然不会收到我的消息,但它似乎返回错误。
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){
Player player = (Player) sender;
if(commandLabel.equalsIgnoreCase("register")){
if(args[0].length() == 0){
player.sendMessage(ChatColor.GOLD + "You Did Not Set A Password! (Ex: /register mysupersecretpassword)");
return false;
}
}
return false;
最终解决方案
if(args.length == 0){
不是
if(args[0].length() == 0){