本文整理匯總了Java中org.bukkit.event.entity.EntityChangeBlockEvent.getEntity方法的典型用法代碼示例。如果您正苦於以下問題:Java EntityChangeBlockEvent.getEntity方法的具體用法?Java EntityChangeBlockEvent.getEntity怎麽用?Java EntityChangeBlockEvent.getEntity使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.bukkit.event.entity.EntityChangeBlockEvent
的用法示例。
在下文中一共展示了EntityChangeBlockEvent.getEntity方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onEndermanGrief
import org.bukkit.event.entity.EntityChangeBlockEvent; //導入方法依賴的package包/類
/**
* Allows or prevents enderman griefing
*/
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onEndermanGrief(final EntityChangeBlockEvent e) {
if (DEBUG) {
plugin.getLogger().info(e.getEventName());
}
if (!(e.getEntity() instanceof Enderman)) {
return;
}
if (!Util.inWorld(e.getEntity())) {
return;
}
// Prevent Enderman griefing at spawn
if (plugin.getIslands() != null && plugin.getIslands().isAtSpawn(e.getEntity().getLocation())) {
e.setCancelled(true);
}
if (Settings.allowEndermanGriefing)
return;
// Stop the Enderman from griefing
// plugin.getLogger().info("Enderman stopped from griefing);
e.setCancelled(true);
}
示例2: onEntityChangeBlock
import org.bukkit.event.entity.EntityChangeBlockEvent; //導入方法依賴的package包/類
@EventHandler(priority=EventPriority.LOWEST)
public void onEntityChangeBlock(EntityChangeBlockEvent e) {
if (e.getEntity() instanceof FallingBlock) {
if (Variables.blocks.contains(e.getEntity().getUniqueId())) {
e.setCancelled(true);
e.getEntity().remove();
}
}
else if (e.getEntity() instanceof Wither) {
SlimefunItem item = BlockStorage.check(e.getBlock());
if (item != null) {
if (item.getName().equals("WITHER_PROOF_OBSIDIAN")) e.setCancelled(true);
if (item.getName().equals("WITHER_PROOF_GLASS")) e.setCancelled(true);
}
}
}
示例3: onEntityPickup
import org.bukkit.event.entity.EntityChangeBlockEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.LOWEST)
public void onEntityPickup(EntityChangeBlockEvent event)
{
//FEATURE: endermen don't steal claimed blocks
//if its an enderman
if(event.getEntity() instanceof Enderman)
{
//and the block is claimed
if(this.dataStore.getClaimAt(event.getBlock().getLocation(), false, null) != null)
{
//he doesn't get to steal it
event.setCancelled(true);
}
}
}
示例4: 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);
}
}
}
示例5: WitherBlockBreak
import org.bukkit.event.entity.EntityChangeBlockEvent; //導入方法依賴的package包/類
@EventHandler
public void WitherBlockBreak(EntityChangeBlockEvent event) {
RedProtect.get().logger.debug("RPEntityListener - Is EntityChangeBlockEvent");
if (event.isCancelled()) {
return;
}
Entity e = event.getEntity();
if (e instanceof Monster) {
Region r = RedProtect.get().rm.getTopRegion(event.getBlock().getLocation());
if (!cont.canWorldBreak(event.getBlock())){
event.setCancelled(true);
return;
}
if (r != null && !r.canMobLoot()){
event.setCancelled(true);
}
}
}
示例6: 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);
}
}
}
示例7: onEntityChangeBlock
import org.bukkit.event.entity.EntityChangeBlockEvent; //導入方法依賴的package包/類
@EventHandler(priority=EventPriority.LOWEST)
public void onEntityChangeBlock(EntityChangeBlockEvent e) {
if (e.getEntity() instanceof FallingBlock) {
if (Variables.blocks.contains(e.getEntity().getUniqueId())) {
e.setCancelled(true);
e.getEntity().remove();
}
}
else if (e.getEntity() instanceof Wither) {
SlimefunItem item = BlockStorage.check(e.getBlock());
if (item != null) {
if (item.getID().equals("WITHER_PROOF_OBSIDIAN")) e.setCancelled(true);
if (item.getID().equals("WITHER_PROOF_GLASS")) e.setCancelled(true);
}
}
}
示例8: onEndermanGrief
import org.bukkit.event.entity.EntityChangeBlockEvent; //導入方法依賴的package包/類
/**
* Allows or prevents enderman griefing
*/
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onEndermanGrief(final EntityChangeBlockEvent e) {
if (DEBUG) {
plugin.getLogger().info(e.getEventName());
}
if (!(e.getEntity() instanceof Enderman)) {
return;
}
if (!inWorld(e.getEntity())) {
return;
}
// Prevent Enderman griefing at spawn
if (plugin.getGrid() != null && plugin.getGrid().isAtSpawn(e.getEntity().getLocation())) {
e.setCancelled(true);
}
if (Settings.allowEndermanGriefing)
return;
// Stop the Enderman from griefing
// plugin.getLogger().info("Enderman stopped from griefing);
e.setCancelled(true);
}
示例9: 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);
}
}
示例10: onSandCannon
import org.bukkit.event.entity.EntityChangeBlockEvent; //導入方法依賴的package包/類
@EventHandler(ignoreCancelled = true)
public void onSandCannon(EntityChangeBlockEvent event) {
BukkitEntity entity = new BukkitEntity(event.getEntity());
if (manager.isPlotWorld(entity) && event.getEntityType().equals(EntityType.FALLING_BLOCK)) {
if (event.getTo().equals(Material.AIR)) {
entity.setMetadata("plotFallBlock", new FixedMetadataValue(plugin, event.getBlock().getLocation()));
} else {
List<MetadataValue> values = entity.getMetadata("plotFallBlock");
if (!values.isEmpty()) {
org.bukkit.Location spawn = (org.bukkit.Location) (values.get(0).value());
org.bukkit.Location createdNew = event.getBlock().getLocation();
if (spawn.getBlockX() != createdNew.getBlockX() || spawn.getBlockZ() != createdNew.getBlockZ()) {
event.setCancelled(true);
}
}
}
}
}
示例11: onBlockChange
import org.bukkit.event.entity.EntityChangeBlockEvent; //導入方法依賴的package包/類
@EventHandler
public void onBlockChange(EntityChangeBlockEvent e) {
if (e.getEntity() instanceof FallingBlock) {
if (plugin.anvils.containsKey(e.getEntity())) {
for (Entity ent : e.getEntity().getWorld().getEntities()) {
if (ent instanceof LivingEntity) {
LivingEntity len = (LivingEntity) ent;
if (Util.inRegionOf(len.getLocation(), e.getEntity().getLocation(), 3)) {
if (len instanceof Player) {
((Player) len).playSound(e.getEntity().getLocation(), Sound.ANVIL_LAND, 1, 1);
}
len.damage(10.0f);
}
}
}
}
plugin.anvils.remove(e.getEntity());
}
}
示例12: onLand
import org.bukkit.event.entity.EntityChangeBlockEvent; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
@EventHandler
public void onLand(EntityChangeBlockEvent e) {
if(e.getEntity() instanceof FallingBlock) {
FallingBlock fall = (FallingBlock) e.getEntity();
if(fall.hasMetadata("tree")) {
final Location loc = fall.getLocation().add(0,-1,0);
for(Entity entity : fall.getNearbyEntities(10, 180, 10)) {
if(entity instanceof Player) {
Player p = (Player) entity;
p.sendBlockChange(loc, fall.getBlockId(), fall.getBlockData());
p.playEffect(loc.add(0, 1, 0), Effect.STEP_SOUND, Material.LEAVES.getId());
}
}
SlowUpdateBlock slow = new SlowUpdateBlock(loc, 400L, pl);
slow.startUpdate();
e.setCancelled(true);
}
}
}
示例13: onFallingBlockChange
import org.bukkit.event.entity.EntityChangeBlockEvent; //導入方法依賴的package包/類
@EventHandler
public void onFallingBlockChange(EntityChangeBlockEvent event) {
final Entity entity = event.getEntity();
this.playParticles(entity.getLocation());
entity.getNearbyEntities(2, 2, 2).forEach(nearby -> {
if(nearby instanceof Player) {
Player player = (Player) nearby;
if(getAPI().getGameManager().isAlive(player)) {
getAPI().getGameManager().setAlive(player, false);
}
}
});
entity.remove();
event.setCancelled(true);
}
示例14: 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()));
}
示例15: onEntityChangeBlock
import org.bukkit.event.entity.EntityChangeBlockEvent; //導入方法依賴的package包/類
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onEntityChangeBlock(final EntityChangeBlockEvent event) {
final Entity entity = event.getEntity();
if (entity instanceof LivingEntity && !attemptBuild(entity, event.getBlock().getLocation(), null)) {
event.setCancelled(true);
}
}