From 9d950b9b4a7d3c6f1cd02e26017676acace4b0a4 Mon Sep 17 00:00:00 2001 From: Xephi59 Date: Thu, 20 Aug 2015 18:39:40 +0200 Subject: [PATCH 01/14] Potential NPE --- .../xephi/authme/process/quit/AsyncronousQuit.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main/java/fr/xephi/authme/process/quit/AsyncronousQuit.java b/src/main/java/fr/xephi/authme/process/quit/AsyncronousQuit.java index 585ab6fa..40a71247 100644 --- a/src/main/java/fr/xephi/authme/process/quit/AsyncronousQuit.java +++ b/src/main/java/fr/xephi/authme/process/quit/AsyncronousQuit.java @@ -21,7 +21,7 @@ public class AsyncronousQuit { protected AuthMe plugin; protected DataSource database; - protected Player p; + protected Player player; protected Utils utils = Utils.getInstance(); private String name; private ItemStack[] armor = null; @@ -33,7 +33,7 @@ public class AsyncronousQuit { public AsyncronousQuit(Player p, AuthMe plugin, DataSource database, boolean isKick) { - this.p = p; + this.player = p; this.plugin = plugin; this.database = database; this.name = p.getName().toLowerCase(); @@ -41,7 +41,8 @@ public class AsyncronousQuit { } public void process() { - final Player player = p; + if (player == null) + return; if (plugin.getCitizensCommunicator().isNPC(player) || Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) { return; } @@ -64,7 +65,8 @@ public class AsyncronousQuit { inv = limbo.getInventory(); armor = limbo.getArmour(); } - utils.addNormal(player, limbo.getGroup()); + if (limbo.getGroup() != null && !limbo.getGroup().equals("")) + utils.addNormal(player, limbo.getGroup()); needToChange = true; isOp = limbo.getOperator(); isFlying = limbo.isFlying(); @@ -94,6 +96,7 @@ public class AsyncronousQuit { database.setUnlogged(name); } AuthMePlayerListener.gameMode.remove(name); - Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new ProcessSyncronousPlayerQuit(plugin, player, inv, armor, isOp, isFlying, needToChange)); + final Player p = player; + Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new ProcessSyncronousPlayerQuit(plugin, p, inv, armor, isOp, isFlying, needToChange)); } } From b84d96360e83c8e44a6d6d1f54e0c243bb421735 Mon Sep 17 00:00:00 2001 From: Xephi59 Date: Thu, 20 Aug 2015 18:49:22 +0200 Subject: [PATCH 02/14] TEMP FIX - Catch all Exception instance due to HikariCP thrown --- .../fr/xephi/authme/datasource/MySQL.java | 56 +++++++++---------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/src/main/java/fr/xephi/authme/datasource/MySQL.java b/src/main/java/fr/xephi/authme/datasource/MySQL.java index 9509192d..201e6f14 100644 --- a/src/main/java/fr/xephi/authme/datasource/MySQL.java +++ b/src/main/java/fr/xephi/authme/datasource/MySQL.java @@ -196,7 +196,7 @@ public class MySQL implements DataSource { pst.setString(1, user); rs = pst.executeQuery(); return rs.next(); - } catch (SQLException ex) { + } catch (Exception ex) { ConsoleLogger.showError(ex.getMessage()); return false; } finally { @@ -246,7 +246,7 @@ public class MySQL implements DataSource { } else { return null; } - } catch (SQLException ex) { + } catch (Exception ex) { ConsoleLogger.showError(ex.getMessage()); return null; } finally { @@ -456,7 +456,7 @@ public class MySQL implements DataSource { if (rs != null && !rs.isClosed()) rs.close(); } - } catch (SQLException ex) { + } catch (Exception ex) { ConsoleLogger.showError(ex.getMessage()); return false; } finally { @@ -501,7 +501,7 @@ public class MySQL implements DataSource { if (rs != null && !rs.isClosed()) rs.close(); } - } catch (SQLException ex) { + } catch (Exception ex) { ConsoleLogger.showError(ex.getMessage()); return false; } finally { @@ -523,7 +523,7 @@ public class MySQL implements DataSource { pst.setString(3, auth.getRealName()); pst.setString(4, auth.getNickname()); pst.executeUpdate(); - } catch (SQLException ex) { + } catch (Exception ex) { ConsoleLogger.showError(ex.getMessage()); return false; } finally { @@ -542,7 +542,7 @@ public class MySQL implements DataSource { pst = con.prepareStatement("DELETE FROM " + tableName + " WHERE " + columnLastLogin + "(); } finally { @@ -606,7 +606,7 @@ public class MySQL implements DataSource { pst = con.prepareStatement("DELETE FROM " + tableName + " WHERE LOWER(" + columnName + ")=?;"); pst.setString(1, user); pst.executeUpdate(); - } catch (SQLException ex) { + } catch (Exception ex) { ConsoleLogger.showError(ex.getMessage()); return false; } finally { @@ -629,7 +629,7 @@ public class MySQL implements DataSource { pst.setString(4, auth.getWorld()); pst.setString(5, auth.getNickname()); pst.executeUpdate(); - } catch (SQLException ex) { + } catch (Exception ex) { ConsoleLogger.showError(ex.getMessage()); return false; } finally { @@ -654,7 +654,7 @@ public class MySQL implements DataSource { countIp++; } return countIp; - } catch (SQLException ex) { + } catch (Exception ex) { ConsoleLogger.showError(ex.getMessage()); return 0; } finally { @@ -674,7 +674,7 @@ public class MySQL implements DataSource { pst.setString(1, auth.getEmail()); pst.setString(2, auth.getNickname()); pst.executeUpdate(); - } catch (SQLException ex) { + } catch (Exception ex) { ConsoleLogger.showError(ex.getMessage()); return false; } finally { @@ -697,7 +697,7 @@ public class MySQL implements DataSource { pst.setString(1, auth.getSalt()); pst.setString(2, auth.getNickname()); pst.executeUpdate(); - } catch (SQLException ex) { + } catch (Exception ex) { ConsoleLogger.showError(ex.getMessage()); return false; } finally { @@ -732,7 +732,7 @@ public class MySQL implements DataSource { if (st != null) { try { st.close(); - } catch (SQLException ex) { + } catch (Exception ex) { ConsoleLogger.showError(ex.getMessage()); } } @@ -742,7 +742,7 @@ public class MySQL implements DataSource { if (rs != null) { try { rs.close(); - } catch (SQLException ex) { + } catch (Exception ex) { ConsoleLogger.showError(ex.getMessage()); } } @@ -752,7 +752,7 @@ public class MySQL implements DataSource { if (con != null) { try { con.close(); - } catch (SQLException ex) { + } catch (Exception ex) { ConsoleLogger.showError(ex.getMessage()); } } @@ -773,7 +773,7 @@ public class MySQL implements DataSource { countIp.add(rs.getString(columnName)); } return countIp; - } catch (SQLException ex) { + } catch (Exception ex) { ConsoleLogger.showError(ex.getMessage()); return new ArrayList(); } finally { @@ -798,7 +798,7 @@ public class MySQL implements DataSource { countIp.add(rs.getString(columnName)); } return countIp; - } catch (SQLException ex) { + } catch (Exception ex) { ConsoleLogger.showError(ex.getMessage()); return new ArrayList(); } finally { @@ -823,7 +823,7 @@ public class MySQL implements DataSource { countEmail.add(rs.getString(columnName)); } return countEmail; - } catch (SQLException ex) { + } catch (Exception ex) { ConsoleLogger.showError(ex.getMessage()); return new ArrayList(); } finally { @@ -844,7 +844,7 @@ public class MySQL implements DataSource { pst.setString(1, name); pst.executeUpdate(); } - } catch (SQLException ex) { + } catch (Exception ex) { ConsoleLogger.showError(ex.getMessage()); } finally { close(pst); @@ -890,7 +890,7 @@ public class MySQL implements DataSource { while (con == null) try { con = ds.getConnection(); - } catch (SQLException e) { + } catch (Exception e) { try { reconnect(false); con = ds.getConnection(); @@ -937,7 +937,7 @@ public class MySQL implements DataSource { rs = pst.executeQuery(); if (rs.next()) return (rs.getInt(columnLogged) == 1); - } catch (SQLException ex) { + } catch (Exception ex) { ConsoleLogger.showError(ex.getMessage()); return false; } finally { @@ -958,7 +958,7 @@ public class MySQL implements DataSource { pst.setInt(1, 1); pst.setString(2, user); pst.executeUpdate(); - } catch (SQLException ex) { + } catch (Exception ex) { ConsoleLogger.showError(ex.getMessage()); return; } finally { @@ -979,7 +979,7 @@ public class MySQL implements DataSource { pst.setInt(1, 0); pst.setString(2, user); pst.executeUpdate(); - } catch (SQLException ex) { + } catch (Exception ex) { ConsoleLogger.showError(ex.getMessage()); return; } finally { @@ -999,7 +999,7 @@ public class MySQL implements DataSource { pst.setInt(1, 0); pst.setInt(2, 1); pst.executeUpdate(); - } catch (SQLException ex) { + } catch (Exception ex) { ConsoleLogger.showError(ex.getMessage()); return; } finally { @@ -1022,7 +1022,7 @@ public class MySQL implements DataSource { if (rs != null && rs.next()) { result = rs.getInt(1); } - } catch (SQLException ex) { + } catch (Exception ex) { ConsoleLogger.showError(ex.getMessage()); return result; } finally { @@ -1042,7 +1042,7 @@ public class MySQL implements DataSource { pst.setString(1, newone); pst.setString(2, oldone); pst.executeUpdate(); - } catch (SQLException ex) { + } catch (Exception ex) { ConsoleLogger.showError(ex.getMessage()); return; } finally { @@ -1092,7 +1092,7 @@ public class MySQL implements DataSource { if (pAuth != null) auths.add(pAuth); } - } catch (SQLException ex) { + } catch (Exception ex) { ConsoleLogger.showError(ex.getMessage()); return auths; } finally { @@ -1143,7 +1143,7 @@ public class MySQL implements DataSource { if (pAuth != null) auths.add(pAuth); } - } catch (SQLException ex) { + } catch (Exception ex) { ConsoleLogger.showError(ex.getMessage()); return auths; } finally { From 86e1b8df7c1c4dc3b6387065fb79e81da11a75fb Mon Sep 17 00:00:00 2001 From: Xephi59 Date: Thu, 20 Aug 2015 18:59:41 +0200 Subject: [PATCH 03/14] Define a max life time of a pool --- src/main/java/fr/xephi/authme/datasource/MySQL.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/fr/xephi/authme/datasource/MySQL.java b/src/main/java/fr/xephi/authme/datasource/MySQL.java index 201e6f14..45c9c651 100644 --- a/src/main/java/fr/xephi/authme/datasource/MySQL.java +++ b/src/main/java/fr/xephi/authme/datasource/MySQL.java @@ -121,6 +121,7 @@ public class MySQL implements DataSource { config.addDataSourceProperty("prepStmtCacheSize", "250"); config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048"); config.addDataSourceProperty("autoReconnect", true); + config.setMaxLifetime(12000); config.setInitializationFailFast(false); ds = new HikariDataSource(config); ConsoleLogger.info("Connection pool ready"); @@ -914,6 +915,7 @@ public class MySQL implements DataSource { config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048"); config.addDataSourceProperty("autoReconnect", true); config.setInitializationFailFast(false); + config.setMaxLifetime(12000); config.setPoolName("AuthMeMYSQLPool"); ds = new HikariDataSource(config); if (!reload) From e1eb22239ac934fa024770c175b39c0698a1d22d Mon Sep 17 00:00:00 2001 From: Xephi59 Date: Thu, 20 Aug 2015 23:29:02 +0200 Subject: [PATCH 04/14] Add Third Party PreLogin Event --- .../events/AuthMeAsyncPreLoginEvent.java | 41 +++++++++++++++++++ .../process/login/AsyncronousLogin.java | 5 +++ 2 files changed, 46 insertions(+) create mode 100644 src/main/java/fr/xephi/authme/events/AuthMeAsyncPreLoginEvent.java diff --git a/src/main/java/fr/xephi/authme/events/AuthMeAsyncPreLoginEvent.java b/src/main/java/fr/xephi/authme/events/AuthMeAsyncPreLoginEvent.java new file mode 100644 index 00000000..d93b2114 --- /dev/null +++ b/src/main/java/fr/xephi/authme/events/AuthMeAsyncPreLoginEvent.java @@ -0,0 +1,41 @@ +package fr.xephi.authme.events; + +import org.bukkit.entity.Player; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +/** + * + * This event is call when AuthMe try to teleport a player + * + * @author Xephi59 + */ +public class AuthMeAsyncPreLoginEvent extends Event { + + private Player player; + private boolean canLogin = true; + private static final HandlerList handlers = new HandlerList(); + + public AuthMeAsyncPreLoginEvent(Player player) { + super(true); + this.player = player; + } + + public Player getPlayer() { + return player; + } + + public boolean canLogin() { + return canLogin; + } + + public void setCanLogin(boolean canLogin) { + this.canLogin = canLogin; + } + + @Override + public HandlerList getHandlers() { + return handlers; + } + +} diff --git a/src/main/java/fr/xephi/authme/process/login/AsyncronousLogin.java b/src/main/java/fr/xephi/authme/process/login/AsyncronousLogin.java index e7c49af8..302203b7 100644 --- a/src/main/java/fr/xephi/authme/process/login/AsyncronousLogin.java +++ b/src/main/java/fr/xephi/authme/process/login/AsyncronousLogin.java @@ -13,6 +13,7 @@ import fr.xephi.authme.cache.auth.PlayerAuth; import fr.xephi.authme.cache.auth.PlayerCache; import fr.xephi.authme.cache.limbo.LimboCache; import fr.xephi.authme.datasource.DataSource; +import fr.xephi.authme.events.AuthMeAsyncPreLoginEvent; import fr.xephi.authme.listener.AuthMePlayerListener; import fr.xephi.authme.security.PasswordSecurity; import fr.xephi.authme.security.RandomString; @@ -113,6 +114,10 @@ public class AsyncronousLogin { m.send(player, "vb_nonActiv"); return null; } + AuthMeAsyncPreLoginEvent event = new AuthMeAsyncPreLoginEvent(player); + Bukkit.getServer().getPluginManager().callEvent(event); + if (!event.canLogin()) + return null; return pAuth; } From cd0659ac894a1775b5041de0a8561f86c266b412 Mon Sep 17 00:00:00 2001 From: Xephi59 Date: Thu, 20 Aug 2015 23:30:31 +0200 Subject: [PATCH 05/14] ahah copy/paste spotted :D --- .../java/fr/xephi/authme/events/AuthMeAsyncPreLoginEvent.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/fr/xephi/authme/events/AuthMeAsyncPreLoginEvent.java b/src/main/java/fr/xephi/authme/events/AuthMeAsyncPreLoginEvent.java index d93b2114..1995fbd0 100644 --- a/src/main/java/fr/xephi/authme/events/AuthMeAsyncPreLoginEvent.java +++ b/src/main/java/fr/xephi/authme/events/AuthMeAsyncPreLoginEvent.java @@ -6,7 +6,7 @@ import org.bukkit.event.HandlerList; /** * - * This event is call when AuthMe try to teleport a player + * This event is call when a player try to /login * * @author Xephi59 */ From c7a711d0b2b20e825d273d78433af44441860f74 Mon Sep 17 00:00:00 2001 From: Xephi59 Date: Sat, 22 Aug 2015 15:30:17 +0200 Subject: [PATCH 06/14] Add Try/catch to DataSource close --- src/main/java/fr/xephi/authme/datasource/MySQL.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/fr/xephi/authme/datasource/MySQL.java b/src/main/java/fr/xephi/authme/datasource/MySQL.java index 45c9c651..8803c874 100644 --- a/src/main/java/fr/xephi/authme/datasource/MySQL.java +++ b/src/main/java/fr/xephi/authme/datasource/MySQL.java @@ -710,8 +710,11 @@ public class MySQL implements DataSource { @Override public synchronized void close() { - if (ds != null) - ds.close(); + try { + if (ds != null) + ds.close(); + } catch (Exception e) { + } } @Override From be3cdaba88fc5244a4362f26e95dc9661bfd8958 Mon Sep 17 00:00:00 2001 From: Alexandre Vanhecke Date: Mon, 24 Aug 2015 12:09:54 +0200 Subject: [PATCH 07/14] Update pom.xml --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 2eab1959..c5f2e8f6 100644 --- a/pom.xml +++ b/pom.xml @@ -180,7 +180,7 @@ com.zaxxer HikariCP - 2.4.0 + 2.4.1 compile From fa6e048c21a79dec518e7aaeef4a298108dfe291 Mon Sep 17 00:00:00 2001 From: Xephi59 Date: Wed, 26 Aug 2015 18:55:33 +0200 Subject: [PATCH 08/14] Fix DriverClassName not properly set --- pom.xml | 1059 +++++++++-------- .../fr/xephi/authme/datasource/MySQL.java | 1 + 2 files changed, 533 insertions(+), 527 deletions(-) diff --git a/pom.xml b/pom.xml index 2eab1959..409c7307 100644 --- a/pom.xml +++ b/pom.xml @@ -1,571 +1,576 @@ - 4.0.0 + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 - fr.xephi - authme - 5.0-SNAPSHOT + fr.xephi + authme + 5.0-SNAPSHOT - AuthMeReloaded - Authentication plugin for CraftBukkit/Spigot! - 2013 - http://dev.bukkit.org/bukkit-plugins/authme-reloaded/ - + AuthMeReloaded + Authentication plugin for CraftBukkit/Spigot! + 2013 + http://dev.bukkit.org/bukkit-plugins/authme-reloaded/ + - - scm:git:https://github.com/Xephi/AuthMeReloaded.git - scm:git:git@github.com:Xephi/AuthMeReloaded.git - http://github.com/Xephi/AuthMeReloaded - + + scm:git:https://github.com/Xephi/AuthMeReloaded.git + scm:git:git@github.com:Xephi/AuthMeReloaded.git + http://github.com/Xephi/AuthMeReloaded + - - - jenkins - http://ci.xephi.fr/job/AuthMeReloaded/ - + + + jenkins + http://ci.xephi.fr/job/AuthMeReloaded/ + - - GitHub - https://github.com/Xephi/AuthMeReloaded/issues - + + GitHub + https://github.com/Xephi/AuthMeReloaded/issues + - - - The GNU General Public Licence version 3 (GPLv3) - http://www.gnu.org/licenses/gpl-3.0.html - - + + + The GNU General Public Licence version 3 (GPLv3) + http://www.gnu.org/licenses/gpl-3.0.html + + - - UTF-8 - - 1.7 - - 1.8.8-R0.1-SNAPSHOT - + + UTF-8 + + 1.7 + + 1.8.8-R0.1-SNAPSHOT + - - AuthMe-${project.version} - - - . - true - ${basedir}/src/main/resources/ - - *.yml - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.3 - - 1.7 - ${javaVersion} - - - - org.apache.maven.plugins - maven-shade-plugin - 2.4.1 - - - - com.maxmind.geoip:* - javax.mail:* - com.sun.mail:* - com.comphenix.attribute:* - org.mcstats.*:* - com.zaxxer:* - org.slf4j:* - - - - - org.mcstats - fr.xephi.authme - - - - - - package - - shade - - - - - - + + AuthMe-${project.version} + + + . + true + ${basedir}/src/main/resources/ + + *.yml + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.3 + + 1.7 + ${javaVersion} + + + + org.apache.maven.plugins + maven-shade-plugin + 2.4.1 + + + + com.maxmind.geoip:* + javax.mail:* + com.sun.mail:* + com.comphenix.attribute:* + org.mcstats.*:* + com.zaxxer:* + org.slf4j:* + + + + + org.mcstats + fr.xephi.authme + + + + + + package + + shade + + + + + + - + - - - spigot-repo - https://hub.spigotmc.org/nexus/content/groups/public - + + + spigot-repo + https://hub.spigotmc.org/nexus/content/groups/public + - - - ess-repo - https://ci.drtshock.net/plugin/repository/everything - + + + ess-repo + https://ci.drtshock.net/plugin/repository/everything + - - - citizensapi-repo - http://ci.citizensnpcs.co/plugin/repository/project/CitizensAPI/LastSuccessful/repository - + + + citizensapi-repo + http://ci.citizensnpcs.co/plugin/repository/project/CitizensAPI/LastSuccessful/repository + - - - minelink-thirdparty - http://repo.minelink.net/content/repositories/public - + + + minelink-thirdparty + http://repo.minelink.net/content/repositories/public + - - - comphenix-snapshots - http://repo.comphenix.net/content/repositories/public - + + + comphenix-snapshots + http://repo.comphenix.net/content/repositories/public + - - - onarandombox - http://repo.onarandombox.com/content/groups/public - + + + onarandombox + http://repo.onarandombox.com/content/groups/public + - - - vault-repo - http://nexus.theyeticave.net/content/repositories/pub_releases - + + + vault-repo + http://nexus.theyeticave.net/content/repositories/pub_releases + - - - luricos-releases - http://repo.luricos.de/content/repositories/releases - + + + luricos-releases + http://repo.luricos.de/content/repositories/releases + - - - xephi-repo - http://ci.xephi.fr/plugin/repository/everything/ - + + + xephi-repo + http://ci.xephi.fr/plugin/repository/everything/ + - - - mcstats-snapshots - http://repo.mcstats.org/content/repositories/snapshots/ - + + + mcstats-snapshots + http://repo.mcstats.org/content/repositories/snapshots/ + - + - + - + - - - org.slf4j - slf4j-simple - 1.7.12 - compile - - - com.zaxxer - HikariCP - 2.4.0 - compile - - - org.slf4j - slf4j-api - - - org.slf4j - slf4j-simple - - - + + + mysql + mysql-connector-java + 5.1.36 + + + org.slf4j + slf4j-simple + 1.7.12 + compile + + + com.zaxxer + HikariCP + 2.4.0 + compile + + + org.slf4j + slf4j-api + + + org.slf4j + slf4j-simple + + + - - - org.xerial - sqlite-jdbc - 3.8.11.1 - compile - + + + org.xerial + sqlite-jdbc + 3.8.11.1 + compile + - - - com.sun.mail - javax.mail - 1.5.4 - compile - + + + com.sun.mail + javax.mail + 1.5.4 + compile + - - - com.maxmind.geoip - geoip-api - 1.2.15 - compile - + + + com.maxmind.geoip + geoip-api + 1.2.15 + compile + - - - org.mcstats.bukkit - metrics - R8-SNAPSHOT - compile - - - org.bukkit - bukkit - - - + + + org.mcstats.bukkit + metrics + R8-SNAPSHOT + compile + + + org.bukkit + bukkit + + + - - - org.bukkit - bukkit - ${bukkitVersion} - provided - + + + org.bukkit + bukkit + ${bukkitVersion} + provided + - - - com.comphenix.attribute - AttributeStorage - 0.0.2-SNAPSHOT - compile - - - org.bukkit - bukkit - - - org.bukkit - craftbukkit - - - + + + com.comphenix.attribute + AttributeStorage + 0.0.2-SNAPSHOT + compile + + + org.bukkit + bukkit + + + org.bukkit + craftbukkit + + + - - - net.milkbowl.vault - VaultAPI - 1.5 - provided - - - org.bukkit - bukkit - - - org.bukkit - craftbukkit - - - + + + net.milkbowl.vault + VaultAPI + 1.5 + provided + + + org.bukkit + bukkit + + + org.bukkit + craftbukkit + + + - - - net.citizensnpcs - citizensapi - 2.0.16-SNAPSHOT - provided - - - org.bukkit - bukkit - - - org.bukkit - craftbukkit - - - + + + net.citizensnpcs + citizensapi + 2.0.16-SNAPSHOT + provided + + + org.bukkit + bukkit + + + org.bukkit + craftbukkit + + + - - - com.onarandombox.multiversecore - Multiverse-Core - 2.5 - jar - provided - - - org.bukkit - bukkit - - - org.bukkit - craftbukkit - - - AllPay - com.fernferret.allpay - - - Vault - net.milkbowl.vault - - - CommandHandler - com.pneumaticraft.commandhandler - - - + + + com.onarandombox.multiversecore + Multiverse-Core + 2.5 + jar + provided + + + org.bukkit + bukkit + + + org.bukkit + craftbukkit + + + AllPay + com.fernferret.allpay + + + Vault + net.milkbowl.vault + + + CommandHandler + com.pneumaticraft.commandhandler + + + - - - net.ess3 - EssentialsX - 2.0.1-SNAPSHOT - provided - - - org.spigotmc - spigot-api - - - + + + net.ess3 + EssentialsX + 2.0.1-SNAPSHOT + provided + + + org.spigotmc + spigot-api + + + - - - net.minelink - CombatTagPlus - 1.2.1-SNAPSHOT - provided - - - org.bukkit - bukkit - - - org.bukkit - craftbukkit - - - CombatTagPlusHook - net.minelink - - - CombatTagPlusFactions-v1_6 - net.minelink - - - CombatTagPlusCompat-v1_7_R3 - net.minelink - - - CombatTagPlusFactions-v1_8 - net.minelink - - - CombatTagPlusCompat-v1_7_R4 - net.minelink - - - CombatTagPlusWG-v5 - net.minelink - - - CombatTagPlusWG-v6 - net.minelink - - - CombatTagPlusCompat-API - net.minelink - - - CombatTagPlusFactions-v2_6 - net.minelink - - - CombatTagPlusCompat-v1_8_R3 - net.minelink - - - CombatTagPlusFactions-v2_7 - net.minelink - - - CombatTagPlusCompat-v1_8_R2 - net.minelink - - - CombatTagPlusCompat-v1_8_R1 - net.minelink - - - metrics-lite - org.mcstats.bukkit - - - + + + net.minelink + CombatTagPlus + 1.2.1-SNAPSHOT + provided + + + org.bukkit + bukkit + + + org.bukkit + craftbukkit + + + CombatTagPlusHook + net.minelink + + + CombatTagPlusFactions-v1_6 + net.minelink + + + CombatTagPlusCompat-v1_7_R3 + net.minelink + + + CombatTagPlusFactions-v1_8 + net.minelink + + + CombatTagPlusCompat-v1_7_R4 + net.minelink + + + CombatTagPlusWG-v5 + net.minelink + + + CombatTagPlusWG-v6 + net.minelink + + + CombatTagPlusCompat-API + net.minelink + + + CombatTagPlusFactions-v2_6 + net.minelink + + + CombatTagPlusCompat-v1_8_R3 + net.minelink + + + CombatTagPlusFactions-v2_7 + net.minelink + + + CombatTagPlusCompat-v1_8_R2 + net.minelink + + + CombatTagPlusCompat-v1_8_R1 + net.minelink + + + metrics-lite + org.mcstats.bukkit + + + - - - com.trc202 - CombatTag - 6.2.1-SNAPSHOT - provided - - - org.bukkit - bukkit - - - org.bukkit - craftbukkit - - - + + + com.trc202 + CombatTag + 6.2.1-SNAPSHOT + provided + + + org.bukkit + bukkit + + + org.bukkit + craftbukkit + + + - - - de.luricos.bukkit - xAuth - 2.6 - provided - - - org.bukkit - bukkit - - - org.bukkit - craftbukkit - - - updater - net.gravitydevelopment.updater - - - lombok - org.projectlombok - - - EssentialsGroupManager - net.ess3 - - - PermissionsEx - ru.tehkode - - - AccountsClient - com.mojang - - - + + + de.luricos.bukkit + xAuth + 2.6 + provided + + + org.bukkit + bukkit + + + org.bukkit + craftbukkit + + + updater + net.gravitydevelopment.updater + + + lombok + org.projectlombok + + + EssentialsGroupManager + net.ess3 + + + PermissionsEx + ru.tehkode + + + AccountsClient + com.mojang + + + - - - com.acrobot.chestshop - chestshop - 3.8.12 - provided - - - org.bukkit - bukkit - - - org.bukkit - craftbukkit - - - Vault - net.milkbowl.vault - - - odditem - info.somethingodd - - - scrollingmenusign - me.desht - - - truezip - de.schlichtherle - - - residence - net.t00thpick1 - - - Heroes - com.herocraftonline.heroes - - - HeroChat - com.dthielke.herochat - - - worldguard - com.sk89q - - - worldedit - com.sk89q - - - lwc - com.griefcraft.lwc - - - js - rhino - - - jchronic - com.sk89q - - - deadbolt - com.daemitus.deadbolt - - - bukkit-classloader-check - com.sk89q.spigot - - - jsr305 - com.google.code.findbugs - - - opencsv - net.sf.opencsv - - - simplechestlock - + + + com.acrobot.chestshop + chestshop + 3.8.12 + provided + + + org.bukkit + bukkit + + + org.bukkit + craftbukkit + + + Vault + net.milkbowl.vault + + + odditem + info.somethingodd + + + scrollingmenusign + me.desht + + + truezip + de.schlichtherle + + + residence + net.t00thpick1 + + + Heroes + com.herocraftonline.heroes + + + HeroChat + com.dthielke.herochat + + + worldguard + com.sk89q + + + worldedit + com.sk89q + + + lwc + com.griefcraft.lwc + + + js + rhino + + + jchronic + com.sk89q + + + deadbolt + com.daemitus.deadbolt + + + bukkit-classloader-check + com.sk89q.spigot + + + jsr305 + com.google.code.findbugs + + + opencsv + net.sf.opencsv + + + simplechestlock + com.webkonsept.bukkit.simplechestlock - - - commandbook - com.sk89q - - - lockette - org.yi.acru.bukkit.lockette - - - + + + commandbook + com.sk89q + + + lockette + org.yi.acru.bukkit.lockette + + + - + diff --git a/src/main/java/fr/xephi/authme/datasource/MySQL.java b/src/main/java/fr/xephi/authme/datasource/MySQL.java index 8803c874..89d9fd85 100644 --- a/src/main/java/fr/xephi/authme/datasource/MySQL.java +++ b/src/main/java/fr/xephi/authme/datasource/MySQL.java @@ -113,6 +113,7 @@ public class MySQL implements DataSource { throws ClassNotFoundException, SQLException, TimeoutException, NumberFormatException, PoolInitializationException { HikariConfig config = new HikariConfig(); + config.setDriverClassName("com.mysql.jdbc.Driver"); config.setJdbcUrl("jdbc:mysql://" + this.host + ":" + this.port + "/" + this.database); config.setUsername(this.username); config.setPassword(this.password); From eec7a7f575f3eec4d7428274ecf67a23ed1b7be4 Mon Sep 17 00:00:00 2001 From: Xephi59 Date: Thu, 27 Aug 2015 23:28:12 +0200 Subject: [PATCH 09/14] Add SALTEDSHA512 Encryption --- .../xephi/authme/security/HashAlgorithm.java | 1 + .../authme/security/PasswordSecurity.java | 9 ++++-- .../authme/security/crypts/SALTEDSHA512.java | 32 +++++++++++++++++++ 3 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 src/main/java/fr/xephi/authme/security/crypts/SALTEDSHA512.java diff --git a/src/main/java/fr/xephi/authme/security/HashAlgorithm.java b/src/main/java/fr/xephi/authme/security/HashAlgorithm.java index a9fd19e5..312b6df0 100644 --- a/src/main/java/fr/xephi/authme/security/HashAlgorithm.java +++ b/src/main/java/fr/xephi/authme/security/HashAlgorithm.java @@ -29,6 +29,7 @@ public enum HashAlgorithm { ROYALAUTH(fr.xephi.authme.security.crypts.ROYALAUTH.class), CRAZYCRYPT1(fr.xephi.authme.security.crypts.CRAZYCRYPT1.class), BCRYPT2Y(fr.xephi.authme.security.crypts.BCRYPT2Y.class), + SALTEDSHA512(fr.xephi.authme.security.crypts.SALTEDSHA512.class), CUSTOM(Null.class); Class classe; diff --git a/src/main/java/fr/xephi/authme/security/PasswordSecurity.java b/src/main/java/fr/xephi/authme/security/PasswordSecurity.java index bfc2fb2d..305b89b6 100644 --- a/src/main/java/fr/xephi/authme/security/PasswordSecurity.java +++ b/src/main/java/fr/xephi/authme/security/PasswordSecurity.java @@ -96,7 +96,12 @@ public class PasswordSecurity { userSalt.put(playerName, salt); break; case BCRYPT2Y: - salt = createSalt(22); + salt = createSalt(16); + userSalt.put(playerName, salt); + break; + case SALTEDSHA512: + salt = createSalt(32); + userSalt.put(playerName, salt); break; case MD5: case SHA1: @@ -165,7 +170,7 @@ public class PasswordSecurity { PlayerAuth nAuth = AuthMe.getInstance().database.getAuth(playerName); if (nAuth != null) { nAuth.setHash(getHash(Settings.getPasswordHash, password, playerName)); - nAuth.setSalt(userSalt.get(playerName)); + nAuth.setSalt(userSalt.containsKey(playerName) ? userSalt.get(playerName) : ""); AuthMe.getInstance().database.updatePassword(nAuth); AuthMe.getInstance().database.updateSalt(nAuth); } diff --git a/src/main/java/fr/xephi/authme/security/crypts/SALTEDSHA512.java b/src/main/java/fr/xephi/authme/security/crypts/SALTEDSHA512.java new file mode 100644 index 00000000..0050dd73 --- /dev/null +++ b/src/main/java/fr/xephi/authme/security/crypts/SALTEDSHA512.java @@ -0,0 +1,32 @@ +package fr.xephi.authme.security.crypts; + +import java.math.BigInteger; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; + +import fr.xephi.authme.AuthMe; + +public class SALTEDSHA512 implements EncryptionMethod { + + @Override + public String getHash(String password, String salt, String name) + throws NoSuchAlgorithmException { + return getSHA512(password + salt); + } + + @Override + public boolean comparePassword(String hash, String password, + String playerName) throws NoSuchAlgorithmException { + String salt = AuthMe.getInstance().database.getAuth(playerName).getSalt(); + return hash.equals(getHash(password, salt, "")); + } + + private static String getSHA512(String message) + throws NoSuchAlgorithmException { + MessageDigest sha512 = MessageDigest.getInstance("SHA-512"); + sha512.reset(); + sha512.update(message.getBytes()); + byte[] digest = sha512.digest(); + return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1, digest)); + } +} From e33ebb7379011d449dcf79237e33b2d591ad06a0 Mon Sep 17 00:00:00 2001 From: Xephi59 Date: Fri, 28 Aug 2015 00:16:26 +0200 Subject: [PATCH 10/14] Change some custom event to let them be async --- .../xephi/authme/commands/AdminCommand.java | 67 +++++++++++-------- .../fr/xephi/authme/events/CustomEvent.java | 8 +++ .../events/FirstSpawnTeleportEvent.java | 1 + .../events/PasswordEncryptionEvent.java | 1 + .../authme/events/ProtectInventoryEvent.java | 1 + .../authme/events/ResetInventoryEvent.java | 1 + .../authme/events/RestoreInventoryEvent.java | 8 +++ .../authme/events/StoreInventoryEvent.java | 3 +- .../authme/process/join/AsyncronousJoin.java | 59 ++++++++-------- .../logout/ProcessSyncronousPlayerLogout.java | 8 +-- .../authme/process/quit/AsyncronousQuit.java | 10 +++ .../quit/ProcessSyncronousPlayerQuit.java | 10 +-- 12 files changed, 103 insertions(+), 74 deletions(-) diff --git a/src/main/java/fr/xephi/authme/commands/AdminCommand.java b/src/main/java/fr/xephi/authme/commands/AdminCommand.java index 28f4519b..cdcbf997 100644 --- a/src/main/java/fr/xephi/authme/commands/AdminCommand.java +++ b/src/main/java/fr/xephi/authme/commands/AdminCommand.java @@ -47,8 +47,8 @@ public class AdminCommand implements CommandExecutor { } @Override - public boolean onCommand(CommandSender sender, Command cmnd, String label, - String[] args) { + public boolean onCommand(final CommandSender sender, Command cmnd, + String label, String[] args) { if (args.length == 0) { sender.sendMessage("Usage:"); sender.sendMessage("/authme reload - Reload the config"); @@ -434,34 +434,43 @@ public class AdminCommand implements CommandExecutor { return true; } } - try { - String name = args[1].toLowerCase(); - String hash = PasswordSecurity.getHash(Settings.getPasswordHash, args[2], name); - PlayerAuth auth = null; - if (PlayerCache.getInstance().isAuthenticated(name)) { - auth = PlayerCache.getInstance().getAuth(name); - } else if (plugin.database.isAuthAvailable(name)) { - auth = plugin.database.getAuth(name); + final String name = args[1].toLowerCase(); + final String raw = args[2]; + Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() { + + @Override + public void run() { + String hash; + try { + hash = PasswordSecurity.getHash(Settings.getPasswordHash, raw, name); + } catch (NoSuchAlgorithmException e) { + m.send(sender, "error"); + return; + } + PlayerAuth auth = null; + if (PlayerCache.getInstance().isAuthenticated(name)) { + auth = PlayerCache.getInstance().getAuth(name); + } else if (plugin.database.isAuthAvailable(name)) { + auth = plugin.database.getAuth(name); + } + if (auth == null) { + m.send(sender, "unknown_user"); + return; + } + auth.setHash(hash); + if (PasswordSecurity.userSalt.containsKey(name)) { + auth.setSalt(PasswordSecurity.userSalt.get(name)); + plugin.database.updateSalt(auth); + } + if (!plugin.database.updatePassword(auth)) { + m.send(sender, "error"); + return; + } + sender.sendMessage("pwd_changed"); + ConsoleLogger.info(name + "'s password changed"); } - if (auth == null) { - m.send(sender, "unknown_user"); - return true; - } - auth.setHash(hash); - if (PasswordSecurity.userSalt.containsKey(name)) { - auth.setSalt(PasswordSecurity.userSalt.get(name)); - plugin.database.updateSalt(auth); - } - if (!plugin.database.updatePassword(auth)) { - m.send(sender, "error"); - return true; - } - sender.sendMessage("pwd_changed"); - ConsoleLogger.info(args[1] + "'s password changed"); - } catch (NoSuchAlgorithmException ex) { - ConsoleLogger.showError(ex.getMessage()); - m.send(sender, "error"); - } + + }); return true; } else if (args[0].equalsIgnoreCase("unregister") || args[0].equalsIgnoreCase("unreg") || args[0].equalsIgnoreCase("del")) { if (args.length != 2) { diff --git a/src/main/java/fr/xephi/authme/events/CustomEvent.java b/src/main/java/fr/xephi/authme/events/CustomEvent.java index 22742996..5be14710 100644 --- a/src/main/java/fr/xephi/authme/events/CustomEvent.java +++ b/src/main/java/fr/xephi/authme/events/CustomEvent.java @@ -13,6 +13,14 @@ public class CustomEvent extends Event implements Cancellable { private boolean isCancelled; private static final HandlerList handlers = new HandlerList(); + public CustomEvent() { + super(false); + } + + public CustomEvent(boolean b) { + super(b); + } + public HandlerList getHandlers() { return handlers; } diff --git a/src/main/java/fr/xephi/authme/events/FirstSpawnTeleportEvent.java b/src/main/java/fr/xephi/authme/events/FirstSpawnTeleportEvent.java index 079a4614..e4061460 100644 --- a/src/main/java/fr/xephi/authme/events/FirstSpawnTeleportEvent.java +++ b/src/main/java/fr/xephi/authme/events/FirstSpawnTeleportEvent.java @@ -16,6 +16,7 @@ public class FirstSpawnTeleportEvent extends CustomEvent { private Location from; public FirstSpawnTeleportEvent(Player player, Location from, Location to) { + super(true); this.player = player; this.from = from; this.to = to; diff --git a/src/main/java/fr/xephi/authme/events/PasswordEncryptionEvent.java b/src/main/java/fr/xephi/authme/events/PasswordEncryptionEvent.java index 9f6ea007..4e5a0f5c 100644 --- a/src/main/java/fr/xephi/authme/events/PasswordEncryptionEvent.java +++ b/src/main/java/fr/xephi/authme/events/PasswordEncryptionEvent.java @@ -22,6 +22,7 @@ public class PasswordEncryptionEvent extends Event { private String playerName = ""; public PasswordEncryptionEvent(EncryptionMethod method, String playerName) { + super(true); this.method = method; this.playerName = playerName; } diff --git a/src/main/java/fr/xephi/authme/events/ProtectInventoryEvent.java b/src/main/java/fr/xephi/authme/events/ProtectInventoryEvent.java index eebf6f4a..10d5636b 100644 --- a/src/main/java/fr/xephi/authme/events/ProtectInventoryEvent.java +++ b/src/main/java/fr/xephi/authme/events/ProtectInventoryEvent.java @@ -20,6 +20,7 @@ public class ProtectInventoryEvent extends CustomEvent { public ProtectInventoryEvent(Player player, ItemStack[] storedinventory, ItemStack[] storedarmor) { + super(true); this.player = player; this.storedinventory = storedinventory; this.storedarmor = storedarmor; diff --git a/src/main/java/fr/xephi/authme/events/ResetInventoryEvent.java b/src/main/java/fr/xephi/authme/events/ResetInventoryEvent.java index 84fbe206..5c7b622e 100644 --- a/src/main/java/fr/xephi/authme/events/ResetInventoryEvent.java +++ b/src/main/java/fr/xephi/authme/events/ResetInventoryEvent.java @@ -13,6 +13,7 @@ public class ResetInventoryEvent extends CustomEvent { private Player player; public ResetInventoryEvent(Player player) { + super(true); this.player = player; } diff --git a/src/main/java/fr/xephi/authme/events/RestoreInventoryEvent.java b/src/main/java/fr/xephi/authme/events/RestoreInventoryEvent.java index f51499a9..c2c36ba4 100644 --- a/src/main/java/fr/xephi/authme/events/RestoreInventoryEvent.java +++ b/src/main/java/fr/xephi/authme/events/RestoreInventoryEvent.java @@ -22,6 +22,14 @@ public class RestoreInventoryEvent extends CustomEvent { this.armor = armor; } + public RestoreInventoryEvent(Player player, ItemStack[] inventory, + ItemStack[] armor, boolean b) { + super(b); + this.player = player; + this.inventory = inventory; + this.armor = armor; + } + public ItemStack[] getInventory() { return this.inventory; } diff --git a/src/main/java/fr/xephi/authme/events/StoreInventoryEvent.java b/src/main/java/fr/xephi/authme/events/StoreInventoryEvent.java index 78507524..c91523d8 100644 --- a/src/main/java/fr/xephi/authme/events/StoreInventoryEvent.java +++ b/src/main/java/fr/xephi/authme/events/StoreInventoryEvent.java @@ -28,8 +28,7 @@ public class StoreInventoryEvent extends CustomEvent { try { this.inventory = fileCache.readCache(player).getInventory(); this.armor = fileCache.readCache(player).getArmour(); - } catch (Exception e) - { + } catch (Exception e) { this.inventory = player.getInventory().getContents(); this.armor = player.getInventory().getArmorContents(); } diff --git a/src/main/java/fr/xephi/authme/process/join/AsyncronousJoin.java b/src/main/java/fr/xephi/authme/process/join/AsyncronousJoin.java index d1ef309d..3a3e8e1f 100644 --- a/src/main/java/fr/xephi/authme/process/join/AsyncronousJoin.java +++ b/src/main/java/fr/xephi/authme/process/join/AsyncronousJoin.java @@ -6,6 +6,7 @@ import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; import org.bukkit.scheduler.BukkitScheduler; @@ -176,25 +177,27 @@ public class AsyncronousJoin { } if (Settings.protectInventoryBeforeLogInEnabled) { - sched.scheduleSyncDelayedTask(plugin, new Runnable() { + try { + LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(player.getName().toLowerCase()); + ProtectInventoryEvent ev = new ProtectInventoryEvent(player, limbo.getInventory(), limbo.getArmour()); + plugin.getServer().getPluginManager().callEvent(ev); + if (ev.isCancelled()) { + if (!Settings.noConsoleSpam) + ConsoleLogger.info("ProtectInventoryEvent has been cancelled for " + player.getName() + " ..."); + } else { + final ItemStack[] inv = ev.getEmptyArmor(); + final ItemStack[] armor = ev.getEmptyArmor(); + sched.scheduleSyncDelayedTask(plugin, new Runnable() { - @Override - public void run() { - try { - LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(player.getName().toLowerCase()); - ProtectInventoryEvent ev = new ProtectInventoryEvent(player, limbo.getInventory(), limbo.getArmour()); - plugin.getServer().getPluginManager().callEvent(ev); - if (ev.isCancelled()) { - if (!Settings.noConsoleSpam) - ConsoleLogger.info("ProtectInventoryEvent has been cancelled for " + player.getName() + " ..."); - } else { - plugin.api.setPlayerInventory(player, ev.getEmptyInventory(), ev.getEmptyArmor()); + @Override + public void run() { + plugin.api.setPlayerInventory(player, inv, armor); } - } catch (NullPointerException ex) { - } - } - }); + }); + } + } catch (NullPointerException ex) { + } } String[] msg; if (Settings.emailRegistration) { @@ -262,21 +265,21 @@ public class AsyncronousJoin { else { if (Spawn.getInstance().getFirstSpawn() == null || Spawn.getInstance().getFirstSpawn().getWorld() == null) return false; - final Location loc = Spawn.getInstance().getFirstSpawn(); - Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + FirstSpawnTeleportEvent tpEvent = new FirstSpawnTeleportEvent(player, player.getLocation(), Spawn.getInstance().getFirstSpawn()); + plugin.getServer().getPluginManager().callEvent(tpEvent); + if (!tpEvent.isCancelled()) { + if (player.isOnline() && tpEvent.getTo() != null && tpEvent.getTo().getWorld() != null) { + final Location fLoc = tpEvent.getTo(); + Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { - @Override - public void run() { - FirstSpawnTeleportEvent tpEvent = new FirstSpawnTeleportEvent(player, player.getLocation(), loc); - plugin.getServer().getPluginManager().callEvent(tpEvent); - if (!tpEvent.isCancelled()) { - if (player.isOnline() && tpEvent.getTo() != null && tpEvent.getTo().getWorld() != null) { - player.teleport(tpEvent.getTo()); + @Override + public void run() { + player.teleport(fLoc); } - } - } - }); + }); + } + } return true; } } diff --git a/src/main/java/fr/xephi/authme/process/logout/ProcessSyncronousPlayerLogout.java b/src/main/java/fr/xephi/authme/process/logout/ProcessSyncronousPlayerLogout.java index f926c694..4cac3864 100644 --- a/src/main/java/fr/xephi/authme/process/logout/ProcessSyncronousPlayerLogout.java +++ b/src/main/java/fr/xephi/authme/process/logout/ProcessSyncronousPlayerLogout.java @@ -56,13 +56,7 @@ public class ProcessSyncronousPlayerLogout implements Runnable { player.setFlying(true); } // Player is now logout... Time to fire event ! - sched.scheduleSyncDelayedTask(plugin, new Runnable() { - - @Override - public void run() { - Bukkit.getServer().getPluginManager().callEvent(new LogoutEvent(player)); - } - }); + Bukkit.getServer().getPluginManager().callEvent(new LogoutEvent(player)); m.send(player, "logout"); ConsoleLogger.info(player.getDisplayName() + " logged out"); } diff --git a/src/main/java/fr/xephi/authme/process/quit/AsyncronousQuit.java b/src/main/java/fr/xephi/authme/process/quit/AsyncronousQuit.java index 40a71247..dd84fdc8 100644 --- a/src/main/java/fr/xephi/authme/process/quit/AsyncronousQuit.java +++ b/src/main/java/fr/xephi/authme/process/quit/AsyncronousQuit.java @@ -13,6 +13,7 @@ import fr.xephi.authme.cache.auth.PlayerCache; import fr.xephi.authme.cache.limbo.LimboCache; import fr.xephi.authme.cache.limbo.LimboPlayer; import fr.xephi.authme.datasource.DataSource; +import fr.xephi.authme.events.RestoreInventoryEvent; import fr.xephi.authme.listener.AuthMePlayerListener; import fr.xephi.authme.plugin.manager.CombatTagComunicator; import fr.xephi.authme.settings.Settings; @@ -97,6 +98,15 @@ public class AsyncronousQuit { } AuthMePlayerListener.gameMode.remove(name); final Player p = player; + RestoreInventoryEvent ev = new RestoreInventoryEvent(player, inv, armor, true); + Bukkit.getPluginManager().callEvent(ev); + if (ev.isCancelled()) { + inv = null; + armor = null; + } else { + inv = ev.getInventory(); + armor = ev.getArmor(); + } Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new ProcessSyncronousPlayerQuit(plugin, p, inv, armor, isOp, isFlying, needToChange)); } } diff --git a/src/main/java/fr/xephi/authme/process/quit/ProcessSyncronousPlayerQuit.java b/src/main/java/fr/xephi/authme/process/quit/ProcessSyncronousPlayerQuit.java index b21a78bf..48813409 100644 --- a/src/main/java/fr/xephi/authme/process/quit/ProcessSyncronousPlayerQuit.java +++ b/src/main/java/fr/xephi/authme/process/quit/ProcessSyncronousPlayerQuit.java @@ -5,7 +5,6 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import fr.xephi.authme.AuthMe; -import fr.xephi.authme.events.RestoreInventoryEvent; import fr.xephi.authme.settings.Settings; public class ProcessSyncronousPlayerQuit implements Runnable { @@ -32,13 +31,8 @@ public class ProcessSyncronousPlayerQuit implements Runnable { @Override public void run() { - if (inv != null && armor != null) { - RestoreInventoryEvent ev = new RestoreInventoryEvent(player, inv, armor); - player.getServer().getPluginManager().callEvent(ev); - if (!ev.isCancelled()) { - plugin.api.setPlayerInventory(player, ev.getInventory(), ev.getArmor()); - } - } + if (inv != null && armor != null) + plugin.api.setPlayerInventory(player, inv, armor); if (needToChange) { player.setOp(isOp); if (player.getGameMode() != GameMode.CREATIVE && !Settings.isMovementAllowed) { From 3bcaa3f12b34102718a00e92b12654b5538963cb Mon Sep 17 00:00:00 2001 From: Xephi59 Date: Fri, 28 Aug 2015 00:16:49 +0200 Subject: [PATCH 11/14] Change to minimum lifeTime --- src/main/java/fr/xephi/authme/datasource/MySQL.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/fr/xephi/authme/datasource/MySQL.java b/src/main/java/fr/xephi/authme/datasource/MySQL.java index 89d9fd85..1588ac6b 100644 --- a/src/main/java/fr/xephi/authme/datasource/MySQL.java +++ b/src/main/java/fr/xephi/authme/datasource/MySQL.java @@ -122,7 +122,7 @@ public class MySQL implements DataSource { config.addDataSourceProperty("prepStmtCacheSize", "250"); config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048"); config.addDataSourceProperty("autoReconnect", true); - config.setMaxLifetime(12000); + config.setMaxLifetime(30000); config.setInitializationFailFast(false); ds = new HikariDataSource(config); ConsoleLogger.info("Connection pool ready"); From fc484c4948791ac846ed2698b6260ef46681c064 Mon Sep 17 00:00:00 2001 From: "Making GitHub Delicious." Date: Thu, 3 Sep 2015 07:56:41 -0600 Subject: [PATCH 12/14] add waffle.io badge --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 3e8242a8..5f537345 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ +[![Stories in Ready](https://badge.waffle.io/Xephi/AuthMeReloaded.png?label=ready&title=Ready)](https://waffle.io/Xephi/AuthMeReloaded)

The most used authentication plugin for CraftBukkit/Spigot!


From 028c70945ef90a9cf245a4cf05fbf763b04f1f5e Mon Sep 17 00:00:00 2001 From: Alexandre Vanhecke Date: Thu, 3 Sep 2015 15:58:18 +0200 Subject: [PATCH 13/14] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5f537345..54b66aa1 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,3 @@ -[![Stories in Ready](https://badge.waffle.io/Xephi/AuthMeReloaded.png?label=ready&title=Ready)](https://waffle.io/Xephi/AuthMeReloaded)

The most used authentication plugin for CraftBukkit/Spigot!


@@ -10,6 +9,8 @@ - Build status (CircleCI): [![Circle CI](https://circleci.com/gh/Xephi/AuthMeReloaded.svg?style=svg)](https://circleci.com/gh/Xephi/AuthMeReloaded) +- Issue Tracking : [![Stories in Ready](https://badge.waffle.io/Xephi/AuthMeReloaded.png?label=ready&title=Ready)](https://waffle.io/Xephi/AuthMeReloaded) + - Build Server (DEVELOPMENT BUILDS): Xephi's Jenkins - JavaDocs: AuthMe Javadoc From 3963a27c27b85d56def652618e617da67d5d6461 Mon Sep 17 00:00:00 2001 From: Alexandre Vanhecke Date: Fri, 4 Sep 2015 10:59:55 +0200 Subject: [PATCH 14/14] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 54b66aa1..2f12855f 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ - Build status (CircleCI): [![Circle CI](https://circleci.com/gh/Xephi/AuthMeReloaded.svg?style=svg)](https://circleci.com/gh/Xephi/AuthMeReloaded) -- Issue Tracking : [![Stories in Ready](https://badge.waffle.io/Xephi/AuthMeReloaded.png?label=ready&title=Ready)](https://waffle.io/Xephi/AuthMeReloaded) +- Issue Tracking : [![Stories in Ready](https://badge.waffle.io/Xephi/AuthMeReloaded.png?label=ready&title=Ready)](https://waffle.io/Xephi/AuthMeReloaded) [![Stories in Bugs](https://badge.waffle.io/Xephi/AuthMeReloaded.png?label=bugs&title=Bugs)](https://waffle.io/Xephi/AuthMeReloaded) [![Stories in In%20Progress](https://badge.waffle.io/Xephi/AuthMeReloaded.png?label=in%20progress&title=In%20Progress)](https://waffle.io/Xephi/AuthMeReloaded) - Build Server (DEVELOPMENT BUILDS): Xephi's Jenkins