本文整理匯總了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);
}
}
}
示例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());
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
}
示例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);
}
}
示例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);
}
}
}
示例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;
}
}
}
}
示例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);
}
}
}
示例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);
}
}
}
示例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));
}
}
示例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());
}
}
示例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());
}
}
示例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);
}
}
}
示例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);
}
}
}