Handling a packet

If you'd like to handle a packet yourself, you need only to hook into PartyCraft.Server.PrePacket.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PartyCraftServer.Plugins;
using PartyCraftServer;
using LibMinecraft.Server;
using LibMinecraft.Model;

namespace TestPlugin
{
    public class TestPlugin : Plugin
    {
        public override string Name
        {
            get { return "Test plugin"; }
        }

        public override bool RequiresRestart
        {
            get { return false; }
        }

        public override void OnInstall()
        {
            PartyCraft.Server.PrePacket +=
                   new EventHandler<PacketEventArgs>(Server_PrePacket);
            base.OnInstall();
        }

        void Server_PrePacket(object sender, PacketEventArgs e)
        {
            // Prevent players from placing blocks
            if (e.PacketID == PacketID.PlayerBlockPlacement)
                e.Handled = true;
        }
    }
}

Last edited Jan 25, 2012 at 6:58 AM by sircmpwn, version 2

Comments

No comments yet.