@@ -60,25 +60,32 @@ Command *CommandsManager::FetchCommand(std::string cmd)
6060 return this ->commands .at (cmd);
6161}
6262
63- void CommandsManager::RegisterCommand (std::string plugin_name, std::string cmd, Command *command)
63+ void CommandsManager::RegisterCommand (std::string plugin_name, std::string cmd, Command *command, bool registerRaw )
6464{
65- if (this ->commands .find (cmd) != this ->commands .end ())
66- return ;
6765
68- this ->commands .insert ({cmd, command});
69- this ->commandAliases .insert ({cmd, {}});
66+ if (!registerRaw)
67+ {
68+ if (this ->commands .find (cmd) != this ->commands .end ())
69+ return ;
70+
71+ this ->commands .insert ({cmd, command});
72+ this ->commandAliases .insert ({cmd, {}});
7073
71- if (this ->commandsByPlugin .find (plugin_name) == this ->commandsByPlugin .end ())
72- this ->commandsByPlugin .insert ({plugin_name, {}});
74+ if (this ->commandsByPlugin .find (plugin_name) == this ->commandsByPlugin .end ())
75+ this ->commandsByPlugin .insert ({plugin_name, {}});
76+
77+ this ->commandsByPlugin [plugin_name].push_back (cmd);
78+ }
7379
74- this ->commandsByPlugin [plugin_name].push_back (cmd);
80+ if (!registerRaw)
81+ cmd = " sw_" + cmd;
7582
7683 if (conCommandCreated.find (cmd) == conCommandCreated.end ())
7784 {
7885 conCommandCreated.insert ({cmd, true });
7986
8087 ConCommandRefAbstract commandRef;
81- new ConCommand (&commandRef, ( " sw_ " + cmd) .c_str (), commandsCallback, " Swiftly Command" , (1 << 25 ) | (1 << 0 ) | (1 << 24 ));
88+ new ConCommand (&commandRef, cmd.c_str (), commandsCallback, " Swiftly Command" , (1 << 25 ) | (1 << 0 ) | (1 << 24 ));
8289 }
8390}
8491
@@ -109,7 +116,7 @@ static void commandsCallback(const CCommandContext &context, const CCommand &arg
109116 CCommand tokenizedArgs;
110117 tokenizedArgs.Tokenize (args.GetCommandString ());
111118
112- std::string commandName = (tokenizedArgs[0 ] + 3 );
119+ std::string commandName = (starts_with ( tokenizedArgs[0 ], " sw_ " ) ? (tokenizedArgs[ 0 ] + 3 ) : tokenizedArgs[ 0 ] );
113120
114121 std::vector<std::string> argsplit;
115122 for (int i = 1 ; i < tokenizedArgs.ArgC (); i++)
0 commit comments