package cn.citycraft.AuthMe.listener;

import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;

import cn.citycraft.AuthMe.AuthMe;
import cn.citycraft.AuthMe.Utils;

public class AuthMeBlockListener implements Listener {

	public AuthMe instance;

	public AuthMeBlockListener(AuthMe instance) {

		this.instance = instance;
	}

	@EventHandler(ignoreCancelled = true)
	public void onBlockBreak(BlockBreakEvent event) {
		Player player = event.getPlayer();
		if (player == null || Utils.checkAuth(player)) {
			return;
		}
		event.setCancelled(true);
	}

	@EventHandler(ignoreCancelled = true)
	public void onBlockPlace(BlockPlaceEvent event) {
		if (Utils.checkAuth(event.getPlayer()))
			return;
		event.setCancelled(true);
	}

}
