public abstract String resourceToString(IResource resource, boolean skipCommments); }
@Override public void load() { BookRepository repo = parent.source; if(data == null || data.isEmpty()) { return; } ResourceLocation location = repo.getResourceLocation(data); if(location != null && repo.resourceExists(location)) { ContentStructure structure = BookLoader.GSON .fromJson(repo.resourceToString(repo.getResource(location)), ContentStructure.class); structure.parent = parent; structure.load(); this.size = structure.size; this.structure = structure.structure; this.text = structure.text; } }
@Override public void load() { if(name == null) { name = "section" + parent.unnamedSectionCounter++; } name = name.toLowerCase(); if(!data.equals("no-load")) { IResource pagesInfo = source.getResource(source.getResourceLocation(data)); if(pagesInfo != null) { String data = source.resourceToString(pagesInfo); if(!data.isEmpty()) { try { pages = new ArrayList<>(Arrays.asList(BookLoader.GSON.fromJson(data, PageData[].class))); } catch(Exception e) { pages = new ArrayList<>(); PageData pdError = new PageData(true); pdError.name = "errorrenous"; pdError.content = new ContentError("Failed to load section " + name + ".", e); pages.add(pdError); } } } } for(PageData page : pages) { page.parent = this; page.source = source; page.load(); } icon.location = source.getResourceLocation(icon.file, true); }
IResource pageInfo = source.getResource(source.getResourceLocation(data)); if(pageInfo != null) { String data = source.resourceToString(pageInfo); if(!data.isEmpty()) { Class<? extends PageContent> ctype = BookLoader.getPageType(type);
public NonNullList<ItemStack> getItems() { if(itemListLocation != null && source.resourceExists(itemListLocation)) { try { ItemsList itemsList = BookLoader.GSON .fromJson(source.resourceToString(source.getResource(itemListLocation)), ItemsList.class); NonNullList<ItemStack> items = NonNullList.<ItemStack> withSize(itemsList.items.length, ItemStack.EMPTY); for(int i = 0; i < itemsList.items.length; i++) { items.set(i, itemsList.items[i].getItem()); } this.action = itemsList.action; return items; } catch(Exception ignored) { } } return NonNullList.<ItemStack> withSize(1, getItem()); }
try { appearance = BookLoader.GSON .fromJson(repo.resourceToString(repo.getResource(appearanceLocation)), AppearanceData.class); } catch(Exception e) { e.printStackTrace(); try { itemLinks = new ArrayList<>(Arrays.asList(BookLoader.GSON .fromJson(repo.resourceToString(repo.getResource(itemLinkLocation)), ItemStackData.ItemLink[].class))); } catch(Exception e) { e.printStackTrace();