diff --git a/CHANGELOG.md b/CHANGELOG.md index e13b9db9..448cb05e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ ######1.9 +* [API] Deprecated platform specific authplugin. Please use AuthPlugin< platform specific player type > +* [API] Deprecated bukkit's password generator. Please use PasswordGenerator< platform specific player type > * Added second attempt login -> cracked login * Add cracked whitelist (switch-mode -> switching to online-mode from offlinemode) * Added configuration to disable auto logins for 2Factor authentication diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/PasswordGenerator.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/PasswordGenerator.java index 172df722..85d8a6fe 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/PasswordGenerator.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/PasswordGenerator.java @@ -2,6 +2,11 @@ package com.github.games647.fastlogin.bukkit; import org.bukkit.entity.Player; +/** + * + * @deprecated please use com.github.games647.fastlogin.core.shared.PasswordGenerator + */ +@Deprecated public interface PasswordGenerator { String getRandomPassword(Player player); 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 97aa8f05..8cbdd8a9 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 @@ -1,6 +1,7 @@ package com.github.games647.fastlogin.bukkit.hooks; import com.avaje.ebeaninternal.api.ClassUtil; +import com.github.games647.fastlogin.core.AuthPlugin; import fr.xephi.authme.api.API; import fr.xephi.authme.api.NewAPI; @@ -14,7 +15,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 BukkitAuthPlugin { +public class AuthMeHook implements AuthPlugin { private final boolean isNewAPIAvailable; diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/hooks/BukkitAuthPlugin.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/hooks/BukkitAuthPlugin.java index 6f22b11f..fd30a6d4 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/hooks/BukkitAuthPlugin.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/hooks/BukkitAuthPlugin.java @@ -5,58 +5,14 @@ import com.github.games647.fastlogin.core.AuthPlugin; import org.bukkit.entity.Player; /** - * Represents a supporting authentication plugin in Bukkit/Spigot/... servers + * @deprecated please use com.github.games647.fastlogin.core.AuthPlugin */ +@Deprecated public interface BukkitAuthPlugin extends AuthPlugin { - /** - * Login the premium (paid account) player after - * the player joined successfully the server. - * - * This operation will be performed async while the player successfully - * joined the server. - * - * @param player the player that needs to be logged in - * @return if the operation was successful - */ boolean forceLogin(Player player); - /** - * Checks whether an account exists for this player name. - * - * This check should check if a cracked player account exists - * so we can be sure the premium player doesn't steal the account - * of that player. - * - * This operation will be performed async while the player is - * connecting. - * - * @param playerName player name - * @return if the player has an account - * @throws Exception if an error occurred - */ boolean isRegistered(String playerName) throws Exception; - /** - * Forces a register in order to protect the paid account. - * - * This operation will be performed async while the player successfully - * joined the server. - * - * After a successful registration the player should be logged - * in too. - * - * The method will be called only for premium accounts. - * So it's recommended to set additionally premium property - * if possible. - * - * Background: If we don't register an account, cracked players - * could steal the unregistered account from the paid - * player account - * - * @param player the premium account - * @param password a strong random generated password - * @return if the operation was successful - */ boolean forceRegister(Player player, String password); } 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 e94462ef..40fb6851 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 @@ -1,5 +1,7 @@ package com.github.games647.fastlogin.bukkit.hooks; +import com.github.games647.fastlogin.core.AuthPlugin; + import de.st_ddt.crazylogin.CrazyLogin; import de.st_ddt.crazylogin.data.LoginPlayerData; import de.st_ddt.crazylogin.databases.CrazyLoginDataDatabase; @@ -22,7 +24,7 @@ import org.bukkit.entity.Player; * * Bukkit: http://dev.bukkit.org/server-mods/crazylogin/ */ -public class CrazyLoginHook implements BukkitAuthPlugin { +public class CrazyLoginHook implements AuthPlugin { protected final CrazyLogin crazyLoginPlugin = CrazyLogin.getPlugin(); private final PlayerListener playerListener = getListener(); diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/hooks/LogItHook.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/hooks/LogItHook.java index cd0ef637..15dcc054 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/hooks/LogItHook.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/hooks/LogItHook.java @@ -1,5 +1,7 @@ package com.github.games647.fastlogin.bukkit.hooks; +import com.github.games647.fastlogin.core.AuthPlugin; + import io.github.lucaseasedup.logit.CancelledState; import io.github.lucaseasedup.logit.LogItCore; import io.github.lucaseasedup.logit.account.Account; @@ -13,7 +15,7 @@ import org.bukkit.entity.Player; * Bukkit: Unknown * Spigot: Unknown */ -public class LogItHook implements BukkitAuthPlugin { +public class LogItHook implements AuthPlugin { @Override public boolean forceLogin(Player player) { 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 16c01a0f..5dd860ed 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 @@ -2,6 +2,7 @@ package com.github.games647.fastlogin.bukkit.hooks; import com.avaje.ebeaninternal.api.ClassUtil; import com.github.games647.fastlogin.bukkit.FastLoginBukkit; +import com.github.games647.fastlogin.core.AuthPlugin; import com.google.common.base.Charsets; import com.lenis0012.bukkit.loginsecurity.LoginSecurity; import com.lenis0012.bukkit.loginsecurity.session.AuthService; @@ -26,7 +27,7 @@ import org.bukkit.entity.Player; * Bukkit: http://dev.bukkit.org/bukkit-plugins/loginsecurity/ * Spigot: https://www.spigotmc.org/resources/loginsecurity.19362/ */ -public class LoginSecurityHook implements BukkitAuthPlugin { +public class LoginSecurityHook implements AuthPlugin { protected final com.lenis0012.bukkit.ls.LoginSecurity securityPlugin; protected final FastLoginBukkit plugin = (FastLoginBukkit) Bukkit.getPluginManager().getPlugin("FastLogin"); 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 2efdc216..c39e9909 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 @@ -1,5 +1,7 @@ package com.github.games647.fastlogin.bukkit.hooks; +import com.github.games647.fastlogin.core.AuthPlugin; + import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; @@ -18,7 +20,7 @@ import org.royaldev.royalauth.RoyalAuth; * * Bukkit: http://dev.bukkit.org/bukkit-plugins/royalauth/ */ -public class RoyalAuthHook implements BukkitAuthPlugin { +public class RoyalAuthHook implements AuthPlugin { private final RoyalAuth royalAuthPlugin = (RoyalAuth) Bukkit.getPluginManager().getPlugin("RoyalAuth"); 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 7011f1b3..99794081 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 @@ -1,5 +1,7 @@ package com.github.games647.fastlogin.bukkit.hooks; +import com.github.games647.fastlogin.core.AuthPlugin; + import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; @@ -19,7 +21,7 @@ import ultraauth.managers.PlayerManager; * Bukkit: http://dev.bukkit.org/bukkit-plugins/ultraauth-aa/ * Spigot: https://www.spigotmc.org/resources/ultraauth.17044/ */ -public class UltraAuthHook implements BukkitAuthPlugin { +public class UltraAuthHook implements AuthPlugin { protected final Plugin ultraAuthPlugin = Main.main; 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 7d6f4e09..350b248e 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 @@ -1,5 +1,7 @@ package com.github.games647.fastlogin.bukkit.hooks; +import com.github.games647.fastlogin.core.AuthPlugin; + import de.luricos.bukkit.xAuth.xAuth; import de.luricos.bukkit.xAuth.xAuthPlayer; @@ -19,7 +21,7 @@ import org.bukkit.entity.Player; * * Bukkit: http://dev.bukkit.org/bukkit-plugins/xauth/ */ -public class xAuthHook implements BukkitAuthPlugin { +public class xAuthHook implements AuthPlugin { protected final xAuth xAuthPlugin = xAuth.getPlugin(); diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/NameCheckTask.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/NameCheckTask.java index 70046a90..299bbe41 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/NameCheckTask.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/NameCheckTask.java @@ -4,7 +4,7 @@ import com.comphenix.protocol.ProtocolLibrary; import com.comphenix.protocol.events.PacketEvent; import com.github.games647.fastlogin.bukkit.BukkitLoginSession; import com.github.games647.fastlogin.bukkit.FastLoginBukkit; -import com.github.games647.fastlogin.core.JoinManagement; +import com.github.games647.fastlogin.core.shared.JoinManagement; import com.github.games647.fastlogin.core.PlayerProfile; import java.util.Random; diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/ProtocolLibLoginSource.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/ProtocolLibLoginSource.java index 30ee54b9..84cb679f 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/ProtocolLibLoginSource.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/ProtocolLibLoginSource.java @@ -7,7 +7,7 @@ import com.comphenix.protocol.events.PacketContainer; import com.comphenix.protocol.events.PacketEvent; import com.comphenix.protocol.wrappers.WrappedChatComponent; import com.github.games647.fastlogin.bukkit.FastLoginBukkit; -import com.github.games647.fastlogin.core.LoginSource; +import com.github.games647.fastlogin.core.shared.LoginSource; import java.lang.reflect.InvocationTargetException; import java.net.InetSocketAddress; diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocolsupport/ProtocolLoginSource.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocolsupport/ProtocolLoginSource.java index f91f4c0a..d2e4680a 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocolsupport/ProtocolLoginSource.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocolsupport/ProtocolLoginSource.java @@ -1,6 +1,6 @@ package com.github.games647.fastlogin.bukkit.listener.protocolsupport; -import com.github.games647.fastlogin.core.LoginSource; +import com.github.games647.fastlogin.core.shared.LoginSource; import java.net.InetSocketAddress; diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocolsupport/ProtocolSupportListener.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocolsupport/ProtocolSupportListener.java index a9becf1a..b5c4c120 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocolsupport/ProtocolSupportListener.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocolsupport/ProtocolSupportListener.java @@ -2,7 +2,7 @@ package com.github.games647.fastlogin.bukkit.listener.protocolsupport; import com.github.games647.fastlogin.bukkit.BukkitLoginSession; import com.github.games647.fastlogin.bukkit.FastLoginBukkit; -import com.github.games647.fastlogin.core.JoinManagement; +import com.github.games647.fastlogin.core.shared.JoinManagement; import com.github.games647.fastlogin.core.PlayerProfile; import java.net.InetSocketAddress; diff --git a/bungee/src/main/java/com/github/games647/fastlogin/bungee/BungeeLoginSource.java b/bungee/src/main/java/com/github/games647/fastlogin/bungee/BungeeLoginSource.java index 82853a67..5111db45 100644 --- a/bungee/src/main/java/com/github/games647/fastlogin/bungee/BungeeLoginSource.java +++ b/bungee/src/main/java/com/github/games647/fastlogin/bungee/BungeeLoginSource.java @@ -1,6 +1,6 @@ package com.github.games647.fastlogin.bungee; -import com.github.games647.fastlogin.core.LoginSource; +import com.github.games647.fastlogin.core.shared.LoginSource; import java.net.InetSocketAddress; diff --git a/bungee/src/main/java/com/github/games647/fastlogin/bungee/FastLoginBungee.java b/bungee/src/main/java/com/github/games647/fastlogin/bungee/FastLoginBungee.java index 06e9bee7..f232800a 100644 --- a/bungee/src/main/java/com/github/games647/fastlogin/bungee/FastLoginBungee.java +++ b/bungee/src/main/java/com/github/games647/fastlogin/bungee/FastLoginBungee.java @@ -5,6 +5,8 @@ import com.github.games647.fastlogin.bungee.hooks.BungeeAuthPlugin; import com.github.games647.fastlogin.bungee.listener.PlayerConnectionListener; import com.github.games647.fastlogin.bungee.listener.PluginMessageListener; import com.github.games647.fastlogin.core.FastLoginCore; +import com.github.games647.fastlogin.core.shared.DefaultPasswordGenerator; +import com.github.games647.fastlogin.core.shared.PasswordGenerator; import com.google.common.cache.CacheBuilder; import com.google.common.collect.Maps; import com.google.common.collect.Sets; @@ -12,7 +14,6 @@ import com.google.common.collect.Sets; import java.io.File; import java.io.IOException; import java.util.List; -import java.util.Random; import java.util.Set; import java.util.UUID; import java.util.concurrent.ConcurrentMap; @@ -20,6 +21,7 @@ import java.util.concurrent.TimeUnit; import java.util.logging.Level; import net.md_5.bungee.api.connection.PendingConnection; +import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.plugin.Plugin; import net.md_5.bungee.config.Configuration; import net.md_5.bungee.config.ConfigurationProvider; @@ -30,14 +32,11 @@ import net.md_5.bungee.config.YamlConfiguration; */ public class FastLoginBungee extends Plugin { - private static final char[] PASSWORD_CHARACTERS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" - .toCharArray(); - private final FastLoginCore loginCore = new BungeeCore(this); private BungeeAuthPlugin bungeeAuthPlugin; private Configuration config; - private final Random random = new Random(); + private final PasswordGenerator passwordGenerator = new DefaultPasswordGenerator<>(); private final Set pendingConfirms = Sets.newHashSet(); private final ConcurrentMap session = Maps.newConcurrentMap(); @@ -86,13 +85,8 @@ public class FastLoginBungee extends Plugin { registerHook(); } - public String generateStringPassword() { - StringBuilder generatedPassword = new StringBuilder(8); - for (int i = 1; i <= 8; i++) { - generatedPassword.append(PASSWORD_CHARACTERS[random.nextInt(PASSWORD_CHARACTERS.length - 1)]); - } - - return generatedPassword.toString(); + public String generatePassword(ProxiedPlayer player) { + return passwordGenerator.getRandomPassword(player); } @Override 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 index daafa057..ff1043c3 100644 --- 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 @@ -4,53 +4,14 @@ import com.github.games647.fastlogin.core.AuthPlugin; import net.md_5.bungee.api.connection.ProxiedPlayer; /** - * Represents a supporting authentication plugin in BungeeCord/Waterfall/... servers + * @deprecated please use com.github.games647.fastlogin.core.AuthPlugin */ +@Deprecated public interface BungeeAuthPlugin extends AuthPlugin { - /** - * Login the premium (paid account) player after - * the player joined successfully a server. - * - * @param player the player that needs to be logged in - * @return if the operation was successful - */ boolean forceLogin(ProxiedPlayer player); - /** - * Checks whether an account exists for this player name. - * - * This check should check if a cracked player account exists - * so we can be sure the premium player doesn't steal the account - * of that player. - * - * This operation will be performed async while the player is - * connecting - * - * @param playerName player name - * @return if the player has an account - * @throws Exception if an error occurred - */ boolean isRegistered(String playerName) throws Exception; - /** - * Forces a register in order to protect the paid account. - * The method will be invoked after the player joined a server. - * - * After a successful registration the player should be logged - * in too. - * - * The method will be called only for premium accounts. - * So it's recommended to set additionally premium property - * if possible. - * - * If we don't register an account, cracked players - * could steal the unregistered account from the paid - * player account - * - * @param player the premium account - * @param password a strong random generated password - * @return if the operation was successful - */ boolean forceRegister(ProxiedPlayer player, String password); } diff --git a/bungee/src/main/java/com/github/games647/fastlogin/bungee/tasks/AsyncPremiumCheck.java b/bungee/src/main/java/com/github/games647/fastlogin/bungee/tasks/AsyncPremiumCheck.java index c2be8c82..d709f346 100644 --- a/bungee/src/main/java/com/github/games647/fastlogin/bungee/tasks/AsyncPremiumCheck.java +++ b/bungee/src/main/java/com/github/games647/fastlogin/bungee/tasks/AsyncPremiumCheck.java @@ -3,8 +3,8 @@ package com.github.games647.fastlogin.bungee.tasks; import com.github.games647.fastlogin.bungee.BungeeLoginSession; import com.github.games647.fastlogin.bungee.BungeeLoginSource; import com.github.games647.fastlogin.bungee.FastLoginBungee; -import com.github.games647.fastlogin.core.JoinManagement; import com.github.games647.fastlogin.core.PlayerProfile; +import com.github.games647.fastlogin.core.shared.JoinManagement; import net.md_5.bungee.api.connection.PendingConnection; import net.md_5.bungee.api.connection.ProxiedPlayer; diff --git a/bungee/src/main/java/com/github/games647/fastlogin/bungee/tasks/ForceLoginTask.java b/bungee/src/main/java/com/github/games647/fastlogin/bungee/tasks/ForceLoginTask.java index 204924b0..94b5fd20 100644 --- a/bungee/src/main/java/com/github/games647/fastlogin/bungee/tasks/ForceLoginTask.java +++ b/bungee/src/main/java/com/github/games647/fastlogin/bungee/tasks/ForceLoginTask.java @@ -81,7 +81,7 @@ public class ForceLoginTask implements Runnable { session.setAlreadyLogged(true); - String password = plugin.generateStringPassword(); + String password = plugin.generatePassword(player); if (authPlugin.forceRegister(player, password)) { //save will happen on success message from bukkit sendBukkitLoginNotification(true); diff --git a/core/src/main/java/com/github/games647/fastlogin/core/AuthPlugin.java b/core/src/main/java/com/github/games647/fastlogin/core/AuthPlugin.java index 2e09a607..3231077f 100644 --- a/core/src/main/java/com/github/games647/fastlogin/core/AuthPlugin.java +++ b/core/src/main/java/com/github/games647/fastlogin/core/AuthPlugin.java @@ -1,10 +1,59 @@ package com.github.games647.fastlogin.core; +/** + * Represents a supporting authentication plugin in BungeeCord and Bukkit/Spigot/... servers + * + * @param either org.bukkit.entity.Player for Bukkit or net.md_5.bungee.api.connection.ProxiedPlayer for BungeeCord + */ public interface AuthPlugin { + /** + * Login the premium (paid account) player after the player joined successfully the server. + * + * This operation will be performed async while the player successfully + * joined the server. + * + * @param player the player that needs to be logged in + * @return if the operation was successful + */ boolean forceLogin(T player); - boolean forceRegister(T player, String password); + /** + * Forces a register in order to protect the paid account. + * + * This operation will be performed async while the player successfully + * joined the server. + * + * After a successful registration the player should be logged + * in too. + * + * The method will be called only for premium accounts. + * So it's recommended to set additionally premium property + * if possible. + * + * Background: If we don't register an account, cracked players + * could steal the unregistered account from the paid + * player account + * + * @param player the premium account + * @param password a strong random generated password + * @return if the operation was successful + */ + boolean forceRegister(T player, String password) throws Exception; + /** + * Checks whether an account exists for this player name. + * + * This check should check if a cracked player account exists + * so we can be sure the premium player doesn't steal the account + * of that player. + * + * This operation will be performed async while the player is + * connecting. + * + * @param playerName player name + * @return if the player has an account + * @throws Exception if an error occurred + */ boolean isRegistered(String playerName) throws Exception; } diff --git a/core/src/main/java/com/github/games647/fastlogin/core/shared/DefaultPasswordGenerator.java b/core/src/main/java/com/github/games647/fastlogin/core/shared/DefaultPasswordGenerator.java new file mode 100644 index 00000000..17f324d1 --- /dev/null +++ b/core/src/main/java/com/github/games647/fastlogin/core/shared/DefaultPasswordGenerator.java @@ -0,0 +1,20 @@ +package com.github.games647.fastlogin.core.shared; + +import java.util.Random; + +public class DefaultPasswordGenerator implements PasswordGenerator { + + private final Random random = new Random(); + private static final char[] PASSWORD_CHARACTERS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" + .toCharArray(); + + @Override + public String getRandomPassword(T player) { + StringBuilder generatedPassword = new StringBuilder(8); + for (int i = 1; i <= 8; i++) { + generatedPassword.append(PASSWORD_CHARACTERS[random.nextInt(PASSWORD_CHARACTERS.length - 1)]); + } + + return generatedPassword.toString(); + } +} diff --git a/core/src/main/java/com/github/games647/fastlogin/core/JoinManagement.java b/core/src/main/java/com/github/games647/fastlogin/core/shared/JoinManagement.java similarity index 93% rename from core/src/main/java/com/github/games647/fastlogin/core/JoinManagement.java rename to core/src/main/java/com/github/games647/fastlogin/core/shared/JoinManagement.java index e925ef9d..59fba62d 100644 --- a/core/src/main/java/com/github/games647/fastlogin/core/JoinManagement.java +++ b/core/src/main/java/com/github/games647/fastlogin/core/shared/JoinManagement.java @@ -1,5 +1,9 @@ -package com.github.games647.fastlogin.core; +package com.github.games647.fastlogin.core.shared; +import com.github.games647.fastlogin.core.AuthPlugin; +import com.github.games647.fastlogin.core.FastLoginCore; +import com.github.games647.fastlogin.core.PlayerProfile; +import com.github.games647.fastlogin.core.SharedConfig; import java.util.UUID; import java.util.logging.Level; diff --git a/core/src/main/java/com/github/games647/fastlogin/core/LoginSource.java b/core/src/main/java/com/github/games647/fastlogin/core/shared/LoginSource.java similarity index 79% rename from core/src/main/java/com/github/games647/fastlogin/core/LoginSource.java rename to core/src/main/java/com/github/games647/fastlogin/core/shared/LoginSource.java index 0103b269..2bb6fb55 100644 --- a/core/src/main/java/com/github/games647/fastlogin/core/LoginSource.java +++ b/core/src/main/java/com/github/games647/fastlogin/core/shared/LoginSource.java @@ -1,4 +1,4 @@ -package com.github.games647.fastlogin.core; +package com.github.games647.fastlogin.core.shared; import java.net.InetSocketAddress; diff --git a/core/src/main/java/com/github/games647/fastlogin/core/shared/PasswordGenerator.java b/core/src/main/java/com/github/games647/fastlogin/core/shared/PasswordGenerator.java new file mode 100644 index 00000000..0400b88b --- /dev/null +++ b/core/src/main/java/com/github/games647/fastlogin/core/shared/PasswordGenerator.java @@ -0,0 +1,6 @@ +package com.github.games647.fastlogin.core.shared; + +public interface PasswordGenerator { + + String getRandomPassword(T player); +}