Setting Hats

Discussion in 'Plugin Development' started by Legocowchaser, Nov 23, 2013.

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

    Legocowchaser

    Hello I am trying to make a plugin dealing with hats. Here is part of my code. Am I doing this right?

    Code:
        @EventHandler
        public void onInventoryClick(InventoryClickEvent event) {
            Player player = (Player) event.getWhoClicked();
            ItemStack clicked = event.getCurrentItem();
            player.getInventory().setHelmet(clicked);
     
  2. Offline

    The Fancy Whale

    You want any block they click to become a hat?
     
  3. Offline

    Legocowchaser

  4. Offline

    The Fancy Whale

    That looks good to me
     
  5. Offline

    mydeblob

    Legocowchaser
    Have you tried testing it? If so what's wrong with it?
     
  6. Offline

    Legocowchaser

    The Fancy Whale mydeblob I am almost positive I tested it and the inventory worked ut not setting the hat when they clicked an item. Anyways I think the problem might be I was testing it on 1.7.2 not 1.6.4 because the build path is for 1.6.2. But I can not test it at the moment because I think either I am having problems or Mojang is because it I can not connect to any servers at the moment.
     
  7. Offline

    JRL1004

    Legocowchaser Did you update the player's inventory after setting the hat?
     
  8. Offline

    Legocowchaser

  9. Offline

    SourceForums

  10. Offline

    Legocowchaser

    SourceForums Thanks I will try this.

    SourceForums Where would I add that? When I add it to a spot it says it is deprecated.

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

    xTrollxDudex

    Legocowchaser
    It's a deprecated method. Lots of people still use it though
     
  12. Offline

    Legocowchaser

  13. Offline

    Commander9292

    Legocowchaser Yes, by the way.. If that's your actual code it's going to give you lots of errors if the users don't do exactly what you stated.
     
  14. Offline

    Legocowchaser

  15. Offline

    SourceForums

    Legocowchaser
    Mark this thread as solved if everything's fixed. :D
     
  16. Offline

    Legocowchaser

    SourceForums I did not really get it working. I am going to watch a video right and maybe that will help? Thanks for the reminder though I probably would forget.
     
  17. Offline

    hubeb

    Legocowchaser
    the helmet item needs to be an itemstack.
    Code:java
    1. ItemStack is = new ItemStack(Material.DIAMOND_BLOCK,1);
    2. player.getInventory().setHelmet(is);
     
Thread Status:
Not open for further replies.

Share This Page