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

项目:EscapeLag    文件:WaterFlowLimitor.java   
@EventHandler
  public void WaterFowLimitor(BlockFromToEvent event) {
if(ConfigOptimize.WaterFlowLimitorenable == true){
    Block block = event.getBlock();
    Chunk chunk = block.getChunk();
       if (block.getType() == Material.STATIONARY_WATER || block.getType() == Material.STATIONARY_LAVA) {
           if(CheckFast(block.getChunk())){
            if(CheckedTimes.get(chunk) == null){
                CheckedTimes.put(chunk, 0);
            }
            CheckedTimes.put(chunk, CheckedTimes.get(chunk) + 1);
            if(CheckedTimes.get(chunk) > ConfigOptimize.WaterFlowLimitorPerChunkTimes){
                event.setCancelled(true);
            }
           }else{
               ChunkLastTime.put(block.getChunk(), System.currentTimeMillis());
           }
       }
}
  }
项目:NeverLag    文件:NoHighFallWater.java   
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
public void onBlockFromTo(BlockFromToEvent e) {
    if (!cm.antiWaterfall) {
        return;
    }
    Block to = e.getToBlock();
    if (to == null) {
        return;
    }
    if (e.getToBlock().getLocation().getBlockY() <= 63) {
        return;
    }
    if (isAirBottom(to, cm.antiWaterfallHeight)) {
        e.setCancelled(true);
    }
}
项目:GriefPreventionFlags    文件:FlagDef_NoFluidFlow.java   
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockFromTo(BlockFromToEvent event)
{
    Location location = event.getBlock().getLocation();
    if(this.previousLocation != null && location.equals(this.previousLocation))
    {
        if(!this.previousWasCancelled) return;
        event.setCancelled(true);
        return;
    }

    Flag flag = this.GetFlagInstanceAtLocation(location, null);
    boolean cancel = (flag != null);

    this.previousLocation = location;
    this.previousWasCancelled = cancel;
    if(cancel)
    {
        event.setCancelled(true);
    }
}
项目:HiddenOre    文件:ExploitListener.java   
/**
 * Prevent gaming using water/lava generators.
 * 
 * Add other generators as you become aware.
 * 
 * Credit for basic generator detector to fireblast709 (https://bukkit.org/threads/blocking-cobblestone-generators.120924/)
 * 
 * @param event
 */
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onGeneratingThings(BlockFromToEvent event) {
    Block root = event.getBlock();
    Block block = event.getToBlock();
    Material type = event.getBlock().getType();
    Material mirror1 = (Material.WATER == type || Material.STATIONARY_WATER == type) ? Material.LAVA : Material.WATER;
    Material mirror2 = (Material.WATER == type || Material.STATIONARY_WATER == type) ? Material.STATIONARY_LAVA : Material.STATIONARY_WATER;
    for (BlockFace face : faces) {
        Block check = block.getRelative(face, 1);
        Block check2 = root.getRelative(face, 1);
        if (mirror1 == check.getType() || mirror2 == check.getType() ||
                mirror1 == check2.getType() || mirror2 == check2.getType()) {
            plugin.getTracking().trackBreak(block.getLocation());
            plugin.getTracking().trackBreak(check.getLocation());
            plugin.getTracking().trackBreak(check2.getLocation());
            debug("Generating something at union of {0} and {1}/{2}", block, check, check2);
            return;
        }
    }
}
项目:Arcade2    文件:Core.java   
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = false)
public void detectLeak(BlockFromToEvent event) {
    if (this.isLeaked() || !this.getDetector().contains(event.getToBlock())) {
        return;
    }

    Material newType = event.getBlock().getType();
    if (this.getLiquid().accepts(newType)) {
        CoreLeakEvent leakEvent = new CoreLeakEvent(this.game.getPlugin(), this);
        this.game.getPlugin().getEventBus().publish(leakEvent);

        if (!leakEvent.isCanceled()) {
            // the core has leaked
            this.leak(null, // We don't know the competitor
                      null); // We don't know the player
        }
    }
}
项目:Cardinal    文件:CoreModule.java   
/**
 * Checks if lava has reached the leak distance below this core.
 *
 * @param event The event.
 */
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockFromTo(BlockFromToEvent event) {
  Match match = Cardinal.getMatch(event.getWorld());
  if (match == null) {
    return;
  }
  Block to = event.getToBlock();
  Material type = event.getBlock().getType();
  if (type.equals(Material.STATIONARY_LAVA) || type.equals(Material.LAVA)) {
    Core core = getClosestCore(match, to.getLocation().clone());
    if (core != null && !core.isComplete()) {
      int distance = getBottom(core) - to.getY();
      if (distance >= core.getLeak()) {
        core.setComplete(true);
        Channels.getGlobalChannel(Cardinal.getMatchThread(match)).sendMessage(new LocalizedComponentBuilder(
            ChatConstant.getConstant("objective.core.completed"),
            new TeamComponent(core.getOwner()),
            Components.setColor(core.getComponent(), ChatColor.RED)).color(ChatColor.RED).build());
        Bukkit.getPluginManager().callEvent(new ObjectiveCompleteEvent(core, null));
      }
    }
  }
}
项目:cubit    文件:AdditionalPhysicsListener.java   
@EventHandler
public void onLiquidFlowOtherLand(final BlockFromToEvent event) {
    Chunk fromChunk = event.getBlock().getLocation().getChunk();
    Chunk toChunk = event.getToBlock().getLocation().getChunk();
    RegionData fromLand = CubitBukkitPlugin.inst().getRegionManager().praseRegionData(fromChunk.getWorld(),
            fromChunk.getX(), fromChunk.getZ());

    RegionData toLand = CubitBukkitPlugin.inst().getRegionManager().praseRegionData(toChunk.getWorld(),
            toChunk.getX(), toChunk.getZ());

    if (toLand.getLandType() == LandTypes.NOTYPE) {
        return;
    }

    if (fromLand.getLandType() == LandTypes.SERVER && toLand.getLandType() == LandTypes.SERVER) {
        return;
    }

    if (!CubitBukkitPlugin.inst().getRegionManager().hasLandPermission(toLand, fromLand.getOwnersUUID()[0])) {
        event.setCancelled(true);
    }
}
项目:Cardinal-Plus    文件:CoreObjective.java   
@EventHandler(priority = EventPriority.HIGHEST)
public void onBlockFromTo(BlockFromToEvent event) {
    if (!event.isCancelled()) {
        Block to = event.getToBlock();
        Block from = event.getBlock();
        if (CoreObjective.getClosestCore(to.getX(), to.getY(), to.getZ()).equals(this)) {
            if ((from.getType().equals(Material.LAVA) || from.getType().equals(Material.STATIONARY_LAVA)) && to.getType().equals(Material.AIR)) {
                double minY = 256;
                for (Block block : getBlocks()) {
                    if (block.getY() < minY)
                        minY = block.getY();
                }
                if (minY - to.getY() >= leak && !this.complete) {
                    this.complete = true;
                    event.setCancelled(false);
                    if (this.show) ChatUtils.getGlobalChannel().sendLocalizedMessage(new UnlocalizedChatMessage(ChatColor.RED + "{0}", new LocalizedChatMessage(ChatConstant.UI_OBJECTIVE_LEAKED, team.getCompleteName() + ChatColor.RED, ChatColor.DARK_AQUA + name + ChatColor.RED)));
                    FireworkUtil.spawnFirework(event.getBlock().getLocation(), event.getBlock().getWorld(), MiscUtils.convertChatColorToColor(team.getColor()));
                    ObjectiveCompleteEvent compEvent = new ObjectiveCompleteEvent(this, null);
                    Bukkit.getServer().getPluginManager().callEvent(compEvent);
                }
            }
        }
    }
}
项目:GriefPreventionPlus    文件:BlockEventHandler.java   
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onBlockFromTo (BlockFromToEvent spreadEvent)
{
    //always allow fluids to flow straight down
       if(spreadEvent.getFace() == BlockFace.DOWN) return;

    //don't track in worlds where claims are not enabled
    if(!GriefPrevention.instance.claimsEnabledForWorld(spreadEvent.getBlock().getWorld())) return;

    //where to?
       Block toBlock = spreadEvent.getToBlock();
       Location toLocation = toBlock.getLocation();
       Claim toClaim = this.dataStore.getClaimAt(toLocation, false, lastSpreadClaim);

       //if into a land claim, it must be from the same land claim
       if(toClaim != null)
       {
           this.lastSpreadClaim = toClaim;
           if(!toClaim.contains(spreadEvent.getBlock().getLocation(), false, false))
           {
               spreadEvent.setCancelled(true);
           }
       }
}
项目:buildinggame    文件:LiquidFlow.java   
/**
    * Handles liquid flowing
    *
    * @param e an event indicating that a liquid has flown
    * @see BlockFromToEvent
    * @since 2.2.1
    */
