Inability to set ItemMeta to Firework when right clicked

Discussion in 'Plugin Development' started by Drkmaster83, Dec 7, 2013.

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

    Drkmaster83

    Code:
    Code:
    @EventHandler
    public void onPlayerInteract(PlayerInteractEvent event)
    {
    Player player = (Player) event.getPlayer();
    if(event.getAction().equals(Action.RIGHT_CLICK_AIR) || event.getAction().equals(Action.RIGHT_CLICK_BLOCK))
    {
                if(player.getItemInHand().getType().equals(Material.FIREWORK))
    {
    if(player.getItemInHand().getItemMeta().getDisplayName().contains("Enabled"))
    {
    ItemStack firework = new ItemStack(Material.FIREWORK);
    FireworkMeta fm = (FireworkMeta) firework.getItemMeta();
    fm.setDisplayName("&6Launcher - &cDisabled");
    fm.setLore(Arrays.asList("§aRight click on the firework", "§ato enable the Launcher game!"));
    firework.setItemMeta(fm);
    }
    if(player.getItemInHand().getItemMeta().getDisplayName().contains("Disabled"))
                            {
                                    plugin.editItem(player.getInventory().getItemInHand(), "&6Launcher - &aEnabled", Arrays.asList("§aHit someone with the firework", "§ato launch them into the air!"));
    event.setCancelled(true);
    event.setUseItemInHand(Result.DENY);
    }
             }
     
    editItem() Method:
     
    public void editItem(ItemStack is, String name, List<String> lore)
    {
    ItemMeta im = is.getItemMeta();
    im.setDisplayName(name.replaceAll("(&([0-9a-fk-orA-FK-OR]))", "\u00A7$2"));
    for(String s : lore)
    {
    s = s.replaceAll("(&([0-9a-fk-orA-FK-OR]))", "\u00A7$2");
    }
    im.setLore(lore);
    is.setItemMeta(im);
    }
    
    All events are registered, as the firework does not fire off, but its ItemMeta will not change.

    Do not worry about the editItem() method, it's slightly broken in the lore portion, but I could care less about that.
     
  2. Offline

    Drkmaster83

    Bump, please.
     
  3. Offline

    Conarnar

    It's a bug in 1.7.2 where right clicking the air doesn't call an event.
     
  4. Offline

    Drkmaster83

    It doesn't do anything when I right click the ground, either. Should I be listening to another event?
     
  5. Offline

    Conarnar

    For now, just test with 1.6.4. If it still doesn't work, then you're doing something wrong.
     
  6. Offline

    Garris0n

    Right clicking the air calls an event for me. Conarnar
     
  7. Offline

    Conarnar

    Garris0n What version are you using?
     
  8. Offline

    Garris0n

    1.7.2.
     
Thread Status:
Not open for further replies.

Share This Page