Example #1
0
 static async Task HandleInput(string input)
 {
     if (input.StartsWith("connect", StringComparison.OrdinalIgnoreCase))
     {
         await ConnectCommand.HandleCommand(input);
     }
     if (input.StartsWith("receive", StringComparison.OrdinalIgnoreCase))
     {
         ReceiveCommand.HandleCommand(input);
     }
     if (input.StartsWith("say", StringComparison.OrdinalIgnoreCase))
     {
         SayCommand.HandleCommand(input);
     }
 }
Example #2
0
 private async Task Say(SayCommand cmd)
 {
     //validate cmd arguments here, before dispatch
     await this.Update(cmd.PersonId, x => x.Say(cmd.PersonId, cmd.Say, cmd.Timestamp));
 }
Example #3
0
        private void ShuffleCommandAction()
        {
            if (xDoc != null)
            {
                Task.Run(() =>
                {
                    SetWaiting(true);
                    try
                    {
                        if (lstAnsweredWords != null)
                        {
                            lstAnsweredWords.Clear();
                        }

                        List <XElement> lst       = new List <XElement>();
                        IEnumerable <XElement> de =
                            from el in xDoc.Descendants()
                            select el;
                        foreach (XElement el in de)
                        {
                            lst.Add(el);
                        }
                        if (xDocUser != null && xDocUser.Descendants().Count() >= 1)
                        {
                            IEnumerable <XElement> deUser = from elUser in xDocUser.Descendants("Text") select elUser;
                            foreach (XElement elCurrent in deUser)
                            {
                                lst.Add(elCurrent);
                            }
                        }

                        Random r       = new Random();
                        int gettedDict = r.Next(1, lst.Count);

                        selectedText = lst[gettedDict].Value;
                        List <string> wordsAndPunctation = selectedText.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries).ToList();


                        FText = new FormattedString();
                        int indexSpecialWords        = 0;
                        int indexAllWords            = 0;
                        List <SpecialWords> lstWords = new List <SpecialWords>();
                        lstSpecialWords.Clear();

                        MainThread.BeginInvokeOnMainThread(() =>
                        {
                            foreach (string word in wordsAndPunctation)
                            {
                                if (word.Contains("Ó") || word.Contains("ó") || word.Contains("U") || word.Contains("u") || word.Contains("rz") || word.Contains("Rz") ||
                                    word.Contains("Ż") || word.Contains("ż") || word.Contains("h") || word.Contains("H") || word.Contains("Ch") || word.Contains("ch")
                                    )
                                {
                                    SayCommand.ChangeCanExecute();
                                    SpecialWords sw = new SpecialWords(word);

                                    string text = string.Empty;
                                    if (Device.RuntimePlatform == Device.Android)
                                    {
                                        text = Environment.NewLine + sw.GetDashedWord() + " ";
                                    }
                                    else
                                    {
                                        text = sw.GetDashedWord() + " ";
                                    }

                                    Span s = new Span()
                                    {
                                        Text = text, TextColor = Color.Red, ForegroundColor = Color.FromHex("999999")
                                    };
                                    TapGestureRecognizer tgr = new TapGestureRecognizer();

                                    tgr.NumberOfTapsRequired = 1;
                                    int temp             = indexSpecialWords;
                                    tgr.CommandParameter = temp;

                                    //tgr.Command = new Command(WordTapped);
                                    tgr.Tapped += Tgr_Tapped;
                                    s.GestureRecognizers.Add(tgr);
                                    FText.Spans.Add(s);

                                    sw.NumberWrongWordElement = indexSpecialWords;
                                    sw.DashedWord             = s.Text;
                                    lstSpecialWords.Add(sw);
                                    indexSpecialWords++;

                                    sw.NumberAllWordsElement = indexAllWords;
                                    lstWords.Add(sw);

                                    indexAllWords++;
                                }
                                else
                                {
                                    if (Device.RuntimePlatform == Device.Android)
                                    {
                                        FText.Spans.Add(new Span()
                                        {
                                            Text = " " + word + " ", ForegroundColor = Color.FromHex("999999")
                                        });
                                    }
                                    else
                                    {
                                        FText.Spans.Add(new Span()
                                        {
                                            Text = word + " ", ForegroundColor = Color.FromHex("999999")
                                        });
                                    }

                                    indexAllWords++;
                                }
                            }
                        });
                    }
                    catch (Exception ex)
                    {
                        UserDialogs.Instance.Alert(Language.txtErrorMessage + ex.Message, Language.txtErrorTitle, Language.txtErrorBtn);
                    }
                    finally
                    {
                        SetWaiting(false);
                    }
                });
            }
        }
