Prevent creating MBs with non-existent commands

This commit is contained in:
UnknownShadow200 2024-04-28 15:35:17 +10:00
parent 4725607d56
commit 9ec7f275c7
2 changed files with 8 additions and 2 deletions

View File

@ -58,7 +58,9 @@ namespace MCGalaxy.Blocks.Extended {
public static bool Validate(Player p, string message, bool allCmds) { public static bool Validate(Player p, string message, bool allCmds) {
string text; string text;
List<string> cmds = MessageBlock.GetParts(message, out text); List<string> cmds = MessageBlock.GetParts(message, out text);
foreach (string cmd in cmds) {
foreach (string cmd in cmds)
{
if (!CheckCommand(p, cmd, allCmds)) return false; if (!CheckCommand(p, cmd, allCmds)) return false;
} }
return true; return true;
@ -70,7 +72,10 @@ namespace MCGalaxy.Blocks.Extended {
Command.Search(ref cmdName, ref cmdArgs); Command.Search(ref cmdName, ref cmdArgs);
Command cmd = Command.Find(cmdName); Command cmd = Command.Find(cmdName);
if (cmd == null) return true; if (cmd == null) {
p.Message("Unknown command &T/{0} &Scannot be used in a messageblock", cmdName);
return false;
}
if (p.CanUse(cmd) && (allCmds || !cmd.MessageBlockRestricted)) return true; if (p.CanUse(cmd) && (allCmds || !cmd.MessageBlockRestricted)) return true;
p.Message("You cannot use &T/{0} &Sin a messageblock.", cmd.name); p.Message("You cannot use &T/{0} &Sin a messageblock.", cmd.name);

View File

@ -18,6 +18,7 @@
using System; using System;
using System.Net; using System.Net;
using MCGalaxy.Network; using MCGalaxy.Network;
using MCGalaxy.Platform;
using MCGalaxy.Tasks; using MCGalaxy.Tasks;
namespace MCGalaxy namespace MCGalaxy