Solved Custom Helmet

Discussion in 'Plugin Development' started by Random_Tomato, Jul 13, 2016.

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

    Random_Tomato

    Hey, I am new to plugin development and I ran into a bit of a problem. I am trying to set leaves as a helmet through an inventory and it does not seem to be working, if anyone could help it would be much appreciated!
    (It works with vanilla helmet types but refuses to work when I set it as leaves)
    :D

    @EventHandler
    public void onInventoryClick(InventoryClickEvent event) {
    Inventory inv = event.getInventory();
    if(!(event.getWhoClicked() instanceof Player))
    return;

    if(!inv.getTitle().equals("Hats"))
    return;

    Player player = (Player) event.getWhoClicked();
    PlayerInventory inventory = player.getInventory();
    ItemStack item = event.getCurrentItem();
    ItemStack redstoneTorch = new ItemStack (Material.LEAVES);
    redstoneTorch.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);

    if(item.getType() == Material.REDSTONE_TORCH_ON) {
    player.sendMessage(ChatColor.RED + "You have been teleported to the spawn!");
    inventory.setHelmet(redstoneTorch);
    }
    event.setCancelled(true);
    player.closeInventory();

    }
    }

    -Random
     
  2. Offline

    Tecno_Wizard

    @Random_Tomato
    Correct me if i'm wrong everyone, but I don't think the API allows that.
     
  3. Offline

    ChipDev

  4. Offline

    Random_Tomato

    @Tecno_Wizard & @ChipDev
    Thanks for the help!

    I have located the problem, I removed this line and everything worked smoothly
    redstoneTorch.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
     
Thread Status:
Not open for further replies.

Share This Page