Skip to content

Commit

Permalink
Prevent creating MBs with non-existent commands
Browse files Browse the repository at this point in the history
  • Loading branch information
UnknownShadow200 committed Apr 28, 2024
1 parent 4725607 commit 9ec7f27
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
9 changes: 7 additions & 2 deletions MCGalaxy/Blocks/Extended/MessageBlock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ public static void Execute(Player p, string message, Vec3S32 mbCoords) {
public static bool Validate(Player p, string message, bool allCmds) {
string 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;
}
return true;
Expand All @@ -70,7 +72,10 @@ static bool CheckCommand(Player p, string message, bool allCmds) {
Command.Search(ref cmdName, ref cmdArgs);

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;
p.Message("You cannot use &T/{0} &Sin a messageblock.", cmd.name);
Expand Down
1 change: 1 addition & 0 deletions MCGalaxy/Server/Maintenance/Updater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ permissions and limitations under the Licenses.
using System;
using System.Net;
using MCGalaxy.Network;
using MCGalaxy.Platform;
using MCGalaxy.Tasks;

namespace MCGalaxy
Expand Down

0 comments on commit 9ec7f27

Please sign in to comment.