mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2025-01-18 23:46:28 +01:00
Sort messenger search results
This commit is contained in:
parent
cb8df7ce6e
commit
85831a9df3
@ -7,11 +7,17 @@ import com.eu.habbo.messages.outgoing.MessageComposer;
|
|||||||
import com.eu.habbo.messages.outgoing.Outgoing;
|
import com.eu.habbo.messages.outgoing.Outgoing;
|
||||||
import gnu.trove.set.hash.THashSet;
|
import gnu.trove.set.hash.THashSet;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class UserSearchResultComposer extends MessageComposer {
|
public class UserSearchResultComposer extends MessageComposer {
|
||||||
private final THashSet<MessengerBuddy> users;
|
private final THashSet<MessengerBuddy> users;
|
||||||
private final THashSet<MessengerBuddy> friends;
|
private final THashSet<MessengerBuddy> friends;
|
||||||
private final Habbo habbo;
|
private final Habbo habbo;
|
||||||
|
|
||||||
|
private static Comparator COMPARATOR = Comparator.comparing((MessengerBuddy b) -> b.getUsername().length()).thenComparing((MessengerBuddy b, MessengerBuddy b2) -> b.getUsername().compareToIgnoreCase(b2.getUsername()));
|
||||||
|
|
||||||
public UserSearchResultComposer(THashSet<MessengerBuddy> users, THashSet<MessengerBuddy> friends, Habbo habbo) {
|
public UserSearchResultComposer(THashSet<MessengerBuddy> users, THashSet<MessengerBuddy> friends, Habbo habbo) {
|
||||||
this.users = users;
|
this.users = users;
|
||||||
this.friends = friends;
|
this.friends = friends;
|
||||||
@ -21,7 +27,7 @@ public class UserSearchResultComposer extends MessageComposer {
|
|||||||
@Override
|
@Override
|
||||||
public ServerMessage compose() {
|
public ServerMessage compose() {
|
||||||
this.response.init(Outgoing.UserSearchResultComposer);
|
this.response.init(Outgoing.UserSearchResultComposer);
|
||||||
THashSet<MessengerBuddy> u = new THashSet<>();
|
List<MessengerBuddy> u = new ArrayList<>();
|
||||||
|
|
||||||
for (MessengerBuddy buddy : this.users) {
|
for (MessengerBuddy buddy : this.users) {
|
||||||
if (!buddy.getUsername().equals(this.habbo.getHabboInfo().getUsername()) && !this.inFriendList(buddy)) {
|
if (!buddy.getUsername().equals(this.habbo.getHabboInfo().getUsername()) && !this.inFriendList(buddy)) {
|
||||||
@ -29,6 +35,11 @@ public class UserSearchResultComposer extends MessageComposer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<MessengerBuddy> friends = new ArrayList<>(this.friends);
|
||||||
|
|
||||||
|
u.sort(UserSearchResultComposer.COMPARATOR);
|
||||||
|
friends.sort(UserSearchResultComposer.COMPARATOR);
|
||||||
|
|
||||||
this.response.appendInt(this.friends.size());
|
this.response.appendInt(this.friends.size());
|
||||||
for (MessengerBuddy buddy : this.friends) {
|
for (MessengerBuddy buddy : this.friends) {
|
||||||
this.response.appendInt(buddy.getId());
|
this.response.appendInt(buddy.getId());
|
||||||
|
Loading…
Reference in New Issue
Block a user