diff --git a/MCGalaxy/Commands/Bots/CmdBot.cs b/MCGalaxy/Commands/Bots/CmdBot.cs index b166703d6..26dfa6835 100644 --- a/MCGalaxy/Commands/Bots/CmdBot.cs +++ b/MCGalaxy/Commands/Bots/CmdBot.cs @@ -65,6 +65,7 @@ public override void Use(Player p, string message, CommandData data) { } void AddBot(Player p, string botName) { + if (!p.level.Config.AllowBots) { p.Message("Bots have been disabled in this level."); return; } botName = botName.Replace(' ', '_'); PlayerBot bot = new PlayerBot(botName, p.level); bot.Owner = p.name; diff --git a/MCGalaxy/Levels/LevelConfig.cs b/MCGalaxy/Levels/LevelConfig.cs index dcbe83c87..1aaf38ff9 100644 --- a/MCGalaxy/Levels/LevelConfig.cs +++ b/MCGalaxy/Levels/LevelConfig.cs @@ -189,10 +189,13 @@ public sealed class LevelConfig : AreaConfig { [ConfigBool("WorldChat", "General", true)] public bool ServerWideChat = true; + // Other settings [ConfigBool("UseBlockDB", "Other", true)] public bool UseBlockDB = true; [ConfigInt("LoadDelay", "Other", 0, 0, 2000)] public int LoadDelay = 0; + [ConfigBool("AllowBots", "Other", true)] + public bool AllowBots = true; [ConfigString("Texture", "Env", "", true)] public string Terrain = ""; @@ -220,7 +223,7 @@ public sealed class LevelConfig : AreaConfig { public List VisitWhitelist = new List(); [ConfigStringList("VisitBlacklist", "Permissions")] public List VisitBlacklist = new List(); - + // Physics settings [ConfigInt("Physics", "Physics", 0, 0, 5)] public int Physics; @@ -278,6 +281,7 @@ public sealed class LevelConfig : AreaConfig { public int RoundsPlayed = 0; [ConfigInt("RoundsHumanWon", "Game", 0)] public int RoundsHumanWon = 0; + readonly object saveLock = new object(); public string Color { diff --git a/MCGalaxy/Levels/LevelOptions.cs b/MCGalaxy/Levels/LevelOptions.cs index 5ba8067ea..27f1cd1ab 100644 --- a/MCGalaxy/Levels/LevelOptions.cs +++ b/MCGalaxy/Levels/LevelOptions.cs @@ -38,7 +38,7 @@ public static class LevelOptions { public const string Edge = "Edge", Grass = "Grass", Death = "Death", Killer = "Killer", Unload = "Unload"; public const string Goto = "LoadOnGoto", Decay = "LeafDecay", Flow = "RandomFlow", Trees = "GrowTrees"; public const string Chat = "Chat", Guns = "Guns", Buildable = "Buildable", Deletable = "Deletable"; - public const string LoadDelay = "LoadDelay", Drawing = "Drawing", Authors = "Authors"; + public const string AllowBots = "AllowBots", LoadDelay = "LoadDelay", Drawing = "Drawing", Authors = "Authors"; public static List Options = new List() { new LevelOption(MOTD, SetMotd, "&HSets the motd for this map. (leave blank to use default motd)"), @@ -65,6 +65,7 @@ public static class LevelOptions { new LevelOption(Guns, SetGuns, "&HWhether guns and missiles can be used"), new LevelOption(Buildable, SetBuildable, "&HWhether any blocks can be placed by players."), new LevelOption(Deletable, SetDeletable, "&HWhether any blocks can be deleted by players."), + new LevelOption(AllowBots, SetAllowBots, "&HWhether bots can be created."), new LevelOption(Drawing, SetDrawing, "&HWhether drawing commands (e.g /z) can be used on this map."), new LevelOption(LoadDelay, SetLoadDelay, "&HSets the delay before the end of the map is sent. " + "Only useful for forcing players to see the map's MOTD at the loading screen."), @@ -138,6 +139,7 @@ static void SetTree(Player p, Level lvl, string value) { static void SetTrees(Player p, Level l, string v) { Toggle(p, l, ref l.Config.GrowTrees, "Tree growing"); } static void SetBuildable(Player p, Level l, string v) { TogglePerms(p, l, ref l.Config.Buildable, "Buildable"); } static void SetDeletable(Player p, Level l, string v) { TogglePerms(p, l, ref l.Config.Deletable, "Deletable"); } + static void SetAllowBots(Player p, Level l, string v) { TogglePerms(p, l, ref l.Config.AllowBots, "Bot creation"); } static void SetChat(Player p, Level l, string v) { Toggle(p, l, ref l.Config.ServerWideChat, "Local level only chat", true);