2014-06-22 16:50:31 +02:00
|
|
|
package com.pahimar.ee3.handler;
|
|
|
|
|
|
|
|
import com.pahimar.ee3.util.LogHelper;
|
|
|
|
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
|
|
|
import net.minecraftforge.event.entity.player.PlayerEvent;
|
|
|
|
|
2014-06-22 20:03:30 +02:00
|
|
|
import java.io.File;
|
|
|
|
import java.io.IOException;
|
|
|
|
|
2014-06-22 16:50:31 +02:00
|
|
|
public class PlayerEventHandler
|
|
|
|
{
|
|
|
|
@SubscribeEvent
|
|
|
|
public void onPlayerSaveToFileEvent(PlayerEvent.SaveToFile event)
|
|
|
|
{
|
|
|
|
LogHelper.info("Save Event: " + event.playerUUID);
|
2014-06-22 20:03:30 +02:00
|
|
|
File playerFile = event.getPlayerFile("ee3");
|
|
|
|
if (!playerFile.exists())
|
|
|
|
{
|
|
|
|
LogHelper.info("Creating knowledge file for player with UUID: " + event.playerUUID);
|
|
|
|
try
|
|
|
|
{
|
|
|
|
playerFile.createNewFile();
|
|
|
|
}
|
|
|
|
catch (IOException e)
|
|
|
|
{
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
2014-06-22 16:50:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@SubscribeEvent
|
|
|
|
public void onPlayerLoadFromFileEvent(PlayerEvent.LoadFromFile event)
|
|
|
|
{
|
|
|
|
LogHelper.info("Load Event: " + event.playerUUID);
|
2014-06-22 20:03:30 +02:00
|
|
|
|
|
|
|
File playerFile = event.getPlayerFile("ee3");
|
|
|
|
try
|
|
|
|
{
|
|
|
|
playerFile.createNewFile();
|
|
|
|
}
|
|
|
|
catch (IOException e)
|
|
|
|
{
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
2014-06-22 16:50:31 +02:00
|
|
|
}
|
|
|
|
}
|