Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2cfd93c197 | ||
|
|
1ddfd9d024 | ||
|
|
5e44a71054 | ||
|
|
5dd4b17db5 | ||
|
|
3379acef80 |
@@ -2,6 +2,7 @@ package org.saturnclient.client;
|
|||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
import org.saturnclient.client.player.SaturnPlayer;
|
import org.saturnclient.client.player.SaturnPlayer;
|
||||||
import org.saturnclient.common.provider.Providers;
|
import org.saturnclient.common.provider.Providers;
|
||||||
@@ -15,16 +16,48 @@ public class ServiceClient {
|
|||||||
private static Session session;
|
private static Session session;
|
||||||
public static UUID uuid;
|
public static UUID uuid;
|
||||||
|
|
||||||
|
public static void initialize() {
|
||||||
|
new Thread(() -> {
|
||||||
|
if (authenticate()) {
|
||||||
|
Cloaks.initialize();
|
||||||
|
Hats.initialize();
|
||||||
|
Providers.saturn.logInfo("Saturn Session initialization complete");
|
||||||
|
} else {
|
||||||
|
Providers.saturn.logError("Failed to authenticate with the server");
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean connectTimeout() {
|
public static boolean connectTimeout() {
|
||||||
try {
|
try {
|
||||||
session = Session.connect("wss://saturn-server.selimaj.dev", 10, TimeUnit.SECONDS);
|
session = Session.connect("wss://saturn-server.selimaj.dev", 2, TimeUnit.MINUTES);
|
||||||
return true;
|
return true;
|
||||||
|
} catch (TimeoutException e) {
|
||||||
|
System.out.println("Session Server timeout");
|
||||||
|
return false;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean connectMultiTimeout() {
|
||||||
|
for (int i = 0; i < 5; i++) {
|
||||||
|
if (connectTimeout()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Providers.saturn.logError("Failed to authenticate (attempt " + (i + 1) + ")");
|
||||||
|
|
||||||
|
try {
|
||||||
|
Thread.sleep(500);
|
||||||
|
} catch (InterruptedException ignored) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean authenticate() {
|
public static boolean authenticate() {
|
||||||
MinecraftClientRef client = Providers.saturn.getClient();
|
MinecraftClientRef client = Providers.saturn.getClient();
|
||||||
|
|
||||||
@@ -50,7 +83,7 @@ public class ServiceClient {
|
|||||||
|
|
||||||
Providers.saturn.logInfo("Authenticating with UUID: " + uuid);
|
Providers.saturn.logInfo("Authenticating with UUID: " + uuid);
|
||||||
|
|
||||||
if (!connectTimeout()) {
|
if (!connectMultiTimeout()) {
|
||||||
Providers.saturn.logError("Unable to authenticate: Session Server Timeout");
|
Providers.saturn.logError("Unable to authenticate: Session Server Timeout");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package org.saturnclient.common.ref.game;
|
package org.saturnclient.common.ref.game;
|
||||||
|
|
||||||
|
import org.saturnclient.common.ref.asset.IdentifierRef;
|
||||||
import org.saturnclient.common.ref.asset.SpriteRef;
|
import org.saturnclient.common.ref.asset.SpriteRef;
|
||||||
|
|
||||||
public interface EffectRef {
|
public interface EffectRef {
|
||||||
@@ -7,6 +8,10 @@ public interface EffectRef {
|
|||||||
|
|
||||||
SpriteRef getIcon();
|
SpriteRef getIcon();
|
||||||
|
|
||||||
|
default IdentifierRef getIconId() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
boolean isInfinite();
|
boolean isInfinite();
|
||||||
|
|
||||||
String getInfiniteText();
|
String getInfiniteText();
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import java.util.List;
|
|||||||
|
|
||||||
import org.saturnclient.common.provider.FeatureProvider;
|
import org.saturnclient.common.provider.FeatureProvider;
|
||||||
import org.saturnclient.common.provider.Providers;
|
import org.saturnclient.common.provider.Providers;
|
||||||
|
import org.saturnclient.common.ref.asset.SpriteRef;
|
||||||
import org.saturnclient.common.ref.game.EffectRef;
|
import org.saturnclient.common.ref.game.EffectRef;
|
||||||
import org.saturnclient.config.property.BoolProperty;
|
import org.saturnclient.config.property.BoolProperty;
|
||||||
import org.saturnclient.config.property.Property;
|
import org.saturnclient.config.property.Property;
|
||||||
@@ -63,7 +64,12 @@ public class StatusEffectsMod extends Mod implements HudMod {
|
|||||||
if (!effect.shouldShowIcon())
|
if (!effect.shouldShowIcon())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
scope.drawSpriteStretched(effect.getIcon(), 0, 18 * row, 16, 16);
|
SpriteRef sprite = effect.getIcon();
|
||||||
|
if (sprite == null) {
|
||||||
|
scope.drawTexture(effect.getIconId(), 0, 18 * row, 0, 0, 16, 16);
|
||||||
|
} else {
|
||||||
|
scope.drawSpriteStretched(sprite, 0, 18 * row, 16, 16);
|
||||||
|
}
|
||||||
scope.drawText(0.5f, durationString(effect),
|
scope.drawText(0.5f, durationString(effect),
|
||||||
18, 18 * row + 3,
|
18, 18 * row + 3,
|
||||||
layout.font.value, -1);
|
layout.font.value, -1);
|
||||||
|
|||||||
@@ -64,19 +64,18 @@ public abstract class Input extends Element {
|
|||||||
public void render(RenderScope renderScope, ElementContext ctx) {
|
public void render(RenderScope renderScope, ElementContext ctx) {
|
||||||
checkReset();
|
checkReset();
|
||||||
|
|
||||||
renderScope.drawRoundedRectangle(0, 0, width, height, 10, 0xFF000000);
|
renderScope.drawRoundedRectangle(0, 0, width, height, 10, Theme.PRIMARY.value);
|
||||||
|
|
||||||
int scrollOffset = getScrollOffset();
|
int scrollOffset = getScrollOffset();
|
||||||
String visibleText = getVisibleText(scrollOffset);
|
String visibleText = getVisibleText(scrollOffset);
|
||||||
int textColor = focused ? 0xFFFFFF : 0xAAAAAA;
|
renderScope.drawText(0.6f, visibleText, 4, 4, Theme.FONT.value, Theme.PRIMARY_FG.value);
|
||||||
renderScope.drawText(0.6f, visibleText, 4, 4, Theme.FONT.value, textColor);
|
|
||||||
|
|
||||||
if (focused) {
|
if (focused) {
|
||||||
int cursorX = 4 +
|
int cursorX = 4 +
|
||||||
(int) (Fonts.getWidth(visibleText.substring(0, cursorPosition - scrollOffset), Theme.FONT.value)
|
(int) (Fonts.getWidth(visibleText.substring(0, cursorPosition - scrollOffset), Theme.FONT.value)
|
||||||
* 0.6f);
|
* 0.6f);
|
||||||
|
|
||||||
renderScope.drawRectangle(cursorX, 2, 1, height - 4, 0xFFFFFFFF);
|
renderScope.drawRectangle(cursorX, 2, 1, height - 4, Theme.ACCENT.value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user