package net.mc_pandacraft.java.plugin.pandacraftutils.network_api.client_test;

import java.io.PrintStream;

public abstract class AbstractRequest {
	
	private final String pass = "test";
	private String command;
	private String data;
	
	
	protected AbstractRequest(String cmd) {
		if (cmd == null || cmd.isEmpty()) throw new IllegalArgumentException("Un message doit-être défini");
		command = cmd;
	}
	
	
	protected void setData(String d) {
		if (d == null) d = "";
		data = d;
	}
	
	
	public void sendPacket(PrintStream out) {
		out.print(pass+"\n");
		out.print(command+"\n");
		out.print(data.length()+"\n");
		out.print(data);
		out.flush();
	}
}
