2014-06-22 16:50:31 +02:00
|
|
|
package com.pahimar.ee3.handler;
|
|
|
|
|
2014-09-04 17:30:22 +02:00
|
|
|
import com.pahimar.ee3.exchange.EnergyValueRegistry;
|
|
|
|
import com.pahimar.ee3.network.PacketHandler;
|
2014-09-11 22:13:39 +02:00
|
|
|
import com.pahimar.ee3.network.message.MessageSyncEnergyValues;
|
2014-06-22 16:50:31 +02:00
|
|
|
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
2014-09-04 17:30:22 +02:00
|
|
|
import net.minecraft.entity.player.EntityPlayerMP;
|
2014-06-22 16:50:31 +02:00
|
|
|
import net.minecraftforge.event.entity.player.PlayerEvent;
|
|
|
|
|
2015-01-11 21:36:41 +01:00
|
|
|
import java.io.File;
|
2014-06-22 20:03:30 +02:00
|
|
|
|
2014-06-22 16:50:31 +02:00
|
|
|
public class PlayerEventHandler
|
|
|
|
{
|
2015-01-27 05:17:32 +01:00
|
|
|
public static File playerDataDirectory;
|
|
|
|
public static File knowledgeDirectory;
|
|
|
|
|
2014-06-22 16:50:31 +02:00
|
|
|
@SubscribeEvent
|
2014-06-26 21:19:59 +02:00
|
|
|
public void onPlayerLoadFromFileEvent(PlayerEvent.LoadFromFile event)
|
2014-06-22 16:50:31 +02:00
|
|
|
{
|
2014-06-26 21:19:59 +02:00
|
|
|
if (!event.entityPlayer.worldObj.isRemote)
|
2014-06-22 20:03:30 +02:00
|
|
|
{
|
2015-01-11 21:36:41 +01:00
|
|
|
// If player knowledge data doesn't exist, initialize a file for the player
|
2015-01-27 05:17:32 +01:00
|
|
|
// File playerTransmutationKnowledgeFile = new File(TransmutationKnowledgeHandler.transmutationKnowledgeDirectory, event.entityPlayer.getUniqueID() + TransmutationKnowledgeHandler.KNOWLEDGE_FILE_EXTENSION);
|
|
|
|
// if (!playerTransmutationKnowledgeFile.exists())
|
|
|
|
// {
|
|
|
|
// TransmutationKnowledgeHandler.savePlayerKnowledge(event.entityPlayer);
|
|
|
|
// }
|
2014-06-22 20:03:30 +02:00
|
|
|
}
|
2014-06-22 16:50:31 +02:00
|
|
|
}
|
2014-09-04 17:30:22 +02:00
|
|
|
|
|
|
|
@SubscribeEvent
|
2014-10-07 22:20:41 +02:00
|
|
|
public void syncEnergyValuesOnLogin(cpw.mods.fml.common.gameevent.PlayerEvent.PlayerLoggedInEvent event)
|
2014-09-04 17:30:22 +02:00
|
|
|
{
|
2014-09-11 22:13:39 +02:00
|
|
|
PacketHandler.INSTANCE.sendTo(new MessageSyncEnergyValues(EnergyValueRegistry.getInstance()), (EntityPlayerMP) event.player);
|
2014-09-04 17:30:22 +02:00
|
|
|
}
|
2014-06-22 16:50:31 +02:00
|
|
|
}
|