Home›Java›Mods›[API] AnvilApi - Supports 1.7 & 1.8
AnvilApi

Description

First of all, thanks to chasechocolate for the original class, this plugin uses the class with modifications to support all versions from 1.7 and 1.8. This plugin allows you to show the Anvil GUI to any player and retrieve the string they inputted.

Pictures from a project testing it
Spoiler: Images
[​IMG]
[​IMG]
[​IMG]

API
NOTICE: Do not forget to add depend: [AnvilApi] or softpdepend: [AnvilApi] in your plugin.yml!
The above project was accomplished by these few lines of code
PHP:
        AnvilGUIInterface gui = AnvilApi .createNewGUI (player , new AnvilClickEventHandler ( ) { [ /B ] [ /B ]
[B ] [B ]         @Override
        public void onAnvilClick (final AnvilClickEvent event ) {
            if (event .getSlot ( ) == AnvilSlot .OUTPUT ) {
                event .setWillClose ( true ) ;
                event .setWillDestroy ( true ) ;
                ItemStack item = items .get (event .getPlayerName ( ) ) ;
                ItemMeta itemMeta = item .getItemMeta ( ) ;
                itemMeta .setDisplayName (event .getName ( ) .replace ( "&" , "§" ) ) ;
                item .setItemMeta (itemMeta ) ;
                Bukkit .getPlayer (event .getPlayerName ( ) ) .setItemInHand (item ) ;
                items .remove (event .getPlayerName ( ) ) ;
                return ;
            } else {
                event .setWillClose ( true ) ;
                event .setWillDestroy ( true ) ;
                Bukkit .getPlayer (event .getPlayerName ( ) ) .setItemInHand (items .get (event .getPlayerName ( ) ) ) ;
                items .remove (event .getPlayerName ( ) ) ;
                return ;
            }
        }
        } ) ;
        gui .setSlot (AnvilSlot .INPUT_LEFT , player .getItemInHand ( ) ) ;
        items .put (player .getName ( ) , player .getItemInHand ( ) ) ;
        player .closeInventory ( ) ;
        player .setItemInHand ( null ) ;
        gui .open ( ) ;
Quick facts

Install steps are the general flow for this file type — How to install Minecraft Java mods & modpacks walks through it step by step.

[API] AnvilApi - Supports 1.7 & 1.8 is a free Minecraft Java mod. Downloaded 1,089 times (via Spigot). Download it and open it directly in the game.

Explore more