package net.cobem.grizzly.communication.composers.messenger;

import net.cobem.grizzly.Grizzly;
import net.cobem.grizzly.communication.EventResponse;
import net.cobem.grizzly.communication.HeaderLibrary;
import net.cobem.grizzly.habbohotel.users.User;
import net.cobem.grizzly.habbohotel.users.messenger.MessengerHandler;

public class SendFriendListComposer {
    public static EventResponse compose(int Rank, MessengerHandler Handler) {
        EventResponse Message = new EventResponse();

        Message.Initialize(HeaderLibrary.InitializeMessengerEvent);
        Message.addInt(1100);
        Message.addInt(300);
        Message.addInt(800);
        Message.addInt(1100);

        Message.addInt(0); //Categories

        /*if (Rank >= 5) {
            Message.addInt(Handler.GrabFriends().size() + 1);

            Message.addInt(new Integer(Grizzly.getConfig().get("habbo.messenger.staffbot.id")));
            Message.addString(Grizzly.getConfig().get("habbo.messenger.staffbot.username"));
            Message.addInt(1);
            Message.addBool(true);
            Message.addBool(false);
            Message.addString(Grizzly.getConfig().get("habbo.messenger.staffbot.look"));
            Message.addInt(0);
            Message.addString(Grizzly.getConfig().get("habbo.messenger.staffbot.motto"));
            Message.addString("");
            Message.addString("");
            Message.addBool(true);
            Message.addBool(true);
            Message.addBool(false);
            Message.addInt(588);

            for (User mUser : Handler.GrabFriends().values()) {
                Message.addInt(mUser.getID());
                Message.addString(mUser.getUsername());
                Message.addInt(1);
                Message.addBool((Grizzly.getHabboHotel().getSessions().getByID(mUser.getID()) != null));
                Message.addBool((Grizzly.getHabboHotel().getSessions().getByID(mUser.getID()) != null) && Grizzly.getHabboHotel().getSessions().getByID(mUser.getID()).getActor().CurrentRoom != null);
                Message.addString(mUser.getLook());
                Message.addInt(0);
                Message.addString(mUser.getMotto());
                Message.addString("");
                Message.addString("");
                Message.addBool(true);
                Message.addBool(true);
                Message.addBool(false);
                Message.addInt(588);
            }
        } else { */
            Message.addInt(Handler.GrabFriends().size());

            for (User mUser : Handler.GrabFriends().values()) {
                Message.addInt(mUser.getID());
                Message.addString(mUser.getUsername());
                Message.addInt(1);
                Message.addBool((Grizzly.getHabboHotel().getSessions().getByID(mUser.getID()) != null));
                Message.addBool((Grizzly.getHabboHotel().getSessions().getByID(mUser.getID()) != null) && Grizzly.getHabboHotel().getSessions().getByID(mUser.getID()).getActor().CurrentRoom != null);
                Message.addString(mUser.getLook());
                Message.addInt(0);
                Message.addString(mUser.getMotto());
                Message.addString("");
                Message.addString("");
                Message.addBool(true);
                Message.addBool(true);
                Message.addBool(false);
                Message.addInt(588);   // the fuk is this
            }
        //}
        return Message;
    }
}
