GVKun编程网logo

org.bukkit.event.block.BlockPhysicsEvent的实例源码(cockroachdb 源码分析)

17

想了解org.bukkit.event.block.BlockPhysicsEvent的实例源码的新动态吗?本文将为您提供详细的信息,我们还将为您解答关于cockroachdb源码分析的相关问题,此外

想了解org.bukkit.event.block.BlockPhysicsEvent的实例源码的新动态吗?本文将为您提供详细的信息,我们还将为您解答关于cockroachdb 源码分析的相关问题,此外,我们还将为您介绍关于org.bukkit.block.Block的实例源码、org.bukkit.block.ContainerBlock的实例源码、org.bukkit.event.block.Action的实例源码、org.bukkit.event.block.BlockBreakEvent的实例源码的新知识。

本文目录一览:

org.bukkit.event.block.BlockPhysicsEvent的实例源码(cockroachdb 源码分析)

org.bukkit.event.block.BlockPhysicsEvent的实例源码(cockroachdb 源码分析)

项目: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.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,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;
}
项目: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,IBlockData iblockdata) {
    if (!this.f(world,blockposition.getZ());
        BlockPhysicsEvent event = new BlockPhysicsEvent(block,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,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(),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,k),CraftMagicNumbers.getId(block));
                this.getServer().getPluginManager().callEvent(event);

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

            block1.doPhysics(this,i,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,k);
            } catch (Throwable throwable1) {
                l = -1;
            }

            crashreportsystemdetails.a("Source block type",(Callable) (new CrashReportSourceBlockType(this,block)));
            CrashReportSystemDetails.a(crashreportsystemdetails,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 l) {
    if (!this.isstatic) {
        int i1 = this.getTypeId(i,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,l);
                    this.getServer().getPluginManager().callEvent(event);

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

                block.doPhysics(this,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,k);
                } catch (Throwable throwable1) {
                    j1 = -1;
                }

                crashreportsystemdetails.a("Source block type",l)));
                CrashReportSystemDetails.a(crashreportsystemdetails,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,block);
        } catch (StackOverflowError stackoverflowerror) { // Spigot Start
            haveWeSilencedAPhysicsCrash = true;
            blockLocation = i + "," + j + "," + k; // Spigot End
        } catch (Throwable throwable) {
            CrashReport crashreport = CrashReport.a(throwable,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,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);
    } 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(),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);
    }
}

org.bukkit.block.Block的实例源码

org.bukkit.block.Block的实例源码

项目:bskyblock    文件:IslandGuard.java   
@EventHandler(priority = EventPriority.LOW)
public void onPistonExtend(BlockPistonExtendEvent e) {
    if (DEBUG) {
        plugin.getLogger().info(e.getEventName());
    }
    Location pistonLoc = e.getBlock().getLocation();
    if (Settings.allowPistonPush || !Util.inWorld(pistonLoc)) {
        //plugin.getLogger().info("DEBUG: Not in world");
        return;
    }
    Island island = plugin.getIslands().getProtectedislandAt(pistonLoc);
    if (island == null || !island.onIsland(pistonLoc)) {
        //plugin.getLogger().info("DEBUG: Not on is island protection zone");
        return;
    }
    // We need to check where the blocks are going to go,not where they are
    for (Block b : e.getBlocks()) {
        if (!island.onIsland(b.getRelative(e.getDirection()).getLocation())) {
            //plugin.getLogger().info("DEBUG: Block is outside protected area");
            e.setCancelled(true);
            return;
        }
    }
}
项目:Arc-v2    文件:LocationHelper.java   
/**
 * @return if we have walked onto a fence.
 */
public static boolean walkedOnFence(Location location) {
    // check if were already under that block.
    Location subtracted = location.clone().subtract(0,1,0);
    Block groundBlock = subtracted.getBlock();
    if (MaterialHelper.isFence(groundBlock.getType()) || MaterialHelper.isFenceGate(groundBlock.getType())) {
        return true;
    }

    LocationBit bit = new LocationBit(0.5);
    for (int i = 1; i <= 4; i++) {
        Location newLocation = location.clone().add(bit.getX(),-1,bit.getZ());
        Block block = newLocation.getBlock();
        if (MaterialHelper.isFence(block.getType()) || MaterialHelper.isFenceGate(block.getType())) {
            return true;
        }
        bit.shift(i);
    }
    return false;
}
项目:HCFCore    文件:PearlGlitchListener.java   
@EventHandler(ignoreCancelled = true,priority = EventPriority.norMAL)
public void onPlayerInteract(PlayerInteractEvent event) {
    if (event.getAction() == Action.RIGHT_CLICK_BLOCK && event.hasItem() && event.getItem().getType() == Material.ENDER_PEARL) {
        Block block = event.getClickedBlock();
        // Don't prevent opening chests,etc,as these won't throw the Enderpearls anyway
        if (block.getType().isSolid() && !(block.getState() instanceof InventoryHolder)) {
            Faction factionAt = HCF.getPlugin().getFactionManager().getFactionAt(block.getLocation());
            if (!(factionAt instanceof ClaimableFaction)) {
                return;
            }

            event.setCancelled(true);
            Player player = event.getPlayer();
            player.setItemInHand(event.getItem()); // required to update Enderpearl count
        }
    }
}
项目:CropControl    文件:CropControlEventHandler.java   
/**
 * So far specifically handles these cases:
 * 
 * 1) Block burnt is tracked
 * 2) Block burnt is under a tracked block (probably only mushrooms eligible)
 * 3) Block burnt was a jungle tree,checks for cocoa.
 * 4) Burnt block had mushroom on top and cocoa on the sides
 * 
 * @param e The event
 */
@EventHandler(priority=EventPriority.HIGHEST,ignoreCancelled = true)
public void onBlockBurn(BlockBurnEvent e) {
    Block block = e.getBlock();
    if (maybeSideTracked(block)) {
        trySideBreak(block,BreakType.FIRE,null);
    }
    if (maybeBelowTracked(block)) {
        block = block.getRelative(BlockFace.UP);
    }
    Location loc = block.getLocation();
    if (!pendingChecks.contains(loc)) {
        pendingChecks.add(loc);
        handleBreak(block,null,null);
    }
}
项目:mczone    文件:Arena.java   
public Arena(String name,String worldName,int id,Block sign,List<Map> maps) {
    this.name = name;
    this.id = id;
    this.worldName = worldName;     
    this.maps = maps;
    this.index = 0;
    this.signBlock = sign;

    this.state = ArenaState.WAITING;
    this.schedule = new ArenaSchedule(this);
    this.schedule.runTasktimerAsynchronously(Walls.getInstance(),20);

    registerTeams();
    loadWorld();

    list.add(this);
}
项目:NavyCraft2-Lite    文件:CraftMover.java   
@SuppressWarnings("deprecation")
public void reloadWeapons(Player p) {

    for (DataBlock dataBlock : craft.dataBlocks) {

        Block theBlock = getWorldBlock(dataBlock.x,dataBlock.y,dataBlock.z);
        if (theBlock.getTypeId() == 23) {

            for (OneCannon onec : aimCannon.getCannons()) {
                if (onec.isThisCannon(theBlock.getLocation(),false)) {
                    onec.reload(p);
                }
            }

        }
    }
}
项目:WC    文件:IronElevators.java   
@EventHandler(priority = EventPriority.HIGH)
public void upElevator(PlayerMoveEvent e) {
    Player p = e.getPlayer();
    Block b = e.getTo().getBlock().getRelative(BlockFace.DOWN);
    if (p.hasPermission("ironelevators.use") && e.getFrom().getY() < e.getTo().getY()
            && b.getType() == elevatorMaterial) {
        b = b.getRelative(BlockFace.UP,minelevation);
        int i = maxElevation;
        while (i > 0 && !(
                b.getType() == elevatorMaterial
                        && b.getRelative(BlockFace.UP).getType().isTransparent()
                        && b.getRelative(BlockFace.UP,2).getType().isTransparent()
        )
                ) {
            i--;
            b = b.getRelative(BlockFace.UP);
        }
        if (i > 0) {
            Location l = p.getLocation();
            l.setY(l.getY() + maxElevation + 3 - i);
            p.teleport(l);
            p.getWorld().playSound(p.getLocation(),Sound.ENTITY_IRONGOLEM_ATTACK,1);
        }
    }
}
项目:DynamicAC    文件:PlayerListener.java   
@EventHandler
public void onPlayerInteract2(PlayerInteractEvent e) {
    Player player = e.getPlayer();
    PlayerInventory inventory = player.getInventory();
    if(e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) {
        Material material = inventory.getItemInHand().getType();
        if(material == Material.BOW) {
            DynamicAC.getManager().getBackend().logBowWindUp(player,System.currentTimeMillis());
        } else if(Utilities.isFood(material)) {
            DynamicAC.getManager().getBackend().logEatingStart(player);
        }
    }
    Block block = e.getClickedBlock();
    if(block != null) {
        distance distance = new distance(player.getLocation(),block.getLocation());
        DynamicAC.getManager().getBackend().checkLongReachBlock(player,distance.getXDifference(),distance
                .getYDifference(),distance.getZDifference());
    }
}
项目:mczone    文件:Events.java   
@EventHandler
  public void onBlockBreak(BlockBreakEvent event) {
if (Walls.getspectators().contains(event.getPlayer().getName())) {
    event.setCancelled(true);
    return;
}

      if (State.PVP)
          return;

      Block b = event.getBlock();
      if (b == null)
          return;
      Team team = Team.getTeam(event.getPlayer());
      if (b.getX() < team.getMin().getX() + 1 || b.getZ() < team.getMin().getZ() + 1) {
          event.setCancelled(true);
      }
      if (b.getX() > team.getMax().getX() - 1 || b.getZ() > team.getMax().getZ() - 1) {
          event.setCancelled(true);
      }
  }
项目:HCFCore    文件:VisualiseHandler.java   
/**
 * Clears a visual block at a given location for a player.
 *
 * @param player
 *            the player to clear for
 * @param location
 *            the location to clear at
 * @param sendRemovalPacket
 *            if a packet to send a block change should be sent (this is used to prevent unnecessary packets sent when disconnecting or changing worlds,for example)
 * @return if the visual block was shown in the first place
 */
public boolean clearVisualBlock(Player player,Location location,boolean sendRemovalPacket) {
    synchronized (storedVisualises) {
        VisualBlock visualBlock = this.storedVisualises.remove(player.getUniqueId(),location);
        if (sendRemovalPacket && visualBlock != null) {
            // Have to send a packet to the original block type,don't send if the fake block has the same data properties though.
            Block block = location.getBlock();
            VisualBlockData visualBlockData = visualBlock.getBlockData();
            if (visualBlockData.getBlockType() != block.getType() || visualBlockData.getData() != block.getData()) {
                player.sendBlockChange(location,block.getType(),block.getData());
            }

            return true;
        }
    }

    return false;
}
项目:AntiCheat    文件:BlockHitManager.java   
public static boolean hitBlock(Player player,Block block) {
    if (player.getGameMode() == GameMode.CREATIVE)
        return true;

    PlayerBlockTracking playerBlockTracking = getPlayerBlockTracking(player);

    if (playerBlockTracking.isBlock(block)) {
        return true;
    }

    long time = playerBlockTracking.getTimeDifference();
    playerBlockTracking.incrementHackingIndicator();
    playerBlockTracking.setBlock(block);
    playerBlockTracking.updateTime();

    int decrement = (int) (time / OrebfuscatorConfig.AntiHitHackDecrementFactor);
    playerBlockTracking.decrementHackingIndicator(decrement);

    if (playerBlockTracking.getHackingIndicator() == OrebfuscatorConfig.AntiHitHackMaxViolation)
        playerBlockTracking.incrementHackingIndicator(OrebfuscatorConfig.AntiHitHackMaxViolation);

    if (playerBlockTracking.getHackingIndicator() > OrebfuscatorConfig.AntiHitHackMaxViolation)
        return false;

    return true;
}
项目:WC    文件:IronElevators.java   
@EventHandler(priority = EventPriority.HIGH)
public void downElevator(PlayerToggleSneakEvent e) {
    Player p = e.getPlayer();
    Block b = p.getLocation().getBlock().getRelative(BlockFace.DOWN);
    if (p.hasPermission("ironelevators.use") && !p.isSneaking()
            && b.getType() == elevatorMaterial) {
        b = b.getRelative(BlockFace.DOWN,minelevation);
        int i = maxElevation; //16
        while (i > 0 && !(
                b.getType() == elevatorMaterial
                        && b.getRelative(BlockFace.UP).getType().isTransparent()
                        && b.getRelative(BlockFace.UP,2).getType().isTransparent()
        )
                ) {
            //e.getPlayer().sendMessage("" + b.getLocation() + b.getType());
            i--;
            b = b.getRelative(BlockFace.DOWN);
        }
        if (i > 0) {
            Location l = p.getLocation();
            l.setY(l.getY() - maxElevation - 3 + i);
            p.teleport(l);
            p.getWorld().playSound(p.getLocation(),1);
        }
    }
}
项目:Uranium    文件:CraftHumanEntity.java   
public InventoryView openWorkbench(Location location,boolean force) {
    if (!force) {
        Block block = location.getBlock();
        if (block.getType() != Material.WORKBENCH) {
            return null;
        }
    }
    if (location == null) {
        location = getLocation();
    }
    getHandle().displayGUIWorkbench(location.getBlockX(),location.getBlockY(),location.getBlockZ());
    if (force) {
        getHandle().openContainer.checkReachable = false;
    }
    return getHandle().openContainer.getBukkitView();
}
项目:ProjectAres    文件:FallingBlocksMatchModule.java   
/**
 * Return the number of unsupported blocks connected to any blocks neighboring the given location.
 * An air block is placed there temporarily if it is not already air. The search may bail out early
 * when the count is >= the given limit,though this cannot be guaranteed.
 */
