Mineserver
A rewrite of Minecraft 1.8.9 in C++ !
Loading...
Searching...
No Matches
plugins.h
Go to the documentation of this file.
1
12#ifndef MINESERVER_PLUGINS_H
13#define MINESERVER_PLUGINS_H
14
15#include <string>
16#include <filesystem>
17#include <vector>
18#include <plugins/luaheaders.h>
19
24class Plugin
25{
26private:
27 std::string path;
28 lua_State *state;
29
30 void defineLibs();
31
32public:
37 std::string name;
42 std::string version;
48 explicit Plugin(std::string path);
54 ~Plugin();
55
62 bool load();
63};
64
71{
72private:
73 static constexpr std::string_view BASE_PATH = "./plugins/";
74 std::vector<std::shared_ptr<Plugin>> plugins;
75
76 static PluginsManager *instance;
77
78public:
89
95 void load();
96
102 const std::vector<std::shared_ptr<Plugin>> &getPlugins() const
103 {
104 return plugins;
105 }
106
113 {
114 return *instance;
115 }
116};
117
118#endif // MINESERVER_PLUGINS_H
Plugin class.
Definition plugins.h:25
bool load()
Loads the plugin.
Definition plugins.cpp:31
std::string name
Name of the plugin.
Definition plugins.h:37
Plugin(std::string path)
Construct a new Plugin object.
Definition plugins.cpp:22
std::string version
Version of the plugin.
Definition plugins.h:42
~Plugin()
Destroy the Plugin object.
Definition plugins.cpp:26
Plugin Manager.
Definition plugins.h:71
void load()
Load all plugins in plugin folder.
Definition plugins.cpp:87
static PluginsManager & inst()
Gets the instance of the plugin manager.
Definition plugins.h:112
PluginsManager()
Construct a new Plugins Manager object.
Definition plugins.cpp:73
~PluginsManager()
Destroy the Plugins Manager object.
Definition plugins.cpp:81
const std::vector< std::shared_ptr< Plugin > > & getPlugins() const
Get the registered plugins.
Definition plugins.h:102
constexpr std::string_view type_name()
Gets the name of the type paramater.
Definition event.h:56
Utility header file for lua things.