Exemplo n.º 1
0
        public override void Process(Level level)
        {
            if (Message.Length > 0)
            {
                if (Message[0] == '/')
                {
                    var obj = GameOpCommandFactory.Parse(Message);
                    if (obj != null)
                    {
                        var player = "";
                        if (level != null)
                        {
                            player += " (" + level.GetPlayerAvatar().GetId() + ", " +
                                      level.GetPlayerAvatar().GetAvatarName() + ")";
                        }
                        ((GameOpCommand)obj).Execute(level);
                    }
                }
                else
                {
                    if (File.Exists(@"filter.ucs"))
                    {
                        var senderId   = level.GetPlayerAvatar().GetId();
                        var senderName = level.GetPlayerAvatar().GetAvatarName();

                        var badwords = new List <string>();
                        var r        = new StreamReader(@"filter.ucs");
                        var line     = "";
                        while ((line = r.ReadLine()) != null)
                        {
                            badwords.Add(line);
                        }
                        var badword = badwords.Any(s => Message.Contains(s));

                        if (badword)
                        {
                            var p = new GlobalChatLineMessage(level.GetClient());
                            p.SetPlayerId(0);
                            p.SetPlayerName("UCS Chat Filter System");
                            p.SetLeagueId(22);
                            p.SetChatMessage("DETECTED BAD WORD! PLEASE AVOID USING BAD WORDS!");
                            PacketManager.ProcessOutgoingPacket(p);
                            return;
                        }

                        foreach (var onlinePlayer in ResourcesManager.GetOnlinePlayers())
                        {
                            var p = new GlobalChatLineMessage(onlinePlayer.GetClient());
                            if (onlinePlayer.GetAccountPrivileges() > 0)
                            {
                                p.SetPlayerName(senderName + " #" + senderId);
                            }
                            else
                            {
                                p.SetPlayerName(senderName);
                            }

                            p.SetChatMessage(Message);
                            p.SetPlayerId(senderId);
                            p.SetLeagueId(level.GetPlayerAvatar().GetLeagueId());
                            p.SetAlliance(ObjectManager.GetAlliance(level.GetPlayerAvatar().GetAllianceId()));
                            PacketManager.ProcessOutgoingPacket(p);
                        }
                    }
                    else
                    {
                        var p = new GlobalChatLineMessage(level.GetClient());
                        p.SetPlayerId(0);
                        p.SetPlayerName("UCS Chat System");
                        p.SetChatMessage(
                            "The Global Chat is currently disabled. Please try again later! For more Informations, check the Server Status!");
                        PacketManager.ProcessOutgoingPacket(p);
                    }
                }
            }
        }
