diff options
| author | anhgelus <anhgelus.morhtuuzh@proton.me> | 2024-08-23 14:22:41 +0000 |
|---|---|---|
| committer | anhgelus <anhgelus.morhtuuzh@proton.me> | 2024-08-23 14:22:41 +0000 |
| commit | 2e87ea59da4e7a3a56f24641c22aeac50cc5b607 (patch) | |
| tree | 1bb7cc82a5833df6f4d9cea01116016bf62be5b9 /src | |
| parent | c6e309f02732eb79a24db6780c4f8f718fac2a29 (diff) | |
fix(networking): crash while joining server
Diffstat (limited to 'src')
| -rw-r--r-- | src/client/java/world/anhgelus/molehunt/client/MolehuntClient.java | 12 | ||||
| -rw-r--r-- | src/main/java/world/anhgelus/molehunt/config/SimpleConfig.java | 13 |
2 files changed, 12 insertions, 13 deletions
diff --git a/src/client/java/world/anhgelus/molehunt/client/MolehuntClient.java b/src/client/java/world/anhgelus/molehunt/client/MolehuntClient.java index 7770a1b..1f92573 100644 --- a/src/client/java/world/anhgelus/molehunt/client/MolehuntClient.java +++ b/src/client/java/world/anhgelus/molehunt/client/MolehuntClient.java @@ -13,13 +13,11 @@ public class MolehuntClient implements ClientModInitializer { @Override public void onInitializeClient() { ClientPlayNetworking.registerGlobalReceiver(ConfigPayload.ID, (payload, context) -> { - try (final var client = context.client()) { - client.execute(() -> { - SHOW_SKINS = payload.showSkins(); - SHOW_NAMETAGS = payload.showNametags(); - SHOW_TAB = payload.showTab(); - }); - } + context.client().execute(() -> { + SHOW_SKINS = payload.showSkins(); + SHOW_NAMETAGS = payload.showNametags(); + SHOW_TAB = payload.showTab(); + }); }); } diff --git a/src/main/java/world/anhgelus/molehunt/config/SimpleConfig.java b/src/main/java/world/anhgelus/molehunt/config/SimpleConfig.java index ef8bef3..2b65829 100644 --- a/src/main/java/world/anhgelus/molehunt/config/SimpleConfig.java +++ b/src/main/java/world/anhgelus/molehunt/config/SimpleConfig.java @@ -2,7 +2,7 @@ package world.anhgelus.molehunt.config; /* * Copyright (c) 2021 magistermaks - * Slightly modified by Léo-21 + * Slightly modified by Léo-21 and Anhgelus Morhtuuzh * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,6 +30,7 @@ import org.apache.logging.log4j.Logger; import java.io.File; import java.io.IOException; import java.io.PrintWriter; +import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; import java.util.HashMap; @@ -110,7 +111,7 @@ public class SimpleConfig { Files.createFile( request.file.toPath() ); // write default config data - PrintWriter writer = new PrintWriter(request.file, "UTF-8"); + PrintWriter writer = new PrintWriter(request.file, StandardCharsets.UTF_8); writer.write( request.getConfig() ); writer.close(); @@ -139,12 +140,12 @@ public class SimpleConfig { String identifier = "Config '" + request.filename + "'"; if( !request.file.exists() ) { - LOGGER.info( identifier + " is missing, generating default one..." ); + LOGGER.info("{} is missing, generating default one...", identifier); try { createConfig(); } catch (IOException e) { - LOGGER.error( identifier + " failed to generate!" ); + LOGGER.error("{} failed to generate!", identifier); LOGGER.trace( e ); broken = true; } @@ -154,7 +155,7 @@ public class SimpleConfig { try { loadConfig(); } catch (Exception e) { - LOGGER.error( identifier + " failed to load!" ); + LOGGER.error("{} failed to load!", identifier); LOGGER.trace( e ); broken = true; } @@ -245,7 +246,7 @@ public class SimpleConfig { * @return true if the operation was successful */ public boolean delete() { - LOGGER.warn( "Config '" + request.filename + "' was removed from existence! Restart the game to regenerate it." ); + LOGGER.warn("Config '{}' was removed from existence! Restart the game to regenerate it.", request.filename); return request.file.delete(); } |
