Improved separation
This commit is contained in:
@@ -7,6 +7,7 @@ import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.saturnclient.client.player.SaturnPlayer;
|
||||
import org.saturnclient.common.provider.Providers;
|
||||
import org.saturnclient.common.ref.game.MinecraftClientRef;
|
||||
|
||||
import dev.selimaj.session.Session;
|
||||
|
||||
@@ -27,7 +28,9 @@ public class ServiceClient {
|
||||
}
|
||||
|
||||
public static boolean authenticate() {
|
||||
Providers.saturn.onClientStopping(() -> {
|
||||
MinecraftClientRef client = Providers.saturn.getClient();
|
||||
|
||||
client.onClientStopping(() -> {
|
||||
if (session != null) {
|
||||
try {
|
||||
session.close();
|
||||
@@ -38,9 +41,9 @@ public class ServiceClient {
|
||||
});
|
||||
|
||||
try {
|
||||
String accessToken = Providers.saturn.getAccessToken();
|
||||
uuid = Providers.saturn.getUuid();
|
||||
String username = Providers.saturn.getUsername();
|
||||
String accessToken = client.getAccessToken();
|
||||
uuid = client.getUuid();
|
||||
String username = client.getUsername();
|
||||
|
||||
if (accessToken == null || uuid == null || username == null) {
|
||||
Providers.saturn.logError("No active Minecraft session found");
|
||||
|
||||
@@ -11,21 +11,11 @@ public interface SaturnProvider {
|
||||
|
||||
public void playEmote(UUID fromPlayerUuid, String emoteIdOrNull);
|
||||
|
||||
public String getAccessToken();
|
||||
|
||||
public UUID getUuid();
|
||||
|
||||
public String getUsername();
|
||||
|
||||
public void onClientStopping(Runnable handler);
|
||||
|
||||
public void logInfo(String message);
|
||||
|
||||
public void logError(String message);
|
||||
|
||||
public void logError(String message, Throwable throwable);
|
||||
|
||||
public void stop();
|
||||
|
||||
public void registerBufferedImageTexture(IdentifierRef i, BufferedImage bi);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.saturnclient.common.ref.game;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.saturnclient.common.ref.asset.IdentifierRef;
|
||||
import org.saturnclient.common.ref.render.WindowRef;
|
||||
@@ -23,4 +24,14 @@ public interface MinecraftClientRef {
|
||||
public void setScreen(SaturnScreen screen);
|
||||
|
||||
public void setScreen(MinecraftScreen screen);
|
||||
|
||||
public String getAccessToken();
|
||||
|
||||
public UUID getUuid();
|
||||
|
||||
public String getUsername();
|
||||
|
||||
public void onClientStopping(Runnable handler);
|
||||
|
||||
public void scheduleStop();
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ public class TitleMenu extends SaturnScreen {
|
||||
.animation(new SlideFade(AnimationConfig.mainMenu, -10)));
|
||||
|
||||
mainButtonStagger.draw(new Button("QUIT", () -> {
|
||||
Providers.saturn.stop();
|
||||
Providers.saturn.getClient().scheduleStop();
|
||||
}).scale(0.69f).dimensions(206, 52).position(146, 80)
|
||||
.animation(new SlideFade(AnimationConfig.mainMenu, -10)));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user