Class BookUpgrader
java.lang.Object
net.ixdarklord.folios.internal.format.BookUpgrader
Rewrites a book written in an older format into a newer one, a format at a time, as it loads: Folios then only ever
reads the current format. Each format's changes are data (
/folios/upgrades/<format>.json), the same files the
docs site's upgrader tool reads, so the two can't drift apart. A change is one of:
"rename": {"old": "new"}: a key takes a new name;"remove": ["key"]: a key goes;"move": {"from": "a.b", "to": "c.d"}: a value moves, dots stepping into objects;"run": "name": one of the few changes that need code, written the same in Java and JavaScript.
"in" naming which files and objects it applies to: book, category, entry,
page (each object of an entry's "pages"), element (each page written as one element, and each
object of a page's "elements"), objective (each of a quest's "objectives"), lockable
(each category, entry and page, which can be locked) or build, and an optional
"where": {"type": "recipe"} to only change objects with those values.
A book already in a format can still hold keys of an older one; check(String, Map, String) names them, from the same changes
(those marked "check": false aside, and of the ones that need code only those marked "check": true).
Books are files by their path in the book's folder: book.json, categories/basics.json,
entries/basics/first_steps.json, builds/tower.json. Gson only: it also runs outside the game, to check
it against the web tool.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordWhat an upgrade made: the files, rewritten; translations to add to the book's lang file (en_us); and what changed, by file. -
Method Summary
Modifier and TypeMethodDescriptionWhat in a book written informatstill has the shape of an older format: each change upgrading to it would make, by file.static voidUpgrades every book under a folder to the current format and writes the results to another, as the web tool would:<in> <out>;--check <in>names what in books already in the current format still has an older shape.static com.google.gson.JsonObjectA format's changes, as the mod carries them.static BookUpgrader.ResultUpgrades a book's files from formatfromtoto; the files given are left as they are.
-
Method Details
-
upgrade
-
check
public static Map<String, List<String>> check(String book, Map<String, com.google.gson.JsonObject> files, String format) What in a book written informatstill has the shape of an older format: each change upgrading to it would make, by file. Empty when the book is clean. The files given are left as they are. -
step
A format's changes, as the mod carries them. -
main
Upgrades every book under a folder to the current format and writes the results to another, as the web tool would:<in> <out>;--check <in>names what in books already in the current format still has an older shape. Used to check the mod and the web tool agree (tools/check-upgrader).- Throws:
IOException
-