MiniBookMiniBook

MiniBook API 🛠️

📄 Introduction

The MiniBookAPI provides static methods to interact programmatically with MiniBook. You can create, manage, and delete books, open books for players, and customize titles, authors, permissions, and pages directly from your code without instantiating the API.


🛠 Installation

Add the repository and dependency for MiniBook.

<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
</repositories>

<dependency>
    <groupId>com.github.xDrygo</groupId>
    <artifactId>MiniBook</artifactId>
    <version>1.0.0</version>
    <scope>provided</scope>
</dependency>

After adding the dependency, add MiniBook as a dependency in your plugin.

name: MyPlugin
main: com.example.MyPlugin.MyPlugin
version: 1.0
depend: # depend if API is required, soft-depend if optional
  - MiniBook

📋 MiniBookAPI Methods

Click to expand
  • boolean openBook(String bookId, Player player)

    Opens a book for a player.
boolean opened = MiniBookAPI.openBook("tutorial", player);
if (opened) {
    player.sendMessage("Book opened successfully!");
}
  • boolean createBook(String bookId, String title, String author, Boolean premium, String permission, String... pages)

    Creates a new book and saves it to the configuration files.
boolean created = MiniBookAPI.createBook(
    "welcome",
    "Welcome Guide",
    "Server Admin",
    false,
    "minibook.welcome",
    "<gradient:#ff0000:#00ff00>Welcome to our server!</gradient>",
    "<bold>Rules:</bold>\n<gray>1. Be respectful\n2. No griefing</gray>"
);
  • boolean deleteBook(String bookId)

    Deletes an existing book.
boolean deleted = MiniBookAPI.deleteBook("oldGuide");
if (deleted) {
    System.out.println("Book deleted successfully!");
}
  • List<BookData> getBooks()

    Retrieves all loaded books as complete objects (BookData).
List<BookData> allBooks = MiniBookAPI.getBooks();
for (BookData book : allBooks) {
    System.out.println("Book: " + book.getTitle());
}
  • List<String> getBookIds()

    Retrieves the IDs of all loaded books.
List<String> ids = MiniBookAPI.getBookIds();
ids.forEach(id -> System.out.println("ID: " + id));
  • BookData getBook(String bookId)

    Retrieves the data of a specific book.
BookData book = MiniBookAPI.getBook("tutorial");
if (book != null) {
    System.out.println("Title: " + book.getTitle());
    System.out.println("Author: " + book.getAuthor());
}
  • ItemStack getBookItem(String bookId)

    Retrieves the ItemStack of a specific book.
ItemStack bookItem = MiniBookAPI.getBookItem("welcome");
if (bookItem != null) {
    player.getInventory().addItem(bookItem);
}
  • boolean bookExists(String bookId)

    Checks if a book exists.
if (MiniBookAPI.bookExists("tutorial")) {
    System.out.println("The tutorial book exists!");
}

💡 Notes

  • All API methods are static, so you do not need to instantiate MiniBookAPI.
  • Book management includes creation, deletion, and retrieval of books.
  • Books support MiniMessage formatting for rich text and colors.
  • The premium parameter can be null (defaults to false).
  • The permission parameter can be null (auto-generates a permission).

🔗 References