@EventHandler
public void onBlockFromTo(BlockFromToEvent e) {
    Location from = e.getBlock().getLocation();
    Location to = e.getToBlock().getLocation();

    for (Arena arena : ArenaManager.getInstance().getArenas()) {
        for (Plot plot : arena.getPlots()) {
               Region boundary = plot.getBoundary();

               if (boundary == null)
                continue;

            if (boundary.isInside(from) != boundary.isInside(to))
                //checks if the source flows/goes out of the boundary and vice versa
                e.setCancelled(true);
        }
    }
}
项目:AncientGates    文件:PluginBlockListener.java   
@EventHandler(priority = EventPriority.NORMAL)
public void onBlockFromTo(final BlockFromToEvent event) {
    if (event.isCancelled())
        return;

    final Block block = event.getBlock();

    if (!block.getType().equals(Material.STATIONARY_WATER) && !block.getType().equals(Material.STATIONARY_LAVA))
        return;

    // Ok so water/lava starts flowing within a portal frame
    // Find the nearest gate!
    final WorldCoord blockCoord = new WorldCoord(block);
    final Gate nearestGate = Gates.gateFromPortal(blockCoord);

    if (nearestGate != null) {
        event.setCancelled(true);
    }
}
项目:beaconz    文件:BeaconProtectionListener.java   
/**
 * Prevents liquid flowing over the beacon beam
 * @param event
 */
