org.bukkit.event.entity.EntityChangeBlockEvent#getTo ( )源码实例Demo

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

源代码1 项目: BedWars   文件: WorldListener.java
@EventHandler
public void onEntityChangeBlock(EntityChangeBlockEvent event) {
    if (event.isCancelled()) {
        return;
    }

    for (String gameName : Main.getGameNames()) {
        Game game = Main.getGame(gameName);
        if (GameCreator.isInArea(event.getBlock().getLocation(), game.getPos1(), game.getPos2())) {
            if (game.getStatus() == GameStatus.RUNNING || game.getStatus() == GameStatus.GAME_END_CELEBRATING) {
                if (event.getEntityType() == EntityType.FALLING_BLOCK
                        && game.getOriginalOrInheritedAllowBlockFalling()) {
                    if (event.getBlock().getType() != event.getTo()) {
                        if (!game.getRegion().isBlockAddedDuringGame(event.getBlock().getLocation())) {
                            if (event.getBlock().getType() != Material.AIR) {
                                game.getRegion().putOriginalBlock(event.getBlock().getLocation(),
                                        event.getBlock().getState());
                            }
                            game.getRegion().addBuiltDuringGame(event.getBlock().getLocation());
                        }
                    }
                    return; // allow block fall
                }
            }

            if (game.getStatus() != GameStatus.DISABLED) {
                event.setCancelled(true);
            }
        }
    }
}
 
源代码2 项目: BedWars   文件: WorldListener.java
@EventHandler
public void onEntityChangeBlock(EntityChangeBlockEvent event) {
    if (event.isCancelled()) {
        return;
    }

    for (String gameName : Main.getGameNames()) {
        Game game = Main.getGame(gameName);
        if (GameCreator.isInArea(event.getBlock().getLocation(), game.getPos1(), game.getPos2())) {
            if (game.getStatus() == GameStatus.RUNNING || game.getStatus() == GameStatus.GAME_END_CELEBRATING) {
                if (event.getEntityType() == EntityType.FALLING_BLOCK
                        && game.getOriginalOrInheritedAllowBlockFalling()) {
                    if (event.getBlock().getType() != event.getTo()) {
                        if (!game.getRegion().isBlockAddedDuringGame(event.getBlock().getLocation())) {
                            if (event.getBlock().getType() != Material.AIR) {
                                game.getRegion().putOriginalBlock(event.getBlock().getLocation(),
                                        event.getBlock().getState());
                            }
                            game.getRegion().addBuiltDuringGame(event.getBlock().getLocation());
                        }
                    }
                    return; // allow block fall
                }
            }

            if (game.getStatus() != GameStatus.DISABLED) {
                event.setCancelled(true);
            }
        }
    }
}
 
源代码3 项目: ProjectAres   文件: BlockTransformListener.java
@EventWrapper
public void onEntityChangeBlock(final EntityChangeBlockEvent event) {
    // Igniting TNT with an arrow is already handled from the ExplosionPrimeEvent
    if(event.getEntity() instanceof Arrow &&
       event.getBlock().getType() == Material.TNT &&
       event.getTo() == Material.AIR) return;

    callEvent(event, event.getBlock().getState(), BlockStateUtils.cloneWithMaterial(event.getBlock(), event.getToData()), entityResolver.getOwner(event.getEntity()));
}
 
源代码4 项目: uSkyBlock   文件: PlayerEvents.java
@EventHandler
public void onLavaAbsorption(EntityChangeBlockEvent event) {
    if (!plugin.getWorldManager().isSkyWorld(event.getBlock().getWorld())) {
        return;
    }
    if (isLavaSource(event.getBlock().getBlockData())) {
        if (event.getTo() != Material.LAVA) {
            event.setCancelled(true);
            // TODO: R4zorax - 21-07-2018: missing datavalue (might convert stuff - exploit)
            ItemStack item = new ItemStack(event.getTo(), 1);
            Location above = event.getBlock().getLocation().add(0, 1, 0);
            event.getBlock().getWorld().dropItemNaturally(above, item);
        }
    }
}