Example #4
0
        public static void listen()
        {
            Console.WriteLine("Erida Consoler v" + CR_VERSION + " for C#.");
            Console.WriteLine("Author - " + CR_AUTHOR);
            Console.WriteLine("Type \"help\" to get command list.");
            Console.Write("Consoler> ");
            ConsolerCommand helpCmd = new HelpCommand(commands)
                                      .setCommandName("help")
                                      .setShortHelpText("Write list of registred commands.");
            ConsolerCommand altHelpCmd = new HelpCommand(commands)
                                         .setCommandName("?")
                                         .setShortHelpText("Alternative command to write list of registred commands.");
            ConsolerCommand exitCmd = new ExitCommand()
                                      .setCommandName("exit")
                                      .setShortHelpText("Terminate all executed processes and close consoler.");
            ConsolerCommand versionCmd = new VersionCommand()
                                         .setCommandName("version")
                                         .setShortHelpText("Write version of consoler.");
            ConsolerCommand clearCmd = new ClearCommand()
                                       .setCommandName("clear")
                                       .setShortHelpText("Clear consoler space from text and other stuff.");
            ConsolerCommand sayCmd = new SayCommand()
                                     .setCommandName("say")
                                     .setShortHelpText("Print phrase with line break or without it.")
                                     .setFullHelpText("Print phrase with line break or without it.\n" +
                                                      "Arguments:\n" +
                                                      "-pl - Print line with line break.\n" +
                                                      "-p - Print just text without line breaks.");
            ConsolerCommand scriptCmd = new ScriptCommand()
                                        .setCommandName("execute")
                                        .setShortHelpText("Execute script with consoler syntax.")
                                        .setFullHelpText("Execute script with consoler syntax. Lines must be ended by nothing, just line break to use next command.\n" +
                                                         "Argument -p is the one, it's need to set path to executing file. File can be any extension and size.");

            register(helpCmd);
            register(altHelpCmd);
            register(exitCmd);
            register(versionCmd);
            register(clearCmd);
            register(sayCmd);
            register(scriptCmd);
            while (true)
            {
                string line = Console.ReadLine();
                if (line != "")
                {
                    ConsolerCommand dedicatedCommand = parseCommand(line);
                    if (isCommandExists(dedicatedCommand.getCommandName()))
                    {
                        GetCommand(dedicatedCommand.getCommandName()).Merge(dedicatedCommand);
                        GetCommand(dedicatedCommand.getCommandName()).executeCommand();
                        Console.Write("Consoler> ");
                    }
                    else
                    {
                        Console.WriteLine("Command \"" + dedicatedCommand.getCommandName() + "\" is not exist or not registred. Type \"help\" to " +
                                          "get registred commands list.");
                        Console.Write("Consoler> ");
                    }
                }
                else
                {
                    Console.Write("Consoler> ");
                }
            }
        }
Example #5
0
        public void TestCustomGroupCommands()
        {
            //setup
            using Datapack pack = new Datapack("datapacks", "pack", "a pack", 0, new NoneFileCreator());
            PackNamespace space    = pack.Namespace("space");
            Function      function = space.Function("function", BaseFile.WriteSetting.OnDispose);

            BaseCommand command1 = new ExecuteAt(ID.Selector.s);
            BaseCommand command2 = new SayCommand("123");
            BaseCommand command3 = new SayMeCommand("123");
            BaseCommand command4 = new ExecuteAs(ID.Selector.s);

            //test
            //without execute at start
            function.Custom.GroupCommands((f) =>
            {
                f.AddCommand(command1.ShallowClone());
                f.AddCommand(command2);
                f.AddCommand(command3);
            });
            Assert.AreEqual("execute at @s run say 123", function.Commands[0].GetCommandString(), "Get first grouped command string returned wrong string");
            Assert.AreEqual("me 123", function.Commands[1].GetCommandString(), "Get second grouped command string returned wrong string");

            //with execute at start
            function.Commands.Clear();
            function.AddCommand(command1.ShallowClone());
            function.Custom.GroupCommands((f) =>
            {
                f.AddCommand(command2);
                f.AddCommand(command4.ShallowClone());
                f.AddCommand(command3);
            });
            Assert.AreEqual("execute at @s run say 123", function.Commands[0].GetCommandString(), "Get first executed grouped command string returned wrong string");
            Assert.AreEqual("execute at @s as @s run me 123", function.Commands[1].GetCommandString(), "Get second executed grouped command string returned wrong string");

            //using function
            function.Commands.Clear();
            function.AddCommand(command1.ShallowClone());
            function.Custom.GroupCommands((f) =>
            {
                f.AddCommand(command2);
                f.AddCommand(command1.ShallowClone());
                f.AddCommand(command3);
            }, true);
            Function addedFunction = (((function.Commands[0] as BaseExecuteCommand) !.ExecuteCommand as RunFunctionCommand) !.Function as Function) !;

            Assert.AreEqual("say 123", addedFunction.Commands[0].GetCommandString(), "Get first function grouped command string returned wrong string");
            Assert.AreEqual("execute at @s run me 123", addedFunction.Commands[1].GetCommandString(), "Get second function grouped command string returned wrong string");
            Assert.AreEqual(2, addedFunction.Commands.Count, "function grouped command doesn't contain the correct amount of commands");

            space.AddSetting(NamespaceSettings.GetSettings().FunctionGroupedCommands());
            function.Commands.Clear();
            function.AddCommand(command1.ShallowClone());
            function.Custom.GroupCommands((f) =>
            {
                f.AddCommand(command2);
                f.AddCommand(command1.ShallowClone());
                f.AddCommand(command3);
            });
            addedFunction = (((function.Commands[0] as BaseExecuteCommand) !.ExecuteCommand as RunFunctionCommand) !.Function as Function) !;
            Assert.AreEqual(2, addedFunction.Commands.Count, "automatic function grouped command doesn't get the correct commands");
        }
