/*
 * This file is part of NucleusFramework 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.nucleus.sounds;

import com.jcwhatever.nucleus.mixins.INamed;
import com.jcwhatever.nucleus.storage.IDataNode;
import com.jcwhatever.nucleus.utils.PreCon;

/**
 * Abstract implementation of a resource sound.
 */
public abstract class ResourceSound implements INamed {

    private final String _soundName;
    private final String _displayName;
    private final String _credit;
    private final int _durationSeconds;
    private final int _durationTicks;

    /**
     * Constructor.
     *
     * @param dataNode  The resource sound data node.
     */
    public ResourceSound (IDataNode dataNode) {
        PreCon.notNull(dataNode);

        // get the required sound name
        _soundName = loadName(dataNode);

        // get the required duration of the sound
        _durationSeconds = dataNode.getInteger("duration", -1);
        if (_durationSeconds < 0)
            throw new RuntimeException("Resource sounds file is missing required duration parameter for sound: " + _soundName);

        _displayName = dataNode.getString("display", _soundName);
        _credit = dataNode.getString("credit", "");
        _durationTicks = _durationSeconds * 20;
    }

    /**
     * Get the name of the sound.
     */
    @Override
    public final String getName() {
        return _soundName;
    }

    /**
     * Get the display name of the sound.
     */
    public final String getDisplayName() {
        return _displayName;
    }

    /**
     * Get the name of the sound creator.
     */
    public final String getCredit() {
        return _credit;
    }

    /**
     * Get the duration of the sound in seconds.
     */
    public final int getDurationSeconds() {
        return _durationSeconds;
    }

    /**
     * Get the duration of the sound in ticks.
     */
    public final int getDurationTicks() {
        return _durationTicks;
    }

    @Override
    public String toString() {
        return _soundName;
    }

    /*
     *  load the name of the resource sound.
     */
    protected String loadName(IDataNode dataNode) {
        return dataNode.getName();
    }
}

@@ -1575,26 +1575,20 @@
 String _
-displayNam
+titl
 e;%0A    p
@@ -2242,26 +2242,20 @@
        _
-displayNam
+titl
 e = data
@@ -2270,23 +2270,21 @@
 String(%22
-display
+title
 %22, _soun
@@ -2559,19 +2559,12 @@
 the 
-display nam
+titl
 e of
@@ -2614,18 +2614,12 @@
  get
-DisplayNam
+Titl
 e() 
@@ -2640,18 +2640,12 @@
 rn _
-displayNam
+titl
 e;%0A 

change 'display' setting to 'title'