/*
 * Copyright (c) 2014 Wyatt Childers.
 *
 * All Rights Reserved
 */

package com.skelril.aurora.items.implementations;

import com.skelril.aurora.events.custom.item.HymnSingEvent;
import com.skelril.aurora.items.custom.CustomItems;
import com.skelril.aurora.items.generic.AbstractItemFeatureImpl;
import com.skelril.aurora.util.item.ItemUtil;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;

import java.util.HashMap;
import java.util.Map;

public class HymnImpl extends AbstractItemFeatureImpl {

    private Map<CustomItems, HymnSingEvent.Hymn> hymns = new HashMap<>();

    public void addHymn(CustomItems item, HymnSingEvent.Hymn hymn) {
        hymns.put(item, hymn);
    }

    @EventHandler(ignoreCancelled = true)
    public void onPlayerInteract(PlayerInteractEvent event) {

        Player player = event.getPlayer();
        ItemStack itemStack = event.getItem();

        if (event.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
            for (Map.Entry<CustomItems, HymnSingEvent.Hymn> entry : hymns.entrySet()) {
                if (ItemUtil.isItem(itemStack, entry.getKey())) {
                    //noinspection AccessStaticViaInstance
                    inst.callEvent(new HymnSingEvent(player, entry.getValue()));
                    break;
                }
            }
        }
    }
}

@@ -293,16 +293,57 @@
 reImpl;%0A
+import com.skelril.aurora.util.ChatUtil;%0A
 import c
@@ -630,16 +630,90 @@
 l.Map;%0A%0A
+import static com.zachsthings.libcomponents.bukkit.BasePlugin.callEvent;%0A%0A
 public c
@@ -1383,46 +1383,60 @@
     
-//noinspection AccessStaticViaInstance
+ChatUtil.sendNotice(player, %22You sing the hymn...%22);
 %0A   
@@ -1456,13 +1456,8 @@
     
-inst.
 call

Readded the missing Hymn message