fix(rcon): allow online motto updates outside rooms

SetMotto updated the in-memory motto and then unconditionally broadcast RoomUserData through the current room. Online users without a current room could throw a null-pointer exception after the state change, making the RCON call report an error despite mutating the user. Only broadcast room data when a room is present and cover the invariant with a contract test.
This commit is contained in:
simoleo89
2026-06-13 15:28:01 +02:00
parent d8260ec461
commit 4eafb54c57
2 changed files with 26 additions and 2 deletions
@@ -0,0 +1,22 @@
package com.eu.habbo.messages.rcon;
import org.junit.jupiter.api.Test;
import java.nio.file.Files;
import java.nio.file.Path;
import static org.junit.jupiter.api.Assertions.assertTrue;
class SetMottoContractTest {
private static String setMottoSource() throws Exception {
return Files.readString(Path.of("src/main/java/com/eu/habbo/messages/rcon/SetMotto.java"));
}
@Test
void onlineMottoUpdateDoesNotRequireCurrentRoom() throws Exception {
String source = setMottoSource();
assertTrue(source.contains("getCurrentRoom() != null"),
"RCON SetMotto must not fail for online users outside a room");
}
}