org.bukkit.event.block.EntityBlockFormEvent源码实例Demo

类org.bukkit.event.block.EntityBlockFormEvent源码实例Demo

下面列出了org.bukkit.event.block.EntityBlockFormEvent 类实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

@EventHandler(ignoreCancelled = true)
public void onEntityBlockFormEvent(EntityBlockFormEvent event)
{
	if (SupportedFeatures.isFrostwalkerSupported())
	{
		BlockState newState = event.getNewState();
		if (newState.getType() == Material.FROSTED_ICE)
		{
			ApplicableRegionSet regions = this.plugin.getWorldGuardCommunicator().getRegionContainer().createQuery().getApplicableRegions(newState.getLocation());
			
			Entity entity = event.getEntity();
			if (entity instanceof Player)
			{
				Player player = (Player)entity;
				if (WorldGuardUtils.queryValue(player, player.getWorld(), regions.getRegions(), Flags.FROSTWALKER) == State.DENY)
				{
					event.setCancelled(true);
				}
			}
			else
			{
				if (regions.queryValue(null, Flags.FROSTWALKER) == State.DENY)
				{
					event.setCancelled(true);
				}
			}
		}
	}
}
 
源代码2 项目: SonarPet   文件: PetEntityListener.java
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onBlockForm(EntityBlockFormEvent event) {
    Entity e = event.getEntity();
    if (plugin.isPet(e) && event.getNewState().getType().equals(Material.SNOW)) {
        event.setCancelled(true);
        event.getNewState().setType(Material.AIR);
    }
}
 
源代码3 项目: RedProtect   文件: EntityListener.java
@EventHandler(ignoreCancelled = true)
public void onPlayerFrostWalk(EntityBlockFormEvent e) {
    if (e.getEntity() instanceof Player) {
        return;
    }
    RedProtect.get().logger.debug(LogLevel.ENTITY, "EntityListener - EntityBlockFormEvent");
    Region r = RedProtect.get().rm.getTopRegion(e.getBlock().getLocation());
    if (r != null && !r.canIceForm()) {
        e.setCancelled(true);
    }
}
 
源代码4 项目: RedProtect   文件: PlayerListener.java
@EventHandler(priority = EventPriority.LOW)
public void onPlayerFrostWalk(EntityBlockFormEvent e) {
    if (!(e.getEntity() instanceof Player)) {
        return;
    }
    RedProtect.get().logger.debug(LogLevel.PLAYER, "PlayerListener - EntityBlockFormEvent canceled? " + e.isCancelled());
    Player p = (Player) e.getEntity();
    Region r = RedProtect.get().rm.getTopRegion(e.getBlock().getLocation());
    if (r != null && e.getNewState().getType().name().contains("FROSTED_ICE") && !r.canIceForm(p)) {
        e.setCancelled(true);
    }
}
 
源代码5 项目: askyblock   文件: IslandGuard1_9.java
/**
 * Handles Frost Walking on visitor's islands
 * @param e - event
 */
@EventHandler(priority = EventPriority.LOW, ignoreCancelled=true)
public void onBlockForm(final EntityBlockFormEvent e) {
    if (e.getEntity() instanceof Player && e.getNewState().getType().equals(Material.FROSTED_ICE)) {
        Player player= (Player) e.getEntity();
        if (!IslandGuard.inWorld(player)) {
            return;
        }
        if (player.isOp()) {
            return;
        }
        // This permission bypasses protection
        if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "mod.bypassprotect")) {
            return;
        }
        // Check island
        Island island = plugin.getGrid().getIslandAt(player.getLocation());
        if (island == null && Settings.defaultWorldSettings.get(SettingsFlag.PLACE_BLOCKS)) {
            return;
        }
        if (island !=null) {
            if (island.getMembers().contains(player.getUniqueId()) || island.getIgsFlag(SettingsFlag.PLACE_BLOCKS)) {
                return;
            }
        }
        // Silently cancel the event
        e.setCancelled(true);
    }
}
 
源代码6 项目: EchoPet   文件: PetEntityListener.java
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onBlockForm(EntityBlockFormEvent event) {
    Entity e = event.getEntity();
    if (ReflectionUtil.getEntityHandle(e) instanceof IEntityPet && event.getNewState().getType().equals(Material.SNOW)) {
        event.setCancelled(true);
        event.getNewState().setType(Material.AIR);
    }
}
 
源代码7 项目: GriefDefender   文件: EntityEventHandler.java
@EventHandler(priority = EventPriority.LOWEST)
public void onEntityBlockFormEvent(EntityBlockFormEvent event) {
    CommonBlockEventHandler.getInstance().handleBlockPlace(event, event.getEntity(), event.getNewState());
}
 
源代码8 项目: PGM   文件: AnvilTracker.java
@EventHandler(priority = EventPriority.MONITOR)
public void onLand(EntityBlockFormEvent event) {
  AnvilInfo info = resolveEntity(event.getEntity());
  if (info != null) blocks().trackBlockState(event.getNewState(), info);
}
 
源代码9 项目: ProjectAres   文件: AnvilTracker.java
@EventHandler(priority = EventPriority.MONITOR)
public void onLand(EntityBlockFormEvent event) {
    AnvilInfo info = resolveEntity(event.getEntity());
    if(info != null) blocks().trackBlockState(event.getNewState(), info);
}
 
源代码10 项目: Shopkeepers   文件: LivingEntityShopListener.java
@EventHandler(ignoreCancelled = true)
void onEntityBlockForm(EntityBlockFormEvent event) {
	if (plugin.isShopkeeper(event.getEntity())) {
		event.setCancelled(true);
	}
}
 
如果文章对您有帮助,请点击页面广告。以鼓励作者做出的努力。
 类所在包
 类方法
 同包方法