Skip to content

Commit

Permalink
don't let join without roles if disabled other options
Browse files Browse the repository at this point in the history
  • Loading branch information
MeiNanziiii committed Nov 19, 2024
1 parent e74e562 commit eba8a1e
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public abstract class ServerLoginNetworkHandlerMixin {

@Inject(method = "onHello", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/MinecraftServer;isOnlineMode()Z"), cancellable = true)
public void minekord$replaceUuid(LoginHelloC2SPacket loginHelloC2SPacket, CallbackInfo ci) {
if (MinekordConfig.Auth.INSTANCE.getSnowflakeBasedUuid() || MinekordConfig.Auth.INSTANCE.getIpBasedLogin()) {
if (MinekordConfig.Auth.INSTANCE.getSnowflakeBasedUuid() || MinekordConfig.Auth.INSTANCE.getIpBasedLogin() || !MinekordConfig.Auth.INSTANCE.getRequiredRoles().isEmpty()) {
member = AuthUtils.INSTANCE.findMember(loginHelloC2SPacket.comp_765());
}

Expand Down Expand Up @@ -96,6 +96,11 @@ public abstract class ServerLoginNetworkHandlerMixin {
}
}
}

if (!MinekordConfig.Auth.INSTANCE.getRequiredRoles().isEmpty() && member == null) {
this.disconnect(Text.translatable("multiplayer.disconnect.unverified_username"));
ci.cancel();
}
}

@Inject(method = "onKey", at = @At(value = "INVOKE", target = "Ljava/lang/Thread;setUncaughtExceptionHandler(Ljava/lang/Thread$UncaughtExceptionHandler;)V"), cancellable = true)
Expand All @@ -104,6 +109,7 @@ public abstract class ServerLoginNetworkHandlerMixin {
Thread thread = new Thread("Minekord User Authenticator #" + NEXT_AUTHENTICATOR_THREAD_ID.incrementAndGet()) {
public void run() {
GameProfile gameProfile = ServerLoginNetworkHandlerMixin.this.profile;
assert gameProfile != null;

if (member == null) {
member = AuthUtils.INSTANCE.findMember(gameProfile.getName());
Expand Down

0 comments on commit eba8a1e

Please sign in to comment.