@EventHandler(priority = EventPriority.LOW, ignoreCancelled=true)
public void onLiquidFlow(final BlockFromToEvent event) {
    World world = event.getBlock().getWorld();
    if (!world.equals(getBeaconzWorld())) {
        return;
    }
    // Only bother with horizontal flows
    if (event.getToBlock().getX() != event.getBlock().getX() || event.getToBlock().getZ() != event.getBlock().getZ()) {
        BeaconObj beacon = getRegister().getBeaconAt(event.getToBlock().getX(),event.getToBlock().getZ());
        if (beacon != null && beacon.getY() < event.getToBlock().getY()) {
            event.setCancelled(true);
            return;
        }
        // Stop flows outside of the game area
        Game game = getGameMgr().getGame(event.getBlock().getLocation());
        if (game == null) {
            event.setCancelled(true);
            return;
        }
    }
}
项目:PlotSquared-Chinese    文件:PlayerEvents.java   
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onChange(final BlockFromToEvent e) {
    final Block b = e.getToBlock();
    final Location loc = BukkitUtil.getLocation(b.getLocation());
    if (PlotSquared.isPlotWorld(loc.getWorld())) {
        if (MainUtil.isPlotRoad(loc)) {
            e.setCancelled(true);
        }
        else {
            Plot plot = MainUtil.getPlot(loc);
            if (FlagManager.isPlotFlagTrue(plot, "disable-physics")) {
                e.setCancelled(true);
            }
        }
    }
}
项目:MonoMods    文件:TribeProtectListener.java   
@EventHandler
public void blockFlow(BlockFromToEvent event) {
    Location source = event.getBlock().getLocation();
    Tribe sourceGroup = TribeProtect.getBlockOwnership(source);
    Location spread = event.getToBlock().getLocation();
    Tribe spreadGroup = TribeProtect.getBlockOwnership(spread);

    //if spreadgroup == null, allow
    //if sourcegroup == null, do not allow where spreadgroup != null
    if (!sourceGroup.isValid()) {
        if (!spreadGroup.isValid()) return;
        else event.setCancelled(true);
    } else {
        if (!spreadGroup.isValid()) return;
        else {
            if (!sourceGroup.equals(spreadGroup))
                event.setCancelled(true);
        }
    }
}
项目:modules-extra    文件:ListenerFlow.java   
@SuppressWarnings("deprecation")
private void handleWaterFlow(BlockFromToEvent event, BlockState toState, BlockState fromState)
{
    Material material = toState.getType();
    if (material == WATER || material == STATIONARY_WATER)
    {
        this.waterFlowFormSource(event.getToBlock());
    }
    else if (material == LAVA || material == STATIONARY_LAVA && toState.getRawData() < 3)
    {
        this.log(LavaWaterForm.class, toState, COBBLESTONE);
    }
    else if (material == AIR || isNonFluidProofBlock(material))
    {
        this.waterFlowForm(event);
        this.waterFlowFormSource(event.getToBlock());
        this.logFlow(material == AIR ? WaterFlow.class : WaterBreak.class, toState, WATER, fromState);
    }
}
项目:modules-extra    文件:ListenerFlow.java   
private void waterFlowForm(BlockFromToEvent event)
{
    for (final BlockFace face : BLOCK_FACES)
    {
        if (face == UP)
        {
            continue;
        }
        final Block nearBlock = event.getToBlock().getRelative(face);
        if (nearBlock.getType() == LAVA && nearBlock.getState().getRawData() <= 4)
        {
            this.log(LavaWaterForm.class, nearBlock.getState(), COBBLESTONE);
        }
        if (nearBlock.getType() == STATIONARY_LAVA)
        {
            this.log(LavaWaterForm.class, nearBlock.getState(), OBSIDIAN);
        }
    }
}
项目:Empirecraft    文件:OnBlockMove.java   
@EventHandler
public void onBlockMove(BlockFromToEvent event) {
    Block block = event.getBlock(), to = event.getToBlock();
    String world = block.getWorld().getUID().toString();
    Integer x = to.getLocation().getChunk().getX(), z = to.getLocation().getChunk().getZ();
    if (QuickChecks.isWorldChunkClaimed(serverdata.get("worldmap").get(world), x, z, "cla")) {
        if (((HashMap) ((HashMap) serverdata.get("worldmap").get(world).get(x)).get(z)).containsKey("str")) {
            if (block.getType().equals(WATER)) {
                block.setType(STATIONARY_WATER);
            } else if (block.getType().equals(LAVA)) {
                block.setType(STATIONARY_LAVA);
            }
            event.setCancelled(true);
        }
    }
}
项目:TCMinigames    文件:BlockListener.java   
@EventHandler
public void onLiquidFlow(BlockFromToEvent event){
    if(Minigame.getCurrentMinigame()!=null){
        switch(Minigame.getCurrentMinigame().getMap().getType()){
        case CIRCLE_OF_BOOM:
            event.setCancelled(true);
            break;
        case KEY_QUEST:
            break;
        case WATER_THE_MONUMENT:
            break;
        default:
            break;

        }
    }
}
项目:block-saver    文件:GeneralListener.java   
@EventHandler(priority = EventPriority.LOWEST)
public void onWaterPassThrough(final BlockFromToEvent event) {
    Block block = event.getToBlock();
    Location location = block.getLocation();

    if (!reinforcementManager.isWorldActive(location.getWorld().getName())) {
        return;
    }

    if (!reinforcementManager.isReinforced(location)) {
        return;
    }

    // If the event is caused by a dragon egg moving to a new location, simply make sure it is not teleporting into a field.
    if (Material.DRAGON_EGG.equals(event.getBlock().getType())) {
        Bukkit.getServer().getPluginManager().callEvent(new BlockDeinforceEvent(block, "Environment", true));
        return;
    }

    if (!liquidsDestroyReinforcedBlocks) {
        event.setCancelled(true);
        return;
    }
}
项目:Essentials    文件:EssentialsProtectBlockListener.java   
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockFromTo(final BlockFromToEvent event)
{
    final ProtectHolder settings = prot.getSettings();
    final Block block = event.getBlock();
    if (block.getType() == Material.WATER || block.getType() == Material.STATIONARY_WATER)
    {
        event.setCancelled(settings.getData().getPrevent().isWaterFlow());
        return;
    }

    if (block.getType() == Material.LAVA || block.getType() == Material.STATIONARY_LAVA)
    {
        event.setCancelled(settings.getData().getPrevent().isLavaFlow());
    }
    // TODO: Test if this still works
        /*
     * if (block.getType() == Material.AIR) {
     * event.setCancelled(prot.getSettingBool(ProtectConfig.prevent_water_bucket_flow)); return; }
     */
}
项目:EscapeLag    文件:SkullCrashPatch.java   
@EventHandler(priority = EventPriority.LOWEST)
public void NoSkullCrash(BlockFromToEvent evt) {
    if (noSkullCrash) {
        if(evt.isCancelled()) {
            return;
        }
        if (evt.getToBlock().getType() == Material.SKULL) {
            evt.setCancelled(true);
        }
    }
}
项目:ProjectAres    文件:BlockTransformListener.java   
@SuppressWarnings("deprecation")
@EventWrapper
public void onBlockFromTo(BlockFromToEvent event) {
    if(event.getToBlock().getType() != event.getBlock().getType()) {
        BlockState oldState = event.getToBlock().getState();
        BlockState newState = event.getToBlock().getState();
        newState.setType(event.getBlock().getType());
        newState.setRawData(event.getBlock().getData());

        // Check for lava ownership
        this.callEvent(event, oldState, newState, blockResolver.getOwner(event.getBlock()));
    }
}
项目:NavyCraft2-Lite    文件:NavyCraft_BlockListener.java   
@EventHandler(priority = EventPriority.HIGH)
public void onBlockFromTo(final BlockFromToEvent event) {
    if (!event.isCancelled()) {
        final Block block = event.getToBlock();

        if ((block.getTypeId() == 75) || (block.getTypeId() == 76) || (block.getTypeId() == 65) || (block.getTypeId() == 69) || (block.getTypeId() == 77) || (block.getTypeId() == 70) || (block.getTypeId() == 72) || (block.getTypeId() == 68) || (block.getTypeId() == 63) || (block.getTypeId() == 143) || (block.getTypeId() == 55)) {
            if (Craft.getCraft(block.getX(), block.getY(), block.getZ()) != null) {
                // event.setCancelled(true);
                block.setTypeId(8);
            }
        }
    }
}
项目:NavyCraft2-Lite    文件:MoveCraft_BlockListener.java   
@EventHandler(priority = EventPriority.HIGH)
public void onBlockFromTo(final BlockFromToEvent event) {
    if (!event.isCancelled()) {
        final Block block = event.getToBlock();

        if ((block.getTypeId() == 75) || (block.getTypeId() == 76) || (block.getTypeId() == 65) || (block.getTypeId() == 69) || (block.getTypeId() == 77) || (block.getTypeId() == 70) || (block.getTypeId() == 72) || (block.getTypeId() == 68) || (block.getTypeId() == 63) || (block.getTypeId() == 143) || (block.getTypeId() == 55)) {
            if (Craft.getCraft(block.getX(), block.getY(), block.getZ()) != null) {
                // event.setCancelled(true);
                block.setTypeId(8);
            }
        }
    }
}
项目:Arcade2    文件:BlockTransformListeners.java   
@EventHandler(ignoreCancelled = true)
public void onBlockFromTo(BlockFromToEvent event) {
    if (event.getBlock().getType().equals(event.getToBlock().getType())) {
        return;
    }

    this.post(event,
              event.getToBlock().getState(),
              event.getBlock().getState());
}
项目:RedProtect    文件:RPGlobalListener.java   
@EventHandler
   public void onFlow(BlockFromToEvent e){
    RedProtect.get().logger.debug("RPGlobalListener - Is BlockFromToEvent event");
    if (e.isCancelled()){
        return;
    }
    Block b = e.getToBlock();
    Block bfrom = e.getBlock();
    RedProtect.get().logger.debug("RPGlobalListener - Is BlockFromToEvent event is to " + b.getType().name() + " from " + bfrom.getType().name());
    Region r = RedProtect.get().rm.getTopRegion(b.getLocation());
    if (r != null){
        return;
    }
    if (bfrom.isLiquid() && !RPConfig.getGlobalFlagBool(b.getWorld().getName()+".liquid-flow")){
             e.setCancelled(true);   
             return;
    }

    if ((bfrom.getType().equals(Material.WATER) || bfrom.getType().equals(Material.STATIONARY_WATER)) 
            && !RPConfig.getGlobalFlagBool(b.getWorld().getName()+".allow-changes-of.water-flow")){
         e.setCancelled(true);   
         return;
    }

    if ((bfrom.getType().equals(Material.LAVA) || bfrom.getType().equals(Material.STATIONARY_LAVA)) 
            && !RPConfig.getGlobalFlagBool(b.getWorld().getName()+".allow-changes-of.lava-flow")){
         e.setCancelled(true);   
         return;
    }

    if (!b.isEmpty() && !RPConfig.getGlobalFlagBool(b.getWorld().getName()+".allow-changes-of.flow-damage")){
         e.setCancelled(true);
    }
}
项目:RedProtect    文件:RPBlockListener.java   
@EventHandler
  public void onFlow(BlockFromToEvent e){
RedProtect.get().logger.debug("RPBlockListener - Is BlockFromToEvent event");
if (e.isCancelled()){
        return;
    }       
    Block bto = e.getToBlock();
    Block bfrom = e.getBlock();
RedProtect.get().logger.debug("RPBlockListener - Is BlockFromToEvent event is to " + bto.getType().name() + " from " + bfrom.getType().name());
    Region rto = RedProtect.get().rm.getTopRegion(bto.getLocation());
    if (rto != null && bfrom.isLiquid() && !rto.canFlow()){
             e.setCancelled(true);   
             return;
    }

    if (rto != null && !bto.isEmpty() && !rto.FlowDamage()){
         e.setCancelled(true);      
        return;
        }

    //deny blocks spread in/out regions
    Region rfrom = RedProtect.get().rm.getTopRegion(bfrom.getLocation());
    if (rfrom != null && rto != null && rfrom != rto && !rfrom.sameLeaders(rto)){
    e.setCancelled(true);
    return;
}
if (rfrom == null && rto != null){
    e.setCancelled(true);
}
  }
