{"id":13407790,"url":"https://github.com/Incendo/interfaces","last_synced_at":"2025-03-14T12:31:33.797Z","repository":{"id":41970475,"uuid":"379697702","full_name":"Incendo/interfaces","owner":"Incendo","description":"A Java user-interface library with support for Minecraft.","archived":false,"fork":false,"pushed_at":"2024-09-22T18:55:09.000Z","size":895,"stargazers_count":94,"open_issues_count":9,"forks_count":16,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-11T07:32:51.135Z","etag":null,"topics":["bukkit","hacktoberfest","interface","minecraft","paper","spigot","ui","user","user-interface"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Incendo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-06-23T18:36:34.000Z","updated_at":"2025-02-04T16:31:54.000Z","dependencies_parsed_at":"2022-09-10T12:20:57.377Z","dependency_job_id":"7ee9519e-dfe4-4569-811c-2b58c69fa292","html_url":"https://github.com/Incendo/interfaces","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Incendo%2Finterfaces","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Incendo%2Finterfaces/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Incendo%2Finterfaces/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Incendo%2Finterfaces/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Incendo","download_url":"https://codeload.github.com/Incendo/interfaces/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243578042,"owners_count":20313743,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bukkit","hacktoberfest","interface","minecraft","paper","spigot","ui","user","user-interface"],"created_at":"2024-07-30T20:00:48.667Z","updated_at":"2025-03-14T12:31:33.188Z","avatar_url":"https://github.com/Incendo.png","language":"Java","funding_links":[],"categories":["Inventories"],"sub_categories":[],"readme":"# `interfaces`\n\n_Building interfaces since 2021._\n\n`interfaces` is a builder-style user interface library designed to make creation of flexible user interfaces as easy as possible.\n\n\u003e 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`.\n\n## Packages\n\n[`interfaces-core`](https://github.com/Incendo/interfaces/tree/master/core) provides the core API classes.\n\n[`interfaces-paper`](https://github.com/Incendo/interfaces/tree/master/paper) implements `interfaces` using the [Paper Minecraft server API](https://papermc.io). This package \nprovides the\ncapability to construct a variety of Minecraft-based interfaces, including text, inventory (i.e. chests), and books.\n\n## Terminology\n\n#### Interface\n\nAn interface is the main class that you'll be interacting with. Interfaces hold a series of transformations and other values that\ncan be used to construct an InterfaceView.\n\n#### InterfaceView (\"view\")\n\nAn InterfaceView represents a 'rendered' interface. An InterfaceView holds one pane and one InterfaceViewer.\n\n#### InterfaceViewer (\"viewer\")\n\nAn InterfaceViewer represents an object that can view an interface. InterfaceViewers are provided panes to view.\n\n#### Pane\n\nA pane holds a collection of elements that make up the visual aspect of an interface.\n\n#### Transform\n\nA transformation (\"transform\") operates on a type of pane to add, remove, or change elements. Transformations are used to interact\nwith panes.\n\n## Usage\n\nSnapshots of this repository are hosted at https://oss.sonatype.org/content/repositories/snapshots/.\n\nGradle example:\n\n```kotlin\nrepositories() {\n    // ...\n    maven(\"https://oss.sonatype.org/content/repositories/snapshots/\")\n    // ...\n}\n\ndependencies() {\n    implementation(\"org.incendo.interfaces:interfaces-{package}:1.0.0-SNAPSHOT\")\n}\n```\n\n## Examples\n\n\u003cdetails open\u003e\n\u003csummary\u003eCreating an interface\u003c/summary\u003e\n\nThis code creates a chest interface with one row, a background fill, an ItemStackElement containing information about the \nplayer, and utilizes an argument provider. This element also tracks how many times it has been clicked. \n\n```java\nChestInterface infoInterface = ChestInterface.builder()\n    // This interface will have one row.\n    .rows(1)\n    // This interface will update every five ticks.\n    .updates(true, 5)\n    // Cancel all inventory click events\n    .clickHandler(ClickHandler.cancel())\n    // Fill the background with black stained glass panes\n    .addTransform(PaperTransform.chestFill(\n    ItemStackElement.of(new ItemStack(Material.BLACK_STAINED_GLASS_PANE))\n    ))\n    // Add some information to the pane\n    .addTransform((pane, view) -\u003e {\n        // Get the view arguments\n        // (Keep in mind - these arguments may be coming from a Supplier, so their values can change!)\n        final String time = view.arguments().get(ArgumentKey.of(\"time\", String.class));\n        final Player player = view.arguments().get(ArgumentKey.of(\"player\", Player.class));\n        final Integer clicks = view.arguments().get(ArgumentKey.of(\"clicks\", Integer.class));\n\n        ItemStack itemStack = new ItemStack(Material.PAPER);\n        ItemMeta itemMeta = itemStack.getItemMeta();\n\n        itemMeta.displayName(Component.text(\"Item Name\", NamedTextColor.GREEN));\n        ArrayList\u003cComponent\u003e lore = new ArrayList\u003c\u003e();\n        lore.add(Component.text(\"Line 1\"));\n        lore.add(Component.text(\"Clicks: \" + clicks));\n        itemMeta.lore(lore);\n        itemStack.setItemMeta(itemMeta);\n\n        // Return a pane with\n        return pane.element(ItemStackElement.of(itemStack,\n        // Handle click\n        (clickHandler) -\u003e {\n            final HashMapInterfaceArguments arguments = HashMapInterfaceArguments\n                .with(ArgumentKey.of(\"clicks\", Integer.class), (clickHandler.view().arguments().get(ArgumentKey.of(\"clicks\", Integer.class))) + 1)\n                .with(ArgumentKey.of(\"player\", Player.class), clickHandler.view().arguments().get(ArgumentKey.of(\"player\", Player.class))).build();\n\n            clickHandler.view().backing().open(clickHandler.viewer(), arguments);\n        }\n    ), 4, 0);\n    })\n    // Set the title\n    .title(Component.text(\"interfaces demo\"))\n    // Build the interface\n    .build();\n```\n\u003c/details\u003e\n\n\u003cdetails open\u003e\n\u003csummary\u003eShowing the interface to a player\u003c/summary\u003e\n\nThis code shows the interface created in the previous example being shown to a viewer.\nAs the interface uses arguments, we can pass in supplier functions to the interface argument.\n\n```java\n// Open the interface to the player.\ninfoInterface.open(PlayerViewer.of(player),\n    // Create a HashMapInterfaceArgument with a time argument set to a\n    // supplier that returns the current time printed all nice and pretty.\n    HashMapInterfaceArguments\n        .with(ArgumentKey.of(\"player\", Player.class), player)\n        .with(ArgumentKey.of(\"time\", String.class), () -\u003e {\n            DateTimeFormatter dtf = DateTimeFormatter.ofPattern(\"yyyy/MM/dd HH:mm:ss\");\n            LocalDateTime now = LocalDateTime.now();\n            return dtf.format(now);\n            })\n        .with(ArgumentKey.of(\"clicks\", Integer.class), 0).build()\n);\n```\n\n[Video of the result of this code in Minecraft](https://imgur.com/a/JPdJPvX).\n\u003c/details\u003e\n\n_Note: these examples may not reflect the latest version of the `interfaces` API._\n\nFurther examples can be found here: https://github.com/Incendo/interfaces/tree/master/examples\n\n## Credits\n\nThanks to [kyori](https://github.com/kyoripowered) and their [`adventure` text library](https://github.com/kyoripowered/adventure).\n\nThanks to [broccolai](https://github.com/broccolai) for letting me steal his entire Gradle project setup.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FIncendo%2Finterfaces","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FIncendo%2Finterfaces","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FIncendo%2Finterfaces/lists"}