@Override public OfflinePlayer[] getOfflinePlayers() { net.minecraft.world.storage.SaveHandler storage = (net.minecraft.world.storage.SaveHandler) console.worlds.get(0).getSaveHandler(); String[] files = storage.getPlayerDir().list(new DatFileFilter()); Set<OfflinePlayer> players = new HashSet<OfflinePlayer>(); for (String file : files) { try { players.add(getOfflinePlayer(UUID.fromString(file.substring(0, file.length() - 4)))); } catch (IllegalArgumentException ex) { // Who knows what is in this directory, just ignore invalid files } } players.addAll(getOnlinePlayers()); return players.toArray(new OfflinePlayer[players.size()]); }
public void handleWorldDataLoad(SaveHandler handler, WorldInfo worldInfo, NBTTagCompound tagCompound) { if (getEffectiveSide()!=Side.SERVER) { return; } if (handlerSet.contains(handler)) { return; } handlerSet.add(handler); handlerToCheck = new WeakReference<SaveHandler>(handler); // for confirmBackupLevelDatUse Map<String,NBTBase> additionalProperties = Maps.newHashMap(); worldInfo.setAdditionalProperties(additionalProperties); for (ModContainer mc : Loader.instance().getModList()) { if (mc instanceof InjectedModContainer) { WorldAccessContainer wac = ((InjectedModContainer)mc).getWrappedWorldAccessContainer(); if (wac != null) { wac.readData(handler, worldInfo, additionalProperties, tagCompound.getCompoundTag(mc.getModId())); } } } }
public void confirmBackupLevelDatUse(SaveHandler handler) { if (handlerToCheck == null || handlerToCheck.get() != handler) { // only run if the save has been initially loaded handlerToCheck = null; return; } String text = "Forge Mod Loader detected that the backup level.dat is being used.\n\n" + "This may happen due to a bug or corruption, continuing can damage\n" + "your world beyond repair or lose data / progress.\n\n" + "It's recommended to create a world backup before continuing."; boolean confirmed = StartupQuery.confirm(text); if (!confirmed) StartupQuery.abort(); }
public void handleWorldDataLoad(SaveHandler handler, WorldInfo worldInfo, NBTTagCompound tagCompound) { if (getEffectiveSide()!=Side.SERVER) { return; } if (handlerSet.contains(handler)) { return; } handlerSet.add(handler); handlerToCheck = new WeakReference<SaveHandler>(handler); // for confirmBackupLevelDatUse Map<String,NBTBase> additionalProperties = Maps.newHashMap(); worldInfo.setAdditionalProperties(additionalProperties); for (ModContainer mc : Loader.instance().getModList()) { if (mc instanceof InjectedModContainer) { WorldAccessContainer wac = ((InjectedModContainer)mc).getWrappedWorldAccessContainer(); if (wac != null) { wac.readData(handler, worldInfo, additionalProperties, tagCompound.func_74775_l(mc.getModId())); } } } }
/** * Return the current root directory for the world save. Accesses getSaveHandler from the overworld * @return the root directory of the save */ public static File getCurrentSaveRootDirectory() { if (DimensionManager.getWorld(0) != null) { return ((SaveHandler)DimensionManager.getWorld(0).func_72860_G()).func_75765_b(); } else if (MinecraftServer.func_71276_C() != null) { MinecraftServer srv = MinecraftServer.func_71276_C(); SaveHandler saveHandler = (SaveHandler) srv.func_71254_M().func_75804_a(srv.func_71270_I(), false); return saveHandler.func_75765_b(); } else { return null; } }
/** * Return the current root directory for the world save. Accesses getSaveHandler from the overworld * @return the root directory of the save */ public static File getCurrentSaveRootDirectory() { if (DimensionManager.getWorld(0) != null) { return ((SaveHandler)DimensionManager.getWorld(0).getSaveHandler()).getWorldDirectory(); } else if (MinecraftServer.getServer() != null) { MinecraftServer srv = MinecraftServer.getServer(); SaveHandler saveHandler = (SaveHandler) srv.getActiveAnvilConverter().getSaveLoader(srv.getFolderName(), false); return saveHandler.getWorldDirectory(); } else { return null; } }
@Override public OfflinePlayer getOfflinePlayer(UUID uuid) { final ISaveHandler saveHandler = MinecraftServer.getServer().getEntityWorld().getSaveHandler(); if (saveHandler instanceof SaveHandler) { final NBTTagCompound tagCompound = ((IMixinSaveHandler) saveHandler).readPlayerData(uuid); if (tagCompound != null) { final GameProfile profile = getPlayerProfileCache().getProfileByUUID(uuid); if (profile != null) { return new NeptuneOfflinePlayer(profile.getName(), uuid, tagCompound); } else { return new NeptuneOfflinePlayer("PLAYER_NAME_UNKNOWN", uuid, tagCompound); } } return null; } else { throw new RuntimeException("ISaveHandler is not of type SaveHandler! Failing to load playerdata"); } }
public void handleWorldDataLoad(SaveHandler handler, WorldInfo worldInfo, NBTTagCompound tagCompound) { if (getEffectiveSide()!=Side.SERVER) { return; } if (handlerSet.contains(handler)) { return; } handlerSet.add(handler); Map<String,NBTBase> additionalProperties = Maps.newHashMap(); worldInfo.setAdditionalProperties(additionalProperties); for (ModContainer mc : Loader.instance().getModList()) { if (mc instanceof InjectedModContainer) { WorldAccessContainer wac = ((InjectedModContainer)mc).getWrappedWorldAccessContainer(); if (wac != null) { wac.readData(handler, worldInfo, additionalProperties, tagCompound.func_74775_l(mc.getModId())); } } } }
@Override public NBTTagCompound getDataForWriting(SaveHandler handler, WorldInfo info) { NBTTagCompound fmlData = new NBTTagCompound(); NBTTagList list = new NBTTagList(); for (ModContainer mc : Loader.instance().getActiveModList()) { NBTTagCompound mod = new NBTTagCompound(); mod.func_74778_a("ModId", mc.getModId()); mod.func_74778_a("ModVersion", mc.getVersion()); list.func_74742_a(mod); } fmlData.func_74782_a("ModList", list); NBTTagList itemList = new NBTTagList(); GameData.writeItemData(itemList); fmlData.func_74782_a("ModItemData", itemList); return fmlData; }
public void handleWorldDataLoad(SaveHandler handler, WorldInfo worldInfo, NBTTagCompound tagCompound) { if (getEffectiveSide()!=Side.SERVER) { return; } if (handlerSet.contains(handler)) { return; } handlerSet.add(handler); Map<String,NBTBase> additionalProperties = Maps.newHashMap(); worldInfo.setAdditionalProperties(additionalProperties); for (ModContainer mc : Loader.instance().getModList()) { if (mc instanceof InjectedModContainer) { WorldAccessContainer wac = ((InjectedModContainer)mc).getWrappedWorldAccessContainer(); if (wac != null) { wac.readData(handler, worldInfo, additionalProperties, tagCompound.getCompoundTag(mc.getModId())); } } } }
@Override public NBTTagCompound getDataForWriting(SaveHandler handler, WorldInfo info) { NBTTagCompound fmlData = new NBTTagCompound(); NBTTagList list = new NBTTagList(); for (ModContainer mc : Loader.instance().getActiveModList()) { NBTTagCompound mod = new NBTTagCompound(); mod.setString("ModId", mc.getModId()); mod.setString("ModVersion", mc.getVersion()); list.appendTag(mod); } fmlData.setTag("ModList", list); NBTTagList itemList = new NBTTagList(); GameData.writeItemData(itemList); fmlData.setTag("ModItemData", itemList); return fmlData; }
public void handleWorldDataSave(SaveHandler handler, WorldInfo worldInfo, NBTTagCompound tagCompound) { for (ModContainer mc : Loader.instance().getModList()) { if (mc instanceof InjectedModContainer) { WorldAccessContainer wac = ((InjectedModContainer)mc).getWrappedWorldAccessContainer(); if (wac != null) { NBTTagCompound dataForWriting = wac.getDataForWriting(handler, worldInfo); tagCompound.setTag(mc.getModId(), dataForWriting); } } } }
@Override public NBTTagCompound getDataForWriting(SaveHandler handler, WorldInfo info) { NBTTagCompound forgeData = new NBTTagCompound(); NBTTagCompound dimData = DimensionManager.saveDimensionDataMap(); forgeData.setTag("DimensionData", dimData); FluidRegistry.writeDefaultFluidList(forgeData); return forgeData; }
public void handleWorldDataSave(SaveHandler handler, WorldInfo worldInfo, NBTTagCompound tagCompound) { for (ModContainer mc : Loader.instance().getModList()) { if (mc instanceof InjectedModContainer) { WorldAccessContainer wac = ((InjectedModContainer)mc).getWrappedWorldAccessContainer(); if (wac != null) { NBTTagCompound dataForWriting = wac.getDataForWriting(handler, worldInfo); tagCompound.func_74782_a(mc.getModId(), dataForWriting); } } } }
@Override public NBTTagCompound getDataForWriting(SaveHandler handler, WorldInfo info) { NBTTagCompound forgeData = new NBTTagCompound(); NBTTagCompound dimData = DimensionManager.saveDimensionDataMap(); forgeData.func_74782_a("DimensionData", dimData); FluidRegistry.writeDefaultFluidList(forgeData); return forgeData; }
@Override public File getWorldContainer() { // Cauldron start - return the proper container if (DimensionManager.getWorld(0) != null) { return ((SaveHandler)DimensionManager.getWorld(0).getSaveHandler()).getWorldDirectory(); } // Cauldron end if (container == null) { container = new File(configuration.getString("settings.world-container", ".")); } return container; }