项目:MyiuLib    文件:MGListener.java   
@EventHandler(priority = EventPriority.HIGHEST)
public void onBlockFlow(BlockFromToEvent e) {
    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().isBlockFlowAllowed()) {
                    e.setCancelled(true);
                    break;
                }
            }
        }
    }
}
项目:beaconz    文件:BeaconPassiveDefenseListener.java   
/**
 * Prevents the tipping of liquids over beacons
 * @param event
 */
/*
@EventHandler(priority = EventPriority.LOW, ignoreCancelled=true)
public void onBucketEmpty(final PlayerBucketEmptyEvent event) {
    //getLogger().info("DEBUG: " + event.getEventName());
    World world = event.getBlockClicked().getWorld();
    if (!world.equals(getBeaconzWorld())) {
        //getLogger().info("DEBUG: not right world");
        return;
    }
    if (event.getBlockClicked().getY() == BLOCK_HEIGHT) {
        event.setCancelled(true);
        event.getPlayer().sendMessage(ChatColor.RED + "You cannot do that here!");
    }
}
 */
@EventHandler(priority = EventPriority.LOW, ignoreCancelled=true)
public void onBlockFlow(final BlockFromToEvent event) {
    //getLogger().info("DEBUG: " + event.getEventName());
    World world = event.getBlock().getWorld();
    if (!event.getBlock().isLiquid() || !world.equals(getBeaconzWorld())) {
        //getLogger().info("DEBUG: not right world");
        return;
    }
    if (getRegister().isAboveBeacon(event.getToBlock().getLocation())) {
        event.setCancelled(true);
        //getLogger().info("DEBUG: stopping flow");
    }
}
项目:Peacecraft    文件:PortalListener.java   
@EventHandler
public void onBlockFromTo(BlockFromToEvent event) {
    if(event.getBlock().getType() == Material.WATER) {
        String portal = this.module.getPortalManager().getPortal(event.getBlock().getLocation());
        if(portal != null) {
            event.setCancelled(true);
        }
    }
}
项目:Peacecraft    文件:LotsListener.java   
@EventHandler
public void onBlockFromTo(BlockFromToEvent event) {
    Lot from = this.module.getLotManager().getLot(event.getBlock().getLocation());
    Lot to = this.module.getLotManager().getLot(event.getToBlock().getLocation());
    Town fromTown = this.module.getLotManager().getTown(event.getBlock().getLocation());
    Town toTown = this.module.getLotManager().getTown(event.getToBlock().getLocation());
    if((from != null && to == null) || (from == null && to != null) || from != to || (fromTown != null && toTown == null) || (fromTown == null && toTown != null) || fromTown != toTown) {
        event.setCancelled(true);
    }
}
项目:CastleRush    文件:GamePlotListener.java   
@EventHandler
public void onLiquidFlow(BlockFromToEvent event){
    Block to = event.getToBlock();
    Block from = event.getBlock();

    if(GameManager.isPlotPart(from.getLocation())
            && !GameManager.isPlotPart(to.getLocation())){
        event.setCancelled(true);
    }
}
项目:WaterlessRedstone    文件:WaterListener.java   
/**
 * Event called when a flowing liquid washes away a block.
 *
 * @param event The BlockFromToBlock
 */
@EventHandler(priority = EventPriority.HIGHEST)
public void onBlockFromTo(BlockFromToEvent event) {
    if(plugin.getWaterlessMats().contains(event.getToBlock().getType())) {
        event.setCancelled(true);
    }
}
项目:NovaGuilds    文件:RegionInteractListener.java   
@EventHandler
public void onBlockFromTo(BlockFromToEvent event) {
    if(!Config.REGION_WATERFLOW.getBoolean()) {
        Material type = event.getBlock().getType();

        if((type == Material.WATER || type == Material.STATIONARY_WATER || type == Material.LAVA || type == Material.STATIONARY_LAVA)
                && RegionManager.get(event.getBlock()) == null
                && RegionManager.get(event.getToBlock()) != null) {
            event.setCancelled(true);
        }
    }
}
项目:acidisland    文件:LavaCheck.java   
/**
   * Removes stone generated by lava pouring onto water
   * 
   * @param e
   */
  @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
  public void onCleanstoneGen(BlockFromToEvent e) {
      // Only do this in ASkyBlock world
      if (!e.getBlock().getWorld().equals(ASkyBlock.getIslandWorld())) {
          return;
      }
      // Do nothing if a new island is being created
      if (plugin.isNewIsland())
          return;
      final Block to = e.getToBlock();
      /*
plugin.getLogger().info("From material is " + e.getBlock().toString());
plugin.getLogger().info("To material is " + to.getType().toString());
plugin.getLogger().info("---------------------------------");
       */
      if (Settings.acidDamage > 0) {
          if (DEBUG)
              plugin.getLogger().info("DEBUG: cleanstone gen " + e.getEventName());

          final Material prev = to.getType();
          // plugin.getLogger().info("To material was " +
          // to.getType().toString());
          plugin.getServer().getScheduler().runTask(plugin, new Runnable() {
              @Override
              public void run() {
                  // plugin.getLogger().info("To material is after 1 tick " +
                  // to.getType().toString());
                  if ((prev.equals(Material.WATER) || prev.equals(Material.STATIONARY_WATER)) && to.getType().equals(Material.STONE)) {
                      to.setType(prev);
                      if (plugin.getServer().getVersion().contains("(MC: 1.8") || plugin.getServer().getVersion().contains("(MC: 1.7")) {
                          to.getWorld().playSound(to.getLocation(), Sound.valueOf("FIZZ"), 1F, 2F);
                      } else {
                          to.getWorld().playSound(to.getLocation(), Sound.ENTITY_CREEPER_PRIMED, 1F, 2F);
                      }
                  }
              }
          });
      }
  }
