[API] AnvilApi - Supports 1.7 & 1.8 1.0.1

Use the Anvil GUI to retrieve Strings!

  1. PatoTheBest
    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
    [​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();

Recent Updates

  1. Added support for v1_8_R3

Recent Reviews

  1. EDMAN93
    EDMAN93
    5/5,
    Version: 1.0.1
    Works wonderful.
    I am going to include this API into my GlobalChestShop plugin.
    Thank you
  2. ZaNotHere
    ZaNotHere
    3/5,
    Version: 1.0.1
    This is a useful resource but it's just a copy of chasechocolates class. I mean you could atleast make it version independant by using reflection instead of copy-pasting the class for each version. :/
  3. iHolden
    iHolden
    1/5,
    Version: 1.0.1
    Your class does not work.. and this plugin/api could just be used by chasechocolate's class instead of downloading this..
    1. PatoTheBest
      Author's Response
      Please don't leave reviews if you are not sure, it does work, it has been tested and this is an updated version of chase's class. The purpose of NMS libraries are for developers not to be worried about the version breaking updates. When minecraft updates, it causes spigot to update their classes thus giving an ClassNotFoundError to plugins using NMS without reflection. Consider changing your review or contacting me for support. Please note that I do this for developers ease as a contribution and not as an obligation.
  4. Krumb069
    Krumb069
    5/5,
    Version: 1.0.1
    Great resource !