static void SaveCore(IEnumerable <BlockPerms> list) { using (StreamWriter w = new StreamWriter(Paths.BlockPermsFile)) { w.WriteLine("#Version 2"); w.WriteLine("# This file list the ranks that can use each block"); w.WriteLine("# Disallow and allow can be left empty."); w.WriteLine("# Works entirely on rank permission values, not rank names."); w.WriteLine("#"); w.WriteLine("# Layout: Block ID : MinRank : Disallow : Allow"); w.WriteLine("# lava : 60 : 80,67 : 40,41,55"); w.WriteLine(""); foreach (BlockPerms perms in list) { if (Block.Name(perms.BlockID).CaselessEq("unknown")) { continue; } string line = perms.BlockID + " : " + (int)perms.MinRank + " : " + CommandPerms.JoinPerms(perms.Disallowed) + " : " + CommandPerms.JoinPerms(perms.Allowed); w.WriteLine(line); } } }
bool HandleIRCCommand(UserInfo user, string channel, string cmdName, string cmdArgs) { Command cmd = Command.all.Find(cmdName); Player p = new IRCPlayer(channel, user.Nick, bot); if (cmd == null) { Player.Message(p, "Unknown command!"); return(false); } string logCmd = cmdArgs.Length == 0 ? cmdName : cmdName + " " + cmdArgs; Logger.Log(LogType.CommandUsage, "/{0} (by {1} from IRC)", logCmd, user.Nick); try { if (!p.group.CanExecute(cmd)) { CommandPerms.Find(cmd.name).MessageCannotUse(p); return(false); } if (!cmd.SuperUseable) { Player.Message(p, cmd.name + " can only be used in-game."); return(false); } cmd.Use(p, cmdArgs); } catch (Exception ex) { Player.Message(p, "CMD Error: " + ex); } return(true); }
public static void Register(Command cmd) { allCmds.Add(cmd); CommandPerms perms = CommandPerms.Find(cmd.name); if (perms == null) { perms = new CommandPerms(cmd.name, cmd.defaultRank, null, null); CommandPerms.List.Add(perms); } foreach (Group grp in Group.GroupList) { if (perms.UsableBy(grp.Permission)) { grp.Commands.Add(cmd); } } CommandPerm[] extra = cmd.ExtraPerms; if (extra != null) { for (int i = 0; i < extra.Length; i++) { CommandExtraPerms.Set(cmd.name, i + 1, extra[i].Description, extra[i].Perm, null, null); } } Alias.RegisterDefaults(cmd); }
public static void PrintCommandInfo(Player p, Command cmd) { ItemPerms perms = CommandPerms.Find(cmd.name); if (perms == null) { perms = new ItemPerms(cmd.defaultRank, null, null); } p.Message("Usable by: " + perms.Describe()); PrintAliases(p, cmd); List <CommandExtraPerms> extraPerms = CommandExtraPerms.FindAll(cmd.name); if (cmd.ExtraPerms == null) { extraPerms.Clear(); } if (extraPerms.Count == 0) { return; } p.Message("%TExtra permissions:"); foreach (CommandExtraPerms extra in extraPerms) { p.Message("{0}) {1} {2}", extra.Num, extra.Describe(), extra.Desc); } }
void cmd_list_SelectedIndexChanged(object sender, EventArgs e) { string cmdName = cmd_list.SelectedItem.ToString(); CommandInitSpecificArrays(); cmd = Command.Find(cmdName); if (cmd == null) { return; } commandPermsOrig = CommandPerms.Find(cmdName); commandPermsCopy = commandPermsChanged.Find(p => p.CmdName.CaselessEq(cmdName)); // fix for when command is added to server but doesn't have permissions defined if (commandPermsOrig == null) { commandPermsOrig = new CommandPerms(cmdName, cmd.defaultRank, null, null); } commandItems.SupressEvents = true; CommandInitExtraPerms(); CommandPerms perms = commandPermsCopy != null ? commandPermsCopy : commandPermsOrig; commandItems.Update(perms); }
bool ExecuteCommand(RelayUser user, string channel, string cmdName, string cmdArgs) { Command cmd = Command.Find(cmdName); Player p = new RelayPlayer(channel, user, this); if (cmd == null) { p.Message("Unknown command!"); return(false); } string logCmd = cmdArgs.Length == 0 ? cmdName : cmdName + " " + cmdArgs; Logger.Log(LogType.CommandUsage, "/{0} (by {1} from {2})", logCmd, user.Nick, RelayName); try { if (!p.CanUse(cmd)) { CommandPerms.Find(cmd.name).MessageCannotUse(p); return(false); } if (!cmd.SuperUseable) { p.Message(cmd.name + " can only be used in-game."); return(false); } cmd.Use(p, cmdArgs); } catch (Exception ex) { p.Message("CMD Error: " + ex); Logger.LogError(ex); } return(true); }
public static void Register(Command cmd) { allCmds.Add(cmd); CommandPerms perms = CommandPerms.GetOrAdd(cmd.name, cmd.defaultRank); foreach (Group grp in Group.GroupList) { if (perms.UsableBy(grp.Permission)) { grp.Commands.Add(cmd); } } CommandPerm[] extra = cmd.ExtraPerms; if (extra != null) { for (int i = 0; i < extra.Length; i++) { CommandExtraPerms exPerms = CommandExtraPerms.GetOrAdd(cmd.name, i + 1, extra[i].Perm); exPerms.Desc = extra[i].Description; } } Alias.RegisterDefaults(cmd); }
public static void PrintCommandInfo(Player p, Command cmd) { CommandPerms perms = CommandPerms.Find(cmd.name); StringBuilder builder = new StringBuilder(); builder.Append("Usable by: "); if (perms == null) { builder.Append(Group.GetColoredName(cmd.defaultRank) + "%S+"); } else { PrintRanks(perms.MinRank, perms.Allowed, perms.Disallowed, builder); } Player.Message(p, builder.ToString()); PrintAliases(p, cmd); List <CommandExtraPerms> extraPerms = CommandExtraPerms.FindAll(cmd.name); if (extraPerms.Count == 0) { return; } Player.Message(p, "%TExtra permissions:"); foreach (CommandExtraPerms extra in extraPerms) { Player.Message(p, "{0}) {1}%S{2}", extra.Number, Group.GetColoredName(extra.MinRank), extra.Description); } }
public static void LoadAllSettings() { // Unload custom plugins List <Plugin> plugins = new List <Plugin>(Plugin.all); foreach (Plugin p in plugins) { if (Plugin.core.Contains(p)) { continue; } Plugin.Unload(p, false); } ZSGame.Instance.infectMessages = ZSConfig.LoadInfectMessages(); Colors.Load(); Alias.Load(); BlockDefinition.LoadGlobal(); ImagePalette.Load(); SrvProperties.Load(); AuthService.ReloadDefault(); Group.LoadAll(); CommandPerms.Load(); Command.InitAll(); Block.SetBlocks(); AwardsList.Load(); PlayerAwards.Load(); Economy.Load(); WarpList.Global.Filename = "extra/warps.save"; WarpList.Global.Load(); CommandExtraPerms.Load(); ProfanityFilter.Init(); Team.LoadList(); ChatTokens.LoadCustom(); SrvProperties.FixupOldPerms(); CpeExtension.LoadDisabledList(); TextFile announcementsFile = TextFile.Files["Announcements"]; announcementsFile.EnsureExists(); announcements = announcementsFile.GetText(); // Reload custom plugins foreach (Plugin p in plugins) { if (Plugin.core.Contains(p)) { continue; } Plugin.Load(p, false); } OnConfigUpdatedEvent.Call(); }
static void UpdatePermissions(Command cmd, Player p, string message) { CommandPerms.Save(); CommandPerms.Load(); Chat.MessageGlobal("&d{0}%S{1}", cmd.name, message); if (Player.IsSuper(p)) { Player.Message(p, cmd.name + message); } }
public static void AddAll() { Command.all.Remove(Command.all.Find("top")); Command.all.Remove(Command.all.Find("whois")); Command.all.Add(new CmdSkills()); Command.all.Add(new CmdSpec()); Command.all.Add(new CmdSpinball()); Command.all.Add(new CmdTeamSet()); Command.all.Add(new CmdTop()); Command.all.Add(new CmdWhois()); CommandPerms.Load(); }
static void SortCommands(List <Command> cmds, string sort) { if (sort == "name" || sort == "names") { cmds.Sort((a, b) => a.name .CompareTo(b.name)); } if (sort == "rank" || sort == "ranks") { cmds.Sort((a, b) => CommandPerms.MinPerm(a) .CompareTo(CommandPerms.MinPerm(b))); } }
void SaveChanges() { SaveProperties(); SaveRanks(); SaveCommands(); SaveBlocks(); SaveGameProps(); try { ZSGame.Config.Save(); } catch { Logger.Log(LogType.Warning, "Error saving Zombie Survival settings!"); } SrvProperties.Load(); // loads when saving? CommandPerms.Load(); }
void btnUnload_Click(object sender, EventArgs e) { string cmdName = lstCommands.SelectedItem.ToString(); Command cmd = Command.all.Find(cmdName); if (cmd == null) { MessageBox.Show(cmdName + " is not a valid or loaded command.", ""); return; } lstCommands.Items.Remove(cmd.name); Command.all.Remove(cmd); CommandPerms.Load(); MessageBox.Show("Command was successfully unloaded.", ""); }
protected override void UpdatePerms(ItemPerms perms, Player p, string msg) { if (perms is CommandPerms) { CommandPerms.Save(); CommandPerms.ApplyChanges(); Announce(p, perms.ItemName + msg); } else { CommandExtraPerms.Save(); CommandExtraPerms ex = (CommandExtraPerms)perms; //Announce(p, cmd.name + "&S's extra permission " + idx + " was set to " + grp.ColoredName); Announce(p, ex.CmdName + " extra permission #" + ex.Num + msg); } }
void cmd_list_SelectedIndexChanged(object sender, EventArgs e) { commandName = cmd_list.SelectedItem.ToString(); commandPermsOrig = CommandPerms.Find(commandName); commandPerms = commandPermsChanged.Find(p => p.CmdName == commandName); CommandInitSpecificArrays(); commandSupressEvents = true; CommandPerms perms = commandPerms != null ? commandPerms : commandPermsOrig; GuiPerms.SetDefaultIndex(cmd_cmbMin, perms.MinRank); GuiPerms.SetSpecificPerms(perms.Allowed, commandAllowBoxes); GuiPerms.SetSpecificPerms(perms.Disallowed, commandDisallowBoxes); CommandInitExtraPerms(); commandSupressEvents = false; }
void LoadCommands() { cmd_list.Items.Clear(); List <CommandPerms> temp = CommandPerms.CopyAll(); temp.Sort((a, b) => a.CmdName.CompareTo(b.CmdName)); foreach (CommandPerms perms in temp) { cmd_list.Items.Add(perms.CmdName); } if (cmd_list.SelectedIndex == -1) { cmd_list.SelectedIndex = 0; } }
public static void LoadAllSettings() { // Unload custom plugins List <Plugin> plugins = Plugin.all; foreach (Plugin plugin in plugins) { if (Plugin.core.Contains(plugin)) { continue; } plugin.Unload(false); } zombie.LoadInfectMessages(); Colors.LoadList(); Alias.Load(); BlockDefinition.LoadGlobal(); ImagePalette.Load(); SrvProperties.Load(); Group.InitAll(); Command.InitAll(); CommandPerms.Load(); Block.SetBlocks(); BlockDefinition.UpdateGlobalBlockProps(); Awards.Load(); Economy.Load(); WarpList.Global.Filename = "extra/warps.save"; WarpList.Global.Load(); CommandExtraPerms.Load(); ProfanityFilter.Init(); Team.LoadList(); ChatTokens.LoadCustom(); SrvProperties.FixupOldPerms(); // Reload custom plugins foreach (Plugin plugin in plugins) { if (Plugin.core.Contains(plugin)) { continue; } plugin.Load(false); } }
public override void Use(Player p, string message, CommandData data) { string[] args = message.SplitSpaces(3); if (args.Length < 2) { Help(p); return; } string cmdName = args[0], cmdArgs = ""; Command.Search(ref cmdName, ref cmdArgs); Command cmd = Command.Find(cmdName); if (cmd == null) { p.Message("Could not find command entered"); return; } if (!p.CanUse(cmd)) { p.Message("Your rank cannot use this command."); return; } if (args.Length == 2) { CommandPerms perms = CommandPerms.Find(cmd.name); SetPerms(p, args, data, perms, "command"); } else { int num = 0; if (!CommandParser.GetInt(p, args[2], "Extra permission number", ref num)) { return; } CommandExtraPerms perms = CommandExtraPerms.Find(cmd.name, num); if (perms == null) { p.Message("This command has no extra permission by that number."); return; } SetPerms(p, args, data, perms, "extra permission"); } }
public static void Register(Command cmd) { allCmds.Add(cmd); CommandPerms perms = CommandPerms.Find(cmd.name); if (perms == null) { perms = new CommandPerms(cmd.name, cmd.defaultRank, null, null); CommandPerms.List.Add(perms); } foreach (Group grp in Group.GroupList) { if (perms.UsableBy(grp.Permission)) { grp.Commands.Add(cmd); } } CommandPerm[] extra = cmd.ExtraPerms; if (extra != null) { for (int i = 0; i < extra.Length; i++) { CommandExtraPerms.Set(cmd.name, i + 1, extra[i].Description, extra[i].Perm, null, null); } } CommandAlias[] aliases = cmd.Aliases; if (aliases == null) { return; } foreach (CommandAlias a in aliases) { Alias alias = new Alias(a.Trigger, cmd.name, a.Format); Alias.coreAliases.Add(alias); } }
void SaveCommands() { if (!CommandsChanged()) { LoadCommands(); return; } foreach (CommandPerms changed in commandPermsChanged) { CommandPerms.Set(changed.CmdName, changed.MinRank, changed.Allowed, changed.Disallowed); } foreach (CommandExtraPerms changed in commandExtraPermsChanged) { CommandExtraPerms orig = CommandExtraPerms.Find(changed.CmdName, changed.Num); orig.MinRank = changed.MinRank; } CommandExtraPerms.Save(); CommandPerms.Save(); CommandPerms.Load(); LoadCommands(); }
static void ProcessLines(string[] lines) { string[] args = new string[4]; foreach (string line in lines) { if (line.Length == 0 || line[0] == '#') { continue; } // Format is - Name/ID : Lowest : Disallow : Allow line.Replace(" ", "").FixedSplit(args, ':'); byte block; if (!byte.TryParse(args[0], out block)) { block = Block.Byte(args[0]); } if (block == Block.Invalid) { continue; } BlockPerms perms = new BlockPerms(); perms.BlockID = block; try { perms.MinRank = (LevelPermission)int.Parse(args[1]); string disallowRaw = args[2], allowRaw = args[3]; perms.Allowed = CommandPerms.ExpandPerms(allowRaw); perms.Disallowed = CommandPerms.ExpandPerms(disallowRaw); } catch { Logger.Log(LogType.Warning, "Hit an error on the block " + line); continue; } List[perms.BlockID] = perms; } }
public override void Use(Player p, string message) { if (!Formatter.ValidName(p, message, "command")) { return; } if (Command.all.Contains(message)) { Player.Message(p, "That command is already loaded!"); return; } if (!File.Exists(IScripting.DllDir + "Cmd" + message + ".dll")) { Player.Message(p, "File &9Cmd" + message + ".dll %Snot found."); return; } string error = IScripting.Load("Cmd" + message); if (error != null) { Player.Message(p, error); return; } CommandPerms.Load(); Player.Message(p, "Command was successfully loaded."); }
Command GetCommand(ref string cmd, ref string cmdArgs) { if (!CheckCommand(cmd)) { return(null); } Command.Search(ref cmd, ref cmdArgs); byte bindIndex; if (byte.TryParse(cmd, out bindIndex) && bindIndex < CmdBindings.Length) { if (CmdArgsBindings[bindIndex] == null) { SendMessage("No command is bound to: /" + cmd); return(null); } cmd = CmdBindings[bindIndex]; cmdArgs = CmdArgsBindings[bindIndex] + " " + cmdArgs; cmdArgs = cmdArgs.TrimEnd(' '); } OnPlayerCommandEvent.Call(this, cmd, cmdArgs); if (cancelcommand) { cancelcommand = false; return(null); } Command command = Command.all.Find(cmd); if (command == null) { if (Block.Byte(cmd) != Block.Invalid) { cmdArgs = cmd.ToLower(); cmd = "mode"; command = Command.all.FindByName("Mode"); } else { Logger.Log(LogType.CommandUsage, "{0} tried to use unknown command: /{1} {2}", name, cmd, cmdArgs); SendMessage("Unknown command \"" + cmd + "\"."); return(null); } } if (!group.CanExecute(command)) { CommandPerms.Find(command.name).MessageCannotUse(this); return(null); } string reason = Command.GetDisabledReason(command.Enabled); if (reason != null) { SendMessage("Command is disabled as " + reason); return(null); } if (level.IsMuseum && !command.museumUsable) { SendMessage("Cannot use this command while in a museum."); return(null); } return(command); }
internal static string GetColor(Command cmd) { LevelPermission perm = CommandPerms.MinPerm(cmd); return(Group.GetColor(perm)); }
void btnLoad_Click(object sender, EventArgs e) { Command[] commands = null; using (FileDialog dialog = new OpenFileDialog()) { dialog.RestoreDirectory = true; dialog.Filter = "Accepted File Types (*.cs, *.vb, *.dll)|*.cs;*.vb;*.dll|C# Source (*.cs)|*.cs|Visual Basic Source (*.vb)|*.vb|.NET Assemblies (*.dll)|*.dll"; if (dialog.ShowDialog() != DialogResult.OK) { return; } string fileName = dialog.FileName; if (fileName.EndsWith(".dll")) { byte[] data = File.ReadAllBytes(fileName); Assembly lib = Assembly.Load(data); commands = IScripting.LoadFrom(lib).ToArray(); } else { IScripting engine = fileName.EndsWith(".cs") ? IScripting.CS : IScripting.VB; if (!File.Exists(fileName)) { return; } CompilerParameters args = new CompilerParameters(); args.GenerateInMemory = true; var result = engine.CompileSource(File.ReadAllText(fileName), args); if (result == null) { MessageBox.Show("Error compiling files"); return; } if (result.Errors.HasErrors) { foreach (CompilerError err in result.Errors) { Logger.Log(LogType.Warning, "Error #" + err.ErrorNumber); Logger.Log(LogType.Warning, "Message: " + err.ErrorText); Logger.Log(LogType.Warning, "Line: " + err.Line); Logger.Log(LogType.Warning, "================================="); } MessageBox.Show("Error compiling from source. Check logs for more details."); return; } commands = IScripting.LoadFrom(result.CompiledAssembly).ToArray(); } } if (commands == null) { MessageBox.Show("Error compiling files"); return; } for (int i = 0; i < commands.Length; i++) { Command cmd = commands[i]; if (lstCommands.Items.Contains(cmd.name)) { MessageBox.Show("Command " + cmd.name + " already exists. As a result, it was not loaded"); continue; } lstCommands.Items.Add(cmd.name); Command.all.Add(cmd); Logger.Log(LogType.SystemActivity, "Added " + cmd.name + " to commands"); } CommandPerms.Load(); }
public override void Use(Player p, string message) { string[] args = message.SplitSpaces(); if (args.Length == 1) { Help(p); return; } Command cmd = Command.all.Find(args[0]); if (cmd == null) { Player.Message(p, "Could not find command entered"); return; } if (p != null && !p.group.CanExecute(cmd)) { Player.Message(p, "Your rank cannot use this command."); return; } if (args.Length == 2 && args[1][0] == '+') { Group grp = GetGroup(p, args[1].Substring(1)); if (grp == null) { return; } CommandPerms perms = CommandPerms.Find(cmd.name); if (perms.Disallowed.Contains(grp.Permission)) { perms.Disallowed.Remove(grp.Permission); } else if (!perms.Allowed.Contains(grp.Permission)) { perms.Allowed.Add(grp.Permission); } UpdatePermissions(cmd, p, " can now be used by " + grp.ColoredName); } else if (args.Length == 2 && args[1][0] == '-') { Group grp = GetGroup(p, args[1].Substring(1)); if (grp == null) { return; } CommandPerms perms = CommandPerms.Find(cmd.name); if (p != null && p.Rank == grp.Permission) { Player.Message(p, "You cannot disallow your own rank from using a command."); return; } if (perms.Allowed.Contains(grp.Permission)) { perms.Allowed.Remove(grp.Permission); } else if (!perms.Disallowed.Contains(grp.Permission)) { perms.Disallowed.Add(grp.Permission); } UpdatePermissions(cmd, p, " is no longer usable by " + grp.ColoredName); } else if (args.Length == 2) { Group grp = GetGroup(p, args[1]); if (grp == null) { return; } CommandPerms perms = CommandPerms.Find(cmd.name); perms.MinRank = grp.Permission; UpdatePermissions(cmd, p, "'s permission was set to " + grp.ColoredName); } else { int otherPermIndex = 0; if (!CommandParser.GetInt(p, args[2], "Extra permission number", ref otherPermIndex)) { return; } CommandExtraPerms perms = CommandExtraPerms.Find(cmd.name, otherPermIndex); if (perms == null) { Player.Message(p, "This command has no extra permission by that number."); return; } if (p != null && p.Rank < perms.MinRank) { Player.Message(p, "Your rank cannot modify this extra permission."); return; } Group grp = GetGroup(p, args[1]); if (grp == null) { return; } perms.MinRank = grp.Permission; CommandExtraPerms.Save(); string permName = "extra permission " + otherPermIndex; Chat.MessageGlobal("&d{0}%S's {1} was set to {2}", cmd.name, permName, grp.ColoredName); if (Player.IsSuper(p)) { Player.Message(p, "{0}'s {1} was set to {2}", cmd.name, permName, grp.ColoredName); } } }
public void SetUsableCommands() { Commands = CommandPerms.AllCommandsUsableBy(Permission); }
Command GetCommand(ref string cmdName, ref string cmdArgs, CommandData data) { if (!CheckCommand(cmdName)) { return(null); } string bound; byte bindIndex; if (CmdBindings.TryGetValue(cmdName, out bound)) { // user defined command shortcuts take priority bound.Separate(out cmdName, out cmdArgs); } else if (byte.TryParse(cmdName, out bindIndex) && bindIndex < 10) { // backwards compatibility for old /cmdbind behaviour Message("No command is bound to: &T/" + cmdName); return(null); } Command.Search(ref cmdName, ref cmdArgs); OnPlayerCommandEvent.Call(this, cmdName, cmdArgs, data); if (cancelcommand) { cancelcommand = false; return(null); } Command command = Command.Find(cmdName); if (command == null) { if (Block.Parse(this, cmdName) != Block.Invalid) { cmdArgs = cmdName; cmdName = "mode"; command = Command.Find("Mode"); } else { Logger.Log(LogType.CommandUsage, "{0} tried to use unknown command: /{1} {2}", name, cmdName, cmdArgs); Message("Unknown command \"{0}\".", cmdName); return(null); } } if (!CanUse(command)) { CommandPerms.Find(command.name).MessageCannotUse(this); return(null); } string reason = Command.GetDisabledReason(command.Enabled); if (reason != null) { Message("Command is disabled as " + reason); return(null); } if (level != null && level.IsMuseum && !command.museumUsable) { Message("Cannot use &T/{0} &Swhile in a museum.", command.name); return(null); } if (frozen && !command.UseableWhenFrozen) { Message("Cannot use &T/{0} &Swhile frozen.", command.name); return(null); } return(command); }
Command GetCommand(ref string cmdName, ref string cmdArgs, CommandData data) { if (!CheckCommand(cmdName)) { return(null); } Command.Search(ref cmdName, ref cmdArgs); byte bindIndex; if (byte.TryParse(cmdName, out bindIndex) && bindIndex < CmdBindings.Length) { if (CmdBindings[bindIndex] == null) { Message("No command is bound to: %T/" + cmdName); return(null); } CmdBindings[bindIndex].Separate(out cmdName, out cmdArgs); Command.Search(ref cmdName, ref cmdArgs); } OnPlayerCommandEvent.Call(this, cmdName, cmdArgs, data); if (cancelcommand) { cancelcommand = false; return(null); } Command command = Command.Find(cmdName); if (command == null) { if (Block.Parse(this, cmdName) != Block.Invalid) { cmdArgs = cmdName; cmdName = "mode"; command = Command.Find("Mode"); } else { Logger.Log(LogType.CommandUsage, "{0} tried to use unknown command: /{1} {2}", name, cmdName, cmdArgs); Message("Unknown command \"" + cmdName + "\"."); return(null); } } if (!CanUse(command)) { CommandPerms.Find(command.name).MessageCannotUse(this); return(null); } string reason = Command.GetDisabledReason(command.Enabled); if (reason != null) { Message("Command is disabled as " + reason); return(null); } if (level != null && level.IsMuseum && !command.museumUsable) { Message("Cannot use %T/{0} %Swhile in a museum.", command.name); return(null); } if (frozen && !command.UseableWhenFrozen) { Message("Cannot use %T/{0} %Swhile frozen.", command.name); return(null); } return(command); }