/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.bekvon.bukkit.residence.event;

import org.bukkit.entity.Player;

import com.bekvon.bukkit.residence.protection.ClaimedResidence;

/**
 *
 * @author Administrator
 */
public class ResidencePlayerFlagEvent extends ResidenceFlagEvent implements ResidencePlayerEventInterface {
    Player p;

    public ResidencePlayerFlagEvent(final String eventName, final ClaimedResidence resref, final Player player, final String flag, final FlagType type, final String target) {
        super(eventName, resref, flag, type, target);
        p = player;
    }

    @Override
    public Player getPlayer() {
        return p;
    }

    @Override
    public boolean isAdmin() {
        if (isPlayer()) {
            return p.hasPermission("residence.admin") || p.isOp();
        }
        return true;
    }

    @Override
    public boolean isPlayer() {
        return p != null;
    }
}
