Skip to content

Commit

Permalink
add option to disable bots
Browse files Browse the repository at this point in the history
  • Loading branch information
forkiesassds committed Sep 25, 2021
1 parent 78d969f commit 2b7840f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions MCGalaxy/Commands/Bots/CmdBot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public override void Use(Player p, string message, CommandData data) {

if (!Formatter.ValidName(p, args[1], "bot")) return;
if (!LevelInfo.Check(p, data.Rank, p.level, "modify bots in this level")) return;
if (!p.level.Config.AllowBots) { p.Message("Bots have been disabled in this level."); return; }

string bot = args[1], value = args.Length > 2 ? args[2] : null;
if (args[0].CaselessEq("add")) {
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

0 comments on commit 2b7840f

Please sign in to comment.