コード例 #1
0
ファイル: AchievementManager.cs プロジェクト: drogs/Miki
        public async Task CallTransactionMadeEventAsync(IDiscordMessageChannel m, User receiver, User giver, int amount)
        {
            try
            {
                TransactionPacket p = new TransactionPacket();
                p.discordChannel = m;
                p.discordUser    = new RuntimeUser(Bot.instance.Client.GetUser(receiver.Id.FromDbLong()));

                if (giver != null)
                {
                    p.giver = giver;
                }

                p.receiver = receiver;

                p.amount = amount;

                if (OnTransaction != null)
                {
                    await OnTransaction?.Invoke(p);
                }
            }
            catch (Exception e)
            {
                await MeruUtils.ReportErrorAsync(e);

                Log.WarningAt("achievement check failed", e.ToString());
            }
        }
コード例 #2
0
ファイル: AchievementManager.cs プロジェクト: Xetera/Miki.Bot
        public async Task CallTransactionMadeEventAsync(IDiscordGuildChannel m, User receiver, User giver, int amount)
        {
            try
            {
                TransactionPacket p = new TransactionPacket();
                p.discordChannel = m;
                p.discordUser    = await m.GetUserAsync(receiver.Id.FromDbLong());

                if (giver != null)
                {
                    p.giver = giver;
                }

                p.receiver = receiver;

                p.amount = amount;

                if (OnTransaction != null)
                {
                    await OnTransaction?.Invoke(p);
                }
            }
            catch (Exception e)
            {
                Log.Warning($"Achievement check failed: {e.ToString()}");
            }
        }
コード例 #3
0
        public static void ReadTransaction(Client client, PacketReader reader)
        {
            TransactionPacket tp = new TransactionPacket();

            tp.Read(reader);

            if (!reader.Failed)
            {
                Client.HandleTransactionPacket(client, tp);
            }
        }
コード例 #4
0
        public AchievementManager(MikiApp bot)
        {
            this.bot = bot;

            AccountManager.Instance.OnLocalLevelUp += async(u, c, l) =>
            {
                using (var db = new MikiContext())
                {
                    if (await provider.IsEnabled(MikiApp.Instance.GetService <ICacheClient>(), db, c.Id))
                    {
                        LevelPacket p = new LevelPacket()
                        {
                            discordUser    = await(c as IDiscordGuildChannel).GetUserAsync(u.Id),
                            discordChannel = c,
                            level          = l,
                        };
                        await OnLevelGained?.Invoke(p);
                    }
                }
            };

            AccountManager.Instance.OnTransactionMade += async(msg, u1, u2, amount) =>
            {
                using (var db = new MikiContext())
                {
                    if (await provider.IsEnabled(MikiApp.Instance.GetService <ICacheClient>(), db, msg.ChannelId))
                    {
                        TransactionPacket p = new TransactionPacket()
                        {
                            discordUser    = msg.Author,
                            discordChannel = await msg.GetChannelAsync(),
                            giver          = u1,
                            receiver       = u2,
                            amount         = amount
                        };

                        await OnTransaction?.Invoke(p);
                    }
                }
            };

            bot.GetService <EventSystem>().GetCommandHandler <SimpleCommandHandler>().OnMessageProcessed += async(e, m, t) =>
            {
                CommandPacket p = new CommandPacket()
                {
                    discordUser    = m.Author,
                    discordChannel = await m.GetChannelAsync(),
                    message        = m,
                    command        = e,
                    success        = true
                };
                await OnCommandUsed?.Invoke(p);
            };
        }
コード例 #5
0
ファイル: AchievementManager.cs プロジェクト: SnipeFrost/Miki
        public AchievementManager(IBot bot)
        {
            this.bot = bot;

            AccountManager.Instance.OnGlobalLevelUp += async(u, c, l) =>
            {
                if (await provider.IsEnabled(c.Id))
                {
                    LevelPacket p = new LevelPacket()
                    {
                        discordUser    = await c.Guild.GetUserAsync(u.Id),
                        discordChannel = c,
                        level          = l,
                    };
                    await OnLevelGained?.Invoke(p);
                }
            };

            AccountManager.Instance.OnTransactionMade += async(msg, u1, u2, amount) =>
            {
                if (await provider.IsEnabled(msg.Channel.Id))
                {
                    TransactionPacket p = new TransactionPacket()
                    {
                        discordUser    = msg.Author,
                        discordChannel = msg.Channel,
                        giver          = u1,
                        receiver       = u2,
                        amount         = amount
                    };

                    await OnTransaction?.Invoke(p);
                }
            };

            EventSystem.Instance.AddCommandDoneEvent(x =>
            {
                x.Name         = "--achievement-manager-command";
                x.processEvent = async(m, e, s, t) =>
                {
                    CommandPacket p = new CommandPacket()
                    {
                        discordUser    = m.Author,
                        discordChannel = m.Channel,
                        message        = m,
                        command        = e,
                        success        = s
                    };
                    await OnCommandUsed?.Invoke(p);
                };
            });
        }
