Better cosmetic update system
This commit is contained in:
@@ -104,11 +104,34 @@ public class Auth {
|
|||||||
String hat = parser.getStringOrNull("hat");
|
String hat = parser.getStringOrNull("hat");
|
||||||
if (cloak != null) {
|
if (cloak != null) {
|
||||||
Cloaks.availableCloaks.add(cloak);
|
Cloaks.availableCloaks.add(cloak);
|
||||||
|
|
||||||
}
|
}
|
||||||
if (hat != null) {
|
if (hat != null) {
|
||||||
Hats.availableHats.add(hat);
|
Hats.availableHats.add(hat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case "update_cloak":
|
||||||
|
String targetUuid = parser.getStringOrNull("uuid");
|
||||||
|
String targetCloak = parser.getStringOrNull("cloak");
|
||||||
|
if (targetUuid != null && targetCloak != null) {
|
||||||
|
SaturnPlayer player = players.get(targetUuid);
|
||||||
|
if (player != null) {
|
||||||
|
player.cloak = targetCloak;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "update_hat":
|
||||||
|
targetUuid = parser.getStringOrNull("uuid");
|
||||||
|
String targetHat = parser.getStringOrNull("hat");
|
||||||
|
if (targetUuid != null && targetHat != null) {
|
||||||
|
SaturnPlayer player = players.get(targetUuid);
|
||||||
|
if (player != null) {
|
||||||
|
player.hat = targetHat;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (parser.error != null) {
|
if (parser.error != null) {
|
||||||
SaturnClient.LOGGER.error("Error from the server: " + parser.error);
|
SaturnClient.LOGGER.error("Error from the server: " + parser.error);
|
||||||
@@ -182,7 +205,7 @@ public class Auth {
|
|||||||
|
|
||||||
public static void setCloak(String cloakName) {
|
public static void setCloak(String cloakName) {
|
||||||
try {
|
try {
|
||||||
Network.write("set_cloak@cloak=" + cloakName + "@notify=" + "d362a04228bd49e1a807ae74dbe8aba9");
|
Network.write("set_cloak@cloak=" + cloakName + "@notify=" + stringifyPlayers());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
SaturnClient.LOGGER.error("Request failed", e);
|
SaturnClient.LOGGER.error("Request failed", e);
|
||||||
}
|
}
|
||||||
@@ -190,12 +213,16 @@ public class Auth {
|
|||||||
|
|
||||||
public static void setHat(String hatName) {
|
public static void setHat(String hatName) {
|
||||||
try {
|
try {
|
||||||
Network.write("set_hat@hat=" + hatName + "@notify=" + "d362a04228bd49e1a807ae74dbe8aba9");
|
Network.write("set_hat@hat=" + hatName + "@notify=" + stringifyPlayers());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
SaturnClient.LOGGER.error("Request failed", e);
|
SaturnClient.LOGGER.error("Request failed", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String stringifyPlayers() {
|
||||||
|
return String.join("$", players.keySet());
|
||||||
|
}
|
||||||
|
|
||||||
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("-", ""));
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ public class Network {
|
|||||||
// Generate AES key
|
// Generate AES key
|
||||||
new SecureRandom().nextBytes(key);
|
new SecureRandom().nextBytes(key);
|
||||||
|
|
||||||
socket = new Socket("77.247.92.168", 8080);
|
socket = new Socket("localhost", 8080);
|
||||||
// out = new DataOutputStream(socket.getOutputStream());
|
// out = new DataOutputStream(socket.getOutputStream());
|
||||||
out = new PrintWriter(socket.getOutputStream(), true);
|
out = new PrintWriter(socket.getOutputStream(), true);
|
||||||
in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
|
in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
|
||||||
|
|||||||
@@ -112,20 +112,25 @@ public class Cloaks {
|
|||||||
List<AnimatedCloakData> animatedFrames = new ArrayList<>();
|
List<AnimatedCloakData> animatedFrames = new ArrayList<>();
|
||||||
for (int i = 0; i < frameCount; i++) {
|
for (int i = 0; i < frameCount; i++) {
|
||||||
String frameId = fileName.replace(".gif", "") + "_frame_" + i;
|
String frameId = fileName.replace(".gif", "") + "_frame_" + i;
|
||||||
Identifier frameIdentifier = Identifier.of(SaturnClient.MOD_ID, "cloaks_" + frameId);
|
Identifier frameIdentifier = Identifier.of(SaturnClient.MOD_ID,
|
||||||
IdentifierUtils.registerBufferedImageTexture(frameIdentifier, frames.get(i));
|
"cloaks_" + frameId);
|
||||||
|
IdentifierUtils.registerBufferedImageTexture(frameIdentifier,
|
||||||
|
frames.get(i));
|
||||||
animatedFrames.add(new AnimatedCloakData(frameIdentifier, delays.get(i)));
|
animatedFrames.add(new AnimatedCloakData(frameIdentifier, delays.get(i)));
|
||||||
}
|
}
|
||||||
animatedCloaks.put(uuid, animatedFrames);
|
animatedCloaks.put(uuid, animatedFrames);
|
||||||
lastFrameTime.put(uuid, System.currentTimeMillis());
|
lastFrameTime.put(uuid, System.currentTimeMillis());
|
||||||
SaturnClient.LOGGER.info("Loaded " + frames.size() + " frames for animated cloak: " + fileName);
|
SaturnClient.LOGGER.info(
|
||||||
|
"Loaded " + frames.size() + " frames for animated cloak: " + fileName);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
SaturnClient.LOGGER.error("Failed to register animated cloak textures: " + fileName, e);
|
SaturnClient.LOGGER
|
||||||
|
.error("Failed to register animated cloak textures: " + fileName, e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
SaturnClient.LOGGER.error("Failed to load animated cloak from resources: " + player.cloak + ".gif", e);
|
SaturnClient.LOGGER
|
||||||
|
.error("Failed to load animated cloak from resources: " + player.cloak + ".gif", e);
|
||||||
}
|
}
|
||||||
}).start();
|
}).start();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user