當前位置: 首頁>>代碼示例>>Java>>正文


Java EntityChangeBlockEvent.getBlock方法代碼示例

本文整理匯總了Java中org.bukkit.event.entity.EntityChangeBlockEvent.getBlock方法的典型用法代碼示例。如果您正苦於以下問題:Java EntityChangeBlockEvent.getBlock方法的具體用法?Java EntityChangeBlockEvent.getBlock怎麽用?Java EntityChangeBlockEvent.getBlock使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.bukkit.event.entity.EntityChangeBlockEvent的用法示例。


在下文中一共展示了EntityChangeBlockEvent.getBlock方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onChangeBlock

import org.bukkit.event.entity.EntityChangeBlockEvent; //導入方法依賴的package包/類
@EventHandler
public void onChangeBlock(EntityChangeBlockEvent e){	
	if (e.isCancelled()){
		return;
	}
	
	if (e.getEntity() instanceof Player){
		Player p = (Player) e.getEntity();    	
    	Block b = e.getBlock();
    	Region r = RedProtect.get().rm.getTopRegion(b.getLocation());
   		if (r != null && !r.canBuild(p)){
   			RPLang.sendMessage(p, "blocklistener.region.cantbreak");
       		e.setCancelled(true);
   		}
   	}
}
 
開發者ID:FabioZumbi12,項目名稱:RedProtect,代碼行數:17,代碼來源:RPMine19.java

示例2: MonsterBlockBreak

import org.bukkit.event.entity.EntityChangeBlockEvent; //導入方法依賴的package包/類
@EventHandler
 public void MonsterBlockBreak(EntityChangeBlockEvent event) {
 	Entity e = event.getEntity();    	
 	Block b = event.getBlock();
 	Region r = RedProtect.get().rm.getTopRegion(event.getBlock().getLocation());
 	if (r != null){
   	   return;
     }
 	
 	if (b != null){
 		RedProtect.get().logger.debug("RPGlobalListener - Is EntityChangeBlockEvent event. Block: "+b.getType().name());
 	}
 	
 	if (e instanceof Monster) {
         if (!RPConfig.getGlobalFlagBool(e.getWorld().getName()+".entity-block-damage")){
         	event.setCancelled(true);
         }
 	}
 	if (e instanceof Player){
 		Player p = (Player) e;
 		if (!bypassBuild(p, b, 2)){
 			event.setCancelled(true);
}
 	}
 }
 
開發者ID:FabioZumbi12,項目名稱:RedProtect,代碼行數:26,代碼來源:RPGlobalListener.java

示例3: onEntityFall

import org.bukkit.event.entity.EntityChangeBlockEvent; //導入方法依賴的package包/類
@EventHandler(ignoreCancelled=true, priority=EventPriority.HIGHEST)
public void onEntityFall(EntityChangeBlockEvent event) {
    if (event.getEntityType() != EntityType.FALLING_BLOCK) {
        return;
    }
    Block block = event.getBlock();
    World world = block.getWorld();
    String worldname = world.getName();
    if (!PlotSquared.isPlotWorld(worldname)) {
        return;
    }
    Location loc = BukkitUtil.getLocation(block.getLocation());
    Plot plot = MainUtil.getPlot(loc);
    if (plot == null) {
        return;
    }
    if (FlagManager.isPlotFlagTrue(plot, "disable-physics")) {
        event.setCancelled(true);
    }
}
 
開發者ID:Mayomi,項目名稱:PlotSquared-Chinese,代碼行數:21,代碼來源:PlayerEvents.java

示例4: onEntityChangeBlock

import org.bukkit.event.entity.EntityChangeBlockEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onEntityChangeBlock(EntityChangeBlockEvent event) {
    final Block block = event.getBlock();
    if ( block == null )
        return;

    // If we're not changing a block in an important way, who cares?
    if ( ! AbyssPlugin.validLiquid(block) && plugin.frameMaterials.contains(event.getTo()) )
        return;

    // Check to see if the block is protected.
    final ArrayList<ABPortal> portals = plugin.protectBlock(block);
    if ( portals == null ) {
        event.setCancelled(true);
        return;
    }

    // After the block is gone, update all our portals.
    if ( portals.size() > 0 )
        plugin.getServer().getScheduler().runTask(plugin, new UpdatePortals(event, portals));
}
 
