A Java user-interface library with support for Minecraft.

Overview

interfaces

Building interfaces since 2021.

interfaces is a builder-style user interface library designed to make creation of flexible user interfaces as easy as possible.

This library is currently in a state of constant breaking changes. The API has yet to be finalized, so please keep this in mind when considering using interfaces.

Packages

interfaces-core provides the core API classes.

interfaces-paper implements interfaces using the Paper Minecraft server API. This package provides the capability to construct a variety of Minecraft-based interfaces, including text, inventory (i.e. chests), and books.

Terminology

Interface

An interface is the main class that you'll be interacting with. Interfaces hold a series of transformations and other values that can be used to construct an InterfaceView.

InterfaceView ("view")

An InterfaceView represents a 'rendered' interface. An InterfaceView holds one pane and one InterfaceViewer.

InterfaceViewer ("viewer")

An InterfaceViewer represents an object that can view an interface. InterfaceViewers are provided panes to view.

Pane

A pane holds a collection of elements that make up the visual aspect of an interface.

Transform

A transformation ("transform") operates on a type of pane to add, remove, or change elements. Transformations are used to interact with panes.

Usage

Usage

Snapshots of this repository are hosted at https://repo.incendo.org/content/repositories/snapshots/.

Gradle example:

repositories() {
    // ...
    maven("https://repo.incendo.org/content/repositories/snapshots/")
    // ...
}

dependencies() {
    implementation("org.incendo.interfaces:interfaces-{package}:1.0.0-SNAPSHOT")
}

Examples

Creating an interface

This code creates a chest interface with one row, a background fill, an ItemStackElement containing information about the player, and utilizes an argument provider. This element also tracks how many times it has been clicked.

ChestInterface infoInterface = ChestInterface.builder()
    // This interface will have one row.
    .rows(1)
    // This interface will update every five ticks.
    .updates(true, 5)
    // Cancel all inventory click events
    .topClickHandler(ClickHandler.cancel())
    // Fill the background with black stained glass panes
    .addTransform(PaperTransform.chestFill(
        ItemStackElement.of(new ItemStack(Material.BLACK_STAINED_GLASS_PANE))
    ))
    // Add some information to the pane
    .addTransform((pane, view) -> {
        // Get the view arguments
        // (Keep in mind - these arguments may be coming from a Supplier, so their values can change!)
        final @NonNull String time = view.argument().get("time");
        final @NonNull Player player = view.argument().get("player");

        // Return a pane with 
        return pane.element(ItemStackElement.of(PaperItemBuilder.paper(Material.PAPER)
            // Add icon name
            .name(Component.text()
                .append(player.displayName())
                .append(Component.text("'s info"))
                .decoration(TextDecoration.ITALIC, false)
                .asComponent())
            // Add icon lore
            .loreComponents(
                Component.text()
                    .append(Component.text("Current time: "))
                    .append(Component.text(time))
                    .color(NamedTextColor.GRAY)
                    .decoration(TextDecoration.ITALIC, false)
                    .asComponent(),
                Component.text()
                    .append(Component.text("Health: "))
                    .append(Component.text(Double.toString(player.getHealth())))
                    .color(NamedTextColor.GRAY)
                    .decoration(TextDecoration.ITALIC, false)
                    .asComponent())
                    .build(),
                // Handle click
                (clickEvent, clickView) -> {
                    final @NonNull InterfaceArgument argument = clickView.argument();
                    argument.set("clicks", ((Integer) argument.get("clicks")) + 1);
                    clickView.parent().open(clickView.viewer(), argument);
                }
            ), 4, 0);
        })
        // Set the title
        .title(Component.text("interfaces demo"))
        // Build the interface
        .build();
Showing the interface to a player

This code shows the interface created in the previous example being shown to a viewer. As the interface uses arguments, we can pass in supplier functions to the interface argument.

// Open the interface to the player.
infoInterface.open(PlayerViewer.of(player),
    // Create a HashMapInterfaceArgument with a time argument set to a
    // supplier that returns the current time printed all nice and pretty.
    HashMapInterfaceArgument.with("time", () -> {
        DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss");
        LocalDateTime now = LocalDateTime.now();
        return dtf.format(now);
    })
        .with("clicks", 0)
        .build()
);

Video of the result of this code in Minecraft.

