TerminalMC / ChatNotify

A client-side multi-loader Minecraft mod that allows the user to set up audio and visual notifications for chat messages.
https://modrinth.com/mod/Iudurxl8
Apache License 2.0
1 stars 0 forks source link

Packet handling error #5

Open Xantrisse opened 2 weeks ago

Xantrisse commented 2 weeks ago

Mod Version

ChatNotify-Fabric-1.21-2.0.0

Mod Loader

Fabric

Minecraft Version

1.21

Bug Description

I was disconnected from the server when the message "f added" appeared in the chat

Reproduction Steps

  1. Join a server with the CoreProtect plugin
  2. Add the item to the chest
  3. Use the command "/co lookup user:YOUR NICK time:1d"
  4. Error

Log File (optional)

---- Minecraft Network Protocol Error Report ---- // What we've got here is failure to communicate

Time: 2024-07-02 13:01:37 Description: Packet handling error

java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10 at java.base/jdk.internal.util.Preconditions$1.apply(Preconditions.java:55) at java.base/jdk.internal.util.Preconditions$1.apply(Preconditions.java:52) at java.base/jdk.internal.util.Preconditions$4.apply(Preconditions.java:213) at java.base/jdk.internal.util.Preconditions$4.apply(Preconditions.java:210) at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:98) at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:106) at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:302) at java.base/java.lang.String.checkIndex(String.java:4832) at java.base/java.lang.StringLatin1.charAt(StringLatin1.java:46) at java.base/java.lang.String.charAt(String.java:1555) at dev.terminalmc.chatnotify.processor.MessageProcessor.activeFormatCodes(MessageProcessor.java:428) at dev.terminalmc.chatnotify.processor.MessageProcessor.restyleContents(MessageProcessor.java:356) at dev.terminalmc.chatnotify.processor.MessageProcessor.restyleComponent(MessageProcessor.java:304) at dev.terminalmc.chatnotify.processor.MessageProcessor.lambda$restyleContents$1(MessageProcessor.java:412) at java.base/java.util.ArrayList.replaceAllRange(ArrayList.java:1795) at java.base/java.util.ArrayList.replaceAll(ArrayList.java:1785) at dev.terminalmc.chatnotify.processor.MessageProcessor.restyleContents(MessageProcessor.java:412) at dev.terminalmc.chatnotify.processor.MessageProcessor.restyleComponent(MessageProcessor.java:304) at dev.terminalmc.chatnotify.processor.MessageProcessor.complexRestyle(MessageProcessor.java:286) at dev.terminalmc.chatnotify.processor.MessageProcessor.tryNotify(MessageProcessor.java:160) at dev.terminalmc.chatnotify.processor.MessageProcessor.processMessage(MessageProcessor.java:53) at net.minecraft.class_338.localvar$zza000$chatnotify$replaceMessage(class_338.java:631) at net.minecraft.class_338.method_44811(class_338.java) at net.minecraft.class_338.method_1812(class_338.java:208) at net.minecraft.class_7594.method_44736(class_7594.java:196) at net.minecraft.class_634.method_43596(class_634.java:904) at net.minecraft.class_7439.method_43631(class_7439.java:25) at net.minecraft.class_7439.method_11054(class_7439.java:11) at net.minecraft.class_2600.method_11072(class_2600.java:27) at net.minecraft.class_1255.method_18859(class_1255.java:162) at net.minecraft.class_4093.method_18859(class_4093.java:23) at net.minecraft.class_1255.method_16075(class_1255.java:136) at net.minecraft.class_1255.method_5383(class_1255.java:121) at net.minecraft.class_310.method_1523(class_310.java:1240) at net.minecraft.class_310.method_1514(class_310.java:882) at net.minecraft.client.main.Main.main(Main.java:256) at net.fabricmc.loader.impl.game.minecraft.MinecraftGameProvider.launch(MinecraftGameProvider.java:470) at net.fabricmc.loader.impl.launch.knot.Knot.launch(Knot.java:74) at net.fabricmc.loader.impl.launch.knot.KnotClient.main(KnotClient.java:23)

A detailed walkthrough of the error, its code path and all known details is as follows:

