package net.cobem.grizzly.communication.events.rooms;

import net.cobem.grizzly.Grizzly;
import net.cobem.grizzly.communication.EventRequest;
import net.cobem.grizzly.communication.GameEvent;
import net.cobem.grizzly.communication.composers.rooms.SendIgnoreStatusEvent;
import net.cobem.grizzly.habbohotel.sessions.Session;

public class IgnoreUserEvent implements GameEvent {

    @Override
    public void compose(Session Session, EventRequest Request) {
        String Username = Request.readString(); //Manipulate this data..

        Session mSession = Grizzly.getHabboHotel().getSessions().getByName(Username);

        if (mSession == null) //We have to do this the hard way..
        {
            return;
        }

        int ID = mSession.getHabbo().getID();

        Grizzly.getStorage().execute("INSERT INTO user_ignores (user_id, ignore_id) VALUES ('" + Session.getHabbo().getID() + "', '" + ID + "')");

        Session.getHabbo().getIgnored().add(ID);

        Session.sendResponse(SendIgnoreStatusEvent.compose(Username, true));
    }

}
