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


Java EntityChangeBlockEvent.getEntityType方法代碼示例

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


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

示例1: WitherChangeBlocks

import org.bukkit.event.entity.EntityChangeBlockEvent; //導入方法依賴的package包/類
/**
 * Withers change blocks to air after they are hit (don't know why)
 * This prevents this when the wither has been spawned by a visitor
 * @param e
 */
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void WitherChangeBlocks(EntityChangeBlockEvent e) {
    if (DEBUG) {
        plugin.getLogger().info(e.getEventName());
    }
    // Only cover withers in the island world
    if (e.getEntityType() != EntityType.WITHER || !Util.inWorld(e.getEntity()) ) {
        return;
    }
    if (mobSpawnInfo.containsKey(e.getEntity())) {
        // We know about this wither
        if (DEBUG) {
            plugin.getLogger().info("DEBUG: We know about this wither");
        }
        if (!mobSpawnInfo.get(e.getEntity()).inIslandSpace(e.getEntity().getLocation())) {
            // Cancel the block changes
            if (DEBUG) {
                plugin.getLogger().info("DEBUG: cancelled wither block change");
            }
            e.setCancelled(true);
        }
    }
}
 
開發者ID:tastybento,項目名稱:bskyblock,代碼行數:29,代碼來源:FlyingMobEvents.java

示例2: onFallingThings

import org.bukkit.event.entity.EntityChangeBlockEvent; //導入方法依賴的package包/類
/**
 * Prevent gaming by dropping sand/gravel/gravity blocks
 * 
 * @param event
 */
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onFallingThings(EntityChangeBlockEvent event) {
	Material from = event.getBlock().getType();
	if (!event.getBlock().isEmpty() && !event.getBlock().isLiquid()) {
		if (!from.hasGravity()) return;
		if (!from.isBlock()) return;
		// At this point we've confirmed that the FROM used to be a block, that is now falling.
		debug("Block about to fall from {0}, was a {1}", event.getBlock().getLocation(), from);
	} else {
		// if (event.getBlock().isEmpty() || event.getBlock().isLiquid()) {
		// At this point we've confirmed that the FROM is air or liquid e.g. this is a block
		// that is done falling and wants to be a block again.
		if (EntityType.FALLING_BLOCK != event.getEntityType()) return;
		debug("Block has fallen to {0}, was a {1}", event.getBlock().getLocation(), from);
	}
	// track a break at FROM and TO, so you can't game sand/gravel by dropping it into a chunk.
	plugin.getTracking().trackBreak(event.getBlock().getLocation());
}
 
開發者ID:DevotedMC,項目名稱:HiddenOre,代碼行數:24,代碼來源:ExploitListener.java

示例3: onEntityChangeBLock

import org.bukkit.event.entity.EntityChangeBlockEvent; //導入方法依賴的package包/類
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onEntityChangeBLock(EntityChangeBlockEvent event)
{
	if(!GriefPrevention.instance.config_endermenMoveBlocks && event.getEntityType() == EntityType.ENDERMAN)
	{
		event.setCancelled(true);
	}
	
	else if(!GriefPrevention.instance.config_silverfishBreakBlocks && event.getEntityType() == EntityType.SILVERFISH)
	{
		event.setCancelled(true);
	}
	
	//don't allow the wither to break blocks, when the wither is determined, too expensive to constantly check for claimed blocks
	else if(event.getEntityType() == EntityType.WITHER && GriefPrevention.instance.config_claims_worldModes.get(event.getBlock().getWorld()) != ClaimsMode.Disabled)
	{
		event.setCancelled(true);
	}
}
 
開發者ID:john01dav,項目名稱:GriefPreventionPlus,代碼行數:20,代碼來源:EntityEventHandler.java

示例4: 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

示例5: WitherChangeBlocks

import org.bukkit.event.entity.EntityChangeBlockEvent; //導入方法依賴的package包/類
/**
 * Withers change blocks to air after they are hit (don't know why)
 * This prevents this when the wither has been spawned by a visitor
 * @param e
 */
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void WitherChangeBlocks(EntityChangeBlockEvent e) {
    if (DEBUG) {
        plugin.getLogger().info(e.getEventName());
    }
    // Only cover withers in the island world
    if (e.getEntityType() != EntityType.WITHER || !IslandGuard.inWorld(e.getEntity()) ) {
        return;
    }
    if (mobSpawnInfo.containsKey(e.getEntity())) {
        // We know about this wither
        if (DEBUG) {
            plugin.getLogger().info("DEBUG: We know about this wither");
        }
        if (!mobSpawnInfo.get(e.getEntity()).inIslandSpace(e.getEntity().getLocation())) {
            // Cancel the block changes
            if (DEBUG) {
                plugin.getLogger().info("DEBUG: cancelled wither block change");
            }
            e.setCancelled(true);
        }
    }
}
 
開發者ID:tastybento,項目名稱:acidisland,代碼行數:29,代碼來源:FlyingMobEvents.java

示例6: onEntityChangeBlock

import org.bukkit.event.entity.EntityChangeBlockEvent; //導入方法依賴的package包/類
/**
 * On entity change block.
 *
 * @param event the event
 */
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onEntityChangeBlock(EntityChangeBlockEvent event) {

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

    // Enderman removeblock
    if ((event.getEntityType() == EntityType.ENDERMAN
            && land.getFlagAndInherit(FlagList.ENDERMAN_DAMAGE.getFlagType()).getValueBoolean() == false)
            || (event.getEntityType() == EntityType.WITHER
            && land.getFlagAndInherit(FlagList.WITHER_DAMAGE.getFlagType()).getValueBoolean() == false)) {
        event.setCancelled(true);
    
    // Crop trample
    } else if (matFrom == Material.SOIL
    		&& matTo == Material.DIRT
            && land.getFlagAndInherit(FlagList.CROP_TRAMPLE.getFlagType()).getValueBoolean() == false) {
    	event.setCancelled(true);
    }
}
 