-- Head -- Thread: Render thread Stacktrace: at java.base/jdk.internal.util.Preconditions$1.apply(Preconditions.java:55) at java.base/jdk.internal.util.Preconditions$1.apply(Preconditions.java:52) at java.base/jdk.internal.util.Preconditions$4.apply(Preconditions.java:213) at java.base/jdk.internal.util.Preconditions$4.apply(Preconditions.java:210) at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:98) at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:106) at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:302) at java.base/java.lang.String.checkIndex(String.java:4832) at java.base/java.lang.StringLatin1.charAt(StringLatin1.java:46) at java.base/java.lang.String.charAt(String.java:1555) at dev.terminalmc.chatnotify.processor.MessageProcessor.activeFormatCodes(MessageProcessor.java:428) at dev.terminalmc.chatnotify.processor.MessageProcessor.restyleContents(MessageProcessor.java:356) at dev.terminalmc.chatnotify.processor.MessageProcessor.restyleComponent(MessageProcessor.java:304) at dev.terminalmc.chatnotify.processor.MessageProcessor.lambda$restyleContents$1(MessageProcessor.java:412) at java.base/java.util.ArrayList.replaceAllRange(ArrayList.java:1795) at java.base/java.util.ArrayList.replaceAll(ArrayList.java:1785) at dev.terminalmc.chatnotify.processor.MessageProcessor.restyleContents(MessageProcessor.java:412) at dev.terminalmc.chatnotify.processor.MessageProcessor.restyleComponent(MessageProcessor.java:304) at dev.terminalmc.chatnotify.processor.MessageProcessor.complexRestyle(MessageProcessor.java:286) at dev.terminalmc.chatnotify.processor.MessageProcessor.tryNotify(MessageProcessor.java:160) at dev.terminalmc.chatnotify.processor.MessageProcessor.processMessage(MessageProcessor.java:53) at net.minecraft.class_338.localvar$zza000$chatnotify$replaceMessage(class_338.java:631) at net.minecraft.class_338.method_44811(class_338.java) at net.minecraft.class_338.method_1812(class_338.java:208) at net.minecraft.class_7594.method_44736(class_7594.java:196)

-- Incoming Packet -- Details: Type: clientbound/minecraft:system_chat Is Terminal: false Is Skippable: true Stacktrace: at net.minecraft.class_2600.method_59803(class_2600.java:56) at net.minecraft.class_8673.method_60882(class_8673.java:136) at net.minecraft.class_8673.method_59807(class_8673.java:113) at net.minecraft.class_2600.method_11072(class_2600.java:32) at net.minecraft.class_1255.method_18859(class_1255.java:162) at net.minecraft.class_4093.method_18859(class_4093.java:23) at net.minecraft.class_1255.method_16075(class_1255.java:136) at net.minecraft.class_1255.method_5383(class_1255.java:121) at net.minecraft.class_310.method_1523(class_310.java:1240) at net.minecraft.class_310.method_1514(class_310.java:882) at net.minecraft.client.main.Main.main(Main.java:256) at net.fabricmc.loader.impl.game.minecraft.MinecraftGameProvider.launch(MinecraftGameProvider.java:470) at net.fabricmc.loader.impl.launch.knot.Knot.launch(Knot.java:74) at net.fabricmc.loader.impl.launch.knot.KnotClient.main(KnotClient.java:23)

-- Connection -- Details: Protocol: play Flow: CLIENTBOUND Server type: OTHER Server brand: Paper (Velocity)

