From c5ba878e088ca35b53aecd34d9e398eb836eee5a Mon Sep 17 00:00:00 2001 From: Goodlyay Date: Tue, 18 Mar 2025 16:25:34 -0700 Subject: [PATCH] Fix permissions for a few commands --- MCGalaxy/Commands/Chat/CmdRankMsg.cs | 3 ++- MCGalaxy/Commands/Economy/CmdGive.cs | 1 + MCGalaxy/Commands/Economy/CmdTake.cs | 2 +- MCGalaxy/Commands/Overseer.cs | 24 ++++++++++++++---------- MCGalaxy/Commands/building/CmdUndo.cs | 2 ++ 5 files changed, 20 insertions(+), 12 deletions(-) diff --git a/MCGalaxy/Commands/Chat/CmdRankMsg.cs b/MCGalaxy/Commands/Chat/CmdRankMsg.cs index 7f9d83ddc..8905dc2ff 100644 --- a/MCGalaxy/Commands/Chat/CmdRankMsg.cs +++ b/MCGalaxy/Commands/Chat/CmdRankMsg.cs @@ -28,7 +28,8 @@ namespace MCGalaxy.Commands.Chatting public override string type { get { return CommandTypes.Chat; } } public override LevelPermission defaultRank { get { return LevelPermission.AdvBuilder; } } public override bool UseableWhenFrozen { get { return true; } } - + public override bool MessageBlockRestricted { get { return true; } } + public override void Use(Player p, string message, CommandData data) { if (message.Length == 0) { Help(p); return; } if (!MessageCmd.CanSpeak(p, name)) return; diff --git a/MCGalaxy/Commands/Economy/CmdGive.cs b/MCGalaxy/Commands/Economy/CmdGive.cs index 5f1ea8246..df6b16e61 100644 --- a/MCGalaxy/Commands/Economy/CmdGive.cs +++ b/MCGalaxy/Commands/Economy/CmdGive.cs @@ -24,6 +24,7 @@ namespace MCGalaxy.Commands.Eco { public override string name { get { return "Give"; } } public override string shortcut { get { return "Gib"; } } public override LevelPermission defaultRank { get { return LevelPermission.Admin; } } + public override bool MessageBlockRestricted { get { return true; } } public override void Use(Player p, string message, CommandData data) { EcoTransaction trans; diff --git a/MCGalaxy/Commands/Economy/CmdTake.cs b/MCGalaxy/Commands/Economy/CmdTake.cs index a5596bb38..36dcddfd4 100644 --- a/MCGalaxy/Commands/Economy/CmdTake.cs +++ b/MCGalaxy/Commands/Economy/CmdTake.cs @@ -23,7 +23,7 @@ namespace MCGalaxy.Commands.Eco { public sealed class CmdTake : MoneyCmd { public override string name { get { return "Take"; } } public override LevelPermission defaultRank { get { return LevelPermission.Admin; } } - + public override bool MessageBlockRestricted { get { return true; } } public override void Use(Player p, string message, CommandData data) { EcoTransaction trans; bool all = true; diff --git a/MCGalaxy/Commands/Overseer.cs b/MCGalaxy/Commands/Overseer.cs index f006cc8f0..5ba9b9dc2 100644 --- a/MCGalaxy/Commands/Overseer.cs +++ b/MCGalaxy/Commands/Overseer.cs @@ -281,22 +281,26 @@ namespace MCGalaxy.Commands.World { opt == LevelOptions.Goto || opt == LevelOptions.Unload; } - static void MapMoved(Player p, string message, string name, SubCommand.Behavior behaviour) { + static void MapMoved(Player p, string message, string name, SubCommand.Behavior behaviour, bool mapOnly = true) { AnnounceRenamed(p, "map " + name, name); + if (mapOnly && !LevelInfo.IsRealmOwner(p.level, p.name)) { + p.Message("You may only use &T/{0} {1}&S after you join your map.", commandShortcut, name); + return; + } behaviour(p, message); } static SubCommandGroup mapSubCommandGroup = new SubCommandGroup(commandShortcut + " map", new List() { - new SubCommand("Physics", (p, arg) => { MapMoved(p, arg, "physics", HandlePhysics); }), - new SubCommand("Add", (p, arg) => { MapMoved(p, arg, "add", HandleAdd); }, false, new string[] { "create", "new" } ), - new SubCommand("Delete", (p, arg) => { MapMoved(p, arg, "delete", HandleDelete); }, false, new string[] { "del", "remove" } ), - new SubCommand("Save", (p, arg) => { MapMoved(p, arg, "save", HandleSave); }), - new SubCommand("Restore", (p, arg) => { MapMoved(p, arg, "restore", HandleRestore); }), - new SubCommand("Resize", (p, arg) => { MapMoved(p, arg, "resize", HandleResize); }), - new SubCommand("PerVisit", (p, arg) => { MapMoved(p, arg, "pervisit", HandlePervisit); }), - new SubCommand("PerBuild", (p, arg) => { MapMoved(p, arg, "perbuild", HandlePerbuild); }), - new SubCommand("Texture", (p, arg) => { MapMoved(p, arg, "texture", HandleTexture); }, false, new string[] { "texturezip", "texturepack" } ), + new SubCommand("Physics", (p, arg) => { MapMoved(p, arg, "physics", HandlePhysics); }), + new SubCommand("Add", (p, arg) => { MapMoved(p, arg, "add", HandleAdd, false);}, false, new string[] { "create", "new" } ), + new SubCommand("Delete", (p, arg) => { MapMoved(p, arg, "delete", HandleDelete); }, false, new string[] { "del", "remove" } ), + new SubCommand("Save", (p, arg) => { MapMoved(p, arg, "save", HandleSave); }), + new SubCommand("Restore", (p, arg) => { MapMoved(p, arg, "restore", HandleRestore); }), + new SubCommand("Resize", (p, arg) => { MapMoved(p, arg, "resize", HandleResize); }), + new SubCommand("PerVisit", (p, arg) => { MapMoved(p, arg, "pervisit", HandlePervisit); }), + new SubCommand("PerBuild", (p, arg) => { MapMoved(p, arg, "perbuild", HandlePerbuild); }), + new SubCommand("Texture", (p, arg) => { MapMoved(p, arg, "texture", HandleTexture); }, false, new string[] { "texturezip", "texturepack" } ), } ); diff --git a/MCGalaxy/Commands/building/CmdUndo.cs b/MCGalaxy/Commands/building/CmdUndo.cs index e905a5360..5f8f35b5b 100644 --- a/MCGalaxy/Commands/building/CmdUndo.cs +++ b/MCGalaxy/Commands/building/CmdUndo.cs @@ -30,6 +30,8 @@ namespace MCGalaxy.Commands.Building { public override CommandPerm[] ExtraPerms { get { return new[] { new CommandPerm(LevelPermission.Operator, "can undo physics") }; } } + public override bool MessageBlockRestricted { get { return true; } } + public override void Use(Player p, string message, CommandData data) { if (message.Length == 0) { UndoLastDrawOp(p); return; }