Command API thoughts
#1
I don't quite like how command handling is done in plugins currently. I'd like to propose a change to the API that would make it easier to use, more consistent and possibly extensible to other languages.
(Sorry for the weird formatting, it's taken out from my notes text file and the forum doesn't seem to support tabs Sad )

Current state:
==============
cPlugin handles command "adding": cPlugin:AddCommand(Command, Description, Permission)
-- used for listing commands using "/help"
cLuaCommandBinder handles command binding via cPlugin:BindCommand(Command, Permission, Function)
-- used for actual command handling

Problems:
-- Binding and Adding aren't too related - plugin can add command without binding it and bind command without adding it -> mess
-- List of commands is fragmented across cPlugin instances


Proposed solution:
==================
cPlugin won't take care of anything command-related within the API. All command-handling functions will be exported on the cPluginManager object. Therefore if we ever support another language, it will make things easier.
New API functions:
-- cPluginManager:BindCommand(Command, Permission, Function, Description)
---- Binds the command, maintains one global list of commands; knows which plugin to bind to using either the LuaState ptr or a global variable within the LuaState
-- cPluginManager:ForEachCommand(Callback)
---- Calls the callback for each command in the list, thus allowing enumeration, inspection etc.
---- function Callback(Command, Permission, Description[, PluginName?]);
-- cPluginManager:IsCommandBound(Command)
---- Returns true if a command with this name has been bound (to any plugin)
-- cPluginManager:GetCommandPermission(Command)
---- Returns the permission needed for executing the command
-- cPluginManager:ExecuteCommand(Player, Command, Parameters)
---- Executes the command, as if it was requested by the player. Checks permissions first.
-- cPluginManager:ForceExecuteCommand(Player, Command, Parameters)
---- Executes the command, as if it was requested by the player. Doesn't check permissions!


So, what do you think?
Reply
Thanks given by:


Messages In This Thread
Command API thoughts - by xoft - 01-30-2013, 05:44 AM
RE: Command API thoughts - by bearbin - 01-30-2013, 05:49 AM
RE: Command API thoughts - by Taugeshtu - 01-30-2013, 06:32 AM
RE: Command API thoughts - by xoft - 01-30-2013, 06:53 AM
RE: Command API thoughts - by Taugeshtu - 01-30-2013, 06:58 PM
RE: Command API thoughts - by xoft - 01-30-2013, 07:41 PM
RE: Command API thoughts - by Taugeshtu - 01-30-2013, 09:38 PM
RE: Command API thoughts - by xoft - 02-01-2013, 05:06 AM
RE: Command API thoughts - by Taugeshtu - 02-01-2013, 05:45 AM
RE: Command API thoughts - by xoft - 02-01-2013, 07:18 PM
RE: Command API thoughts - by xoft - 02-02-2013, 05:57 AM
RE: Command API thoughts - by NiLSPACE - 02-14-2013, 05:21 AM
RE: Command API thoughts - by xoft - 02-14-2013, 05:24 AM
RE: Command API thoughts - by xoft - 02-15-2013, 11:11 PM



Users browsing this thread: 1 Guest(s)