From 3c2aca31b63c1fc02485685b085006b11bfaae3e Mon Sep 17 00:00:00 2001 From: OBro1961 Date: Mon, 16 Dec 2024 11:11:46 -0600 Subject: [PATCH] More syncing with omnivers --- changelog.md | 2 +- .../obro1961/chatpatches/ChatPatches.java | 24 +------------------ .../obro1961/chatpatches/util/ChatUtils.java | 9 ++++--- 3 files changed, 6 insertions(+), 29 deletions(-) diff --git a/changelog.md b/changelog.md index 705e218..e85cb43 100644 --- a/changelog.md +++ b/changelog.md @@ -12,7 +12,7 @@ - Also renamed all variable references of `ChatHudAccessor` strictly to `chat` for consistency - Cleanup and consistent formatting - Now logs errors from `ChatLog#deserialize` and `ChatPatches#jsonOps` like all other errors - - Synced with omnivers minor cleanup changes again + - Synced with cleanup stuff already present on the `omnivers` branch ## Chat Patches `213.6.9` for Minecraft 1.21.2, 1.21.3 on Fabric, Quilt - Updated to 1.21.2-3 diff --git a/src/main/java/obro1961/chatpatches/ChatPatches.java b/src/main/java/obro1961/chatpatches/ChatPatches.java index db1260f..c4cb6a1 100644 --- a/src/main/java/obro1961/chatpatches/ChatPatches.java +++ b/src/main/java/obro1961/chatpatches/ChatPatches.java @@ -32,8 +32,6 @@ public class ChatPatches implements ClientModInitializer { /** Contains the sender and timestamp data of the last received chat message. */ public static ChatUtils.MessageData msgData = ChatUtils.NIL_MSG_DATA; - private static String lastWorld = ""; - /** * Returns a {@code chatpatches:${path}} * {@link Identifier}. @@ -45,6 +43,7 @@ public static Identifier id(String path) { return Identifier.of(MOD_ID, path); } + @Override public void onInitializeClient() { /* @@ -79,27 +78,6 @@ public void onInitializeClient() { LOGGER.info("[ChatPatches()] Finished setting up!"); } - /** - * Returns the current ClientWorld's name. For singleplayer, - * returns the level name. For multiplayer, returns the - * server entry name. Falls back on the IP if it was - * direct-connect. Leads with "C_" or "S_" depending - * on the source of the ClientWorld. - * @param client A non-null MinecraftClient that must be in-game. - * @return (C or S) + "_" + (current world name) - */ - @SuppressWarnings("DataFlowIssue") // getServer and getCurrentServerEntry are not null if isIntegratedServerRunning is true - public static String currentWorldName(@NotNull MinecraftClient client) { - Objects.requireNonNull(client, "MinecraftClient must exist to access client data:"); - String entryName; - - return client.isIntegratedServerRunning() - ? "C_" + client.getServer().getSaveProperties().getLevelName() - : (entryName = client.getCurrentServerEntry().name) == null || entryName.isBlank() // check if null/empty then use IP - ? "S_" + client.getCurrentServerEntry().address - : "S_" + client.getCurrentServerEntry().name - ; - } /** * Logs an error-level message telling the user to report diff --git a/src/main/java/obro1961/chatpatches/util/ChatUtils.java b/src/main/java/obro1961/chatpatches/util/ChatUtils.java index 7c1f374..d4857f7 100644 --- a/src/main/java/obro1961/chatpatches/util/ChatUtils.java +++ b/src/main/java/obro1961/chatpatches/util/ChatUtils.java @@ -246,11 +246,10 @@ public static Text modifyMessage(@NotNull Text m, boolean refreshing) { content = m.copy(); } } catch(Exception e) { - LOGGER.error("[ChatUtils.modifyMessage] An error occurred while modifying message '{}', returning original:", m.getString()); - LOGGER.debug("[ChatUtils.modifyMessage] \tOriginal message structure: {}", m); - LOGGER.debug("[ChatUtils.modifyMessage] \tModified message structure:"); - LOGGER.debug("[ChatUtils.modifyMessage] \t\tTimestamp structure: {}", timestamp); - LOGGER.debug("[ChatUtils.modifyMessage] \t\tContent structure: {}", content); + LOGGER.error("[ChatUtils.modifyMessage] An error occurred while modifying message '{}':", m.getString()); + LOGGER.error("[ChatUtils.modifyMessage] \tModified message structure:"); + LOGGER.error("[ChatUtils.modifyMessage] \t\tTimestamp structure: {}", timestamp); + LOGGER.error("[ChatUtils.modifyMessage] \t\tContent structure: {}", content); ChatPatches.logReportMsg(e); errorThrown = true;