mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-11-27 20:57:35 +01:00
Dramastically increase performance
Maybe fix low tps :O
This commit is contained in:
parent
34a87689ed
commit
030e9b599e
@ -54,9 +54,10 @@ import fr.xephi.authme.commands.RegisterCommand;
|
|||||||
import fr.xephi.authme.commands.UnregisterCommand;
|
import fr.xephi.authme.commands.UnregisterCommand;
|
||||||
import fr.xephi.authme.datasource.CacheDataSource;
|
import fr.xephi.authme.datasource.CacheDataSource;
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
import fr.xephi.authme.datasource.FlatFileThread;
|
import fr.xephi.authme.datasource.DatabaseCalls;
|
||||||
import fr.xephi.authme.datasource.MySQLThread;
|
import fr.xephi.authme.datasource.FlatFile;
|
||||||
import fr.xephi.authme.datasource.SQLiteThread;
|
import fr.xephi.authme.datasource.MySQL;
|
||||||
|
import fr.xephi.authme.datasource.SQLite;
|
||||||
import fr.xephi.authme.listener.AuthMeBlockListener;
|
import fr.xephi.authme.listener.AuthMeBlockListener;
|
||||||
import fr.xephi.authme.listener.AuthMeChestShopListener;
|
import fr.xephi.authme.listener.AuthMeChestShopListener;
|
||||||
import fr.xephi.authme.listener.AuthMeEntityListener;
|
import fr.xephi.authme.listener.AuthMeEntityListener;
|
||||||
@ -102,7 +103,6 @@ public class AuthMe extends JavaPlugin {
|
|||||||
public HashMap<String, String> realIp = new HashMap<String, String>();
|
public HashMap<String, String> realIp = new HashMap<String, String>();
|
||||||
public MultiverseCore multiverse = null;
|
public MultiverseCore multiverse = null;
|
||||||
public Location essentialsSpawn;
|
public Location essentialsSpawn;
|
||||||
public Thread databaseThread = null;
|
|
||||||
public LookupService ls = null;
|
public LookupService ls = null;
|
||||||
public boolean antibotMod = false;
|
public boolean antibotMod = false;
|
||||||
public boolean delayedAntiBot = true;
|
public boolean delayedAntiBot = true;
|
||||||
@ -205,26 +205,20 @@ public class AuthMe extends JavaPlugin {
|
|||||||
*/
|
*/
|
||||||
switch (Settings.getDataSource) {
|
switch (Settings.getDataSource) {
|
||||||
case FILE:
|
case FILE:
|
||||||
FlatFileThread fileThread = new FlatFileThread();
|
FlatFile fileThread = new FlatFile();
|
||||||
fileThread.start();
|
|
||||||
database = fileThread;
|
database = fileThread;
|
||||||
databaseThread = fileThread;
|
|
||||||
final int a = database.getAccountsRegistered();
|
final int a = database.getAccountsRegistered();
|
||||||
if (a >= 1000) {
|
if (a >= 1000) {
|
||||||
ConsoleLogger.showError("YOU'RE USING FILE DATABASE WITH " + a + "+ ACCOUNTS, FOR BETTER PERFORMANCES, PLEASE USE MYSQL!!");
|
ConsoleLogger.showError("YOU'RE USING FILE DATABASE WITH " + a + "+ ACCOUNTS, FOR BETTER PERFORMANCES, PLEASE USE MYSQL!!");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MYSQL:
|
case MYSQL:
|
||||||
MySQLThread sqlThread = new MySQLThread();
|
MySQL sqlThread = new MySQL();
|
||||||
sqlThread.start();
|
|
||||||
database = sqlThread;
|
database = sqlThread;
|
||||||
databaseThread = sqlThread;
|
|
||||||
break;
|
break;
|
||||||
case SQLITE:
|
case SQLITE:
|
||||||
SQLiteThread sqliteThread = new SQLiteThread();
|
SQLite sqliteThread = new SQLite();
|
||||||
sqliteThread.start();
|
|
||||||
database = sqliteThread;
|
database = sqliteThread;
|
||||||
databaseThread = sqliteThread;
|
|
||||||
final int b = database.getAccountsRegistered();
|
final int b = database.getAccountsRegistered();
|
||||||
if (b >= 2000) {
|
if (b >= 2000) {
|
||||||
ConsoleLogger.showError("YOU'RE USING SQLITE DATABASE WITH " + b + "+ ACCOUNTS, FOR BETTER PERFORMANCES, PLEASE USE MYSQL!!");
|
ConsoleLogger.showError("YOU'RE USING SQLITE DATABASE WITH " + b + "+ ACCOUNTS, FOR BETTER PERFORMANCES, PLEASE USE MYSQL!!");
|
||||||
@ -234,19 +228,17 @@ public class AuthMe extends JavaPlugin {
|
|||||||
|
|
||||||
if (Settings.isCachingEnabled) {
|
if (Settings.isCachingEnabled) {
|
||||||
database = new CacheDataSource(this, database);
|
database = new CacheDataSource(this, database);
|
||||||
if (database instanceof CacheDataSource)
|
|
||||||
((CacheDataSource) database).start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
database = new DatabaseCalls(this, database);
|
||||||
|
|
||||||
dataManager = new DataManager(this, database);
|
dataManager = new DataManager(this, database);
|
||||||
dataManager.start();
|
|
||||||
|
|
||||||
// Setup API
|
// Setup API
|
||||||
api = new API(this, database);
|
api = new API(this, database);
|
||||||
|
|
||||||
// Setup Management
|
// Setup Management
|
||||||
management = new Management(database, this);
|
management = new Management(database, this);
|
||||||
management.start();
|
|
||||||
|
|
||||||
PluginManager pm = getServer().getPluginManager();
|
PluginManager pm = getServer().getPluginManager();
|
||||||
if (Settings.bungee) {
|
if (Settings.bungee) {
|
||||||
@ -485,16 +477,6 @@ public class AuthMe extends JavaPlugin {
|
|||||||
database.close();
|
database.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (databaseThread != null) {
|
|
||||||
if (databaseThread.isAlive())
|
|
||||||
databaseThread.interrupt();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dataManager != null) {
|
|
||||||
if (dataManager.isAlive())
|
|
||||||
dataManager.interrupt();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Settings.isBackupActivated && Settings.isBackupOnStop) {
|
if (Settings.isBackupActivated && Settings.isBackupOnStop) {
|
||||||
Boolean Backup = new PerformBackup(this).DoBackup();
|
Boolean Backup = new PerformBackup(this).DoBackup();
|
||||||
if (Backup)
|
if (Backup)
|
||||||
|
@ -2,6 +2,11 @@ package fr.xephi.authme;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.Callable;
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
import net.milkbowl.vault.permission.Permission;
|
import net.milkbowl.vault.permission.Permission;
|
||||||
|
|
||||||
@ -12,7 +17,7 @@ import org.bukkit.entity.Player;
|
|||||||
import fr.xephi.authme.datasource.DataSource;
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
|
|
||||||
public class DataManager extends Thread {
|
public class DataManager {
|
||||||
|
|
||||||
public AuthMe plugin;
|
public AuthMe plugin;
|
||||||
public DataSource database;
|
public DataSource database;
|
||||||
@ -25,7 +30,11 @@ public class DataManager extends Thread {
|
|||||||
public void run() {
|
public void run() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public OfflinePlayer getOfflinePlayer(String name) {
|
public synchronized OfflinePlayer getOfflinePlayer(final String name) {
|
||||||
|
ExecutorService executor = Executors.newSingleThreadExecutor();
|
||||||
|
Future<OfflinePlayer> result = executor.submit(new Callable<OfflinePlayer>() {
|
||||||
|
|
||||||
|
public synchronized OfflinePlayer call() throws Exception {
|
||||||
OfflinePlayer result = null;
|
OfflinePlayer result = null;
|
||||||
try {
|
try {
|
||||||
for (OfflinePlayer op : Bukkit.getOfflinePlayers())
|
for (OfflinePlayer op : Bukkit.getOfflinePlayers())
|
||||||
@ -37,8 +46,15 @@ public class DataManager extends Thread {
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
return result.get();
|
||||||
|
} catch (InterruptedException | ExecutionException e) {
|
||||||
|
return (null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void purgeAntiXray(List<String> cleared) {
|
public synchronized void purgeAntiXray(List<String> cleared) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (String name : cleared) {
|
for (String name : cleared) {
|
||||||
try {
|
try {
|
||||||
@ -57,7 +73,7 @@ public class DataManager extends Thread {
|
|||||||
ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " AntiXRayData Files");
|
ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " AntiXRayData Files");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void purgeLimitedCreative(List<String> cleared) {
|
public synchronized void purgeLimitedCreative(List<String> cleared) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (String name : cleared) {
|
for (String name : cleared) {
|
||||||
try {
|
try {
|
||||||
@ -86,7 +102,7 @@ public class DataManager extends Thread {
|
|||||||
ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " LimitedCreative Survival, Creative and Adventure files");
|
ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " LimitedCreative Survival, Creative and Adventure files");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void purgeDat(List<String> cleared) {
|
public synchronized void purgeDat(List<String> cleared) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (String name : cleared) {
|
for (String name : cleared) {
|
||||||
try {
|
try {
|
||||||
@ -120,12 +136,12 @@ public class DataManager extends Thread {
|
|||||||
ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " EssentialsFiles");
|
ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " EssentialsFiles");
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
public synchronized void purgePermissions(List<String> cleared,
|
||||||
public void purgePermissions(List<String> cleared, Permission permission) {
|
Permission permission) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (String name : cleared) {
|
for (String name : cleared) {
|
||||||
try {
|
try {
|
||||||
OfflinePlayer p = Bukkit.getOfflinePlayer(name);
|
OfflinePlayer p = this.getOfflinePlayer(name);
|
||||||
for (String group : permission.getPlayerGroups((Player) p)) {
|
for (String group : permission.getPlayerGroups((Player) p)) {
|
||||||
permission.playerRemoveGroup(null, p, group);
|
permission.playerRemoveGroup(null, p, group);
|
||||||
}
|
}
|
||||||
|
@ -243,4 +243,17 @@ public class PlayerAuth {
|
|||||||
this.nickname = nickname;
|
this.nickname = nickname;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void set(PlayerAuth auth) {
|
||||||
|
this.setEmail(auth.getEmail());
|
||||||
|
this.setHash(auth.getHash());
|
||||||
|
this.setIp(auth.getIp());
|
||||||
|
this.setLastLogin(auth.getLastLogin());
|
||||||
|
this.setName(auth.getNickname());
|
||||||
|
this.setQuitLocX(auth.getQuitLocX());
|
||||||
|
this.setQuitLocY(auth.getQuitLocY());
|
||||||
|
this.setQuitLocZ(auth.getQuitLocZ());
|
||||||
|
this.setSalt(auth.getSalt());
|
||||||
|
this.setWorld(auth.getWorld());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ import fr.xephi.authme.AuthMe;
|
|||||||
import fr.xephi.authme.ConsoleLogger;
|
import fr.xephi.authme.ConsoleLogger;
|
||||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
import fr.xephi.authme.datasource.FlatFileThread;
|
import fr.xephi.authme.datasource.FlatFile;
|
||||||
import fr.xephi.authme.settings.Messages;
|
import fr.xephi.authme.settings.Messages;
|
||||||
|
|
||||||
public class SqlToFlat implements Converter {
|
public class SqlToFlat implements Converter {
|
||||||
@ -26,8 +26,7 @@ public class SqlToFlat implements Converter {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
FlatFileThread flat = new FlatFileThread();
|
FlatFile flat = new FlatFile();
|
||||||
flat.start();
|
|
||||||
List<PlayerAuth> auths = database.getAllAuths();
|
List<PlayerAuth> auths = database.getAllAuths();
|
||||||
int i = 0;
|
int i = 0;
|
||||||
final int size = auths.size();
|
final int size = auths.size();
|
||||||
@ -38,8 +37,6 @@ public class SqlToFlat implements Converter {
|
|||||||
sender.sendMessage("Conversion Status : " + i + " / " + size);
|
sender.sendMessage("Conversion Status : " + i + " / " + size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (flat != null && flat.isAlive())
|
|
||||||
flat.interrupt();
|
|
||||||
sender.sendMessage("Successfully convert from SQL table to file auths.db");
|
sender.sendMessage("Successfully convert from SQL table to file auths.db");
|
||||||
return;
|
return;
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
|
@ -2,13 +2,14 @@ package fr.xephi.authme.datasource;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import fr.xephi.authme.AuthMe;
|
import fr.xephi.authme.AuthMe;
|
||||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||||
|
|
||||||
public class CacheDataSource extends Thread implements DataSource {
|
public class CacheDataSource implements DataSource {
|
||||||
|
|
||||||
private DataSource source;
|
private DataSource source;
|
||||||
public AuthMe plugin;
|
public AuthMe plugin;
|
||||||
@ -18,19 +19,14 @@ public class CacheDataSource extends Thread implements DataSource {
|
|||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.source = source;
|
this.source = source;
|
||||||
/*
|
/*
|
||||||
* We need to load all players in cache ...
|
* We need to load all players in cache ... It will took more time to
|
||||||
* It will took more time to load the server,
|
* load the server, but it will be much easier to check for an
|
||||||
* but it will be much easier to check for an isAuthAvailable !
|
* isAuthAvailable !
|
||||||
*/
|
*/
|
||||||
for(PlayerAuth auth : source.getAllAuths())
|
for (PlayerAuth auth : source.getAllAuths())
|
||||||
cache.put(auth.getNickname().toLowerCase(), auth);
|
cache.put(auth.getNickname().toLowerCase(), auth);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
this.setName("AuthMeCacheThread");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized boolean isAuthAvailable(String user) {
|
public synchronized boolean isAuthAvailable(String user) {
|
||||||
if (cache.containsKey(user.toLowerCase()))
|
if (cache.containsKey(user.toLowerCase()))
|
||||||
@ -139,7 +135,6 @@ public class CacheDataSource extends Thread implements DataSource {
|
|||||||
@Override
|
@Override
|
||||||
public synchronized void close() {
|
public synchronized void close() {
|
||||||
source.close();
|
source.close();
|
||||||
this.interrupt();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
382
src/main/java/fr/xephi/authme/datasource/DatabaseCalls.java
Normal file
382
src/main/java/fr/xephi/authme/datasource/DatabaseCalls.java
Normal file
@ -0,0 +1,382 @@
|
|||||||
|
package fr.xephi.authme.datasource;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.Callable;
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
|
import fr.xephi.authme.AuthMe;
|
||||||
|
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||||
|
|
||||||
|
public class DatabaseCalls implements DataSource {
|
||||||
|
|
||||||
|
private AuthMe plugin;
|
||||||
|
private DataSource database;
|
||||||
|
|
||||||
|
public DatabaseCalls(AuthMe plugin, DataSource database) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
this.database = database;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public synchronized boolean isAuthAvailable(final String user) {
|
||||||
|
ExecutorService executor = Executors.newSingleThreadExecutor();
|
||||||
|
Future<Boolean> result = executor.submit(new Callable<Boolean>() {
|
||||||
|
|
||||||
|
public Boolean call() throws Exception {
|
||||||
|
return database.isAuthAvailable(user);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
return result.get();
|
||||||
|
} catch (InterruptedException | ExecutionException e) {
|
||||||
|
return (false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public synchronized PlayerAuth getAuth(final String user) {
|
||||||
|
ExecutorService executor = Executors.newSingleThreadExecutor();
|
||||||
|
Future<PlayerAuth> result = executor.submit(new Callable<PlayerAuth>() {
|
||||||
|
|
||||||
|
public PlayerAuth call() throws Exception {
|
||||||
|
return database.getAuth(user);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
return result.get();
|
||||||
|
} catch (InterruptedException | ExecutionException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public synchronized boolean saveAuth(final PlayerAuth auth) {
|
||||||
|
ExecutorService executor = Executors.newSingleThreadExecutor();
|
||||||
|
Future<Boolean> result = executor.submit(new Callable<Boolean>() {
|
||||||
|
|
||||||
|
public Boolean call() throws Exception {
|
||||||
|
return database.saveAuth(auth);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
return result.get();
|
||||||
|
} catch (InterruptedException | ExecutionException e) {
|
||||||
|
return (false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public synchronized boolean updateSession(final PlayerAuth auth) {
|
||||||
|
ExecutorService executor = Executors.newSingleThreadExecutor();
|
||||||
|
Future<Boolean> result = executor.submit(new Callable<Boolean>() {
|
||||||
|
|
||||||
|
public Boolean call() throws Exception {
|
||||||
|
return database.updateSession(auth);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
return result.get();
|
||||||
|
} catch (InterruptedException | ExecutionException e) {
|
||||||
|
return (false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public synchronized boolean updatePassword(final PlayerAuth auth) {
|
||||||
|
ExecutorService executor = Executors.newSingleThreadExecutor();
|
||||||
|
Future<Boolean> result = executor.submit(new Callable<Boolean>() {
|
||||||
|
|
||||||
|
public Boolean call() throws Exception {
|
||||||
|
return database.updatePassword(auth);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
return result.get();
|
||||||
|
} catch (InterruptedException | ExecutionException e) {
|
||||||
|
return (false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public synchronized int purgeDatabase(final long until) {
|
||||||
|
ExecutorService executor = Executors.newSingleThreadExecutor();
|
||||||
|
Future<Integer> result = executor.submit(new Callable<Integer>() {
|
||||||
|
|
||||||
|
public Integer call() throws Exception {
|
||||||
|
return database.purgeDatabase(until);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
return result.get();
|
||||||
|
} catch (InterruptedException | ExecutionException e) {
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public synchronized List<String> autoPurgeDatabase(final long until) {
|
||||||
|
ExecutorService executor = Executors.newSingleThreadExecutor();
|
||||||
|
Future<List<String>> result = executor.submit(new Callable<List<String>>() {
|
||||||
|
|
||||||
|
public List<String> call() throws Exception {
|
||||||
|
return database.autoPurgeDatabase(until);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
return result.get();
|
||||||
|
} catch (InterruptedException | ExecutionException e) {
|
||||||
|
return (new ArrayList<String>());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public synchronized boolean removeAuth(final String user) {
|
||||||
|
ExecutorService executor = Executors.newSingleThreadExecutor();
|
||||||
|
Future<Boolean> result = executor.submit(new Callable<Boolean>() {
|
||||||
|
|
||||||
|
public Boolean call() throws Exception {
|
||||||
|
return database.removeAuth(user);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
return result.get();
|
||||||
|
} catch (InterruptedException | ExecutionException e) {
|
||||||
|
return (false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public synchronized boolean updateQuitLoc(final PlayerAuth auth) {
|
||||||
|
ExecutorService executor = Executors.newSingleThreadExecutor();
|
||||||
|
Future<Boolean> result = executor.submit(new Callable<Boolean>() {
|
||||||
|
|
||||||
|
public Boolean call() throws Exception {
|
||||||
|
return database.updateQuitLoc(auth);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
return result.get();
|
||||||
|
} catch (InterruptedException | ExecutionException e) {
|
||||||
|
return (false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public synchronized int getIps(final String ip) {
|
||||||
|
ExecutorService executor = Executors.newSingleThreadExecutor();
|
||||||
|
Future<Integer> result = executor.submit(new Callable<Integer>() {
|
||||||
|
|
||||||
|
public Integer call() throws Exception {
|
||||||
|
return database.getIps(ip);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
return result.get();
|
||||||
|
} catch (InterruptedException | ExecutionException e) {
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public synchronized List<String> getAllAuthsByName(final PlayerAuth auth) {
|
||||||
|
ExecutorService executor = Executors.newSingleThreadExecutor();
|
||||||
|
Future<List<String>> result = executor.submit(new Callable<List<String>>() {
|
||||||
|
|
||||||
|
public List<String> call() throws Exception {
|
||||||
|
return database.getAllAuthsByName(auth);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
return result.get();
|
||||||
|
} catch (InterruptedException | ExecutionException e) {
|
||||||
|
return (new ArrayList<String>());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public synchronized List<String> getAllAuthsByIp(final String ip) {
|
||||||
|
ExecutorService executor = Executors.newSingleThreadExecutor();
|
||||||
|
Future<List<String>> result = executor.submit(new Callable<List<String>>() {
|
||||||
|
|
||||||
|
public List<String> call() throws Exception {
|
||||||
|
return database.getAllAuthsByIp(ip);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
return result.get();
|
||||||
|
} catch (InterruptedException | ExecutionException e) {
|
||||||
|
return (new ArrayList<String>());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public synchronized List<String> getAllAuthsByEmail(final String email) {
|
||||||
|
ExecutorService executor = Executors.newSingleThreadExecutor();
|
||||||
|
Future<List<String>> result = executor.submit(new Callable<List<String>>() {
|
||||||
|
|
||||||
|
public List<String> call() throws Exception {
|
||||||
|
return database.getAllAuthsByEmail(email);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
return result.get();
|
||||||
|
} catch (InterruptedException | ExecutionException e) {
|
||||||
|
return (new ArrayList<String>());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public synchronized boolean updateEmail(final PlayerAuth auth) {
|
||||||
|
ExecutorService executor = Executors.newSingleThreadExecutor();
|
||||||
|
Future<Boolean> result = executor.submit(new Callable<Boolean>() {
|
||||||
|
|
||||||
|
public Boolean call() throws Exception {
|
||||||
|
return database.updateEmail(auth);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
return result.get();
|
||||||
|
} catch (InterruptedException | ExecutionException e) {
|
||||||
|
return (false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public synchronized boolean updateSalt(final PlayerAuth auth) {
|
||||||
|
ExecutorService executor = Executors.newSingleThreadExecutor();
|
||||||
|
Future<Boolean> result = executor.submit(new Callable<Boolean>() {
|
||||||
|
|
||||||
|
public Boolean call() throws Exception {
|
||||||
|
return database.updateSalt(auth);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
return result.get();
|
||||||
|
} catch (InterruptedException | ExecutionException e) {
|
||||||
|
return (false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public synchronized void close() {
|
||||||
|
database.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public synchronized void reload() {
|
||||||
|
database.reload();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public synchronized void purgeBanned(final List<String> banned) {
|
||||||
|
new Thread(new Runnable() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public synchronized void run() {
|
||||||
|
database.purgeBanned(banned);
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public synchronized DataSourceType getType() {
|
||||||
|
return database.getType();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public synchronized boolean isLogged(final String user) {
|
||||||
|
ExecutorService executor = Executors.newSingleThreadExecutor();
|
||||||
|
Future<Boolean> result = executor.submit(new Callable<Boolean>() {
|
||||||
|
|
||||||
|
public Boolean call() throws Exception {
|
||||||
|
return database.isLogged(user);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
return result.get();
|
||||||
|
} catch (InterruptedException | ExecutionException e) {
|
||||||
|
return (false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public synchronized void setLogged(final String user) {
|
||||||
|
new Thread(new Runnable() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public synchronized void run() {
|
||||||
|
database.setLogged(user);
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public synchronized void setUnlogged(final String user) {
|
||||||
|
new Thread(new Runnable() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public synchronized void run() {
|
||||||
|
database.setUnlogged(user);
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public synchronized void purgeLogged() {
|
||||||
|
new Thread(new Runnable() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public synchronized void run() {
|
||||||
|
database.purgeLogged();
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public synchronized int getAccountsRegistered() {
|
||||||
|
ExecutorService executor = Executors.newSingleThreadExecutor();
|
||||||
|
Future<Integer> result = executor.submit(new Callable<Integer>() {
|
||||||
|
|
||||||
|
public Integer call() throws Exception {
|
||||||
|
return database.getAccountsRegistered();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
return result.get();
|
||||||
|
} catch (InterruptedException | ExecutionException e) {
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public synchronized void updateName(final String oldone, final String newone) {
|
||||||
|
new Thread(new Runnable() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public synchronized void run() {
|
||||||
|
database.updateName(oldone, newone);
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public synchronized List<PlayerAuth> getAllAuths() {
|
||||||
|
ExecutorService executor = Executors.newSingleThreadExecutor();
|
||||||
|
Future<List<PlayerAuth>> result = executor.submit(new Callable<List<PlayerAuth>>() {
|
||||||
|
|
||||||
|
public List<PlayerAuth> call() throws Exception {
|
||||||
|
return database.getAllAuths();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
return result.get();
|
||||||
|
} catch (InterruptedException | ExecutionException e) {
|
||||||
|
return (new ArrayList<PlayerAuth>());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -16,7 +16,7 @@ import fr.xephi.authme.cache.auth.PlayerAuth;
|
|||||||
import fr.xephi.authme.settings.PlayersLogs;
|
import fr.xephi.authme.settings.PlayersLogs;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
|
|
||||||
public class FlatFileThread extends Thread implements DataSource {
|
public class FlatFile implements DataSource {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* file layout:
|
* file layout:
|
||||||
@ -31,11 +31,8 @@ public class FlatFileThread extends Thread implements DataSource {
|
|||||||
*/
|
*/
|
||||||
private File source;
|
private File source;
|
||||||
|
|
||||||
public FlatFileThread() {
|
public FlatFile() {
|
||||||
source = new File(Settings.AUTH_FILE);
|
source = new File(Settings.AUTH_FILE);
|
||||||
}
|
|
||||||
|
|
||||||
public void run() {
|
|
||||||
try {
|
try {
|
||||||
source.createNewFile();
|
source.createNewFile();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@ -48,7 +45,6 @@ public class FlatFileThread extends Thread implements DataSource {
|
|||||||
AuthMe.getInstance().getServer().getPluginManager().disablePlugin(AuthMe.getInstance());
|
AuthMe.getInstance().getServer().getPluginManager().disablePlugin(AuthMe.getInstance());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.setName("AuthMeFlatFileThread");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
@ -18,7 +18,7 @@ import fr.xephi.authme.datasource.MiniConnectionPoolManager.TimeoutException;
|
|||||||
import fr.xephi.authme.security.HashAlgorithm;
|
import fr.xephi.authme.security.HashAlgorithm;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
|
|
||||||
public class MySQLThread extends Thread implements DataSource {
|
public class MySQL implements DataSource {
|
||||||
|
|
||||||
private String host;
|
private String host;
|
||||||
private String port;
|
private String port;
|
||||||
@ -42,7 +42,7 @@ public class MySQLThread extends Thread implements DataSource {
|
|||||||
private List<String> columnOthers;
|
private List<String> columnOthers;
|
||||||
private MiniConnectionPoolManager conPool;
|
private MiniConnectionPoolManager conPool;
|
||||||
|
|
||||||
public void run() {
|
public MySQL() {
|
||||||
this.host = Settings.getMySQLHost;
|
this.host = Settings.getMySQLHost;
|
||||||
this.port = Settings.getMySQLPort;
|
this.port = Settings.getMySQLPort;
|
||||||
this.username = Settings.getMySQLUsername;
|
this.username = Settings.getMySQLUsername;
|
||||||
@ -94,7 +94,6 @@ public class MySQLThread extends Thread implements DataSource {
|
|||||||
AuthMe.getInstance().getServer().getPluginManager().disablePlugin(AuthMe.getInstance());
|
AuthMe.getInstance().getServer().getPluginManager().disablePlugin(AuthMe.getInstance());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.setName("AuthMeMySQLThread");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized void connect() throws ClassNotFoundException,
|
private synchronized void connect() throws ClassNotFoundException,
|
@ -16,7 +16,7 @@ import fr.xephi.authme.datasource.MiniConnectionPoolManager.TimeoutException;
|
|||||||
import fr.xephi.authme.settings.PlayersLogs;
|
import fr.xephi.authme.settings.PlayersLogs;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
|
|
||||||
public class SQLiteThread extends Thread implements DataSource {
|
public class SQLite implements DataSource {
|
||||||
|
|
||||||
private String database;
|
private String database;
|
||||||
private String tableName;
|
private String tableName;
|
||||||
@ -34,7 +34,7 @@ public class SQLiteThread extends Thread implements DataSource {
|
|||||||
private String columnID;
|
private String columnID;
|
||||||
private Connection con;
|
private Connection con;
|
||||||
|
|
||||||
public void run() {
|
public SQLite() {
|
||||||
this.database = Settings.getMySQLDatabase;
|
this.database = Settings.getMySQLDatabase;
|
||||||
this.tableName = Settings.getMySQLTablename;
|
this.tableName = Settings.getMySQLTablename;
|
||||||
this.columnName = Settings.getMySQLColumnName;
|
this.columnName = Settings.getMySQLColumnName;
|
||||||
@ -72,7 +72,6 @@ public class SQLiteThread extends Thread implements DataSource {
|
|||||||
AuthMe.getInstance().getServer().getPluginManager().disablePlugin(AuthMe.getInstance());
|
AuthMe.getInstance().getServer().getPluginManager().disablePlugin(AuthMe.getInstance());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.setName("AuthMeSQLiteThread");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized void connect() throws ClassNotFoundException,
|
private synchronized void connect() throws ClassNotFoundException,
|
@ -357,13 +357,8 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!data.isAuthAvailable(name)) {
|
|
||||||
if (!Settings.isForcedRegistrationEnabled) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!Settings.isForcedRegistrationEnabled) {
|
if (!Settings.isForcedRegistrationEnabled) {
|
||||||
|
if (!data.isAuthAvailable(name))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ import fr.xephi.authme.settings.Settings;
|
|||||||
* href="http://dev.bukkit.org/profiles/Possible/">Possible</a>
|
* href="http://dev.bukkit.org/profiles/Possible/">Possible</a>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class Management extends Thread {
|
public class Management {
|
||||||
|
|
||||||
public DataSource database;
|
public DataSource database;
|
||||||
public AuthMe plugin;
|
public AuthMe plugin;
|
||||||
@ -30,12 +30,10 @@ public class Management extends Thread {
|
|||||||
this.pm = plugin.getServer().getPluginManager();
|
this.pm = plugin.getServer().getPluginManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public void performLogin(final Player player, final String password,
|
public void performLogin(final Player player, final String password,
|
||||||
final boolean forceLogin) {
|
final boolean forceLogin) {
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable(){
|
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
new AsyncronousLogin(player, password, forceLogin, plugin, database).process();
|
new AsyncronousLogin(player, password, forceLogin, plugin, database).process();
|
||||||
@ -45,7 +43,8 @@ public class Management extends Thread {
|
|||||||
|
|
||||||
public void performRegister(final Player player, final String password,
|
public void performRegister(final Player player, final String password,
|
||||||
final String email) {
|
final String email) {
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable(){
|
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
new AsyncronousRegister(player, password, email, plugin, database).process();
|
new AsyncronousRegister(player, password, email, plugin, database).process();
|
||||||
|
Loading…
Reference in New Issue
Block a user