Skip to content

Commit 7108f00

Browse files
committed
Fix complex hover messages, use strict.
1 parent c5cde25 commit 7108f00

File tree

4 files changed

+7
-0
lines changed

4 files changed

+7
-0
lines changed

src/client/resources/web/js/chat.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
'use strict';
12
let ws;
23
const wsPort = parseInt(location.port, 10) + 1;
34
let reconnectAttempts = 0;

src/client/resources/web/js/message_parsing.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
'use strict';
12
// Minecraft JSON message parsing to HTML.
23
// A lot of the code below has been inspired (though not directly copied) by prismarine-chat: https://github.com/PrismarineJS/prismarine-chat
34

@@ -267,6 +268,9 @@ function formatComponent(component, depth = 0) {
267268
hoverContent = typeof component.hoverEvent.contents.name === 'string'
268269
? component.hoverEvent.contents.name
269270
: formatComponentPlainText(component.hoverEvent.contents.name);
271+
} else if (typeof component.hoverEvent.contents === 'object') {
272+
// Handle translation objects in hover content
273+
hoverContent = formatComponentPlainText(component.hoverEvent.contents);
270274
} else {
271275
hoverContent = JSON.stringify(component.hoverEvent.contents);
272276
}

src/client/resources/web/js/translations.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
'use strict';
12
// https://github.com/PrismarineJS/minecraft-data 1.21.1
23
const translations = {
34
"accessibility.onboarding.accessibility.button": "Accessibility Settings...",

src/client/resources/web/js/util.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
'use strict';
12
function faviconCounter(count) {
23
const sizes = [16, 32];
34
const links = {};

0 commit comments

Comments
 (0)