Skip to content
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 41 additions & 5 deletions src/MyPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,67 @@
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU AGPL v3 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE-AGPL3
*/

#include "ScriptMgr.h"
#include "Player.h"
#include "Config.h"
#include "Chat.h"
#include "ConfigValueCache.h"
#include "Player.h"
#include "ScriptMgr.h"

enum MyPlayerAcoreString
{
HELLO_WORLD = 35410
};

enum class MyConfig
{
ENABLED,

NUM_CONFIGS,
};

class MyConfigData : public ConfigValueCache<MyConfig>
{
public:
MyConfigData() : ConfigValueCache(MyConfig::NUM_CONFIGS) { };

void BuildConfigCache() override
{
SetConfigValue<bool>(MyConfig::ENABLED, "MyModule.Enable", true);
}
};

static MyConfigData myConfigData;

// Add player scripts
class MyPlayer : public PlayerScript
{
public:
MyPlayer() : PlayerScript("MyPlayer") { }
MyPlayer() : PlayerScript("MyPlayer", {
PLAYERHOOK_ON_LOGIN
}) { }

void OnPlayerLogin(Player* player) override
{
if (sConfigMgr->GetOption<bool>("MyModule.Enable", false))
if (myConfigData.GetConfigValue<bool>(MyConfig::ENABLED))
ChatHandler(player->GetSession()).PSendSysMessage(HELLO_WORLD);
}
};

class MyWorldScript : public WorldScript
{
public:
MyWorldScript() : WorldScript("MyWorldScript", {
Comment thread
Tereneckla marked this conversation as resolved.
Outdated
WORLDHOOK_ON_BEFORE_CONFIG_LOAD
}) { }

void OnBeforeConfigLoad(bool reload) override
{
myConfigData.Initialize(reload);
}
};

// Add all scripts in one
void AddMyPlayerScripts()
{
new MyPlayer();
new MyWorldScript();
}