Note: these examples may not reflect the latest version of the interfaces API.

Credits

Thanks to kyori and their adventure text library.

Thanks to broccolai for letting me steal his entire Gradle project setup.

Comments
  • Improve click handling API

    Improve click handling API

    This PR aims to improve the click handling API in interfaces. For now I'm leaving everything in the paper package, but when this PR is starting to be finalized I think it will be a good idea to move (what we can of) the click handling to the core package.

    opened by kadenscott 2
  • feature: children interfaces

    feature: children interfaces

    General idea is that this would allow users to easily implement back buttons for complex menu systems.

    My rough image for it would be that you could call Interface#openChild or something similar and then a Interface#back method or a special Element that would put the viewer up one interface.

    enhancement 
    opened by broccolai 1
  • fix: Don't allow/handle elements outside the bounds of a ChestPane

    fix: Don't allow/handle elements outside the bounds of a ChestPane

    • Moves all chest click event handling inside a method to ensure that clicks outside of a chest pane aren't handled by the chest pane.
    • Throws an exception if an element that would be null is attempted to be accessed from a chest pane.

    This PR fixes #51.

    opened by kezz 0
  • Misc. Changes

    Misc. Changes

    • Add interact() to Click
    • Switch click context over from a cancellation boolean to a status enum
    • allow for "chained" click handlers
    • update the example plugin
    opened by Citymonstret 0
  • bug: `ChestPanes` are causing pain

    bug: `ChestPanes` are causing pain

    Opening a ChestPane still allows for some weird behaviour, such as:

    • Items in the hot bar can be moved about at will
    • Items in the inventory section can be shift-clicked into the chest
    • When the items go in the chest, they become part of the pane and throw exceptions once clicked
    • Items in the player inventory throw exceptions when clicked

    Making ChestPane return an empty ItemStackElement when an element is not found fixes some of these issues, but it doesn't solve the root problem which is that ChestPane is allowing (or handling, or not doing something idk) clicks that aren't in the chest.

    opened by kezz 0
  • Update outdated readme

    Update outdated readme

    The current readme examples do not compile and need other libraries to work (which aren't even disclosed),

    I updated it to make it work with the latest version. Should be a lot easier for newbies to get started with interfaces now,

    opened by AlessioGr 0
  • Can modify chest interfaces

    Can modify chest interfaces

    I'm using interfaces to give a shop preview, but using shift-click on items in the player inventory results in the items getting placed in the chest interface.

    ChestInterface.Builder builder = ChestInterface.builder()
                    .rows(6)
                    .clickHandler(ClickHandler.cancel())
                    .addTransform(PaperTransform.chestFill(
                            ItemStackElement.of(new ItemStack(Material.BLACK_STAINED_GLASS_PANE))))
                    .title(Component.text("Shop preview"))
                    .addTransform((pane, view) ->
                            pane.element(ItemStackElement.of(new ItemStack(Material.STONE)), 0,0));
    
                    builder.build().open(PlayerViewer.of(player));
    

    JM25rv3qxY

    Attempting to merge the stacks with spam clicking also works sometimes.

    The listener is registered:

    getServer().getPluginManager().registerEvents(new PaperInterfaceListeners(this), this);
    
    opened by Artuto 0
  • feature: more inventory types

    feature: more inventory types

    These are unusual inventory types that are not handled in other libraries, but support for the enchantment table (custom buttons?), cartography table (custom map view), donkey, mule, etc. would be nice.

    opened by thiccaxe 0
  • feature: chat interface

    feature: chat interface

    Chat interfaces would allow interfaces to be rendered to a Minecraft client's chat view. The interface

    Using clickable command chat components, we can create system which maps a command with a unique argument to a view's click handler, and execute that handler when the command is ran.

    enhancement 
    opened by kadenscott 0
Owner
Incendo
we create free open source software ~ walmart kyori
Incendo
Minecraft mod - Adds more support for keyboard navigation in GUI screens!

UseKeyboardWithMenu Client-sided mod that adds more support for keyboard navigation in GUI screens! ?? Table of Contents About Authors ?? About UseKey

ZimonIsHim 3 Apr 26, 2022
A Minecraft server proxy with unparalleled server support, scalability, and flexibility

Velocity A Minecraft server proxy with unparalleled server support, scalability, and flexibility. Velocity is licensed under the GPLv3 license. Goals

PaperMC 1.2k Jan 8, 2023
Prevent your mods being stolen onto 9minecraft and other reposting sites! Forces the user to download from curseforge, modrinth or a trusted site.

Prevent users from downloading your mods from reposting sites or malicious providers. Powered by the reposting site list from StopModReposts Important

i-am-cal 17 Sep 26, 2021
Prevent your mods being stolen onto 9minecraft and other reposting sites! Redirects the user to download from curseforge, modrinth or a trusted site.

Prevent users from downloading your mods from reposting sites or malicious providers. Powered by the reposting site list from StopModReposts Important

cal6541 17 Sep 26, 2021
A simple, lightweight, safe way to show your user's Spotify now playing in game

Spigotify A simple, lightweight, safe way to show your user's Spotify now playing in game! Installation Install PlaceholderAPI. Install Spigotify Add

Mufin 2 Mar 14, 2022
Duck Library is a library for developers who don't want to spend their time to write same library consistently.

Duck Library is a library for developers who don't want to spend their time to write same library consistently. It has almost every useful feature to

null 5 Jul 28, 2022
A mixin based ghost client for Minecraft 1.8.9 built on Minecraft Forge.

A mixin based ghost client for Minecraft 1.8.9 built on Minecraft Forge. Originally designed as a MCP Client (called Tephra), it is now being ported t

Peanut 130 Jan 1, 2023
An efficient map viewer for Minecraft seed in a nice GUI with utilities without ever needing to install Minecraft.

To download it head to the Releases section. To run it: either double click it on it if you have the Java Runtime (JRE) or use the command line (shift

Neil 127 Dec 24, 2022
A free mixin-based injection hacked-client for Minecraft using Minecraft Forge.

Custom LiquidBounce 1.8.9 build that aims to improve original visuals and bypasses, along with built-in ViaVersion to help you change from 1.8 to 1.17.1 without creating any other version branch.

epic group of paster 123 Jan 2, 2023
Small mod for Minecraft Forge 1.16.5 that sends messages of in-game events to a channel in your Discord server. This mod also enables cross-chatting between Minecraft and Discord.

DiscordSync Small mod for Minecraft Forge 1.16.5 that sends messages of in-game events to a channel in your Discord server. This mod also enables cros

AeonLucid 4 Dec 20, 2022
Minecraft Utility Mod for the latest release of Minecraft developed by Cypphi.

Minecraft Utility Mod for the latest release of Minecraft developed by Cypphi.

Haze 18 Jan 1, 2023
Play snake, in minecraft. This is a crude, horibly made snake in minecraft game. Requires PaperMC 1.18.2.

MinecraftSnake Play snake, in minecraft. This is a crude, horibly made snake in minecraft game. Requires PaperMC 1.18.2. Installation: Create a paperm

null 1 Sep 30, 2022
A library that provide informations for minecraft servers (players, maxplayers and motd)

MinecraftServerInformations MinecraftServerInformation is a java library for retrieving informations about Minecraft Servers. Installation Download th

null 10 Sep 11, 2022
Arnicalib-mcmod - Shared library for AH's Minecraft mods.

ArnicaLib Shared library for AH's Minecraft mods. For Developers There are two ways to use this mod in your workspace: GitHub Package (Recommended) Ad

null 5 Dec 15, 2022
TerraBlender is a library mod for adding biomes in a simple and compatible manner with Minecraft's new biome/terrain system.

https://discord.gg/GyyzU6T TerraBlender is a library mod for adding biomes in a simple and compatible manner with Minecraft's new biome/terrain system

Glitchfiend 31 Dec 12, 2022
A fast, customizable and compatible open source server for Minecraft: Java Edition

Glowstone A fast, customizable and compatible open source server for Minecraft: Java Edition. Introduction Glowstone is a lightweight, from scratch, o

Glowstone Project 1.7k Dec 31, 2022
A Minecraft Java mod that adds 48 pieces of functional, decorative and unique furniture that fit with the vanilla style.

FurniDeco ( ?? WIP) FurniDeco adds 25 pieces of functional, decorative and unique-looking furniture that fit with the vanilla style. With more than 80

Arexon 2 Jul 3, 2022
Minecraft plugins with Java.

Minecraft plugins with Java.

null 2 Feb 22, 2022