Solved Displaying a merchant inventory

Discussion in 'Plugin Development' started by Jogy34, May 23, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    Jogy34

    I am having a really hard time opening up a merchant inventory for the player. Currentl I'm doing this:
    Code:java
    1.  
    2. Player p = (Player) sender;
    3. CraftPlayer cp = (CraftPlayer) p;
    4. EntityPlayer ep = cp.getHandle();
    5. //ep.openTrade(new TreeProtoMerchant(), null);
    6. TreeProtoMerchant protoMerchant = new TreeProtoMerchant();
    7. ContainerMerchant cm = new ContainerMerchant(ep.inventory, protoMerchant, ep.world);
    8. //p.openInventory(cm.getBukkitView());
    9. //EntityVillager hold = new EntityVillager(ep.world);
    10. ep.openTrade(protoMerchant, "Tree Protocall");
    11. // p.openInventory(Bukkit.createInventory((InventoryHolder) new CraftVillager(new CraftServer(MinecraftServer.getServer(), MinecraftServer.getServer().getPlayerList()), hold), InventoryType.MERCHANT));
    12. //ep.activeContainer = cm;
    13. //ep.openTrade(protoMerchant, "Tree Protocall");
    14. //ep.setContainerData(cm, 100, 100);
    15. //ep.syncInventory();
    16.  

    Everything in the comments is everything I've tried already and everything not in the comments is just the last thing I tried. None of this has worked.

    TreeProtoMerchant is a class that implements IMerchant

    Anyone have any ideas. Sorry that the code isn't really organized. I'm currently just using a command to simulate this and I've just been putting stuff in as I find something else to try.
     
  2. Offline

    Minnymin3

    Did you actually solve this? If not then you must set the player entity to the merchant player then open the trade.
    Code:java
    1.  
    2.  
    3. private transient EntityHuman c;
    4.  
    5. public void openTrading(EntityPlayer player, String name) {
    6. this.c = player;
    7. this.c.openTrade(this, name);
    8.  
    9. }
    10.  
     
  3. Offline

    Jogy34

    Yea, I solved this in one of my other threads. That wasn't my problem though. It was that I had the m_() method of my class that implemented IMerchant return null instead of the player.
     
  4. Offline

    Minnymin3

    Ah that'l do it. I just finished up my IMerchant for upgrading custom items.
     
  5. Offline

    Jogy34

    I'm currently trying to get mine to only accept the needed item taking into account metadata. For some reason though the event.setCanceled() method won't cancel the inventory click event.
     
  6. Offline

    Minnymin3

    Make sure the event is firing
     
  7. Offline

    Jogy34

    It is and it's getting all the way through where I check the ItemStack that was place in the box against the ItemStack that is in the MerchantRecipe but the event is never canceled when I set it to be canceled.
     
Thread Status:
Not open for further replies.

Share This Page