문제

i get this wierd bug. i have this code, which compares the password in the config file with the given argument:

if(label.equalsIgnoreCase("login")){
if(getConfig().getString("players."+p.getName()+".password") == args[0]){
p.sendMessage("OK!");
} else {
p.sendMessage("NOT OK!");
}

but no matter what, it ouputs "NOT OK!", what am i doing wrong? ive tried to debug it, to send a message with the given argument and what it sees in the config file. they were both the same!

도움이 되었습니까?

해결책

You should try

String configValue = config.getString("players."+p.getName()+".password");
if(configValue != null && configValue.equals(args[0]) { // maybe you just need to change the index of args[], depending on if your command looks like /xy <password> or /xy z <password>
    p.sendMessage("OK!");
} else {
    p.sendMessage("NOT OK!");
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top