Java Code Examples for org.bukkit.event.entity.ProjectileHitEvent#getHitBlock()

The following examples show how to use org.bukkit.event.entity.ProjectileHitEvent#getHitBlock() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Compat111.java    From RedProtect with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler
private void onChorusBreak(ProjectileHitEvent event) {
    if (!(event.getEntity().getShooter() instanceof Player)) return;

    if (event.getHitBlock() != null && event.getHitBlock().getType() == Material.CHORUS_FLOWER) {
        Player p = (Player) event.getEntity().getShooter();
        Region r = RedProtect.get().rm.getTopRegion(event.getHitBlock().getLocation());
        if (r != null && !r.canBuild(p)) {
            event.getEntity().remove();
            event.getHitBlock().setType(Material.AIR);
            Bukkit.getScheduler().runTask(RedProtect.get(), () -> event.getHitBlock().setType(Material.CHORUS_FLOWER));
            RedProtect.get().lang.sendMessage(p, "blocklistener.region.cantbreak");
        }
    }
}
 
Example 2
Source File: NMSHandler.java    From SkyWarsReloaded with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Block getHitBlock(ProjectileHitEvent event) {
	return event.getHitBlock();
}
 
Example 3
Source File: NMSHandler.java    From SkyWarsReloaded with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Block getHitBlock(ProjectileHitEvent event) {
	return event.getHitBlock();
}
 
Example 4
Source File: NMSHandler.java    From SkyWarsReloaded with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Block getHitBlock(ProjectileHitEvent event) {
	return event.getHitBlock();
}