diff --git a/README.md b/README.md index d0a0d7cb..4990198b 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,7 @@ So they don't need to enter passwords. This is also called auto login (auto-logi * 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/) @@ -41,6 +42,9 @@ So they don't need to enter passwords. This is also called auto login (auto-logi * [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 https://www.spigotmc.org/resources/fastlogin.14153/history diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/FastLoginBukkit.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/FastLoginBukkit.java index 0b600578..2b2741b8 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/FastLoginBukkit.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/FastLoginBukkit.java @@ -6,7 +6,6 @@ import com.comphenix.protocol.ProtocolManager; import com.comphenix.protocol.utility.SafeCacheBuilder; import com.github.games647.fastlogin.bukkit.commands.CrackedCommand; import com.github.games647.fastlogin.bukkit.commands.PremiumCommand; -import com.github.games647.fastlogin.bukkit.hooks.AuthPlugin; import com.github.games647.fastlogin.bukkit.listener.BukkitJoinListener; import com.github.games647.fastlogin.bukkit.listener.BungeeCordListener; import com.github.games647.fastlogin.bukkit.listener.EncryptionPacketListener; @@ -28,6 +27,7 @@ import java.util.logging.Level; import org.apache.commons.lang.RandomStringUtils; import org.bukkit.entity.Player; import org.bukkit.plugin.java.JavaPlugin; +import com.github.games647.fastlogin.bukkit.hooks.BukkitAuthPlugin; /** * This plugin checks if a player has a paid account and if so tries to skip offline mode authentication. @@ -58,7 +58,7 @@ public class FastLoginBukkit extends JavaPlugin { } }); - private AuthPlugin authPlugin; + private BukkitAuthPlugin authPlugin; private final MojangApiConnector mojangApiConnector = new MojangApiConnector(this); @Override @@ -157,7 +157,7 @@ public class FastLoginBukkit extends JavaPlugin { * * @return interface to any supported auth plugin */ - public AuthPlugin getAuthPlugin() { + public BukkitAuthPlugin getAuthPlugin() { return authPlugin; } @@ -172,7 +172,7 @@ public class FastLoginBukkit extends JavaPlugin { } private boolean registerHooks() { - AuthPlugin authPluginHook = null; + BukkitAuthPlugin authPluginHook = null; try { String hooksPackage = this.getClass().getPackage().getName() + ".hooks"; //Look through all classes in the hooks package and look for supporting plugins on the server @@ -181,10 +181,10 @@ public class FastLoginBukkit extends JavaPlugin { String pluginName = clazzInfo.getSimpleName().replace("Hook", ""); Class clazz = clazzInfo.load(); //uses only member classes which uses AuthPlugin interface (skip interfaces) - if (AuthPlugin.class.isAssignableFrom(clazz) + if (BukkitAuthPlugin.class.isAssignableFrom(clazz) //check only for enabled plugins. A single plugin could be disabled by plugin managers && getServer().getPluginManager().isPluginEnabled(pluginName)) { - authPluginHook = (AuthPlugin) clazz.newInstance(); + authPluginHook = (BukkitAuthPlugin) clazz.newInstance(); getLogger().log(Level.INFO, "Hooking into auth plugin: {0}", pluginName); break; } diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/hooks/AuthMeHook.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/hooks/AuthMeHook.java index 449f3f09..ab97469a 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/hooks/AuthMeHook.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/hooks/AuthMeHook.java @@ -11,7 +11,7 @@ import org.bukkit.entity.Player; * Bukkit: http://dev.bukkit.org/bukkit-plugins/authme-reloaded/ * Spigot: https://www.spigotmc.org/resources/authme-reloaded.6269/ */ -public class AuthMeHook implements AuthPlugin { +public class AuthMeHook implements BukkitAuthPlugin { @Override public void forceLogin(Player player) { diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/hooks/AuthPlugin.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/hooks/BukkitAuthPlugin.java similarity index 92% rename from bukkit/src/main/java/com/github/games647/fastlogin/bukkit/hooks/AuthPlugin.java rename to bukkit/src/main/java/com/github/games647/fastlogin/bukkit/hooks/BukkitAuthPlugin.java index a5aa26aa..0010a82d 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/hooks/AuthPlugin.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/hooks/BukkitAuthPlugin.java @@ -3,9 +3,9 @@ package com.github.games647.fastlogin.bukkit.hooks; import org.bukkit.entity.Player; /** - * Represents a supporting authentication plugin + * Represents a supporting authentication plugin in Bukkit/Spigot/... servers */ -public interface AuthPlugin { +public interface BukkitAuthPlugin { /** * Login the premium (paid account) player after diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/hooks/CrazyLoginHook.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/hooks/CrazyLoginHook.java index 2b438b25..78cf52b1 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/hooks/CrazyLoginHook.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/hooks/CrazyLoginHook.java @@ -20,7 +20,7 @@ import org.bukkit.entity.Player; * * Bukkit: http://dev.bukkit.org/server-mods/crazylogin/ */ -public class CrazyLoginHook implements AuthPlugin { +public class CrazyLoginHook implements BukkitAuthPlugin { private final PlayerListener playerListener = getListener(); 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 469f5ffe..451870e8 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 @@ -21,7 +21,7 @@ import org.bukkit.entity.Player; * on join: * https://github.com/lenis0012/LoginSecurity-2/blob/master/src/main/java/com/lenis0012/bukkit/ls/LoginSecurity.java#L282 */ -public class LoginSecurityHook implements AuthPlugin { +public class LoginSecurityHook implements BukkitAuthPlugin { @Override public void forceLogin(Player player) { diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/hooks/RoyalAuthHook.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/hooks/RoyalAuthHook.java index 07e39ac3..3c1c9ede 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/hooks/RoyalAuthHook.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/hooks/RoyalAuthHook.java @@ -11,7 +11,7 @@ import org.royaldev.royalauth.Config; * * Bukkit: http://dev.bukkit.org/bukkit-plugins/royalauth/ */ -public class RoyalAuthHook implements AuthPlugin { +public class RoyalAuthHook implements BukkitAuthPlugin { @Override public void forceLogin(Player player) { diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/hooks/UltraAuthHook.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/hooks/UltraAuthHook.java index de21005d..8f3285c6 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/hooks/UltraAuthHook.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/hooks/UltraAuthHook.java @@ -61,7 +61,7 @@ import ultraauth.api.UltraAuthAPI; * Bukkit: http://dev.bukkit.org/bukkit-plugins/ultraauth-aa/ * Spigot: https://www.spigotmc.org/resources/ultraauth.17044/ */ -public class UltraAuthHook implements AuthPlugin { +public class UltraAuthHook implements BukkitAuthPlugin { @Override public void forceLogin(Player player) { diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/hooks/xAuthHook.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/hooks/xAuthHook.java index 7d011b1c..8c8c23ec 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/hooks/xAuthHook.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/hooks/xAuthHook.java @@ -12,7 +12,7 @@ import org.bukkit.entity.Player; * * Bukkit: http://dev.bukkit.org/bukkit-plugins/xauth/ */ -public class xAuthHook implements AuthPlugin { +public class xAuthHook implements BukkitAuthPlugin { @Override public void forceLogin(Player player) { diff --git a/bungee/pom.xml b/bungee/pom.xml index 46e167dd..69b3e657 100644 --- a/bungee/pom.xml +++ b/bungee/pom.xml @@ -22,6 +22,12 @@ bungeecord-repo https://oss.sonatype.org/content/repositories/snapshots + + + + jitpack.io + https://jitpack.io + @@ -32,5 +38,11 @@ jar provided + + + com.github.MatteCarra + BungeeAuth + -1.2.1-gc367d92-8 + diff --git a/bungee/src/main/java/com/github/games647/fastlogin/bungee/hooks/BungeeAuthHook.java b/bungee/src/main/java/com/github/games647/fastlogin/bungee/hooks/BungeeAuthHook.java new file mode 100644 index 00000000..9179ef96 --- /dev/null +++ b/bungee/src/main/java/com/github/games647/fastlogin/bungee/hooks/BungeeAuthHook.java @@ -0,0 +1,70 @@ +package com.github.games647.fastlogin.bungee.hooks; + +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Random; + +import me.vik1395.BungeeAuth.ListenerClass; +import me.vik1395.BungeeAuth.Main; +import me.vik1395.BungeeAuth.Password.PasswordHandler; +import me.vik1395.BungeeAuth.Tables; + +import net.md_5.bungee.api.connection.ProxiedPlayer; + +/** + * Github: https://github.com/MatteCarra/BungeeAuth + * + * Project page: + * + * Spigot: https://www.spigotmc.org/resources/bungeeauth.493/ + */ +public class BungeeAuthHook implements BungeeAuthPlugin { + + //https://github.com/MatteCarra/BungeeAuth/blob/master/src/me/vik1395/BungeeAuth/Login.java#L32 + private final Tables databaseConnection = new Tables(); + + @Override + public void forceLogin(ProxiedPlayer player) { +//https://github.com/MatteCarra/BungeeAuth/blob/master/src/me/vik1395/BungeeAuth/Login.java#L92-95 + Main.plonline.add(player.getName()); + //renamed from ct to databaseConnection +// databaseConnection.setStatus(player.getName(), "online"); + ListenerClass.movePlayer(player, false); + ListenerClass.prelogin.get(player.getName()).cancel(); + } + + @Override + public boolean isRegistered(String playerName) { + //https://github.com/MatteCarra/BungeeAuth/blob/master/src/me/vik1395/BungeeAuth/Register.java#L46 + //renamed t to databaseConnection + return databaseConnection.checkPlayerEntry(playerName); + } + + @Override + public void forceRegister(ProxiedPlayer player, String password) { + //https://github.com/MatteCarra/BungeeAuth/blob/master/src/me/vik1395/BungeeAuth/Register.java#L102 + PasswordHandler ph = new PasswordHandler(); + Random rand = new Random(); + int maxp = 7; //Total Password Hashing methods. + Date dNow = new Date(); + SimpleDateFormat ft = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss"); + + String Pw = password; + String pType = "" + rand.nextInt(maxp + 1); + String regdate = ft.format(dNow); + //https://github.com/MatteCarra/BungeeAuth/blob/master/src/me/vik1395/BungeeAuth/Register.java#L60 + String lastip = player.getAddress().getAddress().getHostAddress(); + String lastseen = regdate; + String hash = ph.newHash(Pw, pType); + + //creates a new SQL entry with the player's details. +// try { + //renamed t to databaseConnection +// databaseConnection.newPlayerEntry(player.getName(), hash, pType, "", lastip, regdate, lastip, lastseen); + ListenerClass.prelogin.get(player.getName()).cancel(); +// } catch (SQLException e) { +// Main.plugin.getLogger().severe("[BungeeAuth] Error when creating a new player in the MySQL Database"); +// e.printStackTrace(); +// } + } +} diff --git a/bungee/src/main/java/com/github/games647/fastlogin/bungee/hooks/BungeeAuthPlugin.java b/bungee/src/main/java/com/github/games647/fastlogin/bungee/hooks/BungeeAuthPlugin.java new file mode 100644 index 00000000..988ac150 --- /dev/null +++ b/bungee/src/main/java/com/github/games647/fastlogin/bungee/hooks/BungeeAuthPlugin.java @@ -0,0 +1,28 @@ +package com.github.games647.fastlogin.bungee.hooks; + + +import net.md_5.bungee.api.connection.ProxiedPlayer; + +//do not use yet - +public interface BungeeAuthPlugin { + + /** + * + * @param player the player that needs to be logged in + */ + void forceLogin(ProxiedPlayer player); + + /** + * + * @param playerName player name + * @return if the player has an account + */ + boolean isRegistered(String playerName); + + /** + * + * @param player the premium account + * @param password a strong random generated password + */ + void forceRegister(ProxiedPlayer player, String password); +}