Beispiel #1
0
        static bool HandleArenaRenameCommand(StringArguments args, CommandHandler handler)
        {
            if (args.Empty())
            {
                return(false);
            }

            string oldArenaStr = handler.extractQuotedArg(args.NextString());

            if (string.IsNullOrEmpty(oldArenaStr))
            {
                handler.SendSysMessage(CypherStrings.BadValue);
                return(false);
            }

            string newArenaStr = handler.extractQuotedArg(args.NextString());

            if (string.IsNullOrEmpty(newArenaStr))
            {
                handler.SendSysMessage(CypherStrings.BadValue);
                return(false);
            }

            ArenaTeam arena = Global.ArenaTeamMgr.GetArenaTeamByName(oldArenaStr);

            if (arena == null)
            {
                handler.SendSysMessage(CypherStrings.AreanErrorNameNotFound, oldArenaStr);
                return(false);
            }

            if (Global.ArenaTeamMgr.GetArenaTeamByName(newArenaStr) != null)
            {
                handler.SendSysMessage(CypherStrings.ArenaErrorNameExists, oldArenaStr);
                return(false);
            }

            if (arena.IsFighting())
            {
                handler.SendSysMessage(CypherStrings.ArenaErrorCombat);
                return(false);
            }

            if (!arena.SetName(newArenaStr))
            {
                handler.SendSysMessage(CypherStrings.BadValue);
                return(false);
            }

            handler.SendSysMessage(CypherStrings.ArenaRename, arena.GetId(), oldArenaStr, newArenaStr);
            if (handler.GetSession() != null)
            {
                Log.outDebug(LogFilter.Arena, "GameMaster: {0} [GUID: {1}] rename arena team \"{2}\"[Id: {3}] to \"{4}\"",
                             handler.GetSession().GetPlayer().GetName(), handler.GetSession().GetPlayer().GetGUID().ToString(), oldArenaStr, arena.GetId(), newArenaStr);
            }
            else
            {
                Log.outDebug(LogFilter.Arena, "Console: rename arena team \"{0}\"[Id: {1}] to \"{2}\"", oldArenaStr, arena.GetId(), newArenaStr);
            }

            return(true);
        }