package net.cobem.grizzly.habbohotel.roleplay;

import net.cobem.grizzly.communication.composers.rooms.LeaveRoomComposer;
import net.cobem.grizzly.habbohotel.rooms.Room;

public class LeavingMonitor implements Runnable {
    private Thread Thread;

    private int WaitTime = 0;

    private int UserID = 0;

    private Room Room;

    public LeavingMonitor(int UserID) {
        this.UserID = UserID;
    }

    @Override
    public void run() {
        while (WaitTime > 0) {
            this.WaitTime--;

            try {
                Thread.sleep(1000);
            } catch (InterruptedException ignored) {
            }
        }

        Room.sendMessage(LeaveRoomComposer.compose(UserID));
    }

    public void startLeave(Room Room) {
        this.Room = Room;
        this.WaitTime = 15;

        this.Thread = new Thread(this);
        this.Thread.start();
    }
}
