diff --git a/MCGalaxy/Commands/Bots/CmdBotAdd.cs b/MCGalaxy/Commands/Bots/CmdBotAdd.cs index 0ed18dac5..72743b5e3 100644 --- a/MCGalaxy/Commands/Bots/CmdBotAdd.cs +++ b/MCGalaxy/Commands/Bots/CmdBotAdd.cs @@ -32,6 +32,10 @@ namespace MCGalaxy.Commands.Bots { } if (!Formatter.ValidName(p, message, "bot")) return; + if (BotExists(p.level, message)) { + Player.Message(p, "A bot with that name already exists."); return; + } + PlayerBot bot = new PlayerBot(message, p.level); bot.Pos = p.Pos; bot.SetYawPitch(p.Rot.RotY, 0); @@ -39,6 +43,14 @@ namespace MCGalaxy.Commands.Bots { Player.Message(p, "You added the bot " + bot.ColoredName + "%S."); PlayerBot.Add(bot); } + + static bool BotExists(Level lvl, string name) { + PlayerBot[] bots = lvl.Bots.Items; + foreach (PlayerBot bot in bots) { + if (bot.name.CaselessEq(name)) return true; + } + return false; + } public override void Help(Player p) { Player.Message(p, "%T/BotAdd [name]");