Villager Shops

Discussion in 'Plugin Development' started by King_Amun_Ra, Dec 30, 2013.

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

    King_Amun_Ra

    Making a plugin so I can right click a villager in a certain world and then it opens a inventory. Is there a way I can cancel the villager's's trade like the item trading also is there a way I can get the villager's name like if I name it with a name tag??


    Current Code:
    Code:
    public class main extends JavaPlugin implements Listener {
     
            private Menu menu;
         
            public void onEnable() {
                    menu = new Menu(this);
                    Bukkit.getServer().getPluginManager().registerEvents(this, this);
            }
         
            @EventHandler
            public void onPlayerInteract(PlayerInteractEntityEvent e) {
               
                if (!(e.getRightClicked().getType() == EntityType.VILLAGER)) return;
                if (!(e.getRightClicked().getLocation().getWorld().getName().equalsIgnoreCase("empty2"))) return;
               
                    menu.show(e.getPlayer());
            }
    }
    The menu is working fine so not putting that in.
     
  2. Offline

    lukewizzy

    I'm confused why you're using:
    Code:java
    1. menu.show(e.getPlayer());

    Surely the inventory has a static name?
     
  3. Offline

    King_Amun_Ra

    No I just made a custom inventory and showing the player it. I have more stuff in the menu.class but that's not what I need that works it's just when I rightclick a villager there default trade comes up I need to cancel that anyone know how??

    Can anyone help??

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 6, 2016
  4. Offline

    Garris0n

    event.setCancelled(true)?
     
  5. Offline

    King_Amun_Ra

    garrison no on a villager trade is there a even for that?
     
  6. Offline

    Jordymt


    Yes, but there is on the right click/interact event :)
     
  7. Offline

    King_Amun_Ra

    Jordymt
    If I use the right click event then cancle it then the plugin wouldn't run because its on a right click of a villgager. I just need to disable villager trades in a world or cancle the villagers trade for that signal villager
     
  8. Offline

    Jordymt


    Oh didn't know you ment that, this should work:
    https://forums.bukkit.org/threads/canceling-villager-trade.155615/
     
  9. Offline

    King_Amun_Ra

Thread Status:
Not open for further replies.

Share This Page