Two small things in ChatBox.addText:
if(username.equals("server") || color.contains("null")){
adapter.addItem(Localization.getLocalizedString(message));
} else
adapter.addItem(new UserMessageString(username, message, color));
-
It decides a message is a system message by checking username.equals("server"). But "server" is a perfectly valid username (the validator allows [a-zA-Z0-9_]{3,15}). So a real player who registers the username "server" has every chat line they send run through Localization.getLocalizedString(message) and rendered as a system message instead of their actual text. Same for color.contains("null") matching more broadly than intended. System messages should be tagged by something the client controls, not by a magic username string.
-
clearChat() doesn't null-check activity the way addText does:
public void clearChat() {
((ChatListAdapter) Objects.requireNonNull(chatList.getAdapter())).clear();
InputMethodManager inputMan = activity.getSystemService(InputMethodManager.class); // activity may be null after dispose
...
}
addText guards with if (activity == null) return; because a late socket event can arrive after teardown. clearChat() is reachable the same way (CLEAR_CHAT socket event) but has no guard, so a CLEAR_CHAT arriving after the ChatBox is disposed NPEs on activity.
File: android/src/com/focus/kingdom/ui/widget/ChatBox.java, addText line ~104-121 and clearChat line ~123-133.
Two small things in ChatBox.addText:
It decides a message is a system message by checking
username.equals("server"). But "server" is a perfectly valid username (the validator allows[a-zA-Z0-9_]{3,15}). So a real player who registers the username "server" has every chat line they send run throughLocalization.getLocalizedString(message)and rendered as a system message instead of their actual text. Same forcolor.contains("null")matching more broadly than intended. System messages should be tagged by something the client controls, not by a magic username string.clearChat() doesn't null-check
activitythe way addText does:addText guards with
if (activity == null) return;because a late socket event can arrive after teardown. clearChat() is reachable the same way (CLEAR_CHAT socket event) but has no guard, so a CLEAR_CHAT arriving after the ChatBox is disposed NPEs onactivity.File:
android/src/com/focus/kingdom/ui/widget/ChatBox.java, addText line ~104-121 and clearChat line ~123-133.