public int countUnsupportedneighbors(Block block,int limit) {
    BlockState state = null;
    if(block.getType() != Material.AIR) {
        state = block.getState();
        block.setTypeIdAndData(0,(byte) 0,false);
    }

    int count = countUnsupportedneighbors(encodePos(block),limit);

    if(state != null) {
        block.setTypeIdAndData(state.getTypeId(),state.getRawData(),false);
    }

    return count;
}
项目:Uranium    文件:CraftLivingEntity.java   
private List<Block> getLineOfSight(HashSet<Byte> transparent,int maxdistance,int maxLength) {
    if (maxdistance > 120) {
        maxdistance = 120;
    }
    ArrayList<Block> blocks = new ArrayList<Block>();
    Iterator<Block> itr = new BlockIterator(this,maxdistance);
    while (itr.hasNext()) {
        Block block = itr.next();
        blocks.add(block);
        if (maxLength != 0 && blocks.size() > maxLength) {
            blocks.remove(0);
        }
        byte id = (byte)block.getTypeId();
        if (transparent == null) {
            if (id != 0) {
                break;
            }
        } else {
            if (!transparent.contains(id)) {
                break;
            }
        }
    }
    return blocks;
}
项目:HCFCore    文件:CrowbarListener.java   
@EventHandler(ignoreCancelled = true,priority = EventPriority.MONITOR)
public void onBlockPlace(BlockPlaceEvent event) {
    Block block = event.getBlockPlaced();
    ItemStack stack = event.getItemInHand();
    Player player = event.getPlayer();
    if (block.getState() instanceof CreatureSpawner && stack.hasItemMeta()) {
        ItemMeta Meta = stack.getItemMeta();

        if (Meta.hasLore() && Meta.hasdisplayName()) {
            CreatureSpawner spawner = (CreatureSpawner) block.getState();
            List<String> lore = Meta.getLore();
            if (!lore.isEmpty()) {
                String spawnerName = ChatColor.stripColor(lore.get(0).toupperCase());
                Optional<EntityType> entityTypeOptional = GuavaCompat.getIfPresent(EntityType.class,spawnerName);
                if (entityTypeOptional.isPresent()) {
                    spawner.setSpawnedType(entityTypeOptional.get());
                    spawner.update(true,true);
                    player.sendMessage(ChatColor.AQUA + "Placed a " + ChatColor.BLUE + spawnerName + ChatColor.AQUA + " spawner.");
                }
            }
        }
    }
}
项目:Uranium    文件:CraftBlockState.java   
public boolean update(boolean force,boolean applyPhysics) {
    Block block = getBlock();

    if (block.getType() != getType()) {
        if (force) {
            block.setTypeId(getTypeId(),applyPhysics);
        } else {
            return false;
        }
    }

    block.setData(getRawData(),applyPhysics);
    world.getHandle().markBlockForUpdate(x,y,z);
    // Cauldron start - restore TE data from snapshot
    if (nbt != null)
    {
        TileEntity te = world.getHandle().getTileEntity(x,z);
        if (te != null)
        {
            te.readFromNBT(nbt);
        }
    }
    // Cauldron end

    return true;
}
项目:mysticraft    文件:CraftingManager.java   
@EventHandler
public void onDespawn(ItemDespawnEvent event) {
    for (Entry<Block,CraftingOperation> entry : operations.entrySet()) {
        CraftingOperation op = entry.getValue();
        for (Item item : op.getItemEntities()) {
            if (item == event.getEntity()) {
                op.clear(true);
                operations.remove(entry.getKey());
                return;
            }
        }
    }
}
项目:NavyCraft2-Lite    文件:Craftrotator.java   
@SuppressWarnings("deprecation")
public void removeSupportBlocks() {
    short blockId;
    Block block;

    for (int x = 0; x < craft.sizeX; x++) {
        for (int z = 0; z < craft.sizeZ; z++) {
            for (int y = craft.sizeY - 1; y > -1; y--) {
            //for (int y = 0; y < craft.sizeY; y++) {

                blockId = craft.matrix[x][y][z];

                // craft block,replace by air
                if (BlocksInfo.needsSupport(blockId)) {

                    //Block block = world.getBlockAt(posX + x,posY + y,posZ + z);
                    block = getWorldBlock(x,z);

                    // special case for doors
                    // we need to remove the lower part of the door only,or the door will pop
                    // lower part have data 0 - 7,upper part have data 8 - 15
                    if (blockId == 64 || blockId == 71) { // wooden door and steel door
                        if (block.getData() >= 8)
                            continue;
                    }

                    if(blockId == 26) { //bed
                        if(block.getData() >= 4)
                            continue;
                    }

                    setBlock(0,block);
                }
            }
        }
    }
}
项目:FactionsXL    文件:LWCIntegration.java   
public boolean canBypass(Player player,Block block) {
    Region region = plugin.getBoard().getByLocation(block.getLocation());
    if (region == null || region.isNeutral()) {
        return false;
    }
    Faction faction = region.getowner();
    return faction.isAdmin(player);
}
项目:mczone    文件:Lobby.java   
public Sign getKitSign(Sign s) {
    for (Block b : kitSigns) 
        if (b.getX() == s.getX() && b.getY() == s.getY() && b.getZ() == s.getZ())
            if (b.getType() == Material.SIGN || b.getType() == Material.WALL_SIGN)
                return (Sign) b.getState();
    return null;
}
项目:CropControl    文件:CropControlEventHandler.java   
/**
 * Addresses cocoa on sides of trees; can be on any side,but not top,not bottom
 * 
 * @param block The block to test type on
 * @return True if maybe Could possible contain cocoa
 */
@SuppressWarnings("deprecation")
private boolean maybeSideTracked(Block block) {
    if (Material.LOG.equals(block.getType()) && block.getData() == 3) {
        return true;
    } else {
        return false;
    }
}
项目:mczone    文件:ConfigAPI.java   
public Block getBlock(String s) {
    String base = s + ".";
       String world = config.getString(base + "world");
       int x = config.getInt(base + "x");
       int y = config.getInt(base + "y");
       int z = config.getInt(base + "z");

       new WorldCreator(world).createWorld();

    Block r = Bukkit.getWorld(world).getBlockAt(x,z);
    return r;
}
项目:Recreator    文件:Structurechangelistener.java   
@EventHandler(priority = EventPriority.HIGHEST,ignoreCancelled = true)
public void onPlace(BlockPlaceEvent evt) {
    Block source = evt.getBlock();
    Structure s = match(source);
    if (s == null) return;

    s.onCreate(evt);
}
项目:CropControl    文件:CropControlEventHandler.java   
@EventHandler(priority=EventPriority.HIGHEST,ignoreCancelled = true)
public void onEntityChangeBlock(EntityChangeBlockEvent e) {
    Block block = e.getBlock();
    if (maybeSideTracked(block)) {
        trySideBreak(block,BreakType.NATURAL,null);
    }
}
项目:bskyblock    文件:IslandGuard1_9.java   
/**
 * Handle blocks that need special treatment
 * Tilling of coarse dirt into dirt using off-hand (regular hand is in 1.8)
 * Usually prevented because it Could lead to an endless supply of dirt with gravel
 *
 * @param e
 */
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.LOW,ignoreCancelled=true)
public void onPlayerInteract(final PlayerInteractEvent e) {
    if (DEBUG) {
        plugin.getLogger().info("1.9 " + e.getEventName());
    }
    if (!e.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
        return;
    }
    if (!Util.inWorld(e.getPlayer())) {
        return;
    }
    if (e.getPlayer().isOp()) {
        return;
    }
    // This permission bypasses protection
    if (VaultHelper.hasPerm(e.getPlayer(),Settings.PERMPREFIX + "mod.bypassprotect")
            || VaultHelper.hasPerm(e.getPlayer(),Settings.PERMPREFIX + "craft.dirt")) {
        return;
    }
    // Prevents tilling of coarse dirt into dirt
    ItemStack inHand = e.getPlayer().getInventory().getItemInOffHand();
    if (inHand.getType() == Material.WOOD_HOE || inHand.getType() == Material.IRON_HOE || inHand.getType() == Material.GOLD_HOE
            || inHand.getType() == Material.DIAMOND_HOE || inHand.getType() == Material.STONE_HOE) {
        // plugin.getLogger().info("1.8 " + "DEBUG: hoe in hand");
        Block block = e.getClickedBlock();
        // plugin.getLogger().info("1.8 " + "DEBUG: block is " + block.getType() +
        // ":" + block.getData());
        // Check if coarse dirt
        if (block.getType() == Material.DIRT && block.getData() == (byte) 1) {
            // plugin.getLogger().info("1.8 " + "DEBUG: hitting coarse dirt!");
            e.setCancelled(true);
        }
    }
}
项目:CropControl    文件:CastleGatesEventHandler.java   
/**
 * CastleGates has custom block voiding when you "draw" a gate.
 * 
 * @param e CastleGates post-action event.
 */
@EventHandler
public void onDrawEvent(CastleGatesDrawGateEvent e) {
    try {
        List<Block> blocks = new ArrayList<Block>();
        for (Location location : e.getImpacted()) {
            blocks.add(location.getBlock());
        }
        CropControl.getPlugin().getEventHandler().doMultiblockHandler(blocks,BreakType.PISTON,null);
    } catch (Exception g) {
        CropControl.getPlugin().warning("Failed to handle CastleGates Draw Gate Event:",g);
    }
}
项目:KingdomFactions    文件:BuildModule.java   
public boolean isBuilding(Block block) {
    if(block == null) {
        return false;
    }
    if(block.getType() != Material.COAL_BLOCK) {
        return false;
    }


    return getBuilding(block) != null;
}
项目:AntiCheat    文件:BlockHitManager.java   
public static void breakBlock(Player player,Block block) {
    if (player.getGameMode() == GameMode.CREATIVE)
        return;

    PlayerBlockTracking playerBlockTracking = getPlayerBlockTracking(player);
    if (playerBlockTracking.isBlock(block)) {
        playerBlockTracking.decrementHackingIndicator(2);
    }
}
项目:NavyCraft2-Lite    文件:CraftMover.java   
@SuppressWarnings("deprecation")
public void delayedRestoreSigns(int dx,int dy,int dz) {

    plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin,() -> {
        if (NavyCraft.shutDown || craft.sinking) { return; }

        Block theBlock;

        for (DataBlock complexBlock : craft.complexBlocks) {
            theBlock = getWorldBlock(dx + complexBlock.x,dy + complexBlock.y,dz + complexBlock.z);

            theBlock.setData((byte) complexBlock.data);

            if (((complexBlock.id == 63) || (complexBlock.id == 68))) {
                NavyCraft.instance.DebugMessage("Restoring a sign.",4);
                setBlock(complexBlock.id,theBlock);
                // theBlock.setcraft.typeId(complexBlock.id);
                theBlock.setData((byte) complexBlock.data);
                // Sign sign = (Sign) theBlock;
                if ((theBlock.getTypeId() == 63) || (theBlock.getTypeId() == 68)) {
                    Sign sign = (Sign) theBlock.getState();

                    sign.setLine(0,complexBlock.signLines[0]);
                    sign.setLine(1,complexBlock.signLines[1]);
                    sign.setLine(2,complexBlock.signLines[2]);
                    sign.setLine(3,complexBlock.signLines[3]);

                    sign.update();
                }
            }
        }
        structureUpdate(null,false);
    });

}
项目:Arcadia-Spigot    文件:RainbowJumpGame.java   
@Override
public void onGameStart() {
    Iterator<Block> glassBlocks = glass.iterator();
    while(glassBlocks.hasNext()) {
        glassBlocks.next().setType(Material.AIR);
    }
}
项目:Uranium    文件:BlockMetadataStore.java   
/**
 * Retrieves the Metadata for a {@link Block},ensuring the block being asked for actually belongs to this BlockMetadataStore's
 * owning world.
 * @see MetadataStoreBase#getMetadata(Object,String)
 */
