Skip to content

Commit

Permalink
improve mixin
Browse files Browse the repository at this point in the history
  • Loading branch information
MeiNanziiii committed Nov 19, 2024
1 parent 3786641 commit 568513e
Showing 1 changed file with 11 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,37 +70,27 @@ public abstract class ServerLoginNetworkHandlerMixin {
public void minekord$replaceUuid(LoginHelloC2SPacket loginHelloC2SPacket, CallbackInfo ci) {
if (MinekordConfig.Auth.INSTANCE.getSnowflakeBasedUuid() || MinekordConfig.Auth.INSTANCE.getIpBasedLogin() || !MinekordConfig.Auth.INSTANCE.getRequiredRoles().isEmpty()) {
member = AuthUtils.INSTANCE.findMember(loginHelloC2SPacket.comp_765());
}

if (MinekordConfig.Auth.INSTANCE.getSnowflakeBasedUuid() && !server.isOnlineMode()) {
if (member == null) {
this.disconnect(Text.translatable("multiplayer.disconnect.unverified_username"));
ci.cancel();
} else {
this.profile = new GameProfile(AuthUtils.INSTANCE.uuidFromMember(member), loginHelloC2SPacket.comp_765());
LOGGER.info("Snowflake based UUID of player {} is {}", this.profile.getName(), this.profile.getId());
return;
}
}

if (MinekordConfig.Auth.INSTANCE.getSnowflakeBasedUuid() && !server.isOnlineMode()) {
this.profile = new GameProfile(AuthUtils.INSTANCE.uuidFromMember(member), loginHelloC2SPacket.comp_765());
LOGGER.info("Snowflake based UUID of player {} is {}", this.profile.getName(), this.profile.getId());
}

if (MinekordConfig.Auth.INSTANCE.getIpBasedLogin() && this.profile != null) {
if (member == null) {
this.disconnect(Text.translatable("multiplayer.disconnect.unverified_username"));
ci.cancel();
} else {
if (!IPCache.INSTANCE.containsInCache(this.connection.getAddress(), this.profile)) {
if (!IPCache.INSTANCE.isRequested(this.connection.getAddress(), this.profile)) {
IPCheckEvent.Companion.getEVENT().invoker().check(this.connection.getAddress(), this.profile);
}
this.disconnect(Text.literal(MinekordConfig.Messages.INSTANCE.getIpKickMessage()));
ci.cancel();
if (!IPCache.INSTANCE.containsInCache(this.connection.getAddress(), this.profile)) {
if (!IPCache.INSTANCE.isRequested(this.connection.getAddress(), this.profile)) {
IPCheckEvent.Companion.getEVENT().invoker().check(this.connection.getAddress(), this.profile);
}
this.disconnect(Text.literal(MinekordConfig.Messages.INSTANCE.getIpKickMessage()));
ci.cancel();
}
}

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 Down

0 comments on commit 568513e

Please sign in to comment.