// Path: Journey of Legends/aginsun/journey/server/api/QuestHandler.java
// public class QuestHandler
// {
// 	private HashMap<String, NBTTagCompound> questList = new HashMap<String, NBTTagCompound>();
// 	private HashMap<String, HashMap<String, Integer>> questProgress = new HashMap<String, HashMap<String, Integer>>();
// 	private static QuestHandler instance = new QuestHandler();
// 	
// 	public QuestHandler(){}
// 	
// 	public static QuestHandler instance()
// 	{
// 		return instance;
// 	}
// 	
// 	public int getQuestStatus(EntityPlayer player, String QuestName)
// 	{
// 		NBTTagCompound nbt = getQuestPlayer(player);
// 		return nbt.getInteger(QuestName);
// 	}
// 	
// 	public void setQuestStatus(EntityPlayer player, String questName, int questStatus)
// 	{
// 		NBTTagCompound nbt = getQuestPlayer(player);
// 		nbt.setInteger(questName, questStatus);
// 		PacketDispatcher.sendPacketToPlayer(PacketType.populatePacket(new PacketQuestDataClient(player.username, questName, questStatus)), (Player)player);
// 		setQuestPlayer(player, nbt);
// 	}
// 	
// 	public void setQuestStarted(EntityPlayer player, String quest)
// 	{
// 		NBTTagCompound nbt = getQuestPlayer(player);
// 		nbt.setInteger(quest, 1);
// 		PacketDispatcher.sendPacketToPlayer(PacketType.populatePacket(new PacketQuestDataClient(player.username, quest, 1)), (Player)player);
// 		setQuestPlayer(player, nbt);
// 	}
// 	
// 	public void setQuestFinished(EntityPlayer player, String quest)
// 	{
// 		NBTTagCompound nbt = getQuestPlayer(player);
// 		nbt.setInteger(quest, 2);
// 		PacketDispatcher.sendPacketToPlayer(PacketType.populatePacket(new PacketQuestDataClient(player.username, quest, 2)), (Player)player);
// 		setQuestPlayer(player, nbt);
// 	}
// 	
// 	public void questFinishedReward(EntityPlayer player, String quest)
// 	{
// 		NBTTagCompound nbt = getQuestPlayer(player);
// 		nbt.setInteger(quest, 3);
// 		PacketDispatcher.sendPacketToPlayer(PacketType.populatePacket(new PacketQuestDataClient(player.username, quest, 3)), (Player)player);
// 		setQuestPlayer(player, nbt);
// 	}
// 	
// 	public void setQuestPlayer(EntityPlayer player, NBTTagCompound nbt)
// 	{
// 		System.out.println("Added player: " + player.username + " to the QuestMap");
// 		getMap().put(player.username, nbt);
// 	}
// 	
// 	public boolean isQuestActive(EntityPlayer player, String questName)
// 	{
// 		if(getQuestStatus(player, questName) != 3 && getQuestStatus(player, questName) != 0)
// 			return true;
// 		return false;
// 	}
// 	
// 	public NBTTagCompound getQuestPlayer(EntityPlayer player)
// 	{	
// 		if(getMap().containsKey(player.username))
// 		{
// 			System.out.println("Does have the player in there");
// 			return getMap().get(player.username);
// 		}
// 		return null;
// 	}
// 	
// 	public HashMap<String, NBTTagCompound> getMap()
// 	{
// 		return questList;
// 	}
// 	
// 	@SideOnly(Side.CLIENT)
// 	public void setQuestStatusClient(EntityPlayer player, String questName, int questStatus) 
// 	{
// 		HashMap<String, Integer> map = questProgress.get(player.username);
// 		if(map == null)
// 			map = new HashMap<String, Integer>();
// 		map.put(questName, questStatus);
// 		questProgress.put(player.username, map);
// 	}
// 	
// 	@SideOnly(Side.CLIENT)
// 	public int getQuestStatusClient(EntityPlayer player, String questName)
// 	{
// 		HashMap<String, Integer> map;
// 		if(questProgress.containsKey(player.username))
// 		{
// 			map = questProgress.get(player.username);
// 		}
// 		else
// 			map = new HashMap<String, Integer>();
// 		
// 		if(map.containsKey(questName))
// 			return map.get(questName);
// 		return 0;
// 	}
// 	
// 	@SideOnly(Side.CLIENT)
// 	public boolean isQuestActiveClient(EntityPlayer player, String questName)
// 	{
// 		if(getQuestStatusClient(player, questName) != 3 && getQuestStatusClient(player, questName) != 0)
// 			return true;
// 		return false;
// 	}
// }


