Minor - adjust PlayerAuth builder methods

- Rename hash() to password()
- Add location(Location) builder method
- Replace usages of password(new EncryptedPassword(hash, salt)) to the more terse password(String, String) builder method
This commit is contained in:
ljacqu
2015-12-30 18:28:06 +01:00
parent a3402d573f
commit 8b60c66cc8
10 changed files with 30 additions and 257 deletions
+16 -7
View File
@@ -1,6 +1,7 @@
package fr.xephi.authme.cache.auth;
import fr.xephi.authme.security.crypts.EncryptedPassword;
import org.bukkit.Location;
import static com.google.common.base.Objects.firstNonNull;
import static com.google.common.base.Preconditions.checkNotNull;
@@ -317,7 +318,7 @@ public class PlayerAuth {
+ " ! LastLogin : " + lastLogin
+ " ! LastPosition : " + x + "," + y + "," + z + "," + world
+ " ! Email : " + email
+ " ! Hash : {" + password.getHash() + ", " + password.getSalt() + "}";
+ " ! Password : {" + password.getHash() + ", " + password.getSalt() + "}";
}
/**
@@ -368,7 +369,7 @@ public class PlayerAuth {
public static final class Builder {
private String name;
private String realName;
private EncryptedPassword hash;
private EncryptedPassword password;
private String ip;
private String world;
private String email;
@@ -381,7 +382,7 @@ public class PlayerAuth {
public PlayerAuth build() {
return new PlayerAuth(
checkNotNull(name),
firstNonNull(hash, new EncryptedPassword("")),
firstNonNull(password, new EncryptedPassword("")),
groupId,
firstNonNull(ip, "127.0.0.1"),
lastLogin,
@@ -402,13 +403,13 @@ public class PlayerAuth {
return this;
}
public Builder hash(EncryptedPassword hash) {
this.hash = hash;
public Builder password(EncryptedPassword password) {
this.password = password;
return this;
}
public Builder hash(String hash, String salt) {
return hash(new EncryptedPassword(hash, salt));
public Builder password(String hash, String salt) {
return password(new EncryptedPassword(hash, salt));
}
public Builder ip(String ip) {
@@ -416,6 +417,14 @@ public class PlayerAuth {
return this;
}
public Builder location(Location location) {
this.x = location.getX();
this.y = location.getY();
this.z = location.getZ();
this.world = location.getWorld().getName();
return this;
}
public Builder locWorld(String world) {
this.world = world;
return this;