BrewingAPI...Possibly?

Discussion in 'Plugin Development' started by Madster456, Nov 16, 2012.

Thread Status:
Not open for further replies.
  1. Hey guys! So i'm working on a plugin that allows players to access portable enchanting, chests, workbench, brewingStand, and anvil.

    I got enchanting, chests, and workbench to work. But cant seem to find out how to open the UI for brewingStands or anvils.

    For the other three, I used this to open them:

    Code:
    if (player.hasPermission("PEnchant.enchant"))
                        {
                            player.openEnchanting(null, true);
                           
                            succeed = true;
    Thats obviously just a glimps at the code. But like I said before, I can't seem to get it to work with brewingstands and anvils.
    Has someone made a brewingstandAPI or anvilAPI by any chance? or would know how to open the UI's?
     
  2. Offline

    leiger

    Because it's so soon after the 1.4 release, it's most likely that no such API exists yet.
     
  3. Even for brewing stands? That was released back in 1.3

    I mean, im sure vault might have some API choices I could look into for the things I need.
     
  4. Offline

    leiger

    I saw "anvil" and glossed over the mention of Brewing Stands, sorry.

    A brewing stand API is available, but I'm not entirely sure if it can do what you want. Perhaps ask the Portables developers if they found a way to achieve the same thing (it's listed as a potential future update for that plugin).
     
  5. Thanks. I will get into contact with them. It did confuse me for a moment on why bukkit would not have a API for brewing stands. Thanks again for the references.

    ~Madster
     
  6. Offline

    leiger

    Good luck.

    Let us know here if you achieve it, and how. Others may be searching for the same thing and will end up here.
     
  7. Offline

    Sagacious_Zed Bukkit Docs

    player's openInventory method should allow you to open a BrewerInventory.
     
  8. Offline

    SnowGears

    Do something like this:
    player.openInventory(AnvilInventory);

    Although the parameters take an inventoryView, not an inventoryType, you can probably get this to work if you play around with it a bit.
     
  9. Still pondering about this..
     
  10. Offline

    Comphenix

    It seems to be relatively straight forward, provided that you reference CraftBukkit:
    Code:java
    1. public class ExampleMod extends JavaPlugin implements Listener {
    2.  
    3. @Override
    4. public void onEnable() {
    5. getServer().getPluginManager().registerEvents(this, this);
    6. }
    7.  
    8. @EventHandler
    9. public void onCustomBrewingClick(InventoryClickEvent event) {
    10. Inventory inventory = event.getInventory();
    11. HumanEntity entity = event.getWhoClicked();
    12.  
    13. // Simple handler
    14. if (inventory instanceof CraftInventoryCustom && inventory.getType() == InventoryType.BREWING) {
    15. if (entity instanceof Player) {
    16. ((Player) entity).sendMessage(String.format("You put a %s in slot %s.",
    17. event.getCurrentItem(), event.getSlot()));
    18. }
    19. }
    20. }
    21.  
    22. private void performAction(Player player) {
    23. Inventory brewingInventory = new CraftInventoryCustom(player, InventoryType.BREWING);
    24. player.openInventory(brewingInventory);
    25. }
    26.  
    27. private void performAction(CommandSender sender) {
    28. sender.sendMessage("Cannot perform command for console!");
    29. }
    30.  
    31. @Override
    32. public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    33. if (args.length > 0) {
    34. sender.sendMessage("This command doesn't accept any arguments.");
    35. return true;
    36. }
    37.  
    38. if (label.equalsIgnoreCase("performaction")) {
    39. if (sender instanceof Player)
    40. performAction((Player) sender);
    41. else
    42. performAction(sender);
    43. return true;
    44. }
    45.  
    46. return false;
    47. }
    48. }
     
Thread Status:
Not open for further replies.

Share This Page