-- System Details -- Details: Minecraft Version: 1.21 Minecraft Version ID: 1.21 Operating System: Windows 10 (amd64) version 10.0 Java Version: 21.0.3, Microsoft Java VM Version: OpenJDK 64-Bit Server VM (mixed mode), Microsoft Memory: 949781808 bytes (905 MiB) / 1677721600 bytes (1600 MiB) up to 10737418240 bytes (10240 MiB) CPUs: 4 Processor Vendor: GenuineIntel Processor Name: Intel(R) Core(TM) i3-3220 CPU @ 3.30GHz Identifier: Intel64 Family 6 Model 58 Stepping 9 Microarchitecture: Ivy Bridge (Client) Frequency (GHz): 3.29 Number of physical packages: 1 Number of physical CPUs: 2 Number of logical CPUs: 4 Graphics card #0 name: Intel(R) HD Graphics Graphics card #0 vendor: Intel Corporation Graphics card #0 VRAM (MiB): 2112.00 Graphics card #0 deviceId: VideoController1 Graphics card #0 versionInfo: 10.18.10.4252 Graphics card #1 name: NVIDIA GeForce GTX 650 Graphics card #1 vendor: NVIDIA Graphics card #1 VRAM (MiB): 1024.00 Graphics card #1 deviceId: VideoController2 Graphics card #1 versionInfo: 30.0.14.7482 Memory slot #0 capacity (MiB): 4096.00 Memory slot #0 clockSpeed (GHz): 1.33 Memory slot #0 type: DDR3 Memory slot #1 capacity (MiB): 8192.00 Memory slot #1 clockSpeed (GHz): 1.33 Memory slot #1 type: DDR3 Virtual memory max (MiB): 14108.16 Virtual memory used (MiB): 5974.71 Swap memory total (MiB): 1856.00 Swap memory used (MiB): 16.66 Space in storage for jna.tmpdir (MiB): available: 138715.11, total: 228309.69 Space in storage for org.lwjgl.system.SharedLibraryExtractPath (MiB): available: 138715.11, total: 228309.69 Space in storage for io.netty.native.workdir (MiB): available: 138715.11, total: 228309.69 Space in storage for java.io.tmpdir (MiB): available: 138715.11, total: 228309.69 Space in storage for workdir (MiB): available: 138715.11, total: 228309.69 JVM Flags: 9 total; -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump -Xss1M -Xmx10G -XX:+UnlockExperimentalVMOptions -XX:+UseG1GC -XX:G1NewSizePercent=20 -XX:G1ReservePercent=20 -XX:MaxGCPauseMillis=50 -XX:G1HeapRegionSize=32M Fabric Mods: chatnotify: ChatNotify 2.0.0 chesttracker: Chest Tracker 2.4.9+1.21 whereisit: Where Is It 2.5.0+1.21 jackfredlib: JackFredLib 0.10.0+1.21 jackfredlib-base: JackFredLib: Base 1.4.0+1.21 jackfredlib-colour: JackFredLib: Colour 1.1.0+1.21 jackfredlib-extracommandsourcedata: JackFredLib: Extra Command Source Data 1.1.1+1.21 jackfredlib-gps: JackFredLib: GPS 1.0.7+1.21 jackfredlib-lying: JackFredLib: Lying 0.5.5+1.21 jackfredlib-toasts: JackFredLib: Toasts 1.1.0+1.21 fabric-api: Fabric API 0.100.4+1.21 fabric-api-base: Fabric API Base 0.4.42+6573ed8cd1 fabric-api-lookup-api-v1: Fabric API Lookup API (v1) 1.6.67+b5597344d1 fabric-biome-api-v1: Fabric Biome API (v1) 13.0.28+6fc22b99d1 fabric-block-api-v1: Fabric Block API (v1) 1.0.22+0af3f5a7d1 fabric-block-view-api-v2: Fabric BlockView API (v2) 1.0.10+6573ed8cd1 fabric-blockrenderlayer-v1: Fabric BlockRenderLayer Registration (v1) 1.1.52+0af3f5a7d1 fabric-client-tags-api-v1: Fabric Client Tags 1.1.15+6573ed8cd1 fabric-command-api-v1: Fabric Command API (v1) 1.2.48+f71b366fd1 fabric-command-api-v2: Fabric Command API (v2) 2.2.27+6a6dfa19d1 fabric-commands-v0: Fabric Commands (v0) 0.2.65+df3654b3d1 fabric-content-registries-v0: Fabric Content Registries (v0) 8.0.14+b5597344d1 fabric-convention-tags-v1: Fabric Convention Tags 2.0.15+7f945d5bd1 fabric-convention-tags-v2: Fabric Convention Tags (v2) 2.3.2+78017270d1 fabric-crash-report-info-v1: Fabric Crash Report Info (v1) 0.2.29+0af3f5a7d1 fabric-data-attachment-api-v1: Fabric Data Attachment API (v1) 1.1.24+6a6dfa19d1 fabric-data-generation-api-v1: Fabric Data Generation API (v1) 20.2.9+16c4ae25d1 fabric-dimensions-v1: Fabric Dimensions API (v1) 4.0.0+6fc22b99d1 fabric-entity-events-v1: Fabric Entity Events (v1) 1.6.12+6fc22b99d1 fabric-events-interaction-v0: Fabric Events Interaction (v0) 0.7.10+e633f883d1 fabric-game-rule-api-v1: Fabric Game Rule API (v1) 1.0.52+6573ed8cd1 fabric-item-api-v1: Fabric Item API (v1) 11.0.0+afdfc921d1 fabric-item-group-api-v1: Fabric Item Group API (v1) 4.1.2+78017270d1 fabric-key-binding-api-v1: Fabric Key Binding API (v1) 1.0.47+0af3f5a7d1 fabric-keybindings-v0: Fabric Key Bindings (v0) 0.2.45+df3654b3d1 fabric-lifecycle-events-v1: Fabric Lifecycle Events (v1) 2.3.11+8f3583aed1 fabric-loot-api-v2: Fabric Loot API (v2) 3.0.11+6573ed8cd1 fabric-message-api-v1: Fabric Message API (v1) 6.0.13+6573ed8cd1 fabric-model-loading-api-v1: Fabric Model Loading API (v1) 2.0.0+fe474d6bd1 fabric-networking-api-v1: Fabric Networking API (v1) 4.2.0+ab7edbacd1 fabric-object-builder-api-v1: Fabric Object Builder API (v1) 15.1.12+d1321076d1 fabric-particles-v1: Fabric Particles (v1) 4.0.2+6573ed8cd1 fabric-recipe-api-v1: Fabric Recipe API (v1) 5.0.10+65089712d1 fabric-registry-sync-v0: Fabric Registry Sync (v0) 5.0.23+78017270d1 fabric-renderer-api-v1: Fabric Renderer API (v1) 3.3.0+0ae0b97dd1 fabric-renderer-indigo: Fabric Renderer - Indigo 1.6.5+48fb1586d1 fabric-renderer-registries-v1: Fabric Renderer Registries (v1) 3.2.67+df3654b3d1 fabric-rendering-data-attachment-v1: Fabric Rendering Data Attachment (v1) 0.3.48+73761d2ed1 fabric-rendering-fluids-v1: Fabric Rendering Fluids (v1) 3.1.6+b5597344d1 fabric-rendering-v0: Fabric Rendering (v0) 1.1.70+df3654b3d1 fabric-rendering-v1: Fabric Rendering (v1) 5.0.4+5a8c785ed1 fabric-resource-conditions-api-v1: Fabric Resource Conditions API (v1) 4.2.1+d153f344d1 fabric-resource-loader-v0: Fabric Resource Loader (v0) 1.1.5+78017270d1 fabric-screen-api-v1: Fabric Screen API (v1) 2.0.24+b5597344d1 fabric-screen-handler-api-v1: Fabric Screen Handler API (v1) 1.3.80+b5597344d1 fabric-sound-api-v1: Fabric Sound API (v1) 1.0.23+6573ed8cd1 fabric-transfer-api-v1: Fabric Transfer API (v1) 5.1.15+3dccd343d1 fabric-transitive-access-wideners-v1: Fabric Transitive Access Wideners (v1) 6.0.12+6573ed8cd1 fabricloader: Fabric Loader 0.15.11 mixinextras: MixinExtras 0.3.5 java: OpenJDK 64-Bit Server VM 21 lithium: Lithium 0.12.7 minecraft: Minecraft 1.21 modmenu: Mod Menu 11.0.1 placeholder-api: Placeholder API 2.4.0-pre.2+1.21 sodium: Sodium 0.5.11+mc1.21 viafabricplus: ViaFabricPlus 3.4.1 com_google_code_findbugs_jsr305: jsr305 3.0.2 com_vdurmont_semver4j: semver4j 3.1.0 com_viaversion_viabackwards-common: viabackwards-common 5.0.1 com_viaversion_viaversion-common: viaversion-common 5.0.1 de_florianmichael_classic4j: Classic4J 2.0.2 io_jsonwebtoken_jjwt-api: jjwt-api 0.12.3 io_jsonwebtoken_jjwt-gson: jjwt-gson 0.12.3 io_jsonwebtoken_jjwt-impl: jjwt-impl 0.12.3 io_netty_netty-codec-http: netty-codec-http 4.1.111 net_jodah_expiringmap: expiringmap 0.5.10 net_lenni0451_commons_httpclient: httpclient 1.4.1 net_lenni0451_mcping: MCPing 1.4.0 net_lenni0451_mcstructs-bedrock_forms: forms 1.2.0 net_lenni0451_mcstructs-bedrock_text: text 1.2.0 net_lenni0451_reflect: Reflect 1.3.2 net_raphimc_minecraftauth: MinecraftAuth 4.0.0 net_raphimc_viaaprilfools: ViaAprilFools 3.0.0 net_raphimc_viabedrock: ViaBedrock 0.0.9-SNAPSHOT net_raphimc_vialegacy: ViaLegacy 3.0.1 net_raphimc_vialoader: ViaLoader 3.0.1 org_cloudburstmc_netty_netty-transport-raknet: netty-transport-raknet 1.0.0.CR3-SNAPSHOT org_iq80_leveldb_leveldb: leveldb 0.12 org_iq80_leveldb_leveldb-api: leveldb-api 0.12 org_lz4_lz4-pure-java: lz4-pure-java 1.8.0 org_yaml_snakeyaml: snakeyaml 2.2 yet_another_config_lib_v3: YetAnotherConfigLib 3.5.0+1.21-fabric com_twelvemonkeys_common_common-image: common-image 3.10.0 com_twelvemonkeys_common_common-io: common-io 3.10.0 com_twelvemonkeys_common_common-lang: common-lang 3.10.0 com_twelvemonkeys_imageio_imageio-core: imageio-core 3.10.0 com_twelvemonkeys_imageio_imageio-metadata: imageio-metadata 3.10.0 com_twelvemonkeys_imageio_imageio-webp: imageio-webp 3.10.0 org_quiltmc_parsers_gson: gson 0.2.1 org_quiltmc_parsers_json: json 0.2.1

