From 04b00f4f22f5e8722468241fb77c72f54d59a938 Mon Sep 17 00:00:00 2001 From: games647 Date: Thu, 22 Feb 2018 17:57:03 +0100 Subject: [PATCH] Add driver available check for more readable error messages --- bukkit/pom.xml | 2 +- .../fastlogin/bukkit/EncryptionUtil.java | 2 +- .../fastlogin/bukkit/FastLoginBukkit.java | 2 +- .../fastlogin/bukkit/MojangApiBukkit.java | 2 +- .../fastlogin/bukkit/hooks/AuthMeHook.java | 2 +- .../bukkit/hooks/CrazyLoginHook.java | 2 +- .../fastlogin/bukkit/hooks/LogItHook.java | 2 +- .../bukkit/hooks/LoginSecurityHook.java | 4 ++- .../fastlogin/bukkit/hooks/xAuthHook.java | 2 +- .../listener/protocollib/NameCheckTask.java | 2 +- .../protocollib/SkinApplyListener.java | 2 +- .../bungee/hooks/BungeeAuthHook.java | 2 +- .../bungee/listener/ConnectListener.java | 4 +-- .../games647/fastlogin/core/CommonUtil.java | 5 ++++ .../core/mojang/MojangApiConnector.java | 2 +- .../fastlogin/core/shared/FastLoginCore.java | 25 ++++++++++++++++--- core/src/main/resources/config.yml | 8 +++--- core/src/main/resources/messages.yml | 6 ++--- 18 files changed, 51 insertions(+), 25 deletions(-) diff --git a/bukkit/pom.xml b/bukkit/pom.xml index 64da07db..bc126619 100644 --- a/bukkit/pom.xml +++ b/bukkit/pom.xml @@ -80,7 +80,7 @@ https://ci.codemc.org/plugin/repository/everything/ - + jitpack.io https://jitpack.io diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/EncryptionUtil.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/EncryptionUtil.java index 35d84854..2a29a628 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/EncryptionUtil.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/EncryptionUtil.java @@ -18,7 +18,7 @@ import javax.crypto.spec.SecretKeySpec; /** * Encryption and decryption minecraft util for connection between servers - * and paid minecraft account clients. + * and paid Minecraft account clients. * * @see net.minecraft.server.MinecraftEncryption */ 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 480e6d81..12563bc6 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 @@ -56,7 +56,7 @@ public class FastLoginBukkit extends JavaPlugin implements PlatformPlugin * Project page: *

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 3f9ec69d..71938f87 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 @@ -19,7 +19,7 @@ import org.bukkit.Bukkit; import org.bukkit.entity.Player; /** - * Github: https://github.com/ST-DDT/CrazyLogin + * GitHub: https://github.com/ST-DDT/CrazyLogin *

* Project page: *

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 3605948b..b8fc6230 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 @@ -12,7 +12,7 @@ import java.time.Instant; import org.bukkit.entity.Player; /** - * Github: https://github.com/XziomekX/LogIt + * GitHub: https://github.com/XziomekX/LogIt *

* Project page: *

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 53eabab7..fb51158e 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 @@ -11,7 +11,9 @@ import com.lenis0012.bukkit.loginsecurity.session.action.RegisterAction; import org.bukkit.entity.Player; /** - * Github: https://github.com/lenis0012/LoginSecurity-2 Project page: + * GitHub: https://github.com/lenis0012/LoginSecurity-2 + *

+ * Project page: *

* Bukkit: https://dev.bukkit.org/bukkit-plugins/loginsecurity/ *

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 c18839e9..f2febb00 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 @@ -14,7 +14,7 @@ import org.bukkit.Bukkit; import org.bukkit.entity.Player; /** - * Github: https://github.com/LycanDevelopment/xAuth/ + * GitHub: https://github.com/LycanDevelopment/xAuth/ *

* Project page: *

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 a21e7f80..714b31f6 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 @@ -43,7 +43,7 @@ public class NameCheckTask extends JoinManagement UUID requests within 10 minutes. Once those 10 minutes ended we could make requests" + " again. In the meanwhile new skins can only be downloaded using the UUID directly." + " If you are using BungeeCord, consider adding a caching server in order to prevent multiple" + - " spigot servers creating the same requests against Mojang's servers."); + " Spigot servers creating the same requests against Mojang's servers."); lastRateLimit = Instant.now(); if (!connection.usingProxy()) { return getPremiumUUID(playerName); diff --git a/core/src/main/java/com/github/games647/fastlogin/core/shared/FastLoginCore.java b/core/src/main/java/com/github/games647/fastlogin/core/shared/FastLoginCore.java index af862f0d..596cb705 100644 --- a/core/src/main/java/com/github/games647/fastlogin/core/shared/FastLoginCore.java +++ b/core/src/main/java/com/github/games647/fastlogin/core/shared/FastLoginCore.java @@ -8,7 +8,6 @@ import com.github.games647.fastlogin.core.hooks.PasswordGenerator; import com.github.games647.fastlogin.core.mojang.MojangApiConnector; import com.google.common.net.HostAndPort; -import java.io.File; import java.io.IOException; import java.io.InputStream; import java.nio.file.Files; @@ -27,6 +26,8 @@ import net.md_5.bungee.config.Configuration; import net.md_5.bungee.config.ConfigurationProvider; import net.md_5.bungee.config.YamlConfiguration; +import org.slf4j.Logger; + import static java.util.function.Function.identity; import static java.util.stream.Collectors.toList; import static java.util.stream.Collectors.toMap; @@ -92,8 +93,8 @@ public class FastLoginCore

> { defaults = configProvider.load(defaultStream); } - File file = plugin.getPluginFolder().resolve(fileName).toFile(); - return configProvider.load(file, defaults); + Path file = plugin.getPluginFolder().resolve(fileName); + return configProvider.load(Files.newBufferedReader(file), defaults); } public MojangApiConnector getApiConnector() { @@ -121,6 +122,10 @@ public class FastLoginCore

> { public boolean setupDatabase() { String driver = config.getString("driver"); + if (!checkDriver(driver)) { + return false; + } + String host = config.get("host", ""); int port = config.get("port", 3306); String database = config.getString("database"); @@ -140,6 +145,20 @@ public class FastLoginCore

> { } } + private boolean checkDriver(String className) { + try { + Class.forName(className); + return true; + } catch (ClassNotFoundException notFoundEx) { + Logger log = plugin.getLog(); + log.warn("This driver {} is not supported on this platform", className); + log.warn("Please choose MySQL (Spigot+BungeeCord), SQLite (Spigot+Sponge) or MariaDB (Sponge)", notFoundEx); + } + + return false; + } + + public Configuration getConfig() { return config; } diff --git a/core/src/main/resources/config.yml b/core/src/main/resources/config.yml index e62cbc19..938ef7d5 100644 --- a/core/src/main/resources/config.yml +++ b/core/src/main/resources/config.yml @@ -82,7 +82,7 @@ premiumUuid: false # # nameChangeCheck = false ----- autoRegister = true # -# We will always request a premium authentication if the username is unknown to us, but is in use by a paid minecraft +# We will always request a premium authentication if the username is unknown to us, but is in use by a paid Minecraft # account. This means it's kind of a more aggressive check like nameChangeCheck = true and autoRegister = false, because # it request a premium authentication which are completely new to us, that even the premium UUID is not in our database. # @@ -95,7 +95,7 @@ premiumUuid: false # Based on autoRegister it checks if the player name is premium and login using a premium authentication. After that # fastlogin receives the premium UUID and can update the database record. # -# **Limitation from autoRegister**: New offline players who uses the username of an existing minecraft cannot join the +# **Limitation from autoRegister**: New offline players who uses the username of an existing Minecraft cannot join the # server. nameChangeCheck: false @@ -138,7 +138,7 @@ premium-warning: true ip-addresses: [] # How many requests should be established to the Mojang API for Name -> UUID requests. Some other plugins as well -# as the head minecraft block make such requests as well. Using this option you can limit the amount requests this +# as the head Minecraft block make such requests as well. Using this option you can limit the amount requests this # plugin should make. # # If you lower this value, other plugins could still make requests while FastLogin cannot. @@ -154,7 +154,7 @@ auto-register-unknown: false # the player won't be auto logged into the account. # # This can be used as 2Factor authentication for better security of your accounts. A hacker then needs both passwords. -# The password of your minecraft and the password to login in with your auth plugin +# The password of your Minecraft and the password to login in with your auth plugin autoLogin: true # Database configuration diff --git a/core/src/main/resources/messages.yml b/core/src/main/resources/messages.yml index ba4b95df..00122be7 100644 --- a/core/src/main/resources/messages.yml +++ b/core/src/main/resources/messages.yml @@ -5,7 +5,7 @@ # You can access the newest locale here: # https://github.com/games647/FastLogin/blob/master/core/src/main/resources/messages.yml # -# You want to have language template? Visit the Github Wiki here: +# You want to have language template? Visit the GitHub Wiki here: # https://github.com/games647/FastLogin/wiki/English # In order to split a message into separate lines you could just make a new line, but keep the ' @@ -22,7 +22,7 @@ # ========= Shared (BungeeCord and Bukkit) ============ # Switch mode is activated and a new (non-whitelist) cracked player tries to join -switch-kick-message: '&4Only paid minecraft whitelisted accounts are allowed to join this server' +switch-kick-message: '&4Only paid Minecraft whitelisted accounts are allowed to join this server' # GameProfile activated premium login in order to skip offline authentication add-premium: '&2Added to the list of premium players' @@ -90,7 +90,7 @@ invalid-requst: '&4Invalid request' not-started: '&cServer is not fully started yet. Please retry' # Warning message if a user invoked /premium command -premium-warning: '&c&lWARNING: &6This command should &lonly&6 be invoked if you are the owner of this paid minecraft account +premium-warning: '&c&lWARNING: &6This command should &lonly&6 be invoked if you are the owner of this paid Minecraft account Type &a/premium&6 again to confirm' # ========= Bungee/Waterfall only ================================