/** * Requires to start up from external from here * * drawback of the singleton build style * * @param server */ public static void onServerAboutToStart( MinecraftServer server ) { File worldDirectory = DimensionManager.getCurrentSaveRootDirectory(); if( worldDirectory == null ) { worldDirectory = server.getActiveAnvilConverter().getSaveLoader( server.getFolderName(), false ).getWorldDirectory(); } final WorldData newInstance = new WorldData( worldDirectory ); instance = newInstance; newInstance.onServerStarting(); }
public static File getLPFolder() { return new File(DimensionManager.getCurrentSaveRootDirectory(), "LogisticsPipes"); }
protected @Nonnull File getSaveFile() { return new File(DimensionManager.getCurrentSaveRootDirectory(), ident + ".json"); }
private static HashMap<String, ArrayList<PortalLocation>> loadFile() { HashMap<String, ArrayList<PortalLocation>> map; File file = new File(fileName); try { if (!file.exists()) { if (file.getParentFile().mkdir()) { if (file.createNewFile()) { BMLog.DEBUG.info("Creating {} in {}", fileName, DimensionManager.getCurrentSaveRootDirectory()); } } else if (file.createNewFile()) { BMLog.DEBUG.info("Creating {} in {}", fileName, DimensionManager.getCurrentSaveRootDirectory()); } } FileInputStream fileIn = new FileInputStream(file); ObjectInputStream in = new ObjectInputStream(fileIn); map = (HashMap<String, ArrayList<PortalLocation>>) in.readObject(); in.close(); fileIn.close(); return map; } catch (IOException e) { return null; } catch (ClassNotFoundException e) { BMLog.DEFAULT.error("{} was not found in {}", file, DimensionManager.getCurrentSaveRootDirectory()); return null; } }
private void load() { saveDir = new File(DimensionManager.getCurrentSaveRootDirectory(), "EnderStorage"); try { if (!saveDir.exists()) { saveDir.mkdirs(); } //TODO, Ok so, This looks like cancer, but is actually quite smart, data1, and data2 are essentially backups, lock holds the current data and lock is only ever written to after a successful write to data1/2. //TODO, Maybe this isnt needed anymore? Maybe it should be stored via WorldSavedData.. saveFiles = new File[] { new File(saveDir, "data1.dat"), new File(saveDir, "data2.dat"), new File(saveDir, "lock.dat") }; if (saveFiles[2].exists() && saveFiles[2].length() > 0) { FileInputStream fin = new FileInputStream(saveFiles[2]); saveTo = fin.read() ^ 1; fin.close(); if (saveFiles[saveTo ^ 1].exists()) { FileInputStream in = new FileInputStream(saveFiles[saveTo ^ 1]); saveTag = CompressedStreamTools.readCompressed(in); in.close(); } else { saveTag = new NBTTagCompound(); } } else { saveTag = new NBTTagCompound(); } } catch (Exception e) { throw new RuntimeException(String.format("EnderStorage was unable to read it's data, please delete the 'EnderStorage' folder Here: %s and start the server again.", saveDir), e); } }
private static IItemHandlerModifiable loadOfflineBag(UUID playerUUID, EnumDyeColor color) throws CommandException { File playerData = new File(DimensionManager.getCurrentSaveRootDirectory(), "playerdata"); if (playerData.exists()) { File player = new File(playerData, playerUUID.toString() + ".dat"); if (player.exists() && player.isFile()) { try(FileInputStream in = new FileInputStream(player)) { NBTTagCompound playerDat = CompressedStreamTools.readCompressed(in); NBTTagCompound bagProvider = playerDat.getCompoundTag("ForgeCaps").getCompoundTag(AlchBagImpl.Provider.NAME.toString()); IAlchBagProvider provider = ProjectEAPI.ALCH_BAG_CAPABILITY.getDefaultInstance(); ProjectEAPI.ALCH_BAG_CAPABILITY.readNBT(provider, null, bagProvider); return (IItemHandlerModifiable) provider.getBag(color); } catch (IOException e) { // fall through to below } } } throw new CommandException("pe.command.showbag.offline.notfound", playerUUID.toString()); } }
private static boolean cacheOfflineData(UUID playerUUID) { Preconditions.checkState(FMLCommonHandler.instance().getEffectiveSide().isServer(), "CRITICAL: Trying to read filesystem on client!!"); File playerData = new File(DimensionManager.getCurrentSaveRootDirectory(), "playerdata"); if (playerData.exists()) { File player = new File(playerData, playerUUID.toString() + ".dat"); if (player.exists() && player.isFile()) { try(FileInputStream in = new FileInputStream(player)) { NBTTagCompound playerDat = CompressedStreamTools.readCompressed(in); // No need to create buffered stream, that call does it for us NBTTagCompound knowledgeProvider = playerDat.getCompoundTag("ForgeCaps").getCompoundTag(KnowledgeImpl.Provider.NAME.toString()); IKnowledgeProvider provider = ProjectEAPI.KNOWLEDGE_CAPABILITY.getDefaultInstance(); ProjectEAPI.KNOWLEDGE_CAPABILITY.readNBT(provider, null, knowledgeProvider); cachedKnowledgeProviders.put(playerUUID, immutableCopy(provider)); PECore.debugLog("Caching offline data for UUID: {}", playerUUID); return true; } catch (IOException e) { PECore.LOGGER.warn("Failed to cache offline data for API calls for UUID: {}", playerUUID); } } } return false; }
@SubscribeEvent public void save(WorldEvent.Save event) { if(event.getWorld().provider.getDimension() == 0) { try { File data = new File(DimensionManager.getCurrentSaveRootDirectory(), "bank.dat"); if(!data.exists()) { data.createNewFile(); } NBTTagCompound nbt = new NBTTagCompound(); BankUtil.INSTANCE.save(nbt); CompressedStreamTools.write(nbt, data); } catch (IOException e) { e.printStackTrace(); } } } }
@SubscribeEvent public void save(WorldEvent.Save event) { if(event.getWorld().provider.getDimension() == 0) { try { File data = new File(DimensionManager.getCurrentSaveRootDirectory(), "emails.dat"); if(!data.exists()) { data.createNewFile(); } NBTTagCompound nbt = new NBTTagCompound(); EmailManager.INSTANCE.writeToNBT(nbt); CompressedStreamTools.write(nbt, data); } catch (IOException e) { e.printStackTrace(); } } } }
@SubscribeEvent public void load(WorldEvent.Load event) { if(event.getWorld().provider.getDimension() == 0) { try { File data = new File(DimensionManager.getCurrentSaveRootDirectory(), "emails.dat"); if(!data.exists()) { return; } NBTTagCompound nbt = CompressedStreamTools.read(data); if(nbt != null) { EmailManager.INSTANCE.readFromNBT(nbt); } } catch (IOException e) { e.printStackTrace(); } } }
@SubscribeEvent public void load(WorldEvent.Load event) { if(event.getWorld().provider.getDimension() == 0) { try { File data = new File(DimensionManager.getCurrentSaveRootDirectory(), "bank.dat"); if(!data.exists()) { return; } NBTTagCompound nbt = CompressedStreamTools.read(data); if(nbt != null) { BankUtil.INSTANCE.load(nbt); } } catch (IOException e) { e.printStackTrace(); } } }
} else { try { File f = new File(DimensionManager.getCurrentSaveRootDirectory(), "playerdata/" + creator + ".dat"); NBTTagCompound tag = CompressedStreamTools.read(f); NBTTagCompound capsTag = tag.getCompoundTag("ForgeCaps");
File f = new File(DimensionManager.getCurrentSaveRootDirectory(), "playerdata/" + creator + ".dat"); NBTTagCompound tag = CompressedStreamTools.read(f);