Package net.lightstone.net.codec

Source Code of net.lightstone.net.codec.SpawnPositionCodec

package net.lightstone.net.codec;

import java.io.IOException;

import org.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.buffer.ChannelBuffers;

import net.lightstone.msg.SpawnPositionMessage;

public final class SpawnPositionCodec extends MessageCodec<SpawnPositionMessage> {

  public SpawnPositionCodec() {
    super(SpawnPositionMessage.class, 0x06);
  }

  @Override
  public SpawnPositionMessage decode(ChannelBuffer buffer) throws IOException {
    int x = buffer.readInt();
    int y = buffer.readInt();
    int z = buffer.readInt();
    return new SpawnPositionMessage(x, y, z);
  }

  @Override
  public ChannelBuffer encode(SpawnPositionMessage message) throws IOException {
    ChannelBuffer buffer = ChannelBuffers.buffer(12);
    buffer.writeInt(message.getX());
    buffer.writeInt(message.getY());
    buffer.writeInt(message.getZ());
    return buffer;
  }

}
TOP

Related Classes of net.lightstone.net.codec.SpawnPositionCodec

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.