reload cosmetics
This commit is contained in:
@@ -6,6 +6,7 @@ import java.util.Map;
|
|||||||
|
|
||||||
public class SaturnParser {
|
public class SaturnParser {
|
||||||
public String method = "";
|
public String method = "";
|
||||||
|
public String error;
|
||||||
private Map<String, String> params = new HashMap<>();
|
private Map<String, String> params = new HashMap<>();
|
||||||
|
|
||||||
public SaturnParser(String input) throws IOException {
|
public SaturnParser(String input) throws IOException {
|
||||||
@@ -16,7 +17,7 @@ public class SaturnParser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (parts[0].startsWith("!")) {
|
if (parts[0].startsWith("!")) {
|
||||||
throw new IOException(parts[0]);
|
error = input;
|
||||||
}
|
}
|
||||||
|
|
||||||
method = parts[0];
|
method = parts[0];
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ 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;
|
||||||
|
import net.fabricmc.fabric.api.client.message.v1.ClientReceiveMessageEvents;
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
|
|
||||||
import org.saturnclient.saturnclient.SaturnClient;
|
import org.saturnclient.saturnclient.SaturnClient;
|
||||||
@@ -109,6 +110,12 @@ public class SaturnSocket {
|
|||||||
playerNames.entrySet().removeIf(entry -> entry.getValue().equals(uuid));
|
playerNames.entrySet().removeIf(entry -> entry.getValue().equals(uuid));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
if (parser.error != null) {
|
||||||
|
SaturnClient.LOGGER.error("Error from the server: " + parser.error);
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@@ -142,6 +149,16 @@ public class SaturnSocket {
|
|||||||
|
|
||||||
public static void afterAuth() {
|
public static void afterAuth() {
|
||||||
PlayerTracker.initialize();
|
PlayerTracker.initialize();
|
||||||
|
|
||||||
|
ClientReceiveMessageEvents.CHAT.register((message, signedMessage, sender, params, receptionTimestamp) -> {
|
||||||
|
String msg = message.getString();
|
||||||
|
|
||||||
|
if (msg.contains("$SATURN_RELOAD")) {
|
||||||
|
String name = sender.getName();
|
||||||
|
SaturnClient.LOGGER.info("Reloading player: " + name);
|
||||||
|
player(name, sender.getId().toString().replace("-", ""));
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setCloak(String cloakName) {
|
public static void setCloak(String cloakName) {
|
||||||
@@ -169,11 +186,14 @@ public class SaturnSocket {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void joinServer(String ip) {
|
public static void sendReload() {
|
||||||
try {
|
for (Map.Entry<String, String> player : playerNames.entrySet()) {
|
||||||
writer.println("join_server@ip=" + ip);
|
if (players.containsKey(player.getValue()) && !player.getValue().equals(uuid)) {
|
||||||
} catch (Exception e) {
|
MinecraftClient.getInstance().player.networkHandler
|
||||||
SaturnClient.LOGGER.error("Request failed", e);
|
.sendChatCommand("msg " + player.getKey() + " "
|
||||||
|
+ "$SATURN_RELOAD if you are seeing this as a player, please report this to https://github.com/saturnclientmc/saturnclient/issues");
|
||||||
|
;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,10 +17,8 @@ public class ConfigManager {
|
|||||||
|
|
||||||
private static File configFile = new File(
|
private static File configFile = new File(
|
||||||
MinecraftClient.getInstance().runDirectory,
|
MinecraftClient.getInstance().runDirectory,
|
||||||
"saturn.json"
|
"saturn.json");
|
||||||
);
|
private static Map<String, Map<String, Property<?>>> properties = new HashMap<>();
|
||||||
private static Map<String, Map<String, Property<?>>> properties =
|
|
||||||
new HashMap<>();
|
|
||||||
|
|
||||||
private String namespace;
|
private String namespace;
|
||||||
|
|
||||||
@@ -45,49 +43,35 @@ public class ConfigManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
JsonObject jsonObject = JsonParser.parseString(
|
JsonObject jsonObject = JsonParser.parseString(
|
||||||
new String(Files.readAllBytes(configFile.toPath()))
|
new String(Files.readAllBytes(configFile.toPath()))).getAsJsonObject();
|
||||||
).getAsJsonObject();
|
|
||||||
|
|
||||||
for (String namespace : properties.keySet()) {
|
for (String namespace : properties.keySet()) {
|
||||||
JsonElement configElement = jsonObject.get(namespace);
|
JsonElement configElement = jsonObject.get(namespace);
|
||||||
|
|
||||||
if (configElement == null) continue;
|
if (configElement == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
JsonObject config = jsonObject.get(namespace).getAsJsonObject();
|
JsonObject config = jsonObject.get(namespace).getAsJsonObject();
|
||||||
|
|
||||||
if (config == null) {
|
if (config == null) {
|
||||||
SaturnClient.LOGGER.warn(
|
|
||||||
"No config found for namespace: " + namespace
|
|
||||||
);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, Property<?>> propertyMap = properties.get(
|
Map<String, Property<?>> propertyMap = properties.get(
|
||||||
namespace
|
namespace);
|
||||||
);
|
|
||||||
|
|
||||||
for (String propertyName : propertyMap.keySet()) {
|
for (String propertyName : propertyMap.keySet()) {
|
||||||
JsonElement c = config.get(propertyName);
|
JsonElement c = config.get(propertyName);
|
||||||
|
|
||||||
if (c == null) {
|
if (c == null) {
|
||||||
SaturnClient.LOGGER.warn(
|
|
||||||
"No property found in config for " + propertyName
|
|
||||||
);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
SaturnClient.LOGGER.info("got prop " + c);
|
|
||||||
Property<?> p = propertyMap.get(propertyName);
|
Property<?> p = propertyMap.get(propertyName);
|
||||||
SaturnClient.LOGGER.info(
|
|
||||||
"setting prop " + propertyName + " to " + p.value
|
|
||||||
);
|
|
||||||
|
|
||||||
SaturnClient.LOGGER.info("Property type: " + p.getType());
|
|
||||||
if (p.matchesJson(c)) {
|
if (p.matchesJson(c)) {
|
||||||
switch (p.getType()) {
|
switch (p.getType()) {
|
||||||
case BOOLEAN:
|
case BOOLEAN:
|
||||||
((Property<Boolean>) p).value =
|
((Property<Boolean>) p).value = c.getAsBoolean();
|
||||||
c.getAsBoolean();
|
|
||||||
break;
|
break;
|
||||||
case INTEGER:
|
case INTEGER:
|
||||||
((Property<Integer>) p).value = c.getAsInt();
|
((Property<Integer>) p).value = c.getAsInt();
|
||||||
@@ -106,8 +90,7 @@ public class ConfigManager {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
SaturnClient.LOGGER.warn(
|
SaturnClient.LOGGER.warn(
|
||||||
"Property does not match JSON: " + propertyName
|
"Property does not match JSON: " + propertyName);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -126,8 +109,7 @@ public class ConfigManager {
|
|||||||
for (String namespace : properties.keySet()) {
|
for (String namespace : properties.keySet()) {
|
||||||
JsonObject namespaceConfig = new JsonObject();
|
JsonObject namespaceConfig = new JsonObject();
|
||||||
Map<String, Property<?>> propertyMap = properties.get(
|
Map<String, Property<?>> propertyMap = properties.get(
|
||||||
namespace
|
namespace);
|
||||||
);
|
|
||||||
|
|
||||||
// Iterate through each property in the namespace
|
// Iterate through each property in the namespace
|
||||||
for (String propertyName : propertyMap.keySet()) {
|
for (String propertyName : propertyMap.keySet()) {
|
||||||
@@ -138,33 +120,27 @@ public class ConfigManager {
|
|||||||
switch (property.getType()) {
|
switch (property.getType()) {
|
||||||
case BOOLEAN:
|
case BOOLEAN:
|
||||||
propertyValue = new JsonPrimitive(
|
propertyValue = new JsonPrimitive(
|
||||||
(Boolean) property.value
|
(Boolean) property.value);
|
||||||
);
|
|
||||||
break;
|
break;
|
||||||
case INTEGER:
|
case INTEGER:
|
||||||
propertyValue = new JsonPrimitive(
|
propertyValue = new JsonPrimitive(
|
||||||
(Integer) property.value
|
(Integer) property.value);
|
||||||
);
|
|
||||||
break;
|
break;
|
||||||
case FLOAT:
|
case FLOAT:
|
||||||
propertyValue = new JsonPrimitive(
|
propertyValue = new JsonPrimitive(
|
||||||
(Float) property.value
|
(Float) property.value);
|
||||||
);
|
|
||||||
break;
|
break;
|
||||||
case STRING:
|
case STRING:
|
||||||
propertyValue = new JsonPrimitive(
|
propertyValue = new JsonPrimitive(
|
||||||
(String) property.value
|
(String) property.value);
|
||||||
);
|
|
||||||
break;
|
break;
|
||||||
case HEX:
|
case HEX:
|
||||||
propertyValue = new JsonPrimitive(
|
propertyValue = new JsonPrimitive(
|
||||||
(Integer) property.value
|
(Integer) property.value);
|
||||||
);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
SaturnClient.LOGGER.warn(
|
SaturnClient.LOGGER.warn(
|
||||||
"Unknown property type for: " + propertyName
|
"Unknown property type for: " + propertyName);
|
||||||
);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ 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.SaturnSocket;
|
||||||
|
|
||||||
@@ -16,6 +15,7 @@ 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);
|
SaturnSocket.setHat(hatName);
|
||||||
|
SaturnSocket.sendReload();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setHatSilent(String uuid, String hatName) {
|
public static void setHatSilent(String uuid, String hatName) {
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ public class Cloaks {
|
|||||||
public static void setCloak(String uuid, String cloakName) {
|
public static void setCloak(String uuid, String cloakName) {
|
||||||
SaturnSocket.setCloak(cloakName);
|
SaturnSocket.setCloak(cloakName);
|
||||||
setCloakSilent(uuid, cloakName);
|
setCloakSilent(uuid, cloakName);
|
||||||
|
SaturnSocket.sendReload();
|
||||||
SaturnClient.LOGGER.info("Cloak set to " + cloakName);
|
SaturnClient.LOGGER.info("Cloak set to " + cloakName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package org.saturnclient.saturnclient.mixin;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
|
import net.minecraft.client.gui.hud.ChatHud;
|
||||||
|
import net.minecraft.client.gui.hud.MessageIndicator;
|
||||||
|
import net.minecraft.network.message.MessageSignatureData;
|
||||||
|
import net.minecraft.text.Text;
|
||||||
|
|
||||||
|
@Mixin(ChatHud.class)
|
||||||
|
public class SaturnReload {
|
||||||
|
@Inject(method = "addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignatureData;Lnet/minecraft/client/gui/hud/MessageIndicator;)V", at = @At("HEAD"), cancellable = true)
|
||||||
|
public void onAddMessage(Text message, @Nullable MessageSignatureData signatureData,
|
||||||
|
@Nullable MessageIndicator indicator, CallbackInfo ci) {
|
||||||
|
if (message.toString().contains("$SATURN_RELOAD")) {
|
||||||
|
ci.cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,3 +1,8 @@
|
|||||||
{
|
{
|
||||||
"saturnclient:panton": "saturnclient:font/panton"
|
"providers": [
|
||||||
|
{
|
||||||
|
"type": "reference",
|
||||||
|
"id": "saturnclient:panton"
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
{
|
|
||||||
"providers": [
|
|
||||||
{
|
|
||||||
"type": "reference",
|
|
||||||
"id": "saturnclient:panton"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
"shift": [0, 0],
|
"shift": [0, 0],
|
||||||
"size": 9,
|
"size": 9,
|
||||||
"oversample": 5.0,
|
"oversample": 5.0,
|
||||||
"skip_missing": false
|
"skip_missing": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,8 @@
|
|||||||
"TabListMixin",
|
"TabListMixin",
|
||||||
"NameTagMixin",
|
"NameTagMixin",
|
||||||
"PlayerEntityRendererMixin",
|
"PlayerEntityRendererMixin",
|
||||||
"WhoAmI"
|
"WhoAmI",
|
||||||
|
"SaturnReload"
|
||||||
],
|
],
|
||||||
"injectors": {
|
"injectors": {
|
||||||
"defaultRequire": 1
|
"defaultRequire": 1
|
||||||
|
|||||||
Reference in New Issue
Block a user