/*
 * This file is part of EchoPet.
 *
 * EchoPet is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * EchoPet is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with EchoPet.  If not, see <http://www.gnu.org/licenses/>.
 */

package com.samistine.echopet.listeners;

import com.samistine.echopet.compat.api.entity.IPet;
import com.samistine.echopet.compat.api.plugin.EchoPet;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.kitteh.vanish.event.VanishStatusChangeEvent;


public class VanishListener implements Listener {

    @EventHandler
    public void onVanish(VanishStatusChangeEvent event) {
        Player p = event.getPlayer();
        IPet pet = EchoPet.getManager().getPet(p);
        if (pet != null) {
            pet.getEntityPet().setShouldVanish(event.isVanishing());
            pet.getEntityPet().setInvisible(event.isVanishing());
        }
    }
}