Add driver available check for more readable error messages

This commit is contained in:
games647
2018-02-22 17:57:03 +01:00
parent 48c2355745
commit 04b00f4f22
18 changed files with 51 additions and 25 deletions

View File

@ -80,7 +80,7 @@
<url>https://ci.codemc.org/plugin/repository/everything/</url>
</repository>
<!--Github automatic maven builds-->
<!--GitHub automatic maven builds-->
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>

View File

@ -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
*/

View File

@ -56,7 +56,7 @@ public class FastLoginBukkit extends JavaPlugin implements PlatformPlugin<Comman
} catch (ClassNotFoundException notFoundEx) {
//ignore server has no bungee support
} catch (Exception ex) {
logger.warn("Cannot check bungeecord support. You use a non-spigot build", ex);
logger.warn("Cannot check bungeecord support. You use a non-Spigot build", ex);
}
if (getServer().getOnlineMode()) {

View File

@ -19,7 +19,7 @@ import org.slf4j.Logger;
public class MojangApiBukkit extends MojangApiConnector {
//mojang api check to prove a player is logged in minecraft and made a join server request
//mojang api check to prove a player is logged in Minecraft and made a join server request
private static final String HAS_JOINED_URL = "https://sessionserver.mojang.com/session/minecraft/hasJoined?" +
"username=%s&serverId=%s&ip=%s";

View File

@ -9,7 +9,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
/**
* Github: https://github.com/Xephi/AuthMeReloaded/
* GitHub: https://github.com/Xephi/AuthMeReloaded/
* <p>
* Project page:
* <p>

View File

@ -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
* <p>
* Project page:
* <p>

View File

@ -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
* <p>
* Project page:
* <p>

View File

@ -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
* <p>
* Project page:
* <p>
* Bukkit: https://dev.bukkit.org/bukkit-plugins/loginsecurity/
* <p>

View File

@ -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/
* <p>
* Project page:
* <p>

View File

@ -43,7 +43,7 @@ public class NameCheckTask extends JoinManagement<Player, CommandSender, Protoco
}
}
//minecraft server implementation
//Minecraft server implementation
//https://github.com/bergerkiller/CraftSource/blob/master/net.minecraft.server/LoginListener.java#L161
@Override
public void requestPremiumLogin(ProtocolLibLoginSource source, PlayerProfile profile

View File

@ -31,7 +31,7 @@ public class SkinApplyListener implements Listener {
}
@EventHandler(priority = EventPriority.LOW)
//run this on the loginEvent to let skins plugins see the skin like in normal minecraft behaviour
//run this on the loginEvent to let skins plugins see the skin like in normal Minecraft behaviour
public void onPlayerLogin(PlayerLoginEvent loginEvent) {
if (loginEvent.getResult() != Result.ALLOWED) {
return;

View File

@ -8,7 +8,7 @@ import me.vik1395.BungeeAuthAPI.RequestHandler;
import net.md_5.bungee.api.connection.ProxiedPlayer;
/**
* Github: https://github.com/vik1395/BungeeAuth-Minecraft
* GitHub: https://github.com/vik1395/BungeeAuth-Minecraft
*
* Project page:
*

View File

@ -3,11 +3,11 @@ package com.github.games647.fastlogin.bungee.listener;
import com.github.games647.fastlogin.bungee.FastLoginBungee;
import com.github.games647.fastlogin.bungee.tasks.AsyncPremiumCheck;
import com.github.games647.fastlogin.bungee.tasks.ForceLoginTask;
import com.github.games647.fastlogin.core.CommonUtil;
import com.github.games647.fastlogin.core.PlayerProfile;
import com.github.games647.fastlogin.core.shared.LoginSession;
import java.lang.reflect.Field;
import java.nio.charset.StandardCharsets;
import java.util.UUID;
import net.md_5.bungee.api.ProxyServer;
@ -73,7 +73,7 @@ public class ConnectListener implements Listener {
//bungeecord will do this automatically so override it on disabled option
if (!plugin.getCore().getConfig().get("premiumUuid", true)) {
try {
UUID offlineUUID = UUID.nameUUIDFromBytes(("OfflinePlayer:" + username).getBytes(StandardCharsets.UTF_8));
UUID offlineUUID = CommonUtil.getOfflineUUID(username);
//bungeecord doesn't support overriding the premium uuid
//so we have to do it with reflection

View File

@ -3,6 +3,7 @@ package com.github.games647.fastlogin.core;
import com.google.common.cache.CacheLoader;
import java.lang.reflect.Constructor;
import java.nio.charset.StandardCharsets;
import java.util.UUID;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.TimeUnit;
@ -44,6 +45,10 @@ public class CommonUtil {
return uuid.toString().replace("-", "");
}
public static UUID getOfflineUUID(String playerName) {
return UUID.nameUUIDFromBytes(("OfflinePlayer:" + playerName).getBytes(StandardCharsets.UTF_8));
}
public static String translateColorCodes(String rawMessage) {
char[] chars = rawMessage.toCharArray();
for (int i = 0; i < chars.length - 1; i++) {

View File

@ -106,7 +106,7 @@ public class MojangApiConnector {
" Name -> 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);

View File

@ -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<P extends C, C, T extends PlatformPlugin<C>> {
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<P extends C, C, T extends PlatformPlugin<C>> {
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<P extends C, C, T extends PlatformPlugin<C>> {
}
}
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;
}

View File

@ -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

View File

@ -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 ================================