This page is used for testing custom styles for this project.

Custom code box:

Code (C#): ChatMessagePacket.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LibMinecraft.Server;
using LibMinecraft.Client;

namespace LibMinecraft.Model.Packets
{
    public class ChatMessagePacket : Packet
    {
        public string Message { get; set; }

        public ChatMessagePacket()
        {

        }

        public ChatMessagePacket(string Message)
        {
            this.Message = Message;
        }

        public override PacketID PacketID
        {
            get { return PacketID.ChatUpdate; }
        }

        public override int Length
        {
            get { return -1; }
        }

        public override byte[] Payload
        {
            get
            {
                return new byte[] { (byte)PacketID }.Concat(MakeString(Message)).ToArray();
            }
        }

        public override void ReadPacket(RemoteClient Client)
        {
            Message = ReadString(Client.TcpClient.GetStream());
        }

        public override void ReadPacket(MultiplayerClient Client)
        {
            throw new NotImplementedException();
        }

        public override void WritePacket(RemoteClient Client)
        {
            Message = ReadString(Client.TcpClient.GetStream());
        }

        public override void WritePacket(MultiplayerClient Client)
        {
            throw new NotImplementedException();
        }

        public override void HandlePacket(MultiplayerServer Server, RemoteClient Client)
        {
            Server._SendChat("<" + Client.PlayerEntity.Name + "> " + Message, Client);
        }

        public override void HandlePacket(MultiplayerClient Client)
        {
            throw new NotImplementedException();
        }
    }
}

Default code box:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LibMinecraft.Server;
using LibMinecraft.Client;

namespace LibMinecraft.Model.Packets
{
    public class ChatMessagePacket : Packet
    {
        public string Message { get; set; }

        public ChatMessagePacket()
        {

        }

        public ChatMessagePacket(string Message)
        {
            this.Message = Message;
        }

        public override PacketID PacketID
        {
            get { return PacketID.ChatUpdate; }
        }

        public override int Length
        {
            get { return -1; }
        }

        public override byte[] Payload
        {
            get
            {
                return new byte[] { (byte)PacketID }.Concat(MakeString(Message)).ToArray();
            }
        }

        public override void ReadPacket(RemoteClient Client)
        {
            Message = ReadString(Client.TcpClient.GetStream());
        }

        public override void ReadPacket(MultiplayerClient Client)
        {
            throw new NotImplementedException();
        }

        public override void WritePacket(RemoteClient Client)
        {
            Message = ReadString(Client.TcpClient.GetStream());
        }

        public override void WritePacket(MultiplayerClient Client)
        {
            throw new NotImplementedException();
        }

        public override void HandlePacket(MultiplayerServer Server, RemoteClient Client)
        {
            Server._SendChat("<" + Client.PlayerEntity.Name + "> " + Message, Client);
        }

        public override void HandlePacket(MultiplayerClient Client)
        {
            throw new NotImplementedException();
        }
    }
}

Last edited Feb 24, 2012 at 10:28 PM by sircmpwn, version 23

Comments

No comments yet.