開發者ID:stendec,項目名稱:Abyss,代碼行數:22,代碼來源:BlockListener.java

示例5: onEntityChangeBlock

import org.bukkit.event.entity.EntityChangeBlockEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onEntityChangeBlock(final EntityChangeBlockEvent event)
{
	if (plugin.getSettings().areSignsDisabled())
	{
		return;
	}

	final Block block = event.getBlock();
	if (((block.getTypeId() == Material.WALL_SIGN.getId() || block.getTypeId() == Material.SIGN_POST.getId()) && EssentialsSign.isValidSign(
		 new EssentialsSign.BlockSign(block))) || EssentialsSign.checkIfBlockBreaksSigns(block))
	{
		event.setCancelled(true);
		return;
	}
	for (EssentialsSign sign : plugin.getSettings().getEnabledSigns())
	{
		if (sign.getBlocks().contains(block.getType()) && !sign.onBlockBreak(block, ess))
		{
			event.setCancelled(true);
			return;
		}
	}
}
 
開發者ID:Curtis3321,項目名稱:Essentials,代碼行數:25,代碼來源:SignEntityListener.java

示例6: onEntityChangeBlock

import org.bukkit.event.entity.EntityChangeBlockEvent; //導入方法依賴的package包/類
@EventHandler(priority=EventPriority.HIGHEST, ignoreCancelled = true)
public void onEntityChangeBlock(EntityChangeBlockEvent e) {
	Block block = e.getBlock();
	if (maybeSideTracked(block)) {
		trySideBreak(block, BreakType.NATURAL, null);
	}
	if (maybeBelowTracked(block)) {
		block = block.getRelative(BlockFace.UP);
	}
	Location loc = block.getLocation();
	if (!pendingChecks.contains(loc)) {
		pendingChecks.add(loc);
		handleBreak(block, BreakType.NATURAL, null, null);
	}
}
 
開發者ID:DevotedMC,項目名稱:CropControl,代碼行數:16,代碼來源:CropControlEventHandler.java

示例7: onEntityChangeBlock

import org.bukkit.event.entity.EntityChangeBlockEvent; //導入方法依賴的package包/類
@EventHandler(ignoreCancelled = true)
public void onEntityChangeBlock(EntityChangeBlockEvent event) {
    Block block = event.getBlock();

    boolean arrow = event.getEntity() instanceof Arrow;
    if (arrow && event.getTo().equals(Material.AIR) &&
            block.getType().equals(Material.TNT)) {
        return;
    }

    this.post(event,
              block.getState(),
              this.applyState(block, event.getTo(), event.getData()));
}
 
開發者ID:ShootGame,項目名稱:Arcade2,代碼行數:15,代碼來源:BlockTransformListeners.java

示例8: onBlockChange

import org.bukkit.event.entity.EntityChangeBlockEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.LOWEST)
public void onBlockChange(EntityChangeBlockEvent event) {
    if (physicsFreeze) {
        event.setCancelled(true);
        return;
    }
    Block block = event.getBlock();
    int x = block.getX();
    int z = block.getZ();
    int cx = x >> 4;
    int cz = z >> 4;
    int[] count = getCount(cx, cz);
    if (count[1] >= Settings.IMP.TICK_LIMITER.FALLING) {
        event.setCancelled(true);
        return;
    }
    if (event.getEntityType() == EntityType.FALLING_BLOCK) {
        if (++count[1] >= Settings.IMP.TICK_LIMITER.FALLING) {

            // Only cancel falling blocks when it's lagging
            if (Fawe.get().getTimer().getTPS() < 18) {
                cancelNearby(cx, cz);
                if (rateLimit <= 0) {
                    rateLimit = 20;
                    Fawe.debug("[FAWE `tick-limiter`] Detected and cancelled falling block lag source at " + block.getLocation());
                }
                event.setCancelled(true);
                return;
            } else {
                count[1] = 0;
            }
        }
    }
}
 
開發者ID:boy0001,項目名稱:FastAsyncWorldedit,代碼行數:35,代碼來源:ChunkListener.java

示例9: onEntityFall

