当前位置: 首页>>代码示例>>Java>>正文


Java EntityTargetLivingEntityEvent类代码示例

本文整理汇总了Java中org.bukkit.event.entity.EntityTargetLivingEntityEvent的典型用法代码示例。如果您正苦于以下问题:Java EntityTargetLivingEntityEvent类的具体用法?Java EntityTargetLivingEntityEvent怎么用?Java EntityTargetLivingEntityEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


EntityTargetLivingEntityEvent类属于org.bukkit.event.entity包,在下文中一共展示了EntityTargetLivingEntityEvent类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onTarget

import org.bukkit.event.entity.EntityTargetLivingEntityEvent; //导入依赖的package包/类
@EventHandler
public void onTarget(EntityTargetLivingEntityEvent event) {
    if (!(event.getEntity() instanceof Tameable) || !(event.getEntity() instanceof LivingEntity)
            || event.getTarget() == null || !InventoryManager.isAllowedWorld(event.getTarget().getWorld())) {
        return;
    }

    LivingEntity petEntity = (LivingEntity) event.getEntity();
    final OfflinePlayer player = (OfflinePlayer) ((Tameable) petEntity).getOwner();

    if (!InventoryManager.playerIsLoaded(player)) {
        return;
    }

    PlayerWrapper playerWrapper = InventoryManager.get(player);
    if (playerWrapper.hasPet() && petEntity == playerWrapper.getPet()) {
        PetType petType = PetManager.getPetFromEntity(petEntity, player);

        if (petType == null) {
            return;
        }

        if (event.getTarget() != null && event.getTarget().getType() == EntityType.PLAYER) {
            event.setCancelled(!petType.isAttackPlayers());
        } else {
            event.setCancelled(!petType.isAttackMobs());
        }
    }
}
 
开发者ID:EndlessCodeGroup,项目名称:RPGInventory,代码行数:30,代码来源:PetListener.java

示例2: onTargetWhenPlayerNotLoaded

import org.bukkit.event.entity.EntityTargetLivingEntityEvent; //导入依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOW)
public void onTargetWhenPlayerNotLoaded(EntityTargetLivingEntityEvent event) {
    if (event.getTarget() == null || event.getTarget().getType() != EntityType.PLAYER) {
        return;
    }

    if (!InventoryManager.playerIsLoaded((Player) event.getTarget())) {
        event.setCancelled(true);
    }
}
 
开发者ID:EndlessCodeGroup,项目名称:RPGInventory,代码行数:11,代码来源:PlayerListener.java

示例3: onTargeting

import org.bukkit.event.entity.EntityTargetLivingEntityEvent; //导入依赖的package包/类
@EventHandler
public void onTargeting(EntityTargetLivingEntityEvent e) {
    if (!witherEnabled || e == null || e.isCancelled() || !plugin.isSkyAssociatedWorld(e.getEntity().getWorld())) {
        return;
    }
    if (e.getEntity() instanceof Wither && e.getTarget() != null) {
        handleWitherRampage(e, (Wither) e.getEntity(), e.getTarget().getLocation());
    }
}
 
开发者ID:rlf,项目名称:uSkyBlock,代码行数:10,代码来源:GriefEvents.java

示例4: onTarget

import org.bukkit.event.entity.EntityTargetLivingEntityEvent; //导入依赖的package包/类
@EventHandler
public void onTarget(EntityTargetLivingEntityEvent event)
{
    if (event.getTarget() instanceof Player && event.getEntity().hasMetadata("Creator") && event.getEntity().getMetadata("Creator").get(0).asString() == ((Player) event.getTarget()).getName())
    {
        event.setCancelled(true);
    }
}
 
开发者ID:ColonelHedgehog,项目名称:Equestrian-Dash,代码行数:9,代码来源:EntityTargetLivingEntityListener.java

示例5: onEntityTargetLivingEntity

import org.bukkit.event.entity.EntityTargetLivingEntityEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onEntityTargetLivingEntity(EntityTargetLivingEntityEvent event) {
    LivingEntity livingEntity = event.getTarget();

    if (livingEntity instanceof Player) {
        Player player = (Player) livingEntity;

        if (Ghosts.p.getGhostManager().isGhost(player)) {
            event.setCancelled(true);
        }
    }
}
 
开发者ID:TfT-02,项目名称:Ghosts,代码行数:13,代码来源:EntityListener.java