项目:Factoid    文件:WorldListener.java   
/**
 * On block from to.
 *
 * @param event the event
 */
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onBlockFromTo(BlockFromToEvent event) {

    IDummyLand land = Factoid.getThisPlugin().iLands().getLandOrOutsideArea(event.getBlock().getLocation());
    Material ml = event.getBlock().getType();

    // Liquid flow
    if (((ml == Material.LAVA || ml == Material.STATIONARY_LAVA)
            && land.getFlagAndInherit(FlagList.LAVA_FLOW.getFlagType()).getValueBoolean() == false)
            || ((ml == Material.WATER || ml == Material.STATIONARY_WATER)
                    && land.getFlagAndInherit(FlagList.WATER_FLOW.getFlagType()).getValueBoolean() == false)) {
        event.setCancelled(true);
    }
}
项目:UltimateSurvivalGames    文件:ResetListener.java   
@EventHandler(priority = EventPriority.MONITOR)
public void onFromToEvent(BlockFromToEvent event)  {
    if(!event.isCancelled()) {
        logChunk(event.getToBlock().getLocation());
        logChunk(event.getBlock().getLocation());
    }
}
项目:askyblock    文件:LavaCheck.java   
/**
   * Removes stone generated by lava pouring onto water
   * 
   * @param e
   */
  @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
  public void onCleanstoneGen(BlockFromToEvent e) {
      // Only do this in ASkyBlock world
      if (!e.getBlock().getWorld().equals(ASkyBlock.getIslandWorld())) {
          return;
      }
      // Do nothing if a new island is being created
      if (plugin.isNewIsland())
          return;
      final Block to = e.getToBlock();
      /*
plugin.getLogger().info("From material is " + e.getBlock().toString());
plugin.getLogger().info("To material is " + to.getType().toString());
plugin.getLogger().info("---------------------------------");
       */
      if (Settings.acidDamage > 0) {
          if (DEBUG)
              plugin.getLogger().info("DEBUG: cleanstone gen " + e.getEventName());

          final Material prev = to.getType();
          // plugin.getLogger().info("To material was " +
          // to.getType().toString());
          plugin.getServer().getScheduler().runTask(plugin, new Runnable() {
              @Override
              public void run() {
                  // plugin.getLogger().info("To material is after 1 tick " +
                  // to.getType().toString());
                  if ((prev.equals(Material.WATER) || prev.equals(Material.STATIONARY_WATER)) && to.getType().equals(Material.STONE)) {
                      to.setType(prev);
                      if (plugin.getServer().getVersion().contains("(MC: 1.8") || plugin.getServer().getVersion().contains("(MC: 1.7")) {
                          to.getWorld().playSound(to.getLocation(), Sound.valueOf("FIZZ"), 1F, 2F);
                      } else {
                          to.getWorld().playSound(to.getLocation(), Sound.ENTITY_CREEPER_PRIMED, 1F, 2F);
                      }
                  }
              }
          });
      }
  }
