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

    Konato_K

  3. Offline

    Skionz

    @RRL213 Hm, too bad we can't magically read your mind and read those errors.
     
  4. Offline

    Unica

    @RRL213

    Do null checks for the InteractEntityEvent, because you probably right-click air and it will throw an NPE.

    Concerning your amount of double code; create a method with as Return type an itemstack object.

    Code:
    private ItemStack getItem(parameters){
        //Set options etc.
    }
    
    your menu method{
         inv.setItem(x, getIitem());
         //Not a ton of code
    }
     
  5. Offline

    RRL213

    Last edited by a moderator: Jun 13, 2016
  6. Offline

    Timbals

    Can you show US your code right now?
    Especially line 484?
     
  7. Offline

    RRL213

  8. Offline

    I'm Osama

    @RRL213 why add the else statement?
     
  9. Offline

    Skionz

  10. Offline

    Zombie_Striker

    From what I can tell, it's saying that the line that is causing the NullPointerException is the one where you check if the EntityType is a Villager. What are you doing when it throws the exception?

    Edit: this is all just guesswork. Post your entire class so that we can know for sure.
     
  11. Offline

    RRL213

  12. @RRL213
    1. cmd.getName().equalsIgnoreCase not commandLabel
    2. public final Logger logger = Logger.getLogger("Minecraft"); :( getLogger :)
    3. private static Plugin plugin; :eek: Here
    4. else if > if, if, if, if, if, if
     
  13. Offline

    SuchSwegMuchWow

    @RRL213

    Cancel the right click upon clicking the villager
     
  14. Offline

    RRL213

  15. Offline

    Skionz

    @RRL213 Post the entire class.
     
  16. Offline

    Gater12

    @RRL213
    inv1 is null. I never see a way you actually guarantee inv1 will be assigned. I suggest you make your "Page" methods (first follow naming conventions) return an Inventory, rather than set a variable.
     
  17. Offline

    RRL213

    @Skionz
    That is the whole class.
     
  18. Offline

    Skionz

    @RRL213 Including the package. I am not going to count and guess which line is throwing the error.
     
  19. Offline

    RRL213

  20. Offline

    Skionz

    @RRL213 And the corresponding stack-trace.
     
  21. Offline

    RRL213

  22. Offline

    ESSHD

    In your event, try Entity e = (Entity) e.getClicked()
    @RRL213
     
  23. Offline

    Skionz

  24. Offline

    RRL213

  25. Offline

    ESSHD

    @RRL213 Assign e.getClicked() as an entity in your event
     
  26. Offline

    RRL213

    @ESSHD Still throwing the same error?
     
  27. Offline

    RRL213

  28. Offline

    RRL213

  29. Offline

    RRL213

    Anyone?
     
  30. Offline

    Sw_aG

    I think the biggest inv is as double chest (not 64, I don't remember how space it have but for sure less than 64)


    And replace the villager check with:


    @EventHandler

    public void onVillagerClick(PlayerInteractEntityEvent e) {

    Player p = e.getPlayer();



    if(e.getRightClicked().getType() == VILLAGER) {

    if(e.getRightClicked().getCustomName().equals(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("VillagerName")))) {

    p.openInventory(inv);

    }

    }

    }
     
Thread Status:
Not open for further replies.

Share This Page