fix friendhighlight bug with no friends and close #739

This commit is contained in:
Bella 2020-04-22 13:00:29 -04:00
parent cd7d6da17a
commit fa89bc66ff
No known key found for this signature in database
GPG Key ID: DBD4A6030080C8B3
1 changed files with 11 additions and 1 deletions

View File

@ -29,17 +29,27 @@ public class FriendHighlight extends Module {
sendErrorMessage(getChatName() + "Your friends list is bigger then 100, disabling as it would cause too much of a performance impact.");
disable();
}
noFriendsCheck();
}
@EventHandler
public Listener<ClientChatReceivedEvent> listener = new Listener<>(event -> {
if (mc.player == null) return;
if (mc.player == null || noFriendsCheck()) return;
final String[] converted = {""};
Friends.friends.getValue().forEach(friend -> converted[0] = event.getMessage().getFormattedText().replaceAll("(?i)" + friend.getUsername(), colour() + bold() + friend.getUsername() + TextFormatting.RESET.toString()));
TextComponentString message = new TextComponentString(converted[0]);
event.setMessage(message);
});
private boolean noFriendsCheck() {
if (Friends.friends.getValue().size() == 0) {
sendErrorMessage(getChatName() + "You don't have any friends added, silly! Go add some friends before using the module");
disable();
return true;
}
return false;
}
private String bold() {
if (!bold.getValue()) return "";
return TextFormatting.BOLD.toString();