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 "Plugins" + cFile::GetPathSeparator() + 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 
#define LOGD
Definition: LoggerSimple.h:83
std::string AString
Definition: StringUtils.h:11
AString m_Name
The name of the plugin, used to identify the plugin in the system and for inter-plugin calls.
Definition: Plugin.h:147
AString m_FolderName
Name of the folder (in the Plugins folder) from which the plugin is loaded.
Definition: Plugin.h:152
AString GetLocalFolder(void) const
Returns the folder relative to the MCS Executable, from which the plugin is loaded.
Definition: Plugin.cpp:46
virtual ~cPlugin()
Definition: Plugin.cpp:22
virtual void OnDisable(void)
Called as the last call into the plugin before it is unloaded.
Definition: Plugin.h:32
AString m_LoadError
The error encountered while loading the plugin.
Definition: Plugin.h:156
cPlugin(const AString &a_FolderName)
Creates a new instance.
Definition: Plugin.cpp:10
cPluginManager::ePluginStatus m_Status
Definition: Plugin.h:144
virtual void Unload(void)
Unloads the plugin.
Definition: Plugin.cpp:31
void SetLoadError(const AString &a_LoadError)
Sets m_LoadError to the specified string and m_Status to psError.
Definition: Plugin.cpp:55
static cPluginManager * Get(void)
Returns the instance of the Plugin Manager (there is only ever one)
@ psError
The plugin is enabled in settings.ini but has failed to load.
Definition: PluginManager.h:72
@ psUnloaded
The plugin is enabled in settings.ini but has been unloaded (by a command).
Definition: PluginManager.h:68
static AString GetPathSeparator()
Returns the path separator used by the current platform.
Definition: File.cpp:669