#include "mod_personal_isle.h"
#include "Chat.h"
#include "Config.h"
#include "Log.h"
#include "ScriptMgr.h"

using namespace Acore::ChatCommands;

// v0: hello-world stub. Proves the module loads, its config flag is readable, and a command
// registers and responds -- no island, no teleport, no map/DBC work yet. See PLAN.md for the
// actual roadmap (terrain, instancing, entry/exit points).

class PersonalIsleCommandScript : public CommandScript
{
public:
    PersonalIsleCommandScript() : CommandScript("PersonalIsleCommandScript") { }

    ChatCommandTable GetCommands() const override
    {
        static ChatCommandTable commandTable =
        {
            { "isle", HandleIsleCommand, SEC_PLAYER, Console::No },
        };

        return commandTable;
    }

    static bool HandleIsleCommand(ChatHandler* handler)
    {
        if (!sConfigMgr->GetOption("PersonalIsle.Enable", true))
        {
            handler->PSendSysMessage("The Personal Isle module is currently disabled.");
            return true;
        }

        handler->PSendSysMessage("A weathered chart shows an island... but there's no dock built yet.");
        return true;
    }
};

class PersonalIsle_World : public WorldScript
{
public:
    PersonalIsle_World() : WorldScript("PersonalIsle_World") { }

    void OnStartup() override
    {
        LOG_INFO("server.loading", "mod-personal-isle: loaded (v0 hello-world stub, enabled={}).",
            sConfigMgr->GetOption("PersonalIsle.Enable", true));
    }
};

void AddSC_mod_personal_isle()
{
    new PersonalIsleCommandScript();
    new PersonalIsle_World();
}