All Downloads are FREE. Search and download functionalities are using the official Maven repository.

dev.espi.protectionstones.event.PSRemoveEvent Maven / Gradle / Ivy

/*
 * Copyright 2019 ProtectionStones team and contributors
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package dev.espi.protectionstones.event;

import dev.espi.protectionstones.PSRegion;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;

import static com.google.common.base.Preconditions.checkNotNull;

/**
 * Event that is called when a protection stones region is removed
 */

public class PSRemoveEvent extends Event implements Cancellable {
    private static final HandlerList HANDLERS = new HandlerList();

    private PSRegion region;
    private Player p = null;
    private boolean isCancelled = false;

    public PSRemoveEvent(PSRegion psr, Player player) {
        this.region = checkNotNull(psr);
        this.p = player;
    }

    public PSRemoveEvent(PSRegion psr) {
        this.region = checkNotNull(psr);
    }

    /**
     * Returns the player that removed the protect block, if applicable
     * @return the player, or null if the region was not removed because of a player
     */
    public Player getPlayer() {
        return p;
    }

    /**
     * Returns the region being removed.
     * @return the region being removed
     */
    public PSRegion getRegion() {
        return region;
    }

    @Override
    public boolean isCancelled() {
        return isCancelled;
    }

    @Override
    public void setCancelled(boolean isCancelled) {
        this.isCancelled = isCancelled;
    }

    @Override
    public HandlerList getHandlers() {
        return HANDLERS;
    }

    public static HandlerList getHandlerList() {
        return HANDLERS;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy