mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-11-24 11:15:19 +01:00
Merge branch 'db-improve'
Conflicts: src/main/java/fr/xephi/authme/settings/Settings.java
This commit is contained in:
commit
a14e3260dc
@ -13,10 +13,20 @@ import fr.xephi.authme.command.CommandHandler;
|
|||||||
import fr.xephi.authme.command.CommandInitializer;
|
import fr.xephi.authme.command.CommandInitializer;
|
||||||
import fr.xephi.authme.converter.Converter;
|
import fr.xephi.authme.converter.Converter;
|
||||||
import fr.xephi.authme.converter.ForceFlatToSqlite;
|
import fr.xephi.authme.converter.ForceFlatToSqlite;
|
||||||
import fr.xephi.authme.datasource.*;
|
import fr.xephi.authme.datasource.CacheDataSource;
|
||||||
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
|
import fr.xephi.authme.datasource.FlatFile;
|
||||||
|
import fr.xephi.authme.datasource.MySQL;
|
||||||
|
import fr.xephi.authme.datasource.SQLite;
|
||||||
import fr.xephi.authme.hooks.BungeeCordMessage;
|
import fr.xephi.authme.hooks.BungeeCordMessage;
|
||||||
import fr.xephi.authme.hooks.EssSpawn;
|
import fr.xephi.authme.hooks.EssSpawn;
|
||||||
import fr.xephi.authme.listener.*;
|
import fr.xephi.authme.listener.AuthMeBlockListener;
|
||||||
|
import fr.xephi.authme.listener.AuthMeEntityListener;
|
||||||
|
import fr.xephi.authme.listener.AuthMeInventoryPacketAdapter;
|
||||||
|
import fr.xephi.authme.listener.AuthMePlayerListener;
|
||||||
|
import fr.xephi.authme.listener.AuthMePlayerListener16;
|
||||||
|
import fr.xephi.authme.listener.AuthMePlayerListener18;
|
||||||
|
import fr.xephi.authme.listener.AuthMeServerListener;
|
||||||
import fr.xephi.authme.modules.ModuleManager;
|
import fr.xephi.authme.modules.ModuleManager;
|
||||||
import fr.xephi.authme.output.ConsoleFilter;
|
import fr.xephi.authme.output.ConsoleFilter;
|
||||||
import fr.xephi.authme.output.Log4JFilter;
|
import fr.xephi.authme.output.Log4JFilter;
|
||||||
@ -25,7 +35,9 @@ import fr.xephi.authme.output.Messages;
|
|||||||
import fr.xephi.authme.permission.PermissionsManager;
|
import fr.xephi.authme.permission.PermissionsManager;
|
||||||
import fr.xephi.authme.permission.PlayerPermission;
|
import fr.xephi.authme.permission.PlayerPermission;
|
||||||
import fr.xephi.authme.process.Management;
|
import fr.xephi.authme.process.Management;
|
||||||
import fr.xephi.authme.settings.*;
|
import fr.xephi.authme.settings.OtherAccounts;
|
||||||
|
import fr.xephi.authme.settings.Settings;
|
||||||
|
import fr.xephi.authme.settings.Spawn;
|
||||||
import fr.xephi.authme.util.GeoLiteAPI;
|
import fr.xephi.authme.util.GeoLiteAPI;
|
||||||
import fr.xephi.authme.util.StringUtils;
|
import fr.xephi.authme.util.StringUtils;
|
||||||
import fr.xephi.authme.util.Utils;
|
import fr.xephi.authme.util.Utils;
|
||||||
@ -579,20 +591,19 @@ public class AuthMe extends JavaPlugin {
|
|||||||
|
|
||||||
if (isSQLite) {
|
if (isSQLite) {
|
||||||
server.getScheduler().runTaskAsynchronously(this, new Runnable() {
|
server.getScheduler().runTaskAsynchronously(this, new Runnable() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
int accounts = database.getAccountsRegistered();
|
int accounts = database.getAccountsRegistered();
|
||||||
if (accounts >= 4000)
|
if (accounts >= 4000) {
|
||||||
ConsoleLogger.showError("YOU'RE USING THE SQLITE DATABASE WITH " + accounts + "+ ACCOUNTS, FOR BETTER PERFORMANCES, PLEASE UPGRADE TO MYSQL!!");
|
ConsoleLogger.showError("YOU'RE USING THE SQLITE DATABASE WITH "
|
||||||
|
+ accounts + "+ ACCOUNTS, FOR BETTER PERFORMANCES, PLEASE UPGRADE TO MYSQL!!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Settings.isCachingEnabled) {
|
if (Settings.isCachingEnabled) {
|
||||||
database = new CacheDataSource(this, database);
|
database = new CacheDataSource(this, database);
|
||||||
} else {
|
|
||||||
database = new DatabaseCalls(database);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Settings.getDataSource == DataSource.DataSourceType.FILE) {
|
if (Settings.getDataSource == DataSource.DataSourceType.FILE) {
|
||||||
@ -920,14 +931,14 @@ public class AuthMe extends JavaPlugin {
|
|||||||
String realIP = player.getAddress().getAddress().getHostAddress();
|
String realIP = player.getAddress().getAddress().getHostAddress();
|
||||||
String sUrl = "http://monitor-1.verygames.net/api/?action=ipclean-real-ip&out=raw&ip=%IP%&port=%PORT%";
|
String sUrl = "http://monitor-1.verygames.net/api/?action=ipclean-real-ip&out=raw&ip=%IP%&port=%PORT%";
|
||||||
sUrl = sUrl.replace("%IP%", player.getAddress().getAddress().getHostAddress())
|
sUrl = sUrl.replace("%IP%", player.getAddress().getAddress().getHostAddress())
|
||||||
.replace("%PORT%", "" + player.getAddress().getPort());
|
.replace("%PORT%", "" + player.getAddress().getPort());
|
||||||
try {
|
try {
|
||||||
URL url = new URL(sUrl);
|
URL url = new URL(sUrl);
|
||||||
URLConnection urlCon = url.openConnection();
|
URLConnection urlCon = url.openConnection();
|
||||||
try (BufferedReader in = new BufferedReader(new InputStreamReader(urlCon.getInputStream()))) {
|
try (BufferedReader in = new BufferedReader(new InputStreamReader(urlCon.getInputStream()))) {
|
||||||
String inputLine = in.readLine();
|
String inputLine = in.readLine();
|
||||||
if (!StringUtils.isEmpty(inputLine) && !inputLine.equalsIgnoreCase("error")
|
if (!StringUtils.isEmpty(inputLine) && !inputLine.equalsIgnoreCase("error")
|
||||||
&& !inputLine.contains("error")) {
|
&& !inputLine.contains("error")) {
|
||||||
realIP = inputLine;
|
realIP = inputLine;
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
@ -3,6 +3,11 @@ package fr.xephi.authme.cache.auth;
|
|||||||
import fr.xephi.authme.security.HashAlgorithm;
|
import fr.xephi.authme.security.HashAlgorithm;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
|
|
||||||
|
import static com.google.common.base.Objects.firstNonNull;
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
import static com.google.common.base.Strings.nullToEmpty;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
public class PlayerAuth {
|
public class PlayerAuth {
|
||||||
@ -461,7 +466,7 @@ public class PlayerAuth {
|
|||||||
* @return String
|
* @return String
|
||||||
*/
|
*/
|
||||||
public String serialize() {
|
public String serialize() {
|
||||||
StringBuilder str = new StringBuilder();
|
StringBuffer str = new StringBuffer();
|
||||||
char d = ';';
|
char d = ';';
|
||||||
str.append(this.nickname).append(d);
|
str.append(this.nickname).append(d);
|
||||||
str.append(this.realName).append(d);
|
str.append(this.realName).append(d);
|
||||||
@ -503,34 +508,35 @@ public class PlayerAuth {
|
|||||||
|
|
||||||
public static final class Builder {
|
public static final class Builder {
|
||||||
private String name;
|
private String name;
|
||||||
private String realName = "Player";
|
private String realName;
|
||||||
private String hash = "";
|
private String hash;
|
||||||
private String salt = "";
|
private String salt;
|
||||||
private String ip = "127.0.0.1";
|
private String ip;
|
||||||
private String world = "world";
|
private String world;
|
||||||
|
private String email;
|
||||||
|
private int groupId = -1;
|
||||||
private double x = 0.0f;
|
private double x = 0.0f;
|
||||||
private double y = 0.0f;
|
private double y = 0.0f;
|
||||||
private double z = 0.0f;
|
private double z = 0.0f;
|
||||||
private long lastLogin = System.currentTimeMillis();
|
private long lastLogin = System.currentTimeMillis();
|
||||||
private int groupId = -1;
|
|
||||||
private String email = "your@email.com";
|
|
||||||
|
|
||||||
public PlayerAuth build() {
|
public PlayerAuth build() {
|
||||||
return new PlayerAuth(
|
return new PlayerAuth(
|
||||||
name,
|
checkNotNull(name).toLowerCase(),
|
||||||
hash,
|
nullToEmpty(hash),
|
||||||
salt,
|
nullToEmpty(salt),
|
||||||
groupId,
|
groupId,
|
||||||
ip,
|
firstNonNull(ip, "127.0.0.1"),
|
||||||
lastLogin,
|
lastLogin,
|
||||||
x, y, z, world,
|
x, y, z,
|
||||||
email,
|
firstNonNull(world, "world"),
|
||||||
realName
|
firstNonNull(email, "your@email.com"),
|
||||||
|
firstNonNull(realName, "Player")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder name(String name) {
|
public Builder name(String name) {
|
||||||
this.name = name.toLowerCase();
|
this.name = name;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,513 +0,0 @@
|
|||||||
package fr.xephi.authme.datasource;
|
|
||||||
|
|
||||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.concurrent.Callable;
|
|
||||||
import java.util.concurrent.ExecutorService;
|
|
||||||
import java.util.concurrent.Executors;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public class DatabaseCalls implements DataSource {
|
|
||||||
|
|
||||||
private final ExecutorService exec;
|
|
||||||
private final DataSource database;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor for DatabaseCalls.
|
|
||||||
*
|
|
||||||
* @param database DataSource
|
|
||||||
*/
|
|
||||||
public DatabaseCalls(DataSource database) {
|
|
||||||
this.database = database;
|
|
||||||
this.exec = Executors.newCachedThreadPool();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Method isAuthAvailable.
|
|
||||||
*
|
|
||||||
* @param user String
|
|
||||||
*
|
|
||||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#isAuthAvailable(String)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public synchronized boolean isAuthAvailable(final String user) {
|
|
||||||
try {
|
|
||||||
return exec.submit(new Callable<Boolean>() {
|
|
||||||
public Boolean call() throws Exception {
|
|
||||||
return database.isAuthAvailable(user);
|
|
||||||
}
|
|
||||||
}).get();
|
|
||||||
} catch (Exception e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Method getAuth.
|
|
||||||
*
|
|
||||||
* @param user String
|
|
||||||
*
|
|
||||||
* @return PlayerAuth * @see fr.xephi.authme.datasource.DataSource#getAuth(String)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public synchronized PlayerAuth getAuth(final String user) {
|
|
||||||
try {
|
|
||||||
return exec.submit(new Callable<PlayerAuth>() {
|
|
||||||
public PlayerAuth call() throws Exception {
|
|
||||||
return database.getAuth(user);
|
|
||||||
}
|
|
||||||
}).get();
|
|
||||||
} catch (Exception e) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Method saveAuth.
|
|
||||||
*
|
|
||||||
* @param auth PlayerAuth
|
|
||||||
*
|
|
||||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#saveAuth(PlayerAuth)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public synchronized boolean saveAuth(final PlayerAuth auth) {
|
|
||||||
try {
|
|
||||||
return exec.submit(new Callable<Boolean>() {
|
|
||||||
public Boolean call() throws Exception {
|
|
||||||
return database.saveAuth(auth);
|
|
||||||
}
|
|
||||||
}).get();
|
|
||||||
} catch (Exception e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Method updateSession.
|
|
||||||
*
|
|
||||||
* @param auth PlayerAuth
|
|
||||||
*
|
|
||||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateSession(PlayerAuth)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public synchronized boolean updateSession(final PlayerAuth auth) {
|
|
||||||
try {
|
|
||||||
return exec.submit(new Callable<Boolean>() {
|
|
||||||
public Boolean call() throws Exception {
|
|
||||||
return database.updateSession(auth);
|
|
||||||
}
|
|
||||||
}).get();
|
|
||||||
} catch (Exception e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Method updatePassword.
|
|
||||||
*
|
|
||||||
* @param auth PlayerAuth
|
|
||||||
*
|
|
||||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updatePassword(PlayerAuth)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public synchronized boolean updatePassword(final PlayerAuth auth) {
|
|
||||||
try {
|
|
||||||
return exec.submit(new Callable<Boolean>() {
|
|
||||||
public Boolean call() throws Exception {
|
|
||||||
return database.updatePassword(auth);
|
|
||||||
}
|
|
||||||
}).get();
|
|
||||||
} catch (Exception e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Method purgeDatabase.
|
|
||||||
*
|
|
||||||
* @param until long
|
|
||||||
*
|
|
||||||
* @return int * @see fr.xephi.authme.datasource.DataSource#purgeDatabase(long)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public synchronized int purgeDatabase(final long until) {
|
|
||||||
try {
|
|
||||||
return exec.submit(new Callable<Integer>() {
|
|
||||||
public Integer call() throws Exception {
|
|
||||||
return database.purgeDatabase(until);
|
|
||||||
}
|
|
||||||
}).get();
|
|
||||||
} catch (Exception e) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Method autoPurgeDatabase.
|
|
||||||
*
|
|
||||||
* @param until long
|
|
||||||
*
|
|
||||||
* @return List<String> * @see fr.xephi.authme.datasource.DataSource#autoPurgeDatabase(long)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public synchronized List<String> autoPurgeDatabase(final long until) {
|
|
||||||
try {
|
|
||||||
return exec.submit(new Callable<List<String>>() {
|
|
||||||
public List<String> call() throws Exception {
|
|
||||||
return database.autoPurgeDatabase(until);
|
|
||||||
}
|
|
||||||
}).get();
|
|
||||||
} catch (Exception e) {
|
|
||||||
return new ArrayList<>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Method removeAuth.
|
|
||||||
*
|
|
||||||
* @param user String
|
|
||||||
*
|
|
||||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#removeAuth(String)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public synchronized boolean removeAuth(final String user) {
|
|
||||||
try {
|
|
||||||
return exec.submit(new Callable<Boolean>() {
|
|
||||||
public Boolean call() throws Exception {
|
|
||||||
return database.removeAuth(user);
|
|
||||||
}
|
|
||||||
}).get();
|
|
||||||
} catch (Exception e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Method updateQuitLoc.
|
|
||||||
*
|
|
||||||
* @param auth PlayerAuth
|
|
||||||
*
|
|
||||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateQuitLoc(PlayerAuth)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public synchronized boolean updateQuitLoc(final PlayerAuth auth) {
|
|
||||||
try {
|
|
||||||
return exec.submit(new Callable<Boolean>() {
|
|
||||||
public Boolean call() throws Exception {
|
|
||||||
return database.updateQuitLoc(auth);
|
|
||||||
}
|
|
||||||
}).get();
|
|
||||||
} catch (Exception e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Method getIps.
|
|
||||||
*
|
|
||||||
* @param ip String
|
|
||||||
*
|
|
||||||
* @return int * @see fr.xephi.authme.datasource.DataSource#getIps(String)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public synchronized int getIps(final String ip) {
|
|
||||||
try {
|
|
||||||
return exec.submit(new Callable<Integer>() {
|
|
||||||
|
|
||||||
public Integer call() throws Exception {
|
|
||||||
return database.getIps(ip);
|
|
||||||
}
|
|
||||||
}).get();
|
|
||||||
} catch (Exception e) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Method getAllAuthsByName.
|
|
||||||
*
|
|
||||||
* @param auth PlayerAuth
|
|
||||||
*
|
|
||||||
* @return List<String> * @see fr.xephi.authme.datasource.DataSource#getAllAuthsByName(PlayerAuth)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public synchronized List<String> getAllAuthsByName(final PlayerAuth auth) {
|
|
||||||
try {
|
|
||||||
return exec.submit(new Callable<List<String>>() {
|
|
||||||
public List<String> call() throws Exception {
|
|
||||||
return database.getAllAuthsByName(auth);
|
|
||||||
}
|
|
||||||
}).get();
|
|
||||||
} catch (Exception e) {
|
|
||||||
return new ArrayList<>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Method getAllAuthsByIp.
|
|
||||||
*
|
|
||||||
* @param ip String
|
|
||||||
*
|
|
||||||
* @return List<String> * @see fr.xephi.authme.datasource.DataSource#getAllAuthsByIp(String)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public synchronized List<String> getAllAuthsByIp(final String ip) {
|
|
||||||
try {
|
|
||||||
return exec.submit(new Callable<List<String>>() {
|
|
||||||
public List<String> call() throws Exception {
|
|
||||||
return database.getAllAuthsByIp(ip);
|
|
||||||
}
|
|
||||||
}).get();
|
|
||||||
} catch (Exception e) {
|
|
||||||
return new ArrayList<>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Method getAllAuthsByEmail.
|
|
||||||
*
|
|
||||||
* @param email String
|
|
||||||
*
|
|
||||||
* @return List<String> * @see fr.xephi.authme.datasource.DataSource#getAllAuthsByEmail(String)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public synchronized List<String> getAllAuthsByEmail(final String email) {
|
|
||||||
try {
|
|
||||||
return exec.submit(new Callable<List<String>>() {
|
|
||||||
public List<String> call() throws Exception {
|
|
||||||
return database.getAllAuthsByEmail(email);
|
|
||||||
}
|
|
||||||
}).get();
|
|
||||||
} catch (Exception e) {
|
|
||||||
return new ArrayList<>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Method updateEmail.
|
|
||||||
*
|
|
||||||
* @param auth PlayerAuth
|
|
||||||
*
|
|
||||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateEmail(PlayerAuth)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public synchronized boolean updateEmail(final PlayerAuth auth) {
|
|
||||||
try {
|
|
||||||
return exec.submit(new Callable<Boolean>() {
|
|
||||||
public Boolean call() throws Exception {
|
|
||||||
return database.updateEmail(auth);
|
|
||||||
}
|
|
||||||
}).get();
|
|
||||||
} catch (Exception e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Method updateSalt.
|
|
||||||
*
|
|
||||||
* @param auth PlayerAuth
|
|
||||||
*
|
|
||||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateSalt(PlayerAuth)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public synchronized boolean updateSalt(final PlayerAuth auth) {
|
|
||||||
try {
|
|
||||||
return exec.submit(new Callable<Boolean>() {
|
|
||||||
public Boolean call() throws Exception {
|
|
||||||
return database.updateSalt(auth);
|
|
||||||
}
|
|
||||||
}).get();
|
|
||||||
} catch (Exception e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Method close.
|
|
||||||
*
|
|
||||||
* @see fr.xephi.authme.datasource.DataSource#close()
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public synchronized void close() {
|
|
||||||
exec.shutdown();
|
|
||||||
database.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Method reload.
|
|
||||||
*
|
|
||||||
* @see fr.xephi.authme.datasource.DataSource#reload()
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public synchronized void reload() {
|
|
||||||
database.reload();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Method purgeBanned.
|
|
||||||
*
|
|
||||||
* @param banned List<String>
|
|
||||||
*
|
|
||||||
* @see fr.xephi.authme.datasource.DataSource#purgeBanned(List<String>)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public synchronized void purgeBanned(final List<String> banned) {
|
|
||||||
new Thread(new Runnable() {
|
|
||||||
public synchronized void run() {
|
|
||||||
database.purgeBanned(banned);
|
|
||||||
}
|
|
||||||
}).start();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Method getType.
|
|
||||||
*
|
|
||||||
* @return DataSourceType * @see fr.xephi.authme.datasource.DataSource#getType()
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public synchronized DataSourceType getType() {
|
|
||||||
return database.getType();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Method isLogged.
|
|
||||||
*
|
|
||||||
* @param user String
|
|
||||||
*
|
|
||||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#isLogged(String)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public synchronized boolean isLogged(final String user) {
|
|
||||||
try {
|
|
||||||
return exec.submit(new Callable<Boolean>() {
|
|
||||||
public Boolean call() throws Exception {
|
|
||||||
return database.isLogged(user);
|
|
||||||
}
|
|
||||||
}).get();
|
|
||||||
} catch (Exception e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Method setLogged.
|
|
||||||
*
|
|
||||||
* @param user String
|
|
||||||
*
|
|
||||||
* @see fr.xephi.authme.datasource.DataSource#setLogged(String)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public synchronized void setLogged(final String user) {
|
|
||||||
exec.execute(new Runnable() {
|
|
||||||
public synchronized void run() {
|
|
||||||
database.setLogged(user);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Method setUnlogged.
|
|
||||||
*
|
|
||||||
* @param user String
|
|
||||||
*
|
|
||||||
* @see fr.xephi.authme.datasource.DataSource#setUnlogged(String)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public synchronized void setUnlogged(final String user) {
|
|
||||||
exec.execute(new Runnable() {
|
|
||||||
public synchronized void run() {
|
|
||||||
database.setUnlogged(user);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Method purgeLogged.
|
|
||||||
*
|
|
||||||
* @see fr.xephi.authme.datasource.DataSource#purgeLogged()
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public synchronized void purgeLogged() {
|
|
||||||
exec.execute(new Runnable() {
|
|
||||||
public synchronized void run() {
|
|
||||||
database.purgeLogged();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Method getAccountsRegistered.
|
|
||||||
*
|
|
||||||
* @return int * @see fr.xephi.authme.datasource.DataSource#getAccountsRegistered()
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public synchronized int getAccountsRegistered() {
|
|
||||||
try {
|
|
||||||
return exec.submit(new Callable<Integer>() {
|
|
||||||
public Integer call() throws Exception {
|
|
||||||
return database.getAccountsRegistered();
|
|
||||||
}
|
|
||||||
}).get();
|
|
||||||
} catch (Exception e) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Method updateName.
|
|
||||||
*
|
|
||||||
* @param oldOne String
|
|
||||||
* @param newOne String
|
|
||||||
*
|
|
||||||
* @see fr.xephi.authme.datasource.DataSource#updateName(String, String)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public synchronized void updateName(final String oldOne, final String newOne) {
|
|
||||||
exec.execute(new Runnable() {
|
|
||||||
public synchronized void run() {
|
|
||||||
database.updateName(oldOne, newOne);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Method getAllAuths.
|
|
||||||
*
|
|
||||||
* @return List<PlayerAuth> * @see fr.xephi.authme.datasource.DataSource#getAllAuths()
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public synchronized List<PlayerAuth> getAllAuths() {
|
|
||||||
try {
|
|
||||||
return exec.submit(new Callable<List<PlayerAuth>>() {
|
|
||||||
public List<PlayerAuth> call() throws Exception {
|
|
||||||
return database.getAllAuths();
|
|
||||||
}
|
|
||||||
}).get();
|
|
||||||
} catch (Exception e) {
|
|
||||||
return new ArrayList<>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Method getLoggedPlayers.
|
|
||||||
*
|
|
||||||
* @return List<PlayerAuth> * @see fr.xephi.authme.datasource.DataSource#getLoggedPlayers()
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public List<PlayerAuth> getLoggedPlayers() {
|
|
||||||
try {
|
|
||||||
return exec.submit(new Callable<List<PlayerAuth>>() {
|
|
||||||
public List<PlayerAuth> call() throws Exception {
|
|
||||||
return database.getLoggedPlayers();
|
|
||||||
}
|
|
||||||
}).get();
|
|
||||||
} catch (Exception e) {
|
|
||||||
return new ArrayList<>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -259,8 +259,9 @@ public class MySQL implements DataSource {
|
|||||||
pst.setString(1, user.toLowerCase());
|
pst.setString(1, user.toLowerCase());
|
||||||
ResultSet rs = pst.executeQuery();
|
ResultSet rs = pst.executeQuery();
|
||||||
return rs.next();
|
return rs.next();
|
||||||
} catch (Exception ex) {
|
} catch (SQLException ex) {
|
||||||
ConsoleLogger.showError(ex.getMessage());
|
ConsoleLogger.showError(ex.getMessage());
|
||||||
|
ConsoleLogger.writeStackTrace(ex);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -312,8 +313,9 @@ public class MySQL implements DataSource {
|
|||||||
pAuth.setHash(new String(bytes));
|
pAuth.setHash(new String(bytes));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (SQLException ex) {
|
||||||
ConsoleLogger.showError(ex.getMessage());
|
ConsoleLogger.showError(ex.getMessage());
|
||||||
|
ConsoleLogger.writeStackTrace(ex);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return pAuth;
|
return pAuth;
|
||||||
@ -521,8 +523,9 @@ public class MySQL implements DataSource {
|
|||||||
pst.close();
|
pst.close();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} catch (Exception ex) {
|
} catch (SQLException ex) {
|
||||||
ConsoleLogger.showError(ex.getMessage());
|
ConsoleLogger.showError(ex.getMessage());
|
||||||
|
ConsoleLogger.writeStackTrace(ex);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -574,8 +577,9 @@ public class MySQL implements DataSource {
|
|||||||
pst.close();
|
pst.close();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} catch (Exception ex) {
|
} catch (SQLException ex) {
|
||||||
ConsoleLogger.showError(ex.getMessage());
|
ConsoleLogger.showError(ex.getMessage());
|
||||||
|
ConsoleLogger.writeStackTrace(ex);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -602,7 +606,7 @@ public class MySQL implements DataSource {
|
|||||||
pst.executeUpdate();
|
pst.executeUpdate();
|
||||||
pst.close();
|
pst.close();
|
||||||
return true;
|
return true;
|
||||||
} catch (Exception ex) {
|
} catch (SQLException ex) {
|
||||||
ConsoleLogger.showError(ex.getMessage());
|
ConsoleLogger.showError(ex.getMessage());
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -625,8 +629,9 @@ public class MySQL implements DataSource {
|
|||||||
PreparedStatement pst = con.prepareStatement(sql);
|
PreparedStatement pst = con.prepareStatement(sql);
|
||||||
pst.setLong(1, until);
|
pst.setLong(1, until);
|
||||||
result = pst.executeUpdate();
|
result = pst.executeUpdate();
|
||||||
} catch (Exception ex) {
|
} catch (SQLException ex) {
|
||||||
ConsoleLogger.showError(ex.getMessage());
|
ConsoleLogger.showError(ex.getMessage());
|
||||||
|
ConsoleLogger.writeStackTrace(ex);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -653,8 +658,9 @@ public class MySQL implements DataSource {
|
|||||||
sql = "DELETE FROM " + tableName + " WHERE " + columnLastLogin + "<" + until;
|
sql = "DELETE FROM " + tableName + " WHERE " + columnLastLogin + "<" + until;
|
||||||
st.executeUpdate(sql);
|
st.executeUpdate(sql);
|
||||||
st.close();
|
st.close();
|
||||||
} catch (Exception ex) {
|
} catch (SQLException ex) {
|
||||||
ConsoleLogger.showError(ex.getMessage());
|
ConsoleLogger.showError(ex.getMessage());
|
||||||
|
ConsoleLogger.writeStackTrace(ex);
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
@ -693,8 +699,9 @@ public class MySQL implements DataSource {
|
|||||||
pst.setString(1, user);
|
pst.setString(1, user);
|
||||||
pst.executeUpdate();
|
pst.executeUpdate();
|
||||||
return true;
|
return true;
|
||||||
} catch (Exception ex) {
|
} catch (SQLException ex) {
|
||||||
ConsoleLogger.showError(ex.getMessage());
|
ConsoleLogger.showError(ex.getMessage());
|
||||||
|
ConsoleLogger.writeStackTrace(ex);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -723,8 +730,9 @@ public class MySQL implements DataSource {
|
|||||||
pst.executeUpdate();
|
pst.executeUpdate();
|
||||||
pst.close();
|
pst.close();
|
||||||
return true;
|
return true;
|
||||||
} catch (Exception ex) {
|
} catch (SQLException ex) {
|
||||||
ConsoleLogger.showError(ex.getMessage());
|
ConsoleLogger.showError(ex.getMessage());
|
||||||
|
ConsoleLogger.writeStackTrace(ex);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -751,8 +759,9 @@ public class MySQL implements DataSource {
|
|||||||
}
|
}
|
||||||
rs.close();
|
rs.close();
|
||||||
pst.close();
|
pst.close();
|
||||||
} catch (Exception ex) {
|
} catch (SQLException ex) {
|
||||||
ConsoleLogger.showError(ex.getMessage());
|
ConsoleLogger.showError(ex.getMessage());
|
||||||
|
ConsoleLogger.writeStackTrace(ex);
|
||||||
}
|
}
|
||||||
return countIp;
|
return countIp;
|
||||||
}
|
}
|
||||||
@ -776,7 +785,7 @@ public class MySQL implements DataSource {
|
|||||||
pst.executeUpdate();
|
pst.executeUpdate();
|
||||||
pst.close();
|
pst.close();
|
||||||
return true;
|
return true;
|
||||||
} catch (Exception ex) {
|
} catch (SQLException ex) {
|
||||||
ConsoleLogger.showError(ex.getMessage());
|
ConsoleLogger.showError(ex.getMessage());
|
||||||
ConsoleLogger.writeStackTrace(ex);
|
ConsoleLogger.writeStackTrace(ex);
|
||||||
}
|
}
|
||||||
@ -805,8 +814,9 @@ public class MySQL implements DataSource {
|
|||||||
pst.executeUpdate();
|
pst.executeUpdate();
|
||||||
pst.close();
|
pst.close();
|
||||||
return true;
|
return true;
|
||||||
} catch (Exception ex) {
|
} catch (SQLException ex) {
|
||||||
ConsoleLogger.showError(ex.getMessage());
|
ConsoleLogger.showError(ex.getMessage());
|
||||||
|
ConsoleLogger.writeStackTrace(ex);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -820,9 +830,10 @@ public class MySQL implements DataSource {
|
|||||||
public void reload() {
|
public void reload() {
|
||||||
try {
|
try {
|
||||||
reloadArguments();
|
reloadArguments();
|
||||||
} catch (Exception e) {
|
} catch (Exception ex) {
|
||||||
ConsoleLogger.showError(e.getMessage());
|
ConsoleLogger.showError(ex.getMessage());
|
||||||
ConsoleLogger.showError("Can't reconnect to MySQL database... Please check your MySQL configuration!");
|
ConsoleLogger.showError("Can't reconnect to MySQL database... Please check your MySQL configuration!");
|
||||||
|
ConsoleLogger.writeStackTrace(ex);
|
||||||
AuthMe.getInstance().stopOrUnload();
|
AuthMe.getInstance().stopOrUnload();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -861,8 +872,9 @@ public class MySQL implements DataSource {
|
|||||||
}
|
}
|
||||||
rs.close();
|
rs.close();
|
||||||
pst.close();
|
pst.close();
|
||||||
} catch (Exception ex) {
|
} catch (SQLException ex) {
|
||||||
ConsoleLogger.showError(ex.getMessage());
|
ConsoleLogger.showError(ex.getMessage());
|
||||||
|
ConsoleLogger.writeStackTrace(ex);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -889,8 +901,9 @@ public class MySQL implements DataSource {
|
|||||||
}
|
}
|
||||||
rs.close();
|
rs.close();
|
||||||
pst.close();
|
pst.close();
|
||||||
} catch (Exception ex) {
|
} catch (SQLException ex) {
|
||||||
ConsoleLogger.showError(ex.getMessage());
|
ConsoleLogger.showError(ex.getMessage());
|
||||||
|
ConsoleLogger.writeStackTrace(ex);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -938,8 +951,9 @@ public class MySQL implements DataSource {
|
|||||||
pst.executeUpdate();
|
pst.executeUpdate();
|
||||||
}
|
}
|
||||||
pst.close();
|
pst.close();
|
||||||
} catch (Exception ex) {
|
} catch (SQLException ex) {
|
||||||
ConsoleLogger.showError(ex.getMessage());
|
ConsoleLogger.showError(ex.getMessage());
|
||||||
|
ConsoleLogger.writeStackTrace(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -969,8 +983,9 @@ public class MySQL implements DataSource {
|
|||||||
pst.setString(1, user);
|
pst.setString(1, user);
|
||||||
ResultSet rs = pst.executeQuery();
|
ResultSet rs = pst.executeQuery();
|
||||||
isLogged = rs.next() && (rs.getInt(columnLogged) == 1);
|
isLogged = rs.next() && (rs.getInt(columnLogged) == 1);
|
||||||
} catch (Exception ex) {
|
} catch (SQLException ex) {
|
||||||
ConsoleLogger.showError(ex.getMessage());
|
ConsoleLogger.showError(ex.getMessage());
|
||||||
|
ConsoleLogger.writeStackTrace(ex);
|
||||||
}
|
}
|
||||||
return isLogged;
|
return isLogged;
|
||||||
}
|
}
|
||||||
@ -991,8 +1006,9 @@ public class MySQL implements DataSource {
|
|||||||
pst.setString(2, user.toLowerCase());
|
pst.setString(2, user.toLowerCase());
|
||||||
pst.executeUpdate();
|
pst.executeUpdate();
|
||||||
pst.close();
|
pst.close();
|
||||||
} catch (Exception ex) {
|
} catch (SQLException ex) {
|
||||||
ConsoleLogger.showError(ex.getMessage());
|
ConsoleLogger.showError(ex.getMessage());
|
||||||
|
ConsoleLogger.writeStackTrace(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1012,8 +1028,9 @@ public class MySQL implements DataSource {
|
|||||||
pst.setString(2, user.toLowerCase());
|
pst.setString(2, user.toLowerCase());
|
||||||
pst.executeUpdate();
|
pst.executeUpdate();
|
||||||
pst.close();
|
pst.close();
|
||||||
} catch (Exception ex) {
|
} catch (SQLException ex) {
|
||||||
ConsoleLogger.showError(ex.getMessage());
|
ConsoleLogger.showError(ex.getMessage());
|
||||||
|
ConsoleLogger.writeStackTrace(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1033,6 +1050,7 @@ public class MySQL implements DataSource {
|
|||||||
pst.close();
|
pst.close();
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ConsoleLogger.showError(ex.getMessage());
|
ConsoleLogger.showError(ex.getMessage());
|
||||||
|
ConsoleLogger.writeStackTrace(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1047,15 +1065,16 @@ public class MySQL implements DataSource {
|
|||||||
public int getAccountsRegistered() {
|
public int getAccountsRegistered() {
|
||||||
int result = 0;
|
int result = 0;
|
||||||
try (Connection con = getConnection()) {
|
try (Connection con = getConnection()) {
|
||||||
PreparedStatement pst = con.prepareStatement("SELECT COUNT(*) FROM " + tableName + ";");
|
Statement st = con.createStatement();
|
||||||
ResultSet rs = pst.executeQuery();
|
ResultSet rs = st.executeQuery("SELECT COUNT(*) FROM " + tableName);
|
||||||
if (rs.next()) {
|
if (rs.next()) {
|
||||||
result = rs.getInt(1);
|
result = rs.getInt(1);
|
||||||
}
|
}
|
||||||
rs.close();
|
rs.close();
|
||||||
pst.close();
|
st.close();
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ConsoleLogger.showError(ex.getMessage());
|
ConsoleLogger.showError(ex.getMessage());
|
||||||
|
ConsoleLogger.writeStackTrace(ex);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -1078,6 +1097,7 @@ public class MySQL implements DataSource {
|
|||||||
pst.executeUpdate();
|
pst.executeUpdate();
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ConsoleLogger.showError(ex.getMessage());
|
ConsoleLogger.showError(ex.getMessage());
|
||||||
|
ConsoleLogger.writeStackTrace(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1131,6 +1151,7 @@ public class MySQL implements DataSource {
|
|||||||
st.close();
|
st.close();
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ConsoleLogger.showError(ex.getMessage());
|
ConsoleLogger.showError(ex.getMessage());
|
||||||
|
ConsoleLogger.writeStackTrace(ex);
|
||||||
}
|
}
|
||||||
return auths;
|
return auths;
|
||||||
}
|
}
|
||||||
@ -1182,6 +1203,7 @@ public class MySQL implements DataSource {
|
|||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ConsoleLogger.showError(ex.getMessage());
|
ConsoleLogger.showError(ex.getMessage());
|
||||||
|
ConsoleLogger.writeStackTrace(ex);
|
||||||
}
|
}
|
||||||
return auths;
|
return auths;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package fr.xephi.authme.settings;
|
package fr.xephi.authme.settings;
|
||||||
|
|
||||||
|
import com.google.common.base.Charsets;
|
||||||
|
import com.google.common.io.Files;
|
||||||
import fr.xephi.authme.AuthMe;
|
import fr.xephi.authme.AuthMe;
|
||||||
import fr.xephi.authme.ConsoleLogger;
|
import fr.xephi.authme.ConsoleLogger;
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
@ -8,10 +10,14 @@ import fr.xephi.authme.security.HashAlgorithm;
|
|||||||
import fr.xephi.authme.util.Wrapper;
|
import fr.xephi.authme.util.Wrapper;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
|
||||||
import com.google.common.base.Charsets;
|
import java.io.BufferedReader;
|
||||||
import com.google.common.io.Files;
|
import java.io.BufferedWriter;
|
||||||
|
import java.io.File;
|
||||||
import java.io.*;
|
import java.io.FileReader;
|
||||||
|
import java.io.FileWriter;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@ -94,7 +100,7 @@ public final class Settings {
|
|||||||
getMailPort, maxLoginTry, captchaLength, saltLength,
|
getMailPort, maxLoginTry, captchaLength, saltLength,
|
||||||
getmaxRegPerEmail, bCryptLog2Rounds, getPhpbbGroup,
|
getmaxRegPerEmail, bCryptLog2Rounds, getPhpbbGroup,
|
||||||
antiBotSensibility, antiBotDuration, delayRecall, getMaxLoginPerIp,
|
antiBotSensibility, antiBotDuration, delayRecall, getMaxLoginPerIp,
|
||||||
getMaxJoinPerIp, getMySQLMaxConnections;
|
getMaxJoinPerIp;
|
||||||
protected static YamlConfiguration configFile;
|
protected static YamlConfiguration configFile;
|
||||||
private static AuthMe plugin;
|
private static AuthMe plugin;
|
||||||
private static Settings instance;
|
private static Settings instance;
|
||||||
@ -170,7 +176,6 @@ public final class Settings {
|
|||||||
isCachingEnabled = configFile.getBoolean("DataSource.caching", true);
|
isCachingEnabled = configFile.getBoolean("DataSource.caching", true);
|
||||||
getMySQLHost = configFile.getString("DataSource.mySQLHost", "127.0.0.1");
|
getMySQLHost = configFile.getString("DataSource.mySQLHost", "127.0.0.1");
|
||||||
getMySQLPort = configFile.getString("DataSource.mySQLPort", "3306");
|
getMySQLPort = configFile.getString("DataSource.mySQLPort", "3306");
|
||||||
getMySQLMaxConnections = configFile.getInt("DataSource.mySQLMaxConections", 25);
|
|
||||||
getMySQLUsername = configFile.getString("DataSource.mySQLUsername", "authme");
|
getMySQLUsername = configFile.getString("DataSource.mySQLUsername", "authme");
|
||||||
getMySQLPassword = configFile.getString("DataSource.mySQLPassword", "12345");
|
getMySQLPassword = configFile.getString("DataSource.mySQLPassword", "12345");
|
||||||
getMySQLDatabase = configFile.getString("DataSource.mySQLDatabase", "authme");
|
getMySQLDatabase = configFile.getString("DataSource.mySQLDatabase", "authme");
|
||||||
@ -302,39 +307,36 @@ public final class Settings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static String loadEmailText() {
|
private static String loadEmailText() {
|
||||||
if (!EMAIL_FILE.exists())
|
if (!EMAIL_FILE.exists())
|
||||||
saveDefaultEmailText();
|
saveDefaultEmailText();
|
||||||
StringBuilder str = new StringBuilder();
|
StringBuilder str = new StringBuilder();
|
||||||
try {
|
try {
|
||||||
BufferedReader in = new BufferedReader(new FileReader(EMAIL_FILE));
|
BufferedReader in = new BufferedReader(new FileReader(EMAIL_FILE));
|
||||||
String s;
|
String s;
|
||||||
while ((s = in.readLine()) != null)
|
while ((s = in.readLine()) != null)
|
||||||
str.append(s);
|
str.append(s);
|
||||||
in.close();
|
in.close();
|
||||||
} catch(IOException e)
|
} catch (IOException ignored) {
|
||||||
{
|
}
|
||||||
}
|
return str.toString();
|
||||||
return str.toString();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private static void saveDefaultEmailText() {
|
private static void saveDefaultEmailText() {
|
||||||
InputStream file = plugin.getResource("email.html");
|
InputStream file = plugin.getResource("email.html");
|
||||||
StringBuilder str = new StringBuilder();
|
StringBuilder str = new StringBuilder();
|
||||||
try {
|
try {
|
||||||
BufferedReader in = new BufferedReader(new InputStreamReader(file, Charset.forName("utf-8")));
|
BufferedReader in = new BufferedReader(new InputStreamReader(file, Charset.forName("utf-8")));
|
||||||
String s;
|
String s;
|
||||||
while ((s = in.readLine()) != null)
|
while ((s = in.readLine()) != null)
|
||||||
str.append(s);
|
str.append(s);
|
||||||
in.close();
|
in.close();
|
||||||
Files.touch(EMAIL_FILE);
|
Files.touch(EMAIL_FILE);
|
||||||
Files.write(str.toString(), EMAIL_FILE, Charsets.UTF_8);
|
Files.write(str.toString(), EMAIL_FILE, Charsets.UTF_8);
|
||||||
}
|
} catch (Exception ignored) {
|
||||||
catch(Exception e)
|
}
|
||||||
{
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setValue(String key, Object value) {
|
public static void setValue(String key, Object value) {
|
||||||
instance.set(key, value);
|
instance.set(key, value);
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
@ -720,10 +722,9 @@ public final class Settings {
|
|||||||
changes = true;
|
changes = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (contains("Email.mailText"))
|
if (contains("Email.mailText")) {
|
||||||
{
|
set("Email.mailText", null);
|
||||||
set("Email.mailText", null);
|
ConsoleLogger.showError("Remove Email.mailText from config, we now use the email.html file");
|
||||||
ConsoleLogger.showError("Remove Email.mailText from config, we now use the email.html file");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (changes) {
|
if (changes) {
|
||||||
|
@ -8,8 +8,6 @@ DataSource:
|
|||||||
mySQLHost: 127.0.0.1
|
mySQLHost: 127.0.0.1
|
||||||
# Database Port
|
# Database Port
|
||||||
mySQLPort: '3306'
|
mySQLPort: '3306'
|
||||||
# MySql Max Connections
|
|
||||||
mySQLMaxConections: 8
|
|
||||||
# Username about Database Connection Infos
|
# Username about Database Connection Infos
|
||||||
mySQLUsername: authme
|
mySQLUsername: authme
|
||||||
# Password about Database Connection Infos
|
# Password about Database Connection Infos
|
||||||
|
Loading…
Reference in New Issue
Block a user