示例6: getZombieTarget

import org.bukkit.event.entity.EntityTargetLivingEntityEvent; //导入依赖的package包/类
@EventHandler
public void getZombieTarget(EntityTargetLivingEntityEvent e) {
	if(e.getEntity() instanceof Zombie) {
		if(e.getTarget() instanceof Player) {
			if(e.getEntity().getLocation().distance(e.getTarget().getLocation()) > pl.getConfiguration().getEntityConfig().getCustomZombieAggroRange()) {
				e.setCancelled(true);
			}
		}
	}
}
 
开发者ID:xEssentials,项目名称:xEssentials-deprecated-bukkit,代码行数:11,代码来源:CustomZombieAggroRangeEvent.java

示例7: onTarget

import org.bukkit.event.entity.EntityTargetLivingEntityEvent; //导入依赖的package包/类
@EventHandler
public void onTarget(EntityTargetLivingEntityEvent e) {
	if(e.getTarget() instanceof Player) {
		Player p = (Player) e.getTarget();
		if(pl.getManagers().getPlayerManager().isOnline(p.getName())) {
			XPlayer xp = pl.getManagers().getPlayerManager().getPlayer(p.getName());
			if(xp.isInChair()) {
				e.setCancelled(true);
			}
		}
	}
}
 
开发者ID:xEssentials,项目名称:xEssentials-deprecated-bukkit,代码行数:13,代码来源:ChairDisableMonsterEvent.java

示例8: isGodModeAfk

import org.bukkit.event.entity.EntityTargetLivingEntityEvent; //导入依赖的package包/类
@EventHandler
public void isGodModeAfk(EntityTargetLivingEntityEvent e) {
	if(e.getTarget() instanceof Player) {
		Player p = (Player) e.getTarget();
		if(pl.getConfiguration().getPlayerConfig().isGodModeInAfkEnabled()) {
			XPlayer xp = pl.getManagers().getPlayerManager().getPlayer(p.getName());
			if(xp.isAfk()) {
				e.setCancelled(true);
			}
		}
	}
}
 
开发者ID:xEssentials,项目名称:xEssentials-deprecated-bukkit,代码行数:13,代码来源:AfkCheckEvent.java

示例9: onTarget

import org.bukkit.event.entity.EntityTargetLivingEntityEvent; //导入依赖的package包/类
@EventHandler
public void onTarget(EntityTargetLivingEntityEvent e) {
	if(e.getTarget() instanceof Player) {
		Player p = (Player) e.getTarget();
		if(pl.getManagers().getPlayerManager().isOnline(p.getName())) {
			XPlayer xp = pl.getManagers().getPlayerManager().getPlayer(p.getName());
			if(xp.isVanished()) {
				e.setCancelled(true);
			}
		}
	}
}
 
开发者ID:xEssentials,项目名称:xEssentials-deprecated-bukkit,代码行数:13,代码来源:VanishEvent.java

示例10: ignoremob

import org.bukkit.event.entity.EntityTargetLivingEntityEvent; //导入依赖的package包/类
@EventHandler
public void ignoremob(EntityTargetLivingEntityEvent e) {
	if(e.getTarget() instanceof Player) {
		Player p = (Player) e.getTarget();
		if(vanishApi.isVanished(p)) {
			e.setCancelled(true);
		}
	}
}
 
开发者ID:xize,项目名称:xEssentials_old_Source,代码行数:10,代码来源:vanishEntity.java

示例11: getZombieTarget

import org.bukkit.event.entity.EntityTargetLivingEntityEvent; //导入依赖的package包/类
@EventHandler
public void getZombieTarget(EntityTargetLivingEntityEvent e) {
	if(e.getEntity() instanceof Zombie) {
		if(e.getTarget() instanceof Player) {
			if(e.getEntity().getLocation().distance(e.getTarget().getLocation()) > xEssentialsMemory.zombieRange) {
				e.setCancelled(true);
			}
		}
	}
}
 
开发者ID:xize,项目名称:xEssentials_old_Source,代码行数:11,代码来源:zombieTarget.java

示例12: GodModeAfk

import org.bukkit.event.entity.EntityTargetLivingEntityEvent; //导入依赖的package包/类
@EventHandler
public void GodModeAfk(EntityTargetLivingEntityEvent e) {
	if(xEssentialsMemory.playerGodmodeAfk) {
		if(e.getTarget() instanceof Player) {
			Player p = (Player) e.getTarget();
			if(afkList.contains(p.getName())) {
				e.setCancelled(true);
			}
		}
	}
}
 
