From 34b3c13404c466c8f64d198dce914a1e3fa094c2 Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Fri, 15 Feb 2013 13:00:59 +0000 Subject: Plugins can now bind console commands FS #300 Most console commands are now implemented in the Core plugin. git-svn-id: http://mc-server.googlecode.com/svn/trunk@1214 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/PluginManager.h | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'source/PluginManager.h') diff --git a/source/PluginManager.h b/source/PluginManager.h index 86e357e91..d070bfabd 100644 --- a/source/PluginManager.h +++ b/source/PluginManager.h @@ -86,7 +86,9 @@ public: // tolua_export class cCommandEnumCallback { public: - /// Called for each command; return true to abort enumeration + /** Called for each command; return true to abort enumeration + For console commands, a_Permission is not used (set to empty string) + */ virtual bool Command(const AString & a_Command, const cPlugin * a_Plugin, const AString & a_Permission, const AString & a_HelpString) = 0; } ; @@ -170,7 +172,22 @@ public: // tolua_export /// Executes the command, as if it was requested by a_Player. Permisssions are not checked. Returns true if executed (false if not found) bool ForceExecuteCommand(cPlayer * a_Player, const AString & a_Command); // tolua_export - + + /// Removes all console command bindings that the specified plugin has made + void RemovePluginConsoleCommands(cPlugin * a_Plugin); + + /// Binds a console command to the specified plugin. Returns true if successful, false if command already bound. + bool BindConsoleCommand(const AString & a_Command, cPlugin * a_Plugin, const AString & a_HelpString); // Exported in ManualBindings.cpp, without the a_Plugin param + + /// Calls a_Callback for each bound console command, returns true if all commands were enumerated + bool ForEachConsoleCommand(cCommandEnumCallback & a_Callback); // Exported in ManualBindings.cpp + + /// Returns true if the console command is in the command map + bool IsConsoleCommandBound(const AString & a_Command); // tolua_export + + /// Executes the command split into a_Split, as if it was given on the console. Returns true if executed. + bool ExecuteConsoleCommand(const AStringVector & a_Split); // tolua_export + private: friend class cRoot; @@ -178,7 +195,7 @@ private: { public: cPlugin * m_Plugin; - AString m_Permission; + AString m_Permission; // Not used for console commands AString m_HelpString; } ; @@ -189,6 +206,7 @@ private: PluginMap m_Plugins; HookMap m_Hooks; CommandMap m_Commands; + CommandMap m_ConsoleCommands; bool m_bReloadPlugins; -- cgit v1.2.3