diff --git a/common/src/main/java/org/samo_lego/simpleauth/mixin/MixinServerLoginNetworkHandler.java b/common/src/main/java/org/samo_lego/simpleauth/mixin/MixinServerLoginNetworkHandler.java index 353155b..398189e 100644 --- a/common/src/main/java/org/samo_lego/simpleauth/mixin/MixinServerLoginNetworkHandler.java +++ b/common/src/main/java/org/samo_lego/simpleauth/mixin/MixinServerLoginNetworkHandler.java @@ -78,9 +78,14 @@ public abstract class MixinServerLoginNetworkHandler { // Player has a Mojang account httpsURLConnection.disconnect(); - - // Caches the request - mojangAccountNamesCache.add(playername); + if (!config.main.allowExistingNames) { + // Caches the request + mojangAccountNamesCache.add(playername); + } else { + state = ServerLoginNetworkHandler.State.READY_TO_ACCEPT; + this.profile = packet.getProfile(); + ci.cancel(); + } // Authentication continues in original method } else if(response == HttpURLConnection.HTTP_NO_CONTENT) { diff --git a/common/src/main/java/org/samo_lego/simpleauth/storage/AuthConfig.java b/common/src/main/java/org/samo_lego/simpleauth/storage/AuthConfig.java index 58d2b2d..57180f5 100644 --- a/common/src/main/java/org/samo_lego/simpleauth/storage/AuthConfig.java +++ b/common/src/main/java/org/samo_lego/simpleauth/storage/AuthConfig.java @@ -162,6 +162,11 @@ public class AuthConfig { */ public boolean premiumAutologin = false; + /* + * Whether to allow offline players with registered usernames to connect. + */ + public boolean allowExistingNames = false; + /** * Contains a list of lower case (!) player names * that should always be treated as offline. diff --git a/forge/build.gradle b/forge/build.gradle index 7177955..84e8cc6 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -30,19 +30,23 @@ dependencies { // Password hashing // Argon2 - shadow "de.mkammerer:argon2-jvm:${argon2_version}" + shadowCommon ("de.mkammerer:argon2-jvm:${argon2_version}") { + exclude group: "net.java.dev.jna" + } // BCrypt - shadow "at.favre.lib:bcrypt:${bcrypt_version}" - shadow "at.favre.lib:bytes:${bytes_version}" + shadowCommon "at.favre.lib:bcrypt:${bcrypt_version}" + shadowCommon "at.favre.lib:bytes:${bytes_version}" // Storage // leveldb - shadow group: 'org.iq80.leveldb', name: 'leveldb', version: '0.12' - shadow group: 'org.iq80.leveldb', name: 'leveldb-api', version: '0.12' + shadowCommon (group: 'org.iq80.leveldb', name: 'leveldb', version: '0.12') { + exclude group: "com.google.guava" + } + shadowCommon group: 'org.iq80.leveldb', name: 'leveldb-api', version: '0.12' // JNA lib - shadow 'net.java.dev.jna:jna:5.5.0' + compileOnly 'net.java.dev.jna:jna:5.5.0' } shadowJar { diff --git a/forge/src/main/java/org/samo_lego/simpleauth/forge/SimpleAuthForge.java b/forge/src/main/java/org/samo_lego/simpleauth/SimpleAuthForge.java similarity index 96% rename from forge/src/main/java/org/samo_lego/simpleauth/forge/SimpleAuthForge.java rename to forge/src/main/java/org/samo_lego/simpleauth/SimpleAuthForge.java index c06149e..b77c0ce 100644 --- a/forge/src/main/java/org/samo_lego/simpleauth/forge/SimpleAuthForge.java +++ b/forge/src/main/java/org/samo_lego/simpleauth/SimpleAuthForge.java @@ -1,4 +1,4 @@ -package org.samo_lego.simpleauth.forge; +package org.samo_lego.simpleauth; import com.mojang.brigadier.CommandDispatcher; import net.minecraft.server.command.ServerCommandSource; diff --git a/forge/src/main/java/org/samo_lego/simpleauth/forge/event/AuthEventHandlerForge.java b/forge/src/main/java/org/samo_lego/simpleauth/event/AuthEventHandlerForge.java similarity index 98% rename from forge/src/main/java/org/samo_lego/simpleauth/forge/event/AuthEventHandlerForge.java rename to forge/src/main/java/org/samo_lego/simpleauth/event/AuthEventHandlerForge.java index 8d5270b..5b6a9b3 100644 --- a/forge/src/main/java/org/samo_lego/simpleauth/forge/event/AuthEventHandlerForge.java +++ b/forge/src/main/java/org/samo_lego/simpleauth/event/AuthEventHandlerForge.java @@ -1,4 +1,4 @@ -package org.samo_lego.simpleauth.forge.event; +package org.samo_lego.simpleauth.event; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.util.ActionResult; diff --git a/forge/src/main/java/org/samo_lego/simpleauth/forge/utils/forge/PlatformSpecificImpl.java b/forge/src/main/java/org/samo_lego/simpleauth/utils/forge/PlatformSpecificImpl.java similarity index 84% rename from forge/src/main/java/org/samo_lego/simpleauth/forge/utils/forge/PlatformSpecificImpl.java rename to forge/src/main/java/org/samo_lego/simpleauth/utils/forge/PlatformSpecificImpl.java index 810a662..7552bb9 100644 --- a/forge/src/main/java/org/samo_lego/simpleauth/forge/utils/forge/PlatformSpecificImpl.java +++ b/forge/src/main/java/org/samo_lego/simpleauth/utils/forge/PlatformSpecificImpl.java @@ -1,4 +1,4 @@ -package org.samo_lego.simpleauth.forge.utils.forge; +package org.samo_lego.simpleauth.utils.forge; import net.minecraft.entity.player.PlayerEntity;