diff --git a/build.gradle b/build.gradle index 92f34a4..ac02b47 100644 --- a/build.gradle +++ b/build.gradle @@ -17,7 +17,7 @@ buildscript { apply plugin: 'forge' -version = "1.7.10-1.0.1.0" +version = "1.7.10-1.0.1.1" group= "com.azanor.baubles" archivesBaseName = "Baubles" diff --git a/src/main/java/baubles/api/package-info.java b/src/main/java/baubles/api/package-info.java new file mode 100644 index 0000000..15b770d --- /dev/null +++ b/src/main/java/baubles/api/package-info.java @@ -0,0 +1,5 @@ +@API(owner = "Baubles", apiVersion = baubles.common.Baubles.VERSION, provides = "Baubles|API") +package baubles.api; + +import cpw.mods.fml.common.API; + diff --git a/src/main/java/baubles/common/Baubles.java b/src/main/java/baubles/common/Baubles.java index f3cabfe..136e9a9 100644 --- a/src/main/java/baubles/common/Baubles.java +++ b/src/main/java/baubles/common/Baubles.java @@ -24,7 +24,7 @@ public class Baubles { public static final String MODID = "Baubles"; public static final String MODNAME = "Baubles"; - public static final String VERSION = "1.0.1.0"; + public static final String VERSION = "1.0.1.1"; @SidedProxy(clientSide = "baubles.client.ClientProxy", serverSide = "baubles.common.CommonProxy") public static CommonProxy proxy; diff --git a/src/main/java/baubles/common/event/EventHandlerEntity.java b/src/main/java/baubles/common/event/EventHandlerEntity.java index 7f6e9dd..e7cbb4a 100644 --- a/src/main/java/baubles/common/event/EventHandlerEntity.java +++ b/src/main/java/baubles/common/event/EventHandlerEntity.java @@ -1,14 +1,19 @@ package baubles.common.event; +import java.io.File; +import java.io.IOException; + import net.minecraft.entity.player.EntityPlayer; import net.minecraftforge.event.entity.player.PlayerDropsEvent; import net.minecraftforge.event.entity.player.PlayerEvent; import baubles.api.IBauble; +import baubles.common.Baubles; import baubles.common.container.InventoryBaubles; import baubles.common.lib.PlayerHandler; -import cpw.mods.fml.common.FMLCommonHandler; + +import com.google.common.io.Files; + import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.relauncher.Side; public class EventHandlerEntity { @@ -47,12 +52,34 @@ public class EventHandlerEntity { @SubscribeEvent public void playerLoad(PlayerEvent.LoadFromFile event) { PlayerHandler.clearPlayerBaubles(event.entityPlayer); - PlayerHandler.loadPlayerBaubles(event.entityPlayer, event.getPlayerFile("baub"), event.getPlayerFile("baubback")); + + File file1 = event.getPlayerFile("baub"); + if (!file1.exists()) { + File filet = getLegacyFileFromPlayer(event.entityPlayer); + if (filet.exists()) { + try { + Files.copy(filet, file1); + Baubles.log.info("Using pre MC 1.7.10 Baubles savefile for "+event.entityPlayer.getCommandSenderName()); + } catch (IOException e) {} + } + } + + PlayerHandler.loadPlayerBaubles(event.entityPlayer, file1, event.getPlayerFile("baubback")); + for (int a = 0; a < 4; a++) PlayerHandler.getPlayerBaubles(event.entityPlayer) .syncSlotToClients(a); } + + public static File getLegacyFileFromPlayer(EntityPlayer player) + { + try { + File playersDirectory = new File(player.worldObj.getSaveHandler().getWorldDirectory(), "players"); + return new File(playersDirectory, player.getCommandSenderName() + ".baub"); + } catch (Exception e) { e.printStackTrace(); } + return null; + } @SubscribeEvent public void playerSave(PlayerEvent.SaveToFile event) { diff --git a/src/main/resources/changelog.txt b/src/main/resources/changelog.txt index 4856ebc..9fa3dd3 100644 --- a/src/main/resources/changelog.txt +++ b/src/main/resources/changelog.txt @@ -1,3 +1,6 @@ +1.0.1.1 +- added backwards compatibility for legacy (pre 1.7.10) savefiles + 1.0.1.0 - update for MC 1.7.10 - no requires Forge 10.13.0.1177