This commit is contained in:
DarkGuardsman 2013-07-19 10:04:41 -04:00
parent 3d82011b96
commit 8538476bc9
3 changed files with 64 additions and 18 deletions

View file

@ -5,6 +5,9 @@ import java.util.Arrays;
import java.util.logging.Logger;
import net.minecraftforge.common.Configuration;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.ForgeSubscribe;
import net.minecraftforge.event.world.WorldEvent;
import universalelectricity.prefab.network.PacketManager;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.Mod;
@ -15,7 +18,10 @@ import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLServerStoppingEvent;
import cpw.mods.fml.common.network.NetworkMod;
import dark.core.hydraulic.helpers.FluidRestrictionHandler;
import dark.library.saving.SaveManager;
/** @author HangCow, DarkGuardsman */
@Mod(modid = DarkMain.MOD_ID, name = DarkMain.MOD_NAME, version = DarkMain.VERSION, useMetadata = true)
@ -59,11 +65,14 @@ public class DarkMain
/** Main config file */
public static final Configuration CONFIGURATION = new Configuration(new File(Loader.instance().getConfigDir(), "Dark/General.cfg"));
/** Main mod output to console */
public static final Logger LOGGER = Logger.getLogger("DarkLib");
public static final Logger LOGGER = Logger.getLogger("DarkCore");
@EventHandler
public void preInit(FMLPreInitializationEvent event)
{
MinecraftForge.EVENT_BUS.register(this);
MinecraftForge.EVENT_BUS.register(new FluidRestrictionHandler());
proxy.preInit();
}
@ -72,7 +81,7 @@ public class DarkMain
public void generalLoad(FMLInitializationEvent event)
{
proxy.init();
/* MCMOD.INFO FILE BUILDER? */
meta.modId = DarkMain.MOD_ID;
meta.name = DarkMain.MOD_NAME;
@ -94,4 +103,16 @@ public class DarkMain
}
@ForgeSubscribe
public void onWorldSave(WorldEvent.Save event)
{
SaveManager.save(!event.world.isRemote);
}
@EventHandler
public void serverStopping(FMLServerStoppingEvent event)
{
SaveManager.save(true);
}
}

View file

@ -5,11 +5,46 @@ import java.util.Date;
public class Time
{
public static Pair<String,Date> getCurrentTimeStamp()
/** Returns the current time stamp as both the Data and string of time */
public static Pair<String, Date> getCurrentTimeStamp()
{
SimpleDateFormat sdfDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date now = new Date();
String strDate = sdfDate.format(now);
return new Pair<String,Date>(strDate,now);
return new Pair<String, Date>(strDate, now);
}
/** Returns the current time stamp as a class of numbers */
public static TimeData getCurrentTimeData()
{
return new TimeData();
}
/** Used to stored the data in a class for easy access */
public static class TimeData
{
int hour, min, sec, day, month, year;
@SuppressWarnings("deprecation")
public TimeData()
{
Date now = new Date();
this.hour = now.getHours();
this.min = now.getMinutes();
this.sec = now.getSeconds();
this.day = now.getDay();
this.month = now.getMonth();
this.year = now.getYear();
}
public TimeData(int hour, int min, int sec, int day, int month, int year)
{
this.hour = hour;
this.min = min;
this.sec = sec;
this.day = day;
this.month = month;
this.year = year;
}
}
}

View file

@ -6,7 +6,7 @@ import java.util.List;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.ForgeSubscribe;
import net.minecraftforge.event.world.WorldEvent;
import cpw.mods.fml.common.Mod.ServerStopping;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.event.FMLServerStoppingEvent;
public class SaveManager
@ -33,20 +33,10 @@ public class SaveManager
nbtSaveList.add(saveClass);
}
}
@ForgeSubscribe
public void onWorldSave(WorldEvent.Save event)
{
save(!event.world.isRemote);
}
@ServerStopping
public void serverStopping(FMLServerStoppingEvent event)
{
save(true);
}
public void save(boolean isServer)
/** Called to get all INbtSave classes to do a save to world */
public static void save(boolean isServer)
{
for (INbtSave save : nbtSaveList)
{