Fix #408 Player quit location is not updated

- Ensure that the cache data source updates the quit location on the actual source
This commit is contained in:
ljacqu 2016-01-04 21:51:28 +01:00
parent 6d7d856ebe
commit 5ec1b67e03
2 changed files with 1 additions and 399 deletions

View File

@ -52,44 +52,17 @@ public class CacheDataSource implements DataSource {
}); });
} }
/**
* Method isAuthAvailable.
*
* @param user String
*
* @return boolean
*
* @see fr.xephi.authme.datasource.DataSource#isAuthAvailable(String)
*/
@Override @Override
public synchronized boolean isAuthAvailable(String user) { public synchronized boolean isAuthAvailable(String user) {
return getAuth(user) != null; return getAuth(user) != null;
} }
/**
* Method getAuth.
*
* @param user String
*
* @return PlayerAuth
*
* @see fr.xephi.authme.datasource.DataSource#getAuth(String)
*/
@Override @Override
public synchronized PlayerAuth getAuth(String user) { public synchronized PlayerAuth getAuth(String user) {
user = user.toLowerCase(); user = user.toLowerCase();
return cachedAuths.getUnchecked(user).orNull(); return cachedAuths.getUnchecked(user).orNull();
} }
/**
* Method saveAuth.
*
* @param auth PlayerAuth
*
* @return boolean
*
* @see fr.xephi.authme.datasource.DataSource#saveAuth(PlayerAuth)
*/
@Override @Override
public synchronized boolean saveAuth(PlayerAuth auth) { public synchronized boolean saveAuth(PlayerAuth auth) {
boolean result = source.saveAuth(auth); boolean result = source.saveAuth(auth);
@ -99,15 +72,6 @@ public class CacheDataSource implements DataSource {
return result; return result;
} }
/**
* Method updatePassword.
*
* @param auth PlayerAuth
*
* @return boolean
*
* @see fr.xephi.authme.datasource.DataSource#updatePassword(PlayerAuth)
*/
@Override @Override
public synchronized boolean updatePassword(PlayerAuth auth) { public synchronized boolean updatePassword(PlayerAuth auth) {
boolean result = source.updatePassword(auth); boolean result = source.updatePassword(auth);
@ -117,15 +81,6 @@ public class CacheDataSource implements DataSource {
return result; return result;
} }
/**
* Method updateSession.
*
* @param auth PlayerAuth
*
* @return boolean
*
* @see fr.xephi.authme.datasource.DataSource#updateSession(PlayerAuth)
*/
@Override @Override
public boolean updateSession(PlayerAuth auth) { public boolean updateSession(PlayerAuth auth) {
boolean result = source.updateSession(auth); boolean result = source.updateSession(auth);
@ -135,47 +90,20 @@ public class CacheDataSource implements DataSource {
return result; return result;
} }
/**
* Method updateQuitLoc.
*
* @param auth PlayerAuth
*
* @return boolean
*
* @see fr.xephi.authme.datasource.DataSource#updateQuitLoc(PlayerAuth)
*/
@Override @Override
public boolean updateQuitLoc(final PlayerAuth auth) { public boolean updateQuitLoc(final PlayerAuth auth) {
boolean result = source.updateSession(auth); boolean result = source.updateQuitLoc(auth);
if (result) { if (result) {
cachedAuths.refresh(auth.getNickname()); cachedAuths.refresh(auth.getNickname());
} }
return result; return result;
} }
/**
* Method getIps.
*
* @param ip String
*
* @return int
*
* @see fr.xephi.authme.datasource.DataSource#getIps(String)
*/
@Override @Override
public int getIps(String ip) { public int getIps(String ip) {
return source.getIps(ip); return source.getIps(ip);
} }
/**
* Method purgeDatabase.
*
* @param until long
*
* @return int
*
* @see fr.xephi.authme.datasource.DataSource#purgeDatabase(long)
*/
@Override @Override
public int purgeDatabase(long until) { public int purgeDatabase(long until) {
int cleared = source.purgeDatabase(until); int cleared = source.purgeDatabase(until);
@ -189,15 +117,6 @@ public class CacheDataSource implements DataSource {
return cleared; return cleared;
} }
/**
* Method autoPurgeDatabase.
*
* @param until long
*
* @return List
*
* @see fr.xephi.authme.datasource.DataSource#autoPurgeDatabase(long)
*/
@Override @Override
public List<String> autoPurgeDatabase(long until) { public List<String> autoPurgeDatabase(long until) {
List<String> cleared = source.autoPurgeDatabase(until); List<String> cleared = source.autoPurgeDatabase(until);
@ -207,15 +126,6 @@ public class CacheDataSource implements DataSource {
return cleared; return cleared;
} }
/**
* Method removeAuth.
*
* @param name String
*
* @return boolean
*
* @see fr.xephi.authme.datasource.DataSource#removeAuth(String)
*/
@Override @Override
public synchronized boolean removeAuth(String name) { public synchronized boolean removeAuth(String name) {
name = name.toLowerCase(); name = name.toLowerCase();
@ -226,11 +136,6 @@ public class CacheDataSource implements DataSource {
return result; return result;
} }
/**
* Method close.
*
* @see fr.xephi.authme.datasource.DataSource#close()
*/
@Override @Override
public synchronized void close() { public synchronized void close() {
try { try {
@ -242,11 +147,6 @@ public class CacheDataSource implements DataSource {
source.close(); source.close();
} }
/**
* Method reload.
*
* @see fr.xephi.authme.datasource.DataSource#reload()
*/
@Override @Override
public void reload() { // unused method public void reload() { // unused method
exec.execute(new Runnable() { exec.execute(new Runnable() {
@ -258,15 +158,6 @@ public class CacheDataSource implements DataSource {
}); });
} }
/**
* Method updateEmail.
*
* @param auth PlayerAuth
*
* @return boolean
*
* @see fr.xephi.authme.datasource.DataSource#updateEmail(PlayerAuth)
*/
@Override @Override
public synchronized boolean updateEmail(final PlayerAuth auth) { public synchronized boolean updateEmail(final PlayerAuth auth) {
boolean result = source.updateEmail(auth); boolean result = source.updateEmail(auth);
@ -276,55 +167,21 @@ public class CacheDataSource implements DataSource {
return result; return result;
} }
/**
* Method getAllAuthsByName.
*
* @param auth PlayerAuth
*
* @return List
*
* @see fr.xephi.authme.datasource.DataSource#getAllAuthsByName(PlayerAuth)
*/
@Override @Override
public synchronized List<String> getAllAuthsByName(PlayerAuth auth) { public synchronized List<String> getAllAuthsByName(PlayerAuth auth) {
return source.getAllAuthsByName(auth); return source.getAllAuthsByName(auth);
} }
/**
* Method getAllAuthsByIp.
*
* @param ip String
*
* @return List
*
* @see fr.xephi.authme.datasource.DataSource#getAllAuthsByIp(String)
*/
@Override @Override
public synchronized List<String> getAllAuthsByIp(final String ip) { public synchronized List<String> getAllAuthsByIp(final String ip) {
return source.getAllAuthsByIp(ip); return source.getAllAuthsByIp(ip);
} }
/**
* Method getAllAuthsByEmail.
*
* @param email String
*
* @return List
*
* @see fr.xephi.authme.datasource.DataSource#getAllAuthsByEmail(String)
*/
@Override @Override
public synchronized List<String> getAllAuthsByEmail(final String email) { public synchronized List<String> getAllAuthsByEmail(final String email) {
return source.getAllAuthsByEmail(email); return source.getAllAuthsByEmail(email);
} }
/**
* Method purgeBanned.
*
* @param banned List of String
*
* @see fr.xephi.authme.datasource.DataSource#purgeBanned(List)
*/
@Override @Override
public synchronized void purgeBanned(final List<String> banned) { public synchronized void purgeBanned(final List<String> banned) {
exec.execute(new Runnable() { exec.execute(new Runnable() {
@ -336,39 +193,16 @@ public class CacheDataSource implements DataSource {
}); });
} }
/**
* Method getType.
*
* @return DataSourceType
*
* @see fr.xephi.authme.datasource.DataSource#getType()
*/
@Override @Override
public DataSourceType getType() { public DataSourceType getType() {
return source.getType(); return source.getType();
} }
/**
* Method isLogged.
*
* @param user String
*
* @return boolean
*
* @see fr.xephi.authme.datasource.DataSource#isLogged(String)
*/
@Override @Override
public boolean isLogged(String user) { public boolean isLogged(String user) {
return PlayerCache.getInstance().isAuthenticated(user); return PlayerCache.getInstance().isAuthenticated(user);
} }
/**
* Method setLogged.
*
* @param user String
*
* @see fr.xephi.authme.datasource.DataSource#setLogged(String)
*/
@Override @Override
public void setLogged(final String user) { public void setLogged(final String user) {
exec.execute(new Runnable() { exec.execute(new Runnable() {
@ -379,13 +213,6 @@ public class CacheDataSource implements DataSource {
}); });
} }
/**
* Method setUnlogged.
*
* @param user String
*
* @see fr.xephi.authme.datasource.DataSource#setUnlogged(String)
*/
@Override @Override
public void setUnlogged(final String user) { public void setUnlogged(final String user) {
exec.execute(new Runnable() { exec.execute(new Runnable() {
@ -396,11 +223,6 @@ public class CacheDataSource implements DataSource {
}); });
} }
/**
* Method purgeLogged.
*
* @see fr.xephi.authme.datasource.DataSource#purgeLogged()
*/
@Override @Override
public void purgeLogged() { public void purgeLogged() {
exec.execute(new Runnable() { exec.execute(new Runnable() {
@ -412,26 +234,11 @@ public class CacheDataSource implements DataSource {
}); });
} }
/**
* Method getAccountsRegistered.
*
* @return int
*
* @see fr.xephi.authme.datasource.DataSource#getAccountsRegistered()
*/
@Override @Override
public int getAccountsRegistered() { public int getAccountsRegistered() {
return source.getAccountsRegistered(); return source.getAccountsRegistered();
} }
/**
* Method updateName.
*
* @param oldOne String
* @param newOne String
*
* @see fr.xephi.authme.datasource.DataSource#updateName(String, String)
*/
@Override @Override
public void updateName(final String oldOne, final String newOne) { public void updateName(final String oldOne, final String newOne) {
exec.execute(new Runnable() { exec.execute(new Runnable() {
@ -443,25 +250,11 @@ public class CacheDataSource implements DataSource {
}); });
} }
/**
* Method getAllAuths.
*
* @return List
*
* @see fr.xephi.authme.datasource.DataSource#getAllAuths()
*/
@Override @Override
public List<PlayerAuth> getAllAuths() { public List<PlayerAuth> getAllAuths() {
return source.getAllAuths(); return source.getAllAuths();
} }
/**
* Method getLoggedPlayers.
*
* @return List
*
* @see fr.xephi.authme.datasource.DataSource#getLoggedPlayers()
*/
@Override @Override
public List<PlayerAuth> getLoggedPlayers() { public List<PlayerAuth> getLoggedPlayers() {
return new ArrayList<>(PlayerCache.getInstance().getCache().values()); return new ArrayList<>(PlayerCache.getInstance().getCache().values());

View File

@ -70,12 +70,6 @@ public class SQLite implements DataSource {
} }
} }
/**
* Method connect.
*
* @throws ClassNotFoundException
* @throws SQLException
*/
private synchronized void connect() throws ClassNotFoundException, SQLException { private synchronized void connect() throws ClassNotFoundException, SQLException {
Class.forName("org.sqlite.JDBC"); Class.forName("org.sqlite.JDBC");
ConsoleLogger.info("SQLite driver loaded"); ConsoleLogger.info("SQLite driver loaded");
@ -83,11 +77,6 @@ public class SQLite implements DataSource {
} }
/**
* Method setup.
*
* @throws SQLException
*/
private synchronized void setup() throws SQLException { private synchronized void setup() throws SQLException {
Statement st = null; Statement st = null;
ResultSet rs = null; ResultSet rs = null;
@ -149,14 +138,6 @@ public class SQLite implements DataSource {
ConsoleLogger.info("SQLite Setup finished"); ConsoleLogger.info("SQLite Setup finished");
} }
/**
* Method isAuthAvailable.
*
* @param user String
*
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#isAuthAvailable(String)
*/
@Override @Override
public synchronized boolean isAuthAvailable(String user) { public synchronized boolean isAuthAvailable(String user) {
PreparedStatement pst = null; PreparedStatement pst = null;
@ -175,14 +156,6 @@ public class SQLite implements DataSource {
} }
} }
/**
* Method getAuth.
*
* @param user String
*
* @return PlayerAuth
* @see fr.xephi.authme.datasource.DataSource#getAuth(String)
*/
@Override @Override
public synchronized PlayerAuth getAuth(String user) { public synchronized PlayerAuth getAuth(String user) {
PreparedStatement pst = null; PreparedStatement pst = null;
@ -205,14 +178,6 @@ public class SQLite implements DataSource {
} }
} }
/**
* Method saveAuth.
*
* @param auth PlayerAuth
*
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#saveAuth(PlayerAuth)
*/
@Override @Override
public synchronized boolean saveAuth(PlayerAuth auth) { public synchronized boolean saveAuth(PlayerAuth auth) {
PreparedStatement pst = null; PreparedStatement pst = null;
@ -252,14 +217,6 @@ public class SQLite implements DataSource {
return true; return true;
} }
/**
* Method updatePassword.
*
* @param auth PlayerAuth
*
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#updatePassword(PlayerAuth)
*/
@Override @Override
public synchronized boolean updatePassword(PlayerAuth auth) { public synchronized boolean updatePassword(PlayerAuth auth) {
PreparedStatement pst = null; PreparedStatement pst = null;
@ -287,14 +244,6 @@ public class SQLite implements DataSource {
return true; return true;
} }
/**
* Method updateSession.
*
* @param auth PlayerAuth
*
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#updateSession(PlayerAuth)
*/
@Override @Override
public boolean updateSession(PlayerAuth auth) { public boolean updateSession(PlayerAuth auth) {
PreparedStatement pst = null; PreparedStatement pst = null;
@ -314,14 +263,6 @@ public class SQLite implements DataSource {
return true; return true;
} }
/**
* Method purgeDatabase.
*
* @param until long
*
* @return int
* @see fr.xephi.authme.datasource.DataSource#purgeDatabase(long)
*/
@Override @Override
public int purgeDatabase(long until) { public int purgeDatabase(long until) {
PreparedStatement pst = null; PreparedStatement pst = null;
@ -338,14 +279,6 @@ public class SQLite implements DataSource {
} }
} }
/**
* Method autoPurgeDatabase.
*
* @param until long
*
* @return List of String
* @see fr.xephi.authme.datasource.DataSource#autoPurgeDatabase(long)
*/
@Override @Override
public List<String> autoPurgeDatabase(long until) { public List<String> autoPurgeDatabase(long until) {
PreparedStatement pst = null; PreparedStatement pst = null;
@ -368,14 +301,6 @@ public class SQLite implements DataSource {
} }
} }
/**
* Method removeAuth.
*
* @param user String
*
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#removeAuth(String)
*/
@Override @Override
public synchronized boolean removeAuth(String user) { public synchronized boolean removeAuth(String user) {
PreparedStatement pst = null; PreparedStatement pst = null;
@ -392,14 +317,6 @@ public class SQLite implements DataSource {
return true; return true;
} }
/**
* Method updateQuitLoc.
*
* @param auth PlayerAuth
*
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#updateQuitLoc(PlayerAuth)
*/
@Override @Override
public boolean updateQuitLoc(PlayerAuth auth) { public boolean updateQuitLoc(PlayerAuth auth) {
PreparedStatement pst = null; PreparedStatement pst = null;
@ -420,14 +337,6 @@ public class SQLite implements DataSource {
return true; return true;
} }
/**
* Method getIps.
*
* @param ip String
*
* @return int
* @see fr.xephi.authme.datasource.DataSource#getIps(String)
*/
@Override @Override
public int getIps(String ip) { public int getIps(String ip) {
PreparedStatement pst = null; PreparedStatement pst = null;
@ -451,14 +360,6 @@ public class SQLite implements DataSource {
} }
} }
/**
* Method updateEmail.
*
* @param auth PlayerAuth
*
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#updateEmail(PlayerAuth)
*/
@Override @Override
public boolean updateEmail(PlayerAuth auth) { public boolean updateEmail(PlayerAuth auth) {
PreparedStatement pst = null; PreparedStatement pst = null;
@ -476,11 +377,6 @@ public class SQLite implements DataSource {
return true; return true;
} }
/**
* Method close.
*
* @see fr.xephi.authme.datasource.DataSource#close()
*/
@Override @Override
public synchronized void close() { public synchronized void close() {
try { try {
@ -490,20 +386,10 @@ public class SQLite implements DataSource {
} }
} }
/**
* Method reload.
*
* @see fr.xephi.authme.datasource.DataSource#reload()
*/
@Override @Override
public void reload() { public void reload() {
} }
/**
* Method close.
*
* @param st Statement
*/
private void close(Statement st) { private void close(Statement st) {
if (st != null) { if (st != null) {
try { try {
@ -514,11 +400,6 @@ public class SQLite implements DataSource {
} }
} }
/**
* Method close.
*
* @param rs ResultSet
*/
private void close(ResultSet rs) { private void close(ResultSet rs) {
if (rs != null) { if (rs != null) {
try { try {
@ -529,14 +410,6 @@ public class SQLite implements DataSource {
} }
} }
/**
* Method getAllAuthsByName.
*
* @param auth PlayerAuth
*
* @return List of String
* @see fr.xephi.authme.datasource.DataSource#getAllAuthsByName(PlayerAuth)
*/
@Override @Override
public List<String> getAllAuthsByName(PlayerAuth auth) { public List<String> getAllAuthsByName(PlayerAuth auth) {
PreparedStatement pst = null; PreparedStatement pst = null;
@ -561,14 +434,6 @@ public class SQLite implements DataSource {
} }
} }
/**
* Method getAllAuthsByIp.
*
* @param ip String
*
* @return List of String
* @see fr.xephi.authme.datasource.DataSource#getAllAuthsByIp(String)
*/
@Override @Override
public List<String> getAllAuthsByIp(String ip) { public List<String> getAllAuthsByIp(String ip) {
PreparedStatement pst = null; PreparedStatement pst = null;
@ -593,14 +458,6 @@ public class SQLite implements DataSource {
} }
} }
/**
* Method getAllAuthsByEmail.
*
* @param email String
*
* @return List of String
* @see fr.xephi.authme.datasource.DataSource#getAllAuthsByEmail(String)
*/
@Override @Override
public List<String> getAllAuthsByEmail(String email) { public List<String> getAllAuthsByEmail(String email) {
PreparedStatement pst = null; PreparedStatement pst = null;
@ -641,24 +498,11 @@ public class SQLite implements DataSource {
} }
} }
/**
* Method getType.
*
* @return DataSourceType
* @see fr.xephi.authme.datasource.DataSource#getType()
*/
@Override @Override
public DataSourceType getType() { public DataSourceType getType() {
return DataSourceType.SQLITE; return DataSourceType.SQLITE;
} }
/**
* Method isLogged.
*
* @param user String
*
* @return boolean * @see fr.xephi.authme.datasource.DataSource#isLogged(String)
*/
@Override @Override
public boolean isLogged(String user) { public boolean isLogged(String user) {
PreparedStatement pst = null; PreparedStatement pst = null;
@ -679,13 +523,6 @@ public class SQLite implements DataSource {
return false; return false;
} }
/**
* Method setLogged.
*
* @param user String
*
* @see fr.xephi.authme.datasource.DataSource#setLogged(String)
*/
@Override @Override
public void setLogged(String user) { public void setLogged(String user) {
PreparedStatement pst = null; PreparedStatement pst = null;
@ -701,13 +538,6 @@ public class SQLite implements DataSource {
} }
} }
/**
* Method setUnlogged.
*
* @param user String
*
* @see fr.xephi.authme.datasource.DataSource#setUnlogged(String)
*/
@Override @Override
public void setUnlogged(String user) { public void setUnlogged(String user) {
PreparedStatement pst = null; PreparedStatement pst = null;
@ -724,11 +554,6 @@ public class SQLite implements DataSource {
} }
} }
/**
* Method purgeLogged.
*
* @see fr.xephi.authme.datasource.DataSource#purgeLogged()
*/
@Override @Override
public void purgeLogged() { public void purgeLogged() {
PreparedStatement pst = null; PreparedStatement pst = null;
@ -744,12 +569,6 @@ public class SQLite implements DataSource {
} }
} }
/**
* Method getAccountsRegistered.
*
* @return int
* @see fr.xephi.authme.datasource.DataSource#getAccountsRegistered()
*/
@Override @Override
public int getAccountsRegistered() { public int getAccountsRegistered() {
int result = 0; int result = 0;
@ -785,11 +604,6 @@ public class SQLite implements DataSource {
} }
} }
/**
* Method getAllAuths.
*
* @return List of PlayerAuth
*/
@Override @Override
public List<PlayerAuth> getAllAuths() { public List<PlayerAuth> getAllAuths() {
List<PlayerAuth> auths = new ArrayList<>(); List<PlayerAuth> auths = new ArrayList<>();
@ -811,11 +625,6 @@ public class SQLite implements DataSource {
return auths; return auths;
} }
/**
* Method getLoggedPlayers.
*
* @return List of PlayerAuth
*/
@Override @Override
public List<PlayerAuth> getLoggedPlayers() { public List<PlayerAuth> getLoggedPlayers() {
List<PlayerAuth> auths = new ArrayList<>(); List<PlayerAuth> auths = new ArrayList<>();