本文整理匯總了Java中org.bukkit.event.entity.EntityChangeBlockEvent.getTo方法的典型用法代碼示例。如果您正苦於以下問題:Java EntityChangeBlockEvent.getTo方法的具體用法?Java EntityChangeBlockEvent.getTo怎麽用?Java EntityChangeBlockEvent.getTo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.bukkit.event.entity.EntityChangeBlockEvent
的用法示例。
在下文中一共展示了EntityChangeBlockEvent.getTo方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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) {
// Crop trample
IDummyLand land = Factoid.getThisPlugin().iLands().getLandOrOutsideArea(
event.getBlock().getLocation());
Material matFrom = event.getBlock().getType();
Material matTo = event.getTo();
Player player;
if(event.getEntity() instanceof Player
&& playerConf.get(player = (Player) event.getEntity()) != null // Citizens bugfix
&& ((land instanceof ILand && ((ILand) land).isBanned(player))
|| (matFrom == Material.SOIL
&& matTo == Material.DIRT
&& !checkPermission(land, player,
PermissionList.CROP_TRAMPLE.getPermissionType())))) {
event.setCancelled(true);
}
}
示例2: 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);
}
}
示例3: 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);
}
}
}
示例4: onEntityChangeBlock
import org.bukkit.event.entity.EntityChangeBlockEvent; //導入方法依賴的package包/類
@EventWrapper
public void onEntityChangeBlock(final EntityChangeBlockEvent event) {
// Igniting TNT with an arrow is already handled from the ExplosionPrimeEvent
if(event.getEntity() instanceof Arrow &&
event.getBlock().getType() == Material.TNT &&
event.getTo() == Material.AIR) return;
callEvent(event, event.getBlock().getState(), BlockStateUtils.cloneWithMaterial(event.getBlock(), event.getToData()), entityResolver.getOwner(event.getEntity()));
}
示例5: onLavaAbsorption
import org.bukkit.event.entity.EntityChangeBlockEvent; //導入方法依賴的package包/類
@EventHandler
public void onLavaAbsorption(EntityChangeBlockEvent event) {
if (!plugin.isSkyWorld(event.getBlock().getWorld())) {
return;
}
if (isLavaSource(event.getBlock().getType(), event.getBlock().getData())) {
if (event.getTo() != Material.LAVA && event.getTo() != Material.STATIONARY_LAVA) {
event.setCancelled(true);
ItemStack item = new ItemStack(event.getTo(), 1, event.getData());
Location above = event.getBlock().getLocation().add(0, 1, 0);
event.getBlock().getWorld().dropItemNaturally(above, item);
}
}
}
示例6: 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));
}
}
示例7: 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);
}
}
}
示例8: 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());
}
}
示例9: 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);
}
}
}