项目:PlotMe-Core    文件:BukkitPlotListener.java   
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onBlockFromTo(BlockFromToEvent event) {
    Location location = BukkitUtil.adapt(event.getBlock().getLocation());
    if (manager.isPlotWorld(location)) {
        PlotId id = manager.getPlotId(location);
        if (id == null) {
            event.setCancelled(true);
        } else {
            event.setCancelled(api.isPlotLocked(id));
        }
    }
}
项目:DDCustomPlugin    文件:PlotMeOverride.java   
@EventHandler (priority=EventPriority.HIGHEST)
    public void BlockFromTo(BlockFromToEvent e) {
        if (e.isCancelled()) {
            Location loc = e.getToBlock().getLocation();
            if (loc.getWorld().getName().equals("Build")) {
//              String id = PlotManager.getPlotId(loc);
//              if (getPlot(id) != null)
//                  return;
                String x1 = PlotManager.getPlotId(loc.clone().add(5, 0, 0));
                String x2 = PlotManager.getPlotId(loc.clone().add(-5, 0, 0));
                String y1 = PlotManager.getPlotId(loc.clone().add(0, 0, 5));
                String y2 = PlotManager.getPlotId(loc.clone().add(0, 0, -5));
                boolean allowed = false;
                if (getPlot(x1) != null && getPlot(x2) != null)
                    allowed = getPlot(x1).getOwner().equals(getPlot(x2).getOwner());
                if (!allowed && getPlot(y1) != null && getPlot(y2) != null)
                    allowed = getPlot(y1).getOwner().equals(getPlot(y2).getOwner());
                if (allowed) {
                    e.setCancelled(false);
                    return;
                }
                String cor1 = PlotManager.getPlotId(loc.clone().add(5, 0, 5));
                String cor2 = PlotManager.getPlotId(loc.clone().add(-5, 0, 5));
                String cor3 = PlotManager.getPlotId(loc.clone().add(5, 0, 5));
                String cor4 = PlotManager.getPlotId(loc.clone().add(-5, 0, -5));
                if (getPlot(cor1) != null && getPlot(cor2) != null && getPlot(cor3) != null && getPlot(cor4) != null)
                    if (getPlot(cor1).getOwner().equals(getPlot(cor2).getOwner()) && getPlot(cor1).getOwner().equals(getPlot(cor3).getOwner()) && getPlot(cor1).getOwner().equals(getPlot(cor4).getOwner())) {
                        e.setCancelled(false);
                    }
            }
        }
    }