forked from virt-mirrors/Sit
Merge branch 'refs/heads/1.20.4' into 1.20.1
# Conflicts: # gradle.properties # src/main/java/one/oth3r/sit/Sit.java # src/main/java/one/oth3r/sit/SitClient.java # src/main/resources/fabric.mod.json
This commit is contained in:
commit
01463a50b6
5 changed files with 16 additions and 8 deletions
|
@ -40,6 +40,7 @@ public class Sit implements ModInitializer {
|
|||
// copy to not throw errors
|
||||
PacketBuilder packet = new PacketBuilder(buf.copy());
|
||||
server.execute(() -> {
|
||||
LOGGER.info(String.format("Received custom sitting settings from %s.",player.getName().getString()));
|
||||
Type hashMapToken = new TypeToken<HashMap<String, Object>>() {}.getType();
|
||||
Gson gson = new GsonBuilder().disableHtmlEscaping().create();
|
||||
playerSettings.put(player,gson.fromJson(packet.getMessage(),hashMapToken));
|
||||
|
|
|
@ -13,13 +13,19 @@ public class SitClient implements ClientModInitializer {
|
|||
ClientPlayConnectionEvents.JOIN.register((handler, sender, client) -> {
|
||||
inGame = true;
|
||||
// send a data packet whenever joining a server
|
||||
client.execute(SitClient::sendPackets);
|
||||
sendSettingsPackets();
|
||||
});
|
||||
// reset inGame
|
||||
ClientPlayConnectionEvents.DISCONNECT.register((handler, client) -> inGame = false);
|
||||
}
|
||||
public static void sendPackets() {
|
||||
Gson gson = new GsonBuilder().disableHtmlEscaping().create();
|
||||
new PacketBuilder(gson.toJson(Utl.HandSettings.getHandSettings())).send();
|
||||
|
||||
/**
|
||||
* sends the settings packets to the server is the client is in game
|
||||
*/
|
||||
public static void sendSettingsPackets() {
|
||||
if (inGame) {
|
||||
Gson gson = new GsonBuilder().disableHtmlEscaping().create();
|
||||
new PacketBuilder(gson.toJson(Utl.HandSettings.getHandSettings())).send();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -213,7 +213,7 @@ public class Config {
|
|||
file.write("\nhand.off.whitelist="+gson.toJson(offWhitelist));
|
||||
file.write("\nhand.off.blacklist="+gson.toJson(offBlacklist));
|
||||
// send packets to update the settings on the server
|
||||
if (SitClient.inGame) SitClient.sendPackets();
|
||||
SitClient.sendSettingsPackets();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue