Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            string url  = "irc.chat.twitch.tv";
            int    port = 80;

            string user       = "******";
            string oAuthToken = System.IO.File.ReadAllText(@"token.txt"); // token.txt must be in the same folder as EXE
            string channel    = "lobosjr";

            //Set up one IrcClient, only one is required it allows better cooldown managerment and traffic will
            //never cause this code to run slower then any twitch cool down for bots.
            TwitchClientFactory icf    = new TwitchClientFactory();
            ITwitchClient       client = icf.create(url, port, user, oAuthToken, channel, 600,
                                                    new OperationRequestEventRaiser(), new PrivMessageEventRaiser(),
                                                    new WhisperMessageEventRaiser());

            client.DefaultMessageHandler += (o, e) =>
            {
                Console.WriteLine(string.Format("System: {0}", e.Raw));
            };

            //Set up Legacy Item -> IEquipment converter.
            LegacyItemEquipmentConverter liec = new LegacyItemEquipmentConverter();
            //Set up Equipment repository, if legacy then this will load all items from old files and convert them
            //into IEquipment in memory.
            IEquipmentRepository equipmentRepository = LegacyEquipmentRepository
                                                       .getInstance(liec, LegacyEquipmentRepository.LEGACY_ITEM_BRIDGE_FILE_PATH,
                                                                    LegacyEquipmentRepository.LEGACY_ITEM_PREFIX_FILE_PATH);

            //Set up Player Repository, Factory and default ILevelObservers
            ILevelObserver levelUpNotifier = new LevelupNotifier(client);
            PlayerFactory  pf = new PlayerFactory(3, 20, levelUpNotifier);
            ILevelObserver classChoiceNotifier = new ClassChoiceNotifier(client, pf, 3);

            pf.GetCurrentDefaultObservers().Add(classChoiceNotifier);
            IPlayerRepository playerRepo = LegacyPlayerRepository.getInstance(3, 20, pf,
                                                                              equipmentRepository, LegacyPlayerRepository.LEGACY_USER_COINS_FILE_PATH,
                                                                              LegacyPlayerRepository.LEGACY_USER_XP_FILE_PATH,
                                                                              LegacyPlayerRepository.LEGACY_USER_CLASS_FILE_PATH, "players.json");


            //Set up Adventure repository.
            IAdventureRepository adventureRepository = LegacyAdventureRepository
                                                       .getInstance(LegacyAdventureRepository.LEGACY_DUNGEON_BRIDGE_FILE_PATH,
                                                                    LegacyAdventureRepository.LEGACY_DUNGEON_FILE_PATH_PREFIX, equipmentRepository);

            //Set up Adventure manager who's Run() func should be used to run adventures on a daemon thread
            IAdventureManager adventureManager = new AdventureManager(client, 3);

            new Thread(() =>
            {
                Thread.CurrentThread.Name         = "Adventure Manager";
                Thread.CurrentThread.IsBackground = true;
                adventureManager.Run();
            }).Start();
            //Set up Party Pool, this keeps track of current parties.
            IPartyPool partyPool = new PartyPool(client);
            //Set up Group finder, use the current adventure managers queue. Decide party size capacity for
            // group finder.
            GroupFinderFactory gff         = new GroupFinderFactory();
            IGroupFinder       groupFinder = gff.Create(partyPool, 3, adventureRepository,
                                                        adventureManager);

            //Set up FutureTask Registry which will keep track of time based operations
            FutureTaskRegistry futureTaskRegistry = new FutureTaskRegistry();

            //Set up Custom Command Factory and Repository for the Command Manager allowing
            //for saved custom commands to be used aswell as providing capability for new
            //custom commands to be created from chat(broadcaster/mod only).
            CustomCommandFactory    ccf            = new CustomCommandFactory();
            CustomCommandRepository ccr            = new CustomCommandRepository();
            CommandManager          commandManager = new CommandManager(client, ccf, ccr);

            //Initialise all commands to be added to the command manager, seperated by
            //the source of the request, either PRVMSG or WHISPER.
            #region Initialisation of Commands

            #region General Commands

            UptimeCommand          uptime       = new UptimeCommand();
            Command <IPrivRequest> broadcasting = new BroadcastingFlagCommand(user, playerRepo,
                                                                              pf, uptime, client, futureTaskRegistry, 1, 3, 2, TimeSpan.FromMinutes(30));
            Command <IPrivRequest> time     = new TimeCommand();
            Command <IPrivRequest> playlist = new PlaylistCommand("http://open.spotify.com/user/1251282601/playlist/2j1FVSjJ4zdJiqGQgXgW3t");
            Command <IPrivRequest> opinion  = new OpinionCommand();
            Command <IPrivRequest> pun      = new PunCommand();
            Command <IPrivRequest> quote    = new QuoteCommand();
            Command <IPrivRequest> raffle   = new RaffleCommand(client, 5, futureTaskRegistry);

            #endregion

            #region RPG Commands

            #region General

            Command <IWhisperRequest> stats     = new StatsCommand(pf, playerRepo);
            Command <IWhisperRequest> inventory = new InventoryCommand(pf, playerRepo);
            Command <IWhisperRequest> item      = new ItemCommand(equipmentRepository, pf, playerRepo);
            Command <IWhisperRequest> equip     = new EquipCommand(equipmentRepository, pf, playerRepo);
            Command <IWhisperRequest> unequip   = new UnequipCommand(equipmentRepository, pf,
                                                                     playerRepo);
            Command <IWhisperRequest> shop        = new ShopCommand();
            Command <IWhisperRequest> classChoice = new ClassChoice(pf, playerRepo, 3);
            Command <IWhisperRequest> gloat       = new GloatCommand(client, pf, playerRepo);
            Command <IWhisperRequest> respec      = new RespecCommand(pf, playerRepo);
            Command <IWhisperRequest> daily       = new DailyCommand(pf, playerRepo);
            Command <IWhisperRequest> queue       = new QueueCommand(groupFinder, pf, playerRepo);
            Command <IWhisperRequest> leaveQueue  = new LeaveQueueCommand(groupFinder, pf, playerRepo);
            Command <IWhisperRequest> queueTime   = new QueueTimeCommand(groupFinder, pf, playerRepo);

            #endregion

            #region Party Commands

            Command <IWhisperRequest> createParty = new CreatePartyCommand(partyPool, pf,
                                                                           playerRepo);
            Command <IWhisperRequest> pendingInvite = new PendingInvite(partyPool, pf, playerRepo);
            Command <IWhisperRequest> leaveParty    = new LeavePartyCommand(pf, playerRepo);

            #region Party Leader Commands

            Command <IWhisperRequest> partyAdd   = new AddPartyCommand(client, pf, playerRepo);
            Command <IWhisperRequest> partyKick  = new KickPartyCommand(client, pf, playerRepo);
            Command <IWhisperRequest> partyStart = new StartPartyCommand(groupFinder, pf,
                                                                         playerRepo);
            Command <IWhisperRequest> partyPromote = new PromotePartyCommand(client, pf,
                                                                             playerRepo);

            #endregion

            #endregion

            #region Broadcaster only

            Command <IWhisperRequest> addPlayerXp    = new AddPlayerXP(pf, playerRepo);
            Command <IWhisperRequest> addPlayerCoin  = new AddPlayerCoin(pf, playerRepo);
            Command <IWhisperRequest> setPlayerLevel = new SetPlayerLevel(pf, playerRepo);

            #endregion

            #endregion

            #endregion

            commandManager.AddAll(uptime, broadcasting, time, playlist, opinion, pun, quote,
                                  raffle);
            commandManager.AddAll(stats, inventory, item, equip, unequip, shop, classChoice,
                                  gloat, respec, daily, queue, leaveQueue, queueTime, createParty, pendingInvite,
                                  leaveParty, partyAdd, partyKick, partyStart, partyPromote,
                                  addPlayerXp, addPlayerCoin, setPlayerLevel);

            //Provide Handles for events raised by client, multiple handles can be added
            //allow for parsing of PRVMSG chat for mirroring certain messages.
            #region Client Event Handling

            client.AddOperationHandler    += commandManager.Handle;
            client.CancelOperationHandler += commandManager.Handle;
            client.DeleteOperationHandler += commandManager.Handle;
            client.EditOperationHandler   += commandManager.Handle;
            client.InfoOperationHandler   += commandManager.Handle;

            client.PrivHandler += (o, e) =>
            {
                Console.WriteLine(string.Format("{0}: {1}", e.User, e.Message));
            };
            client.PrivRequestHandler += commandManager.Handle;

            client.WhisperHandler += (o, e) =>
            {
                Console.WriteLine(string.Format("Whisper {0}: {1}", e.User, e.Message));
            };
            client.WhisperRequestHandler += commandManager.Handle;



            #endregion

            //new thread for sending messages back to twitch server.
            new Thread(() =>
            {
                Thread.CurrentThread.Name         = "Twitch Client";
                Thread.CurrentThread.IsBackground = true;
                client.Run();
            }).Start();



            futureTaskRegistry.Run();
        }
Ejemplo n.º 2
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);
        }