From 5ec1b67e0357431fb7789201465d5709cb934919 Mon Sep 17 00:00:00 2001 From: ljacqu Date: Mon, 4 Jan 2016 21:51:28 +0100 Subject: [PATCH] Fix #408 Player quit location is not updated - Ensure that the cache data source updates the quit location on the actual source --- .../authme/datasource/CacheDataSource.java | 209 +----------------- .../fr/xephi/authme/datasource/SQLite.java | 191 ---------------- 2 files changed, 1 insertion(+), 399 deletions(-) diff --git a/src/main/java/fr/xephi/authme/datasource/CacheDataSource.java b/src/main/java/fr/xephi/authme/datasource/CacheDataSource.java index 9b346bcb..cfb17c06 100644 --- a/src/main/java/fr/xephi/authme/datasource/CacheDataSource.java +++ b/src/main/java/fr/xephi/authme/datasource/CacheDataSource.java @@ -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 public synchronized boolean isAuthAvailable(String user) { return getAuth(user) != null; } - /** - * Method getAuth. - * - * @param user String - * - * @return PlayerAuth - * - * @see fr.xephi.authme.datasource.DataSource#getAuth(String) - */ @Override public synchronized PlayerAuth getAuth(String user) { user = user.toLowerCase(); return cachedAuths.getUnchecked(user).orNull(); } - /** - * Method saveAuth. - * - * @param auth PlayerAuth - * - * @return boolean - * - * @see fr.xephi.authme.datasource.DataSource#saveAuth(PlayerAuth) - */ @Override public synchronized boolean saveAuth(PlayerAuth auth) { boolean result = source.saveAuth(auth); @@ -99,15 +72,6 @@ public class CacheDataSource implements DataSource { return result; } - /** - * Method updatePassword. - * - * @param auth PlayerAuth - * - * @return boolean - * - * @see fr.xephi.authme.datasource.DataSource#updatePassword(PlayerAuth) - */ @Override public synchronized boolean updatePassword(PlayerAuth auth) { boolean result = source.updatePassword(auth); @@ -117,15 +81,6 @@ public class CacheDataSource implements DataSource { return result; } - /** - * Method updateSession. - * - * @param auth PlayerAuth - * - * @return boolean - * - * @see fr.xephi.authme.datasource.DataSource#updateSession(PlayerAuth) - */ @Override public boolean updateSession(PlayerAuth auth) { boolean result = source.updateSession(auth); @@ -135,47 +90,20 @@ public class CacheDataSource implements DataSource { return result; } - /** - * Method updateQuitLoc. - * - * @param auth PlayerAuth - * - * @return boolean - * - * @see fr.xephi.authme.datasource.DataSource#updateQuitLoc(PlayerAuth) - */ @Override public boolean updateQuitLoc(final PlayerAuth auth) { - boolean result = source.updateSession(auth); + boolean result = source.updateQuitLoc(auth); if (result) { cachedAuths.refresh(auth.getNickname()); } return result; } - /** - * Method getIps. - * - * @param ip String - * - * @return int - * - * @see fr.xephi.authme.datasource.DataSource#getIps(String) - */ @Override public int getIps(String ip) { return source.getIps(ip); } - /** - * Method purgeDatabase. - * - * @param until long - * - * @return int - * - * @see fr.xephi.authme.datasource.DataSource#purgeDatabase(long) - */ @Override public int purgeDatabase(long until) { int cleared = source.purgeDatabase(until); @@ -189,15 +117,6 @@ public class CacheDataSource implements DataSource { return cleared; } - /** - * Method autoPurgeDatabase. - * - * @param until long - * - * @return List - * - * @see fr.xephi.authme.datasource.DataSource#autoPurgeDatabase(long) - */ @Override public List autoPurgeDatabase(long until) { List cleared = source.autoPurgeDatabase(until); @@ -207,15 +126,6 @@ public class CacheDataSource implements DataSource { return cleared; } - /** - * Method removeAuth. - * - * @param name String - * - * @return boolean - * - * @see fr.xephi.authme.datasource.DataSource#removeAuth(String) - */ @Override public synchronized boolean removeAuth(String name) { name = name.toLowerCase(); @@ -226,11 +136,6 @@ public class CacheDataSource implements DataSource { return result; } - /** - * Method close. - * - * @see fr.xephi.authme.datasource.DataSource#close() - */ @Override public synchronized void close() { try { @@ -242,11 +147,6 @@ public class CacheDataSource implements DataSource { source.close(); } - /** - * Method reload. - * - * @see fr.xephi.authme.datasource.DataSource#reload() - */ @Override public void reload() { // unused method 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 public synchronized boolean updateEmail(final PlayerAuth auth) { boolean result = source.updateEmail(auth); @@ -276,55 +167,21 @@ public class CacheDataSource implements DataSource { return result; } - /** - * Method getAllAuthsByName. - * - * @param auth PlayerAuth - * - * @return List - * - * @see fr.xephi.authme.datasource.DataSource#getAllAuthsByName(PlayerAuth) - */ @Override public synchronized List getAllAuthsByName(PlayerAuth auth) { return source.getAllAuthsByName(auth); } - /** - * Method getAllAuthsByIp. - * - * @param ip String - * - * @return List - * - * @see fr.xephi.authme.datasource.DataSource#getAllAuthsByIp(String) - */ @Override public synchronized List getAllAuthsByIp(final String ip) { return source.getAllAuthsByIp(ip); } - /** - * Method getAllAuthsByEmail. - * - * @param email String - * - * @return List - * - * @see fr.xephi.authme.datasource.DataSource#getAllAuthsByEmail(String) - */ @Override public synchronized List getAllAuthsByEmail(final String email) { return source.getAllAuthsByEmail(email); } - /** - * Method purgeBanned. - * - * @param banned List of String - * - * @see fr.xephi.authme.datasource.DataSource#purgeBanned(List) - */ @Override public synchronized void purgeBanned(final List banned) { 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 public DataSourceType getType() { return source.getType(); } - /** - * Method isLogged. - * - * @param user String - * - * @return boolean - * - * @see fr.xephi.authme.datasource.DataSource#isLogged(String) - */ @Override public boolean isLogged(String user) { return PlayerCache.getInstance().isAuthenticated(user); } - /** - * Method setLogged. - * - * @param user String - * - * @see fr.xephi.authme.datasource.DataSource#setLogged(String) - */ @Override public void setLogged(final String user) { 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 public void setUnlogged(final String user) { exec.execute(new Runnable() { @@ -396,11 +223,6 @@ public class CacheDataSource implements DataSource { }); } - /** - * Method purgeLogged. - * - * @see fr.xephi.authme.datasource.DataSource#purgeLogged() - */ @Override public void purgeLogged() { 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 public int getAccountsRegistered() { return source.getAccountsRegistered(); } - /** - * Method updateName. - * - * @param oldOne String - * @param newOne String - * - * @see fr.xephi.authme.datasource.DataSource#updateName(String, String) - */ @Override public void updateName(final String oldOne, final String newOne) { 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 public List getAllAuths() { return source.getAllAuths(); } - /** - * Method getLoggedPlayers. - * - * @return List - * - * @see fr.xephi.authme.datasource.DataSource#getLoggedPlayers() - */ @Override public List getLoggedPlayers() { return new ArrayList<>(PlayerCache.getInstance().getCache().values()); diff --git a/src/main/java/fr/xephi/authme/datasource/SQLite.java b/src/main/java/fr/xephi/authme/datasource/SQLite.java index e068daf8..a04bb7f9 100644 --- a/src/main/java/fr/xephi/authme/datasource/SQLite.java +++ b/src/main/java/fr/xephi/authme/datasource/SQLite.java @@ -70,12 +70,6 @@ public class SQLite implements DataSource { } } - /** - * Method connect. - * - * @throws ClassNotFoundException - * @throws SQLException - */ private synchronized void connect() throws ClassNotFoundException, SQLException { Class.forName("org.sqlite.JDBC"); ConsoleLogger.info("SQLite driver loaded"); @@ -83,11 +77,6 @@ public class SQLite implements DataSource { } - /** - * Method setup. - * - * @throws SQLException - */ private synchronized void setup() throws SQLException { Statement st = null; ResultSet rs = null; @@ -149,14 +138,6 @@ public class SQLite implements DataSource { ConsoleLogger.info("SQLite Setup finished"); } - /** - * Method isAuthAvailable. - * - * @param user String - * - * @return boolean - * @see fr.xephi.authme.datasource.DataSource#isAuthAvailable(String) - */ @Override public synchronized boolean isAuthAvailable(String user) { 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 public synchronized PlayerAuth getAuth(String user) { 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 public synchronized boolean saveAuth(PlayerAuth auth) { PreparedStatement pst = null; @@ -252,14 +217,6 @@ public class SQLite implements DataSource { return true; } - /** - * Method updatePassword. - * - * @param auth PlayerAuth - * - * @return boolean - * @see fr.xephi.authme.datasource.DataSource#updatePassword(PlayerAuth) - */ @Override public synchronized boolean updatePassword(PlayerAuth auth) { PreparedStatement pst = null; @@ -287,14 +244,6 @@ public class SQLite implements DataSource { return true; } - /** - * Method updateSession. - * - * @param auth PlayerAuth - * - * @return boolean - * @see fr.xephi.authme.datasource.DataSource#updateSession(PlayerAuth) - */ @Override public boolean updateSession(PlayerAuth auth) { PreparedStatement pst = null; @@ -314,14 +263,6 @@ public class SQLite implements DataSource { return true; } - /** - * Method purgeDatabase. - * - * @param until long - * - * @return int - * @see fr.xephi.authme.datasource.DataSource#purgeDatabase(long) - */ @Override public int purgeDatabase(long until) { 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 public List autoPurgeDatabase(long until) { 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 public synchronized boolean removeAuth(String user) { PreparedStatement pst = null; @@ -392,14 +317,6 @@ public class SQLite implements DataSource { return true; } - /** - * Method updateQuitLoc. - * - * @param auth PlayerAuth - * - * @return boolean - * @see fr.xephi.authme.datasource.DataSource#updateQuitLoc(PlayerAuth) - */ @Override public boolean updateQuitLoc(PlayerAuth auth) { PreparedStatement pst = null; @@ -420,14 +337,6 @@ public class SQLite implements DataSource { return true; } - /** - * Method getIps. - * - * @param ip String - * - * @return int - * @see fr.xephi.authme.datasource.DataSource#getIps(String) - */ @Override public int getIps(String ip) { 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 public boolean updateEmail(PlayerAuth auth) { PreparedStatement pst = null; @@ -476,11 +377,6 @@ public class SQLite implements DataSource { return true; } - /** - * Method close. - * - * @see fr.xephi.authme.datasource.DataSource#close() - */ @Override public synchronized void close() { try { @@ -490,20 +386,10 @@ public class SQLite implements DataSource { } } - /** - * Method reload. - * - * @see fr.xephi.authme.datasource.DataSource#reload() - */ @Override public void reload() { } - /** - * Method close. - * - * @param st Statement - */ private void close(Statement st) { if (st != null) { try { @@ -514,11 +400,6 @@ public class SQLite implements DataSource { } } - /** - * Method close. - * - * @param rs ResultSet - */ private void close(ResultSet rs) { if (rs != null) { 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 public List getAllAuthsByName(PlayerAuth auth) { 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 public List getAllAuthsByIp(String ip) { 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 public List getAllAuthsByEmail(String email) { PreparedStatement pst = null; @@ -641,24 +498,11 @@ public class SQLite implements DataSource { } } - /** - * Method getType. - * - * @return DataSourceType - * @see fr.xephi.authme.datasource.DataSource#getType() - */ @Override public DataSourceType getType() { return DataSourceType.SQLITE; } - /** - * Method isLogged. - * - * @param user String - * - * @return boolean * @see fr.xephi.authme.datasource.DataSource#isLogged(String) - */ @Override public boolean isLogged(String user) { PreparedStatement pst = null; @@ -679,13 +523,6 @@ public class SQLite implements DataSource { return false; } - /** - * Method setLogged. - * - * @param user String - * - * @see fr.xephi.authme.datasource.DataSource#setLogged(String) - */ @Override public void setLogged(String user) { 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 public void setUnlogged(String user) { PreparedStatement pst = null; @@ -724,11 +554,6 @@ public class SQLite implements DataSource { } } - /** - * Method purgeLogged. - * - * @see fr.xephi.authme.datasource.DataSource#purgeLogged() - */ @Override public void purgeLogged() { PreparedStatement pst = null; @@ -744,12 +569,6 @@ public class SQLite implements DataSource { } } - /** - * Method getAccountsRegistered. - * - * @return int - * @see fr.xephi.authme.datasource.DataSource#getAccountsRegistered() - */ @Override public int getAccountsRegistered() { int result = 0; @@ -785,11 +604,6 @@ public class SQLite implements DataSource { } } - /** - * Method getAllAuths. - * - * @return List of PlayerAuth - */ @Override public List getAllAuths() { List auths = new ArrayList<>(); @@ -811,11 +625,6 @@ public class SQLite implements DataSource { return auths; } - /** - * Method getLoggedPlayers. - * - * @return List of PlayerAuth - */ @Override public List getLoggedPlayers() { List auths = new ArrayList<>();