-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheconomyAPI.h
64 lines (49 loc) · 1.7 KB
/
economyAPI.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//
// Created by admin on 2024/7/28.
//
#include "endstone/plugin/plugin.h"
#include "endstone/event/event_handler.h"
#include "endstone/command/plugin_command.h"
#include "endstone/event/player/player_join_event.h"
#include "economyListener.h"
#include "command/economyCommand.h"
#include "util/data/poco/jsonHelper.h"
#include "util/files/filesInitialize.h"
#include <iostream>
class economyAPI : public endstone::Plugin{
public:
void onLoad() override
{
getLogger().info("EconomyAPI Loading!");
}
void onEnable() override{
getLogger().info("EconomyAPI Activated");
if (auto *command = getCommand("economy")) {
command->setExecutor(std::make_unique<economyCommand>());
}
try{
filesInitialize::configInitialize();
filesInitialize::languageInitialize();
filesInitialize::dataBaseInitialize();
}catch (const std::runtime_error& e){
getLogger().error(e.what());
}
listener_ = std::make_unique<economyListener>(*this);
registerEvent(&economyListener::onPlayerJoin, *listener_, endstone::EventPriority::Normal);
}
void onDisable() override
{
getLogger().info("EconomyAPI Disable!");
}
void registerCommand(const std::vector<std::string>& names, std::unique_ptr<CommandExecutor>& executor) {
for (const std::string& name : names) {
auto * command = getCommand(name);
if (command == nullptr) {
throw std::invalid_argument("Unknown command '" + name + "'");
}
command->setExecutor(std::move(executor));
}
}
private:
std::unique_ptr<economyListener> listener_;
};