Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add option to disable bots #634

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions MCGalaxy/Commands/Bots/CmdBot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 5 additions & 1 deletion MCGalaxy/Levels/LevelConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "";
Expand Down Expand Up @@ -220,7 +223,7 @@ public sealed class LevelConfig : AreaConfig {
public List<string> VisitWhitelist = new List<string>();
[ConfigStringList("VisitBlacklist", "Permissions")]
public List<string> VisitBlacklist = new List<string>();

// Physics settings
[ConfigInt("Physics", "Physics", 0, 0, 5)]
public int Physics;
Expand Down Expand Up @@ -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 {
Expand Down
4 changes: 3 additions & 1 deletion MCGalaxy/Levels/LevelOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<LevelOption> Options = new List<LevelOption>() {
new LevelOption(MOTD, SetMotd, "&HSets the motd for this map. (leave blank to use default motd)"),
Expand All @@ -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."),
Expand Down Expand Up @@ -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);
Expand Down