Remove Case dependance, auto-update name on join into database (care
forums users!)
This commit is contained in:
+11
-17
@@ -17,16 +17,14 @@ public class PlayerAuth {
|
||||
private String vBhash = null;
|
||||
private int groupId = -1;
|
||||
private String email = "your@email.com";
|
||||
private String realName = "";
|
||||
|
||||
public PlayerAuth(String nickname, String hash, String ip, long lastLogin,
|
||||
String email, String realName) {
|
||||
String email) {
|
||||
this.nickname = nickname;
|
||||
this.hash = hash;
|
||||
this.ip = ip;
|
||||
this.lastLogin = lastLogin;
|
||||
this.email = email;
|
||||
this.realName = realName;
|
||||
|
||||
}
|
||||
|
||||
@@ -42,8 +40,7 @@ public class PlayerAuth {
|
||||
}
|
||||
|
||||
public PlayerAuth(String nickname, String hash, String ip, long lastLogin,
|
||||
double x, double y, double z, String world, String email,
|
||||
String realName) {
|
||||
double x, double y, double z, String world, String email) {
|
||||
this.nickname = nickname;
|
||||
this.hash = hash;
|
||||
this.ip = ip;
|
||||
@@ -53,13 +50,12 @@ public class PlayerAuth {
|
||||
this.z = z;
|
||||
this.world = world;
|
||||
this.email = email;
|
||||
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) {
|
||||
String world, String email) {
|
||||
this.nickname = nickname;
|
||||
this.hash = hash;
|
||||
this.ip = ip;
|
||||
@@ -71,36 +67,33 @@ public class PlayerAuth {
|
||||
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) {
|
||||
String ip, long lastLogin) {
|
||||
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 salt, String ip,
|
||||
long lastLogin, String realName) {
|
||||
long lastLogin) {
|
||||
this.nickname = nickname;
|
||||
this.hash = hash;
|
||||
this.ip = ip;
|
||||
this.lastLogin = lastLogin;
|
||||
this.salt = salt;
|
||||
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) {
|
||||
String email) {
|
||||
this.nickname = nickname;
|
||||
this.hash = hash;
|
||||
this.ip = ip;
|
||||
@@ -111,7 +104,7 @@ public class PlayerAuth {
|
||||
this.world = world;
|
||||
this.salt = salt;
|
||||
this.email = email;
|
||||
this.realName = realName;
|
||||
|
||||
}
|
||||
|
||||
public PlayerAuth(String nickname, String ip, long lastLogin) {
|
||||
@@ -241,12 +234,13 @@ public class PlayerAuth {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String s = "Player : " + nickname + " ! IP : " + ip + " ! LastLogin : " + lastLogin + " ! LastPosition : " + x + "," + y + "," + z + "," + world + " ! Email : " + email + " ! Hash : " + hash + " ! Salt : " + salt + " ! RealName : " + realName;
|
||||
String s = "Player : " + nickname + " ! IP : " + ip + " ! LastLogin : " + lastLogin + " ! LastPosition : " + x + "," + y + "," + z + "," + world + " ! Email : " + email + " ! Hash : " + hash + " ! Salt : " + salt;
|
||||
return s;
|
||||
|
||||
}
|
||||
|
||||
public String getRealname() {
|
||||
return realName;
|
||||
public void setName(String nickname) {
|
||||
this.nickname = nickname;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -12,24 +12,24 @@ public class PlayerCache {
|
||||
}
|
||||
|
||||
public void addPlayer(PlayerAuth auth) {
|
||||
cache.put(auth.getNickname().toLowerCase(), auth);
|
||||
cache.put(auth.getNickname(), auth);
|
||||
}
|
||||
|
||||
public void updatePlayer(PlayerAuth auth) {
|
||||
cache.remove(auth.getNickname().toLowerCase());
|
||||
cache.put(auth.getNickname().toLowerCase(), auth);
|
||||
cache.remove(auth.getNickname());
|
||||
cache.put(auth.getNickname(), auth);
|
||||
}
|
||||
|
||||
public void removePlayer(String user) {
|
||||
cache.remove(user.toLowerCase());
|
||||
cache.remove(user);
|
||||
}
|
||||
|
||||
public boolean isAuthenticated(String user) {
|
||||
return cache.containsKey(user.toLowerCase());
|
||||
return cache.containsKey(user);
|
||||
}
|
||||
|
||||
public PlayerAuth getAuth(String user) {
|
||||
return cache.get(user.toLowerCase());
|
||||
return cache.get(user);
|
||||
}
|
||||
|
||||
public static PlayerCache getInstance() {
|
||||
|
||||
@@ -29,7 +29,7 @@ public class LimboCache {
|
||||
}
|
||||
|
||||
public void addLimboPlayer(Player player) {
|
||||
String name = player.getName().toLowerCase();
|
||||
String name = player.getName();
|
||||
Location loc = player.getLocation();
|
||||
GameMode gameMode = player.getGameMode();
|
||||
ItemStack[] arm;
|
||||
@@ -91,11 +91,11 @@ public class LimboCache {
|
||||
if (player.isDead()) {
|
||||
loc = plugin.getSpawnLocation(player);
|
||||
}
|
||||
cache.put(player.getName().toLowerCase(), new LimboPlayer(name, loc, inv, arm, gameMode, operator, playerGroup, flying));
|
||||
cache.put(player.getName(), new LimboPlayer(name, loc, inv, arm, gameMode, operator, playerGroup, flying));
|
||||
}
|
||||
|
||||
public void addLimboPlayer(Player player, String group) {
|
||||
cache.put(player.getName().toLowerCase(), new LimboPlayer(player.getName().toLowerCase(), group));
|
||||
cache.put(player.getName(), new LimboPlayer(player.getName(), group));
|
||||
}
|
||||
|
||||
public void deleteLimboPlayer(String name) {
|
||||
@@ -118,8 +118,8 @@ public class LimboCache {
|
||||
}
|
||||
|
||||
public void updateLimboPlayer(Player player) {
|
||||
if (this.hasLimboPlayer(player.getName().toLowerCase())) {
|
||||
this.deleteLimboPlayer(player.getName().toLowerCase());
|
||||
if (this.hasLimboPlayer(player.getName())) {
|
||||
this.deleteLimboPlayer(player.getName());
|
||||
}
|
||||
this.addLimboPlayer(player);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user