import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.network.INetworkManager;
import aginsun.journey.server.api.QuestHandler;
import cpw.mods.fml.common.network.Player;
	{
		super(PacketType.QUESTDATA, false);
	}
	
	public PacketQuestData(String username, String questName, int questStatus)
	{
		super(PacketType.QUESTDATA, false);
		this.username = username;
		this.questName = questName;
		this.questStatus = questStatus;
	}
	
	public void readData(DataInputStream data) throws IOException
	{
		this.username = data.readUTF();
		this.questName = data.readUTF();
		this.questStatus = data.readInt();
	}
	
	public void writeData(DataOutputStream dos) throws IOException
	{
		dos.writeUTF(username);
		dos.writeUTF(questName);
		dos.writeInt(questStatus);
	}
	
	public void execute(INetworkManager network, Player player)
	{
		EntityPlayer thePlayer = (EntityPlayer)player;
		
// Path: Journey of Legends/aginsun/journey/server/api/QuestHandler.java
// public class QuestHandler
// {
// 	private HashMap<String, NBTTagCompound> questList = new HashMap<String, NBTTagCompound>();
// 	private HashMap<String, HashMap<String, Integer>> questProgress = new HashMap<String, HashMap<String, Integer>>();
// 	private static QuestHandler instance = new QuestHandler();
// 	
// 	public QuestHandler(){}
// 	
// 	public static QuestHandler instance()
// 	{
// 		return instance;
// 	}
// 	
// 	public int getQuestStatus(EntityPlayer player, String QuestName)
// 	{
// 		NBTTagCompound nbt = getQuestPlayer(player);
// 		return nbt.getInteger(QuestName);
// 	}
// 	
// 	public void setQuestStatus(EntityPlayer player, String questName, int questStatus)
// 	{
// 		NBTTagCompound nbt = getQuestPlayer(player);
// 		nbt.setInteger(questName, questStatus);
// 		PacketDispatcher.sendPacketToPlayer(PacketType.populatePacket(new PacketQuestDataClient(player.username, questName, questStatus)), (Player)player);
// 		setQuestPlayer(player, nbt);
// 	}
// 	
// 	public void setQuestStarted(EntityPlayer player, String quest)
// 	{
// 		NBTTagCompound nbt = getQuestPlayer(player);
// 		nbt.setInteger(quest, 1);
// 		PacketDispatcher.sendPacketToPlayer(PacketType.populatePacket(new PacketQuestDataClient(player.username, quest, 1)), (Player)player);
// 		setQuestPlayer(player, nbt);
// 	}
// 	
// 	public void setQuestFinished(EntityPlayer player, String quest)
// 	{
// 		NBTTagCompound nbt = getQuestPlayer(player);
// 		nbt.setInteger(quest, 2);
// 		PacketDispatcher.sendPacketToPlayer(PacketType.populatePacket(new PacketQuestDataClient(player.username, quest, 2)), (Player)player);
// 		setQuestPlayer(player, nbt);
// 	}
// 	
// 	public void questFinishedReward(EntityPlayer player, String quest)
// 	{
// 		NBTTagCompound nbt = getQuestPlayer(player);
// 		nbt.setInteger(quest, 3);
// 		PacketDispatcher.sendPacketToPlayer(PacketType.populatePacket(new PacketQuestDataClient(player.username, quest, 3)), (Player)player);
// 		setQuestPlayer(player, nbt);
// 	}
// 	
// 	public void setQuestPlayer(EntityPlayer player, NBTTagCompound nbt)
// 	{
// 		System.out.println("Added player: " + player.username + " to the QuestMap");
// 		getMap().put(player.username, nbt);
// 	}
// 	
// 	public boolean isQuestActive(EntityPlayer player, String questName)
// 	{
// 		if(getQuestStatus(player, questName) != 3 && getQuestStatus(player, questName) != 0)
// 			return true;
// 		return false;
// 	}
// 	
// 	public NBTTagCompound getQuestPlayer(EntityPlayer player)
// 	{	
// 		if(getMap().containsKey(player.username))
// 		{
// 			System.out.println("Does have the player in there");
// 			return getMap().get(player.username);
// 		}
// 		return null;
// 	}
// 	
// 	public HashMap<String, NBTTagCompound> getMap()
// 	{
// 		return questList;
// 	}
// 	
// 	@SideOnly(Side.CLIENT)
// 	public void setQuestStatusClient(EntityPlayer player, String questName, int questStatus) 
// 	{
// 		HashMap<String, Integer> map = questProgress.get(player.username);
// 		if(map == null)
// 			map = new HashMap<String, Integer>();
// 		map.put(questName, questStatus);
// 		questProgress.put(player.username, map);
// 	}
// 	
// 	@SideOnly(Side.CLIENT)
// 	public int getQuestStatusClient(EntityPlayer player, String questName)
// 	{
// 		HashMap<String, Integer> map;
// 		if(questProgress.containsKey(player.username))
// 		{
// 			map = questProgress.get(player.username);
// 		}
// 		else
// 			map = new HashMap<String, Integer>();
// 		
// 		if(map.containsKey(questName))
// 			return map.get(questName);
// 		return 0;
// 	}
// 	
// 	@SideOnly(Side.CLIENT)
// 	public boolean isQuestActiveClient(EntityPlayer player, String questName)
// 	{
// 		if(getQuestStatusClient(player, questName) != 3 && getQuestStatusClient(player, questName) != 0)
// 			return true;
// 		return false;
// 	}
// }


// Path: Journey of Legends/aginsun/journey/universal/packets/PacketQuestData.java
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.network.INetworkManager;
import aginsun.journey.server.api.QuestHandler;
import cpw.mods.fml.common.network.Player;

	{
		super(PacketType.QUESTDATA, false);
	}
	
	public PacketQuestData(String username, String questName, int questStatus)
	{
		super(PacketType.QUESTDATA, false);
		this.username = username;
		this.questName = questName;
		this.questStatus = questStatus;
	}
	
	public void readData(DataInputStream data) throws IOException
	{
		this.username = data.readUTF();
		this.questName = data.readUTF();
		this.questStatus = data.readInt();
	}
	
	public void writeData(DataOutputStream dos) throws IOException
	{
		dos.writeUTF(username);
		dos.writeUTF(questName);
		dos.writeInt(questStatus);
	}
	
	public void execute(INetworkManager network, Player player)
	{
		EntityPlayer thePlayer = (EntityPlayer)player;
		
		QuestHandler.instance().setQuestStatus(thePlayer, questName, questStatus);