diff --git a/MCGalaxy/Bots/PlayerBot.cs b/MCGalaxy/Bots/PlayerBot.cs index 58ad63238..03581111f 100644 --- a/MCGalaxy/Bots/PlayerBot.cs +++ b/MCGalaxy/Bots/PlayerBot.cs @@ -72,8 +72,7 @@ namespace MCGalaxy { public static bool CanEditAny(Player p) { if (LevelInfo.IsRealmOwner(p.name, p.level.name)) { return true; } - ItemPerms perms = CommandExtraPerms.Find("Bot", 1); - perms = perms == null ? new ItemPerms(LevelPermission.Operator, null, null) : perms; + ItemPerms perms = CommandExtraPerms.Find("Bot", 1) ?? new ItemPerms(LevelPermission.Operator); if (perms.UsableBy(p.Rank)) { return true; } return false; } @@ -308,10 +307,10 @@ namespace MCGalaxy { ScaleZ == 0 ? "none" : ScaleZ.ToString() ); } - if (String.IsNullOrEmpty(ClickedOnText)) { return; } - ItemPerms perms = CommandExtraPerms.Find("About", 1); - perms = perms == null ? new ItemPerms(LevelPermission.AdvBuilder, null, null) : perms; - if (!perms.UsableBy(p.Rank)) { return; } //don't show bot's ClickedOnText if player isn't allowed to see message block contents + + if (String.IsNullOrEmpty(ClickedOnText)) return; + ItemPerms perms = CommandExtraPerms.Find("About", 1) ?? new ItemPerms(LevelPermission.AdvBuilder); + if (!perms.UsableBy(p.Rank)) return; //don't show bot's ClickedOnText if player isn't allowed to see message block contents p.Message(" Clicked-on text: {0}", ClickedOnText); } diff --git a/MCGalaxy/Chat/Chat.cs b/MCGalaxy/Chat/Chat.cs index bf47e3ec6..0456955c7 100644 --- a/MCGalaxy/Chat/Chat.cs +++ b/MCGalaxy/Chat/Chat.cs @@ -46,14 +46,14 @@ namespace MCGalaxy { public static ItemPerms OpchatPerms { get { ItemPerms perms = CommandExtraPerms.Find("OpChat", 1); - return perms != null ? perms : new ItemPerms(LevelPermission.Operator, null, null); + return perms ?? new ItemPerms(LevelPermission.Operator); } } public static ItemPerms AdminchatPerms { get { ItemPerms perms = CommandExtraPerms.Find("AdminChat", 1); - return perms != null ? perms : new ItemPerms(LevelPermission.Admin, null, null); + return perms ?? new ItemPerms(LevelPermission.Admin); } } diff --git a/MCGalaxy/Commands/Economy/CmdPay.cs b/MCGalaxy/Commands/Economy/CmdPay.cs index 10049b8d2..be46cadf6 100644 --- a/MCGalaxy/Commands/Economy/CmdPay.cs +++ b/MCGalaxy/Commands/Economy/CmdPay.cs @@ -30,6 +30,7 @@ namespace MCGalaxy.Commands.Eco { if (!ParseArgs(p, message, ref all, "pay", out trans)) return; // Player can use /pay messages to bypass a mute + // TODO: Make MessageCmd.CanSpeak more generic so that can be used here instead if (trans.Reason != null && !p.CanSpeak()) { p.Message("%WCannot specify a payment reason, as you cannot currently speak"); return; diff --git a/MCGalaxy/Commands/Moderation/CmdHide.cs b/MCGalaxy/Commands/Moderation/CmdHide.cs index 2d6d94bce..847ab3ac0 100644 --- a/MCGalaxy/Commands/Moderation/CmdHide.cs +++ b/MCGalaxy/Commands/Moderation/CmdHide.cs @@ -32,7 +32,7 @@ namespace MCGalaxy.Commands.Moderation { } static void AnnounceOps(Player p, string msg) { - ItemPerms perms = new ItemPerms(p.hideRank, null, null); + ItemPerms perms = new ItemPerms(p.hideRank); Chat.MessageFrom(ChatScope.Perms, p, msg, perms, null, true); } diff --git a/MCGalaxy/Config/Permissions/ItemPerms.cs b/MCGalaxy/Config/Permissions/ItemPerms.cs index 195c92104..6263761be 100644 --- a/MCGalaxy/Config/Permissions/ItemPerms.cs +++ b/MCGalaxy/Config/Permissions/ItemPerms.cs @@ -28,6 +28,8 @@ namespace MCGalaxy { public LevelPermission MinRank; public List Allowed, Disallowed; + public ItemPerms(LevelPermission min) { Init(min, null, null); } + public ItemPerms(LevelPermission min, List allowed, List disallowed) { Init(min, allowed, disallowed); diff --git a/MCGalaxy/util/Formatting/Formatter.cs b/MCGalaxy/util/Formatting/Formatter.cs index 16ba94d9f..9bf3d4909 100644 --- a/MCGalaxy/util/Formatting/Formatter.cs +++ b/MCGalaxy/util/Formatting/Formatter.cs @@ -25,9 +25,7 @@ namespace MCGalaxy { public static class Formatter { public static void PrintCommandInfo(Player p, Command cmd) { - ItemPerms perms = CommandPerms.Find(cmd.name); - if (perms == null) perms = new ItemPerms(cmd.defaultRank, null, null); - + ItemPerms perms = CommandPerms.Find(cmd.name) ?? new ItemPerms(cmd.defaultRank); p.Message("Usable by: " + perms.Describe()); PrintAliases(p, cmd);