Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EGUI

A comprehensive inventory menu API for Spigot with pages support. Supports Bukkit/Spigot 1.7 - 1.20 (see Version Notes) (Future versions ought to work just fine too!).

License No Dependencies

JitPack JavaDoc




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



Version Notes

IMPORTANT! If you have an opinion on how backwards compatibility should be achieved with new versions, please feel free to drop a reply to this open discussion.

  • I don't see a reason it shouldn't work in Spigot 1.7 or any version of Bukkit from 1.8 - 1.20 but it hasn't been tested on each individual version.
  • This library has been tested on Spigot 1.8, Spigot 1.16, PaperSpigot 1.19, Spigot 1.20 and is expected to work on every versions in-between for most, if not all, forks of Spigot.
  • The ItemBuilder API should work for all versions of Bukkit/Spigot unless you use the ItemDataColor (or data value) which relies on pre-1.13 item data values. (Though you can just use the relevant Material instead - e.g., instead of using Material.WOOL and ItemDataColor.BLUE, just use Material.BLUE_WOOL.)

Installation

You can very easily install EGUI using JitPack. (The JitPack page contains instructions for Gradle, Maven, sbt, etc.)

Instructions for Gradle

Just add the following to your build.gradle file:

repositories {
    // ...
    maven { url 'https://jitpack.io' }
}

dependencies {
    // ...
    implementation 'fr.elias:EGUI:<insert latest version here>'
}

For distribution, you can just shade the library into your plugin JAR. On Gradle, this can be done by adding the following to the end of your build.gradle:

jar {
    duplicatesStrategy(DuplicatesStrategy.EXCLUDE)

    from {
        configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
    }
}

If you aren't using a build system, you can just download the latest JAR and add it to your project's classpath (just make sure the EGUI classes are included in your JAR when you build it).


Quick Start

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

class MyPlugin extends JavaPlugin {

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

Step 2: Use the library

public void openMyAwesomeMenu(Player player) {

  // Create a GUI with 3 rows (27 slots)
  SGMenu myAwesomeMenu = MyPlugin.EGUI.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!


About

My Custom GUI API

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages