Git Product home page Git Product logo

book-api's Introduction

spigot-book-api

This project contains more APIs that help the developer in using the books. Follows a brief documentation on how to use it.

To include the API in your project put this into our pom.xml (maven)

<dependencies>
  ...
  <dependency>
    <groupId>xyz.upperlevel.spigot.book</groupId>
    <artifactId>spigot-book-api</artifactId>
    <version>1.4</version>
  </dependency>
</dependencies>

After that you'll be able to use the class BookUtil for Book printing/interaction, the full guide is posted in the wiki. Some usage examples:

ItemStack book = BookUtil.writtenBook()
    .author("SnowyCoder")
    .title("The Test-ament")
    .pages(
        new BaseComponent[]{
            new TextComponent("Introduction page")
        },
        new BookUtil.PageBuilder()
            .add(new TextComponent("visit "))
            .add(
                BookUtil.TextBuilder.of("Spigot")
                    .color(ChatColor.GOLD)
                    .style(ChatColor.BOLD, ChatColor.ITALIC)
                    .onClick(BookUtil.ClickAction.openUrl("https://www.spigotmc.org"))
                    .onHover(BookUtil.HoverAction.showText("Open spigot!"))
                    .build()
            )
            .add(" or ")
            .add(
                new ComponentBuilder("Bukkit")
                    .color(net.md_5.bungee.api.ChatColor.BLUE)
                    .bold(true)
                    .italic(true)
                    .event(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://bukkit.org"))
                    .event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new BaseComponent[]{new TextComponent("Open bukkit!")}))
                    .create()
            )
            .newLine()
            .add("I think that the ")
            .add(
                BookUtil.TextBuilder.of("TextBuilder")
                    .color(ChatColor.AQUA)
                    .style(ChatColor.BOLD)
                    .onClick(BookUtil.ClickAction.changePage(3))
                    .onHover(BookUtil.HoverAction.showText("TextBuilder's page"))
                    .build()
            )
            .add(" is really useful to ")
            .add(
                BookUtil.TextBuilder.of("you")
                    .color(ChatColor.AQUA)
                    .style(ChatColor.BOLD)
                    .onClick(BookUtil.ClickAction.runCommand("/kill"))//lol
                    .onHover(BookUtil.HoverAction.showText("Kill yasself"))
                    .build()
            )
            .build(),
        new BookUtil.PageBuilder()
            .add("TextBuilder's page")
            .newLine().newLine()
            .add("Isn't this amazing?")
            .build()
    )
    .build();

BookUtil.openPlayer(player, book);

book-api's People

Contributors

snowycoder avatar flori-schwa avatar elgbar avatar tominous avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.