コード例 #6
0
ファイル: AchievementManager.cs プロジェクト: wingertge/Miki
        public AchievementManager(Bot bot)
        {
            this.bot = bot;

            AccountManager.Instance.OnGlobalLevelUp += async(u, c, l) =>
            {
                if (await provider.IsEnabled(Global.RedisClient, c.Id))
                {
                    LevelPacket p = new LevelPacket()
                    {
                        discordUser    = await(c as IDiscordGuildChannel).GetUserAsync(u.Id),
                        discordChannel = c,
                        level          = l,
                    };
                    await OnLevelGained?.Invoke(p);
                }
            };

            AccountManager.Instance.OnTransactionMade += async(msg, u1, u2, amount) =>
            {
                if (await provider.IsEnabled(Global.RedisClient, msg.ChannelId))
                {
                    TransactionPacket p = new TransactionPacket()
                    {
                        discordUser    = msg.Author,
                        discordChannel = await msg.GetChannelAsync(),
                        giver          = u1,
                        receiver       = u2,
                        amount         = amount
                    };

                    await OnTransaction?.Invoke(p);
                }
            };

            bot.GetAttachedObject <EventSystem>().GetCommandHandler <SimpleCommandHandler>().OnMessageProcessed += async(e, m, t) =>
            {
                CommandPacket p = new CommandPacket()
                {
                    discordUser    = m.Author,
                    discordChannel = await m.GetChannelAsync(),
                    message        = m,
                    command        = e,
                    success        = true
                };
                await OnCommandUsed?.Invoke(p);
            };
        }
コード例 #7
0
ファイル: AchievementManager.cs プロジェクト: mugSans/Miki
        public AchievementManager(Bot bot)
        {
            this.bot = bot;

            AccountManager.Instance.OnGlobalLevelUp += async(u, c, l) =>
            {
                if (await provider.IsEnabled(c.Id))
                {
                    LevelPacket p = new LevelPacket()
                    {
                        discordUser    = await(c as IGuildChannel).GetUserAsync(u.Id),
                        discordChannel = c,
                        level          = l,
                    };
                    await OnLevelGained?.Invoke(p);
                }
            };

            AccountManager.Instance.OnTransactionMade += async(msg, u1, u2, amount) =>
            {
                if (await provider.IsEnabled(msg.Channel.Id))
                {
                    TransactionPacket p = new TransactionPacket()
                    {
                        discordUser    = msg.Author,
                        discordChannel = msg.Channel,
                        giver          = u1,
                        receiver       = u2,
                        amount         = amount
                    };

                    await OnTransaction?.Invoke(p);
                }
            };

            bot.GetAttachedObject <EventSystem>().OnCommandDone += async(ex, e, m, t) =>
            {
                CommandPacket p = new CommandPacket()
                {
                    discordUser    = m.Author,
                    discordChannel = m.Channel,
                    message        = m,
                    command        = e,
                    success        = ex == null
                };
                await OnCommandUsed?.Invoke(p);
            };
        }
