Open menu on Villager click

Discussion in 'Plugin Help/Development/Requests' started by RRL213, Feb 12, 2015.

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

    RRL213

  2. Offline

    Justinian6

    @RRL213 The issue is that the name is null

    Make sure the villager has a custom name (The one the user should have set in the config)
     
    Last edited: Feb 20, 2015
  3. Offline

    RRL213

  4. Offline

    Sw_aG

    Probably 'cause the code is correct but not for your request, check if you've wrote the villager name correct.
     
  5. Offline

    RRL213

    Sorry to sound newbish but how would I do that? xD
    @Sw_aG
     
  6. Offline

    Sw_aG

    Don't worry, espicially from me, I was very noobie myself few months ago (Still not a pro but I'm a'ight).

    What's the exact name of your villager? (That's what you need to put within the code1 that checking the villager name).

    Sorry if I misspelled or right incorrect I wrote this comment from my phone.
     
  7. Offline

    RRL213

  8. Offline

    Sw_aG

    Can you send me the whole plugin file?
     
  9. Offline

    RRL213

  10. Offline

    RRL213

  11. Offline

    RRL213

    Anyone? This issue still isn't resolved.

    I'll be offering a reward for anyone who can resolve this. It's been going on for over a week and I need it fixed.

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

    RRL213

  13. Offline

    metmad22

    @RRL213 I didn't fully look at the code, but if you want an inventory to open when clicking a villager, use this. Tested and works with no errors.

    Code:
        @EventHandler
        public void onChestGUI(PlayerInteractEntityEvent event)
        {
            Player player = event.getPlayer();
            EntityType villager = EntityType.VILLAGER;
    
            if(event.getRightClicked().getType() == villager)
            {
                Inventory inventory = Bukkit.getServer().createInventory(player, InventoryType.CHEST, "            §4§l[This is a random title]");
                player.openInventory(inventory);
            }
            else
            {
                event.setCancelled(true);
                return;
            }
        }
    This would open a basic empty inventory. If your villager has a custom name, you can add your previous line to this code to open it. This should help you with what you need. Feel free to modify it to your needs.
     
  14. Offline

    RRL213

    Thank you so much! I'll pm you so we can work out some sort of thank you gift :)
    @metmad22
     
Thread Status:
Not open for further replies.

Share This Page