From 8cb462105568df03be82582c9caf210d95b1016c Mon Sep 17 00:00:00 2001 From: games647 Date: Sun, 20 Mar 2016 15:19:02 +0100 Subject: [PATCH] Fixed autoRegister support for LoginSecurity --- README.md | 23 +++++++++++-------- .../bukkit/hooks/LoginSecurityHook.java | 22 ++++++++++-------- 2 files changed, 26 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 4990198b..f6a36608 100644 --- a/README.md +++ b/README.md @@ -33,17 +33,20 @@ So they don't need to enter passwords. This is also called auto login (auto-logi * Tested Bukkit/[Spigot](https://www.spigotmc.org) 1.9 (could also work with other versions) * Java 7+ * Run Spigot and/or BungeeCord in offline mode (see server.properties or config.yml) -* An auth plugin. Supported Plugins: - * Bukkit: - * [AuthMe](http://dev.bukkit.org/bukkit-plugins/authme-reloaded/) - * [xAuth](http://dev.bukkit.org/bukkit-plugins/xauth/) - * [CrazyLogin](http://dev.bukkit.org/bukkit-plugins/crazylogin/) - * [LoginSecurity](http://dev.bukkit.org/bukkit-plugins/loginsecurity/) - * [RoyalAuth](http://dev.bukkit.org/bukkit-plugins/royalauth/) - * [UltraAuth](http://dev.bukkit.org/bukkit-plugins/ultraauth-aa/) +* An auth plugin. Supported Plugins - * BungeeCord: - * [BungeeAuth](https://www.spigotmc.org/resources/bungeeauth.493/) +#### Bukkit + +* [AuthMe](http://dev.bukkit.org/bukkit-plugins/authme-reloaded/) +* [xAuth](http://dev.bukkit.org/bukkit-plugins/xauth/) +* [CrazyLogin](http://dev.bukkit.org/bukkit-plugins/crazylogin/) +* [LoginSecurity](http://dev.bukkit.org/bukkit-plugins/loginsecurity/) +* [RoyalAuth](http://dev.bukkit.org/bukkit-plugins/royalauth/) +* [UltraAuth](http://dev.bukkit.org/bukkit-plugins/ultraauth-aa/) + +#### BungeeCord + +* [BungeeAuth](https://www.spigotmc.org/resources/bungeeauth.493/) ###Downloads diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/hooks/LoginSecurityHook.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/hooks/LoginSecurityHook.java index 451870e8..04501cb9 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/hooks/LoginSecurityHook.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/hooks/LoginSecurityHook.java @@ -12,11 +12,10 @@ import org.bukkit.Bukkit; import org.bukkit.entity.Player; /** - * Github: https://github.com/lenis0012/LoginSecurity-2 - * Project page: + * Github: https://github.com/lenis0012/LoginSecurity-2 Project page: * - * Bukkit: http://dev.bukkit.org/bukkit-plugins/loginsecurity/ - * Spigot: https://www.spigotmc.org/resources/loginsecurity.19362/ + * Bukkit: http://dev.bukkit.org/bukkit-plugins/loginsecurity/ Spigot: + * https://www.spigotmc.org/resources/loginsecurity.19362/ * * on join: * https://github.com/lenis0012/LoginSecurity-2/blob/master/src/main/java/com/lenis0012/bukkit/ls/LoginSecurity.java#L282 @@ -45,14 +44,14 @@ public class LoginSecurityHook implements BukkitAuthPlugin { DataManager dataManager = securityPlugin.data; //https://github.com/lenis0012/LoginSecurity-2/blob/master/src/main/java/com/lenis0012/bukkit/ls/LoginSecurity.java#L283 - UUID offlineUuid = UUID.nameUUIDFromBytes(playerName.getBytes(Charsets.UTF_8)); + UUID offlineUuid = UUID.nameUUIDFromBytes(("OfflinePlayer:" + playerName).getBytes(Charsets.UTF_8)); return dataManager.isRegistered(offlineUuid.toString().replace("-", "")); //check for loginsecurity sessions in order to prevent a sql query? //sesUse && thread.getSession().containsKey(uuid) && checkLastIp(player)) { } @Override - public void forceRegister(Player player, final String password) { + public void forceRegister(final Player player, final String password) { final LoginSecurity securityPlugin = LoginSecurity.instance; final DataManager dataManager = securityPlugin.data; @@ -65,10 +64,15 @@ public class LoginSecurityHook implements BukkitAuthPlugin { @Override public void run() { dataManager.register(uuidString, password, securityPlugin.hasher.getTypeId(), ipAddress.toString()); + //run forcelogin only if it was successfull + Bukkit.getScheduler().runTask(securityPlugin, new Runnable() { + @Override + public void run() { + //notify the plugin that this player can be logged in + forceLogin(player); + } + }); } }); - - //notify the plugin that this player can be logged in - forceLogin(player); } }