import org.bukkit.event.entity.EntityChangeBlockEvent; //導入方法依賴的package包/類
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onEntityFall(EntityChangeBlockEvent event) {
    if (event.getEntityType() != EntityType.FALLING_BLOCK) {
        return;
    }
    Block block = event.getBlock();
    World world = block.getWorld();
    String worldName = world.getName();
    if (!PS.get().hasPlotArea(worldName)) {
        return;
    }
    Location location = BukkitUtil.getLocation(block.getLocation());
    PlotArea area = location.getPlotArea();
    if (area == null) {
        return;
    }
    Plot plot = area.getOwnedPlotAbs(location);
    if (plot == null || plot.getFlag(Flags.DISABLE_PHYSICS, false)) {
        event.setCancelled(true);
        return;
    }
    if (event.getTo().hasGravity()) {
        Entity entity = event.getEntity();
        List<MetadataValue> meta = entity.getMetadata("plot");
        if (meta.isEmpty()) {
            return;
        }
        Plot origin = (Plot) meta.get(0).value();
        if (origin != null && !origin.equals(plot)) {
            event.setCancelled(true);
            entity.remove();
        }
    } else if (event.getTo() == Material.AIR) {
        event.getEntity().setMetadata("plot", new FixedMetadataValue((Plugin) PS.get().IMP, plot));
    }
}
 
開發者ID:IntellectualSites,項目名稱:PlotSquared,代碼行數:37,代碼來源:PlayerEvents.java

示例10: onEntityChangeBlock

import org.bukkit.event.entity.EntityChangeBlockEvent; //導入方法依賴的package包/類
/**
 * Monitor EntityChangeBlock events.
 *
 * @param event The event to watch
 */
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onEntityChangeBlock(EntityChangeBlockEvent event) {
    Block block = event.getBlock();

    // When the event is fired for the falling block that changes back to a normal block
    // event.getBlock().getType() returns AIR
    if (!BlockUtils.shouldBeWatched(block.getState()) && block.getType() != Material.AIR) {
        return;
    }

    Entity entity = event.getEntity();

    if (entity instanceof FallingBlock || entity instanceof Enderman) {
        boolean isTracked = entity.hasMetadata(mcMMO.entityMetadataKey);

        if (mcMMO.getPlaceStore().isTrue(block) && !isTracked) {
            mcMMO.getPlaceStore().setFalse(block);
            entity.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue);
        }
        else if (isTracked) {
            mcMMO.getPlaceStore().setTrue(block);
        }
    }
    else if ((block.getType() == Material.REDSTONE_ORE || block.getType() == Material.GLOWING_REDSTONE_ORE) && (event.getTo() == Material.REDSTONE_ORE || event.getTo() == Material.GLOWING_REDSTONE_ORE)) {
        return;
    }
    else {
        if (mcMMO.getPlaceStore().isTrue(block)) {
            mcMMO.getPlaceStore().setFalse(block);
        }
    }
}
 
開發者ID:Pershonkey,項目名稱:McMMOPlus,代碼行數:38,代碼來源:EntityListener.java

示例11: onEntityChangeBlockEvent

import org.bukkit.event.entity.EntityChangeBlockEvent; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
@EventHandler
public void onEntityChangeBlockEvent(EntityChangeBlockEvent e) {
	EntityType type = e.getEntityType();
	if (type != EntityType.FALLING_BLOCK) {
		return;
	}
	
	Entity entity = e.getEntity();
	if (!fallingAnvils.contains(entity)) {
		return;
	}
	
	Block block = e.getBlock();
	Block under = block.getRelative(BlockFace.DOWN);
	
	fallingAnvils.remove(entity);
	e.setCancelled(true);		
	
	if (!game.canSpleef(under)) {
		entity.remove();
		return;
	}
	
	Material material = under.getType();
	under.setType(Material.AIR);
	World world = under.getWorld();

       Sound anvilLandSound = Game.getSoundEnumType("ANVIL_LAND");
       if (anvilLandSound != null) {
           world.playSound(block.getLocation(), anvilLandSound, 1.0f, 1.0f);
       }
	
	if (game.getPropertyValue(GameProperty.PLAY_BLOCK_BREAK)) {
		world.playEffect(under.getLocation(), Effect.STEP_SOUND, material.getId());
	}
}
 
