Skip to content

Commit

Permalink
Fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaming32 committed Aug 9, 2024
1 parent 199c41c commit 17422ef
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
8 changes: 3 additions & 5 deletions src/main/java/io/github/gaming32/worldhost/WorldHost.java
Original file line number Diff line number Diff line change
Expand Up @@ -238,17 +238,15 @@ public void onInitializeClient() {
//#endif
//$$ final var modFile = container.getModInfo().getOwningFile().getFile();
//$$ init(path -> modFile.findResource(path.split("/")));
//$$ final BiFunction<Minecraft, Screen, Screen> screenFunction =
//$$ (mc, screen) -> new WorldHostConfigScreen(screen);
//$$ container.registerExtensionPoint(
//#if MC >= 1.20.5
//$$ IConfigScreenFactory.class, screenFunction::apply
//$$ IConfigScreenFactory.class, (ignored, screen) -> new WorldHostConfigScreen(screen)
//#elseif MC >= 1.19.2
//$$ ConfigScreenHandler.ConfigScreenFactory.class,
//$$ () -> new ConfigScreenHandler.ConfigScreenFactory(screenFunction)
//$$ () -> new ConfigScreenHandler.ConfigScreenFactory((ignored, screen) -> new WorldHostConfigScreen(screen))
//#else
//$$ ConfigGuiHandler.ConfigGuiFactory.class,
//$$ () -> new ConfigGuiHandler.ConfigGuiFactory(screenFunction)
//$$ () -> new ConfigGuiHandler.ConfigGuiFactory((ignored, screen) -> new WorldHostConfigScreen(screen))
//#endif
//$$ );
//$$ }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
import com.google.common.net.HostAndPort;
import com.mojang.authlib.exceptions.AuthenticationException;
import com.mojang.authlib.exceptions.AuthenticationUnavailableException;
import com.mojang.authlib.exceptions.ForcedUsernameChangeException;
import com.mojang.authlib.exceptions.InsufficientPrivilegesException;
import com.mojang.authlib.exceptions.InvalidCredentialsException;
import com.mojang.authlib.exceptions.UserBannedException;
import io.github.gaming32.worldhost.WorldHost;
import io.github.gaming32.worldhost.protocol.proxy.ProxyPassthrough;
import io.github.gaming32.worldhost.protocol.punch.PunchCookie;
Expand Down Expand Up @@ -45,6 +43,14 @@
//$$ import com.mojang.authlib.GameProfile;
//#endif

//#if MC >= 1.20.2
import com.mojang.authlib.exceptions.ForcedUsernameChangeException;
//#endif

//#if MC >= 1.19.1
import com.mojang.authlib.exceptions.UserBannedException;
//#endif

public final class ProtocolClient implements AutoCloseable, ProxyPassthrough {
private static final Thread.Builder CONNECTION_THREAD_BUILDER = Thread.ofVirtual().name("WH-ConnectionThread-", 1);
private static final Thread.Builder SEND_THREAD_BUILDER = Thread.ofVirtual().name("WH-SendThread-", 1);
Expand Down Expand Up @@ -297,9 +303,17 @@ private static String authenticateServer(
return I18n.get("disconnect.loginFailedInfo.invalidSession");
} catch (InsufficientPrivilegesException e) {
return I18n.get("disconnect.loginFailedInfo.insufficientPrivileges");
} catch (ForcedUsernameChangeException | UserBannedException e) {
return I18n.get("disconnect.loginFailedInfo.userBanned");
} catch (AuthenticationException e) {
//#if MC >= 1.19.1
if (
//#if MC >= 1.20.2
e instanceof ForcedUsernameChangeException ||
//#endif
e instanceof UserBannedException
) {
return I18n.get("disconnect.loginFailedInfo.userBanned");
}
//#endif
return e.getMessage();
}
}
Expand Down

0 comments on commit 17422ef

Please sign in to comment.