コード例 #8
0
        private AchievementManager(Bot bot)
        {
            this.bot = bot;

            AccountManager.Instance.OnGlobalLevelUp += async(u, c, l) =>
            {
                LevelPacket p = new LevelPacket()
                {
                    discordUser    = await c.Guild.GetUserAsync(u.Id.FromDbLong()),
                    discordChannel = c,
                    account        = u,
                    level          = l,
                };
                await OnLevelGained?.Invoke(p);
            };
            AccountManager.Instance.OnTransactionMade += async(msg, u1, u2, amount) =>
            {
                TransactionPacket p = new TransactionPacket()
                {
                    discordUser    = msg.Author,
                    discordChannel = msg.Channel,
                    giver          = u1,
                    receiver       = u2,
                    amount         = amount
                };

                await OnTransaction?.Invoke(p);
            };

            bot.Client.MessageReceived += async(e) =>
            {
                if (OnMessageReceived == null)
                {
                    return;
                }

                MessageEventPacket p = new MessageEventPacket()
                {
                    message        = new RuntimeMessage(e),
                    discordUser    = new RuntimeUser(e.Author),
                    discordChannel = new RuntimeMessageChannel(e.Channel)
                };
                await OnMessageReceived?.Invoke(p);
            };
            bot.Client.UserUpdated += async(ub, ua) =>
            {
                UserUpdatePacket p = new UserUpdatePacket()
                {
                    discordUser = new RuntimeUser(ub),
                    userNew     = new RuntimeUser(ua)
                };
                await OnUserUpdate?.Invoke(p);
            };
            bot.Events.AddCommandDoneEvent(x =>
            {
                x.Name         = "--achievement-manager-command";
                x.processEvent = async(m, e, s) =>
                {
                    CommandPacket p = new CommandPacket()
                    {
                        discordUser    = m.Author,
                        discordChannel = m.Channel,
                        message        = m,
                        command        = e,
                        success        = s
                    };
                    await OnCommandUsed?.Invoke(p);
                };
            });
        }