開發者ID:xaniox,項目名稱:HeavySpleef,代碼行數:38,代碼來源:FlagAnvilSpleef.java

示例12: onTNTPrimed

import org.bukkit.event.entity.EntityChangeBlockEvent; //導入方法依賴的package包/類
/**
 * Trap TNT being primed by flaming arrows
 * @param e
 */
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onTNTPrimed(final EntityChangeBlockEvent e) {
    if (DEBUG) {
        plugin.getLogger().info(e.getEventName());
        plugin.getLogger().info("DEBUG: block = " + e.getBlock().getType());
        plugin.getLogger().info("DEBUG: entity = " + e.getEntityType());
        plugin.getLogger().info("DEBUG: material changing to " + e.getTo());
    }
    if (actionAllowed(e.getEntity().getLocation(), SettingsFlag.FIRE)) {
        return;
    }
    if (e.getBlock() == null) {
        return;
    }
    // Check for TNT
    if (!e.getBlock().getType().equals(Material.TNT)) {
        //plugin.getLogger().info("DEBUG: not tnt");
        return;
    }
    // Check world
    if (!Util.inWorld(e.getBlock())) {
        return;
    }
    // Check if this is on an island
    Island island = plugin.getIslands().getIslandAt(e.getBlock().getLocation());
    if (island == null || island.isSpawn()) {
        return;
    }
    // Stop TNT from being damaged if it is being caused by a visitor with a flaming arrow
    if (e.getEntity() instanceof Projectile) {
        //plugin.getLogger().info("DEBUG: projectile");
        Projectile projectile = (Projectile) e.getEntity();
        // Find out who fired it
        if (projectile.getShooter() instanceof Player) {
            //plugin.getLogger().info("DEBUG: player shot arrow. Fire ticks = " + projectile.getFireTicks());
            if (projectile.getFireTicks() > 0) {
                //plugin.getLogger().info("DEBUG: arrow on fire");
                Player shooter = (Player)projectile.getShooter();
                if (!plugin.getIslands().locationIsAtHome(shooter, true, e.getBlock().getLocation())) {
                    //plugin.getLogger().info("DEBUG: shooter is not at home");
                    // Only say it once a second
                    // Debounce event (it can be called twice for the same action)
                    if (!tntBlocks.contains(e.getBlock().getLocation())) {
                        Util.sendMessage(shooter, plugin.getLocale(shooter.getUniqueId()).get("island.protected"));
                        tntBlocks.add(e.getBlock().getLocation());
                        plugin.getServer().getScheduler().runTaskLater(plugin, () -> tntBlocks.remove(e.getBlock().getLocation()), 20L);
                    }
                    // Remove the arrow
                    projectile.remove();
                    e.setCancelled(true);
                }
            }
        }
    }
}
 
開發者ID:tastybento,項目名稱:bskyblock,代碼行數:60,代碼來源:IslandGuard.java

示例13: onTNTPrimed