Example #6
0
        protected override void OnReceived(byte[] body)
        {
            ByteArrayArrayStream stream = new ByteArrayArrayStream(body);

            ByteArrayStreamReader reader = new ByteArrayStreamReader(stream);

            try
            {
                if (Adler32.Generate(body, 4) == reader.ReadUInt())
                {
                    if (Keys == null)
                    {
                        Rsa.DecryptAndReplace(body, 9);
                    }
                    else
                    {
                        Xtea.DecryptAndReplace(body, 4, 32, Keys);

                        stream.Seek(Origin.Current, 2);
                    }

                    Command command = null;

                    switch (reader.ReadByte())
                    {
                    case 0x0A:
                    {
                        var packet = server.PacketsFactory.Create <SelectedCharacterIncomingPacket>(reader);

                        command = new LogInCommand(this, packet);
                    }
                    break;

                    case 0x14:

                        command = new LogOutCommand(Client.Player);

                        break;

                    case 0x1E:

                        command = new PongCommand(Client.Player);

                        break;

                    case 0x64:
                    {
                        var packet = server.PacketsFactory.Create <WalkToIncomingPacket>(reader);

                        command = new WalkToKnownPathCommand(Client.Player, packet.MoveDirections);
                    }
                    break;

                    case 0x65:

                        command = new WalkCommand(Client.Player, MoveDirection.North);

                        break;

                    case 0x66:

                        command = new WalkCommand(Client.Player, MoveDirection.East);

                        break;

                    case 0x67:

                        command = new WalkCommand(Client.Player, MoveDirection.South);

                        break;

                    case 0x68:

                        command = new WalkCommand(Client.Player, MoveDirection.West);

                        break;

                    case 0x69:

                        command = new StopWalkCommand(Client.Player);

                        break;

                    case 0x6A:

                        command = new WalkCommand(Client.Player, MoveDirection.NorthEast);

                        break;

                    case 0x6B:

                        command = new WalkCommand(Client.Player, MoveDirection.SouthEast);

                        break;

                    case 0x6C:

                        command = new WalkCommand(Client.Player, MoveDirection.SouthWest);

                        break;

                    case 0x6D:

                        command = new WalkCommand(Client.Player, MoveDirection.NorthWest);

                        break;

                    case 0x6F:

                        command = new TurnCommand(Client.Player, Direction.North);

                        break;

                    case 0x70:

                        command = new TurnCommand(Client.Player, Direction.East);

                        break;

                    case 0x71:

                        command = new TurnCommand(Client.Player, Direction.South);

                        break;

                    case 0x72:

                        command = new TurnCommand(Client.Player, Direction.West);

                        break;

                    case 0x78:
                    {
                        var packet = server.PacketsFactory.Create <MoveItemIncomingPacket>(reader);

                        Position fromPosition = new Position(packet.FromX, packet.FromY, packet.FromZ);

                        Position toPosition = new Position(packet.ToX, packet.ToY, packet.ToZ);

                        if (fromPosition.IsContainer)
                        {
                            if (toPosition.IsContainer)
                            {
                                command = new MoveItemFromContainerToContainerCommand(Client.Player, fromPosition.ContainerId, fromPosition.ContainerIndex, packet.FromItemId, toPosition.ContainerId, toPosition.ContainerIndex, packet.Count);
                            }
                            else if (toPosition.IsInventory)
                            {
                                command = new MoveItemFromContainerToInventoryCommand(Client.Player, fromPosition.ContainerId, fromPosition.ContainerIndex, packet.FromItemId, toPosition.InventoryIndex, packet.Count);
                            }
                            else
                            {
                                command = new MoveItemFromContainerToTileCommand(Client.Player, fromPosition.ContainerId, fromPosition.ContainerIndex, packet.FromItemId, toPosition, packet.Count);
                            }
                        }
                        else if (fromPosition.IsInventory)
                        {
                            if (toPosition.IsContainer)
                            {
                                command = new MoveItemFromInventoryToContainerCommand(Client.Player, fromPosition.InventoryIndex, packet.FromItemId, toPosition.ContainerId, toPosition.ContainerIndex, packet.Count);
                            }
                            else if (toPosition.IsInventory)
                            {
                                command = new MoveItemFromInventoryToInventoryCommand(Client.Player, fromPosition.InventoryIndex, packet.FromItemId, toPosition.InventoryIndex, packet.Count);
                            }
                            else
                            {
                                command = new MoveItemFromInventoryToTileCommand(Client.Player, fromPosition.InventoryIndex, packet.FromItemId, toPosition, packet.Count);
                            }
                        }
                        else
                        {
                            if (toPosition.IsContainer)
                            {
                                command = new MoveItemFromTileToContainerCommand(Client.Player, fromPosition, packet.FromIndex, packet.FromItemId, toPosition.ContainerId, toPosition.ContainerIndex, packet.Count);
                            }
                            else if (toPosition.IsInventory)
                            {
                                command = new MoveItemFromTileToInventoryCommand(Client.Player, fromPosition, packet.FromIndex, packet.FromItemId, toPosition.InventoryIndex, packet.Count);
                            }
                            else
                            {
                                command = new MoveItemFromTileToTileCommand(Client.Player, fromPosition, packet.FromIndex, packet.FromItemId, toPosition, packet.Count);
                            }
                        }
                    }
                    break;

                    case 0x79:
                    {
                        var packet = server.PacketsFactory.Create <LookItemNpcTradeIncommingPacket>(reader);

                        command = new LookFromNpcTradeCommand(Client.Player, packet.ItemId, packet.Type);
                    }
                    break;

                    case 0x7A:
                    {
                        var packet = server.PacketsFactory.Create <BuyNpcTradeIncommingPacket>(reader);

                        command = new BuyNpcTradeCommand(Client.Player, packet);
                    }
                    break;

                    case 0x7B:
                    {
                        var packet = server.PacketsFactory.Create <SellNpcTradeIncommingPacket>(reader);

                        command = new SellNpcTradeCommand(Client.Player, packet);
                    }
                    break;

                    case 0x7C:

                        command = new CloseNpcTradeCommand(Client.Player);

                        break;

                    case 0x7D:
                    {
                        var packet = server.PacketsFactory.Create <TradeWithIncommingPacket>(reader);

                        Position fromPosition = new Position(packet.X, packet.Y, packet.Z);

                        if (fromPosition.IsContainer)
                        {
                            command = new TradeWithFromContainerCommand(Client.Player, fromPosition.ContainerId, fromPosition.ContainerIndex, packet.ItemId, packet.CreatureId);
                        }
                        else if (fromPosition.IsInventory)
                        {
                            command = new TradeWithFromInventoryCommand(Client.Player, fromPosition.InventoryIndex, packet.ItemId, packet.CreatureId);
                        }
                        else
                        {
                            command = new TradeWithFromTileCommand(Client.Player, fromPosition, packet.Index, packet.ItemId, packet.CreatureId);
                        }
                    }
                    break;

                    case 0x7E:
                    {
                        var packet = server.PacketsFactory.Create <LookItemTradeIncommingPacket>(reader);

                        command = new LookFromTradeCommand(Client.Player, packet.WindowId, packet.Index);
                    }
                    break;

                    case 0x7F:

                        command = new AcceptTradeCommand(Client.Player);

                        break;

                    case 0x80:

                        command = new CancelTradeCommand(Client.Player);

                        break;

                    case 0x82:
                    {
                        var packet = server.PacketsFactory.Create <UseItemIncomingPacket>(reader);

                        Position fromPosition = new Position(packet.X, packet.Y, packet.Z);

                        if (fromPosition.IsContainer)
                        {
                            command = new UseItemFromContainerCommand(Client.Player, fromPosition.ContainerId, fromPosition.ContainerIndex, packet.ItemId, packet.ContainerId);
                        }
                        else if (fromPosition.IsInventory)
                        {
                            command = new UseItemFromInventoryCommand(Client.Player, fromPosition.InventoryIndex, packet.ItemId);
                        }
                        else
                        {
                            command = new UseItemFromTileCommand(Client.Player, fromPosition, packet.Index, packet.ItemId);
                        }
                    }
                    break;

                    case 0x83:
                    {
                        var packet = server.PacketsFactory.Create <UseItemWithItemIncomingPacket>(reader);

                        Position fromPosition = new Position(packet.FromX, packet.FromY, packet.FromZ);

                        Position toPosition = new Position(packet.ToX, packet.ToY, packet.ToZ);

                        if (fromPosition.IsContainer)
                        {
                            if (toPosition.IsContainer)
                            {
                                command = new UseItemWithItemFromContainerToContainerCommand(Client.Player, fromPosition.ContainerId, fromPosition.ContainerIndex, packet.FromItemId, toPosition.ContainerId, toPosition.ContainerIndex, packet.ToItemId);
                            }
                            else if (toPosition.IsInventory)
                            {
                                command = new UseItemWithItemFromContainerToInventoryCommand(Client.Player, fromPosition.ContainerId, fromPosition.ContainerIndex, packet.FromItemId, toPosition.InventoryIndex, packet.ToItemId);
                            }
                            else
                            {
                                command = new UseItemWithItemFromContainerToTileCommand(Client.Player, fromPosition.ContainerId, fromPosition.ContainerIndex, packet.FromItemId, toPosition, packet.ToIndex, packet.ToItemId);
                            }
                        }
                        else if (fromPosition.IsInventory)
                        {
                            if (toPosition.IsContainer)
                            {
                                command = new UseItemWithItemFromInventoryToContainerCommand(Client.Player, fromPosition.InventoryIndex, packet.FromItemId, toPosition.ContainerId, toPosition.ContainerIndex, packet.ToItemId);
                            }
                            else if (toPosition.IsInventory)
                            {
                                command = new UseItemWithItemFromInventoryToInventoryCommand(Client.Player, fromPosition.InventoryIndex, packet.FromItemId, toPosition.InventoryIndex, packet.ToItemId);
                            }
                            else
                            {
                                command = new UseItemWithItemFromInventoryToTileCommand(Client.Player, fromPosition.InventoryIndex, packet.FromItemId, toPosition, packet.ToIndex, packet.ToItemId);
                            }
                        }
                        else
                        {
                            if (toPosition.IsContainer)
                            {
                                command = new UseItemWithItemFromTileToContainerCommand(Client.Player, fromPosition, packet.FromIndex, packet.FromItemId, toPosition.ContainerId, toPosition.ContainerIndex, packet.ToItemId);
                            }
                            else if (toPosition.IsInventory)
                            {
                                command = new UseItemWithItemFromTileToInventoryCommand(Client.Player, fromPosition, packet.FromIndex, packet.FromItemId, toPosition.InventoryIndex, packet.ToItemId);
                            }
                            else
                            {
                                command = new UseItemWithItemFromTileToTileCommand(Client.Player, fromPosition, packet.FromIndex, packet.FromItemId, toPosition, packet.ToIndex, packet.ToItemId);
                            }
                        }
                    }
                    break;

                    case 0x84:
                    {
                        var packet = server.PacketsFactory.Create <UseItemWithCreatureIncomingPacket>(reader);

                        Position fromPosition = new Position(packet.X, packet.Y, packet.Z);

                        if (fromPosition.IsContainer)
                        {
                            command = new UseItemWithCreatureFromContainerCommand(Client.Player, fromPosition.ContainerId, fromPosition.ContainerIndex, packet.ItemId, packet.CreatureId);
                        }
                        else if (fromPosition.IsInventory)
                        {
                            command = new UseItemWithCreatureFromInventoryCommand(Client.Player, fromPosition.InventoryIndex, packet.ItemId, packet.CreatureId);
                        }
                        else
                        {
                            command = new UseItemWithCreatureFromTileCommand(Client.Player, fromPosition, packet.Index, packet.ItemId, packet.CreatureId);
                        }
                    }
                    break;

                    case 0x85:
                    {
                        var packet = server.PacketsFactory.Create <RotateItemIncomingPacket>(reader);

                        var fromPosition = new Position(packet.X, packet.Y, packet.Z);

                        if (fromPosition.IsContainer)
                        {
                            command = new RotateItemFromContainerCommand(Client.Player, fromPosition.ContainerId, fromPosition.ContainerIndex, packet.ItemId);
                        }
                        else if (fromPosition.IsInventory)
                        {
                            command = new RotateItemFromInventoryCommand(Client.Player, fromPosition.InventoryIndex, packet.ItemId);
                        }
                        else
                        {
                            command = new RotateItemFromTileCommand(Client.Player, fromPosition, packet.Index, packet.ItemId);
                        }
                    }
                    break;

                    case 0x87:
                    {
                        var packet = server.PacketsFactory.Create <CloseContainerIncommingPacket>(reader);

                        command = new CloseContainerCommand(Client.Player, packet.ContainerId);
                    }
                    break;

                    case 0x88:
                    {
                        var packet = server.PacketsFactory.Create <OpenParentIncommingPacket>(reader);

                        command = new OpenParentContainerCommand(Client.Player, packet.ContainerId);
                    }
                    break;

                    case 0x8C:
                    {
                        var packet = server.PacketsFactory.Create <LookIncomingPacket>(reader);

                        var fromPosition = new Position(packet.X, packet.Y, packet.Z);

                        if (fromPosition.IsContainer)
                        {
                            command = new LookFromContainerCommand(Client.Player, fromPosition.ContainerId, fromPosition.ContainerIndex, packet.ItemId);
                        }
                        else if (fromPosition.IsInventory)
                        {
                            command = new LookFromInventoryCommand(Client.Player, fromPosition.InventoryIndex, packet.ItemId);
                        }
                        else
                        {
                            command = new LookFromTileCommand(Client.Player, fromPosition, packet.Index, packet.ItemId);
                        }
                    }
                    break;

                    case 0x96:
                    {
                        var packet = server.PacketsFactory.Create <TalkIncommingPacket>(reader);

                        switch (packet.TalkType)
                        {
                        case TalkType.Say:

                            command = new SayCommand(Client.Player, packet.Message);

                            break;

                        case TalkType.Whisper:

                            command = new WhisperCommand(Client.Player, packet.Message);

                            break;

                        case TalkType.Yell:

                            command = new YellCommand(Client.Player, packet.Message);

                            break;

                        case TalkType.Private:

                            command = new SendMessageToPlayerCommand(Client.Player, packet.Name, packet.Message);

                            break;

                        case TalkType.ChannelYellow:

                            command = new SendMessageToChannel(Client.Player, packet.ChannelId, packet.Message);

                            break;

                        case TalkType.ReportRuleViolationOpen:

                            command = new CreateReportRuleViolationCommand(Client.Player, packet.Message);

                            break;

                        case TalkType.ReportRuleViolationAnswer:

                            command = new AnswerInReportRuleViolationChannelCommand(Client.Player, packet.Name, packet.Message);

                            break;

                        case TalkType.ReportRuleViolationQuestion:

                            command = new AskInReportRuleViolationChannelCommand(Client.Player, packet.Message);

                            break;

                        case TalkType.Broadcast:

                            command = new BroadcastMessageCommand(Client.Player, packet.Message);

                            break;
                        }
                    }
                    break;

                    case 0x97:

                        command = new OpenNewChannelCommand(Client.Player);

                        break;

                    case 0x98:
                    {
                        var packet = server.PacketsFactory.Create <OpenedNewChannelIncomingPacket>(reader);

                        command = new OpenedNewChannelCommand(Client.Player, packet.ChannelId);
                    }
                    break;

                    case 0x99:
                    {
                        var packet = server.PacketsFactory.Create <CloseChannelIncommingPacket>(reader);

                        command = new CloseChannelCommand(Client.Player, packet.ChannelId);
                    }
                    break;

                    case 0x9A:
                    {
                        var packet = server.PacketsFactory.Create <OpenedPrivateChannelIncomingPacket>(reader);

                        command = new OpenedPrivateChannelCommand(Client.Player, packet.Name);
                    }
                    break;

                    case 0x9B:
                    {
                        var packet = server.PacketsFactory.Create <ProcessReportRuleViolationIncommingPacket>(reader);

                        command = new ProcessReportRuleViolationCommand(Client.Player, packet.Name);
                    }
                    break;

                    case 0x9C:
                    {
                        var packet = server.PacketsFactory.Create <CloseReportRuleViolationChannelAnswerIncommingPacket>(reader);

                        command = new CloseReportRuleViolationChannelAnswerCommand(Client.Player, packet.Name);
                    }
                    break;

                    case 0x9D:

                        command = new CloseReportRuleViolationChannelQuestionCommand(Client.Player);

                        break;

                    case 0x9E:

                        command = new CloseNpcsChannelCommand(Client.Player);

                        break;

                    case 0xA0:
                    {
                        var packet = server.PacketsFactory.Create <CombatControlsIncommingPacket>(reader);

                        command = new CombatControlsCommand(Client.Player, packet.FightMode, packet.ChaseMode, packet.SafeMode);
                    }
                    break;

                    case 0xA1:
                    {
                        var packet = server.PacketsFactory.Create <AttackIncommingPacket>(reader);

                        if (packet.CreatureId == 0)
                        {
                            command = new StopAttackCommand(Client.Player);
                        }
                        else
                        {
                            command = new StartAttackCommand(Client.Player, packet.CreatureId, packet.Nonce);
                        }
                    }
                    break;

                    case 0xA2:
                    {
                        var packet = server.PacketsFactory.Create <FollowIncommingPacket>(reader);

                        if (packet.CreatureId == 0)
                        {
                            command = new StopFollowCommand(Client.Player);
                        }
                        else
                        {
                            command = new StartFollowCommand(Client.Player, packet.CreatureId, packet.Nonce);
                        }
                    }
                    break;

                    case 0xA3:
                    {
                        var packet = server.PacketsFactory.Create <InviteToPartyIncomingPacket>(reader);

                        command = new InviteToPartyCommand(Client.Player, packet.CreatureId);
                    }
                    break;

                    case 0xA4:
                    {
                        var packet = server.PacketsFactory.Create <JoinPartyIncomingPacket>(reader);

                        command = new JoinPartyCommand(Client.Player, packet.CreatureId);
                    }
                    break;

                    case 0xA5:
                    {
                        var packet = server.PacketsFactory.Create <RevokePartyIncomingPacket>(reader);

                        command = new RevokePartyCommand(Client.Player, packet.CreatureId);
                    }
                    break;

                    case 0xA6:
                    {
                        var packet = server.PacketsFactory.Create <PassLeadershipToIncomingPacket>(reader);

                        command = new PassLeaderShipToCommand(Client.Player, packet.CreatureId);
                    }
                    break;

                    case 0xA7:

                        command = new LeavePartyCommand(Client.Player);

                        break;

                    case 0xA8:
                    {
                        var packet = server.PacketsFactory.Create <SharedExperienceIncomingPacket>(reader);

                        command = new SharedExperienceCommand(Client.Player, packet.Enabled);
                    }
                    break;

                    case 0xAA:

                        command = new OpenedMyPrivateChannelCommand(Client.Player);

                        break;

                    case 0xAB:
                    {
                        var packet = server.PacketsFactory.Create <InvitePlayerIncommingPacket>(reader);

                        command = new InvitePlayerCommand(Client.Player, packet.Name);
                    }
                    break;

                    case 0xAC:
                    {
                        var packet = server.PacketsFactory.Create <ExcludePlayerIncommingPacket>(reader);

                        command = new ExcludePlayerCommand(Client.Player, packet.Name);
                    }
                    break;

                    case 0xBE:

                        command = new StopCommand(Client.Player);

                        break;

                    case 0xD2:

                        command = new SelectOutfitCommand(Client.Player);

                        break;

                    case 0xD3:
                    {
                        var packet = server.PacketsFactory.Create <SelectedOutfitIncomingPacket>(reader);

                        command = new SelectedOutfitCommand(Client.Player, packet.Outfit);
                    }
                    break;

                    case 0xDC:
                    {
                        var packet = server.PacketsFactory.Create <AddVipIncommingPacket>(reader);

                        command = new AddVipCommand(Client.Player, packet.Name);
                    }
                    break;

                    case 0xDD:
                    {
                        var packet = server.PacketsFactory.Create <RemoveVipIncommingPacket>(reader);

                        command = new RemoveVipCommand(Client.Player, packet.CreatureId);
                    }
                    break;

                    case 0xE6:
                    {
                        var packet = server.PacketsFactory.Create <ReportBugIncomingPacket>(reader);

                        command = new ReportBugCommand(Client.Player, packet.Message);
                    }
                    break;

                    case 0xF0:

                        command = new OpenQuestsCommand(Client.Player);

                        break;

                    case 0xF1:
                    {
                        var packet = server.PacketsFactory.Create <OpenQuestIncomingPacket>(reader);

                        command = new OpenQuestCommand(Client.Player, packet.QuestId);
                    }
                    break;
                    }

                    if (command != null)
                    {
                        server.QueueForExecution(command);
                    }
                }
            }
            catch (Exception ex)
            {
                server.Logger.WriteLine(ex.ToString());
            }

            base.OnReceived(body);
        }