Encrypted authentication
This commit is contained in:
@@ -5,7 +5,7 @@ import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents;
|
|||||||
import net.fabricmc.fabric.api.client.screen.v1.ScreenEvents;
|
import net.fabricmc.fabric.api.client.screen.v1.ScreenEvents;
|
||||||
import net.minecraft.client.gui.screen.TitleScreen;
|
import net.minecraft.client.gui.screen.TitleScreen;
|
||||||
|
|
||||||
import org.saturnclient.saturnclient.auth.SaturnSocket;
|
import org.saturnclient.saturnclient.auth.Auth;
|
||||||
import org.saturnclient.saturnclient.config.ConfigManager;
|
import org.saturnclient.saturnclient.config.ConfigManager;
|
||||||
import org.saturnclient.saturnclient.cosmetics.Hats;
|
import org.saturnclient.saturnclient.cosmetics.Hats;
|
||||||
import org.saturnclient.saturnclient.cosmetics.cloaks.Cloaks;
|
import org.saturnclient.saturnclient.cosmetics.cloaks.Cloaks;
|
||||||
@@ -45,7 +45,7 @@ public class SaturnClient implements ModInitializer {
|
|||||||
});
|
});
|
||||||
|
|
||||||
KeyInputHandler.register();
|
KeyInputHandler.register();
|
||||||
if (SaturnSocket.authenticate()) {
|
if (Auth.authenticate()) {
|
||||||
Cloaks.initialize();
|
Cloaks.initialize();
|
||||||
Hats.initialize();
|
Hats.initialize();
|
||||||
LOGGER.info(MOD_ID + " initialization complete");
|
LOGGER.info(MOD_ID + " initialization complete");
|
||||||
|
|||||||
+17
-39
@@ -1,7 +1,5 @@
|
|||||||
package org.saturnclient.saturnclient.auth;
|
package org.saturnclient.saturnclient.auth;
|
||||||
|
|
||||||
import java.io.*;
|
|
||||||
import java.net.Socket;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents;
|
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents;
|
||||||
@@ -10,18 +8,10 @@ import org.saturnclient.saturnclient.cosmetics.Hats;
|
|||||||
import org.saturnclient.saturnclient.cosmetics.cloaks.Cloaks;
|
import org.saturnclient.saturnclient.cosmetics.cloaks.Cloaks;
|
||||||
import org.saturnclient.saturnclient.SaturnClient;
|
import org.saturnclient.saturnclient.SaturnClient;
|
||||||
|
|
||||||
public class SaturnSocket {
|
public class Auth {
|
||||||
|
|
||||||
private static final String server = "77.247.92.168";
|
|
||||||
private static final int port = 8080;
|
|
||||||
|
|
||||||
public static Map<String, SaturnPlayer> players = new HashMap<>();
|
public static Map<String, SaturnPlayer> players = new HashMap<>();
|
||||||
public static Map<String, String> playerNames = new HashMap<>();
|
public static Map<String, String> playerNames = new HashMap<>();
|
||||||
public static String uuid;
|
public static String uuid;
|
||||||
|
|
||||||
private static Socket socket;
|
|
||||||
private static BufferedReader reader;
|
|
||||||
private static PrintWriter writer;
|
|
||||||
private static Thread listenerThread;
|
private static Thread listenerThread;
|
||||||
private static Thread pingThread;
|
private static Thread pingThread;
|
||||||
private static volatile boolean running = false;
|
private static volatile boolean running = false;
|
||||||
@@ -41,15 +31,11 @@ public class SaturnSocket {
|
|||||||
String accessToken = client.getSession().getAccessToken();
|
String accessToken = client.getSession().getAccessToken();
|
||||||
SaturnClient.LOGGER.info("Authenticating");
|
SaturnClient.LOGGER.info("Authenticating");
|
||||||
|
|
||||||
// Establish a persistent connection
|
Network.init();
|
||||||
socket = new Socket(server, port);
|
|
||||||
reader = new BufferedReader(
|
|
||||||
new InputStreamReader(socket.getInputStream()));
|
|
||||||
writer = new PrintWriter(socket.getOutputStream(), true);
|
|
||||||
|
|
||||||
// Send authentication request
|
Network.write(accessToken);
|
||||||
writer.println(accessToken);
|
|
||||||
String response = reader.readLine();
|
String response = Network.read();
|
||||||
|
|
||||||
SaturnParser parser = new SaturnParser(response);
|
SaturnParser parser = new SaturnParser(response);
|
||||||
|
|
||||||
@@ -75,7 +61,7 @@ public class SaturnSocket {
|
|||||||
startPingThread();
|
startPingThread();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} catch (IOException e) {
|
} catch (Exception e) {
|
||||||
SaturnClient.LOGGER.error("Authentication failed", e);
|
SaturnClient.LOGGER.error("Authentication failed", e);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -86,7 +72,7 @@ public class SaturnSocket {
|
|||||||
listenerThread = new Thread(() -> {
|
listenerThread = new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
while (running) {
|
while (running) {
|
||||||
String message = reader.readLine();
|
String message = Network.read();
|
||||||
if (message == null) {
|
if (message == null) {
|
||||||
SaturnClient.LOGGER.error("Connection closed");
|
SaturnClient.LOGGER.error("Connection closed");
|
||||||
running = false;
|
running = false;
|
||||||
@@ -117,7 +103,7 @@ public class SaturnSocket {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (Exception e) {
|
||||||
SaturnClient.LOGGER.error("Error reading from server", e);
|
SaturnClient.LOGGER.error("Error reading from server", e);
|
||||||
} finally {
|
} finally {
|
||||||
close();
|
close();
|
||||||
@@ -133,12 +119,12 @@ public class SaturnSocket {
|
|||||||
try {
|
try {
|
||||||
while (running) {
|
while (running) {
|
||||||
Thread.sleep(25000); // 25 seconds
|
Thread.sleep(25000); // 25 seconds
|
||||||
if (running && writer != null) {
|
if (running) {
|
||||||
writer.println("ping");
|
Network.write("ping");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
SaturnClient.LOGGER.error("Ping thread interrupted", e);
|
SaturnClient.LOGGER.warn("Ping thread interrupted", e);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
SaturnClient.LOGGER.error("Error in ping thread", e);
|
SaturnClient.LOGGER.error("Error in ping thread", e);
|
||||||
}
|
}
|
||||||
@@ -150,24 +136,16 @@ public class SaturnSocket {
|
|||||||
|
|
||||||
public static void close() {
|
public static void close() {
|
||||||
running = false;
|
running = false;
|
||||||
try {
|
|
||||||
if (pingThread != null) {
|
if (pingThread != null) {
|
||||||
pingThread.interrupt();
|
pingThread.interrupt();
|
||||||
}
|
}
|
||||||
if (listenerThread != null) {
|
if (listenerThread != null) {
|
||||||
listenerThread.interrupt();
|
listenerThread.interrupt();
|
||||||
}
|
}
|
||||||
if (writer != null) {
|
try {
|
||||||
writer.close();
|
close();
|
||||||
}
|
|
||||||
if (reader != null) {
|
|
||||||
reader.close();
|
|
||||||
}
|
|
||||||
if (socket != null) {
|
|
||||||
socket.close();
|
|
||||||
}
|
|
||||||
SaturnClient.LOGGER.info("SaturnApi connection closed.");
|
SaturnClient.LOGGER.info("SaturnApi connection closed.");
|
||||||
} catch (IOException e) {
|
} catch (Exception e) {
|
||||||
SaturnClient.LOGGER.error("Failed to close resources", e);
|
SaturnClient.LOGGER.error("Failed to close resources", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -178,7 +156,7 @@ public class SaturnSocket {
|
|||||||
|
|
||||||
public static void setCloak(String cloakName) {
|
public static void setCloak(String cloakName) {
|
||||||
try {
|
try {
|
||||||
writer.println("set_cloak@cloak=" + cloakName);
|
Network.write("set_cloak@cloak=" + cloakName);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
SaturnClient.LOGGER.error("Request failed", e);
|
SaturnClient.LOGGER.error("Request failed", e);
|
||||||
}
|
}
|
||||||
@@ -186,7 +164,7 @@ public class SaturnSocket {
|
|||||||
|
|
||||||
public static void setHat(String hatName) {
|
public static void setHat(String hatName) {
|
||||||
try {
|
try {
|
||||||
writer.println("set_hat@hat=" + hatName);
|
Network.write("set_hat@hat=" + hatName);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
SaturnClient.LOGGER.error("Request failed", e);
|
SaturnClient.LOGGER.error("Request failed", e);
|
||||||
}
|
}
|
||||||
@@ -195,7 +173,7 @@ public class SaturnSocket {
|
|||||||
public static void player(String name, String uuid) {
|
public static void player(String name, String uuid) {
|
||||||
try {
|
try {
|
||||||
playerNames.put(name, uuid.replaceAll("-", ""));
|
playerNames.put(name, uuid.replaceAll("-", ""));
|
||||||
writer.println("player@uuid=" + uuid.replaceAll("-", ""));
|
Network.write("player@uuid=" + uuid.replaceAll("-", ""));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
SaturnClient.LOGGER.error("Request failed", e);
|
SaturnClient.LOGGER.error("Request failed", e);
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,99 @@
|
|||||||
|
package org.saturnclient.saturnclient.auth;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
import java.net.*;
|
||||||
|
import java.security.*;
|
||||||
|
import java.util.Base64;
|
||||||
|
import javax.crypto.*;
|
||||||
|
import javax.crypto.spec.*;
|
||||||
|
import java.security.interfaces.*;
|
||||||
|
import java.security.spec.X509EncodedKeySpec;
|
||||||
|
|
||||||
|
public class Network {
|
||||||
|
static Socket socket;
|
||||||
|
static DataOutputStream out;
|
||||||
|
static BufferedReader in;
|
||||||
|
static byte[] key = new byte[32];
|
||||||
|
|
||||||
|
public static class AES {
|
||||||
|
public static byte[] encryptAES256(String message, byte[] key) throws Exception {
|
||||||
|
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
|
||||||
|
SecretKeySpec secretKeySpec = new SecretKeySpec(key, "AES");
|
||||||
|
cipher.init(Cipher.ENCRYPT_MODE, secretKeySpec);
|
||||||
|
byte[] encryptedMessage = cipher.doFinal(message.getBytes());
|
||||||
|
return encryptedMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String decryptAES256(byte[] encryptedMessage, byte[] key) throws Exception {
|
||||||
|
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
|
||||||
|
SecretKeySpec secretKeySpec = new SecretKeySpec(key, "AES");
|
||||||
|
cipher.init(Cipher.DECRYPT_MODE, secretKeySpec);
|
||||||
|
byte[] decryptedMessage = cipher.doFinal(encryptedMessage);
|
||||||
|
return new String(decryptedMessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void init() throws Exception {
|
||||||
|
// Generate AES key
|
||||||
|
new SecureRandom().nextBytes(key);
|
||||||
|
|
||||||
|
socket = new Socket("localhost", 8080);
|
||||||
|
out = new DataOutputStream(socket.getOutputStream());
|
||||||
|
in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
|
||||||
|
|
||||||
|
StringBuilder publicKeyBuilder = new StringBuilder();
|
||||||
|
String line;
|
||||||
|
while (!(line = in.readLine()).contains("-----END PUBLIC KEY-----")) {
|
||||||
|
publicKeyBuilder.append(line).append("\n");
|
||||||
|
}
|
||||||
|
publicKeyBuilder.append(line);
|
||||||
|
|
||||||
|
String publicKeyPem = publicKeyBuilder.toString();
|
||||||
|
|
||||||
|
String publicKeyBase64 = publicKeyPem.replace("-----BEGIN PUBLIC KEY-----", "")
|
||||||
|
.replace("-----END PUBLIC KEY-----", "").replace("\n", "").replace("\r", "");
|
||||||
|
byte[] publicKeyBytes = Base64.getDecoder().decode(publicKeyBase64);
|
||||||
|
|
||||||
|
X509EncodedKeySpec keySpec = new X509EncodedKeySpec(publicKeyBytes);
|
||||||
|
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
|
||||||
|
RSAPublicKey publicKey = (RSAPublicKey) keyFactory.generatePublic(keySpec);
|
||||||
|
|
||||||
|
Cipher rsaCipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");
|
||||||
|
rsaCipher.init(Cipher.ENCRYPT_MODE, publicKey);
|
||||||
|
byte[] encryptedKey = rsaCipher.doFinal(key);
|
||||||
|
|
||||||
|
out.write(Base64.getEncoder().encode(encryptedKey));
|
||||||
|
out.write('\n');
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void write(String message) {
|
||||||
|
try {
|
||||||
|
out.write(Base64.getEncoder().encode(AES.encryptAES256(message, key)));
|
||||||
|
out.write('\n');
|
||||||
|
out.flush();
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String read() {
|
||||||
|
try {
|
||||||
|
String msg = in.readLine();
|
||||||
|
if (msg != null) {
|
||||||
|
return AES.decryptAES256(Base64.getDecoder().decode(msg), key);
|
||||||
|
} else {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void close() {
|
||||||
|
try {
|
||||||
|
socket.close();
|
||||||
|
out.close();
|
||||||
|
in.close();
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -45,7 +45,7 @@ public class PlayerTracker {
|
|||||||
private static void onPlayerJoin(MinecraftClient client, PlayerListEntry player) {
|
private static void onPlayerJoin(MinecraftClient client, PlayerListEntry player) {
|
||||||
GameProfile profile = player.getProfile();
|
GameProfile profile = player.getProfile();
|
||||||
String uuid = profile.getId().toString();
|
String uuid = profile.getId().toString();
|
||||||
if (uuid != SaturnSocket.uuid)
|
if (uuid != Auth.uuid)
|
||||||
SaturnSocket.player(profile.getName(), uuid);
|
Auth.player(profile.getName(), uuid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package org.saturnclient.saturnclient.cosmetics;
|
package org.saturnclient.saturnclient.cosmetics;
|
||||||
|
|
||||||
import org.saturnclient.saturnclient.auth.SaturnSocket;
|
import org.saturnclient.saturnclient.auth.Auth;
|
||||||
import org.saturnclient.saturnclient.cosmetics.cloaks.Cloaks;
|
import org.saturnclient.saturnclient.cosmetics.cloaks.Cloaks;
|
||||||
|
|
||||||
import net.minecraft.client.render.OverlayTexture;
|
import net.minecraft.client.render.OverlayTexture;
|
||||||
@@ -57,14 +57,15 @@ public class CloakFeatureRenderer extends FeatureRenderer<PlayerEntityRenderStat
|
|||||||
|
|
||||||
if (skinTextures.capeTexture() == null) {
|
if (skinTextures.capeTexture() == null) {
|
||||||
String name = playerEntityRenderState.name;
|
String name = playerEntityRenderState.name;
|
||||||
String uuid = SaturnSocket.playerNames.get(name);
|
String uuid = Auth.playerNames.get(name);
|
||||||
if (uuid == null || !SaturnSocket.players.containsKey(uuid)) {
|
if (uuid == null || !Auth.players.containsKey(uuid)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Identifier customCape = Cloaks.getCurrentCloakTexture(uuid);
|
Identifier customCape = Cloaks.getCurrentCloakTexture(uuid);
|
||||||
|
|
||||||
if (customCape != null && !this.hasCustomModelForLayer(playerEntityRenderState.equippedChestStack, LayerType.WINGS)) {
|
if (customCape != null
|
||||||
|
&& !this.hasCustomModelForLayer(playerEntityRenderState.equippedChestStack, LayerType.WINGS)) {
|
||||||
matrixStack.push();
|
matrixStack.push();
|
||||||
if (this.hasCustomModelForLayer(playerEntityRenderState.equippedChestStack, LayerType.HUMANOID)) {
|
if (this.hasCustomModelForLayer(playerEntityRenderState.equippedChestStack, LayerType.HUMANOID)) {
|
||||||
matrixStack.translate(0.0F, -0.053125F, 0.06875F);
|
matrixStack.translate(0.0F, -0.053125F, 0.06875F);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package org.saturnclient.saturnclient.cosmetics;
|
package org.saturnclient.saturnclient.cosmetics;
|
||||||
|
|
||||||
import org.saturnclient.saturnclient.auth.SaturnPlayer;
|
import org.saturnclient.saturnclient.auth.SaturnPlayer;
|
||||||
import org.saturnclient.saturnclient.auth.SaturnSocket;
|
import org.saturnclient.saturnclient.auth.Auth;
|
||||||
|
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.client.render.OverlayTexture;
|
import net.minecraft.client.render.OverlayTexture;
|
||||||
@@ -29,9 +29,9 @@ public class HatFeatureRenderer extends FeatureRenderer<PlayerEntityRenderState,
|
|||||||
public void render(MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light,
|
public void render(MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light,
|
||||||
PlayerEntityRenderState state, float limbAngle, float limbDistance) {
|
PlayerEntityRenderState state, float limbAngle, float limbDistance) {
|
||||||
ItemStack headItem = state.equippedHeadStack;
|
ItemStack headItem = state.equippedHeadStack;
|
||||||
String uuid = SaturnSocket.playerNames.get(state.name);
|
String uuid = Auth.playerNames.get(state.name);
|
||||||
if (headItem.isEmpty() && uuid != null) {
|
if (headItem.isEmpty() && uuid != null) {
|
||||||
SaturnPlayer player = SaturnSocket.players.get(uuid);
|
SaturnPlayer player = Auth.players.get(uuid);
|
||||||
if (player == null || player.hat == null || player.hat.isEmpty()) {
|
if (player == null || player.hat == null || player.hat.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package org.saturnclient.saturnclient.cosmetics;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.saturnclient.saturnclient.auth.SaturnPlayer;
|
import org.saturnclient.saturnclient.auth.SaturnPlayer;
|
||||||
import org.saturnclient.saturnclient.auth.SaturnSocket;
|
import org.saturnclient.saturnclient.auth.Auth;
|
||||||
|
|
||||||
public class Hats {
|
public class Hats {
|
||||||
public static List<String> availableHats = new ArrayList<>();
|
public static List<String> availableHats = new ArrayList<>();
|
||||||
@@ -14,14 +14,14 @@ public class Hats {
|
|||||||
|
|
||||||
public static void setHat(String uuid, String hatName) {
|
public static void setHat(String uuid, String hatName) {
|
||||||
setHatSilent(uuid, hatName);
|
setHatSilent(uuid, hatName);
|
||||||
SaturnSocket.setHat(hatName);
|
Auth.setHat(hatName);
|
||||||
SaturnSocket.sendReload();
|
Auth.sendReload();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setHatSilent(String uuid, String hatName) {
|
public static void setHatSilent(String uuid, String hatName) {
|
||||||
SaturnPlayer player = SaturnSocket.players.get(uuid);
|
SaturnPlayer player = Auth.players.get(uuid);
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
SaturnSocket.players.put(uuid, new SaturnPlayer("", hatName));
|
Auth.players.put(uuid, new SaturnPlayer("", hatName));
|
||||||
} else {
|
} else {
|
||||||
player.hat = hatName;
|
player.hat = hatName;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package org.saturnclient.saturnclient.cosmetics.cloaks;
|
package org.saturnclient.saturnclient.cosmetics.cloaks;
|
||||||
|
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import org.saturnclient.saturnclient.auth.SaturnSocket;
|
import org.saturnclient.saturnclient.auth.Auth;
|
||||||
import org.saturnclient.saturnclient.cosmetics.cloaks.utils.AnimatedCloakData;
|
import org.saturnclient.saturnclient.cosmetics.cloaks.utils.AnimatedCloakData;
|
||||||
import org.saturnclient.saturnclient.cosmetics.cloaks.utils.IdentifierUtils;
|
import org.saturnclient.saturnclient.cosmetics.cloaks.utils.IdentifierUtils;
|
||||||
import org.saturnclient.saturnclient.auth.SaturnPlayer;
|
import org.saturnclient.saturnclient.auth.SaturnPlayer;
|
||||||
@@ -42,9 +42,9 @@ public class Cloaks {
|
|||||||
* @param cloakName Name of the cloak file to load
|
* @param cloakName Name of the cloak file to load
|
||||||
*/
|
*/
|
||||||
public static void setCloak(String uuid, String cloakName) {
|
public static void setCloak(String uuid, String cloakName) {
|
||||||
SaturnSocket.setCloak(cloakName);
|
Auth.setCloak(cloakName);
|
||||||
setCloakSilent(uuid, cloakName);
|
setCloakSilent(uuid, cloakName);
|
||||||
SaturnSocket.sendReload();
|
Auth.sendReload();
|
||||||
SaturnClient.LOGGER.info("Cloak set to " + cloakName);
|
SaturnClient.LOGGER.info("Cloak set to " + cloakName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,9 +55,9 @@ public class Cloaks {
|
|||||||
* @param cloakName Name of the cloak file to load
|
* @param cloakName Name of the cloak file to load
|
||||||
*/
|
*/
|
||||||
public static void setCloakSilent(String uuid, String cloakName) {
|
public static void setCloakSilent(String uuid, String cloakName) {
|
||||||
SaturnPlayer player = SaturnSocket.players.get(uuid);
|
SaturnPlayer player = Auth.players.get(uuid);
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
SaturnSocket.players.put(uuid, new SaturnPlayer(cloakName, null));
|
Auth.players.put(uuid, new SaturnPlayer(cloakName, null));
|
||||||
} else {
|
} else {
|
||||||
player.cloak = cloakName;
|
player.cloak = cloakName;
|
||||||
}
|
}
|
||||||
@@ -137,11 +137,11 @@ public class Cloaks {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Identifier getCurrentCloakTexture(String uuid) {
|
public static Identifier getCurrentCloakTexture(String uuid) {
|
||||||
if (!SaturnSocket.players.containsKey(uuid)) {
|
if (!Auth.players.containsKey(uuid)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
String cloakName = SaturnSocket.players.get(uuid).cloak;
|
String cloakName = Auth.players.get(uuid).cloak;
|
||||||
|
|
||||||
if (cloakName.isEmpty()) {
|
if (cloakName.isEmpty()) {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package org.saturnclient.saturnclient.menus;
|
|||||||
|
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
import org.saturnclient.saturnclient.SaturnClientConfig;
|
import org.saturnclient.saturnclient.SaturnClientConfig;
|
||||||
import org.saturnclient.saturnclient.auth.SaturnSocket;
|
import org.saturnclient.saturnclient.auth.Auth;
|
||||||
import org.saturnclient.saturnclient.config.Property;
|
import org.saturnclient.saturnclient.config.Property;
|
||||||
import org.saturnclient.saturnclient.cosmetics.cloaks.Cloaks;
|
import org.saturnclient.saturnclient.cosmetics.cloaks.Cloaks;
|
||||||
import org.saturnclient.ui.SaturnUi;
|
import org.saturnclient.ui.SaturnUi;
|
||||||
@@ -123,7 +123,7 @@ public class CloaksMenu extends SaturnUi {
|
|||||||
|
|
||||||
scroll.draw(
|
scroll.draw(
|
||||||
new SaturnClickableSprite(Textures.BUTTON_BORDER, () -> {
|
new SaturnClickableSprite(Textures.BUTTON_BORDER, () -> {
|
||||||
Cloaks.setCloak(SaturnSocket.uuid, cloak);
|
Cloaks.setCloak(Auth.uuid, cloak);
|
||||||
})
|
})
|
||||||
.setX(modX)
|
.setX(modX)
|
||||||
.setY(modY)
|
.setY(modY)
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package org.saturnclient.saturnclient.menus;
|
|||||||
|
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
import org.saturnclient.saturnclient.SaturnClientConfig;
|
import org.saturnclient.saturnclient.SaturnClientConfig;
|
||||||
import org.saturnclient.saturnclient.auth.SaturnSocket;
|
import org.saturnclient.saturnclient.auth.Auth;
|
||||||
import org.saturnclient.saturnclient.cosmetics.Hats;
|
import org.saturnclient.saturnclient.cosmetics.Hats;
|
||||||
import org.saturnclient.ui.SaturnUi;
|
import org.saturnclient.ui.SaturnUi;
|
||||||
import org.saturnclient.ui.Textures;
|
import org.saturnclient.ui.Textures;
|
||||||
@@ -88,7 +88,7 @@ public class HatsMenu extends SaturnUi {
|
|||||||
for (String hat : Hats.availableHats) {
|
for (String hat : Hats.availableHats) {
|
||||||
modsScroll.draw(
|
modsScroll.draw(
|
||||||
new SaturnClickableSprite(Textures.BUTTON_BORDER, () -> {
|
new SaturnClickableSprite(Textures.BUTTON_BORDER, () -> {
|
||||||
Hats.setHat(SaturnSocket.uuid, hat);
|
Hats.setHat(Auth.uuid, hat);
|
||||||
})
|
})
|
||||||
.setX(modX)
|
.setX(modX)
|
||||||
.setY(modY)
|
.setY(modY)
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import net.minecraft.util.math.Vec3d;
|
|||||||
import net.minecraft.client.render.LightmapTextureManager;
|
import net.minecraft.client.render.LightmapTextureManager;
|
||||||
|
|
||||||
import org.saturnclient.saturnclient.SaturnClientConfig;
|
import org.saturnclient.saturnclient.SaturnClientConfig;
|
||||||
import org.saturnclient.saturnclient.auth.SaturnSocket;
|
import org.saturnclient.saturnclient.auth.Auth;
|
||||||
import org.joml.Matrix4f;
|
import org.joml.Matrix4f;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Overwrite;
|
import org.spongepowered.asm.mixin.Overwrite;
|
||||||
@@ -33,7 +33,8 @@ public abstract class NameTagMixin<S extends EntityRenderState> {
|
|||||||
@Overwrite
|
@Overwrite
|
||||||
public void renderLabelIfPresent(S state, Text text_o, MatrixStack matrices,
|
public void renderLabelIfPresent(S state, Text text_o, MatrixStack matrices,
|
||||||
VertexConsumerProvider vertexConsumers, int light) {
|
VertexConsumerProvider vertexConsumers, int light) {
|
||||||
Text text = isSaturn(state) ? Text.literal(SaturnClientConfig.getSaturnIndicator() + text_o.getString()) : text_o;
|
Text text = isSaturn(state) ? Text.literal(SaturnClientConfig.getSaturnIndicator() + text_o.getString())
|
||||||
|
: text_o;
|
||||||
|
|
||||||
Vec3d vec3d = state.nameLabelPos;
|
Vec3d vec3d = state.nameLabelPos;
|
||||||
if (vec3d != null) {
|
if (vec3d != null) {
|
||||||
@@ -61,8 +62,8 @@ public abstract class NameTagMixin<S extends EntityRenderState> {
|
|||||||
private boolean isSaturn(S state) {
|
private boolean isSaturn(S state) {
|
||||||
if (state instanceof PlayerEntityRenderState) {
|
if (state instanceof PlayerEntityRenderState) {
|
||||||
String name = ((PlayerEntityRenderState) state).name;
|
String name = ((PlayerEntityRenderState) state).name;
|
||||||
String uuid = SaturnSocket.playerNames.get(name);
|
String uuid = Auth.playerNames.get(name);
|
||||||
return uuid != null && SaturnSocket.players.containsKey(uuid);
|
return uuid != null && Auth.players.containsKey(uuid);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package org.saturnclient.saturnclient.mixin;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.saturnclient.saturnclient.auth.SaturnSocket;
|
import org.saturnclient.saturnclient.auth.Auth;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
@@ -21,10 +21,10 @@ public class SaturnReload {
|
|||||||
@Nullable MessageIndicator indicator, CallbackInfo ci) {
|
@Nullable MessageIndicator indicator, CallbackInfo ci) {
|
||||||
String msg = message.toString();
|
String msg = message.toString();
|
||||||
if (msg.contains("$SATURN_RELOAD")) {
|
if (msg.contains("$SATURN_RELOAD")) {
|
||||||
for (Map.Entry<String, String> player : SaturnSocket.playerNames.entrySet()) {
|
for (Map.Entry<String, String> player : Auth.playerNames.entrySet()) {
|
||||||
String name = player.getKey();
|
String name = player.getKey();
|
||||||
if (msg.contains(name)) {
|
if (msg.contains(name)) {
|
||||||
SaturnSocket.player(name, player.getValue());
|
Auth.player(name, player.getValue());
|
||||||
}
|
}
|
||||||
ci.cancel();
|
ci.cancel();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import net.minecraft.client.network.PlayerListEntry;
|
|||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.saturnclient.saturnclient.SaturnClientConfig;
|
import org.saturnclient.saturnclient.SaturnClientConfig;
|
||||||
import org.saturnclient.saturnclient.auth.SaturnSocket;
|
import org.saturnclient.saturnclient.auth.Auth;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Overwrite;
|
import org.spongepowered.asm.mixin.Overwrite;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
@@ -30,6 +30,6 @@ public abstract class TabListMixin {
|
|||||||
String uuid = profile.getId().toString().replaceAll("-", "");
|
String uuid = profile.getId().toString().replaceAll("-", "");
|
||||||
|
|
||||||
return Text.literal(
|
return Text.literal(
|
||||||
SaturnSocket.players.containsKey(uuid) ? SaturnClientConfig.getSaturnIndicator() + name : name);
|
Auth.players.containsKey(uuid) ? SaturnClientConfig.getSaturnIndicator() + name : name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user