/* This file is part of MusicalRegions for Bukkit, licensed under the MIT License (MIT).
 *
 * Copyright (c) JCThePants (www.jcwhatever.com)
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */


package com.jcwhatever.musical;


import com.jcwhatever.nucleus.events.sounds.PlayResourceSoundEvent;
import com.jcwhatever.nucleus.sounds.MusicSound;
import com.jcwhatever.nucleus.sounds.ResourceSound;

import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;

/**
 * Listens to Bukkit events.
 */
public class BukkitEventListener implements Listener {

    @EventHandler()
    private void onPlayResourceSound(PlayResourceSoundEvent event) {

        if (!(event.getResourceSound() instanceof MusicSound))
            return;

        String msg = "";
        ResourceSound sound = event.getResourceSound();
        Player p = event.getPlayer();

        if (sound.getCredit() != null) {
            msg += sound.getCredit();
        }

        if (!msg.isEmpty())
            msg += " - ";

        msg += '\'' + sound.getDisplayName() + '\'';

        if (!msg.isEmpty())
            Msg.tell(p, msg);
    }
}

@@ -1249,16 +1249,67 @@
 ical;%0A%0A%0A
+import com.jcwhatever.nucleus.actionbar.ActionBar;%0A
 import c
@@ -1576,16 +1576,65 @@
 tener;%0A%0A
+import java.util.HashMap;%0Aimport java.util.Map;%0A%0A
 /**%0A * L
@@ -1714,24 +1714,93 @@
 Listener %7B%0A%0A
+    private Map%3CString, ActionBar%3E _actionBars = new HashMap%3C%3E(10);%0A%0A
     @EventHa
@@ -1965,33 +1965,8 @@
 n;%0A%0A
-        String msg = %22%22;%0A
     
@@ -2017,24 +2017,25 @@
 ound();%0A
+%0A
         
 Player p
@@ -2030,70 +2030,87 @@
     
-Player p = event.getPlayer();%0A%0A        if (sound.getCredit() !
+ActionBar actionBar = _actionBars.get(sound.getName());%0A        if (actionBar =
 = nu
@@ -2115,16 +2115,17 @@
 null) %7B%0A
+%0A
         
@@ -2132,72 +2132,143 @@
     
+String 
 msg 
-+
 = 
-sound.getCredit();%0A        %7D%0A%0A        if (!msg.isEmpty())
+MusicalRegions.getPlugin().getChatPrefix() + '%5C'' + sound.getTitle() + '%5C'';%0A%0A            if (sound.getCredit() != null) %7B
 %0A   
@@ -2272,24 +2272,28 @@
             
+    
 msg += %22 - %22
@@ -2295,93 +2295,198 @@
 %22 - 
-%22;%0A%0A        msg += '%5C'' + sound.getDisplayName() + '%5C'';%0A%0A        if (!msg.isEmpty())
+By %22 + sound.getCredit();%0A            %7D%0A%0A            actionBar = new ActionBar(msg);%0A            _actionBars.put(sound.getName(), actionBar);%0A        %7D%0A%0A        Player p = event.getPlayer();
 %0A   
@@ -2494,27 +2494,24 @@
     
-    Msg.tell(p, msg
+actionBar.show(p
 );%0A 

Use action bars to display music credits instead of chat