From 264bddf42b0f9ba7b28e69864047986b59b6ad7c Mon Sep 17 00:00:00 2001 From: Ryan Barlow <7389646+ryanbarlow97@users.noreply.github.com> Date: Mon, 12 Oct 2026 07:06:44 +0000 Subject: [PATCH] fix: treat a null shared display name as no character name A null display name reached isBlank(), threw, and logged the "names skipped" warning for what is not a failure. It now falls back to the account name quietly. Co-Authored-By: Claude Opus 5.5 --- src/main/java/net/tfminecraft/games/voice/RpNames.java | 2 +- .../net/tfminecraft/games/voice/VoiceIntegrationTest.java | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/tfminecraft/games/voice/RpNames.java b/src/main/java/net/tfminecraft/games/voice/RpNames.java index 73b7dd5..625e898 100644 --- a/src/main/java/net/tfminecraft/games/voice/RpNames.java +++ b/src/main/java/net/tfminecraft/games/voice/RpNames.java @@ -37,7 +37,7 @@ public static String of(UUID id) { private static String characterDisplay(Player player) { try { String display = Characters.displayName(player); - return !display.isBlank() ? display : null; + return display != null && !display.isBlank() ? display : null; } catch (RuntimeException | LinkageError ex) { if (!loggedFail) { loggedFail = true; diff --git a/src/test/java/net/tfminecraft/games/voice/VoiceIntegrationTest.java b/src/test/java/net/tfminecraft/games/voice/VoiceIntegrationTest.java index bd5ce2f..301502c 100644 --- a/src/test/java/net/tfminecraft/games/voice/VoiceIntegrationTest.java +++ b/src/test/java/net/tfminecraft/games/voice/VoiceIntegrationTest.java @@ -101,11 +101,16 @@ void namesUseFreshSharedAliasesWithoutCanonicalCharacterLookups() { } @Test - void blankOrNullSharedDisplayUsesAccountName() { + void blankOrNullSharedDisplayUsesAccountNameWithoutLoggingAFailure() { when(identity.displayName(player)).thenReturn(" "); assertEquals("AccountName", RpNames.of(id)); when(identity.displayName(player)).thenReturn(null); assertEquals("AccountName", RpNames.of(id)); + try (var names = mockStatic(net.tfminecraft.tlibs.character.Characters.class)) { + names.when(() -> net.tfminecraft.tlibs.character.Characters.displayName(player)).thenReturn(null); + assertEquals("AccountName", RpNames.of(id)); + } + verifyNoInteractions(logger); } @Test