package common.packet;

import java.io.IOException;

import common.network.IClientPlayer;
import common.network.Packet;
import common.network.PacketBuffer;

public class SPacketTimeUpdate implements Packet<IClientPlayer> {
	private long worldTime;
	private String serverInfo;

	public SPacketTimeUpdate() {
	}

	public SPacketTimeUpdate(long time, String info) {
		this.worldTime = time;
		this.serverInfo = info;
	}

	public void readPacketData(PacketBuffer buf) throws IOException {
		this.worldTime = buf.readLong();
		this.serverInfo = buf.readStringFromBuffer(512);
	}

	public void writePacketData(PacketBuffer buf) throws IOException {
		buf.writeLong(this.worldTime);
		buf.writeString(this.serverInfo);
	}

	public void processPacket(IClientPlayer handler) {
		handler.handleTimeUpdate(this);
	}

	public long getWorldTime() {
		return this.worldTime;
	}

	public String getServerinfo() {
		return this.serverInfo;
	}
}