Crash Report (optional)

No response

Xantrisse commented 2 weeks ago

image image

NotRyken commented 2 weeks ago

Thanks for reporting, I have reproduced the issue and will begin working on a fix.

NotRyken commented 2 weeks ago

Question, how did you come to use "f added" as a trigger? The f it's picking up on is the format code for white, which is what's causing the problem in the restyle algorithm. The obvious way to fix it would be to ignore format codes when doing the trigger check unless regex is enabled.

Xantrisse commented 2 weeks ago

I wanted it to detect "f added" and not just "added" because "f added" means something hasn't been rolled back and "f §m added" means rolled back. If I did without it, it would show rollback changes and those that were not rolled back. I haven't tried using regex yet, but I will try :)

NotRyken commented 2 weeks ago

I think it will be necessary to prevent normal triggers from matching format codes. Regex triggers do use the literal message text but consequently they can't selectively highlight, so that may not be suitable for your use-case.

However, the effect you described can be achieved using an exclusion trigger m added, paired with a normal trigger added. See below for the notification json entry, which can be added to the existing list of notifications, though I advise backing up your existing config file before attempting to modify it manually.

Note that regex is enabled for the exclusion trigger. This is not currently necessary, but will be necessary when the patch is rolled out, as format codes will then be ignored by non-regex triggers.

notification json ```json { "version": 1, "enabled": true, "exclusionEnabled": true, "responseEnabled": false, "sound": { "version": 1, "enabled": true, "id": "block.note_block.bell", "volume": 1.0, "pitch": 1.0 }, "textStyle": { "version": 1, "doColor": true, "color": 65280, "bold": { "state": "DISABLED" }, "italic": { "state": "DISABLED" }, "underlined": { "state": "DISABLED" }, "strikethrough": { "state": "DISABLED" }, "obfuscated": { "state": "DISABLED" } }, "triggers": [ { "version": 1, "enabled": true, "string": "added", "isKey": false, "isRegex": false } ], "exclusionTriggers": [ { "version": 1, "enabled": true, "string": "m added", "isKey": false, "isRegex": true } ], "responseMessages": [] } ```
Xantrisse commented 1 week ago

Thank you! It changes a lot :) 2024-07-05_12 03 42

NotRyken commented 1 week ago

My latest design to fix this is to have an optional second field for each trigger, which tells chatnotify what to restyle, and all restyle operations ignore format codes. Thus in your case you'd have a trigger 'f added' and a style string 'added'. It's a work in progress, edit: now released as v2.1.0-beta.1