Exemplo n.º 2
0
        public override void Execute(Level level)
        {
            if (level.GetAccountPrivileges() >= GetRequiredAccountPrivileges())
            {
                try
                {
                    if (m_vArgs.Length >= 2)
                    {
                        var senderId   = level.GetPlayerAvatar().GetId();
                        var c          = level.GetClient();
                        var argcount   = m_vArgs.Length;
                        int currentarg = 2;
                        var msg        = "";
                        while (currentarg < m_vArgs.Length)
                        {
                            msg += m_vArgs[currentarg] + " ";
                            currentarg++;
                        }
                        var  message = msg;
                        long id      = Convert.ToInt64(m_vArgs[1]);

                        bool playerexist;
                        try
                        {
                            var l = ResourcesManager.GetPlayer(id);
                            playerexist = true;
                        }
                        catch
                        {
                            playerexist = false;
                        }
                        if (playerexist.Equals(true))
                        {
                            var l              = ResourcesManager.GetPlayer(id);
                            var sendername     = level.GetPlayerAvatar().GetAvatarName();
                            var senderalliance = ObjectManager.GetAlliance(level.GetPlayerAvatar().GetAllianceId());
                            if (ResourcesManager.IsPlayerOnline(l))
                            {
                                var utmclient = l.GetClient();
                                var pm        = new GlobalChatLineMessage(utmclient);
                                pm.SetChatMessage(Message.FilterString(message));
                                pm.SetPlayerName(sendername + " (Private Message)");
                                pm.SetPlayerId(senderId);
                                pm.SetLeagueId(l.GetPlayerAvatar().GetLeagueId());
                                pm.SetAlliance(senderalliance);
                                PacketManager.ProcessOutgoingPacket(pm);
                                var resp = new GlobalChatLineMessage(c);
                                resp.SetChatMessage("Successfully sent Private Message to: " + l.GetPlayerAvatar().GetAvatarName() + " with the Text: " + Message.FilterString(message));
                                resp.SetPlayerId(senderId);
                                resp.SetAlliance(senderalliance);
                                resp.SetLeagueId(22);
                                PacketManager.ProcessOutgoingPacket(resp);
                            }
                            else
                            {
                                var pm = new GlobalChatLineMessage(c);
                                pm.SetChatMessage("Player is offline or not exist.");
                                pm.SetPlayerId(0);
                                pm.SetPlayerName("System Manager");
                                pm.SetLeagueId(22);
                                PacketManager.ProcessOutgoingPacket(pm);
                            }
                        }
                    }
                    else
                    {
                        var p = new GlobalChatLineMessage(level.GetClient());
                        p.SetChatMessage("Wrong usage,Please use /pm userid text\nTo get your ID use /myid. Save it or tell it to your friends.");
                        p.SetPlayerId(0);
                        p.SetLeagueId(22);
                        p.SetPlayerName("System Manager");
                    }
                }
                catch (Exception e)
                {
                    var p = new GlobalChatLineMessage(level.GetClient());
                    p.SetChatMessage("Wrong usage,Please use /pm userid text\nTo get your ID use /myid. Save it or tell it to your friends.");
                    p.SetPlayerId(0);
                    p.SetLeagueId(22);
                    p.SetPlayerName("System Manager");
                    PacketManager.ProcessOutgoingPacket(p);
                    MainWindow.RemoteWindow.WriteConsoleDebug("Exception on PM caught.: " + e, (int)MainWindow.level.DEBUGFATAL);
                }
            }
            else
            {
                SendCommandFailedMessage(level.GetClient());
            }
        }
Exemplo n.º 3
0
        public override async void Process(Level level)
        {
            try
            {
                if (Message.Length > 0)
                {
                    if (Message.Length < 101)
                    {
                        if (Message[0] == '/')
                        {
                            if (Message == "/test")
                            {
                                PacketProcessor.Send(new HomeBattleReplayDataMessage(Client));
                            }

                            object obj = GameOpCommandFactory.Parse(Message);
                            if (obj != null)
                            {
                                string player = "";
                                if (level != null)
                                {
                                    player += " (" + level.GetPlayerAvatar().GetId() + ", " +
                                              level.GetPlayerAvatar().GetAvatarName() + ")";
                                }
                                ((GameOpCommand)obj).Execute(level);
                            }
                        }
                        else
                        {
                            long   senderId   = level.GetPlayerAvatar().GetId();
                            string senderName = level.GetPlayerAvatar().GetAvatarName();

                            bool badword = DirectoryChecker.badwords.Any(s => Message.Contains(s));

                            if (badword)
                            {
                                foreach (Level pl in ResourcesManager.GetOnlinePlayers())
                                {
                                    /*if (pl.GetPlayerAvatar().GetUserRegion() == level.GetPlayerAvatar().GetUserRegion())
                                     * {*/
                                    GlobalChatLineMessage p = new GlobalChatLineMessage(pl.GetClient());
                                    string NewMessage       = "";

                                    for (int i = 0; i < Message.Length; i++)
                                    {
                                        NewMessage += "*";
                                    }

                                    p.SetPlayerName(senderName);
                                    p.SetChatMessage(NewMessage);
                                    p.SetPlayerId(senderId);
                                    p.SetLeagueId(level.GetPlayerAvatar().GetLeagueId());
                                    p.SetAlliance(await ObjectManager.GetAlliance(level.GetPlayerAvatar().GetAllianceId()));

                                    ChatProcessor.AddMessage(p);
                                    //PacketManager.Send(p);
                                    //}
                                }
                            }
                            else
                            {
                                foreach (Level onlinePlayer in ResourcesManager.GetOnlinePlayers())
                                {
                                    /*if (onlinePlayer.GetPlayerAvatar().GetUserRegion() == level.GetPlayerAvatar().GetUserRegion())
                                     * {*/
                                    GlobalChatLineMessage p = new GlobalChatLineMessage(onlinePlayer.GetClient());
                                    p.SetPlayerName(senderName);
                                    p.SetChatMessage(Message);
                                    p.SetPlayerId(senderId);
                                    p.SetLeagueId(level.GetPlayerAvatar().GetLeagueId());
                                    p.SetAlliance(await ObjectManager.GetAlliance(level.GetPlayerAvatar().GetAllianceId()));
                                    //PacketManager.Send(p);
                                    ChatProcessor.AddMessage(p);
                                    Logger.Write("Chat Message: '" + Message + "' from '" + senderName + "':'" + senderId + "'");
                                    //}
                                }
                            }
                        }
                    }
                }
            } catch (Exception) { }
        }
