mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-12-26 10:37:39 +01:00
commit
759bc8221e
@ -12,6 +12,7 @@ import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.logging.Logger;
|
||||
@ -71,7 +72,6 @@ import fr.xephi.authme.plugin.manager.EssSpawn;
|
||||
import fr.xephi.authme.process.Management;
|
||||
import fr.xephi.authme.settings.Messages;
|
||||
import fr.xephi.authme.settings.OtherAccounts;
|
||||
import fr.xephi.authme.settings.PlayersLogs;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import fr.xephi.authme.settings.Spawn;
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
@ -253,8 +253,6 @@ public class AuthMe extends JavaPlugin {
|
||||
ConsoleLogger.showError("WARNING!!! By disabling ForceSingleSession, your server protection is inadequate!");
|
||||
}
|
||||
|
||||
PlayersLogs.getInstance();
|
||||
|
||||
if (Settings.reloadSupport)
|
||||
try {
|
||||
int playersOnline = 0;
|
||||
@ -269,7 +267,15 @@ public class AuthMe extends JavaPlugin {
|
||||
database.purgeLogged();
|
||||
} catch (NullPointerException npe) {
|
||||
}
|
||||
} else PlayersLogs.getInstance().loadPlayers();
|
||||
} else {
|
||||
for (PlayerAuth auth : database.getLoggedPlayers()) {
|
||||
if (auth == null)
|
||||
continue;
|
||||
auth.setLastLogin(new Date().getTime());
|
||||
database.updateSession(auth);
|
||||
PlayerCache.getInstance().addPlayer(auth);
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
|
||||
@ -428,7 +434,10 @@ public class AuthMe extends JavaPlugin {
|
||||
}
|
||||
|
||||
if (database != null) {
|
||||
database.close();
|
||||
try {
|
||||
database.close();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
|
||||
if (Settings.isBackupActivated && Settings.isBackupOnStop) {
|
||||
@ -444,8 +453,7 @@ public class AuthMe extends JavaPlugin {
|
||||
return authme;
|
||||
}
|
||||
|
||||
public void savePlayer(Player player)
|
||||
throws IllegalStateException, NullPointerException {
|
||||
public void savePlayer(Player player) {
|
||||
try {
|
||||
if ((citizens.isNPC(player)) || (Utils.getInstance().isUnrestricted(player)) || (CombatTagComunicator.isNPC(player))) {
|
||||
return;
|
||||
@ -455,7 +463,7 @@ public class AuthMe extends JavaPlugin {
|
||||
try {
|
||||
String name = player.getName().toLowerCase();
|
||||
if (PlayerCache.getInstance().isAuthenticated(name) && !player.isDead() && Settings.isSaveQuitLocationEnabled) {
|
||||
final PlayerAuth auth = new PlayerAuth(player.getName().toLowerCase(), player.getLocation().getX(), player.getLocation().getY(), player.getLocation().getZ(), player.getWorld().getName());
|
||||
final PlayerAuth auth = new PlayerAuth(player.getName().toLowerCase(), player.getLocation().getX(), player.getLocation().getY(), player.getLocation().getZ(), player.getWorld().getName(), player.getName());
|
||||
database.updateQuitLoc(auth);
|
||||
}
|
||||
if (LimboCache.getInstance().hasLimboPlayer(name)) {
|
||||
|
@ -116,11 +116,9 @@ public class Utils {
|
||||
public boolean isUnrestricted(Player player) {
|
||||
if (!Settings.isAllowRestrictedIp)
|
||||
return false;
|
||||
if (Settings.getUnrestrictedName.isEmpty() || Settings.getUnrestrictedName == null)
|
||||
if (Settings.getUnrestrictedName == null || Settings.getUnrestrictedName.isEmpty())
|
||||
return false;
|
||||
if (Settings.getUnrestrictedName.contains(player.getName()))
|
||||
return true;
|
||||
return false;
|
||||
return (Settings.getUnrestrictedName.contains(player.getName()));
|
||||
}
|
||||
|
||||
public static Utils getInstance() {
|
||||
|
@ -17,30 +17,33 @@ 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 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, double x, double y, double z,
|
||||
String world) {
|
||||
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 hash, String ip, long lastLogin,
|
||||
double x, double y, double z, String world, String email) {
|
||||
double x, double y, double z, String world, String email,
|
||||
String realName) {
|
||||
this.nickname = nickname;
|
||||
this.hash = hash;
|
||||
this.ip = ip;
|
||||
@ -50,12 +53,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 world, String email, String realName) {
|
||||
this.nickname = nickname;
|
||||
this.hash = hash;
|
||||
this.ip = ip;
|
||||
@ -67,33 +70,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 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 salt, String ip,
|
||||
long lastLogin) {
|
||||
long lastLogin, String realName) {
|
||||
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 email, String realName) {
|
||||
this.nickname = nickname;
|
||||
this.hash = hash;
|
||||
this.ip = ip;
|
||||
@ -104,21 +107,24 @@ public class PlayerAuth {
|
||||
this.world = world;
|
||||
this.salt = salt;
|
||||
this.email = email;
|
||||
|
||||
this.realName = realName;
|
||||
}
|
||||
|
||||
public PlayerAuth(String nickname, String ip, long lastLogin) {
|
||||
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 ip, long lastLogin) {
|
||||
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 String getIp() {
|
||||
@ -234,7 +240,7 @@ 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;
|
||||
String s = "Player : " + nickname + " | " + realName + " ! IP : " + ip + " ! LastLogin : " + lastLogin + " ! LastPosition : " + x + "," + y + "," + z + "," + world + " ! Email : " + email + " ! Hash : " + hash + " ! Salt : " + salt;
|
||||
return s;
|
||||
|
||||
}
|
||||
@ -254,6 +260,15 @@ public class PlayerAuth {
|
||||
this.setQuitLocZ(auth.getQuitLocZ());
|
||||
this.setSalt(auth.getSalt());
|
||||
this.setWorld(auth.getWorld());
|
||||
this.setRealName(auth.getRealName());
|
||||
}
|
||||
|
||||
public String getRealName() {
|
||||
return realName;
|
||||
}
|
||||
|
||||
public void setRealName(String realName) {
|
||||
this.realName = realName;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ public class CrazyLoginConverter implements Converter {
|
||||
String psw = args[1];
|
||||
try {
|
||||
if (player != null && psw != null) {
|
||||
PlayerAuth auth = new PlayerAuth(player, psw, "127.0.0.1", System.currentTimeMillis());
|
||||
PlayerAuth auth = new PlayerAuth(player, psw, "127.0.0.1", System.currentTimeMillis(), player);
|
||||
database.saveAuth(auth);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
@ -93,7 +93,7 @@ public class RakamakConverter implements Converter {
|
||||
} else {
|
||||
ip = "127.0.0.1";
|
||||
}
|
||||
PlayerAuth auth = new PlayerAuth(player, psw, ip, System.currentTimeMillis());
|
||||
PlayerAuth auth = new PlayerAuth(player, psw, ip, System.currentTimeMillis(), player);
|
||||
if (PasswordSecurity.userSalt.containsKey(player))
|
||||
auth.setSalt(PasswordSecurity.userSalt.get(player));
|
||||
database.saveAuth(auth);
|
||||
|
@ -240,4 +240,9 @@ public class CacheDataSource implements DataSource {
|
||||
public List<PlayerAuth> getAllAuths() {
|
||||
return source.getAllAuths();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PlayerAuth> getLoggedPlayers() {
|
||||
return source.getLoggedPlayers();
|
||||
}
|
||||
}
|
||||
|
@ -65,4 +65,6 @@ public interface DataSource {
|
||||
|
||||
List<PlayerAuth> getAllAuths();
|
||||
|
||||
List<PlayerAuth> getLoggedPlayers();
|
||||
|
||||
}
|
||||
|
@ -534,4 +534,25 @@ public class DatabaseCalls implements DataSource {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PlayerAuth> getLoggedPlayers() {
|
||||
ExecutorService executor = Executors.newSingleThreadExecutor();
|
||||
List<PlayerAuth> result;
|
||||
try {
|
||||
result = executor.submit(new Callable<List<PlayerAuth>>() {
|
||||
|
||||
public List<PlayerAuth> call() throws Exception {
|
||||
return database.getLoggedPlayers();
|
||||
}
|
||||
}).get();
|
||||
} catch (InterruptedException e1) {
|
||||
return (new ArrayList<PlayerAuth>());
|
||||
} catch (ExecutionException e1) {
|
||||
return (new ArrayList<PlayerAuth>());
|
||||
} finally {
|
||||
executor.shutdown();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -14,7 +14,6 @@ import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||
import fr.xephi.authme.settings.PlayersLogs;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
|
||||
public class FlatFile implements DataSource {
|
||||
@ -115,23 +114,23 @@ public class FlatFile implements DataSource {
|
||||
if (args[0].equals(auth.getNickname())) {
|
||||
switch (args.length) {
|
||||
case 4: {
|
||||
newAuth = new PlayerAuth(args[0], auth.getHash(), args[2], Long.parseLong(args[3]), 0, 0, 0, "world", "your@email.com");
|
||||
newAuth = new PlayerAuth(args[0], auth.getHash(), args[2], Long.parseLong(args[3]), 0, 0, 0, "world", "your@email.com", args[0]);
|
||||
break;
|
||||
}
|
||||
case 7: {
|
||||
newAuth = new PlayerAuth(args[0], auth.getHash(), args[2], Long.parseLong(args[3]), Double.parseDouble(args[4]), Double.parseDouble(args[5]), Double.parseDouble(args[6]), "world", "your@email.com");
|
||||
newAuth = new PlayerAuth(args[0], auth.getHash(), args[2], Long.parseLong(args[3]), Double.parseDouble(args[4]), Double.parseDouble(args[5]), Double.parseDouble(args[6]), "world", "your@email.com", args[0]);
|
||||
break;
|
||||
}
|
||||
case 8: {
|
||||
newAuth = new PlayerAuth(args[0], auth.getHash(), args[2], Long.parseLong(args[3]), Double.parseDouble(args[4]), Double.parseDouble(args[5]), Double.parseDouble(args[6]), args[7], "your@email.com");
|
||||
newAuth = new PlayerAuth(args[0], auth.getHash(), args[2], Long.parseLong(args[3]), Double.parseDouble(args[4]), Double.parseDouble(args[5]), Double.parseDouble(args[6]), args[7], "your@email.com", args[0]);
|
||||
break;
|
||||
}
|
||||
case 9: {
|
||||
newAuth = new PlayerAuth(args[0], auth.getHash(), args[2], Long.parseLong(args[3]), Double.parseDouble(args[4]), Double.parseDouble(args[5]), Double.parseDouble(args[6]), args[7], args[8]);
|
||||
newAuth = new PlayerAuth(args[0], auth.getHash(), args[2], Long.parseLong(args[3]), Double.parseDouble(args[4]), Double.parseDouble(args[5]), Double.parseDouble(args[6]), args[7], args[8], args[0]);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
newAuth = new PlayerAuth(args[0], auth.getHash(), args[2], 0, 0, 0, 0, "world", "your@email.com");
|
||||
newAuth = new PlayerAuth(args[0], auth.getHash(), args[2], 0, 0, 0, 0, "world", "your@email.com", args[0]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -174,23 +173,23 @@ public class FlatFile implements DataSource {
|
||||
if (args[0].equalsIgnoreCase(auth.getNickname())) {
|
||||
switch (args.length) {
|
||||
case 4: {
|
||||
newAuth = new PlayerAuth(args[0], args[1], auth.getIp(), auth.getLastLogin(), 0, 0, 0, "world", "your@email.com");
|
||||
newAuth = new PlayerAuth(args[0], args[1], auth.getIp(), auth.getLastLogin(), 0, 0, 0, "world", "your@email.com", args[0]);
|
||||
break;
|
||||
}
|
||||
case 7: {
|
||||
newAuth = new PlayerAuth(args[0], args[1], auth.getIp(), auth.getLastLogin(), Double.parseDouble(args[4]), Double.parseDouble(args[5]), Double.parseDouble(args[6]), "world", "your@email.com");
|
||||
newAuth = new PlayerAuth(args[0], args[1], auth.getIp(), auth.getLastLogin(), Double.parseDouble(args[4]), Double.parseDouble(args[5]), Double.parseDouble(args[6]), "world", "your@email.com", args[0]);
|
||||
break;
|
||||
}
|
||||
case 8: {
|
||||
newAuth = new PlayerAuth(args[0], args[1], auth.getIp(), auth.getLastLogin(), Double.parseDouble(args[4]), Double.parseDouble(args[5]), Double.parseDouble(args[6]), args[7], "your@email.com");
|
||||
newAuth = new PlayerAuth(args[0], args[1], auth.getIp(), auth.getLastLogin(), Double.parseDouble(args[4]), Double.parseDouble(args[5]), Double.parseDouble(args[6]), args[7], "your@email.com", args[0]);
|
||||
break;
|
||||
}
|
||||
case 9: {
|
||||
newAuth = new PlayerAuth(args[0], args[1], auth.getIp(), auth.getLastLogin(), Double.parseDouble(args[4]), Double.parseDouble(args[5]), Double.parseDouble(args[6]), args[7], args[8]);
|
||||
newAuth = new PlayerAuth(args[0], args[1], auth.getIp(), auth.getLastLogin(), Double.parseDouble(args[4]), Double.parseDouble(args[5]), Double.parseDouble(args[6]), args[7], args[8], args[0]);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
newAuth = new PlayerAuth(args[0], args[1], auth.getIp(), auth.getLastLogin(), 0, 0, 0, "world", "your@email.com");
|
||||
newAuth = new PlayerAuth(args[0], args[1], auth.getIp(), auth.getLastLogin(), 0, 0, 0, "world", "your@email.com", args[0]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -231,7 +230,7 @@ public class FlatFile implements DataSource {
|
||||
while ((line = br.readLine()) != null) {
|
||||
String[] args = line.split(":");
|
||||
if (args[0].equalsIgnoreCase(auth.getNickname())) {
|
||||
newAuth = new PlayerAuth(args[0], args[1], args[2], Long.parseLong(args[3]), auth.getQuitLocX(), auth.getQuitLocY(), auth.getQuitLocZ(), auth.getWorld(), auth.getEmail());
|
||||
newAuth = new PlayerAuth(args[0], args[1], args[2], Long.parseLong(args[3]), auth.getQuitLocX(), auth.getQuitLocY(), auth.getQuitLocZ(), auth.getWorld(), auth.getEmail(), args[0]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -433,17 +432,17 @@ public class FlatFile implements DataSource {
|
||||
if (args[0].equalsIgnoreCase(user)) {
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
return new PlayerAuth(args[0], args[1], "192.168.0.1", 0, "your@email.com");
|
||||
return new PlayerAuth(args[0], args[1], "192.168.0.1", 0, "your@email.com", args[0]);
|
||||
case 3:
|
||||
return new PlayerAuth(args[0], args[1], args[2], 0, "your@email.com");
|
||||
return new PlayerAuth(args[0], args[1], args[2], 0, "your@email.com", args[0]);
|
||||
case 4:
|
||||
return new PlayerAuth(args[0], args[1], args[2], Long.parseLong(args[3]), "your@email.com");
|
||||
return new PlayerAuth(args[0], args[1], args[2], Long.parseLong(args[3]), "your@email.com", args[0]);
|
||||
case 7:
|
||||
return new PlayerAuth(args[0], args[1], args[2], Long.parseLong(args[3]), Double.parseDouble(args[4]), Double.parseDouble(args[5]), Double.parseDouble(args[6]), "unavailableworld", "your@email.com");
|
||||
return new PlayerAuth(args[0], args[1], args[2], Long.parseLong(args[3]), Double.parseDouble(args[4]), Double.parseDouble(args[5]), Double.parseDouble(args[6]), "unavailableworld", "your@email.com", args[0]);
|
||||
case 8:
|
||||
return new PlayerAuth(args[0], args[1], args[2], Long.parseLong(args[3]), Double.parseDouble(args[4]), Double.parseDouble(args[5]), Double.parseDouble(args[6]), args[7], "your@email.com");
|
||||
return new PlayerAuth(args[0], args[1], args[2], Long.parseLong(args[3]), Double.parseDouble(args[4]), Double.parseDouble(args[5]), Double.parseDouble(args[6]), args[7], "your@email.com", args[0]);
|
||||
case 9:
|
||||
return new PlayerAuth(args[0], args[1], args[2], Long.parseLong(args[3]), Double.parseDouble(args[4]), Double.parseDouble(args[5]), Double.parseDouble(args[6]), args[7], args[8]);
|
||||
return new PlayerAuth(args[0], args[1], args[2], Long.parseLong(args[3]), Double.parseDouble(args[4]), Double.parseDouble(args[5]), Double.parseDouble(args[6]), args[7], args[8], args[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -485,7 +484,7 @@ public class FlatFile implements DataSource {
|
||||
while ((line = br.readLine()) != null) {
|
||||
String[] args = line.split(":");
|
||||
if (args[0].equals(auth.getNickname())) {
|
||||
newAuth = new PlayerAuth(args[0], args[1], args[2], Long.parseLong(args[3]), Double.parseDouble(args[4]), Double.parseDouble(args[5]), Double.parseDouble(args[6]), args[7], auth.getEmail());
|
||||
newAuth = new PlayerAuth(args[0], args[1], args[2], Long.parseLong(args[3]), Double.parseDouble(args[4]), Double.parseDouble(args[5]), Double.parseDouble(args[6]), args[7], auth.getEmail(), args[0]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -662,17 +661,14 @@ public class FlatFile implements DataSource {
|
||||
|
||||
@Override
|
||||
public void setLogged(String user) {
|
||||
PlayersLogs.getInstance().savePlayerLogs();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUnlogged(String user) {
|
||||
PlayersLogs.getInstance().savePlayerLogs();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void purgeLogged() {
|
||||
PlayersLogs.getInstance().clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -717,17 +713,17 @@ public class FlatFile implements DataSource {
|
||||
String[] args = line.split(":");
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
auths.add(new PlayerAuth(args[0], args[1], "192.168.0.1", 0, "your@email.com"));
|
||||
auths.add(new PlayerAuth(args[0], args[1], "192.168.0.1", 0, "your@email.com", args[0]));
|
||||
case 3:
|
||||
auths.add(new PlayerAuth(args[0], args[1], args[2], 0, "your@email.com"));
|
||||
auths.add(new PlayerAuth(args[0], args[1], args[2], 0, "your@email.com", args[0]));
|
||||
case 4:
|
||||
auths.add(new PlayerAuth(args[0], args[1], args[2], Long.parseLong(args[3]), "your@email.com"));
|
||||
auths.add(new PlayerAuth(args[0], args[1], args[2], Long.parseLong(args[3]), "your@email.com", args[0]));
|
||||
case 7:
|
||||
auths.add(new PlayerAuth(args[0], args[1], args[2], Long.parseLong(args[3]), Double.parseDouble(args[4]), Double.parseDouble(args[5]), Double.parseDouble(args[6]), "unavailableworld", "your@email.com"));
|
||||
auths.add(new PlayerAuth(args[0], args[1], args[2], Long.parseLong(args[3]), Double.parseDouble(args[4]), Double.parseDouble(args[5]), Double.parseDouble(args[6]), "unavailableworld", "your@email.com", args[0]));
|
||||
case 8:
|
||||
auths.add(new PlayerAuth(args[0], args[1], args[2], Long.parseLong(args[3]), Double.parseDouble(args[4]), Double.parseDouble(args[5]), Double.parseDouble(args[6]), args[7], "your@email.com"));
|
||||
auths.add(new PlayerAuth(args[0], args[1], args[2], Long.parseLong(args[3]), Double.parseDouble(args[4]), Double.parseDouble(args[5]), Double.parseDouble(args[6]), args[7], "your@email.com", args[0]));
|
||||
case 9:
|
||||
auths.add(new PlayerAuth(args[0], args[1], args[2], Long.parseLong(args[3]), Double.parseDouble(args[4]), Double.parseDouble(args[5]), Double.parseDouble(args[6]), args[7], args[8]));
|
||||
auths.add(new PlayerAuth(args[0], args[1], args[2], Long.parseLong(args[3]), Double.parseDouble(args[4]), Double.parseDouble(args[5]), Double.parseDouble(args[6]), args[7], args[8], args[0]));
|
||||
}
|
||||
}
|
||||
} catch (FileNotFoundException ex) {
|
||||
@ -746,4 +742,9 @@ public class FlatFile implements DataSource {
|
||||
}
|
||||
return auths;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PlayerAuth> getLoggedPlayers() {
|
||||
return new ArrayList<PlayerAuth>();
|
||||
}
|
||||
}
|
||||
|
@ -41,6 +41,7 @@ public class MySQL implements DataSource {
|
||||
private String columnLogged;
|
||||
private List<String> columnOthers;
|
||||
private MiniConnectionPoolManager conPool;
|
||||
private String columnRealName;
|
||||
|
||||
public MySQL() {
|
||||
this.host = Settings.getMySQLHost;
|
||||
@ -63,6 +64,7 @@ public class MySQL implements DataSource {
|
||||
this.columnOthers = Settings.getMySQLOtherUsernameColumn;
|
||||
this.columnID = Settings.getMySQLColumnId;
|
||||
this.columnLogged = Settings.getMySQLColumnLogged;
|
||||
this.columnRealName = Settings.getMySQLColumnRealName;
|
||||
try {
|
||||
this.connect();
|
||||
this.setup();
|
||||
@ -157,6 +159,11 @@ public class MySQL implements DataSource {
|
||||
if (rs.next()) {
|
||||
st.executeUpdate("ALTER TABLE " + tableName + " MODIFY " + lastlocX + " DOUBLE NOT NULL DEFAULT '0.0', MODIFY " + lastlocY + " DOUBLE NOT NULL DEFAULT '0.0', MODIFY " + lastlocZ + " DOUBLE NOT NULL DEFAULT '0.0';");
|
||||
}
|
||||
rs.close();
|
||||
rs = con.getMetaData().getColumns(null, null, tableName, columnRealName);
|
||||
if (!rs.next()) {
|
||||
st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + columnRealName + " VARCHAR(255) DEFAULT 'Player' AFTER " + columnLogged + ";");
|
||||
}
|
||||
} finally {
|
||||
close(rs);
|
||||
close(st);
|
||||
@ -204,14 +211,14 @@ public class MySQL implements DataSource {
|
||||
if (rs.next()) {
|
||||
id = rs.getInt(columnID);
|
||||
if (rs.getString(columnIp).isEmpty() && rs.getString(columnIp) != null) {
|
||||
pAuth = new PlayerAuth(rs.getString(columnName).toLowerCase(), rs.getString(columnPassword), "192.168.0.1", rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail));
|
||||
pAuth = new PlayerAuth(rs.getString(columnName).toLowerCase(), rs.getString(columnPassword), "192.168.0.1", rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail), rs.getString(columnRealName));
|
||||
} else {
|
||||
if (!columnSalt.isEmpty()) {
|
||||
if (!columnGroup.isEmpty())
|
||||
pAuth = new PlayerAuth(rs.getString(columnName).toLowerCase(), rs.getString(columnPassword), rs.getString(columnSalt), rs.getInt(columnGroup), rs.getString(columnIp), rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail));
|
||||
else pAuth = new PlayerAuth(rs.getString(columnName).toLowerCase(), rs.getString(columnPassword), rs.getString(columnSalt), rs.getString(columnIp), rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail));
|
||||
pAuth = new PlayerAuth(rs.getString(columnName).toLowerCase(), rs.getString(columnPassword), rs.getString(columnSalt), rs.getInt(columnGroup), rs.getString(columnIp), rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail), rs.getString(columnRealName));
|
||||
else pAuth = new PlayerAuth(rs.getString(columnName).toLowerCase(), rs.getString(columnPassword), rs.getString(columnSalt), rs.getString(columnIp), rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail), rs.getString(columnRealName));
|
||||
} else {
|
||||
pAuth = new PlayerAuth(rs.getString(columnName).toLowerCase(), rs.getString(columnPassword), rs.getString(columnIp), rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail));
|
||||
pAuth = new PlayerAuth(rs.getString(columnName).toLowerCase(), rs.getString(columnPassword), rs.getString(columnIp), rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail), rs.getString(columnRealName));
|
||||
}
|
||||
}
|
||||
if (Settings.getPasswordHash == HashAlgorithm.XENFORO) {
|
||||
@ -249,27 +256,29 @@ public class MySQL implements DataSource {
|
||||
try {
|
||||
con = makeSureConnectionIsReady();
|
||||
if ((columnSalt == null || columnSalt.isEmpty()) || (auth.getSalt() == null || auth.getSalt().isEmpty())) {
|
||||
pst = con.prepareStatement("INSERT INTO " + tableName + "(" + columnName + "," + columnPassword + "," + columnIp + "," + columnLastLogin + ") VALUES (?,?,?,?);");
|
||||
pst = con.prepareStatement("INSERT INTO " + tableName + "(" + columnName + "," + columnPassword + "," + columnIp + "," + columnLastLogin + "," + columnRealName + ") VALUES (?,?,?,?,?);");
|
||||
pst.setString(1, auth.getNickname());
|
||||
pst.setString(2, auth.getHash());
|
||||
pst.setString(3, auth.getIp());
|
||||
pst.setLong(4, auth.getLastLogin());
|
||||
pst.setString(5, auth.getRealName());
|
||||
pst.executeUpdate();
|
||||
pst.close();
|
||||
} else {
|
||||
pst = con.prepareStatement("INSERT INTO " + tableName + "(" + columnName + "," + columnPassword + "," + columnIp + "," + columnLastLogin + "," + columnSalt + ") VALUES (?,?,?,?,?);");
|
||||
pst = con.prepareStatement("INSERT INTO " + tableName + "(" + columnName + "," + columnPassword + "," + columnIp + "," + columnLastLogin + "," + columnSalt + "," + columnRealName + ") VALUES (?,?,?,?,?,?);");
|
||||
pst.setString(1, auth.getNickname());
|
||||
pst.setString(2, auth.getHash());
|
||||
pst.setString(3, auth.getIp());
|
||||
pst.setLong(4, auth.getLastLogin());
|
||||
pst.setString(5, auth.getSalt());
|
||||
pst.setString(6, auth.getRealName());
|
||||
pst.executeUpdate();
|
||||
pst.close();
|
||||
}
|
||||
if (!columnOthers.isEmpty()) {
|
||||
for (String column : columnOthers) {
|
||||
pst = con.prepareStatement("UPDATE " + tableName + " SET " + column + "=? WHERE " + columnName + "=?;");
|
||||
pst.setString(1, auth.getNickname());
|
||||
pst.setString(1, auth.getRealName());
|
||||
pst.setString(2, auth.getNickname());
|
||||
pst.executeUpdate();
|
||||
pst.close();
|
||||
@ -338,72 +347,84 @@ public class MySQL implements DataSource {
|
||||
pst.setString(2, "first_name");
|
||||
pst.setString(3, "");
|
||||
pst.executeUpdate();
|
||||
pst.close();
|
||||
// Last Name
|
||||
pst = con.prepareStatement("INSERT INTO " + Settings.getWordPressPrefix + "usermeta (user_id, meta_key, meta_value) VALUES (?,?,?);");
|
||||
pst.setInt(1, id);
|
||||
pst.setString(2, "last_name");
|
||||
pst.setString(3, "");
|
||||
pst.executeUpdate();
|
||||
pst.close();
|
||||
// Nick Name
|
||||
pst = con.prepareStatement("INSERT INTO " + Settings.getWordPressPrefix + "usermeta (user_id, meta_key, meta_value) VALUES (?,?,?);");
|
||||
pst.setInt(1, id);
|
||||
pst.setString(2, "nickname");
|
||||
pst.setString(3, auth.getNickname());
|
||||
pst.executeUpdate();
|
||||
pst.close();
|
||||
// Description
|
||||
pst = con.prepareStatement("INSERT INTO " + Settings.getWordPressPrefix + "usermeta (user_id, meta_key, meta_value) VALUES (?,?,?);");
|
||||
pst.setInt(1, id);
|
||||
pst.setString(2, "description");
|
||||
pst.setString(3, "");
|
||||
pst.executeUpdate();
|
||||
pst.close();
|
||||
// Rich_Editing
|
||||
pst = con.prepareStatement("INSERT INTO " + Settings.getWordPressPrefix + "usermeta (user_id, meta_key, meta_value) VALUES (?,?,?);");
|
||||
pst.setInt(1, id);
|
||||
pst.setString(2, "rich_editing");
|
||||
pst.setString(3, "true");
|
||||
pst.executeUpdate();
|
||||
pst.close();
|
||||
// Comments_Shortcuts
|
||||
pst = con.prepareStatement("INSERT INTO " + Settings.getWordPressPrefix + "usermeta (user_id, meta_key, meta_value) VALUES (?,?,?);");
|
||||
pst.setInt(1, id);
|
||||
pst.setString(2, "comment_shortcuts");
|
||||
pst.setString(3, "false");
|
||||
pst.executeUpdate();
|
||||
pst.close();
|
||||
// admin_color
|
||||
pst = con.prepareStatement("INSERT INTO " + Settings.getWordPressPrefix + "usermeta (user_id, meta_key, meta_value) VALUES (?,?,?);");
|
||||
pst.setInt(1, id);
|
||||
pst.setString(2, "admin_color");
|
||||
pst.setString(3, "fresh");
|
||||
pst.executeUpdate();
|
||||
pst.close();
|
||||
// use_ssl
|
||||
pst = con.prepareStatement("INSERT INTO " + Settings.getWordPressPrefix + "usermeta (user_id, meta_key, meta_value) VALUES (?,?,?);");
|
||||
pst.setInt(1, id);
|
||||
pst.setString(2, "use_ssl");
|
||||
pst.setString(3, "0");
|
||||
pst.executeUpdate();
|
||||
pst.close();
|
||||
// show_admin_bar_front
|
||||
pst = con.prepareStatement("INSERT INTO " + Settings.getWordPressPrefix + "usermeta (user_id, meta_key, meta_value) VALUES (?,?,?);");
|
||||
pst.setInt(1, id);
|
||||
pst.setString(2, "show_admin_bar_front");
|
||||
pst.setString(3, "true");
|
||||
pst.executeUpdate();
|
||||
pst.close();
|
||||
// wp_capabilities
|
||||
pst = con.prepareStatement("INSERT INTO " + Settings.getWordPressPrefix + "usermeta (user_id, meta_key, meta_value) VALUES (?,?,?);");
|
||||
pst.setInt(1, id);
|
||||
pst.setString(2, "wp_capabilities");
|
||||
pst.setString(3, "a:1:{s:10:\"subscriber\";b:1;}");
|
||||
pst.executeUpdate();
|
||||
pst.close();
|
||||
// wp_user_level
|
||||
pst = con.prepareStatement("INSERT INTO " + Settings.getWordPressPrefix + "usermeta (user_id, meta_key, meta_value) VALUES (?,?,?);");
|
||||
pst.setInt(1, id);
|
||||
pst.setString(2, "wp_user_level");
|
||||
pst.setString(3, "0");
|
||||
pst.executeUpdate();
|
||||
pst.close();
|
||||
// default_password_nag
|
||||
pst = con.prepareStatement("INSERT INTO " + Settings.getWordPressPrefix + "usermeta (user_id, meta_key, meta_value) VALUES (?,?,?);");
|
||||
pst.setInt(1, id);
|
||||
pst.setString(2, "default_password_nag");
|
||||
pst.setString(3, "");
|
||||
pst.executeUpdate();
|
||||
pst.close();
|
||||
}
|
||||
}
|
||||
if (Settings.getPasswordHash == HashAlgorithm.XENFORO) {
|
||||
@ -424,6 +445,8 @@ public class MySQL implements DataSource {
|
||||
pst.setBlob(3, blob);
|
||||
pst.executeUpdate();
|
||||
}
|
||||
if (rs != null && !rs.isClosed())
|
||||
rs.close();
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
@ -470,6 +493,8 @@ public class MySQL implements DataSource {
|
||||
pst.setInt(2, id);
|
||||
pst.executeUpdate();
|
||||
}
|
||||
if (rs != null && !rs.isClosed())
|
||||
rs.close();
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
@ -1079,26 +1104,28 @@ public class MySQL implements DataSource {
|
||||
PlayerAuth pAuth = null;
|
||||
int id = rs.getInt(columnID);
|
||||
if (rs.getString(columnIp).isEmpty() && rs.getString(columnIp) != null) {
|
||||
pAuth = new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), "192.168.0.1", rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail));
|
||||
pAuth = new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), "192.168.0.1", rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail), rs.getString(columnRealName));
|
||||
} else {
|
||||
if (!columnSalt.isEmpty()) {
|
||||
if (!columnGroup.isEmpty())
|
||||
pAuth = new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), rs.getString(columnSalt), rs.getInt(columnGroup), rs.getString(columnIp), rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail));
|
||||
else pAuth = new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), rs.getString(columnSalt), rs.getString(columnIp), rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail));
|
||||
pAuth = new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), rs.getString(columnSalt), rs.getInt(columnGroup), rs.getString(columnIp), rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail), rs.getString(columnRealName));
|
||||
else pAuth = new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), rs.getString(columnSalt), rs.getString(columnIp), rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail), rs.getString(columnRealName));
|
||||
} else {
|
||||
pAuth = new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), rs.getString(columnIp), rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail));
|
||||
pAuth = new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), rs.getString(columnIp), rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail), rs.getString(columnRealName));
|
||||
}
|
||||
}
|
||||
if (Settings.getPasswordHash == HashAlgorithm.XENFORO) {
|
||||
rs.close();
|
||||
ResultSet rsid = null;
|
||||
pst = con.prepareStatement("SELECT * FROM xf_user_authenticate WHERE " + columnID + "=?;");
|
||||
pst.setInt(1, id);
|
||||
rs = pst.executeQuery();
|
||||
if (rs.next()) {
|
||||
Blob blob = rs.getBlob("data");
|
||||
rsid = pst.executeQuery();
|
||||
if (rsid.next()) {
|
||||
Blob blob = rsid.getBlob("data");
|
||||
byte[] bytes = blob.getBytes(1, (int) blob.length());
|
||||
pAuth.setHash(new String(bytes));
|
||||
}
|
||||
if (rsid != null)
|
||||
rsid.close();
|
||||
}
|
||||
if (pAuth != null)
|
||||
auths.add(pAuth);
|
||||
@ -1112,6 +1139,61 @@ public class MySQL implements DataSource {
|
||||
} finally {
|
||||
close(pst);
|
||||
close(con);
|
||||
close(rs);
|
||||
}
|
||||
return auths;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PlayerAuth> getLoggedPlayers() {
|
||||
List<PlayerAuth> auths = new ArrayList<PlayerAuth>();
|
||||
Connection con = null;
|
||||
PreparedStatement pst = null;
|
||||
ResultSet rs = null;
|
||||
try {
|
||||
con = makeSureConnectionIsReady();
|
||||
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE " + columnLogged + "=1;");
|
||||
rs = pst.executeQuery();
|
||||
while (rs.next()) {
|
||||
PlayerAuth pAuth = null;
|
||||
int id = rs.getInt(columnID);
|
||||
if (rs.getString(columnIp).isEmpty() && rs.getString(columnIp) != null) {
|
||||
pAuth = new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), "192.168.0.1", rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail), rs.getString(columnRealName));
|
||||
} else {
|
||||
if (!columnSalt.isEmpty()) {
|
||||
if (!columnGroup.isEmpty())
|
||||
pAuth = new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), rs.getString(columnSalt), rs.getInt(columnGroup), rs.getString(columnIp), rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail), rs.getString(columnRealName));
|
||||
else pAuth = new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), rs.getString(columnSalt), rs.getString(columnIp), rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail), rs.getString(columnRealName));
|
||||
} else {
|
||||
pAuth = new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), rs.getString(columnIp), rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail), rs.getString(columnRealName));
|
||||
}
|
||||
}
|
||||
if (Settings.getPasswordHash == HashAlgorithm.XENFORO) {
|
||||
ResultSet rsid = null;
|
||||
pst = con.prepareStatement("SELECT * FROM xf_user_authenticate WHERE " + columnID + "=?;");
|
||||
pst.setInt(1, id);
|
||||
rsid = pst.executeQuery();
|
||||
if (rsid.next()) {
|
||||
Blob blob = rsid.getBlob("data");
|
||||
byte[] bytes = blob.getBytes(1, (int) blob.length());
|
||||
pAuth.setHash(new String(bytes));
|
||||
}
|
||||
if (rsid != null)
|
||||
rsid.close();
|
||||
}
|
||||
if (pAuth != null)
|
||||
auths.add(pAuth);
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return auths;
|
||||
} catch (TimeoutException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return auths;
|
||||
} finally {
|
||||
close(pst);
|
||||
close(rs);
|
||||
close(con);
|
||||
}
|
||||
return auths;
|
||||
}
|
||||
|
@ -12,9 +12,7 @@ import java.util.List;
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||
import fr.xephi.authme.datasource.MiniConnectionPoolManager.TimeoutException;
|
||||
import fr.xephi.authme.settings.PlayersLogs;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
|
||||
public class SQLite implements DataSource {
|
||||
@ -34,6 +32,8 @@ public class SQLite implements DataSource {
|
||||
private String columnEmail;
|
||||
private String columnID;
|
||||
private Connection con;
|
||||
private String columnLogged;
|
||||
private String columnRealName;
|
||||
|
||||
public SQLite() {
|
||||
this.database = Settings.getMySQLDatabase;
|
||||
@ -50,6 +50,8 @@ public class SQLite implements DataSource {
|
||||
this.lastlocWorld = Settings.getMySQLlastlocWorld;
|
||||
this.columnEmail = Settings.getMySQLColumnEmail;
|
||||
this.columnID = Settings.getMySQLColumnId;
|
||||
this.columnLogged = Settings.getMySQLColumnLogged;
|
||||
this.columnRealName = Settings.getMySQLColumnRealName;
|
||||
|
||||
try {
|
||||
this.connect();
|
||||
@ -101,7 +103,7 @@ public class SQLite implements DataSource {
|
||||
rs.close();
|
||||
rs = con.getMetaData().getColumns(null, null, tableName, columnLastLogin);
|
||||
if (!rs.next()) {
|
||||
st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + columnLastLogin + " BIGINT;");
|
||||
st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + columnLastLogin + " BIGINT DEFAULT '0';");
|
||||
}
|
||||
rs.close();
|
||||
rs = con.getMetaData().getColumns(null, null, tableName, lastlocX);
|
||||
@ -118,7 +120,17 @@ public class SQLite implements DataSource {
|
||||
rs.close();
|
||||
rs = con.getMetaData().getColumns(null, null, tableName, columnEmail);
|
||||
if (!rs.next()) {
|
||||
st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + columnEmail + " VARCHAR(255) DEFAULT 'your@email.com';");
|
||||
st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + columnEmail + " VARCHAR(255) DEFAULT 'your@email.com';");
|
||||
}
|
||||
rs.close();
|
||||
rs = con.getMetaData().getColumns(null, null, tableName, columnLogged);
|
||||
if (!rs.next()) {
|
||||
st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + columnLogged + " BIGINT DEFAULT '0';");
|
||||
}
|
||||
rs.close();
|
||||
rs = con.getMetaData().getColumns(null, null, tableName, columnRealName);
|
||||
if (!rs.next()) {
|
||||
st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + columnRealName + " VARCHAR(255) DEFAULT 'Player';");
|
||||
}
|
||||
} finally {
|
||||
close(rs);
|
||||
@ -155,12 +167,12 @@ public class SQLite implements DataSource {
|
||||
rs = pst.executeQuery();
|
||||
if (rs.next()) {
|
||||
if (rs.getString(columnIp).isEmpty()) {
|
||||
return new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), "192.168.0.1", rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail));
|
||||
return new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), "192.168.0.1", rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail), rs.getString(columnRealName));
|
||||
} else {
|
||||
if (!columnSalt.isEmpty()) {
|
||||
return new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), rs.getString(columnSalt), rs.getInt(columnGroup), rs.getString(columnIp), rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail));
|
||||
return new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), rs.getString(columnSalt), rs.getInt(columnGroup), rs.getString(columnIp), rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail), rs.getString(columnRealName));
|
||||
} else {
|
||||
return new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), rs.getString(columnIp), rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail));
|
||||
return new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), rs.getString(columnIp), rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail), rs.getString(columnRealName));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -180,19 +192,21 @@ public class SQLite implements DataSource {
|
||||
PreparedStatement pst = null;
|
||||
try {
|
||||
if (columnSalt.isEmpty() && auth.getSalt().isEmpty()) {
|
||||
pst = con.prepareStatement("INSERT INTO " + tableName + "(" + columnName + "," + columnPassword + "," + columnIp + "," + columnLastLogin + ") VALUES (?,?,?,?);");
|
||||
pst = con.prepareStatement("INSERT INTO " + tableName + "(" + columnName + "," + columnPassword + "," + columnIp + "," + columnLastLogin + "," + columnRealName + ") VALUES (?,?,?,?,?);");
|
||||
pst.setString(1, auth.getNickname());
|
||||
pst.setString(2, auth.getHash());
|
||||
pst.setString(3, auth.getIp());
|
||||
pst.setLong(4, auth.getLastLogin());
|
||||
pst.setString(5, auth.getRealName());
|
||||
pst.executeUpdate();
|
||||
} else {
|
||||
pst = con.prepareStatement("INSERT INTO " + tableName + "(" + columnName + "," + columnPassword + "," + columnIp + "," + columnLastLogin + "," + columnSalt + ") VALUES (?,?,?,?,?);");
|
||||
pst = con.prepareStatement("INSERT INTO " + tableName + "(" + columnName + "," + columnPassword + "," + columnIp + "," + columnLastLogin + "," + columnSalt + "," + columnRealName + ") VALUES (?,?,?,?,?,?);");
|
||||
pst.setString(1, auth.getNickname());
|
||||
pst.setString(2, auth.getHash());
|
||||
pst.setString(3, auth.getIp());
|
||||
pst.setLong(4, auth.getLastLogin());
|
||||
pst.setString(5, auth.getSalt());
|
||||
pst.setString(6, auth.getRealName());
|
||||
pst.executeUpdate();
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
@ -225,10 +239,11 @@ public class SQLite implements DataSource {
|
||||
public boolean updateSession(PlayerAuth auth) {
|
||||
PreparedStatement pst = null;
|
||||
try {
|
||||
pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnIp + "=?, " + columnLastLogin + "=? WHERE " + columnName + "=?;");
|
||||
pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnIp + "=?, " + columnLastLogin + "=?, " + columnRealName + "=? WHERE " + columnName + "=?;");
|
||||
pst.setString(1, auth.getIp());
|
||||
pst.setLong(2, auth.getLastLogin());
|
||||
pst.setString(3, auth.getNickname());
|
||||
pst.setString(3, auth.getRealName());
|
||||
pst.setString(4, auth.getNickname());
|
||||
pst.executeUpdate();
|
||||
} catch (SQLException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
@ -509,22 +524,86 @@ public class SQLite implements DataSource {
|
||||
|
||||
@Override
|
||||
public boolean isLogged(String user) {
|
||||
return PlayerCache.getInstance().isAuthenticated(user);
|
||||
PreparedStatement pst = null;
|
||||
ResultSet rs = null;
|
||||
try {
|
||||
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE LOWER(" + columnName + ")=?;");
|
||||
pst.setString(1, user);
|
||||
rs = pst.executeQuery();
|
||||
if (rs.next())
|
||||
return (rs.getInt(columnLogged) == 1);
|
||||
} catch (SQLException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return false;
|
||||
} catch (TimeoutException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return false;
|
||||
} finally {
|
||||
close(rs);
|
||||
close(pst);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLogged(String user) {
|
||||
PlayersLogs.getInstance().savePlayerLogs();
|
||||
PreparedStatement pst = null;
|
||||
try {
|
||||
pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnLogged + "=? WHERE LOWER(" + columnName + ")=?;");
|
||||
pst.setInt(1, 1);
|
||||
pst.setString(2, user);
|
||||
pst.executeUpdate();
|
||||
} catch (SQLException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return;
|
||||
} catch (TimeoutException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return;
|
||||
} finally {
|
||||
close(pst);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUnlogged(String user) {
|
||||
PlayersLogs.getInstance().savePlayerLogs();
|
||||
PreparedStatement pst = null;
|
||||
if (user != null)
|
||||
try {
|
||||
pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnLogged + "=? WHERE LOWER(" + columnName + ")=?;");
|
||||
pst.setInt(1, 0);
|
||||
pst.setString(2, user);
|
||||
pst.executeUpdate();
|
||||
} catch (SQLException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return;
|
||||
} catch (TimeoutException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return;
|
||||
} finally {
|
||||
close(pst);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void purgeLogged() {
|
||||
PlayersLogs.getInstance().clear();
|
||||
PreparedStatement pst = null;
|
||||
try {
|
||||
pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnLogged + "=? WHERE " + columnLogged + "=?;");
|
||||
pst.setInt(1, 0);
|
||||
pst.setInt(2, 1);
|
||||
pst.executeUpdate();
|
||||
} catch (SQLException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return;
|
||||
} catch (TimeoutException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return;
|
||||
} finally {
|
||||
close(pst);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -581,12 +660,46 @@ public class SQLite implements DataSource {
|
||||
while (rs.next()) {
|
||||
PlayerAuth pAuth = null;
|
||||
if (rs.getString(columnIp).isEmpty()) {
|
||||
pAuth = new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), "127.0.0.1", rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail));
|
||||
pAuth = new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), "127.0.0.1", rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail), rs.getString(columnRealName));
|
||||
} else {
|
||||
if (!columnSalt.isEmpty()) {
|
||||
pAuth = new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), rs.getString(columnSalt), rs.getInt(columnGroup), rs.getString(columnIp), rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail));
|
||||
pAuth = new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), rs.getString(columnSalt), rs.getInt(columnGroup), rs.getString(columnIp), rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail), rs.getString(columnRealName));
|
||||
} else {
|
||||
pAuth = new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), rs.getString(columnIp), rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail));
|
||||
pAuth = new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), rs.getString(columnIp), rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail), rs.getString(columnRealName));
|
||||
}
|
||||
}
|
||||
if (pAuth != null)
|
||||
auths.add(pAuth);
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return auths;
|
||||
} catch (TimeoutException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return auths;
|
||||
} finally {
|
||||
close(pst);
|
||||
}
|
||||
return auths;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PlayerAuth> getLoggedPlayers() {
|
||||
List<PlayerAuth> auths = new ArrayList<PlayerAuth>();
|
||||
PreparedStatement pst = null;
|
||||
ResultSet rs = null;
|
||||
try {
|
||||
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE " + columnLogged + "=1;");
|
||||
rs = pst.executeQuery();
|
||||
while (rs.next()) {
|
||||
PlayerAuth pAuth = null;
|
||||
if (rs.getString(columnIp).isEmpty()) {
|
||||
pAuth = new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), "127.0.0.1", rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail), rs.getString(columnRealName));
|
||||
} else {
|
||||
if (!columnSalt.isEmpty()) {
|
||||
pAuth = new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), rs.getString(columnSalt), rs.getInt(columnGroup), rs.getString(columnIp), rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail), rs.getString(columnRealName));
|
||||
} else {
|
||||
pAuth = new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), rs.getString(columnIp), rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail), rs.getString(columnRealName));
|
||||
}
|
||||
}
|
||||
if (pAuth != null)
|
||||
|
@ -827,7 +827,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
|
||||
Location spawn = plugin.getSpawnLocation(player);
|
||||
if (Settings.isSaveQuitLocationEnabled && plugin.database.isAuthAvailable(name)) {
|
||||
final PlayerAuth auth = new PlayerAuth(name, spawn.getX(), spawn.getY(), spawn.getZ(), spawn.getWorld().getName());
|
||||
final PlayerAuth auth = new PlayerAuth(name, spawn.getX(), spawn.getY(), spawn.getZ(), spawn.getWorld().getName(), player.getName());
|
||||
try {
|
||||
plugin.database.updateQuitLoc(auth);
|
||||
} catch (NullPointerException npe) {
|
||||
|
27
src/main/java/fr/xephi/authme/modules/Module.java
Normal file
27
src/main/java/fr/xephi/authme/modules/Module.java
Normal file
@ -0,0 +1,27 @@
|
||||
package fr.xephi.authme.modules;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
|
||||
public interface Module {
|
||||
|
||||
public String getName();
|
||||
|
||||
public AuthMe getInstanceOfAuthMe();
|
||||
|
||||
public Module getInstance();
|
||||
|
||||
public enum ModuleType {
|
||||
MANAGER,
|
||||
MYSQL,
|
||||
ACTIONS,
|
||||
CONVERTERS,
|
||||
EMAILS,
|
||||
CUSTOM;
|
||||
}
|
||||
|
||||
public ModuleType getType();
|
||||
|
||||
public boolean load();
|
||||
|
||||
public boolean unload();
|
||||
}
|
@ -100,6 +100,26 @@ public class AsyncronousJoin {
|
||||
}
|
||||
final Location spawnLoc = plugin.getSpawnLocation(player);
|
||||
if (database.isAuthAvailable(name)) {
|
||||
PlayerAuth auth = database.getAuth(name);
|
||||
if (!auth.getRealName().equals("Player") && !auth.getRealName().equals(player.getName())) {
|
||||
final GameMode gM = AuthMePlayerListener.gameMode.get(name);
|
||||
sched.scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (gM != null) {
|
||||
AuthMePlayerListener.causeByAuthMe.put(name, true);
|
||||
player.setGameMode(gM);
|
||||
AuthMePlayerListener.causeByAuthMe.put(name, false);
|
||||
}
|
||||
player.kickPlayer("You are not the Owner of this account, please try another name!");
|
||||
if (Settings.banUnsafeIp)
|
||||
plugin.getServer().banIP(ip);
|
||||
}
|
||||
|
||||
}, 1);
|
||||
return;
|
||||
}
|
||||
if (Settings.isForceSurvivalModeEnabled && !Settings.forceOnlyAfterLogin) {
|
||||
sched.scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
|
||||
|
@ -50,11 +50,11 @@ public class AsyncronousLogin {
|
||||
protected boolean needsCaptcha() {
|
||||
if (Settings.useCaptcha) {
|
||||
if (!plugin.captcha.containsKey(name)) {
|
||||
plugin.captcha.put(name, 1);
|
||||
plugin.captcha.putIfAbsent(name, 1);
|
||||
} else {
|
||||
int i = plugin.captcha.get(name) + 1;
|
||||
plugin.captcha.remove(name);
|
||||
plugin.captcha.put(name, i);
|
||||
plugin.captcha.putIfAbsent(name, i);
|
||||
}
|
||||
if (plugin.captcha.containsKey(name) && plugin.captcha.get(name) >= Settings.maxLoginTry) {
|
||||
plugin.cap.put(name, rdm.nextString());
|
||||
@ -133,7 +133,7 @@ public class AsyncronousLogin {
|
||||
return;
|
||||
}
|
||||
if (passwordVerified && player.isOnline()) {
|
||||
PlayerAuth auth = new PlayerAuth(name, hash, getIP(), new Date().getTime(), email);
|
||||
PlayerAuth auth = new PlayerAuth(name, hash, getIP(), new Date().getTime(), email, realName);
|
||||
database.updateSession(auth);
|
||||
|
||||
if (Settings.useCaptcha) {
|
||||
@ -157,7 +157,7 @@ public class AsyncronousLogin {
|
||||
}
|
||||
|
||||
if (!Settings.noConsoleSpam)
|
||||
ConsoleLogger.info(player.getName() + " logged in!");
|
||||
ConsoleLogger.info(realName + " logged in!");
|
||||
|
||||
// makes player isLoggedin via API
|
||||
PlayerCache.getInstance().addPlayer(auth);
|
||||
@ -178,7 +178,7 @@ public class AsyncronousLogin {
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, syncronousPlayerLogin);
|
||||
} else if (player.isOnline()) {
|
||||
if (!Settings.noConsoleSpam)
|
||||
ConsoleLogger.info(player.getName() + " used the wrong password");
|
||||
ConsoleLogger.info(realName + " used the wrong password");
|
||||
if (Settings.isKickOnWrongPasswordEnabled) {
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
|
||||
|
@ -51,13 +51,13 @@ public class AsyncronousQuit {
|
||||
|
||||
if (PlayerCache.getInstance().isAuthenticated(name) && !player.isDead()) {
|
||||
if (Settings.isSaveQuitLocationEnabled && database.isAuthAvailable(name)) {
|
||||
final PlayerAuth auth = new PlayerAuth(name, loc.getX(), loc.getY(), loc.getZ(), loc.getWorld().getName());
|
||||
final PlayerAuth auth = new PlayerAuth(name, loc.getX(), loc.getY(), loc.getZ(), loc.getWorld().getName(), player.getName());
|
||||
try {
|
||||
database.updateQuitLoc(auth);
|
||||
} catch (NullPointerException npe) {
|
||||
}
|
||||
}
|
||||
PlayerAuth auth = new PlayerAuth(name, ip, System.currentTimeMillis());
|
||||
PlayerAuth auth = new PlayerAuth(name, ip, System.currentTimeMillis(), player.getName());
|
||||
database.updateSession(auth);
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,6 @@ import fr.xephi.authme.cache.auth.PlayerCache;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.security.PasswordSecurity;
|
||||
import fr.xephi.authme.settings.Messages;
|
||||
import fr.xephi.authme.settings.PlayersLogs;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
|
||||
public class AsyncronousRegister {
|
||||
@ -62,12 +61,12 @@ public class AsyncronousRegister {
|
||||
m.send(player, "password_error_nick");
|
||||
allowRegister = false;
|
||||
}
|
||||
|
||||
|
||||
else if (password.length() < Settings.getPasswordMinLen || password.length() > Settings.passwordMaxLength) {
|
||||
m.send(player, "pass_len");
|
||||
allowRegister = false;
|
||||
}
|
||||
|
||||
|
||||
else if (!Settings.unsafePasswords.isEmpty()) {
|
||||
if (Settings.unsafePasswords.contains(password.toLowerCase())) {
|
||||
m.send(player, "password_error_unsafe");
|
||||
@ -77,7 +76,6 @@ public class AsyncronousRegister {
|
||||
|
||||
else if (database.isAuthAvailable(name)) {
|
||||
m.send(player, "user_regged");
|
||||
PlayersLogs.getInstance().savePlayerLogs();
|
||||
allowRegister = false;
|
||||
}
|
||||
|
||||
@ -117,7 +115,7 @@ public class AsyncronousRegister {
|
||||
PlayerAuth auth = null;
|
||||
try {
|
||||
final String hashnew = PasswordSecurity.getHash(Settings.getPasswordHash, password, name);
|
||||
auth = new PlayerAuth(name, hashnew, getIp(), 0, (int) player.getLocation().getX(), (int) player.getLocation().getY(), (int) player.getLocation().getZ(), player.getLocation().getWorld().getName(), email);
|
||||
auth = new PlayerAuth(name, hashnew, getIp(), 0, (int) player.getLocation().getX(), (int) player.getLocation().getY(), (int) player.getLocation().getZ(), player.getLocation().getWorld().getName(), email, player.getName());
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
ConsoleLogger.showError(e.getMessage());
|
||||
m.send(player, "error");
|
||||
@ -146,9 +144,9 @@ public class AsyncronousRegister {
|
||||
return;
|
||||
}
|
||||
if (Settings.getMySQLColumnSalt.isEmpty() && !PasswordSecurity.userSalt.containsKey(name)) {
|
||||
auth = new PlayerAuth(name, hash, getIp(), new Date().getTime(), "your@email.com");
|
||||
auth = new PlayerAuth(name, hash, getIp(), new Date().getTime(), "your@email.com", player.getName());
|
||||
} else {
|
||||
auth = new PlayerAuth(name, hash, PasswordSecurity.userSalt.get(name), getIp(), new Date().getTime());
|
||||
auth = new PlayerAuth(name, hash, PasswordSecurity.userSalt.get(name), getIp(), new Date().getTime(), player.getName());
|
||||
}
|
||||
if (!database.saveAuth(auth)) {
|
||||
m.send(player, "error");
|
||||
|
@ -18,7 +18,6 @@ import fr.xephi.authme.events.LoginEvent;
|
||||
import fr.xephi.authme.events.RegisterTeleportEvent;
|
||||
import fr.xephi.authme.events.RestoreInventoryEvent;
|
||||
import fr.xephi.authme.settings.Messages;
|
||||
import fr.xephi.authme.settings.PlayersLogs;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import fr.xephi.authme.task.MessageTask;
|
||||
import fr.xephi.authme.task.TimeoutTask;
|
||||
@ -73,7 +72,6 @@ public class ProcessSyncronousPasswordRegister implements Runnable {
|
||||
BukkitTask msgT = sched.runTaskAsynchronously(plugin, new MessageTask(plugin, name, m.send("login_msg"), interval));
|
||||
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(msgT);
|
||||
try {
|
||||
PlayersLogs.getInstance().save();
|
||||
if (player.isInsideVehicle())
|
||||
player.getVehicle().eject();
|
||||
} catch (NullPointerException npe) {
|
||||
|
@ -1,64 +0,0 @@
|
||||
package fr.xephi.authme.settings;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Xephi59
|
||||
*/
|
||||
public class PlayersLogs extends CustomConfiguration {
|
||||
|
||||
private static PlayersLogs pllog = null;
|
||||
|
||||
public PlayersLogs() {
|
||||
super(new File("." + File.separator + "plugins" + File.separator + "AuthMe" + File.separator + "players.yml"));
|
||||
pllog = this;
|
||||
load();
|
||||
save();
|
||||
}
|
||||
|
||||
public void loadPlayers() {
|
||||
DataSource database = AuthMe.getInstance().database;
|
||||
List<String> list = this.getStringList("players");
|
||||
if (list == null || list.isEmpty())
|
||||
return;
|
||||
for (String s : list) {
|
||||
PlayerAuth auth = database.getAuth(s);
|
||||
if (auth == null)
|
||||
continue;
|
||||
auth.setLastLogin(new Date().getTime());
|
||||
database.updateSession(auth);
|
||||
PlayerCache.getInstance().addPlayer(auth);
|
||||
}
|
||||
}
|
||||
|
||||
public static PlayersLogs getInstance() {
|
||||
if (pllog == null) {
|
||||
pllog = new PlayersLogs();
|
||||
}
|
||||
return pllog;
|
||||
}
|
||||
|
||||
public void savePlayerLogs() {
|
||||
List<String> players = new ArrayList<String>();
|
||||
for (String s : PlayerCache.getInstance().getCache().keySet()) {
|
||||
players.add(s);
|
||||
}
|
||||
this.set("players", players);
|
||||
this.save();
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
this.set("players", new ArrayList<String>());
|
||||
this.save();
|
||||
}
|
||||
|
||||
}
|
@ -82,7 +82,8 @@ public final class Settings extends YamlConfiguration {
|
||||
getmailPassword, getmailSMTP, getMySQLColumnId, getmailSenderName,
|
||||
getMailSubject, getMailText, getMySQLlastlocWorld, defaultWorld,
|
||||
getPhpbbPrefix, getWordPressPrefix, getMySQLColumnLogged,
|
||||
spawnPriority, crazyloginFileName, getPassRegex;
|
||||
spawnPriority, crazyloginFileName, getPassRegex,
|
||||
getMySQLColumnRealName;
|
||||
|
||||
public static int getWarnMessageInterval, getSessionTimeout,
|
||||
getRegistrationTimeout, getMaxNickLength, getMinNickLength,
|
||||
@ -161,6 +162,7 @@ public final class Settings extends YamlConfiguration {
|
||||
getMySQLlastlocY = configFile.getString("DataSource.mySQLlastlocY", "y");
|
||||
getMySQLlastlocZ = configFile.getString("DataSource.mySQLlastlocZ", "z");
|
||||
getMySQLlastlocWorld = configFile.getString("DataSource.mySQLlastlocWorld", "world");
|
||||
getMySQLColumnRealName = configFile.getString("DataSource.mySQLRealName", "realname");
|
||||
getNonActivatedGroup = configFile.getInt("ExternalBoardOptions.nonActivedUserGroup", -1);
|
||||
unRegisteredGroup = configFile.getString("GroupOptions.UnregisteredPlayerGroup", "");
|
||||
getUnrestrictedName = configFile.getStringList("settings.unrestrictions.UnrestrictedName");
|
||||
@ -328,6 +330,7 @@ public final class Settings extends YamlConfiguration {
|
||||
getMySQLlastlocY = configFile.getString("DataSource.mySQLlastlocY", "y");
|
||||
getMySQLlastlocZ = configFile.getString("DataSource.mySQLlastlocZ", "z");
|
||||
getMySQLlastlocWorld = configFile.getString("DataSource.mySQLlastlocWorld", "world");
|
||||
getMySQLColumnRealName = configFile.getString("DataSource.mySQLRealName", "realname");
|
||||
getNonActivatedGroup = configFile.getInt("ExternalBoardOptions.nonActivedUserGroup", -1);
|
||||
unRegisteredGroup = configFile.getString("GroupOptions.UnregisteredPlayerGroup", "");
|
||||
getUnrestrictedName = configFile.getStringList("settings.unrestrictions.UnrestrictedName");
|
||||
@ -592,6 +595,10 @@ public final class Settings extends YamlConfiguration {
|
||||
set("Email.generateImage", true);
|
||||
changes = true;
|
||||
}
|
||||
if (!contains("DataSource.mySQLRealName")) {
|
||||
set("DataSource.mySQLRealName", "realname");
|
||||
changes = true;
|
||||
}
|
||||
|
||||
if (changes) {
|
||||
plugin.getLogger().warning("Merge new Config Options - I'm not an error, please don't report me");
|
||||
|
@ -37,6 +37,8 @@ DataSource:
|
||||
mySQLlastlocZ: z
|
||||
# Column for SaveQuitLocation - World name
|
||||
mySQLlastlocWorld: world
|
||||
# Column for RealName
|
||||
mySQLRealName: realname
|
||||
GroupOptions:
|
||||
# if you want to set up a particulary Permission Group for
|
||||
# users that arent registered yet. Pay attention this option
|
||||
|
Loading…
Reference in New Issue
Block a user