@Override
public List<MetadataValue> getMetadata(Block block,String MetadataKey) {
    if(block.getWorld() == owningWorld) {
        return super.getMetadata(block,MetadataKey);
    } else {
        throw new IllegalArgumentException("Block does not belong to world " + owningWorld.getName());
    }
}
项目:ProjectAres    文件:CraftingProtect.java   
@EventHandler(priority = EventPriority.MONITOR)
public void cloneCraftingWindow(final PlayerInteractEvent event) {
    if(!AntiGrief.CraftProtect.enabled()) {
        return;
    }

    if(!event.isCancelled() && event.getAction() == Action.RIGHT_CLICK_BLOCK && event.getPlayer().getopenInventory().getType() == InventoryType.CRAFTING /* nothing open */) {
        Block block = event.getClickedBlock();
        if(block != null && block.getType() == Material.WORKBENCH && !event.getPlayer().isSneaking()) {
            // create the window ourself
            event.setCancelled(true);
            event.getPlayer().openWorkbench(null,true); // doesn't check reachable
        }
    }
}
项目:mczone    文件:ParkourEndCmd.java   
public boolean execute(CommandSender sender,String[] args) {
    if (args.length != 1) {
        Chat.player(sender,"&cPlease include the name.");
        return true;
    }

    Course c = Course.get(args[0]);
    if (c == null) {
        Chat.player(sender,"&7[Parkour] Couldn't find the course," + args[0]);
        return true;
    }

    Player p = (Player) sender;

Block b = p.getTargetBlock(null,10);
if (b == null || b.getType() != Material.STONE_BUTTON) {
    Chat.player(sender,"&2[SG] &cThat is not a button");
    return true;
}
Parkour.getInstance().getConfigAPI().set(c.getName() + ".end.x",b.getX());
Parkour.getInstance().getConfigAPI().set(c.getName() + ".end.y",b.getY());
Parkour.getInstance().getConfigAPI().set(c.getName() + ".end.z",b.getZ());
Parkour.getInstance().getConfigAPI().set(c.getName() + ".end.world",b.getWorld().getName());
Chat.player(sender,"&7[Parkour] &aEnd button added to " + c.getName());
    Parkour.getInstance().saveConfig();
    Parkour.getInstance().loadCourses();

      return true;
  }
项目:Zorahpractice    文件:Cuboid.java   
/**
 * Check if the Cuboid contains only blocks of the given type
 *
 * @param blockId - The block ID to check for
 * @return true if this Cuboid contains only blocks of the given type
 */
public boolean containsOnly(int blockId) {
    for (Block b : this) {
        if (b.getTypeId() != blockId) return false;
    }
    return true;
}
项目:Slimefun4-Chinese-Version    文件:AutomatedCraftingChAmber.java   
protected void tick(Block b) {
    if (BlockStorage.getBlockInfo(b,"enabled").equals("false")) return;
    if (ChargableBlock.getCharge(b) < getEnergyConsumption()) return;

    BlockMenu menu = BlockStorage.getInventory(b);

    StringBuilder builder = new StringBuilder();
    int i = 0;
    for (int j = 0; j < 9; j++) {
        if (i > 0) {
            builder.append(" </slot> ");
        }

        ItemStack item = menu.getItemInSlot(getInputSlots()[j]);

        if (item != null && item.getAmount() == 1) return;

        builder.append(CustomItemSerializer.serialize(item,ItemFlag.DATA,ItemFlag.ITEMMeta_disPLAY_NAME,ItemFlag.ITEMMeta_LORE,ItemFlag.MATERIAL));

        i++;
    }

    String input = builder.toString();

    if (recipes.containsKey(input)) {
        ItemStack output = recipes.get(input).clone();

        if (fits(b,new ItemStack[] {output})) {
            pushItems(b,new ItemStack[] {output});
            ChargableBlock.addCharge(b,-getEnergyConsumption());
            for (int j = 0; j < 9; j++) {
                if (menu.getItemInSlot(getInputSlots()[j]) != null) menu.replaceExistingItem(getInputSlots()[j],InvUtils.decreaseItem(menu.getItemInSlot(getInputSlots()[j]),1));
            }
        }
    }
}
项目:Warzone    文件:ExplosiveListener.java   
@EventHandler(priority = EventPriority.MONITOR,ignoreCancelled = true)
public void onBlockPistonRetract(BlockPistonRetractEvent event) {
    if(!this.tracker.isEnabled(event.getBlock().getWorld())) return;

    if(event.issticky()) {
        Block newBlock = event.getBlock().getRelative(event.getDirection());
        Block oldBlock = newBlock.getRelative(event.getDirection());
        Player player = this.tracker.getPlacer(oldBlock);
        if(player != null) {
            this.tracker.setPlacer(oldBlock,null);
            this.tracker.setPlacer(newBlock,player);
        }
    }
}
项目:Warzone    文件:dispenserListener.java   
@EventHandler(priority = EventPriority.MONITOR,ignoreCancelled = true)
public void onBlockExplode(EntityExplodeEvent event) {
    if (!this.tracker.isEnabled(event.getLocation().getWorld())) return;

    // Remove all blocks that are destroyed from explosion
    for (Block block : event.blockList()) {
        if (block.getType() == Material.disPENSER) this.tracker.clearPlacer(block);
    }
}
项目:ProjectAres    文件:BlockTransformlistener.java   
@EventWrapper
public void onPrimeTNT(ExplosionPrimeEvent event) {
    if(event.getEntity() instanceof TNTPrimed && !(event instanceof InstantTNTPlaceEvent)) {
        Block block = event.getEntity().getLocation().getBlock();
        if(block.getType() == Material.TNT) {
            ParticipantState player;
            if(event instanceof ExplosionPrimeByEntityEvent) {
                player = entityResolver.getowner(((ExplosionPrimeByEntityEvent) event).getPrimer());
            } else {
                player = null;
            }
            callEvent(event,block.getState(),BlockStateUtils.toAir(block),player);
        }
    }
}
项目:ProjectAres    文件:CoreMatchModule.java   
@EventHandler(priority = EventPriority.HIGHEST,ignoreCancelled = true)
public void damageCheck(BlockdamageEvent event) {
    Block block = event.getBlock();
    if(block.getWorld() != this.match.getWorld()) return;
    MatchPlayer player = this.match.getPlayer(event.getPlayer());
    Vector center = BlockUtils.center(block).toVector();

    for(Core core : this.cores) {
        if(!core.hasLeaked() && core.getCasingRegion().contains(center) && player.getParty() == core.getowner()) {
            event.setCancelled(true);
            player.sendWarning(pgmTranslations.t("match.core.damageOwn",player),true);
        }
    }
}

org.bukkit.block.ContainerBlock的实例源码

org.bukkit.block.ContainerBlock的实例源码

项目:simple-survival-games    文件:ArenaContainer.java   
/**
 * Get the current container
 * @return the container
 */
public ContainerBlock getContainerBlock() {
    // Get the container block,the block may not be null
    Block b = getBlock();
    if(b == null)
        return null;

    // Convert the block to a control and return
    if(b.getState() instanceof ContainerBlock)
        return (ContainerBlock) b.getState();
    return null;
}

org.bukkit.event.block.Action的实例源码

org.bukkit.event.block.Action的实例源码

项目:NeverLag    文件:AntiUseEggsChangeSpawnerType.java   
@EventHandler(priority = EventPriority.norMAL,ignoreCancelled = true)
public void onPlayerInteract(PlayerInteractEvent e) {
    if (!cm.isdisableChangeSpawnerType) {
        return;
    }
    if (e.getAction() == Action.RIGHT_CLICK_BLOCK) {
        if (e.getClickedBlock().getType() == Material.MOB_SPAWNER) {
            if (e.getItem() == null) {
                return;
            }
            if (e.getPlayer().isOp()) {
                return;
            }
            if (e.getItem().getType() == Material.MONSTER_EGG || e.getItem().getType() == Material.MONSTER_EGGS) {
                e.setCancelled(true);
            }
        }
    }
}
项目:MT_Communication    文件:WalkieTalkieListener.java   
@EventHandler
public void onWalkieTalkieInteract(PlayerInteractEvent e) {
    if (e.getPlayer().getInventory().getItemInMainHand().getType() != Material.REDSTONE_COMParaTOR)
        return;
    if (e.getHand() == EquipmentSlot.OFF_HAND)
        return;

    WalkieTalkie wt = new WalkieTalkie(main,main.getPlayerManager().getPlayer(e.getPlayer()).getCurrentWalkieTalkieFrequency());

    // Left click to tune frequency.
    if (e.getAction() == Action.LEFT_CLICK_AIR || e.getAction() == Action.LEFT_CLICK_BLOCK) {
        if (e.getPlayer().isSneaking()) {
            wt.decreaseFrequency(e.getPlayer());
        } else {
            wt.increaseFrequency(e.getPlayer());
        }
    }

}
项目:CloudNet    文件:SignSelector.java   
@EventHandler
public void handleInteract(PlayerInteractEvent e)
{
    if (e.getAction().equals(Action.RIGHT_CLICK_BLOCK) && (e.getClickedBlock().getType().equals(Material.SIGN_POST) || e.getClickedBlock().getType().equals(Material.WALL_SIGN)))
    {
        if (containsPosition(e.getClickedBlock().getLocation()))
        {
            Sign sign = getSignByPosition(e.getClickedBlock().getLocation());
            if (sign.getServerInfo() != null)
            {
                String s = sign.getServerInfo().getServiceId().getServerId();
                ByteArrayDataOutput output = ByteStreams.newDataOutput();
                output.writeUTF("Connect");
                output.writeUTF(s);
                e.getPlayer().sendpluginMessage(CloudServer.getInstance().getPlugin(),"BungeeCord",output.toByteArray());
            }
        }
    }
}
项目:bankomat    文件:BankMenuListener.java   
@EventHandler
public void onPlayerInteract(PlayerInteractEvent e) {   
    if (e.getAction() == Action.RIGHT_CLICK_BLOCK) { // This check needs to be there,'cause RightClickAction has only the getType function,LeftClickAction doesnt and boooom!!
        Player player = (Player) e.getPlayer();
        ItemStack item = e.getItem();
        Block block = e.getClickedBlock();
        String bankId = BukkitUtils.getNBTTag(item,"bankid");

        if (item == null || block == null) return;

        if (bankId != null && bankId.length() > 0 && item.getType() == Material.PAPER && block.getType() == Material.ENDER_STONE) {
            // got a foreign card?
            if (!bankId.equals(player.getUniqueId().toString())) {
                player.getInventory().remove(item);
                BankomatCommand.appendCreditCardToUser(player); 
            } 

            player.openInventory(bankUi); // dispatch our event by opening bankUi here:
        }   
    }
}
项目:ZentrelaRPG    文件:Itemmanager.java   
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
    Player p = event.getPlayer();
    ItemStack item = event.getPlayer().getEquipment().getItemInMainHand();
    if (event.getHand() == EquipmentSlot.HAND && item != null && item.hasItemMeta() && item.getItemMeta().hasdisplayName() && (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK)) {
        String name = item.getItemMeta().getdisplayName();
        if (itemNametoIdentifierMap.containsKey(name)) {
            String identifier = itemNametoIdentifierMap.get(name);
            if (itemIdentifierToRunnableMap.containsKey(identifier)) {
                PlayerDataRPG pd = plugin.getPD(p);
                if (pd != null)
                    itemIdentifierToRunnableMap.get(identifier).run(event,p,pd);
                event.setCancelled(true);
            }
        }
    }
}
项目:ZentrelaRPG    文件:EtcItem.java   
public static void healWithPotion(int amount,String name,Event event,Player p) {
    if (!(event instanceof PlayerInteractEvent))
        return;
    PlayerInteractEvent e = (PlayerInteractEvent) event;
    if (!(e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK))
        return;
    if (lastHealItem.containsKey(p.getName()) && System.currentTimeMillis() - lastHealItem.get(p.getName()) < 500) {
        return;
    }
    lastHealItem.put(p.getName(),System.currentTimeMillis());
    p.getEquipment().setItemInMainHand(new ItemStack(Material.AIR));
    PlayerDataRPG pd = plugin.getPD(p);
    pd.heal(amount,HealType.POTION);
    for (int k = 0; k < p.getInventory().getContents().length; k++) {
        if (Itemmanager.isItem(p.getInventory().getItem(k),name)) {
            p.getEquipment().setItemInMainHand(p.getInventory().getItem(k));
            p.getInventory().setItem(k,new ItemStack(Material.AIR));
            break;
        }
    }
    RSound.playSound(p,Sound.ENTITY_GENERIC_DRINK);
}
项目:bskyblock    文件:IslandGuard.java   
/**
 * Prevents usage of an Ender Chest
 *
 * @param event
 */