Exemplo n.º 4
0
        public override void Process(Level level)
        {
            if (Message.Length > 0)
            {
                if (Message[0] == '/')
                {
                    var obj = GameOpCommandFactory.Parse(Message);
                    if (obj != null)
                    {
                        var player = "";
                        if (level != null)
                        {
                            player += " (" + level.GetPlayerAvatar().GetId() + ", " +
                                      level.GetPlayerAvatar().GetAvatarName() + ")";
                        }
                        ((GameOpCommand)obj).Execute(level);
                    }
                }
                else
                {
                    if (File.Exists(@"filter.ucs"))
                    {
                        var senderId   = level.GetPlayerAvatar().GetId();
                        var senderName = level.GetPlayerAvatar().GetAvatarName();

                        var badwords = new List <string>();
                        var r        = new StreamReader(@"filter.ucs");
                        var line     = "";
                        while ((line = r.ReadLine()) != null)
                        {
                            badwords.Add(line);
                        }
                        var badword = badwords.Any(s => Message.Contains(s));

                        if (badword)
                        {
                            var p = new GlobalChatLineMessage(level.GetClient());
                            p.SetPlayerId(0);
                            p.SetPlayerName("Chat Filter System");
                            p.SetLeagueId(22);
                            p.SetChatMessage("DETECTED BAD WORD! PLEASE AVOID USING BAD WORDS!");
                            p.Send();
                            return;
                        }

                        Parallel.ForEach((ResourcesManager.GetOnlinePlayers()), (onlinePlayer, l) =>
                        {
                            var p  = new GlobalChatLineMessage(onlinePlayer.GetClient());
                            var p2 = onlinePlayer.GetPlayerAvatar().GetPremium();
                            if (onlinePlayer.GetAccountPrivileges() > 0)
                            {
                                p.SetPlayerName(senderName + " #" + senderId);
                            }
                            else
                            {
                                p.SetPlayerName(senderName);
                            }
                            p.SetChatMessage(Message);
                            p.SetPlayerId(senderId);
                            p.SetLeagueId(level.GetPlayerAvatar().GetLeagueId());
                            p.SetAlliance(ObjectManager.GetAlliance(level.GetPlayerAvatar().GetAllianceId()));
                            p.Send();
                            Logger.Write("Chat Message: '" + Message + "' from '" + senderName + "':'" + senderId + "'");
                        });
                    }
                }
            }
        }
        public override void Process(Level level)
        {
            if (Message.Length > 0)
            {
                if (Message[0] == '/')
                {
                    var cmd = (GameOpCommand)GameOpCommandFactory.Parse(Message);
                    cmd?.Execute(level);
                }
                else
                {
                    var senderId   = level.GetPlayerAvatar().GetId();
                    var senderName = level.GetPlayerAvatar().GetAvatarName();

                    if (File.Exists(@"filter.ucs"))
                    {
                        var messageLower = Message.ToLower();
                        var flagged      = false;
                        for (int i = 0; i < s_bannedWords.Length; i++)
                        {
                            if (messageLower.Contains(s_bannedWords[i]))
                            {
                                flagged = true;
                                break;
                            }
                        }

                        if (flagged)
                        {
                            var message = new GlobalChatLineMessage(level.GetClient());
                            message.SetPlayerId(0);
                            message.SetPlayerName("Chat Filter System");
                            message.SetLeagueId(22);
                            message.SetChatMessage("We've detected banned words in your chat message.");
                            message.Send();
                            return;
                        }
                    }

                    var onlinePlayers = ResourcesManager.GetOnlinePlayers();
                    for (int i = 0; i < onlinePlayers.Count; i++)
                    {
                        var player  = onlinePlayers[i];
                        var message = new GlobalChatLineMessage(player.GetClient());

                        if (player.GetAccountPrivileges() > 0)
                        {
                            message.SetPlayerName(senderName + " #" + senderId);
                        }
                        else
                        {
                            message.SetPlayerName(senderName);
                        }

                        message.SetChatMessage(Message);
                        message.SetPlayerId(senderId);
                        message.SetLeagueId(level.GetPlayerAvatar().GetLeagueId());
                        message.SetAlliance(ObjectManager.GetAlliance(level.GetPlayerAvatar().GetAllianceId()));
                        message.Send();
                    }
                }
            }
        }
