org.bukkit.event.world.StructureGrowEvent#getBlocks ( )源码实例Demo

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

源代码1 项目: GriefDefender   文件: BlockEventHandler.java
@EventHandler(priority = EventPriority.LOWEST)
public void onStructureGrow(StructureGrowEvent event) {
    final World world = event.getLocation().getWorld();
    if (!GriefDefenderPlugin.getInstance().claimsEnabledForWorld(world.getUID())) {
        return;
    }

    for (BlockState blockstate : event.getBlocks()) {
        final Location location = blockstate.getLocation();
        final GDClaim targetClaim = this.storage.getClaimAt(location);

        if (targetClaim.isWilderness()) {
            continue;
        }

        final Tristate result = GDPermissionManager.getInstance().getFinalPermission(event, location, targetClaim, Flags.BLOCK_GROW, null, blockstate, event.getPlayer(), TrustTypes.BUILDER, true);
        if (result == Tristate.FALSE) {
            event.setCancelled(true);
            return;
        }
    }
}
 
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onStructureGrow(StructureGrowEvent event) {
    if (!useEnhanceProtection) {
        return;
    }

    for (BlockState blockstate : event.getBlocks()) {
        final Shop shop = getShopNature(blockstate.getLocation(), true);

        if (shop == null) {
            continue;
        }

        event.setCancelled(true);
        return;
        // plugin.getLogger().warning("[Exploit Alert] a StructureGrowing tried to break the shop of "
        // + shop);
        // Util.sendMessageToOps(ChatColor.RED + "[QuickShop][Exploit alert] A StructureGrowing tried
        // to break the shop of " + shop);
    }
}
 
源代码3 项目: Modern-LWC   文件: LWCBlockListener.java
@EventHandler
public void onStructureGrow(StructureGrowEvent event) {
    if (!LWC.ENABLED) {
        return;
    }

    LWC lwc = LWC.getInstance();
    // the blocks that were changed / replaced
    List<BlockState> blocks = event.getBlocks();

    for (BlockState block : blocks) {
        if (!lwc.isProtectable(block.getBlock())) {
            continue;
        }
        // we don't have the block id of the block before it
        // so we have to do some raw lookups (these are usually cache hits
        // however, at least!)
        Protection protection = lwc.getPhysicalDatabase().loadProtection(block.getWorld().getName(), block.getX(),
                block.getY(), block.getZ());
        if (protection != null) {
            event.setCancelled(true);
        }
    }
}
 
源代码4 项目: RedProtect   文件: BlockListener.java
@EventHandler(ignoreCancelled = true)
public void onStructureGrow(StructureGrowEvent e) {
    RedProtect.get().logger.debug(LogLevel.BLOCKS, "BlockListener - Is StructureGrowEvent event");
    if (!RedProtect.get().config.configRoot().region_settings.deny_structure_bypass_regions) {
        return;
    }
    Region rfrom = RedProtect.get().rm.getTopRegion(e.getLocation());
    for (BlockState bstt : e.getBlocks()) {
        Region rto = RedProtect.get().rm.getTopRegion(bstt.getLocation());
        Block bloc = bstt.getLocation().getBlock();
        //deny blocks spread in/out regions
        if (rfrom != null && rto != null && rfrom != rto && !rfrom.sameLeaders(rto)) {
            bstt.setType(bloc.getType());
        }
        if (rfrom == null && rto != null) {
            bstt.setType(bloc.getType());
        }
        if (rfrom != null && rto == null) {
            bstt.setType(bloc.getType());
        }
        bstt.update();
    }
}
 
源代码5 项目: askyblock   文件: NetherPortals.java
/**
 * Converts trees to gravel and glowstone
 * 
 * @param e - event
 */
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onTreeGrow(final StructureGrowEvent e) {
    if (DEBUG)
        plugin.getLogger().info("DEBUG: " + e.getEventName());

    if (!Settings.netherTrees) {
        return;
    }
    if (!Settings.createNether || ASkyBlock.getNetherWorld() == null) {
        return;
    }
    // Check world
    if (!e.getLocation().getWorld().equals(ASkyBlock.getNetherWorld())) {
        return;
    }
    for (BlockState b : e.getBlocks()) {
        if (b.getType() == Material.LOG || b.getType() == Material.LOG_2) {
            b.setType(Material.GRAVEL);
        } else if (b.getType() == Material.LEAVES || b.getType() == Material.LEAVES_2) {
            b.setType(Material.GLOWSTONE);
        }
    }
}
 
源代码6 项目: PGM   文件: BlockTransformListener.java
@EventWrapper
public void onStructureGrow(final StructureGrowEvent event) {
  for (BlockState block : event.getBlocks()) {
    this.callEvent(
        new BlockTransformEvent(event, block.getLocation().getBlock().getState(), block));
  }
}
 
源代码7 项目: ShopChest   文件: ShopItemListener.java
@EventHandler(priority = EventPriority.HIGH)
public void onStructureGrow(StructureGrowEvent e) {
    for (BlockState state : e.getBlocks()) {
        Block newBlock = state.getBlock();
        if (shopUtils.isShop(newBlock.getLocation()) || shopUtils.isShop(newBlock.getRelative(BlockFace.DOWN).getLocation())) {
            e.setCancelled(true);
        }
    }
}
 
 同类方法