Cuberite
A lightweight, fast and extensible game server for Minecraft
Plugin.cpp
Go to the documentation of this file.
1 
2 #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
3 
4 #include "Plugin.h"
5 
6 
7 
8 
9 
10 cPlugin::cPlugin(const AString & a_FolderName) :
11  m_Status(cPluginManager::psDisabled),
12  m_Name(a_FolderName),
13  m_Version(0),
14  m_FolderName(a_FolderName)
15 {
16 }
17 
18 
19 
20 
21 
23 {
24  LOGD("Destroying plugin \"%s\".", m_Name.c_str());
25 }
26 
27 
28 
29 
30 
31 void cPlugin::Unload(void)
32 {
33  auto pm = cPluginManager::Get();
34  pm->RemovePluginCommands(this);
35  pm->RemovePluginConsoleCommands(this);
36  pm->RemoveHooks(this);
37  OnDisable();
39  m_LoadError.clear();
40 }
41 
42 
43 
44 
45 
47 {
48  return std::string("Plugins/") + m_FolderName;
49 }
50 
51 
52 
53 
54 
55 void cPlugin::SetLoadError(const AString & a_LoadError)
56 {
58  m_LoadError = a_LoadError;
59 }
60 
61 
62 
63 
cPlugin(const AString &a_FolderName)
Creates a new instance.
Definition: Plugin.cpp:10
virtual void OnDisable(void)
Called as the last call into the plugin before it is unloaded.
Definition: Plugin.h:32
AString m_FolderName
Name of the folder (in the Plugins folder) from which the plugin is loaded.
Definition: Plugin.h:150
virtual ~cPlugin()
Definition: Plugin.cpp:22
static cPluginManager * Get(void)
Returns the instance of the Plugin Manager (there is only ever one)
AString GetLocalFolder(void) const
Returns the folder relative to the MCS Executable, from which the plugin is loaded.
Definition: Plugin.cpp:46
virtual void Unload(void)
Unloads the plugin.
Definition: Plugin.cpp:31
cPluginManager::ePluginStatus m_Status
Definition: Plugin.h:142
void SetLoadError(const AString &a_LoadError)
Sets m_LoadError to the specified string and m_Status to psError.
Definition: Plugin.cpp:55
#define LOGD(...)
Definition: LoggerSimple.h:40
The plugin is enabled in settings.ini but has failed to load.
Definition: PluginManager.h:70
std::string AString
Definition: StringUtils.h:13
The plugin is enabled in settings.ini but has been unloaded (by a command).
Definition: PluginManager.h:66
AString m_LoadError
The error encountered while loading the plugin.
Definition: Plugin.h:154
AString m_Name
The name of the plugin, used to identify the plugin in the system and for inter-plugin calls...
Definition: Plugin.h:145