Display magic content from the interwebz in a book!
2

API

Here’s some API docs (no fancy stuff):

WebBooks.java

public static void loadUrl(String url, Player player, WebsiteReadyConsumer callback)

Start a async executor download the website from url, posting additional data for player to the web-server.
When done parding the functional-callback is executed, containing the Website-object (see below)
In case your callback manipulated the wolrd it should do so by reating a **sync** executor
**param** *url* the url to download
**param** *player* the player to collect data from for the web-server
**param** *callback* functional callback to be executed on success

public static Website parseHtml(String html, String baseURL, Player player)

Parse a html string as website with baseURL to complete links
**param** *html* the html to parse
**param** *baseURL* the base url to complete links with
**param** *player* currently unused
**return** the Website-object for this html

Website.java

public String getUrl()

Get the url this website was requested from
**return** the request url

public int getResponseCode()

Get the response code from the web-server, 200 usually means everything's ok
**return** the response-code

public Map<String, String> getResponseHeaders()

Get all response headers, in case your web-application sends additional headers or idk
**return** a map containing the key-value mapping for the received headers

public Text getTitle()

Gets the page title as returned in the <head><title>-Tag
**return** the page title

public Collection<Text> getPages()

All declared pages on this website, where pages are children of the first <ul> element with class book.
The JavaScript equivalent for selecting Pages would be `document.querySelector("ul.book").children();`
**return** A collection of Text, each representing a page.

public void displayBook(Player player)

Show this website to a player wrapped in a bookview.
**param** *player* the player to show this website to

public void displayChat(MessageReceiver receiver)

Show this website to a player presented by the chat paginator.
**param** *receiver* who ever is supposed to read the website

public ItemStack save()

Turns this website object into a signed book that can be opened over and over again, without
any delay and no matter if the source website is available... how usefull :D
**return** An ItemStack containing 1 Book with all pages

Category: Miscellaneous

Published on Sep 5, 2017

views

stars

watchers

total downloads

Licensed under MIT

Promoted Versions

Members