Skip to content

Commit

Permalink
More syncing with omnivers
Browse files Browse the repository at this point in the history
  • Loading branch information
mrbuilder1961 committed Dec 16, 2024
1 parent dc3ed5a commit 3c2aca3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 29 deletions.
2 changes: 1 addition & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 1 addition & 23 deletions src/main/java/obro1961/chatpatches/ChatPatches.java
Original file line number Diff line number Diff line change
Expand Up @@ -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}.
Expand All @@ -45,6 +43,7 @@ public static Identifier id(String path) {
return Identifier.of(MOD_ID, path);
}


@Override
public void onInitializeClient() {
/*
Expand Down Expand Up @@ -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
Expand Down
9 changes: 4 additions & 5 deletions src/main/java/obro1961/chatpatches/util/ChatUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 3c2aca3

Please sign in to comment.