package fr.xephi.authme.cache.auth; import fr.xephi.authme.security.HashAlgorithm; import fr.xephi.authme.settings.Settings; public class PlayerAuth { private String email = "your@email.com"; private int groupId = -1; private String hash = ""; private String ip = "192.168.0.1"; private long lastLogin = 0; private String nickname = ""; private String realName; private String salt = ""; private String vBhash = null; private String world = "world"; private double x = 0; private double y = 0; private double z = 0; public PlayerAuth(String nickname, double x, double y, double z, String world, String realName) { this.nickname = nickname; this.x = x; this.y = y; this.z = z; this.world = world; this.realName = realName; this.lastLogin = System.currentTimeMillis(); } public PlayerAuth(String nickname, String ip, long lastLogin, String realName) { this.nickname = nickname; this.ip = ip; this.lastLogin = lastLogin; this.realName = realName; } public PlayerAuth(String nickname, String hash, String salt, int groupId, String ip, long lastLogin, double x, double y, double z, String world, String email, String realName) { this.nickname = nickname; this.hash = hash; this.ip = ip; this.lastLogin = lastLogin; this.x = x; this.y = y; this.z = z; this.world = world; this.salt = salt; this.groupId = groupId; this.email = email; this.realName = realName; } public PlayerAuth(String nickname, String hash, String salt, int groupId, String ip, long lastLogin, String realName) { this.nickname = nickname; this.hash = hash; this.ip = ip; this.lastLogin = lastLogin; this.salt = salt; this.groupId = groupId; this.realName = realName; } public PlayerAuth(String nickname, String hash, String ip, long lastLogin, double x, double y, double z, String world, String email, String realName) { this.nickname = nickname; this.hash = hash; this.ip = ip; this.lastLogin = lastLogin; this.x = x; this.y = y; this.z = z; this.world = world; this.email = email; this.realName = realName; } public PlayerAuth(String nickname, String hash, String ip, long lastLogin, String realName) { this.nickname = nickname; this.ip = ip; this.lastLogin = lastLogin; this.hash = hash; this.realName = realName; } public PlayerAuth(String nickname, String hash, String ip, long lastLogin, String email, String realName) { this.nickname = nickname; this.hash = hash; this.ip = ip; this.lastLogin = lastLogin; this.email = email; this.realName = realName; } public PlayerAuth(String nickname, String hash, String salt, String ip, long lastLogin, double x, double y, double z, String world, String email, String realName) { this.nickname = nickname; this.hash = hash; this.ip = ip; this.lastLogin = lastLogin; this.x = x; this.y = y; this.z = z; this.world = world; this.salt = salt; this.email = email; this.realName = realName; } public PlayerAuth(String nickname, String hash, String salt, String ip, long lastLogin, String realName) { this.nickname = nickname; this.hash = hash; this.ip = ip; this.lastLogin = lastLogin; this.salt = salt; this.realName = realName; } @Override public boolean equals(Object obj) { if (!(obj instanceof PlayerAuth)) { return false; } PlayerAuth other = (PlayerAuth) obj; return other.getIp().equals(this.ip) && other.getNickname().equals(this.nickname); } public String getEmail() { return email; } public int getGroupId() { return groupId; } public String getHash() { if (Settings.getPasswordHash == HashAlgorithm.MD5VB) { if (salt != null && !salt.isEmpty() && Settings.getPasswordHash == HashAlgorithm.MD5VB) { vBhash = "$MD5vb$" + salt + "$" + hash; return vBhash; } } return hash; } public String getIp() { if (ip == null || ip.isEmpty()) ip = "127.0.0.1"; return ip; } public long getLastLogin() { try { if (Long.valueOf(lastLogin) == null) lastLogin = 0L; } catch (NullPointerException e) { lastLogin = 0L; } return lastLogin; } public String getNickname() { return nickname; } public double getQuitLocX() { return x; } public double getQuitLocY() { return y; } public double getQuitLocZ() { return z; } public String getRealName() { return realName; } public String getSalt() { return this.salt; } public String getWorld() { return world; } @Override public int hashCode() { int hashCode = 7; hashCode = 71 * hashCode + (this.nickname != null ? this.nickname.hashCode() : 0); hashCode = 71 * hashCode + (this.ip != null ? this.ip.hashCode() : 0); return hashCode; } public void set(PlayerAuth auth) { this.setEmail(auth.getEmail()); this.setHash(auth.getHash()); this.setIp(auth.getIp()); this.setLastLogin(auth.getLastLogin()); this.setName(auth.getNickname()); this.setQuitLocX(auth.getQuitLocX()); this.setQuitLocY(auth.getQuitLocY()); this.setQuitLocZ(auth.getQuitLocZ()); this.setSalt(auth.getSalt()); this.setWorld(auth.getWorld()); this.setRealName(auth.getRealName()); } public void setEmail(String email) { this.email = email; } public void setHash(String hash) { this.hash = hash; } public void setIp(String ip) { this.ip = ip; } public void setLastLogin(long lastLogin) { this.lastLogin = lastLogin; } public void setName(String nickname) { this.nickname = nickname; } public void setQuitLocX(double d) { this.x = d; } public void setQuitLocY(double d) { this.y = d; } public void setQuitLocZ(double d) { this.z = d; } public void setRealName(String realName) { this.realName = realName; } public void setSalt(String salt) { this.salt = salt; } public void setWorld(String world) { this.world = world; } @Override public String toString() { String s = "Player : " + nickname + " | " + realName + " ! IP : " + ip + " ! LastLogin : " + lastLogin + " ! LastPosition : " + x + "," + y + "," + z + "," + world + " ! Email : " + email + " ! Hash : " + hash + " ! Salt : " + salt; return s; } }