Exemplo n.º 6
0
        internal override async void Process()
        {
            if (Message.Length > 0 && Message.Length < 200)
            {
                if (Message[0] == '/')
                {
                    object obj = GameOpCommandFactory.Parse(Message);
                    if (obj != null)
                    {
                        string player = "";
                        if (this.Device.Player != null)
                        {
                            player += " (" + this.Device.Player.Avatar.UserId + ", " +
                                      this.Device.Player.Avatar.AvatarName + ")";
                        }
                        ((GameOpCommand)obj).Execute(this.Device.Player);
                    }
                }
                else
                {
                    long   senderId   = this.Device.Player.Avatar.UserId;
                    string senderName = this.Device.Player.Avatar.AvatarName;

                    bool badword = DirectoryChecker.badwords.Any(s => Message.Contains(s));

                    try
                    {
                        if (badword)
                        {
                            foreach (Level pl in ResourcesManager.m_vOnlinePlayers)
                            {
                                if (pl.Avatar.Region == this.Device.Player.Avatar.Region)
                                {
                                    string NewMessage = "";

                                    for (int i = 0; i < Message.Length; i++)
                                    {
                                        NewMessage += "*";
                                    }

                                    GlobalChatLineMessage p = new GlobalChatLineMessage(pl.Client)
                                    {
                                        PlayerName    = senderName,
                                        Message       = NewMessage,
                                        HomeId        = senderId,
                                        CurrentHomeId = senderId,
                                        LeagueId      = this.Device.Player.Avatar.m_vLeagueId
                                    };

                                    p.SetAlliance(ObjectManager.GetAlliance(this.Device.Player.Avatar.AllianceId));
                                    p.Send();
                                }
                            }
                        }
                        else
                        {
                            foreach (Level onlinePlayer in ResourcesManager.m_vOnlinePlayers)
                            {
                                if (onlinePlayer.Avatar.Region == this.Device.Player.Avatar.Region)
                                {
                                    GlobalChatLineMessage p = new GlobalChatLineMessage(onlinePlayer.Client)
                                    {
                                        PlayerName    = senderName,
                                        Message       = this.Message,
                                        HomeId        = senderId,
                                        CurrentHomeId = senderId,
                                        LeagueId      = this.Device.Player.Avatar.m_vLeagueId
                                    };
                                    p.SetAlliance(ObjectManager.GetAlliance(this.Device.Player.Avatar.AllianceId));
                                    p.Send();
                                    Logger.Write($"Chat Message: '{Message}' from '{senderName}':'{senderId}'");
                                }
                            }
                        }
                    }
                    catch (Exception)
                    {
                    }
                }
            }
        }