proxies) {
return new MojangApiBukkit(logger, addresses, requests, proxies);
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 28d344e1..cebe9efe 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,12 +1,10 @@
package com.github.games647.fastlogin.bukkit.hooks;
-import com.github.games647.fastlogin.bukkit.FastLoginBukkit;
import com.github.games647.fastlogin.core.hooks.AuthPlugin;
import fr.xephi.authme.api.v3.AuthMeApi;
import org.bukkit.entity.Player;
-import org.bukkit.event.Listener;
/**
* GitHub: https://github.com/Xephi/AuthMeReloaded/
@@ -17,23 +15,16 @@ import org.bukkit.event.Listener;
*
* Spigot: https://www.spigotmc.org/resources/authme-reloaded.6269/
*/
-public class AuthMeHook implements AuthPlugin, Listener {
-
- private final FastLoginBukkit plugin;
-
- public AuthMeHook(FastLoginBukkit plugin) {
- this.plugin = plugin;
- }
+public class AuthMeHook implements AuthPlugin {
@Override
public boolean forceLogin(Player player) {
//skips registration and login
if (AuthMeApi.getInstance().isAuthenticated(player)) {
return false;
- } else {
- AuthMeApi.getInstance().forceLogin(player);
}
+ AuthMeApi.getInstance().forceLogin(player);
return true;
}
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 3d701035..1aa80553 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
@@ -8,6 +8,7 @@ import com.github.games647.fastlogin.core.messages.ChannelMessage;
import com.github.games647.fastlogin.core.mojang.MojangApiConnector;
import com.github.games647.fastlogin.core.shared.FastLoginCore;
import com.github.games647.fastlogin.core.shared.PlatformPlugin;
+import com.google.common.collect.MapMaker;
import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
import com.google.common.net.HostAndPort;
@@ -15,7 +16,6 @@ import com.google.common.util.concurrent.ThreadFactoryBuilder;
import java.nio.file.Path;
import java.util.List;
-import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ThreadFactory;
@@ -34,7 +34,7 @@ import org.slf4j.Logger;
*/
public class FastLoginBungee extends Plugin implements PlatformPlugin {
- private final ConcurrentMap session = new ConcurrentHashMap<>();
+ private final ConcurrentMap session = new MapMaker().weakKeys().makeMap();
private FastLoginCore core;
private Logger logger;
diff --git a/bungee/src/main/java/com/github/games647/fastlogin/bungee/listener/ConnectListener.java b/bungee/src/main/java/com/github/games647/fastlogin/bungee/listener/ConnectListener.java
index 099d3b8d..e676356b 100644
--- a/bungee/src/main/java/com/github/games647/fastlogin/bungee/listener/ConnectListener.java
+++ b/bungee/src/main/java/com/github/games647/fastlogin/bungee/listener/ConnectListener.java
@@ -3,8 +3,8 @@ 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.mojang.UUIDTypeAdapter;
import com.github.games647.fastlogin.core.shared.LoginSession;
import java.lang.reflect.Field;
@@ -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 = CommonUtil.getOfflineUUID(username);
+ UUID offlineUUID = UUIDTypeAdapter.getOfflineUUID(username);
//bungeecord doesn't support overriding the premium uuid
//so we have to do it with reflection
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 b787f730..3521b0ee 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
@@ -4,6 +4,7 @@ import com.github.games647.fastlogin.bungee.BungeeLoginSession;
import com.github.games647.fastlogin.bungee.FastLoginBungee;
import com.github.games647.fastlogin.core.messages.ChannelMessage;
import com.github.games647.fastlogin.core.messages.ForceActionMessage;
+import com.github.games647.fastlogin.core.messages.ForceActionMessage.Type;
import com.github.games647.fastlogin.core.shared.FastLoginCore;
import com.github.games647.fastlogin.core.shared.ForceLoginManagement;
import com.github.games647.fastlogin.core.shared.LoginSession;
@@ -59,9 +60,9 @@ public class ForceLoginTask
@Override
public void onForceActionSuccess(LoginSession session) {
//sub channel name
- String type = "AUTO_LOGIN";
+ Type type = Type.LOGIN;
if (session.needsRegistration()) {
- type = "AUTO_REGISTER";
+ type = Type.LOGIN;
}
UUID proxyId = UUID.fromString(ProxyServer.getInstance().getConfig().getUuid());
diff --git a/core/src/main/java/com/github/games647/fastlogin/core/AuthStorage.java b/core/src/main/java/com/github/games647/fastlogin/core/AuthStorage.java
index 657a34e8..ff16f999 100644
--- a/core/src/main/java/com/github/games647/fastlogin/core/AuthStorage.java
+++ b/core/src/main/java/com/github/games647/fastlogin/core/AuthStorage.java
@@ -1,5 +1,6 @@
package com.github.games647.fastlogin.core;
+import com.github.games647.fastlogin.core.mojang.UUIDTypeAdapter;
import com.github.games647.fastlogin.core.shared.FastLoginCore;
import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
@@ -35,6 +36,8 @@ public class AuthStorage {
this.core = core;
HikariConfig config = new HikariConfig();
+ config.setPoolName(core.getPlugin().getName());
+
config.setUsername(user);
config.setPassword(pass);
config.setDriverClassName(driver);
@@ -97,7 +100,7 @@ public class AuthStorage {
if (resultSet.next()) {
long userId = resultSet.getInt(1);
- UUID uuid = CommonUtil.parseId(resultSet.getString(2));
+ UUID uuid = UUIDTypeAdapter.parseId(resultSet.getString(2));
boolean premium = resultSet.getBoolean(4);
String lastIp = resultSet.getString(5);
@@ -117,7 +120,7 @@ public class AuthStorage {
public PlayerProfile loadProfile(UUID uuid) {
try (Connection con = dataSource.getConnection();
PreparedStatement loadStmt = con.prepareStatement(LOAD_BY_UUID)) {
- loadStmt.setString(1, CommonUtil.toMojangId(uuid));
+ loadStmt.setString(1, UUIDTypeAdapter.toMojangId(uuid));
try (ResultSet resultSet = loadStmt.executeQuery()) {
if (resultSet.next()) {
@@ -146,7 +149,7 @@ public class AuthStorage {
if (uuid == null) {
saveStmt.setString(1, null);
} else {
- saveStmt.setString(1, CommonUtil.toMojangId(uuid));
+ saveStmt.setString(1, UUIDTypeAdapter.toMojangId(uuid));
}
saveStmt.setString(2, playerProfile.getPlayerName());
@@ -166,7 +169,7 @@ public class AuthStorage {
if (uuid == null) {
saveStmt.setString(1, null);
} else {
- saveStmt.setString(1, CommonUtil.toMojangId(uuid));
+ saveStmt.setString(1, UUIDTypeAdapter.toMojangId(uuid));
}
saveStmt.setString(2, playerProfile.getPlayerName());
diff --git a/core/src/main/java/com/github/games647/fastlogin/core/CommonUtil.java b/core/src/main/java/com/github/games647/fastlogin/core/CommonUtil.java
index d766f828..d7e51b78 100644
--- a/core/src/main/java/com/github/games647/fastlogin/core/CommonUtil.java
+++ b/core/src/main/java/com/github/games647/fastlogin/core/CommonUtil.java
@@ -3,12 +3,9 @@ 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;
import java.util.logging.Level;
-import java.util.regex.Pattern;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -16,8 +13,6 @@ import org.slf4j.impl.JDK14LoggerAdapter;
public class CommonUtil {
- private static final Pattern UUID_PATTERN = Pattern.compile("(\\w{8})(\\w{4})(\\w{4})(\\w{4})(\\w{12})");
-
private static final char COLOR_CHAR = '&';
private static final char TRANSLATED_CHAR = 'ยง';
@@ -37,18 +32,6 @@ public class CommonUtil {
}));
}
- public static UUID parseId(String withoutDashes) {
- return UUID.fromString(UUID_PATTERN.matcher(withoutDashes).replaceAll("$1-$2-$3-$4-$5"));
- }
-
- public static String toMojangId(UUID uuid) {
- 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++) {
diff --git a/core/src/main/java/com/github/games647/fastlogin/core/hooks/AuthPlugin.java b/core/src/main/java/com/github/games647/fastlogin/core/hooks/AuthPlugin.java
index 84f30580..dfbcead2 100644
--- a/core/src/main/java/com/github/games647/fastlogin/core/hooks/AuthPlugin.java
+++ b/core/src/main/java/com/github/games647/fastlogin/core/hooks/AuthPlugin.java
@@ -3,7 +3,7 @@ package com.github.games647.fastlogin.core.hooks;
/**
* Represents a supporting authentication plugin in BungeeCord and Bukkit/Spigot/... servers
*
- * @param either org.bukkit.entity.GameProfile for Bukkit or net.md_5.bungee.api.connection.ProxiedPlayer
+ * @param
either {@link org.bukkit.entity.Player} for Bukkit or {@link net.md_5.bungee.api.connection.ProxiedPlayer}
* for BungeeCord
*/
public interface AuthPlugin
{
diff --git a/core/src/main/java/com/github/games647/fastlogin/core/mojang/GameProfile.java b/core/src/main/java/com/github/games647/fastlogin/core/mojang/GameProfile.java
index c15699c1..5f03f522 100644
--- a/core/src/main/java/com/github/games647/fastlogin/core/mojang/GameProfile.java
+++ b/core/src/main/java/com/github/games647/fastlogin/core/mojang/GameProfile.java
@@ -7,6 +7,15 @@ public class GameProfile {
private UUID id;
private String name;
+ public GameProfile(UUID id, String name) {
+ this.id = id;
+ this.name = name;
+ }
+
+ public GameProfile() {
+ //gson
+ }
+
public UUID getId() {
return id;
}
diff --git a/core/src/main/java/com/github/games647/fastlogin/core/mojang/MojangApiConnector.java b/core/src/main/java/com/github/games647/fastlogin/core/mojang/MojangApiConnector.java
index 71e6313e..7f6761a9 100644
--- a/core/src/main/java/com/github/games647/fastlogin/core/mojang/MojangApiConnector.java
+++ b/core/src/main/java/com/github/games647/fastlogin/core/mojang/MojangApiConnector.java
@@ -30,6 +30,7 @@ import java.util.Optional;
import java.util.Set;
import java.util.UUID;
import java.util.regex.Pattern;
+import java.util.stream.Collectors;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLSocketFactory;
@@ -98,8 +99,8 @@ public class MojangApiConnector {
if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) {
try (BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()))) {
- String line = reader.readLine();
- return Optional.of(getUUIDFromJson(line));
+ String content = reader.lines().collect(Collectors.joining());
+ return Optional.of(getUUIDFromJson(content));
}
} else if (connection.getResponseCode() == RATE_LIMIT_CODE) {
logger.info("Mojang's rate-limit reached. The public IPv4 address of this server issued more than 600" +
diff --git a/core/src/main/java/com/github/games647/fastlogin/core/mojang/UUIDTypeAdapter.java b/core/src/main/java/com/github/games647/fastlogin/core/mojang/UUIDTypeAdapter.java
index ec12074f..07f782d8 100644
--- a/core/src/main/java/com/github/games647/fastlogin/core/mojang/UUIDTypeAdapter.java
+++ b/core/src/main/java/com/github/games647/fastlogin/core/mojang/UUIDTypeAdapter.java
@@ -1,21 +1,36 @@
package com.github.games647.fastlogin.core.mojang;
-import com.github.games647.fastlogin.core.CommonUtil;
import com.google.gson.TypeAdapter;
import com.google.gson.internal.bind.TypeAdapters;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;
+import java.nio.charset.StandardCharsets;
import java.util.UUID;
+import java.util.regex.Pattern;
public class UUIDTypeAdapter extends TypeAdapter {
+ private static final Pattern UUID_PATTERN = Pattern.compile("(\\w{8})(\\w{4})(\\w{4})(\\w{4})(\\w{12})");
+
+ public static UUID parseId(String withoutDashes) {
+ return UUID.fromString(UUID_PATTERN.matcher(withoutDashes).replaceAll("$1-$2-$3-$4-$5"));
+ }
+
+ public static String toMojangId(UUID uuid) {
+ return uuid.toString().replace("-", "");
+ }
+
+ public static UUID getOfflineUUID(String playerName) {
+ return UUID.nameUUIDFromBytes(("OfflinePlayer:" + playerName).getBytes(StandardCharsets.UTF_8));
+ }
+
public void write(JsonWriter out, UUID value) throws IOException {
- TypeAdapters.STRING.write(out, CommonUtil.toMojangId(value));
+ TypeAdapters.STRING.write(out, toMojangId(value));
}
public UUID read(JsonReader in) throws IOException {
- return CommonUtil.parseId(TypeAdapters.STRING.read(in));
+ return parseId(TypeAdapters.STRING.read(in));
}
}
diff --git a/core/src/main/java/com/github/games647/fastlogin/core/shared/PlatformPlugin.java b/core/src/main/java/com/github/games647/fastlogin/core/shared/PlatformPlugin.java
index 76ebf32d..71f6938f 100644
--- a/core/src/main/java/com/github/games647/fastlogin/core/shared/PlatformPlugin.java
+++ b/core/src/main/java/com/github/games647/fastlogin/core/shared/PlatformPlugin.java
@@ -19,7 +19,9 @@ public interface PlatformPlugin {
void sendMessage(C receiver, String message);
- ThreadFactory getThreadFactory();
+ default ThreadFactory getThreadFactory() {
+ return null;
+ }
MojangApiConnector makeApiConnector(List addresses, int requests, List proxies);
}
diff --git a/pom.xml b/pom.xml
index c8d05e7e..bf535fca 100644
--- a/pom.xml
+++ b/pom.xml
@@ -32,7 +32,6 @@
- install
${project.name}