Search in sources :

Example 1 with EntityCreatePortalEvent

use of org.bukkit.event.entity.EntityCreatePortalEvent in project Glowstone by GlowstoneMC.

the class BlockEnderPortalFrame method createPortal.

/**
     * Spawn the portal and call the {@link EntityCreatePortalEvent}.
     */
private void createPortal(GlowPlayer player, GlowBlock center) {
    List<BlockState> blocks = new ArrayList<>(9);
    for (int i = -1; i <= 1; i++) {
        for (int j = -1; j <= 1; j++) {
            BlockState state = center.getRelative(i, 0, j).getState();
            state.setType(Material.ENDER_PORTAL);
            blocks.add(state);
        }
    }
    if (!EventFactory.callEvent(new EntityCreatePortalEvent(player, blocks, PortalType.ENDER)).isCancelled()) {
        for (BlockState state : blocks) {
            state.update(true);
        }
    }
}
Also used : BlockState(org.bukkit.block.BlockState) GlowBlockState(net.glowstone.block.GlowBlockState) ArrayList(java.util.ArrayList) EntityCreatePortalEvent(org.bukkit.event.entity.EntityCreatePortalEvent)

Aggregations

ArrayList (java.util.ArrayList)1 GlowBlockState (net.glowstone.block.GlowBlockState)1 BlockState (org.bukkit.block.BlockState)1 EntityCreatePortalEvent (org.bukkit.event.entity.EntityCreatePortalEvent)1