開發者ID:Tabinol,項目名稱:Factoid,代碼行數:27,代碼來源:WorldListener.java

示例7: onAnvilLand

import org.bukkit.event.entity.EntityChangeBlockEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onAnvilLand(EntityChangeBlockEvent event) {
    if (!this.tracker.isEnabled(event.getEntity().getWorld())) return;

    if (event.getEntityType() == EntityType.FALLING_BLOCK && event.getTo() == Material.ANVIL) {
        OfflinePlayer owner = tracker.getOwner((FallingBlock) event.getEntity());
        if(owner != null) {
            tracker.setPlacer(event.getBlock(), tracker.getOwner((FallingBlock) event.getEntity()));
            tracker.setOwner((FallingBlock) event.getEntity(), null);
        }
    }
}
 
開發者ID:WarzoneMC,項目名稱:Warzone,代碼行數:13,代碼來源:AnvilListener.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: onEntityChangeBlockEvent

import org.bukkit.event.entity.EntityChangeBlockEvent; //導入方法依賴的package包/類
@EventHandler
public void onEntityChangeBlockEvent(EntityChangeBlockEvent event) {
	if (event.getEntityType() == EntityType.FALLING_BLOCK) {
		FallingBlock fallingBlock = (FallingBlock) event.getEntity();
		if (fallingBlock.getMaterial() == Material.STAINED_CLAY) {
			event.setCancelled(true);
		}
		if (fallingBlock.getMaterial() == Material.WOOL) {
			event.setCancelled(true);
		}
	}
}
 
開發者ID:Hansdekip,項目名稱:BlockParty-1.8,代碼行數:13,代碼來源:ChangeBlockListener.java

示例10: fragBallFallingBlock

import org.bukkit.event.entity.EntityChangeBlockEvent; //導入方法依賴的package包/類
@EventHandler
public void fragBallFallingBlock(final EntityChangeBlockEvent event) {
    if ((event.getEntityType() == EntityType.FALLING_BLOCK)) {
        if(event.getEntity().hasMetadata("explode")) {
            new BukkitRunnable() {
                @Override
                public void run() {
                    event.getBlock().getWorld().playEffect(event.getBlock().getLocation(), Effect.STEP_SOUND, event.getBlock().getType().getId());
                    event.getBlock().setType(Material.AIR);
                }
            }.runTaskLater(plugin, 1);
        }
    }
}
 
開發者ID:ModernDayPlayer,項目名稱:SurvivalGamesX,代碼行數:15,代碼來源:BlockListener.java

示例11: 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

示例12: onEntityChangeBlock

import org.bukkit.event.entity.EntityChangeBlockEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onEntityChangeBlock(final EntityChangeBlockEvent event)
{
    ActionEntityBlock action;
    if (event.getEntityType() == SHEEP)
    {
        action = this.newAction(SheepEat.class, event.getBlock().getWorld());
    }
    else if (event.getEntity() instanceof Enderman)
    {
        if (event.getTo() == AIR)
        {
            action = this.newAction(EndermanPickup.class, event.getBlock().getWorld());
        }
        else
        {
            action = this.newAction(EndermanPlace.class, event.getBlock().getWorld());
        }
    }
    else
    {
        action = this.newAction(EntityChange.class, event.getBlock().getWorld());
    }
    if (action != null)
    {
        action.setNewBlock(event.getTo());
        this.setAndLog(action, event.getBlock().getState(), event.getEntity());
    }
}
 
開發者ID:CubeEngine,項目名稱:modules-extra,代碼行數:30,代碼來源:ListenerEntityBlock.java

示例13: 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

示例14: onEntityChangeBlock

import org.bukkit.event.entity.EntityChangeBlockEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onEntityChangeBlock(final EntityChangeBlockEvent event) {
    if (event.getEntityType() == EntityType.ENDERMAN) {
        final GeneralRegion region = this.getPlugin().getDb().getPriorByLocation(event.getBlock().getLocation());
        if (region != null && region.getFlag(Flag.ENDERMANGRIEF)) {
            ((Enderman)event.getEntity()).setCarriedMaterial(Material.JACK_O_LANTERN.getNewData((byte)0));
            event.setCancelled(true);
        }
    }
}
 
開發者ID:Ribesg,項目名稱:NPlugins,代碼行數:11,代碼來源:EndermanGriefFlagListener.java

示例15: onEntityChangeBlock

import org.bukkit.event.entity.EntityChangeBlockEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onEntityChangeBlock(final ExtendedEntityChangeBlockEvent ext) {
    final EntityChangeBlockEvent event = (EntityChangeBlockEvent)ext.getBaseEvent();
    if (event.getEntityType() == EntityType.ENDER_DRAGON || event.getEntityType() == EntityType.WITHER) {
        if (ext.getBlockRegion() != null && ext.getBlockRegion().getFlag(Flag.EXPLOSION_BLOCK)) {
            event.setCancelled(true);
        }
    }
}
 
開發者ID:Ribesg,項目名稱:NPlugins,代碼行數:10,代碼來源:ExplosionFlagListener.java


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