@EventHandler(priority = EventPriority.LOWEST,ignoreCancelled = true)
public void onEnderChestEvent(PlayerInteractEvent event) {
    if (DEBUG) {
        plugin.getLogger().info("Ender chest " + event.getEventName());
    }
    Player player = (Player) event.getPlayer();
    if (Util.inWorld(player) || player.getWorld().equals(IslandWorld.getNetherWorld())) {
        if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
            if (event.getClickedBlock().getType() == Material.ENDER_CHEST) {
                if (!(event.getPlayer().hasPermission(Settings.PERMPREFIX + "craft.enderchest"))) {
                    Util.sendMessage(player,plugin.getLocale(player.getUniqueId()).get("general.errors.no-permission"));
                    event.setCancelled(true);
                }
            }
        }
    }
}
项目:HCFCore    文件:SignSubclaimListener.java   
@EventHandler(ignoreCancelled = true,priority = EventPriority.HIGH)
public void onPlayerInteract(PlayerInteractEvent event) {
    if (event.getAction() != Action.RIGHT_CLICK_BLOCK)
        return;

    Player player = event.getPlayer();
    if (player.getGameMode() == GameMode.CREATIVE && player.hasPermission(ProtectionListener.PROTECTION_BYPASS_PERMISSION)) {
        return;
    }

    if (plugin.getEotwHandler().isEndOfTheWorld()) {
        return;
    }

    Block block = event.getClickedBlock();
    if (!this.isSubclaimable(block)) {
        return;
    }

    if (!this.checkSubclaimIntegrity(player,block)) {
        event.setCancelled(true);
        player.sendMessage(ChatColor.RED + "You do not have access to this subclaimed " + block.getType().toString() + '.');
    }
}
项目:HCFCore    文件:PearlGlitchListener.java   
@EventHandler(ignoreCancelled = true,priority = EventPriority.norMAL)
public void onPlayerInteract(PlayerInteractEvent event) {
    if (event.getAction() == Action.RIGHT_CLICK_BLOCK && event.hasItem() && event.getItem().getType() == Material.ENDER_PEARL) {
        Block block = event.getClickedBlock();
        // Don't prevent opening chests,etc,as these won't throw the Enderpearls anyway
        if (block.getType().isSolid() && !(block.getState() instanceof InventoryHolder)) {
            Faction factionAt = HCF.getPlugin().getFactionManager().getFactionAt(block.getLocation());
            if (!(factionAt instanceof ClaimableFaction)) {
                return;
            }

            event.setCancelled(true);
            Player player = event.getPlayer();
            player.setItemInHand(event.getItem()); // required to update Enderpearl count
        }
    }
}
项目:VoxelGamesLibv2    文件:VoteFeature.java   
@GameEvent
public void openVoteMenu(@Nonnull PlayerInteractEvent event,User user) {
    if ((event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) && openMenuItem.equals(event.getItem())) {
        int pos = 0;
        BasicInventory basicInventory = inventoryHandler.createInventory(BasicInventory.class,user,"Vote for a map",availableMaps.size());
        for (int id : availableMaps.keySet()) {
            MapInfo info = availableMaps.get(id);
            ItemStack item = new ItemBuilder(Material.PAPER).amount(id).name(info.getName()).lore(info.getAuthor()).build();
            basicInventory.getBukkitInventory().setItem(pos++,item);
            basicInventory.addClickAction(item,((itemStack,inventoryClickEvent) -> {
                confirmVote(user,id);
                basicInventory.close();

                // Destroy the inventory,we don't need it anymore
                inventoryHandler.removeInventory(basicInventory.getIdentifier());
            }));
        }
        user.getPlayer().openInventory(basicInventory.getBukkitInventory());
    }
}
项目:chaoticWeapons    文件:Core.java   
@SuppressWarnings("deprecation")
@EventHandler
public void grenadeEvent(PlayerInteractEvent e){
    final Player p = e.getPlayer();
    if(e.getAction().equals(Action.RIGHT_CLICK_AIR) || e.getAction().equals(Action.RIGHT_CLICK_BLOCK)){
        if(p.getItemInHand().hasItemMeta()){
            if(p.getItemInHand().getItemMeta().getLore() == null) return;
            if(p.getItemInHand().getItemMeta().getLore().contains(ChatColor.GRAY + "Grenade I")){
                p.getItemInHand().setDurability((short) (p.getItemInHand().getDurability() - 4));
                final Item grenade = p.getWorld().dropItem(p.getEyeLocation(),new ItemStack(Material.CLAY_BALL));
                grenade.setVeLocity(p.getEyeLocation().getDirection().normalize().multiply(0.8D));
                Bukkit.getScheduler().scheduleSyncDelayedTask(this,new Runnable(){
                    public void run(){
                        p.getWorld().createExplosion(grenade.getLocation().getX(),grenade.getLocation().getY(),grenade.getLocation().getZ(),3,false,false);
                        grenade.remove();
                    }
                },30L);
            }
        }
    }
}
项目:ProjectAres    文件:GunGizmo.java   
@EventHandler
public void playerInteract(final PlayerInteractEvent event) {
    if(event.getAction() == Action.PHYSICAL
            || !(Gizmos.gizmoMap.get(event.getPlayer()) instanceof GunGizmo)
            || event.getItem() == null || event.getItem().getType() != this.getIcon()) return;

    final Player player = event.getPlayer();
    RaindropUtil.giveRaindrops(Users.playerId(player),-1,new RaindropResult() {
        @Override
        public void run() {
            if(success) {
                Vector veLocity = player.getLocation().getDirection().multiply(1.75D);

                Item item = player.getWorld().dropItem(event.getPlayer().getEyeLocation(),new ItemStack(Material.GHAST_TEAR));
                item.setVeLocity(veLocity);
                item.setTicksLived((5 * 60 * 20) - (5 * 20)); // 5 minutes - 5 seconds
                items.put(item,player.getUniqueId());
            } else {
                player.sendMessage(ChatColor.RED + LobbyTranslations.get().t("gizmo.gun.empty",player));
                player.playSound(player.getLocation(),Sound.UI_BUTTON_CLICK,1f,1f);
            }
        }
    },null,true,false);
}
项目:RPGInventory    文件:ArmorEquipListener.java   
@EventHandler(ignoreCancelled = true,priority = EventPriority.LOWEST)
public void onQuickEquip(PlayerInteractEvent event) {
    final Player player = event.getPlayer();
    if (!InventoryManager.playerIsLoaded(player) || event.getAction() != Action.RIGHT_CLICK_AIR &&
            event.getAction() != Action.RIGHT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_BLOCK &&
            !event.getClickedBlock().getState().getClass().getSimpleName().contains("BlockState")) {
        return;
    }

    ItemStack item = event.getItem();
    if (ItemUtils.isEmpty(item)) {
        return;
    }

    ArmorType armorType = ArmorType.matchType(item);
    if (InventoryUtils.playerNeedArmor(player,armorType)) {
        Slot armorSlot = SlotManager.instance().getSlot(armorType.name());
        if (armorSlot == null) {
            return;
        }

        event.setCancelled(!InventoryManager.validateArmor(player,InventoryAction.PLACE_ONE,armorSlot,item));

        PlayerUtils.updateInventory(player);
    }
}
项目:KingdomFactions    文件:EmpireWandInteractEventListener.java   
@SuppressWarnings("deprecation")
@EventHandler
public void onClick(PlayerInteractEvent e) {
    if(e.getAction() == Action.PHYSICAL) return;
    KingdomFactionsPlayer p = PlayerModule.getInstance().getPlayer(e.getPlayer());
    if(p.getPlayer().getInventory() == null) return;
    if(p.getPlayer().getItemInHand() == null) return;
    if(p.getPlayer().getItemInHand().getType() != Material.BLAZE_ROD) return;
    if(!p.getPlayer().getItemInHand().hasItemMeta()) return;
    if(!p.getPlayer().getItemInHand().getItemMeta().getdisplayName().equals(ChatColor.RED + "Empire Wand")) return;
    e.setCancelled(true);
    if(e.getAction() == Action.LEFT_CLICK_AIR || e.getAction() == Action.LEFT_CLICK_BLOCK) { 
        if(p.hasCooldown(CooldownType.WAND)) {
            p.sendMessage(ChatColor.GOLD + "[" + ChatColor.GRAY + "X" + ChatColor.GOLD + "] "
                    + "Je moet nog " + ChatColor.GRAY + p.getCooldown(CooldownType.WAND).getCooldown() + " seconde(n)" + ChatColor.GOLD + " wachten!");
            return;
        }
            if(p.getSpell() == null) {
            p.setSpell(SpellModule.getInstance().getSpell("Spark"));
        }
       p.getSpell().execute(p);
       p.addCooldown(new Cooldown(CooldownType.WAND,60));
    } else if(e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) {
        p.rotateSpells();
    }
}
项目:RPGInventory    文件:BackpackListener.java   
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.LOWEST)
public void onUseBackpack(PlayerInteractEvent event) {
    ItemStack item = event.getItem();
    if (!event.hasItem() || !ItemUtils.hasTag(item,ItemUtils.BACKPACK_TAG)) {
        return;
    }

    Player player = event.getPlayer();
    Action action = event.getAction();
    if ((action == Action.RIGHT_CLICK_AIR || action == Action.RIGHT_CLICK_BLOCK)
            && InventoryManager.isQuickSlot(player.getInventory().getHeldItemSlot())) {
        BackpackManager.open(player,item);
    }

    event.setCancelled(true);
    player.updateInventory();
}
项目:SurvivalPlus    文件:FooddiversityConsume.java   
@EventHandler(priority = EventPriority.HIGHEST)
public void onConsumeCake(PlayerInteractEvent event)
{
    if(event.isCancelled()) return;
    Player player = event.getPlayer();
    if(event.hasBlock() && event.getAction().equals(Action.RIGHT_CLICK_BLOCK))
    {
        Block cake = event.getClickedBlock();
        if(cake.getType().equals(Material.CAKE_BLOCK))
        {
            if(player.getFoodLevel() < 20 && (player.getGameMode() == GameMode.SURVIVAL || player.getGameMode() == GameMode.ADVENTURE))
            {
                addStats(player,carbon,171);
                addStats(player,protein,114);
                addStats(player,salts,3);
            }
        }
    }
}
项目:DynamicAC    文件:PlayerListener.java   
@EventHandler
public void onPlayerInteract2(PlayerInteractEvent e) {
    Player player = e.getPlayer();
    PlayerInventory inventory = player.getInventory();
    if(e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) {
        Material material = inventory.getItemInHand().getType();
        if(material == Material.BOW) {
            DynamicAC.getManager().getBackend().logBowWindUp(player,System.currentTimeMillis());
        } else if(Utilities.isFood(material)) {
            DynamicAC.getManager().getBackend().logEatingStart(player);
        }
    }
    Block block = e.getClickedBlock();
    if(block != null) {
        distance distance = new distance(player.getLocation(),block.getLocation());
        DynamicAC.getManager().getBackend().checkLongReachBlock(player,distance.getXDifference(),distance
                .getYDifference(),distance.getZDifference());
    }
}
项目:Hub    文件:DevelopperListener.java   
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event)
{
    this.hub.getServer().getScheduler().runTaskAsynchronously(this.hub,() ->
    {
        if (SamaGamesAPI.get().getPermissionsManager().hasPermission(event.getPlayer(),"hub.sign.selection"))
        {
            if (event.getItem() != null && event.getItem().getType() == Material.WOOD_AXE)
            {
                Action act = event.getAction();

                if (act == Action.LEFT_CLICK_BLOCK)
                {
                    this.hub.getPlayerManager().setSelection(event.getPlayer(),event.getClickedBlock().getLocation());
                    event.getPlayer().sendMessage(ChatColor.GOLD + "Point sélectionné !");
                }
            }
        }
    });
}
项目:HCFCore    文件:BookDeenchantListener.java   
@EventHandler(ignoreCancelled = true,priority = EventPriority.HIGH)
public void onPlayerInteract(PlayerInteractEvent event) {
    if (event.getAction() == Action.LEFT_CLICK_BLOCK && event.hasItem()) {
        // The player didn't click an enchantment table,Creative players will instantly destroy.
        Player player = event.getPlayer();
        if (event.getClickedBlock().getType() == Material.ENCHANTMENT_TABLE && player.getGameMode() != GameMode.CREATIVE) {

            // The player didn't click with an enchanted book.
            ItemStack stack = event.getItem();
            if (stack != null && stack.getType() == Material.ENCHANTED_BOOK) {
                ItemMeta Meta = stack.getItemMeta();
                if (Meta instanceof EnchantmentStorageMeta) {
                    EnchantmentStorageMeta enchantmentStorageMeta = (EnchantmentStorageMeta) Meta;
                    for (Enchantment enchantment : enchantmentStorageMeta.getStoredEnchants().keySet()) {
                        enchantmentStorageMeta.removeStoredEnchant(enchantment);
                    }

                    event.setCancelled(true);
                    player.setItemInHand(EMPTY_BOOK);
                    player.sendMessage(ChatColor.GREEN + "You reverted this item to its original form.");
                }
            }
        }
    }
}
项目:RealSurvival    文件:TestCMD.java   
@EventHandler
private void getDatas(PlayerInteractEvent e){
    if(!(e.getAction()==Action.LEFT_CLICK_BLOCK||e.getAction()==Action.LEFT_CLICK_AIR))return;
    if(!canUsePeople.contains(e.getPlayer().getUniqueId()))return;
    e.setCancelled(true);
    Block block=e.getPlayer().getWorld().getBlockAt(e.getPlayer().getTargetBlock((Set<Material>)null,6).getLocation()); 
    if(block!=null)
        e.getPlayer().sendMessage("��b������: ��3��l"+block.getType());
    if(e.getPlayer().getInventory().getItemInMainHand()!=null)
        e.getPlayer().sendMessage("��b��Ʒ��: ��3��l"+e.getPlayer().getInventory().getItemInMainHand().getType());
    double _temper1=getTemper(e.getPlayer(),e.getPlayer().getWorld().getTemperature(e.getPlayer().getLocation().getBlockX(),e.getPlayer().getLocation().getBlockZ()));
    e.getPlayer().sendMessage("��b�����¶�: ��3��l"+_temper1+"��");
    if(block!=null){
        double _temper2=getTemper(e.getPlayer(),e.getPlayer().getWorld().getTemperature(block.getX(),block.getZ()));
        e.getPlayer().sendMessage("��bĿ�귽���¶�: ��3��l"+_temper2+"��");
        e.getPlayer().sendMessage("��bĿ�귽������Ⱥϵ: ��3��l"+block.getBiome());
    }


}
项目:mczone    文件:Events.java   
@EventHandler
public void onspectatorInteract(PlayerInteractEvent event) {
    Player p = event.getPlayer();
    Gamer g = Gamer.get(p.getName());
    if (!g.isInvisible())
        return;

    if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK || event.getAction() == Action.PHYSICAL) {
        event.setCancelled(true);
        return;
    }


    int cur = 0;
    if (g.getvariable("spectating") != null)
        cur = (Integer) g.getvariable("spectating");
    int next = cur + 1;
    if (next + 1 >= Game.getTributes().size())
        next = 0;
    g.setvariable("spectating",next);
    Gamer t = Game.getTributes().get(next);
    g.getPlayer().teleport(t.getPlayer().getLocation());
    Chat.player(g.getPlayer(),"&2[SG] &eCurrently spectating " + g.getPrefix() + g.getName());
    event.setCancelled(true);
}
项目:SurvivalAPI    文件:CookieHeadModule.java   
/**
 * Give old player enchants on head eating
 *
 * @param event Event
 */
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event)
{
    if (event.getItem() == null || event.getItem().getType() != Material.SKULL_ITEM || event.getItem().getDurability() != 3
            || (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK))
        return;

    SkullMeta skullMeta = (SkullMeta)event.getItem().getItemMeta();
    List<PotionEffect> effectList = this.effects.get(skullMeta.getowner());

    if (effectList != null)
    {
        effectList.forEach(event.getPlayer()::addPotionEffect);
        this.effects.remove(skullMeta.getowner());
        event.getPlayer().getWorld().playSound(event.getPlayer().getLocation(),Sound.BURP,1F,1F);
    }
}
项目:DungeonGen    文件:Passageway.java   
/**Event handler for a player pressing the button of this Passageway. Will callback to DunGen to generate the next DunGen part.
 * Also moves all other players to this Passageway.
 * @param event
 */
