Question

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!

Était-ce utile?

La solution

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!");
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top