#include <ChatCommand/TimeCommand/TimeCommand.hpp>

TimeCommand::TimeCommand(LocalWorld &world)
{
    require(UserPermission::SetTimeOfDay);

    addVariant(
        "<hour> - Set the time to the specified hour.",
        [&world](Player &player, int hour)
        {
            int offsetHour = hour - 6 + 24;
            world.setTimeOfDay(World::cycleDuration * offsetHour / 24);

            player.writeChat(formatString("Time of day set to $+:00", hour), Color::success);
            Log::info(formatString("Time of day set to $+:00", hour));
        }
    );
}