@EventHandler(priority = EventPriority.MONITOR)
public void onNextRoomButtonPress(PlayerInteractEvent event) {
    //Player p = event.getPlayer();
    if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
        Block clicked = event.getClickedBlock();
        if (   clicked.getType() == Material.STONE_BUTTON 
            && modVolume.contains(BukkitUtil.toVector(clicked.getLocation())) ) {

            unregister(); // button cannot be pushed twice
            // If double button push appears more often,then use flag here
            // Here we need the activePlayers list. This is not present in the entry,so don't teleport during STARTUP phase.
            // This might be solvable better somehow...

            // only teleport if the dungeon runs,not during entry startup state
            if (parent.state == State.RUNNING) 
                for (Player p : parent.activePlayers) {
                    if (!modVolume.contains(BukkitUtil.toVector(p.getLocation()))) {
                        p.teleport(BukkitUtil.toLocation(parent.world,toGlobal(respawnLoc).add(0.5,0.5)));
                    }
                }

            parent.genNextRoom();
        }
    }
}
项目:SlimefunBugFixer    文件:Listeners.java   
@EventHandler
public void onClick(PlayerInteractEvent e) {
    Action act = e.getAction();
    if (!(act.equals(Action.RIGHT_CLICK_AIR) || act.equals(Action.RIGHT_CLICK_BLOCK)))
        return;
    ItemStack item = e.getItem();
    if (item == null)
        return;
    if (!item.hasItemMeta())
        return;
    if (!item.getItemMeta().hasdisplayName())
        return;
    if (!item.getItemMeta().getdisplayName().contains(ConfigManager.getInstance().getBackpackName()))
        return;
    Player p = e.getPlayer();
    String name = p.getName();
    if (BackpackCooldown.getInstance().isReady(name,500)) {
        BackpackCooldown.getInstance().put(name);
    } else {
        e.setCancelled(true);
        p.closeInventory();
        p.sendMessage(Messages.getMessages().getNoQuickopen().replace("&","§"));
    }
}
项目:HCFCore    文件:ArcherClass.java   
@EventHandler(ignoreCancelled=false,priority=EventPriority.HIGH)
public void onArcherSpeedClick(PlayerInteractEvent event)
{
    Action action = event.getAction();
    if (((action == Action.RIGHT_CLICK_AIR) || (action == Action.RIGHT_CLICK_BLOCK)) &&
            (event.hasItem()) && (event.getItem().getType() == Material.SUGAR))
    {
        if (this.plugin.getPvpClassManager().getEquippedClass(event.getPlayer()) != this) {
            return;
        }
        Player player = event.getPlayer();
        UUID uuid = player.getUniqueId();
        long timestamp = this.archerSpeedCooldowns.get(uuid);
        long millis = System.currentTimeMillis();
        long remaining = timestamp == this.archerSpeedCooldowns.getNoEntryValue() ? -1L : timestamp - millis;
        if (remaining > 0L)
        {
            player.sendMessage(ChatColor.RED + "Cannot use Speed Boost for another " + DurationFormatUtils.formatDurationWords(remaining,true) + ".");
        }
        else
        {
            ItemStack stack = player.getItemInHand();
            if (stack.getAmount() == 1) {
                player.setItemInHand(new ItemStack(Material.AIR,1));
            } else {
                stack.setAmount(stack.getAmount() - 1);
            }
            player.sendMessage(ChatColor.GREEN + "Speed 4 activated for 7 seconds.");

            this.plugin.getEffectRestorer().setRestoreEffect(player,ARCHER_SPEED_EFFECT);
            this.archerSpeedCooldowns.put(event.getPlayer().getUniqueId(),System.currentTimeMillis() + ARCHER_SPEED_COOLDOWN_DELAY);
        }
    }
}
项目:AsgardAscension    文件:GodFoodListener.java   
@SuppressWarnings("deprecation")
@EventHandler
public void onFoodEat(PlayerInteractEvent event) {
    if(!(event.getAction().equals(Action.RIGHT_CLICK_AIR) || event.getAction().equals(Action.RIGHT_CLICK_BLOCK))) {
        return;
    }
    if(!event.getPlayer().isSneaking() || event.getPlayer().getInventory().getItemInMainHand() == null) {
        return;
    }

    Player player = event.getPlayer();
    List<Integer> ids = GodFoodFile.getFoodId(player.getInventory().getItemInMainHand().getTypeId());
    for(int id : ids) {
        byte data = (byte)GodFoodFile.getData(id);

        if(player.getInventory().getItemInMainHand().getData().getData() != data || id == 0)
            continue;

        if(player.getInventory().getItemInMainHand().getAmount() > GodFoodFile.getAmount(id)) {
            ItemStack item = player.getInventory().getItemInMainHand();
            item.setAmount(item.getAmount() - GodFoodFile.getAmount(id));
            player.setItemInHand(item);
        } else if(player.getInventory().getItemInMainHand().getAmount() == GodFoodFile.getAmount(id)) {
            player.setItemInHand(new ItemStack(Material.AIR));
        } else {
            return;
        }
        event.setCancelled(true);

        addPotionEffects(player,id);
        player.sendMessage(Lang.HEADERS_FOG.toString() + "You used " 
                + ChatColor.RED + GodFoodFile.getName(id) + ChatColor.GRAY + "!");
    }
}
项目:uppercore    文件:HotbarManager.java   
@EventHandler
public void onPlayerInteract(PlayerInteractEvent e) {
    try {
        if (e.getHand() != EquipmentSlot.HAND)
            return;
    } catch (Error ignored) {
    }
    if (e.getAction() != Action.PHYSICAL)
        onClick(e); // this method cancels the event by himself
}
项目:Zorahpractice    文件:PearlFix.java   
@EventHandler(ignoreCancelled = true,priority = EventPriority.norMAL)
public void onInteract(PlayerInteractEvent event) {
    if ((event.getAction() == Action.RIGHT_CLICK_BLOCK) && (event.hasItem()) && (event.getItem().getType() == Material.ENDER_PEARL)) {
        Block block = event.getClickedBlock();

        if ((block.getType().isSolid()) && (!(block.getState() instanceof InventoryHolder))) {
            event.setCancelled(true);
            Player player = event.getPlayer();
            player.setItemInHand(event.getItem());
        }
    }
}
项目:ZentrelaRPG    文件:EnvironmentManager.java   
@EventHandler
public void onPlayerInteractCrops(PlayerInteractEvent event) {
    if (event.getAction() == Action.PHYSICAL) {
        Block b = event.getClickedBlock();
        if (b.getType() == Material.soIL) {
            event.setCancelled(true);
            b.setTypeIdAndData(b.getType().getId(),b.getData(),true);
        }
        if (b.getType() == Material.CROPS) {
            event.setCancelled(true);
            b.setTypeIdAndData(b.getType().getId(),true);
        }
    }
}
项目:ZentrelaRPG    文件:EnvironmentManager.java   
@EventHandler
public void onAnvilOrEnchantInteract(PlayerInteractEvent event) {
    if (event.getClickedBlock() != null) {
        if (event.getPlayer().getGameMode() == GameMode.CREATIVE && (event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK))
            return;
        Material type = event.getClickedBlock().getType();
        for (Material m : RESTRICTED_TYPES) {
            if (m == type) {
                event.setCancelled(true);
                break;
            }
        }
    }
}
项目:ZentrelaRPG    文件:CombatManager.java   
@EventHandler
public void onPlayerInteract_equipItem(final PlayerInteractEvent event) {
    if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
        RScheduler.schedule(plugin,new Runnable() {
            public void run() {
                PlayerDataRPG pd = plugin.getPD((Player) (event.getPlayer()));
                if (pd != null)
                    pd.updateEquipmentStats();
            }
        });
    }
}
项目:Zorahpractice    文件:KitEditManager.java   
@EventHandler(ignoreCancelled = true,priority = EventPriority.MONITOR)
public void onPearl(PlayerInteractEvent event) {
    if ((event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) && event.getItem() != null && event.getItem().getType() == Material.ENDER_PEARL) {
        if (this.editKits.containsKey(event.getPlayer().getUniqueId())) {
            event.setCancelled(true);
        }
    }
}
项目:EscapeLag    文件:SpawnerController.java   
@EventHandler(priority = EventPriority.MONITOR,ignoreCancelled = true)
public void onModify(PlayerInteractEvent evt) {
    if (!preventSpawnerModify || evt.getItem() == null || evt.getAction() != Action.RIGHT_CLICK_BLOCK) return;

    Player player = evt.getPlayer();
    if (Perms.has(player)) return;

    if (evt.getClickedBlock().getType() == Material.MOB_SPAWNER) {
        Material type = evt.getItem().getType();
        if (type == Material.MONSTER_EGG || type == Material.MONSTER_EGGS) {
            evt.setCancelled(true);
            AzureAPI.log(player,messagePreventSpawnerModify);
        }
    }
}
项目:bskyblock    文件:IslandGuard1_9.java   
/**
 * Handle blocks that need special treatment
 * Tilling of coarse dirt into dirt using off-hand (regular hand is in 1.8)
 * Usually prevented because it Could lead to an endless supply of dirt with gravel
 *
 * @param e
 */
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.LOW,ignoreCancelled=true)
public void onPlayerInteract(final PlayerInteractEvent e) {
    if (DEBUG) {
        plugin.getLogger().info("1.9 " + e.getEventName());
    }
    if (!e.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
        return;
    }
    if (!Util.inWorld(e.getPlayer())) {
        return;
    }
    if (e.getPlayer().isOp()) {
        return;
    }
    // This permission bypasses protection
    if (VaultHelper.hasPerm(e.getPlayer(),Settings.PERMPREFIX + "mod.bypassprotect")
            || VaultHelper.hasPerm(e.getPlayer(),Settings.PERMPREFIX + "craft.dirt")) {
        return;
    }
    // Prevents tilling of coarse dirt into dirt
    ItemStack inHand = e.getPlayer().getInventory().getItemInOffHand();
    if (inHand.getType() == Material.WOOD_HOE || inHand.getType() == Material.IRON_HOE || inHand.getType() == Material.GOLD_HOE
            || inHand.getType() == Material.DIAMOND_HOE || inHand.getType() == Material.STONE_HOE) {
        // plugin.getLogger().info("1.8 " + "DEBUG: hoe in hand");
        Block block = e.getClickedBlock();
        // plugin.getLogger().info("1.8 " + "DEBUG: block is " + block.getType() +
        // ":" + block.getData());
        // Check if coarse dirt
        if (block.getType() == Material.DIRT && block.getData() == (byte) 1) {
            // plugin.getLogger().info("1.8 " + "DEBUG: hitting coarse dirt!");
            e.setCancelled(true);
        }
    }
}
项目:bskyblock    文件:IslandGuard.java   
/**
 * Pressure plates
 * @param e
 */
