Java 类org.bukkit.event.block.BlockPhysicsEvent 实例源码

项目:AntiCheat    文件:OrebfuscatorBlockListener.java   
@EventHandler(priority = EventPriority.MONITOR)
public void onBlockPhysics(BlockPhysicsEvent event) {
    if (event.isCancelled()) {
        return;
    }

    if (event.getBlock().getType() != Material.SAND && event.getBlock().getType() != Material.GRAVEL) {
        return;
    }

    if (!DeprecatedMethods.applyPhysics(event.getBlock())) {
        return;
    }

    BlockUpdate.Update(event.getBlock());
}
项目:EscapeLag    文件:AntiInfRail.java   
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
   public void PhysicsCheck(BlockPhysicsEvent event) {
       if (ConfigPatch.fixInfRail == true) {
           if (event.getChangedType().name().contains("RAIL")) {
               if(CheckFast()){
                event.setCancelled(true);
               }
               LastCheckedTime = System.currentTimeMillis();
           }
           if (event.getChangedTypeId() == 165) {
            if(CheckFast()){
                event.setCancelled(true);
               }
               LastCheckedTime = System.currentTimeMillis();
           }
       }
   }
项目:NavyCraft2-Lite    文件:NavyCraft_BlockListener.java   
@EventHandler(priority = EventPriority.HIGH)
public void onBlockPhysics(final BlockPhysicsEvent event) {
    if (!event.isCancelled()) {

        final Block block = event.getBlock();
        if (Craft_Hyperspace.hyperspaceBlocks.contains(block)) {
            event.setCancelled(true);
        }


        if ((block.getTypeId() == 63) || (block.getTypeId() == 68) || (block.getTypeId() == 50) || (block.getTypeId() == 75) || (block.getTypeId() == 76) || (block.getTypeId() == 65) || (block.getTypeId() == 64) || (block.getTypeId() == 71) || (block.getTypeId() == 70) || (block.getTypeId() == 72) || (block.getTypeId() == 143)) {
            Craft c = Craft.getCraft(block.getX(), block.getY(), block.getZ());
            if (c != null) {

                // if not iron door being controlled by circuit...
                if ((event.getChangedTypeId() != 0) && !(((block.getTypeId() == 71) || (block.getTypeId() == 64)) && ((event.getChangedTypeId() == 69) || (event.getChangedTypeId() == 77) || (event.getChangedTypeId() == 55) || (event.getChangedTypeId() == 70) || (event.getChangedTypeId() == 72) || (block.getTypeId() == 143) || (block.getTypeId() == 75) || (block.getTypeId() == 76) || (block.getTypeId() == 50)))) {

                    event.setCancelled(true);
                }
            }
        }

    }
}
项目:NavyCraft2-Lite    文件:MoveCraft_BlockListener.java   
@EventHandler(priority = EventPriority.HIGH)
public void onBlockPhysics(final BlockPhysicsEvent event) {
    if (!event.isCancelled()) {

        final Block block = event.getBlock();
        if (Craft_Hyperspace.hyperspaceBlocks.contains(block)) {
            event.setCancelled(true);
        }


        if ((block.getTypeId() == 63) || (block.getTypeId() == 68) || (block.getTypeId() == 50) || (block.getTypeId() == 75) || (block.getTypeId() == 76) || (block.getTypeId() == 65) || (block.getTypeId() == 64) || (block.getTypeId() == 71) || (block.getTypeId() == 70) || (block.getTypeId() == 72) || (block.getTypeId() == 143)) {
            Craft c = Craft.getCraft(block.getX(), block.getY(), block.getZ());
            if (c != null) {

                // if not iron door being controlled by circuit...
                if ((event.getChangedTypeId() != 0) && !(((block.getTypeId() == 71) || (block.getTypeId() == 64)) && ((event.getChangedTypeId() == 69) || (event.getChangedTypeId() == 77) || (event.getChangedTypeId() == 55) || (event.getChangedTypeId() == 70) || (event.getChangedTypeId() == 72) || (block.getTypeId() == 143) || (block.getTypeId() == 75) || (block.getTypeId() == 76) || (block.getTypeId() == 50)))) {

                    event.setCancelled(true);
                }
            }
        }

    }
}
项目:Carbon-2    文件:BlockPlant.java   
protected void e(World world, BlockPosition blockposition, IBlockData iblockdata) {
    if (!f(world, blockposition, iblockdata)) {
        // CraftBukkit Start
        org.bukkit.block.Block block = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
        @SuppressWarnings("deprecation")
        BlockPhysicsEvent event = new BlockPhysicsEvent(block, block.getTypeId());
        world.getServer().getPluginManager().callEvent(event);

        if (event.isCancelled()) {
            return;
        }
        // CraftBukkit end
        this.b(world, blockposition, iblockdata, 0);
        world.setTypeAndData(blockposition, Blocks.AIR.getBlockData(), 3);
    }

}
项目:AncientGates    文件:PluginBlockListener.java   
@EventHandler(priority = EventPriority.NORMAL)
public void onBlockPhysics(final BlockPhysicsEvent event) {
    if (event.isCancelled())
        return;

    final Block block = event.getBlock();
    final WorldCoord coord = new WorldCoord(block);

    // Stop portal blocks from breaking
    if (BlockUtil.isStandableGateMaterial(block.getType()) && Gates.gateFromPortal(coord) != null) {
        event.setCancelled(true);
    }

    // Stop sand falling when part of the frame
    if (block.getType() == Material.SAND && Gates.gateFromFrame(coord) != null) {
        event.setCancelled(true);
    }

    return;
}
项目:Carbon-2    文件:BlockPlant.java   
protected void e(World world, BlockPosition blockposition, IBlockData iblockdata) {
    if (!f(world, blockposition, iblockdata)) {
        // CraftBukkit Start
        org.bukkit.block.Block block = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
        @SuppressWarnings("deprecation")
        BlockPhysicsEvent event = new BlockPhysicsEvent(block, block.getTypeId());
        world.getServer().getPluginManager().callEvent(event);

        if (event.isCancelled()) {
            return;
        }
        // CraftBukkit end
        this.b(world, blockposition, iblockdata, 0);
        world.setTypeAndData(blockposition, Blocks.AIR.getBlockData(), 3);
    }

}
项目:sensibletoolbox    文件:BlockUpdateDetector.java   
@Override
public void onBlockPhysics(BlockPhysicsEvent event) {
    final Block b = event.getBlock();
    long timeNow = getLocation().getWorld().getFullTime();
    Debugger.getInstance().debug(this + ": BUD physics: time=" + timeNow + ", lastPulse=" + lastPulse + ", duration=" + getDuration());
    if (timeNow - lastPulse > getDuration() + getQuiet() && isRedstoneActive()) {
        // emit a signal for one or more ticks
        lastPulse = timeNow;
        active = true;
        repaint(b);
        Bukkit.getScheduler().runTaskLater(getProviderPlugin(), new Runnable() {
            @Override
            public void run() {
                active = false;
                repaint(b);
            }
        }, duration);
    }
}
项目:SpigotSource    文件:BlockPlant.java   
protected void e(World world, BlockPosition blockposition, IBlockData iblockdata) {
    if (!this.f(world, blockposition, iblockdata)) {
        // CraftBukkit Start
        org.bukkit.block.Block block = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
        BlockPhysicsEvent event = new BlockPhysicsEvent(block, block.getTypeId());
        world.getServer().getPluginManager().callEvent(event);

        if (event.isCancelled()) {
            return;
        }
        // CraftBukkit end
        this.b(world, blockposition, iblockdata, 0);
        world.setTypeAndData(blockposition, Blocks.AIR.getBlockData(), 3);
    }

}
项目:Zeus    文件:ZeusEventHandler.java   
@EventHandler
public void onBlockPhysicsChange(BlockPhysicsEvent event) {
    if (event.getBlock().getState() instanceof Sign) {
        Sign droppedSign = (Sign) event.getBlock().getState();
        if (plugin.jailMan.isJailSign(droppedSign.getLine(0))) {
            if (plugin.jailMan.jailExists(droppedSign.getLine(1))) {
                plugin.jailMan.destroyCell(droppedSign.getLine(1),
                        Integer.valueOf(droppedSign.getLine(2)));
                plugin.getLogger().info("[Zeus] Cell Destroyed");
            }
        }
    }

    /*
     * Block pressurePlate = event.getBlock(); if
     * (pressurePlate.getState().getType() == Material.WOOD_PLATE ||
     * pressurePlate.getState().getType() == Material.STONE_PLATE) {
     * 
     * }
     */
}
项目:Sprout    文件:SproutListener.java   
@EventHandler (priority = EventPriority.LOW, ignoreCancelled = true)
public void onBlockPhysics(BlockPhysicsEvent event) {
    final Block physics = event.getBlock();
    if (physics.getRelative(BlockFace.DOWN).getType() != Material.AIR) {
        return;
    }
    final Sprout sprout = plugin.getWorldRegistry().remove(physics.getWorld().getName(), physics.getX(), physics.getY(), physics.getZ());
    final SaveThread thread = ((SaveThread) ThreadRegistry.get(physics.getWorld().getName()));
    if (thread != null) {
        thread.remove(physics.getLocation(), (SimpleSprout) sprout);
    }
    if (sprout == null) {
        return;
    }
    event.setCancelled(true);
    physics.setType(Material.AIR);
    ((SpoutBlock) physics).setCustomBlock(null);
    if (!sprout.getRequiredTools().isEmpty()) {
        disperseDrops(sprout, physics, false);
    }
}
项目:ProjectAres    文件:EventRuleMatchModule.java   
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void checkBlockPhysics(final BlockPhysicsEvent event) {
    BlockEventQuery query = new BlockEventQuery(event, event.getBlock().getState());
    for(EventRule rule : this.ruleContext.get(EventRuleScope.BLOCK_PHYSICS)) {
        if(rule.region().contains(event.getBlock()) && processQuery(rule, query)) break;
    }
}
项目:CastleGates    文件:BridgeEventHandler.java   
public void handleBlockPhysics(BlockPhysicsEvent event) {
    Block block = event.getBlock();

    if(this.waitingBlocks.remove(block)) {
        processBlock(block, block.isBlockPowered());
    }
}
项目:Arcade2    文件:RegionListeners.java   
@EventHandler(ignoreCancelled = true)
public void onBlockPhysics(BlockPhysicsEvent event) {
    Region region = this.regions.fetch(event.getBlock());
    FilterResult result = this.getFilterResult(region, RegionEventType.BLOCK_PHYSICS, null, null, event.getBlock());

    if (result.equals(FilterResult.DENY)) {
        event.setCancelled(true);
    }
}
项目:Cardinal    文件:AppliedModule.java   
/**
 * Filters BlockPhysicsEvent, like redstone updating, or sand start falling.
 *
 * <p>Applies to: block physics<p/>
 */
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onBlockPhysics(BlockPhysicsEvent event) {
  Match match = Cardinal.getMatch(event.getWorld());
  if (match == null) {
    return;
  }
  for (AppliedRegion reg : get(match, ApplyType.BLOCK_PHYSICS)) {
    if (apply(reg, event.getBlock().getLocation(), null, event, event, event.getBlock())) {
      break;
    }
  }
}
项目:FastAsyncWorldedit    文件:ChunkListener.java   
protected boolean containsSetAir(Exception e, BlockPhysicsEvent event) {
    for (int frame = 25; frame < 35; frame++) {
        StackTraceElement elem = getElement(e, frame);
        if (elem != null) {
            String methodName = elem.getMethodName();
            // setAir (hacky, but this needs to be efficient)
            if (methodName.charAt(0) == 's' && methodName.length() == 6) {
                return true;
            }
        }
    }
    return false;
}
项目:MyiuLib    文件:MGListener.java   
@EventHandler(priority = EventPriority.HIGHEST)
public void onBlockPhysics(BlockPhysicsEvent e) {
    boolean cancelled = false;
    String w = e.getBlock().getWorld().getName();
    for (String p : worlds.keySet()) {
        for (int i = 0; i < worlds.get(p).size(); i++) {
            if (worlds.get(p).get(i).equals(w)) {
                if (!Minigame.getMinigameInstance(p).getConfigManager().areBlockPhysicsAllowed()) {
                    e.setCancelled(true);
                    cancelled = true;
                    break;
                }
            }
        }
    }
    if (cancelled) {
        return;
    }
    Block adjBlock = MGUtil.getAttachedSign(e.getBlock());
    if (adjBlock != null) {
        for (Minigame mg : Minigame.getMinigameInstances()) {
            for (LobbySign l : mg.getLobbyManager().signs.values()) {
                if (l.getX() == adjBlock.getX() && l.getY() == adjBlock.getY() && l.getZ() == adjBlock.getZ() &&
                        l.getWorld().equals(adjBlock.getWorld().getName())) {
                    e.setCancelled(true);
                    break;
                }
            }
        }
    }
}
项目:CraftBukkit    文件:World.java   
public void e(int i, int j, int k, Block block) {
    if (!this.isStatic) {
        Block block1 = this.getType(i, j, k);

        try {
            // CraftBukkit start
            CraftWorld world = ((WorldServer) this).getWorld();
            if (world != null) {
                BlockPhysicsEvent event = new BlockPhysicsEvent(world.getBlockAt(i, j, k), CraftMagicNumbers.getId(block));
                this.getServer().getPluginManager().callEvent(event);

                if (event.isCancelled()) {
                    return;
                }
            }
            // CraftBukkit end

            block1.doPhysics(this, i, j, k, block);
        } catch (Throwable throwable) {
            CrashReport crashreport = CrashReport.a(throwable, "Exception while updating neighbours");
            CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Block being updated");

            int l;

            try {
                l = this.getData(i, j, k);
            } catch (Throwable throwable1) {
                l = -1;
            }

            crashreportsystemdetails.a("Source block type", (Callable) (new CrashReportSourceBlockType(this, block)));
            CrashReportSystemDetails.a(crashreportsystemdetails, i, j, k, block1, l);
            throw new ReportedException(crashreport);
        }
    }
}
项目:PlotSquared-Chinese    文件:ChunkListener.java   
@EventHandler(priority=EventPriority.LOWEST)
public void onBlockPhysics(BlockPhysicsEvent event) {
    long now = System.currentTimeMillis();
    if (now - last < 20) {
        if (count > Settings.CHUNK_PROCESSOR_MAX_ENTITIES) {
            event.setCancelled(true);
        }
        count++;
    }
    else {
        count = 0;
    }
    last = now;
}
项目:Peacecraft    文件:PortalListener.java   
@EventHandler
public void onBlockPhysics(BlockPhysicsEvent event) {
    if(event.getChangedType() == Material.PORTAL || event.getBlock().getType() == Material.PORTAL) {
        String portal = this.module.getPortalManager().getPortal(event.getBlock().getLocation());
        if(portal != null) {
            event.setCancelled(true);
        }
    }
}
项目:BelovedBlocks    文件:PortalsBlocksListener.java   
/**
 * Called when block physics occurs.
 */
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockPhysics(BlockPhysicsEvent ev) 
{
   if (ev.getBlock().getType() != Material.PORTAL) return;

   // Only cancelled when a block is placed (changedType = air), or a block is destroyed, which is not portal or obsidian
   if (ev.getChangedType() != Material.PORTAL && ev.getChangedType() != Material.OBSIDIAN)
        ev.setCancelled(true);
}
项目:Almura-Server    文件:World.java   
public void g(int i, int j, int k, int l) {
    if (!this.isStatic) {
        int i1 = this.getTypeId(i, j, k);
        Block block = Block.byId[i1];

        if (block != null) {
            try {
                // CraftBukkit start
                CraftWorld world = ((WorldServer) this).getWorld();
                if (world != null) {
                    BlockPhysicsEvent event = new BlockPhysicsEvent(world.getBlockAt(i, j, k), l);
                    this.getServer().getPluginManager().callEvent(event);

                    if (event.isCancelled()) {
                        return;
                    }
                }
                // CraftBukkit end

                block.doPhysics(this, i, j, k, l);
            } catch (Throwable throwable) {
                CrashReport crashreport = CrashReport.a(throwable, "Exception while updating neighbours");
                CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Block being updated");

                int j1;

                try {
                    j1 = this.getData(i, j, k);
                } catch (Throwable throwable1) {
                    j1 = -1;
                }

                crashreportsystemdetails.a("Source block type", (Callable) (new CrashReportSourceBlockType(this, l)));
                CrashReportSystemDetails.a(crashreportsystemdetails, i, j, k, i1, j1);
                throw new ReportedException(crashreport);
            }
        }
    }
}
项目:AreaShop    文件:SignsFeature.java   
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onIndirectSignBreak(BlockPhysicsEvent event) {
    if(event.getBlock().getType() == Material.SIGN_POST || event.getBlock().getType() == Material.WALL_SIGN) {
        // Check if the rent sign is really the same as a saved rent
        if(SignsFeature.getSignByLocation(event.getBlock().getLocation()) != null) {
            // Cancel the sign breaking, will create a floating sign but at least it is not disconnected/gone
            event.setCancelled(true);
        }
    }
}
项目:Tweakkit-Server    文件:World.java   
public void e(int i, int j, int k, Block block) {
    if (!this.isStatic) {
        Block block1 = this.getType(i, j, k);

        try {
            // CraftBukkit start
            CraftWorld world = ((WorldServer) this).getWorld();
            if (world != null) {
                BlockPhysicsEvent event = new BlockPhysicsEvent(world.getBlockAt(i, j, k), CraftMagicNumbers.getId(block));
                this.getServer().getPluginManager().callEvent(event);

                if (event.isCancelled()) {
                    return;
                }
            }
            // CraftBukkit end

            block1.doPhysics(this, i, j, k, block);
        } catch (StackOverflowError stackoverflowerror) { // Spigot Start
            haveWeSilencedAPhysicsCrash = true;
            blockLocation = i + ", " + j + ", " + k; // Spigot End
        } catch (Throwable throwable) {
            CrashReport crashreport = CrashReport.a(throwable, "Exception while updating neighbours");
            CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Block being updated");

            int l;

            try {
                l = this.getData(i, j, k);
            } catch (Throwable throwable1) {
                l = -1;
            }

            crashreportsystemdetails.a("Source block type", (Callable) (new CrashReportSourceBlockType(this, block)));
            CrashReportSystemDetails.a(crashreportsystemdetails, i, j, k, block1, l);
            throw new ReportedException(crashreport);
        }
    }
}
项目:StarQuestCode    文件:RedstoneBridgeListener.java   
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onRedstone(BlockPhysicsEvent event) {
    if (event.getChangedType() != Material.DIODE_BLOCK_ON)
        return;
    Block blockUpdated = event.getBlock();
    if(blockUpdated.getType() != Material.LEVER){
        return;
    }

    plugin.queueDetect(blockUpdated);
}
项目:modules-extra    文件:ListenerBlock.java   
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockFall(final BlockPhysicsEvent event)
{
    if (!this.isActive(BlockFall.class, event.getBlock().getWorld()))
    {
        return;
    }
    BlockState state = event.getBlock().getState();
    if (state.getType().hasGravity() || state.getType() == DRAGON_EGG)
    {
        if (event.getBlock().getRelative(DOWN).getType() == AIR)
        {
            Location loc = state.getLocation();

            BlockFall action = this.set(BlockFall.class, state, null);
            ActionBlock cause = this.plannedFall.remove(loc);
            if (cause instanceof ActionPlayerBlock)
            {
                action.cause = this.reference((ActionPlayerBlock)cause);
            }
            action.setNewBlock(AIR);
            this.logAction(action);
            Block onTop = state.getBlock().getRelative(UP);
            if (onTop.getType().hasGravity() || onTop.getType() == DRAGON_EGG)
            {
                this.preplanBlockFall(new BlockPreFallEvent(onTop.getLocation(), cause));
            }
        }
    }
}
项目:SavageDeathChest    文件:BlockEventListener.java   
/**
 * Block physics event handler<br>
 * remove detached death chest signs from game to prevent players gaining additional signs
 * @param event
 */
@EventHandler
public void signDetachCheck(BlockPhysicsEvent event) {

    Block block = event.getBlock();

    // if event is cancelled, do nothing and return
    if (event.isCancelled()) {
        return;
    }

    // if block is not a DeathChestBlock, do nothing and return
    if (!DeathChestBlock.isDeathChestBlock(block)) {
        return;
    }

    // if block is not a sign, do nothing and return
    if (block.getType() != Material.WALL_SIGN && block.getType() != Material.SIGN_POST) {
        return;
    }

    Sign sign = (Sign)block.getState().getData();
    Block attached_block = block.getRelative(sign.getAttachedFace());

    // if attached block is still there, do nothing and return
    if (attached_block.getType() != Material.AIR) {
        return;
    }

    // cancel event
    event.setCancelled(true);

    // destroy DeathChestBlock
    plugin.chestManager.destroyDeathChestBlock(block);
}
项目:sensibletoolbox    文件:ItemRouter.java   
@Override
public void onBlockPhysics(BlockPhysicsEvent event) {
    Bukkit.getScheduler().runTask(getProviderPlugin(), new Runnable() {
        @Override
        public void run() {
            findNeighbourInventories();
        }
    });
}
项目:sensibletoolbox    文件:BasicSolarCell.java   
@Override
public void onBlockPhysics(BlockPhysicsEvent event) {
    // ensure carpet layer doesn't get popped off (and thus not cleared) when block is broken
    if (event.getBlock().getType() == Material.CARPET) {
        event.setCancelled(true);
    }
}
项目:MGLib    文件:MGListener.java   
@EventHandler(priority = EventPriority.HIGHEST)
public void onBlockPhysics(BlockPhysicsEvent e) {
    boolean cancelled = false;
    String w = e.getBlock().getWorld().getName();
    for (String p : worlds.keySet()) {
        for (int i = 0; i < worlds.get(p).size(); i++) {
            if (worlds.get(p).get(i).equals(w)) {
                if (!Minigame.getMinigameInstance(p).getConfigManager().areBlockPhysicsAllowed()) {
                    e.setCancelled(true);
                    cancelled = true;
                    break;
                }
            }
        }
    }
    if (cancelled) {
        return;
    }
    Block adjBlock = MGUtil.getAttachedSign(e.getBlock());
    if (adjBlock != null) {
        for (Minigame mg : Minigame.getMinigameInstances()) {
            for (LobbySign l : mg.getLobbyManager().signs.values()) {
                if (l.getX() == adjBlock.getX() && l.getY() == adjBlock.getY() && l.getZ() == adjBlock.getZ() &&
                        l.getWorld().equals(adjBlock.getWorld().getName())) {
                    e.setCancelled(true);
                    break;
                }
            }
        }
    }
}
项目:xEssentials-deprecated-bukkit    文件:PortalActivateEvent.java   
@EventHandler
public void psycic(BlockPhysicsEvent e) {
    if(e.isCancelled()) {
        return;
    }

    if(e.getBlock().getType() == Material.PORTAL) {
        for(Portal portal : pl.getConfiguration().getPortalConfig().getPortals().values()) {
            if(portal.getInnerBlocks().contains(e.getBlock())) {
                e.setCancelled(true);
            }
        }
    }
}
项目:xEssentials-deprecated-bukkit    文件:PortalSelectedCreateEvent.java   
@EventHandler
public void onPsyics(BlockPhysicsEvent e) {
    if(e.isCancelled()) {
        return;
    }

    if(e.getBlock().getType() == Material.PORTAL) {
        for(Portal portal : pl.getConfiguration().getPortalConfig().getPortals().values()) {
            if(portal.getInnerBlocks().contains(e.getBlock())) {
                e.setCancelled(true);
                break;
            }
        }
    }
}
项目:Blueprint-A-Bukkit-Plugin    文件:PlayerListener.java   
/**
 *
 * @param bpe
 */