コード例 #9
0
        /// <summary>
        /// Gets a packet from the server and returns it.
        /// </summary>
        /// <returns>The received packet.</returns>
        public Packet GetPacket()
        {
            var packetID = (byte)_stream.ReadByte();

            //_log.Debug("Got packet ID: " + packetID); // Spammy debug message
            if (!Enum.IsDefined(typeof(PacketType), (int)packetID))
            {
                return(null);
            }
            var    type = (PacketType)packetID;
            Packet pack = null;

            switch (type)
            {
            case PacketType.KeepAlive:
                pack = new KeepAlivePacket(_tools.ReadInt32());
                break;

            case PacketType.LoginRequest:
                pack = new LoginRequestPacketSC
                {
                    EntityID    = _tools.ReadInt32(),
                    NotUsed     = _tools.ReadString(),
                    LevelType   = _tools.ReadString(),
                    Gamemode    = _tools.ReadInt32(),
                    Dimension   = _tools.ReadInt32(),
                    Difficulty  = _tools.ReadSignedByte(),
                    WorldHeight = _tools.ReadByte(),                             // Not Used
                    MaxPlayers  = _tools.ReadByte()
                };
                break;

            case PacketType.Handshake:
                pack = new HandshakePacketSC(_tools.ReadString());
                break;

            case PacketType.ChatMessage:
                pack = new ChatMessagePacket(_tools.ReadString());
                break;

            case PacketType.TimeUpdate:
                pack = new TimeUpdatePacket(_tools.ReadInt32());
                break;

            case PacketType.EntityEquipment:
                pack = new EntityEquipmentPacket(_tools.ReadInt32(), _tools.ReadInt16(), _tools.ReadInt16(), _tools.ReadInt16());
                break;

            case PacketType.SpawnPosition:
                pack = new SpawnPositionPacket(_tools.ReadInt32(), _tools.ReadInt32(), _tools.ReadInt32());
                break;

            case PacketType.UseEntity:
                pack = new UseEntityPacket(_tools.ReadInt32(), _tools.ReadInt32(), _tools.ReadBoolean());
                break;

            case PacketType.UpdateHealth:
                pack = new UpdateHealthPacket(_tools.ReadInt16(), _tools.ReadInt16(), _tools.ReadSingle());
                break;

            case PacketType.Respawn:
                pack = new RespawnPacket(_tools.ReadInt32(), _tools.ReadSignedByte(), _tools.ReadSignedByte(),
                                         _tools.ReadInt16(), _tools.ReadString());
                break;

            case PacketType.Player:
                pack = new PlayerPacket(_tools.ReadBoolean());
                break;

            case PacketType.PlayerPosition:
                pack = new PlayerPositionPacket(_tools.ReadDouble(), _tools.ReadDouble(), _tools.ReadDouble(), _tools.ReadDouble(),
                                                _tools.ReadBoolean());
                break;

            case PacketType.PlayerLook:
                pack = new PlayerLookPacket(_tools.ReadSingle(), _tools.ReadSingle(), _tools.ReadBoolean());
                break;

            case PacketType.PlayerPositionAndLook:
                pack = new PlayerPositionAndLookPacket(_tools.ReadDouble(), _tools.ReadDouble(), _tools.ReadDouble(),
                                                       _tools.ReadDouble(), _tools.ReadSingle(), _tools.ReadSingle(),
                                                       _tools.ReadBoolean());
                break;

            case PacketType.PlayerDigging:
                pack = new PlayerDiggingPacket(_tools.ReadSignedByte(), _tools.ReadInt32(), _tools.ReadSignedByte(),
                                               _tools.ReadInt32(), _tools.ReadSignedByte());
                break;

            case PacketType.PlayerBlockPlacement:
                pack = new PlayerBlockPlacementPacket(_tools.ReadInt32(), _tools.ReadSignedByte(), _tools.ReadInt32(),
                                                      _tools.ReadSignedByte(), _tools.ReadSlotData());
                break;

            case PacketType.UseBed:
                pack = new UseBedPacket(_tools.ReadInt32(), _tools.ReadSignedByte(), _tools.ReadInt32(), _tools.ReadSignedByte(),
                                        _tools.ReadInt32());
                break;

            case PacketType.Animation:
                pack = new AnimationPacket(_tools.ReadInt32(), _tools.ReadSignedByte());
                break;

            case PacketType.NamedEntitySpawn:
                pack = new NamedEntitySpawnPacket(_tools.ReadInt32(), _tools.ReadString(), _tools.ReadInt32(), _tools.ReadInt32(),
                                                  _tools.ReadInt32(), _tools.ReadSignedByte(), _tools.ReadSignedByte(),
                                                  _tools.ReadInt16());
                break;

            case PacketType.PickupSpawn:
                pack = new PickupSpawnPacket(_tools.ReadInt32(), _tools.ReadInt16(), _tools.ReadSignedByte(), _tools.ReadInt16(),
                                             _tools.ReadInt32(), _tools.ReadInt32(), _tools.ReadInt32(), _tools.ReadSignedByte(),
                                             _tools.ReadSignedByte(), _tools.ReadSignedByte());
                break;

            case PacketType.CollectItem:
                pack = new CollectItemPacket(_tools.ReadInt32(), _tools.ReadInt32());
                break;

            case PacketType.AddObjectVehicle:
                pack = new AddObjectVehiclePacket(_tools.ReadInt32(), _tools.ReadSignedByte(), _tools.ReadInt32(),
                                                  _tools.ReadInt32(), _tools.ReadInt32());
                var ftEid = _tools.ReadInt32(); ((AddObjectVehiclePacket)pack).FireballThrowerID = ftEid;
                if (ftEid > 0)
                {
                    var aovpPack = (AddObjectVehiclePacket)pack;
                    aovpPack.SpeedX = _tools.ReadInt16();
                    aovpPack.SpeedY = _tools.ReadInt16();
                    aovpPack.SpeedZ = _tools.ReadInt16();
                    pack            = aovpPack;
                }
                break;

            case PacketType.HoldingChange:
                pack = new HoldingChangePacket(_tools.ReadInt16());
                break;

            case PacketType.MobSpawn:
                pack = new MobSpawnPacket(_tools.ReadInt32(), _tools.ReadSignedByte(), _tools.ReadInt32(), _tools.ReadInt32(),
                                          _tools.ReadInt32(), _tools.ReadSignedByte(), _tools.ReadSignedByte(),
                                          _tools.ReadSignedByte(), _tools.ReadEntityMetadata());
                break;

            case PacketType.EntityPainting:
                pack = new EntityPaintingPacket(_tools.ReadInt32(), _tools.ReadString(), _tools.ReadInt32(),
                                                _tools.ReadInt32(), _tools.ReadInt32(), _tools.ReadInt32());
                break;

            case PacketType.ExperienceOrb:
                pack = new ExperienceOrbPacket(_tools.ReadInt32(), _tools.ReadInt32(), _tools.ReadInt32(),
                                               _tools.ReadInt32(), _tools.ReadInt16());
                break;

            case PacketType.EntityVelocity:
                pack = new EntityVelocityPacket(_tools.ReadInt32(), _tools.ReadInt16(), _tools.ReadInt16(), _tools.ReadInt16());
                break;

            case PacketType.DestroyEntity:
                pack = new DestroyEntityPacket(_tools.ReadInt32());
                break;

            case PacketType.Entity:
                pack = new EntityPacket(_tools.ReadInt32());
                break;

            case PacketType.EntityRelativeMove:
                pack = new EntityRelativeMovePacket(_tools.ReadInt32(), _tools.ReadSignedByte(), _tools.ReadSignedByte(),
                                                    _tools.ReadSignedByte());
                break;

            case PacketType.EntityLook:
                pack = new EntityLookPacket(_tools.ReadInt32(), _tools.ReadSignedByte(), _tools.ReadSignedByte());
                break;

            case PacketType.EntityLookAndRelativeMove:
                pack = new EntityLookAndRelativeMovePacket(_tools.ReadInt32(), _tools.ReadSignedByte(), _tools.ReadSignedByte(),
                                                           _tools.ReadSignedByte(), _tools.ReadSignedByte(),
                                                           _tools.ReadSignedByte());
                break;

            case PacketType.EntityTeleport:
                pack = new EntityTeleportPacket(_tools.ReadInt32(), _tools.ReadInt32(), _tools.ReadInt32(), _tools.ReadInt32(),
                                                _tools.ReadSignedByte(), _tools.ReadSignedByte());
                break;

            case PacketType.EntityHeadLook:
                pack = new EntityHeadLookPacket(_tools.ReadInt32(), _tools.ReadSignedByte());
                break;

            case PacketType.EntityStatus:
                pack = new EntityStatusPacket(_tools.ReadInt32(), _tools.ReadSignedByte());
                break;

            case PacketType.AttachEntity:
                pack = new AttachEntityPacket(_tools.ReadInt32(), _tools.ReadInt32());
                break;

            case PacketType.EntityMetadata:
                var entityMetadataPacket = new EntityMetadataPacket(_tools.ReadInt32());

                var metaData = new List <sbyte>();
                var b        = true;
                while (b)
                {
                    var value = _tools.ReadSignedByte();
                    if (value == 127)
                    {
                        b = false;
                    }
                    metaData.Add(value);
                }
                entityMetadataPacket.Metadata = metaData.ToArray();

                break;

            case PacketType.EntityEffect:
                pack = new EntityEffectPacket(_tools.ReadInt32(), _tools.ReadSignedByte(), _tools.ReadSignedByte(),
                                              _tools.ReadInt16());
                break;

            case PacketType.RemoveEntityEffect:
                pack = new RemoveEntityEffectPacket(_tools.ReadInt32(), _tools.ReadSignedByte());
                break;

            case PacketType.Experience:
                pack = new ExperiencePacket(_tools.ReadSingle(), _tools.ReadInt16(), _tools.ReadInt16());
                break;

            case PacketType.PreChunk:
                pack = new PreChunkPacket(_tools.ReadInt32(), _tools.ReadInt32(), _tools.ReadBoolean());
                break;

            case PacketType.MapChunk:
                var mapChunkPacket = new MapChunkPacket(_tools.ReadInt32(), _tools.ReadInt16(), _tools.ReadInt32(),
                                                        _tools.ReadSignedByte(), _tools.ReadSignedByte(), _tools.ReadSignedByte());

                mapChunkPacket.CompressedSize = _tools.ReadInt32();
                mapChunkPacket.CompressedData = _tools.ReadSignedBytes(mapChunkPacket.CompressedSize);

                pack = mapChunkPacket;
                break;

            case PacketType.MultiBlockChange:
                var multiBlockChangePacket = new MultiBlockChangePacket(_tools.ReadInt32(), _tools.ReadInt32());

                var arraySize = _tools.ReadInt16();
                multiBlockChangePacket.ArraySize = arraySize;

                var coordinates = new short[arraySize, 3];
                for (short i = 0; i < arraySize; i++)
                {
                    coordinates[i, 0] = _tools.ReadInt16();
                    coordinates[i, 1] = _tools.ReadInt16();
                    coordinates[i, 2] = _tools.ReadInt16();
                }
                multiBlockChangePacket.Coordinates = coordinates;

                var types = new sbyte[arraySize];
                for (short i = 0; i < arraySize; i++)
                {
                    types[i] = _tools.ReadSignedByte();
                }
                multiBlockChangePacket.Types = types;

                var metadata = new sbyte[arraySize];
                for (short i = 0; i < arraySize; i++)
                {
                    metadata[i] = _tools.ReadSignedByte();
                }
                multiBlockChangePacket.Metadata = metadata;

                pack = multiBlockChangePacket;
                break;

            case PacketType.BlockChange:
                pack = new BlockChangePacket(_tools.ReadInt32(), _tools.ReadSignedByte(), _tools.ReadInt32(),
                                             _tools.ReadSignedByte(), _tools.ReadSignedByte());
                break;

            case PacketType.BlockAction:
                pack = new BlockActionPacket(_tools.ReadInt32(), _tools.ReadInt16(), _tools.ReadInt32(), _tools.ReadSignedByte(),
                                             _tools.ReadSignedByte());
                break;

            case PacketType.Explosion:
                var explosionPacket = new ExplosionPacket(_tools.ReadDouble(), _tools.ReadDouble(), _tools.ReadDouble(), _tools.ReadSingle());

                var recordCount = _tools.ReadInt32();
                explosionPacket.Count = recordCount;

                var records = new sbyte[recordCount, 3];
                for (var i = 0; i < recordCount; i++)
                {
                    records[i, 0] = _tools.ReadSignedByte();
                    records[i, 1] = _tools.ReadSignedByte();
                    records[i, 2] = _tools.ReadSignedByte();
                }
                explosionPacket.Records = records;

                pack = explosionPacket;
                break;

            case PacketType.SoundParticleEffect:
                pack = new SoundParticleEffectPacket(_tools.ReadInt32(), _tools.ReadInt32(), _tools.ReadSignedByte(),
                                                     _tools.ReadInt32(), _tools.ReadInt32());
                break;

            case PacketType.NewInvalidState:
                pack = new NewInvalidStatePacket(_tools.ReadSignedByte(), _tools.ReadSignedByte());
                break;

            case PacketType.Thunderbolt:
                pack = new ThunderboltPacket(_tools.ReadInt32(), _tools.ReadBoolean(), _tools.ReadInt32(), _tools.ReadInt32(),
                                             _tools.ReadInt32());
                break;

            case PacketType.OpenWindow:
                pack = new OpenWindowPacket(_tools.ReadSignedByte(), _tools.ReadSignedByte(), _tools.ReadString(),
                                            _tools.ReadSignedByte());
                break;

            case PacketType.CloseWindow:
                pack = new CloseWindowPacket(_tools.ReadSignedByte());
                break;

            case PacketType.SetSlot:
                pack = new SetSlotPacket(_tools.ReadSignedByte(), _tools.ReadInt16(), _tools.ReadSlotData());
                break;

            case PacketType.WindowItems:
                var windowItemsPacket = new WindowItemsPacket(_tools.ReadSignedByte());

                var count = _tools.ReadInt16();
                windowItemsPacket.Count = count;

                var slotData = new SlotData[count];
                for (short i = 0; i < count; i++)
                {
                    slotData[i] = _tools.ReadSlotData();
                }
                windowItemsPacket.SlotData = slotData;

                pack = windowItemsPacket;
                break;

            case PacketType.UpdateWindowProperty:
                pack = new UpdateWindowPropertyPacket(_tools.ReadSignedByte(), _tools.ReadInt16(), _tools.ReadInt16());
                break;

            case PacketType.Transaction:
                pack = new TransactionPacket(_tools.ReadSignedByte(), _tools.ReadInt16(), _tools.ReadBoolean());
                break;

            case PacketType.CreativeInventoryAction:
                pack = new CreativeInventoryActionPacket(_tools.ReadInt16(), _tools.ReadSlotData());
                break;

            case PacketType.UpdateSign:
                pack = new UpdateSignPacket(_tools.ReadInt32(), _tools.ReadInt16(), _tools.ReadInt32(), _tools.ReadString(),
                                            _tools.ReadString(), _tools.ReadString(), _tools.ReadString());
                break;

            case PacketType.ItemData:
                pack = new ItemDataPacket(_tools.ReadInt16(), _tools.ReadInt16());

                byte len = _tools.ReadByte();
                ((ItemDataPacket)pack).Length = len;
                ((ItemDataPacket)pack).Text   = _tools.ReadSignedBytes(len);

                break;

            case PacketType.IncrementStatistic:
                pack = new IncrementStatisticPacket(_tools.ReadInt32(), _tools.ReadSignedByte());
                break;

            case PacketType.PlayerListItem:
                pack = new PlayerListItemPacket(_tools.ReadString(), _tools.ReadBoolean(), _tools.ReadInt16());
                break;

            case PacketType.PluginMessage:
                pack = new PluginMessagePacket(_tools.ReadString());
                var length = _tools.ReadInt16(); ((PluginMessagePacket)pack).Length = length;
                ((PluginMessagePacket)pack).Data = _tools.ReadSignedBytes(length);
                break;

            case PacketType.DisconnectKick:
                pack = new DisconnectKickPacket(_tools.ReadString());
                break;
            }

            return(pack);
        }
コード例 #10
0
 public static void HandleTransactionPacket(Client client, TransactionPacket packet)
 {
     //todo-something?
 }