@EventHandler(priority = EventPriority.LOW,ignoreCancelled = true)
public void onPlateStep(PlayerInteractEvent e) {
    if (DEBUG) {
        plugin.getLogger().info("pressure plate = " + e.getEventName());
        plugin.getLogger().info("action = " + e.getAction());
    }
    if (!Util.inWorld(e.getPlayer()) || !e.getAction().equals(Action.PHYSICAL)
            || e.getPlayer().isOp() || VaultHelper.hasPerm(e.getPlayer(),Settings.PERMPREFIX + "mod.bypassprotect")
            || plugin.getIslands().playerIsOnIsland(e.getPlayer())) {
        //plugin.getLogger().info("DEBUG: Not in world");
        return;
    }
    // Check island
    Island island = plugin.getIslands().getProtectedislandAt(e.getPlayer().getLocation());
    if ((island == null && Settings.defaultWorldSettings.get(SettingsFlag.PRESSURE_PLATE))) {
        return;
    }
    if (island != null && island.getFlag(SettingsFlag.PRESSURE_PLATE)) {
        return;
    }
    // Block action
    UUID playerUUID = e.getPlayer().getUniqueId();
    if (!onPlate.containsKey(playerUUID)) {
        Util.sendMessage(e.getPlayer(),plugin.getLocale(playerUUID).get("island.protected"));
        Vector v = e.getPlayer().getLocation().toVector();
        onPlate.put(playerUUID,new Vector(v.getBlockX(),v.getBlockY(),v.getBlockZ()));
    }
    e.setCancelled(true);
}
项目:bskyblock    文件:IslandGuard1_8.java   
/**
 * Handle V1.8 blocks that need special treatment
 * Tilling of coarse dirt into dirt
 * Usually prevented because it Could lead to an endless supply of dirt with gravel
 *
 * @param e
 */
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.LOW,ignoreCancelled=true)
public void onPlayerInteract(final PlayerInteractEvent e) {
    if (DEBUG) {
        plugin.getLogger().info("1.8 " + e.getEventName());
    }
    if (!e.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
        return;
    }
    if (!Util.inWorld(e.getPlayer())) {
        return;
    }
    if (e.getPlayer().isOp()) {
        return;
    }
    // This permission bypasses protection
    if (VaultHelper.hasPerm(e.getPlayer(),Settings.PERMPREFIX + "craft.dirt")) {
        return;
    }
    // Prevents tilling of coarse dirt into dirt
    ItemStack inHand = e.getPlayer().getItemInHand();
    if (inHand.getType() == Material.WOOD_HOE || inHand.getType() == Material.IRON_HOE || inHand.getType() == Material.GOLD_HOE
            || inHand.getType() == Material.DIAMOND_HOE || inHand.getType() == Material.STONE_HOE) {
        // plugin.getLogger().info("1.8 " + "DEBUG: hoe in hand");
        Block block = e.getClickedBlock();
        // plugin.getLogger().info("1.8 " + "DEBUG: block is " + block.getType() +
        // ":" + block.getData());
        // Check if coarse dirt
        if (block.getType() == Material.DIRT && block.getData() == (byte) 1) {
            // plugin.getLogger().info("1.8 " + "DEBUG: hitting coarse dirt!");
            e.setCancelled(true);
        }
    }
}
项目:Absorption    文件:InteractionListener.java   
@EventHandler
public void onPlayerInteract(PlayerInteractEvent e) {
    if(e.getPlayer().getGameMode() != GameMode.CREATIVE)
        e.setCancelled(true);

    GamePlayer player = Absorption.getPlayer(e.getPlayer());
    if(player == null) return;

    if(e.getPlayer().getItemInHand().getType() == Material.AIR) return;

    if(player.getState() == PlayerState.WAITING) {

    } else if(player.getState() == PlayerState.PLAYING) {
        int slot = e.getPlayer().getInventory().getHeldItemSlot();
        if(e.getAction() == Action.LEFT_CLICK_AIR || e.getAction() == Action.LEFT_CLICK_BLOCK) {
            if(slot == 0) {
                player.getKit().onLeftClick(player);
            } else if(slot == 1) {
                player.getKit().getSecondaryWeapon().onLeftClick(player);
            } else if(slot == 2) {
                player.getKit().getSpecialWeapon().onLeftClick(player);
            }
        } else if(e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) {
            if(slot == 0) {
                player.getKit().onRightClick(player);
            } else if(slot == 1) {
                player.getKit().getSecondaryWeapon().onRightClick(player);
            } else if(slot == 2) {
                player.getKit().getSpecialWeapon().onRightClick(player);
            }
        }
    } else if(player.getState() == PlayerState.RESPAWNING) {

    } else if(player.getState() == PlayerState.END) {
        // nothing
    }
}
项目:WC    文件:Weapons.java   
@EventHandler
public void onInteract(PlayerInteractEvent e){
    Player p = e.getPlayer();
    Weapon weapon;

    if (e.getItem() == null || e.getHand() != EquipmentSlot.HAND) return;

    if (e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK){
        if (e.getItem().getType() == Material.POTION) return;
        if (e.getItem() == null || Weapon.getWeaponByItemStack(e.getItem()) == null || !Weapon.isWeapon(e.getItem())) return;
        weapon = Weapon.getWeaponByItemStack(e.getItem());

        if (weapon != null) e.setCancelled(true);
        if (weapon == null) return;

        weapon.shoot(p);
        return;
    }

    if (e.getAction() == Action.LEFT_CLICK_AIR || e.getAction() == Action.LEFT_CLICK_BLOCK){
        if (e.getItem() == null || Weapon.getWeaponByItemStack(e.getItem()) == null || !Weapon.isWeapon(e.getItem())) return;
        weapon = Weapon.getWeaponByItemStack(e.getItem());

        if (weapon != null) e.setCancelled(true);
        if (weapon == null) return;

        if (weapon.getId() == 0) return;

        weapon.watch(p);
    }
}
项目:McLink    文件:VItem.java   
public static Map<Item.ActionType,Method> getActions(Class<?> c) {
    Map<Item.ActionType,Method> a = new HashMap<Item.ActionType,Method>();

    for (Method m : c.getmethods()) {
        if (m.isAnnotationPresent(Item.Action.class)) {
            a.put(m.getAnnotation(Item.Action.class).type(),m);
        }
    }

    return a;
}

org.bukkit.event.block.BlockBreakEvent的实例源码

org.bukkit.event.block.BlockBreakEvent的实例源码

项目:bskyblock    文件:NetherEvents.java   
/**
 * Prevents blocks from being broken
 *
 * @param e
 */
@EventHandler(priority = EventPriority.LOW)
public void onBlockBreak(final BlockBreakEvent e) {
    if (DEBUG)
        plugin.getLogger().info("DEBUG: " + e.getEventName());
    // plugin.getLogger().info("Block break");
    if ((e.getPlayer().getWorld().getName().equalsIgnoreCase(Settings.worldName + "_nether") && !Settings.netherIslands)
            || e.getPlayer().getWorld().getName().equalsIgnoreCase(Settings.worldName + "_the_end")) {
        if (VaultHelper.hasPerm(e.getPlayer(),Settings.PERMPREFIX + "mod.bypassprotect")) {
            return;
        }
        if (DEBUG)
            plugin.getLogger().info("Block break in island nether");
        if (!awayFromSpawn(e.getPlayer()) && !e.getPlayer().isOp()) {
            Util.sendMessage(e.getPlayer(),plugin.getLocale(e.getPlayer().getUniqueId()).get("nether.spawnisprotected"));
            e.setCancelled(true);
        }
    }

}
项目:HCFCore    文件:DeathSignListener.java   
@EventHandler(ignoreCancelled = true,priority = EventPriority.HIGHEST)
public void onBlockBreak(BlockBreakEvent event) {
    Block block = event.getBlock();
    if (isDeathSign(block)) {
        BlockState state = block.getState();
        Sign sign = (Sign) state;
        ItemStack stack = new ItemStack(Material.SIGN,1);
        ItemMeta Meta = stack.getItemMeta();
        Meta.setdisplayName(DEATH_SIGN_ITEM_NAME);
        Meta.setLore(Arrays.asList(sign.getLines()));
        stack.setItemMeta(Meta);

        Player player = event.getPlayer();
        World world = player.getWorld();
        if (player.getGameMode() != GameMode.CREATIVE && world.isGameRule("doTileDrops")) {
            world.dropItemNaturally(block.getLocation(),stack);
        }

        // Manually handle the dropping
        event.setCancelled(true);
        block.setType(Material.AIR);
        state.update();
    }
}
项目:CropControl    文件:CropControlEventHandler.java   
/**
 * So far specifically handles these cases:
 * 
 * 1) Block broken is tracked
 * 2) Block breaks by not-players
 * 3) Block breaks by players
 * 4) Indirect block breaks -- destroying block supporting a crop or collapsible tree,or under mushrooms
 * 5) Indirect block break of cocoa bearing logs
 * 6) Block broken had mushroom on top and cocoa on the sides
 * 
 * @param e The event
 */
@EventHandler(priority=EventPriority.HIGHEST,ignoreCancelled = true)
public void onBlockBreak(BlockBreakEvent e) {
    Block block = e.getBlock();
    Player player = e.getPlayer();
    BreakType type = player != null ? BreakType.PLAYER : BreakType.NATURAL;
    UUID uuid = player != null ? player.getUniqueId() : null;
    if (maybeSideTracked(block)) {
        trySideBreak(block,type,uuid);
    }
    if (maybeBelowTracked(block)) {
        block = block.getRelative(BlockFace.UP);
    }
    Location loc = block.getLocation();
    if (!pendingChecks.contains(loc)) {
        pendingChecks.add(loc);
        handleBreak(block,uuid,null);
    }
}
项目:Warzone    文件:BuildFilterType.java   
@EventHandler
public void onBlockBreak(BlockBreakEvent event) {
    for (Region region : regions) {
        if (region.contains(event.getBlock().getLocation())) {
            for (MatchTeam matchTeam : teams) {
                if (matchTeam.containsPlayer(event.getPlayer())) {
                    FilterResult filterResult = evaluator.evaluate(event.getPlayer());
                    if (filterResult == FilterResult.DENY) {
                        event.setCancelled(true);
                        event.getPlayer().sendMessage(message);
                    } else if (filterResult == FilterResult.ALLOW) {
                        event.setCancelled(false);
                    }
                }
            }
        }
    }
}
项目:Slimefun4-Chinese-Version    文件:TalismanListener.java   
/**
 *
 * @param e BlockBreakEvent
 * @since 4.2.0
 */