@EventHandler
public void onPhysicsEvent(final BlockPhysicsEvent bpe) {
    if (DataHandler.isBlueprintBlock(bpe.getBlock())) {
        DataHandler.updateBlock(bpe.getBlock());
        bpe.setCancelled(true);
    }
}
项目:Craft-city    文件:World.java   
public void g(int i, int j, int k, int l) {
    if (!this.isStatic) {
        int i1 = this.getTypeId(i, j, k);
        Block block = Block.byId[i1];

        if (block != null) {
            try {
                // CraftBukkit start
                CraftWorld world = ((WorldServer) this).getWorld();
                if (world != null) {
                    BlockPhysicsEvent event = new BlockPhysicsEvent(world.getBlockAt(i, j, k), l);
                    this.getServer().getPluginManager().callEvent(event);

                    if (event.isCancelled()) {
                        return;
                    }
                }
                // CraftBukkit end

                block.doPhysics(this, i, j, k, l);
            } catch (Throwable throwable) {
                CrashReport crashreport = CrashReport.a(throwable, "Exception while updating neighbours");
                CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Block being updated");

                int j1;

                try {
                    j1 = this.getData(i, j, k);
                } catch (Throwable throwable1) {
                    j1 = -1;
                }

                crashreportsystemdetails.a("Source block type", (Callable) (new CrashReportSourceBlockType(this, l)));
                CrashReportSystemDetails.a(crashreportsystemdetails, i, j, k, i1, j1);
                throw new ReportedException(crashreport);
            }
        }
    }
}
项目:Shopkeepers    文件:SignShopListener.java   
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
void onBlockPhysics(BlockPhysicsEvent event) {
    Block block = event.getBlock();
    if (cancelNextBlockPhysicsLoc != null && cancelNextBlockPhysicsLoc.equals(block.getLocation())) {
        event.setCancelled(true);
    } else {
        if (Utils.isSign(block.getType()) && plugin.getShopkeeperByBlock(block) != null) {
            event.setCancelled(true);
        }
    }
}
项目:UltimateGames    文件:ArenaListener.java   
/**
 * Cancels block physics events in arenas not currently running.
 * @param event The {@link org.bukkit.event.block.BlockPhysicsEvent} event.
 */
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockPhysics(BlockPhysicsEvent event) {
    Material material = event.getChangedType();
    if (material == Material.WATER || material == Material.LAVA || UGUtils.hasPhysics(material)) {
        Arena arena = ultimateGames.getArenaManager().getLocationArena(event.getBlock().getLocation());
        if (arena != null && arena.getStatus() != ArenaStatus.RUNNING) {
            event.setCancelled(true);
        }
    }
}
项目:CropControl    文件:CropControlEventHandler.java   
/**
 * Physics checks; launches a break task if the material under review might be breaking and not covered by some other test.
 * 
 * Note that basically all physics related checks involve breaks. Some are 
 * immediate and can be cancelled; others you only know what's going on if you check the material
 * and then check all the conditions that can break it (missing soil, light, etc) as the
 * code paths in new.minecraft.server don't involve any return values.
 * 
 * So for our purposes as we're just augmenting drops at present, we'll look for things we
 * care about, and register a break-check if it looks interesting.
 * 
 * Currently tracked: 
 * <ul><li>Too little light on crops</li><li>Too much light on mushrooms (with wrong soil)</li>
 * <li>No water adjacent to sugarcane</li><li>Solid blocks adjacent to cactus</li></ul> 
 *  
 * @param e The physics event.
 */
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled=true) 
public void onPhysics(BlockPhysicsEvent e) {
    Block block = e.getBlock();
    Material chMat = block.getType(); //getChangedType();
    Location loc = block.getLocation();
    boolean checkBreak = false;
    if (maybeTracked(chMat) && !pendingChecks.contains(loc)) { // do we even slightly care?
        // Check light levels.
        if (Material.CROPS.equals(chMat) || Material.POTATO.equals(chMat) || Material.CARROT.equals(chMat) || Material.BEETROOT.equals(chMat)) {
            if (block.getLightLevel() < 8) {
                checkBreak = true;
            }
        } else if (Material.RED_MUSHROOM.equals(chMat) || Material.BROWN_MUSHROOM.equals(chMat)) {
            Block below = block.getRelative(BlockFace.DOWN);
            Material belowM = below.getType();
            if (!Material.MYCEL.equals(belowM) && !Material.DIRT.equals(belowM)) {
                checkBreak = true;
            } else if (Material.DIRT.equals(belowM) && below.getData() != 2) {
                checkBreak = true;
            }
        }
    }
    if (checkBreak) {
        pendingChecks.add(loc);
        handleBreak(block, BreakType.PHYSICS, null, null);
    } else { // we haven't found a break condition yet. However, what follows aren't light level checks but rather
        // block checks, so these are controlled by a variety of rules. Some involve physics firing _adjacent_ to the block.
        // Basically it's a crapshoot.
        if (Material.SUGAR_CANE_BLOCK.equals(e.getChangedType())) {
            // Sugarcane winds up being weird. I'm still not sure what event fires and removes the bottom block but for
            // unattended (non-player) breaks physics events remove middle and top blocks. So, we just register
            // breaks for lower and upper blocks and if they are gone, we know it then.
            //
            // Note this will leave singular base blocks undetected. TODO
            if (chMat.equals(e.getChangedType())) {
                for (BlockFace a : CropControlEventHandler.traverse) {
                    Location adjL = block.getRelative(a).getLocation();
                    if (!pendingChecks.contains(adjL)) {
                        pendingChecks.add(adjL);
                        // So, the physics check can take a tick to resolve. We mark our interest but defer resolution.
                        Bukkit.getScheduler().runTaskLater(CropControl.getPlugin(), new Runnable() {
                            public void run() {
                                handleBreak(adjL.getBlock(), BreakType.PHYSICS, null, null);
                            }
                        }, 1L);
                    }
                }
            }
        } else if (Material.CACTUS.equals(e.getChangedType())) {
            if (chMat.equals(e.getChangedType())) return; // handled elsewhere

            // Cactus is a little simpler. It breaks on adjacent placements; that's what would trigger this event. 
            for (BlockFace face : CropControlEventHandler.directions) {
                // We look around face-adjacent places and trigger a break-check for any cactus found.
                Block adj = block.getRelative(face);
                Material adjM = adj.getType();
                Location adjL = adj.getLocation();
                if (Material.CACTUS.equals(adjM) && !pendingChecks.contains(adjL)) {
                    pendingChecks.add(adjL);
                    // So, the physics check can take a tick to resolve. We mark our interest but defer resolution.
                    Bukkit.getScheduler().runTaskLater(CropControl.getPlugin(), new Runnable() {
项目:ProjectAres    文件:BlockPhysicsListener.java   
@EventHandler
public void onBlockPhysics(BlockPhysicsEvent event) {
    if(!allowPhysics()) {
        event.setCancelled(true);
    }
}
项目:ProjectAres    文件:EnvironmentControlListener.java   
@EventHandler(priority = EventPriority.HIGH)
public void physics(final BlockPhysicsEvent event) {
    event.setCancelled(true);
}
项目:NeverLag    文件:AntiInfiniteRail.java   
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onBlockPhysics(BlockPhysicsEvent e) {
    if (cm.isAntiInfiniteRail && this.isDupeBlock(e.getChangedType()) && this.isRails(e.getBlock().getType())) {
        e.setCancelled(true);
    }
}