mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-11-09 12:10:56 +01:00
Don't Wait !
This commit is contained in:
parent
def272428b
commit
0fbf57cf1a
@ -1,6 +1,5 @@
|
||||
package fr.xephi.authme.cache.limbo;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@ -84,10 +83,8 @@ public class LimboPlayer {
|
||||
}
|
||||
|
||||
public void setTimeoutTaskId(BukkitTask i) {
|
||||
if (this.timeoutTaskId != null) {
|
||||
if (Bukkit.getScheduler().isCurrentlyRunning(this.timeoutTaskId.getTaskId()) || Bukkit.getScheduler().isQueued(this.timeoutTaskId.getTaskId()))
|
||||
Bukkit.getScheduler().cancelTask(this.timeoutTaskId.getTaskId());
|
||||
}
|
||||
if (this.timeoutTaskId != null)
|
||||
this.timeoutTaskId.cancel();
|
||||
this.timeoutTaskId = i;
|
||||
}
|
||||
|
||||
@ -96,10 +93,8 @@ public class LimboPlayer {
|
||||
}
|
||||
|
||||
public void setMessageTaskId(BukkitTask messageTaskId) {
|
||||
if (this.messageTaskId != null) {
|
||||
if (Bukkit.getScheduler().isCurrentlyRunning(this.messageTaskId.getTaskId()) || Bukkit.getScheduler().isQueued(this.messageTaskId.getTaskId()))
|
||||
Bukkit.getScheduler().cancelTask(this.messageTaskId.getTaskId());
|
||||
}
|
||||
if (this.messageTaskId != null)
|
||||
this.messageTaskId.cancel();
|
||||
this.messageTaskId = messageTaskId;
|
||||
}
|
||||
|
||||
|
@ -29,9 +29,7 @@ public class CacheDataSource implements DataSource {
|
||||
|
||||
@Override
|
||||
public synchronized boolean isAuthAvailable(String user) {
|
||||
if (cache.containsKey(user.toLowerCase()))
|
||||
return true;
|
||||
return false;
|
||||
return cache.containsKey(user.toLowerCase());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -3,9 +3,9 @@ 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.cache.auth.PlayerAuth;
|
||||
|
||||
@ -20,14 +20,23 @@ public class DatabaseCalls implements DataSource {
|
||||
@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);
|
||||
}
|
||||
});
|
||||
Boolean result;
|
||||
try {
|
||||
return result.get();
|
||||
result = executor.submit(new Callable<Boolean>() {
|
||||
|
||||
public Boolean call() throws Exception {
|
||||
return database.isAuthAvailable(user);
|
||||
}
|
||||
}).get();
|
||||
} catch (InterruptedException e1) {
|
||||
return false;
|
||||
} catch (ExecutionException e1) {
|
||||
return false;
|
||||
} finally {
|
||||
executor.shutdown();
|
||||
}
|
||||
try {
|
||||
return result.booleanValue();
|
||||
} catch (Exception e) {
|
||||
return (false);
|
||||
}
|
||||
@ -36,14 +45,23 @@ public class DatabaseCalls implements DataSource {
|
||||
@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);
|
||||
}
|
||||
});
|
||||
PlayerAuth result;
|
||||
try {
|
||||
return result.get();
|
||||
result = executor.submit(new Callable<PlayerAuth>() {
|
||||
|
||||
public PlayerAuth call() throws Exception {
|
||||
return database.getAuth(user);
|
||||
}
|
||||
}).get();
|
||||
} catch (InterruptedException e1) {
|
||||
return null;
|
||||
} catch (ExecutionException e1) {
|
||||
return null;
|
||||
} finally {
|
||||
executor.shutdown();
|
||||
}
|
||||
try {
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
@ -52,14 +70,23 @@ public class DatabaseCalls implements DataSource {
|
||||
@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);
|
||||
}
|
||||
});
|
||||
Boolean result;
|
||||
try {
|
||||
return result.get();
|
||||
result = executor.submit(new Callable<Boolean>() {
|
||||
|
||||
public Boolean call() throws Exception {
|
||||
return database.saveAuth(auth);
|
||||
}
|
||||
}).get();
|
||||
} catch (InterruptedException e1) {
|
||||
return false;
|
||||
} catch (ExecutionException e1) {
|
||||
return false;
|
||||
} finally {
|
||||
executor.shutdown();
|
||||
}
|
||||
try {
|
||||
return result.booleanValue();
|
||||
} catch (Exception e) {
|
||||
return (false);
|
||||
}
|
||||
@ -68,14 +95,23 @@ public class DatabaseCalls implements DataSource {
|
||||
@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);
|
||||
}
|
||||
});
|
||||
Boolean result;
|
||||
try {
|
||||
return result.get();
|
||||
result = executor.submit(new Callable<Boolean>() {
|
||||
|
||||
public Boolean call() throws Exception {
|
||||
return database.updateSession(auth);
|
||||
}
|
||||
}).get();
|
||||
} catch (InterruptedException e1) {
|
||||
return false;
|
||||
} catch (ExecutionException e1) {
|
||||
return false;
|
||||
} finally {
|
||||
executor.shutdown();
|
||||
}
|
||||
try {
|
||||
return result.booleanValue();
|
||||
} catch (Exception e) {
|
||||
return (false);
|
||||
}
|
||||
@ -84,14 +120,23 @@ public class DatabaseCalls implements DataSource {
|
||||
@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);
|
||||
}
|
||||
});
|
||||
Boolean result;
|
||||
try {
|
||||
return result.get();
|
||||
result = executor.submit(new Callable<Boolean>() {
|
||||
|
||||
public Boolean call() throws Exception {
|
||||
return database.updatePassword(auth);
|
||||
}
|
||||
}).get();
|
||||
} catch (InterruptedException e1) {
|
||||
return false;
|
||||
} catch (ExecutionException e1) {
|
||||
return false;
|
||||
} finally {
|
||||
executor.shutdown();
|
||||
}
|
||||
try {
|
||||
return result.booleanValue();
|
||||
} catch (Exception e) {
|
||||
return (false);
|
||||
}
|
||||
@ -100,14 +145,23 @@ public class DatabaseCalls implements DataSource {
|
||||
@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);
|
||||
}
|
||||
});
|
||||
Integer result;
|
||||
try {
|
||||
return result.get();
|
||||
result = executor.submit(new Callable<Integer>() {
|
||||
|
||||
public Integer call() throws Exception {
|
||||
return database.purgeDatabase(until);
|
||||
}
|
||||
}).get();
|
||||
} catch (InterruptedException e1) {
|
||||
return 0;
|
||||
} catch (ExecutionException e1) {
|
||||
return 0;
|
||||
} finally {
|
||||
executor.shutdown();
|
||||
}
|
||||
try {
|
||||
return result.intValue();
|
||||
} catch (Exception e) {
|
||||
return (0);
|
||||
}
|
||||
@ -116,14 +170,23 @@ public class DatabaseCalls implements DataSource {
|
||||
@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);
|
||||
}
|
||||
});
|
||||
List<String> result;
|
||||
try {
|
||||
return result.get();
|
||||
result = executor.submit(new Callable<List<String>>() {
|
||||
|
||||
public List<String> call() throws Exception {
|
||||
return database.autoPurgeDatabase(until);
|
||||
}
|
||||
}).get();
|
||||
} catch (InterruptedException e1) {
|
||||
return new ArrayList<String>();
|
||||
} catch (ExecutionException e1) {
|
||||
return new ArrayList<String>();
|
||||
} finally {
|
||||
executor.shutdown();
|
||||
}
|
||||
try {
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
return (new ArrayList<String>());
|
||||
}
|
||||
@ -132,14 +195,23 @@ public class DatabaseCalls implements DataSource {
|
||||
@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);
|
||||
}
|
||||
});
|
||||
Boolean result;
|
||||
try {
|
||||
return result.get();
|
||||
result = executor.submit(new Callable<Boolean>() {
|
||||
|
||||
public Boolean call() throws Exception {
|
||||
return database.removeAuth(user);
|
||||
}
|
||||
}).get();
|
||||
} catch (InterruptedException e1) {
|
||||
return false;
|
||||
} catch (ExecutionException e1) {
|
||||
return false;
|
||||
} finally {
|
||||
executor.shutdown();
|
||||
}
|
||||
try {
|
||||
return result.booleanValue();
|
||||
} catch (Exception e) {
|
||||
return (false);
|
||||
}
|
||||
@ -148,14 +220,23 @@ public class DatabaseCalls implements DataSource {
|
||||
@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);
|
||||
}
|
||||
});
|
||||
Boolean result;
|
||||
try {
|
||||
return result.get();
|
||||
result = executor.submit(new Callable<Boolean>() {
|
||||
|
||||
public Boolean call() throws Exception {
|
||||
return database.updateQuitLoc(auth);
|
||||
}
|
||||
}).get();
|
||||
} catch (InterruptedException e1) {
|
||||
return false;
|
||||
} catch (ExecutionException e1) {
|
||||
return false;
|
||||
} finally {
|
||||
executor.shutdown();
|
||||
}
|
||||
try {
|
||||
return result.booleanValue();
|
||||
} catch (Exception e) {
|
||||
return (false);
|
||||
}
|
||||
@ -164,14 +245,23 @@ public class DatabaseCalls implements DataSource {
|
||||
@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);
|
||||
}
|
||||
});
|
||||
Integer result;
|
||||
try {
|
||||
return result.get();
|
||||
result = executor.submit(new Callable<Integer>() {
|
||||
|
||||
public Integer call() throws Exception {
|
||||
return database.getIps(ip);
|
||||
}
|
||||
}).get();
|
||||
} catch (InterruptedException e1) {
|
||||
return 0;
|
||||
} catch (ExecutionException e1) {
|
||||
return 0;
|
||||
} finally {
|
||||
executor.shutdown();
|
||||
}
|
||||
try {
|
||||
return result.intValue();
|
||||
} catch (Exception e) {
|
||||
return (0);
|
||||
}
|
||||
@ -180,14 +270,23 @@ public class DatabaseCalls implements DataSource {
|
||||
@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);
|
||||
}
|
||||
});
|
||||
List<String> result;
|
||||
try {
|
||||
return result.get();
|
||||
result = executor.submit(new Callable<List<String>>() {
|
||||
|
||||
public List<String> call() throws Exception {
|
||||
return database.getAllAuthsByName(auth);
|
||||
}
|
||||
}).get();
|
||||
} catch (InterruptedException e1) {
|
||||
return new ArrayList<String>();
|
||||
} catch (ExecutionException e1) {
|
||||
return new ArrayList<String>();
|
||||
} finally {
|
||||
executor.shutdown();
|
||||
}
|
||||
try {
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
return (new ArrayList<String>());
|
||||
}
|
||||
@ -196,14 +295,23 @@ public class DatabaseCalls implements DataSource {
|
||||
@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);
|
||||
}
|
||||
});
|
||||
List<String> result;
|
||||
try {
|
||||
return result.get();
|
||||
result = executor.submit(new Callable<List<String>>() {
|
||||
|
||||
public List<String> call() throws Exception {
|
||||
return database.getAllAuthsByIp(ip);
|
||||
}
|
||||
}).get();
|
||||
} catch (InterruptedException e1) {
|
||||
return new ArrayList<String>();
|
||||
} catch (ExecutionException e1) {
|
||||
return new ArrayList<String>();
|
||||
} finally {
|
||||
executor.shutdown();
|
||||
}
|
||||
try {
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
return (new ArrayList<String>());
|
||||
}
|
||||
@ -212,14 +320,23 @@ public class DatabaseCalls implements DataSource {
|
||||
@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);
|
||||
}
|
||||
});
|
||||
List<String> result;
|
||||
try {
|
||||
return result.get();
|
||||
result = executor.submit(new Callable<List<String>>() {
|
||||
|
||||
public List<String> call() throws Exception {
|
||||
return database.getAllAuthsByEmail(email);
|
||||
}
|
||||
}).get();
|
||||
} catch (InterruptedException e1) {
|
||||
return new ArrayList<String>();
|
||||
} catch (ExecutionException e1) {
|
||||
return new ArrayList<String>();
|
||||
} finally {
|
||||
executor.shutdown();
|
||||
}
|
||||
try {
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
return (new ArrayList<String>());
|
||||
}
|
||||
@ -228,14 +345,23 @@ public class DatabaseCalls implements DataSource {
|
||||
@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);
|
||||
}
|
||||
});
|
||||
Boolean result;
|
||||
try {
|
||||
return result.get();
|
||||
result = executor.submit(new Callable<Boolean>() {
|
||||
|
||||
public Boolean call() throws Exception {
|
||||
return database.updateEmail(auth);
|
||||
}
|
||||
}).get();
|
||||
} catch (InterruptedException e1) {
|
||||
return false;
|
||||
} catch (ExecutionException e1) {
|
||||
return false;
|
||||
} finally {
|
||||
executor.shutdown();
|
||||
}
|
||||
try {
|
||||
return result.booleanValue();
|
||||
} catch (Exception e) {
|
||||
return (false);
|
||||
}
|
||||
@ -244,14 +370,23 @@ public class DatabaseCalls implements DataSource {
|
||||
@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);
|
||||
}
|
||||
});
|
||||
Boolean result;
|
||||
try {
|
||||
return result.get();
|
||||
result = executor.submit(new Callable<Boolean>() {
|
||||
|
||||
public Boolean call() throws Exception {
|
||||
return database.updateSalt(auth);
|
||||
}
|
||||
}).get();
|
||||
} catch (InterruptedException e1) {
|
||||
return false;
|
||||
} catch (ExecutionException e1) {
|
||||
return false;
|
||||
} finally {
|
||||
executor.shutdown();
|
||||
}
|
||||
try {
|
||||
return result.booleanValue();
|
||||
} catch (Exception e) {
|
||||
return (false);
|
||||
}
|
||||
@ -286,14 +421,23 @@ public class DatabaseCalls implements DataSource {
|
||||
@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);
|
||||
}
|
||||
});
|
||||
Boolean result;
|
||||
try {
|
||||
return result.get();
|
||||
result = executor.submit(new Callable<Boolean>() {
|
||||
|
||||
public Boolean call() throws Exception {
|
||||
return database.isLogged(user);
|
||||
}
|
||||
}).get();
|
||||
} catch (InterruptedException e1) {
|
||||
return false;
|
||||
} catch (ExecutionException e1) {
|
||||
return false;
|
||||
} finally {
|
||||
executor.shutdown();
|
||||
}
|
||||
try {
|
||||
return result.booleanValue();
|
||||
} catch (Exception e) {
|
||||
return (false);
|
||||
}
|
||||
@ -335,14 +479,23 @@ public class DatabaseCalls implements DataSource {
|
||||
@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();
|
||||
}
|
||||
});
|
||||
Integer result;
|
||||
try {
|
||||
return result.get();
|
||||
result = executor.submit(new Callable<Integer>() {
|
||||
|
||||
public Integer call() throws Exception {
|
||||
return database.getAccountsRegistered();
|
||||
}
|
||||
}).get();
|
||||
} catch (InterruptedException e1) {
|
||||
return 0;
|
||||
} catch (ExecutionException e1) {
|
||||
return 0;
|
||||
} finally {
|
||||
executor.shutdown();
|
||||
}
|
||||
try {
|
||||
return result.intValue();
|
||||
} catch (Exception e) {
|
||||
return (0);
|
||||
}
|
||||
@ -363,17 +516,22 @@ public class DatabaseCalls implements DataSource {
|
||||
@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();
|
||||
}
|
||||
});
|
||||
List<PlayerAuth> result;
|
||||
try {
|
||||
return result.get();
|
||||
} catch (Exception e) {
|
||||
result = executor.submit(new Callable<List<PlayerAuth>>() {
|
||||
|
||||
public List<PlayerAuth> call() throws Exception {
|
||||
return database.getAllAuths();
|
||||
}
|
||||
}).get();
|
||||
} catch (InterruptedException e1) {
|
||||
return (new ArrayList<PlayerAuth>());
|
||||
} catch (ExecutionException e1) {
|
||||
return (new ArrayList<PlayerAuth>());
|
||||
} finally {
|
||||
executor.shutdown();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user