@EventHandler
public void onBlockBreak(BlockBreakEvent e) {
    List<ItemStack> drops = new ArrayList<ItemStack>();
    ItemStack item = e.getPlayer().getInventory().getItemInMainHand();
    int fortune = 1;

    if (item != null) {
        if (item.getEnchantments().containsKey(Enchantment.LOOT_BONUS_BLOCKS) && !item.getEnchantments().containsKey(Enchantment.SILK_TOUCH)) {
            fortune = SlimefunStartup.randomize(item.getEnchantmentLevel(Enchantment.LOOT_BONUS_BLOCKS) + 2) - 1;
            if (fortune <= 0) fortune = 1;
            fortune = (e.getBlock().getType() == Material.LAPIS_ORE ? 4 + SlimefunStartup.randomize(5) : 1) * (fortune + 1);
        }

        if (!item.getEnchantments().containsKey(Enchantment.SILK_TOUCH) && e.getBlock().getType().toString().endsWith("_ORE")) {
            if (Talisman.checkFor(e,SlimefunItem.getByID("mineR_TALISMAN"))) {
                if (drops.isEmpty()) drops = (List<ItemStack>) e.getBlock().getDrops();
                for (ItemStack drop : new ArrayList<ItemStack>(drops)) {
                    if (!drop.getType().isBlock()) drops.add(new CustomItem(drop,fortune * 2));
                }
            }
        }
    }
}
项目:SuperiorCraft    文件:CustomBlock.java   
public void removeBlock(BlockBreakEvent e) {
        for (Entity en : e.getBlock().getWorld().getEntities()) {
            if (en.getCustomName() != null && en.getCustomName().equals(getName()) && en.getLocation().add(-0.5,-0.5).equals(e.getBlock().getLocation())) {
                en.remove();
                en.getWorld().getBlockAt(en.getLocation().add(-0.5,-0.5)).setType(Material.AIR);

                ItemStack block = new ItemStack(Material.MONSTER_EGG,1);

                ItemMeta bMeta = block.getItemMeta();

                bMeta.setdisplayName(name);

                block.setItemMeta(bMeta);

                if (e.getPlayer() != null && e.getPlayer().getGameMode().equals(GameMode.CREATIVE)) {
                    e.getPlayer().getInventory().addItem(block);
                } else {
                    e.getBlock().getWorld().dropItemNaturally(en.getLocation().add(-0.5,-0.5),block);
                }
            }
        }
    //}
}
项目:SuperiorCraft    文件:CustomTexturedBlock.java   
@Override
public void removeBlock(BlockBreakEvent e) {
        if (e.getPlayer() == null) {return;}
        for (Entity en : e.getPlayer().getNearbyEntities(10,10,10)) {
            System.out.println("Removal has Begun");
            if (en.getCustomName() != null && en.getCustomName().equals(getName()) && /*en.getLocation().add(-0.5,-0.5).equals(e.getBlock().getLocation())*/ en.getLocation().distance(e.getBlock().getLocation()) < 2) {
                for (Entity ent : en.getNearbyEntities(0.5,0.5,0.5)) {
                    if (ent.getCustomName().equals("CustomBlock")) {
                        ent.remove();
                        break;
                    }
                }
                en.remove();
                //en.getWorld().getBlockAt(en.getLocation().add(-0.5,-0.5)).setType(Material.AIR);
                if (e.getPlayer() != null && e.getPlayer().getGameMode().equals(GameMode.CREATIVE)) {
                    e.getPlayer().getInventory().addItem(getItem());
                } else {
                    e.getBlock().getWorld().dropItemNaturally(en.getLocation().add(-0.5,getItem());
                }

                return;
            }
        }
}
项目:SurvivalPlus    文件:Chairs.java   
@EventHandler(priority = EventPriority.HIGHEST)
public void onBlockBreak(BlockBreakEvent event)
{
    if(event.isCancelled()) return;
    if(Survival.allowedBlocks.contains(event.getBlock().getType()))
    {
        ArmorStand drop = dropSeat(event.getBlock(),(Stairs)event.getBlock().getState().getData());

        for(Entity e : drop.getNearbyEntities(0.5,0.5))
        {
            if(e != null && e instanceof ArmorStand && e.getCustomName() == "Chair")
                e.remove();
        }

        drop.remove();
    }
}
项目:Stats4    文件:BlockBreakStat.java   
@EventHandler
private void onBlockBreak(final BlockBreakEvent event) {
    Material material = event.getBlock().getType();
    byte data = event.getBlock().getData();
    ItemStack mainHandItem = event.getPlayer().getInventory().getItemInMainHand();
    DatabaseQueryWorker.getInstance().submit(() -> {
        try {
            BlockBreakDAO.storeRecord(
                    event.getPlayer().getUniqueId(),event.getPlayer().getType().name(),material,data,event.getBlock().getLocation(),mainHandItem
            );
        } catch (sqlException e) {
            e.printstacktrace();
        }
    });
}
项目:mczone    文件:KitEvents.java   
@EventHandler
public void Woodcutter(BlockBreakEvent event) {
    if (State.PRE)
        return;

    Player p = event.getPlayer();
    if (Kit.getKit(p).getName().equalsIgnoreCase("woodcutter")
            && event.getBlock().getType().equals(Material.LOG)
            && (p.getItemInHand().getType().toString().contains("AXE"))) {
        for (int i = 0; i <= 50; i++) {
            Location loc = event.getBlock().getLocation();
            loc.setY(loc.getY() + i);
            if (loc.getBlock().getType().equals(Material.LOG))
                loc.getBlock().breakNaturally();
            else
                break;
        }
    }
}
项目:HCFCore    文件:GlowstoneListener.java   
@EventHandler
public void onBlockBreak(BlockBreakEvent e) {
    Player p = e.getPlayer();
    Faction faction = hcf.getFactionManager().getFactionAt(e.getBlock());
    if(e.getBlock().getType().equals(Material.GLOWSTONE) && e.getBlock().getLocation().getWorld().getName().equalsIgnoreCase("world_nether")) {
        if(faction.getName().equalsIgnoreCase("GlowstoneMountain")) {
            e.setCancelled(true);
            e.getBlock().setType(Material.bedROCK);
            Bukkit.getScheduler().scheduleSyncDelayedTask(hcf,new Runnable() {
                public void run() {
                    if(e.getBlock().getType().equals(Material.bedROCK)) {
                        e.getBlock().setType(Material.GLOWSTONE);
                    }
                }
            },20L*60L*10L);
            p.getInventory().addItem(new ItemStack(Material.GLOWSTONE));
        }
    }
}
项目:Mega-Walls    文件:BlockBreakListener.java   
@EventHandler
public void onBlockBreak(BlockBreakEvent e)
{
    User user = MWAPI.getUserHandler().findById(e.getPlayer().getUniqueId());

    if (user.getGame() != null)
    {
        if (user.getGame().getspectators().contains(user) || user.getGame().getState().equals(GameState.LOBBY))
        {
            e.setCancelled(true);
            return;
        }

        // Todo handle other stuff like the castles and walls
    }
}
项目:ArchersBattle    文件:WorldListener.java   
@EventHandler
public void onBreak(BlockBreakEvent e) {
    if (e.isCancelled()) {
        return;
    }
    if (!Utils.isInArena(e.getPlayer())) {
        return;
    }
    if (!Utils.isArenaWorld(e.getBlock().getWorld())) {
        return;
    }
    if (e.getPlayer().isOp()) {
        return;
    }
    e.setCancelled(true);
}
项目:SurvivalAPI    文件:PersonalBlocksModule.java   
/**
 * Private block breaking handling
 *
 * @param event Event
 */
@EventHandler(ignoreCancelled = true,priority = EventPriority.HIGH)
public void onBlockBreak(BlockBreakEvent event)
{
    if (this.blocksOwner.containsKey(event.getBlock().getLocation()) && this.blocksOwner.get(event.getBlock().getLocation()) != event.getPlayer().getUniqueId())
    {
        UUID id = this.blocksOwner.get(event.getBlock().getLocation());

        if (id == null || id.equals(event.getPlayer().getUniqueId()) || (this.game instanceof SurvivalTeamGame && ((SurvivalTeamGame) this.game).getPlayerTeam(id) == ((SurvivalTeamGame) this.game).getPlayerTeam(event.getPlayer().getUniqueId())))
        {
            this.blocksOwner.remove(event.getBlock().getLocation());
        }
        else if (!this.game.isPvPActivated())
        {
            event.getPlayer().sendMessage(ChatColor.RED + "Ce bloc appartient à " + Bukkit.getofflinePlayer(this.blocksOwner.get(event.getBlock().getLocation())).getName()  + ". Vous ne pouvez pas le casser actuellement !");
            event.setCancelled(true);
        }
    }
}
项目:SurvivalAPI    文件:ParanoidModule.java   
/**
 * Write a message when a player mine a diamond
 *
 * @param event Event
 */
@EventHandler(ignoreCancelled = true)
public void onBlockBreak(BlockBreakEvent event)
{
    if (event.getBlock().getType() != Material.DIAMOND_ORE)
        return;

    Location location = event.getBlock().getLocation();

    StringBuilder builder = new StringBuilder();
    builder.append(ChatColor.GOLD).append("[").append(ChatColor.YELLOW);
    builder.append("Paranoïa");
    builder.append(ChatColor.GOLD).append("]").append(ChatColor.YELLOW);
    builder.append(" Le joueur ").append(ChatColor.GOLD).append(event.getPlayer().getName()).append(ChatColor.YELLOW);
    builder.append(" a miné un bloc de diamant aux coordonnées ").append(ChatColor.GOLD);
    builder.append(location.getBlockX()).append("; ").append(location.getBlockY()).append("; ").append(location.getBlockZ());
    builder.append(ChatColor.YELLOW).append(" !");

    Bukkit.broadcastMessage(builder.toString());
}
项目:Kineticraft    文件:Xray.java   
@EventHandler(priority = EventPriority.LOW)
public void onBlockBreak(BlockBreakEvent evt) {
    Location at = evt.getBlock().getLocation();
    if (at.getY() > 20 || !at.getWorld().equals(Core.getMainWorld()))
        return;

    // Remember mined blocks.
    brokenBlock bk = new brokenBlock(evt.getPlayer(),evt.getBlock());
    blocks.add(bk);
    if ((bk.getType() == Material.DIAMOND_ORE || Utils.randChance(20))
            && (getBlockscore(evt.getPlayer()) >= 20 || getTimescore(evt.getPlayer()) >= 20))
            blocks.detect(bk);

    // Handle suspicIoUs ascending / descending.
    if (elevation.getDetections(evt.getPlayer()).stream().noneMatch(b -> b.getLocation().getY() == at.getY()))
        elevation.detect(bk);
}
项目:GhostScavengerHunt    文件:GhostSkull.java   
@EventHandler
public void onSkullBreak(BlockBreakEvent event) {
    if(!LocationUtils.center(event.getBlock().getLocation()).equals(LocationUtils.center(this.location))) return;
    if(!event.getPlayer().hasPermission("ghostskull.break")) {
        event.getPlayer().sendMessage(ChatColor.translatealternateColorCodes('&',this.getPlugin().getMessageFile().getString("cannot-break-skull-message")));
        event.setCancelled(true);
    } else {
        HandlerList.unregisterall(this);
        plugin.getGhostSkulls().remove(this);
        plugin.getDataFile().set(this.uuid.toString(),null);
        try {
            plugin.getDataFile().save(plugin.getF_dataFile());
        } catch (IOException e) {
            e.printstacktrace();
        }
        event.getPlayer().sendMessage(ChatColor.GREEN + "Ghost Skull has been deleted.");
    }
}
项目:MT_Core    文件:SupplyDropListener.java   
@EventHandler
public void onSupplyDropBreak(BlockBreakEvent e) {
    SupplyDropObject sd = core.getSupplyDropManager().getSupplyDropByLocation(e.getBlock().getLocation());

    if (sd == null)
        return;

    sd.setLooted(true);
    core.getSupplyDropManager().removeSupplyDrop(e.getBlock().getLocation());
}
项目:CropControl    文件:CitadelEventHandler.java   
@EventHandler(priority=EventPriority.HIGHEST,ignoreCancelled=true)
public void handleAcidBreak(AcidBlockEvent e) {
    try {
        Location acided = e.getDestroyedBlockReinforcement().getLocation();

        CropControl.getPlugin().getEventHandler().onBlockBreak(new BlockBreakEvent( acided.getBlock(),e.getPlayer() ) );
    } catch (Exception g) {
        CropControl.getPlugin().warning("Failed to handle Citadel Acid Block Event:",g);
    }
}
项目:VoxelGamesLibv2    文件:NoBlockBreakFeature.java   
@SuppressWarnings({"JavaDoc","Duplicates"})
@GameEvent
public void onBlockBreak(@Nonnull BlockBreakEvent event) {
    if (blacklist.length != 0) {
        if (Arrays.stream(blacklist).anyMatch(m -> m.equals(event.getBlock().getType()))) {
            event.setCancelled(true);
        }
    } else if (whitelist.length != 0) {
        if (Arrays.stream(whitelist).noneMatch(m -> m.equals(event.getBlock().getType()))) {
            event.setCancelled(true);
        }
    } else {
        event.setCancelled(true);
    }
}
项目:Warzone    文件:WoolChestModule.java   
@EventHandler
public void onBreak(BlockBreakEvent event) {
    if (event.getBlock().getType() == Material.CHEST) {
        if (scannedChests.contains(((Chest) event.getBlock().getState()).getBlockInventory().getHolder())) {
            event.setCancelled(true);
            event.getPlayer().sendMessage(ChatColor.RED + "You cannot break the wool chest!");
        }
    }
}
项目:Warzone    文件:dispenserListener.java   
@EventHandler(priority = EventPriority.MONITOR,ignoreCancelled = true)
public void onBlockBreak(BlockBreakEvent event) {
    if (!this.tracker.isEnabled(event.getBlock().getWorld())) return;

    if (event.getBlock().getType() == Material.disPENSER) {
        this.tracker.clearPlacer(event.getBlock());
    }
}
项目:Warzone    文件:AnvilListener.java   
@EventHandler(priority = EventPriority.MONITOR,ignoreCancelled = true)
public void onBlockBreak(BlockBreakEvent event) {
    if (!this.tracker.isEnabled(event.getBlock().getWorld())) return;

    if (event.getBlock().getType() == Material.ANVIL) {
        this.tracker.clearPlacer(event.getBlock());
    }
}
项目:HCFCore    文件:BorderListener.java   
@EventHandler(ignoreCancelled = true,priority = EventPriority.HIGH)
public void onBlockBreak(final BlockBreakEvent event) {
    if (!isWithinBorder(event.getBlock().getLocation())) {
        event.setCancelled(true);
        event.getPlayer().sendMessage(ChatColor.RED + "You cannot break blocks past the border.");
    }
}
项目:AntiCheat    文件:OrebfuscatorBlockListener.java   
@EventHandler(priority = EventPriority.MONITOR)
public void onBlockBreak(BlockBreakEvent event) {
    if (event.isCancelled()) {
        return;
    }

    BlockUpdate.Update(event.getBlock());
    BlockHitManager.breakBlock(event.getPlayer(),event.getBlock());
}
项目:ZentrelaRPG    文件:EnvironmentManager.java   
@EventHandler
public void onBlockBreak(BlockBreakEvent event) {
    PlayerDataRPG pd = plugin.getPD(event.getPlayer());
    if (pd == null)
        event.setCancelled(true);
    if (event.getPlayer().getGameMode() != GameMode.CREATIVE)
        event.setCancelled(true);
    if (!canBuild(pd))
        event.setCancelled(true);
}
项目:HCFCore    文件:ExpMultiplierListener.java   
@EventHandler(ignoreCancelled = true,priority = EventPriority.norMAL)
public void onBlockBreak(BlockBreakEvent event) {
    double amount = event.getExpToDrop();
    Player player = event.getPlayer();
    ItemStack stack = player.getItemInHand();
    if (stack != null && stack.getType() != Material.AIR && amount > 0) {
        int enchantmentLevel = stack.getEnchantmentLevel(Enchantment.LOOT_BONUS_BLOCKS);
        if (enchantmentLevel > 0) {
            double multiplier = enchantmentLevel * SettingsYML.EXP_MULTIPLIER_FORTUNE_PER_LEVEL;
            int result = (int) Math.ceil(amount * multiplier);
            event.setExpToDrop(result);
        }
    }
}
项目:EscapeLag    文件:AntiBreakUsingChest.java   
@EventHandler
public void CheckNoBreakChest(BlockBreakEvent e) {
    if (ConfigPatch.protectUsingChest) {
        Player p = e.getPlayer();
        if (e.getBlock().getState() instanceof InventoryHolder) {
            InventoryHolder ih = (InventoryHolder) e.getBlock().getState();
            if (ih.getInventory().getViewers().isEmpty() == false) {
                e.setCancelled(true);
                AzureAPI.log(p,ConfigPatch.AntiBreakUsingChestWarnMessage);
            }
        }
    }
}
项目:Arcadia-Spigot    文件:SpleefGame.java   
@EventHandler
public void onBlockBreak(BlockBreakEvent event) {
    if(this.getAPI().getGameManager().isAlive(event.getPlayer())) {
        if(event.getBlock().getType() == Material.SNow_BLOCK) {
            event.getPlayer().getInventory().addItem(new ItemStack(Material.SNow_BALL,2));
            event.setDropItems(false);
        }
    }
}
项目:Arcadia-Spigot    文件:WorldListener.java   
@EventHandler
public void onBlockBreak(BlockBreakEvent event) {
    ArcadiaAPI api = Arcadia.getPlugin(Arcadia.class).getAPI();
    if(!api.getGameManager().isAlive(event.getPlayer())) event.setCancelled(true);
    if(api.getGameManager().getCurrentGame() != null) {
        MaterialData materialData = new MaterialData(event.getBlock().getType(),event.getBlock().getData());
        if(!api.getGameManager().getCurrentGame().breakableBlocks.contains(materialData)) {
            event.setCancelled(true);
        }
    }
}
项目:HCFCore    文件:FoundDiamondsListener.java   
@EventHandler(ignoreCancelled = true,priority = EventPriority.MONITOR)
public void onBlockBreak(final BlockBreakEvent event) {
    final Player player = event.getPlayer();
    if(player.getGameMode() == GameMode.CREATIVE) {
        return;
    }
    if(player.getItemInHand().getEnchantments().containsKey(Enchantment.SILK_TOUCH)) return;;
    final Block block = event.getBlock();
    final Location blockLocation = block.getLocation();
    if(block.getType() == FoundDiamondsListener.SEARCH_TYPE && this.foundLocations.add(blockLocation.toString())) {
        int count = 1;
        for(int x = -5; x < 5; ++x) {
            for(int y = -5; y < 5; ++y) {
                for(int z = -5; z < 5; ++z) {
                    final Block otherBlock = blockLocation.clone().add((double) x,(double) y,(double) z).getBlock();
                    if(!otherBlock.equals(block) && otherBlock.getType() == FoundDiamondsListener.SEARCH_TYPE && this.foundLocations.add(otherBlock.getLocation().toString())) {
                        ++count;
                    }
                }
            }
        }

        String message;
        for(Player on : Bukkit.getonlinePlayers()) {
            if(plugin.getFactionManager().getPlayerFaction(player.getUniqueId()) != null) {
                 message = plugin.getFactionManager().getPlayerFaction(player.getUniqueId()).getRelation(on).tochatColour() + player.getName() + ChatColor.GRAY + " has found " + ChatColor.AQUA + count + ChatColor.GRAY + " diamond(s).";
                on.sendMessage(message);
            }else{
                message = ChatColor.AQUA + "[" + ChatColor.GRAY + "♠" + ChatColor.AQUA + "]" + ChatColor.GRAY + " " + ChatColor.AQUA + player.getName() + ChatColor.GRAY + " has just spotted " + ChatColor.BLUE + count + ChatColor.GRAY +" diamonds!";
                on.sendMessage(message);
            }
        }
    }
}
项目:AsgardAscension    文件:AbilityListener.java   
private void handleLuckyRepair(BlockBreakEvent event) {
    ItemStack item = event.getPlayer().getInventory().getItemInMainHand();
    if(Utility.getRandom(1,10000) > 2 || item == null ||!ItemStackGenerator.isRepairable(item)) {
        return;
    }
    item.setDurability((short)0);
}
项目:AddGun    文件:RailGun.java   
/**
 * Prevent using the gun-item to break blocks
 * @param event the break event
 */
@EventHandler(priority = EventPriority.HIGHEST,ignoreCancelled = true)
public void preventBlockBreakWithGun(BlockBreakEvent event) {
    if (event.getPlayer() != null && isGun(event.getPlayer().getInventory().getItemInMainHand())) {
        event.setCancelled(true);
    }
}
项目:prisonPicks    文件:Events.java   
@EventHandler
public void onBlockBreak(BlockBreakEvent event)
{

    Player player = event.getPlayer();
    ItemStack item = player.getInventory().getItemInMainHand();

    if (aoepick)
    {
        //stop our event recurring
        return;
    }

    //Are we using one of our picks
    if (Xpick.isPick(item))
    {
        aoepick = true;
        //this is an Xpick
        Xpick x = new Xpick();
        x.breakBlock(event);
    }else if (Pickoplenty.isPick(item))
    {
        Pickoplenty pop = new Pickoplenty();
        pop.breakBlock(event);
    }else if (XPickoPlenty.isPick(item))
    {
        aoepick = true;
        XPickoPlenty xpop = new XPickoPlenty();
        xpop.breakBlock(event);
    }

    aoepick = false;
}
项目:prisonPicks    文件:Xpickoplentytest.java   
@Test
public void testBreakBlock()
{
    //Todo: update this test to be more comprehensive
    BlockBreakEvent bbe = new BlockBreakEvent(block,player);
    XPickoPlenty xpick = new XPickoPlenty();

    xpick.breakBlock(bbe);
    verify(block,atLeastOnce()).setType(Material.AIR);
}
项目:prisonPicks    文件:XpickTest.java   
@Test
public void testBreakBlock()
{
    BlockBreakEvent bbe = new BlockBreakEvent(block,player);
    Xpick xpick = new Xpick();

    xpick.breakBlock(bbe);
    verify(block,atLeastOnce()).setType(Material.AIR);
}
项目:prisonPicks    文件:PickoplentyTest.java   
@Test
public void testBreakBlock()
{
    BlockBreakEvent bbe = new BlockBreakEvent(block,player);
    Pickoplenty pickoplenty = new Pickoplenty();

    pickoplenty.breakBlock(bbe);
    verify(block,atLeastOnce()).setType(Material.AIR);
}
项目:SuperiorCraft    文件:RealBreakBlock.java   
@SuppressWarnings("deprecation")
@EventHandler
public void onBlockbreak(BlockBreakEvent e) {
    if (e.getPlayer().getGameMode().equals(GameMode.CREATIVE)) return;

    for (BlockBreakRule r : BlockBreakRule.rules) {
        if (r.getMaterial().equals(e.getBlock().getType()) && (e.getPlayer().getEquipment().getItemInMainHand() == null || !r.getLevel().canBreakWith(e.getPlayer().getEquipment().getItemInMainHand()))) {
            e.setCancelled(true);
            return;
        }
    }

    for (CustomItem it : CustomItem.items) {
        if (it instanceof CustomTool) {
            if (e.getPlayer().getItemInHand() != null && e.getPlayer().getItemInHand().getType() != null && e.getPlayer().getItemInHand().hasItemMeta() && e.getPlayer().getItemInHand().getItemMeta().hasdisplayName() && it.getItem().getItemMeta().getdisplayName().equals(e.getPlayer().getItemInHand().getItemMeta().getdisplayName())) {
                if (!e.getPlayer().getItemInHand().getItemMeta().isUnbreakable()) {
                    //e.getPlayer().sendMessage(e.getPlayer().getItemInHand().getType().name());
                    int maxdamage = e.getPlayer().getItemInHand().getType().getMaxDurability(); // btw,this value is 0 for items that don't have durability bar
                    int damage = e.getPlayer().getItemInHand().getDurability() + ((CustomTool) it).getdamagePerUse();

                    if(damage > maxdamage) // calculated damage exceeds max damage
                    {
                        e.getPlayer().getInventory().remove(e.getPlayer().getItemInHand());
                    }
                    else
                    {
                        e.getPlayer().getItemInHand().setDurability((short) damage);
                    }
                }
            }
        }
    }
}
项目:SuperiorCraft    文件:Flag.java   
@Override
public void removeBlock(BlockBreakEvent e) {
        for (Entity en : e.getPlayer().getWorld().getEntities()) {
            if (en.getCustomName() != null && en.getCustomName().equals("flag") && en.getLocation().add(-0.5,-0.5).equals(e.getBlock().getLocation())) {
                en.remove();
                e.getPlayer().sendMessage(ChatColor.GRAY + "Flag removed");
            }
    }
}
项目:SuperiorCraft    文件:Elevator.java   
@Override
public CustomBlockInstance getInstance(ArmorStand s) {
    ElevatorInstance ei = new ElevatorInstance(s,getTextureEntity(s),getTexture());
    Bukkit.getScheduler().scheduleSyncRepeatingTask(SuperiorCraft.plugin,new Runnable() {
        @Override
        public void run() {
            if (s.getCustomName() != null && s.getCustomName().equals(getName()) && s.getLocation().add(-0.5,-0.5).getBlock().getType() == Material.AIR) {
                removeBlock(new BlockBreakEvent(s.getLocation().add(-0.5,-0.5).getBlock(),null));
                //System.out.println("A");
            }
        }
    },0);
    SuperiorCraft.plugin.getServer().getPluginManager().registerEvents(ei,SuperiorCraft.plugin);
    return ei;
}

今天关于org.bukkit.event.block.BlockPhysicsEvent的实例源码cockroachdb 源码分析的介绍到此结束,谢谢您的阅读,有关org.bukkit.block.Block的实例源码、org.bukkit.block.ContainerBlock的实例源码、org.bukkit.event.block.Action的实例源码、org.bukkit.event.block.BlockBreakEvent的实例源码等更多相关知识的信息可以在本站进行查询。

本文标签: