Villager trade 1.8

Discussion in 'Plugin Development' started by Xhork, Sep 25, 2019.

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

    Xhork

    Hello i have some problems with my customs trades.... please help me if you can !

    EDIT: (the problem is that the inventory won't open)

    Here is the code:

    Code:
    @EventHandler
        public void onInteractPlayer(PlayerInteractEntityEvent ev) {
            Player p = ev.getPlayer();
            Entity ent = ev.getRightClicked();
            if (ent instanceof Villager) {
    
                if (ent.getCustomName().equalsIgnoreCase("§aTest")){
                    ev.setCancelled(true);
                    Inventory i = Bukkit.createInventory(null, InventoryType.MERCHANT, "Test");
                    i.clear();
                    i.addItem(new ItemStack(Material.DIAMOND, 10), new ItemStack(Material.EMERALD, 1));
                    p.openInventory(i);
    
                }
            }
        }
    thank you !
     
  2. Online

    timtower Administrator Administrator Moderator

    @Xhork Does the event fire?
    If you add debug lines do you see those?
     
  3. Offline

    Xhork

    i tried to put a p.sendMessage"§agood" after the lines of inventory and the message was sent so i don't understand, i also tried to put the inventory lines in a try / catch and no error, but nothing happen
     
  4. Offline

    Sir_Jonn

    How does your main class look like
     
  5. Offline

    Xhork

    first thank's for trying to help me :D and i only use the main class so i have 800+ lines.. And i really think it's just a bug, cause if i try to open a chest inventory, it works ! but not InventoryType.MERCHANT........ strange
     
  6. Online

    timtower Administrator Administrator Moderator

  7. Offline

    Xhork

  8. Online

    timtower Administrator Administrator Moderator

    Then I have no idea.
     
Thread Status:
Not open for further replies.

Share This Page