import org.bukkit.event.entity.EntityChangeBlockEvent; //導入方法依賴的package包/類
/**
 * Trap TNT being primed by flaming arrows
 * @param e
 */
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onTNTPrimed(final EntityChangeBlockEvent e) {
    if (DEBUG) {
        plugin.getLogger().info(e.getEventName());
        plugin.getLogger().info("DEBUG: block = " + e.getBlock().getType());
        plugin.getLogger().info("DEBUG: entity = " + e.getEntityType());
        plugin.getLogger().info("DEBUG: material changing to " + e.getTo());
    }
    if (actionAllowed(e.getEntity().getLocation(), SettingsFlag.FIRE)) {
        return;
    }
    if (e.getBlock() == null) {
        return;
    }
    // Check for TNT
    if (!e.getBlock().getType().equals(Material.TNT)) {
        //plugin.getLogger().info("DEBUG: not tnt");
        return;
    }
    // Check world
    if (!inWorld(e.getBlock())) {
        return;
    }
    // Check if this is on an island
    Island island = plugin.getGrid().getIslandAt(e.getBlock().getLocation());
    if (island == null || island.isSpawn()) {
        return;
    }
    // Stop TNT from being damaged if it is being caused by a visitor with a flaming arrow
    if (e.getEntity() instanceof Projectile) {
        //plugin.getLogger().info("DEBUG: projectile");
        Projectile projectile = (Projectile) e.getEntity();
        // Find out who fired it
        if (projectile.getShooter() instanceof Player) {
            //plugin.getLogger().info("DEBUG: player shot arrow. Fire ticks = " + projectile.getFireTicks());
            if (projectile.getFireTicks() > 0) {
                //plugin.getLogger().info("DEBUG: arrow on fire");
                Player shooter = (Player)projectile.getShooter();
                if (!plugin.getGrid().locationIsAtHome(shooter, true, e.getBlock().getLocation())) {
                    //plugin.getLogger().info("DEBUG: shooter is not at home");
                    // Only say it once a second
                    // Debounce event (it can be called twice for the same action)
                    if (!tntBlocks.contains(e.getBlock().getLocation())) {
                        Util.sendMessage(shooter, ChatColor.RED + plugin.myLocale(shooter.getUniqueId()).islandProtected);
                        tntBlocks.add(e.getBlock().getLocation());
                        plugin.getServer().getScheduler().runTaskLater(plugin, new Runnable() {

                            @Override
                            public void run() {
                                tntBlocks.remove(e.getBlock().getLocation());
                            }}, 20L);
                    }
                    // Remove the arrow
                    projectile.remove();
                    e.setCancelled(true);
                    return;
                }
            }
        }
    }
}
 
開發者ID:tastybento,項目名稱:acidisland,代碼行數:66,代碼來源:IslandGuard.java

示例14: onEntityChangeBlock

import org.bukkit.event.entity.EntityChangeBlockEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.LOWEST)
public void onEntityChangeBlock(final EntityChangeBlockEvent event) {
    final Block block = event.getBlock();
    final Location location = block.getLocation();
    final Material fromMaterial = block.getType();
    final Entity entity = event.getEntity();
    final EntityType entityType = event.getEntityType();
    final Material toMaterial = event.getTo();

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

    if (!reinforcementManager.isReinforced(location)) {
        if (Material.AIR.equals(fromMaterial) && entity instanceof FallingBlock) {
            reinforcementManager.restoreFallingEntity((FallingBlock) entity);
        }
        return;
    }

    if (entity == null) {
        return;
    }

    if (EntityType.ENDERMAN.equals(entityType)) {
        // If the enderman is placing a block, ignore the event.
        if (fromMaterial.equals(Material.AIR) && !toMaterial.equals(Material.AIR)) {
            return;
        }

        // If the enderman is picking up a block, and is allowed to do so, the reinforcement is removed from the block.
        if (!fromMaterial.equals(Material.AIR) && toMaterial.equals(Material.AIR)) {
            if (mobsInteractWithReinforcedBlocks) {
                Bukkit.getServer().getPluginManager().callEvent(new BlockDeinforceEvent(block, "Environment", true));
            } else {
                event.setCancelled(true);
            }
        }
    }

    // Are sheep able to eat grass, and prevent withers from destroying blocks.
    if (EntityType.SHEEP.equals(entityType) || EntityType.WITHER.equals(entityType) || EntityType.WITHER_SKULL.equals(entityType)) {
        if (mobsInteractWithReinforcedBlocks) {
            Bukkit.getServer().getPluginManager().callEvent(new BlockDeinforceEvent(block, "Environment", true));
        } else {
            event.setCancelled(true);
        }
    }

    // Prevent sand and gravel from falling, if the plugin is configured to do so. Otherwise, their reinforcements are removed.
    if (entity instanceof FallingBlock && (Material.SAND.equals(fromMaterial) || Material.GRAVEL.equals(fromMaterial))) {
        if (allowReinforcedBlockPhysics) {
            reinforcementManager.storeFallingEntity((FallingBlock) entity);
            Bukkit.getServer().getPluginManager().callEvent(new BlockDeinforceEvent(block, "Environment", true));
        } else {
            event.setCancelled(true);
        }
    }
}
 
開發者ID:MinerAp,項目名稱:block-saver,代碼行數:60,代碼來源:GeneralListener.java


注:本文中的org.bukkit.event.entity.EntityChangeBlockEvent.getBlock方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。