GithubHelp home page GithubHelp logo

finalboolean / spigui Goto Github PK

View Code? Open in Web Editor NEW

This project forked from samjakob/spigui

0.0 0.0 0.0 458 KB

A comprehensive GUI API for Spigot with pages support.

License: MIT License

Java 100.00%

spigui's Introduction

SpiGUI

A comprehensive inventory menu API for Spigot with pages support. Supports Bukkit/Spigot 1.7 - 1.16 (see Version Notes).

License No Dependencies

JitPack JavaDoc




The code for this example can be found in the library test class.



Version Notes

  • I don't see a reason it shouldn't work in Spigot 1.7 or any version of Bukkit from 1.8 - 1.16 but it hasn't been tested on those versions.
  • This library has been tested on Spigot 1.8 and Spigot 1.16 and is expected to work on every version in-between.
  • The ItemBuilder API does require that api-version be "legacy" (or not specified) for Spigot versions after 1.13.

Quick Start

Step 1: Create an instance of the SpiGUI library in your plugin

class MyPlugin extends JavaPlugin {

  public static SpiGUI spiGUI;
  
  @Override
  public void onEnable() {
    // (IMPORTANT!) Registers SpiGUI event handlers (and stores plugin-wide settings for SpiGUI.)
    spiGUI = new SpiGUI(this);
  }
  
}

Step 2: Use the library

public void openMyAwesomeMenu(Player player) {

  // Create a GUI with 3 rows (27 slots)
  SGMenu myAwesomeMenu = MyPlugin.spiGUI.create("&cMy Awesome Menu", 3);

  // Create a button
  SGButton myAwesomeButton = new SGButton(
    // Includes an ItemBuilder class with chainable methods to easily
    // create menu items.
    new ItemBuilder(Material.WOOD).build()
  ).withListener((InventoryClickEvent event) -> {
    // Events are cancelled automatically, unless you turn it off
    // for your plugin or for this inventory.
    event.getWhoClicked().sendMessage("Hello, world!");
  });
  
  // Add the button to your GUI
  myAwesomeMenu.addButton(myAwesomeButton);
  
  // Show the GUI
  player.openInventory(myAwesomeMenu.getInventory());

}

Step 3: Profit!


Why?

Chest Inventory Menus (commonly referred to as GUIs) are the ubiquitous way to display menus, execute actions and even manage configuration in Spigot plugins. However, the Inventory API leveraged to achieve this in Spigot is not designed for menus, making code far more verbose and far less maintainable than it needs to be.

SpiGUI is a rewrite of my outdated SpigotPaginatedGUI API including improvements and features I've added whilst using the API in my own software that aims to provide a highly readable and concise API for menus.

spigui's People

Contributors

samjakob avatar stijnb1234 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.