开发者ID:xize,项目名称:xEssentials_old_Source,代码行数:12,代码来源:afkCheck.java

示例13: m

import org.bukkit.event.entity.EntityTargetLivingEntityEvent; //导入依赖的package包/类
public void m() {
    super.m();
    EntityHuman prevTarget = this.targetPlayer;// CraftBukkit - store old target
    if (this.c > 0) {
        --this.c;
    }

    this.lastX = this.locX;
    this.lastY = this.locY;
    this.lastZ = this.locZ;
    this.motY -= 0.029999999329447746D;
    if (this.world.getType(new BlockPosition(this)).getMaterial() == Material.LAVA) {
        this.motY = 0.20000000298023224D;
        this.motX = (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.2F);
        this.motZ = (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.2F);
        this.a(SoundEffects.bA, 0.4F, 2.0F + this.random.nextFloat() * 0.4F);
    }

    this.j(this.locX, (this.getBoundingBox().b + this.getBoundingBox().e) / 2.0D, this.locZ);
    double d0 = 8.0D;

    if (this.targetTime < this.a - 20 + this.getId() % 100) {
        if (this.targetPlayer == null || this.targetPlayer.h(this) > d0 * d0) {
            this.targetPlayer = this.world.findNearbyPlayer(this, d0);
        }

        this.targetTime = this.a;
    }

    if (this.targetPlayer != null && this.targetPlayer.isSpectator()) {
        this.targetPlayer = null;
    }

    if (this.targetPlayer != null) {
        // CraftBukkit start
        boolean cancelled = false;
        if (this.targetPlayer != prevTarget) {
            EntityTargetLivingEntityEvent event = CraftEventFactory.callEntityTargetLivingEvent(this, targetPlayer, EntityTargetEvent.TargetReason.CLOSEST_PLAYER);
            EntityLiving target = event.getTarget() == null ? null : ((org.bukkit.craftbukkit.entity.CraftLivingEntity) event.getTarget()).getHandle();
            targetPlayer = target instanceof EntityHuman ? (EntityHuman) target : null;
            cancelled = event.isCancelled();
        }

        if (!cancelled && targetPlayer != null) {
        double d1 = (this.targetPlayer.locX - this.locX) / d0;
        double d2 = (this.targetPlayer.locY + (double) this.targetPlayer.getHeadHeight() / 2.0D - this.locY) / d0;
        double d3 = (this.targetPlayer.locZ - this.locZ) / d0;
        double d4 = Math.sqrt(d1 * d1 + d2 * d2 + d3 * d3);
        double d5 = 1.0D - d4;

        if (d5 > 0.0D) {
            d5 *= d5;
            this.motX += d1 / d4 * d5 * 0.1D;
            this.motY += d2 / d4 * d5 * 0.1D;
            this.motZ += d3 / d4 * d5 * 0.1D;
        }
        }
        // CraftBukkit end
    }

    this.move(this.motX, this.motY, this.motZ);
    float f = 0.98F;

    if (this.onGround) {
        f = this.world.getType(new BlockPosition(MathHelper.floor(this.locX), MathHelper.floor(this.getBoundingBox().b) - 1, MathHelper.floor(this.locZ))).getBlock().frictionFactor * 0.98F;
    }

    this.motX *= (double) f;
    this.motY *= 0.9800000190734863D;
    this.motZ *= (double) f;
    if (this.onGround) {
        this.motY *= -0.8999999761581421D;
    }

    ++this.a;
    ++this.b;
    if (this.b >= 6000) {
        this.die();
    }

}
 
开发者ID:bergerkiller,项目名称:SpigotSource,代码行数:82,代码来源:EntityExperienceOrb.java

示例14: onEntityTarget

import org.bukkit.event.entity.EntityTargetLivingEntityEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onEntityTarget(final EntityTargetLivingEntityEvent event) {
    if (event.getTarget().getType() == EntityType.PLAYER && this.loggedOutPlayers.containsKey(event.getTarget().getUniqueId())) {
        event.setCancelled(true);
    }
}
 
开发者ID:Ribesg,项目名称:NPlugins,代码行数:7,代码来源:LoggedOutUserHandler.java


注:本文中的org.bukkit.event.entity.EntityTargetLivingEntityEvent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。