Java 类org.bukkit.entity.Entity 实例源码
项目:Crescent
文件:KillauraB.java
/**
* @param check
* The entity to check whether
* @param distance
* The difference in distance to allow for.
* @return
*/
private boolean isInLineOfSight(Entity check, double distance) {
final Location entityLocation = check.getLocation();
final BlockIterator iterator = new BlockIterator(profile.getPlayer().getEyeLocation(), 0.0, 7);
while (iterator.hasNext()) {
final Location current = iterator.next().getLocation();
if (getLocationDifference(current, entityLocation, "X") < distance
&& getLocationDifference(current, entityLocation, "Y") < distance
&& getLocationDifference(current, entityLocation, "Z") < distance) {
return true;
}
}
// The entity has not been found in the player's line of sight.
return false;
}
项目:FactionsXL
文件:EntityProtectionListener.java
@EventHandler
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
Player attacker = getDamageSource(event.getDamager());
Entity eDefender = event.getEntity();
if (!(eDefender instanceof Player)) {
forbidIfInProtectedTerritory(attacker, eDefender, event, ATTACK);
return;
}
Player defender = (Player) eDefender;
Faction aFaction = plugin.getFactionCache().getByMember(attacker);
Faction dFaction = plugin.getFactionCache().getByMember(defender);
Faction rFaction = plugin.getFactionCache().getByLocation(defender.getLocation());
if (aFaction.getRelation(dFaction).isProtected()) {
ParsingUtil.sendMessage(attacker, FMessage.PROTECTION_CANNOT_ATTACK_PLAYER.getMessage(), dFaction);
event.setCancelled(true);
} else if (rFaction != null && rFaction.getRelation(dFaction).isProtected()) {
if (plugin.getFConfig().isTerritoryProtectionEnabled() && (!plugin.getFConfig().isCapitalProtectionEnabled()
|| rFaction.getCapital().equals(plugin.getBoard().getByLocation(eDefender.getLocation())))) {
ParsingUtil.sendMessage(attacker, FMessage.PROTECTION_CANNOT_ATTACK_FACTION.getMessage(), rFaction);
event.setCancelled(true);
} else if (plugin.getFConfig().getTerritoryShield() != 0) {
event.setDamage(event.getDamage() * plugin.getFConfig().getTerritoryShield());
}
}
}
项目:Mob-AI
文件:CommandHandler.java
public static List<Entity> getEntities(Location location, double radius) {
List<Entity> entities = new ArrayList<Entity>();
World world = location.getWorld();
// Find chunck by coordinates
int smallX = MathHelper.floor((location.getX() - radius) / 16.0D);
int bigX = MathHelper.floor((location.getX() + radius) / 16.0D);
int smallZ = MathHelper.floor((location.getZ() - radius) / 16.0D);
int bigZ = MathHelper.floor((location.getZ() + radius) / 16.0D);
for (int x = smallX; x <= bigX; x++)
for (int z = smallZ; z <= bigZ; z++)
if (world.isChunkLoaded(x, z)) entities.addAll(Arrays.asList(world.getChunkAt(x, z).getEntities()));
Iterator<Entity> entityIterator = entities.iterator();
while (entityIterator.hasNext())
if (entityIterator.next().getLocation().distanceSquared(location) > radius * radius) entityIterator.remove();
return entities;
}
项目:HCFCore
文件:TeleportTimer.java
/**
* Gets the amount of enemies nearby a {@link Player}.
*
* @param player
* the {@link Player} to get for
* @param distance
* the radius to get within
* @return the amount of players within enemy distance
*/
public int getNearbyEnemies(Player player, int distance) {
FactionManager factionManager = plugin.getFactionManager();
Faction playerFaction = factionManager.getPlayerFaction(player.getUniqueId());
int count = 0;
Collection<Entity> nearby = player.getNearbyEntities(distance, distance, distance);
for (Entity entity : nearby) {
if (entity instanceof Player) {
Player target = (Player) entity;
// If the nearby player or sender cannot see each-other, continue.
if (!target.canSee(player) || !player.canSee(target)) {
continue;
}
if (playerFaction == null || factionManager.getPlayerFaction(target) != playerFaction) {
count++;
}
}
}
return count;
}
项目:ProjectAres
文件:ProjectileDefinition.java
public ProjectileDefinitionImpl(@Nullable String name,
@Nullable Double damage,
double velocity,
ClickAction clickAction,
Class<? extends Entity> entity,
List<PotionEffect> potion,
Filter destroyFilter,
Duration coolDown,
boolean throwable) {
this.name = name;
this.damage = damage;
this.velocity = velocity;
this.clickAction = clickAction;
this.projectile = entity;
this.potion = potion;
this.destroyFilter = destroyFilter;
this.coolDown = coolDown;
this.throwable = throwable;
}
项目:BlockBall
文件:CustomArmorstand.java
/**
* Passes the ball with the given strength parameters
*
* @param entity entity
* @param horizontalStrength horizontalStrength
* @param verticalStrength verticalStrength
*/
@Override
public void pass(Entity entity, double horizontalStrength, double verticalStrength) {
BallKickEvent event = null;
if (entity instanceof Player) {
event = new BallKickEvent((Player) entity, this);
Bukkit.getPluginManager().callEvent(new BallKickEvent((Player) entity, this));
}
if (event == null || !event.isCancelled()) {
this.startVector = this.slime.getSpigotEntity().getLocation().toVector().subtract(entity.getLocation().toVector()).normalize().multiply(horizontalStrength * 0.8);
this.startVector.setY(verticalStrength * 0.5);
try {
this.slime.getSpigotEntity().setVelocity(this.startVector.clone());
} catch (final IllegalArgumentException ex) {
}
if (this.isRotating)
this.getSpigotEntity().setHeadPose(new EulerAngle(1, this.getSpigotEntity().getHeadPose().getY(), this.getSpigotEntity().getHeadPose().getZ()));
this.rvalue = this.random.nextInt(5) + 9;
this.jumps = this.random.nextInt(5) + 5;
}
}
项目:mczone
文件:Control.java
public static void walkToPlayer(Entity e, Player p) {
// Tamed animals already handle their own following
if (e instanceof Tameable) {
if (((Tameable) e).isTamed()) {
return;
}
}
if (e.getPassenger() instanceof Player) {
return;
}
// Moving the dragon is too buggy
if (e instanceof EnderDragon) {
return;
}
// Once this is set we can't unset it.
//((Creature)e).setTarget(p);
// If the pet is too far just teleport instead of attempt navigation
if (e.getLocation().distance(p.getLocation()) > 20) {
e.teleport(p);
} else {
Navigation n = ((CraftLivingEntity) e).getHandle().getNavigation();
n.a(p.getLocation().getX(), p.getLocation().getY(), p.getLocation().getZ(), 0.30f);
}
}
项目:SuperiorCraft
文件:CustomBlock.java
public void removeBlock(BlockBreakEvent e) {
for (Entity en : e.getBlock().getWorld().getEntities()) {
if (en.getCustomName() != null && en.getCustomName().equals(getName()) && en.getLocation().add(-0.5, 0, -0.5).equals(e.getBlock().getLocation())) {
en.remove();
en.getWorld().getBlockAt(en.getLocation().add(-0.5, 0, -0.5)).setType(Material.AIR);
ItemStack block = new ItemStack(Material.MONSTER_EGG, 1);
ItemMeta bmeta = block.getItemMeta();
bmeta.setDisplayName(name);
block.setItemMeta(bmeta);
if (e.getPlayer() != null && e.getPlayer().getGameMode().equals(GameMode.CREATIVE)) {
e.getPlayer().getInventory().addItem(block);
} else {
e.getBlock().getWorld().dropItemNaturally(en.getLocation().add(-0.5, 0, -0.5), block);
}
}
}
//}
}
项目:ProjectAres
文件:MatchEntityState.java
protected MatchEntityState(Match match, Class<? extends Entity> entityClass, UUID uuid, EntityLocation location, @Nullable String customName) {
this.uuid = checkNotNull(uuid);
this.match = checkNotNull(match);
this.entityClass = checkNotNull(entityClass);
this.location = checkNotNull(location);
this.customName = customName;
EntityType type = null;
for(EntityType t : EntityType.values()) {
if(t.getEntityClass().isAssignableFrom(entityClass)) {
type = t;
break;
}
}
checkArgument(type != null, "Unknown entity class " + entityClass);
this.entityType = type;
}
项目:Uranium
文件:CraftWorld.java
public List<Player> getPlayers() {
List<Player> list = new ArrayList<Player>();
for (Object o : world.loadedEntityList) {
if (o instanceof net.minecraft.entity.Entity) {
net.minecraft.entity.Entity mcEnt = (net.minecraft.entity.Entity) o;
Entity bukkitEntity = mcEnt.getBukkitEntity();
if ((bukkitEntity != null) && (bukkitEntity instanceof Player)) {
list.add((Player) bukkitEntity);
}
}
}
return list;
}
项目:Debuggery
文件:InputFormatter.java
@Nullable
private static Entity getEntity(String input, @Nullable CommandSender sender) throws InputException {
Entity target;
if (sender instanceof Player) {
if (input.equalsIgnoreCase("that")) {
target = PlatformUtil.getEntityPlayerLookingAt((Player) sender, 25, 1.5D);
if (target != null) {
return target;
}
} else if (input.equalsIgnoreCase("me")) {
return ((Player) sender);
}
}
Location loc = getLocation(input, sender);
return PlatformUtil.getEntityNearestTo(loc, 25, 1.5D);
}
项目:helper
文件:Metadata.java
/**
* Gets a {@link MetadataMap} for the given object, if one already exists and has
* been cached in this registry.
*
* A map will only be returned if the object is an instance of
* {@link Player}, {@link UUID}, {@link Entity}, {@link Block} or {@link World}.
*
* @param obj the object
* @return a metadata map
*/
@Nonnull
public static Optional<MetadataMap> get(@Nonnull Object obj) {
Preconditions.checkNotNull(obj, "obj");
if (obj instanceof Player) {
return getForPlayer(((Player) obj));
} else if (obj instanceof UUID) {
return getForPlayer(((UUID) obj));
} else if (obj instanceof Entity) {
return getForEntity(((Entity) obj));
} else if (obj instanceof Block) {
return getForBlock(((Block) obj));
} else if (obj instanceof World) {
return getForWorld(((World) obj));
} else {
throw new IllegalArgumentException("Unknown object type: " + obj.getClass());
}
}
项目:SuperiorCraft
文件:GhostBlock.java
@EventHandler
public void onPlayerMoveEvent(PlayerMoveEvent e) {
for (Entity en : e.getPlayer().getWorld().getEntities()) {
if (en.getCustomName() != null && en.getCustomName().equals(getName()) && en.getLocation().distance(e.getTo()) <= 1) {
Location l = en.getLocation();
//e.getPlayer().sendMessage(getPlayerDirection(e.getPlayer()));
if (getPlayerDirection(e.getPlayer()).equals("north")) {
l.add(-1.2, 0, 0);
}
else if (getPlayerDirection(e.getPlayer()).equals("south")) {
l.add(1.2, 0, 0);
}
else if (getPlayerDirection(e.getPlayer()).equals("east")) {
l.add(0, 0, -1.2);
}
else if (getPlayerDirection(e.getPlayer()).equals("west")) {
l.add(0, 0, 1.2);
}
else {
l = e.getPlayer().getLocation();
}
l.setDirection(e.getPlayer().getLocation().getDirection());
e.setTo(l);
}
}
}
项目:OpenUHC
文件:GoldenFleece.java
/**
* Utilizes a random chance to either spawn a skeleton with gold armor or resources.
*
* @param event The event
*/
@EventHandler
public void onEntityDeath(EntityDeathEvent event) {
Entity entity = event.getEntity();
if (entity instanceof Sheep) {
double chance = Math.random();
if (0.25 > chance) {
Skeleton skeleton = entity.getWorld().spawn(entity.getLocation(), Skeleton.class);
skeleton.getEquipment().setArmorContents(
new ItemStack[]{
new ItemStack(Material.GOLD_HELMET),
new ItemStack(Material.GOLD_CHESTPLATE),
new ItemStack(Material.GOLD_LEGGINGS),
new ItemStack(Material.GOLD_BOOTS)
}
);
} else if (0.5 > chance) {
event.getDrops().add(new ItemStack(Material.IRON_INGOT));
} else if (0.75 > chance) {
event.getDrops().add(new ItemStack(Material.GOLD_INGOT));
} else {
event.getDrops().add(new ItemStack(Material.DIAMOND));
}
}
}
项目:AsgardAscension
文件:RuneManager.java
private void handleSlowdown(Player player, Rune rune) {
new BukkitRunnable() {
int iterations = 0;
public void run() {
if(!player.isOnline() || iterations / 2 >= rune.getDuration()) {
finish(player, true);
this.cancel();
return;
}
for(Entity entity : player.getNearbyEntities(3D, 3D, 3D)) {
if(!(entity instanceof Player)) {
continue;
}
Player target = (Player) entity;
if(Utility.canAttack(player, target)) {
target.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 40, 0));
}
}
iterations++;
}
}.runTaskTimer(plugin, 0L, 10L);
}
项目:ZentrelaRPG
文件:MobData.java
public void knockback(Entity attacker, double knockbackMultiplier) {
return;
// if (dead || noKnockback || entity == null || frozen)
// return;
// if (attributes.contains(MobAttribute.LOWKNOCKBACK)) {
// knockbackMultiplier = 0.25;
// }
// if (System.currentTimeMillis() - lastKnockback > 600) {
// lastKnockback = System.currentTimeMillis();
// Vector newVelocity = entity.getLocation().toVector().subtract(attacker.getLocation().toVector()).normalize().multiply(knockbackMultiplier);
// // cap Y knockback
// if (Math.abs(newVelocity.getY()) > 0.01)
// newVelocity.setY(0.01 * Math.signum(newVelocity.getY()));
// // cap X knockback
// if (Math.abs(newVelocity.getX()) > 1)
// newVelocity.setX(1 * Math.signum(newVelocity.getX()));
// // cap Z knockback
// if (Math.abs(newVelocity.getZ()) > 1)
// newVelocity.setZ(1 * Math.signum(newVelocity.getZ()));
// if (newVelocity.getY() < 0.2)
// newVelocity.setY(0.2);
// if (entity != null && entity.isValid())
// entity.setVelocity(newVelocity);
// }
}
项目:SuperiorCraft
文件:HoverBike.java
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (command.getName().equalsIgnoreCase("hbike")) {
Player player = (Player) sender;
if (args[0].equals("create")) {
create(player.getLocation()).setPassenger(player);
}
else if (args[0].equals("destroy")) {
for (Entity ent : player.getNearbyEntities(0.2, 0.2, 0.2)) {
if (ent.getCustomName() != null && ent.getCustomName().equals("HoverBike")) {
ent.remove();
return true;
}
}
}
return true;
}
return false;
}
项目:ZentrelaRPG
文件:BuffManager.java
public static void handleBuff(Entity player, Entity e) {
if (!(player instanceof Player))
return;
Player p = (Player) player;
PlayerDataRPG pd = plugin.getPD(p);
if (pd != null && buffMap.containsKey(e.getUniqueId())) {
try {
Buff buff = buffMap.remove(e.getUniqueId());
buff.apply(p, pd);
} catch (Exception e2) {
e2.printStackTrace();
}
Location loc = e.getLocation();
RParticles.showWithOffsetPositiveY(ParticleEffect.EXPLOSION_LARGE, loc, 1.0, 10);
e.remove();
}
}
项目:CloudNet
文件:ArmorStandListener.java
@EventHandler
public void handle(ItemDespawnEvent e)
{
MobSelector.MobImpl mob = CollectionWrapper.filter(MobSelector.getInstance().getMobs().values(), new Acceptable<MobSelector.MobImpl>() {
@Override
public boolean isAccepted(MobSelector.MobImpl value)
{
return ((Entity) value.getDisplayMessage()).getPassenger() != null && e.getEntity().getEntityId() == ((Entity) value.getDisplayMessage()).getPassenger().getEntityId();
}
});
if (mob != null)
{
e.setCancelled(true);
}
}
项目:ProjectAres
文件:SequentialPointProvider.java
@Override
public Location getPoint(Match match, @Nullable Entity entity) {
for(PointProvider child : children) {
Location loc = child.getPoint(match, entity);
if(loc != null) return loc;
}
return null;
}
项目:uppercore
文件:EntityNms.java
public static Object getHandle(Entity entity) {
try {
return getHandle.invoke(entity);
} catch (Exception e) {
handleException(e);
return null;
}
}
项目:HCFCore
文件:CombatTimer.java
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
Player attacker = BukkitUtils.getFinalAttacker(event, true);
Entity entity;
if (attacker != null && (entity = event.getEntity()) instanceof Player) {
Player attacked = (Player) entity;
setCooldown(attacker, attacker.getUniqueId(), defaultCooldown, false);
setCooldown(attacked, attacked.getUniqueId(), defaultCooldown, false);
}
}
项目:PetBlocks
文件:PetBlockCommandExecutor.java
private void killNextCommand(Player sender) {
double distance = 100;
Entity nearest = null;
for (final Entity entity : sender.getLocation().getChunk().getEntities()) {
if (!(entity instanceof Player) && sender.getLocation().distance(entity.getLocation()) < distance) {
distance = sender.getLocation().distance(entity.getLocation());
nearest = entity;
}
}
if (nearest != null) {
nearest.remove();
sender.sendMessage(Config.getInstance().getPrefix() + "" + ChatColor.GREEN + "You removed entity " + nearest.getType() + '.');
}
}
项目:PetBlocks
文件:PetBlockListener.java
private PetBlock getPet(Entity entity) {
try {
for (final PetBlock block : this.manager.getPetBlockController().getAll()) {
if (block != null && entity != null && block.getArmorStand() != null && block.getEngineEntity() != null && (block.getArmorStand().equals(entity) || block.getEngineEntity().equals(entity)))
return block;
}
} catch (final Exception ignored) {
}
return null;
}
项目:ProjectAres
文件:GenericDamageResolver.java
@Override
public @Nullable DamageInfo resolveDamage(EntityDamageEvent.DamageCause damageType, Entity victim, @Nullable PhysicalInfo damager) {
if(damager instanceof DamageInfo) {
// If the damager block/entity resolved to a DamageInfo directly, return that
return (DamageInfo) damager;
} else {
return new GenericDamageInfo(damageType, damager);
}
}
项目:CaulCrafting
文件:ItemDropListener.java
Entity[] getNearbyEntities(Location l, int radius){
int chunkRadius = radius < 16 ? 1 : (radius - (radius % 16))/16;
HashSet<Entity> radiusEntities = new HashSet<Entity>();
for (int chX = 0 -chunkRadius; chX <= chunkRadius; chX ++){
for (int chZ = 0 -chunkRadius; chZ <= chunkRadius; chZ++){
int x=(int) l.getX(),y=(int) l.getY(),z=(int) l.getZ();
for (Entity e : new Location(l.getWorld(),x+(chX*16),y,z+(chZ*16)).getChunk().getEntities()){
if (e.getLocation().distance(l) <= radius && e.getLocation().getBlock() != l.getBlock()) radiusEntities.add(e);
}
}
}
return radiusEntities.toArray(new Entity[radiusEntities.size()]);
}
项目:Slimefun4-Chinese-Version
文件:AutoBreeder.java
protected void tick(Block b)
throws Exception
{
for(Iterator iterator = me.mrCookieSlime.Slimefun.holograms.AutoBreeder.getArmorStand(b).getNearbyEntities(4D, 2D, 4D).iterator(); iterator.hasNext();)
{
Entity n = (Entity)iterator.next();
if(Animals.isFeedable(n))
{
int ai[];
int j = (ai = getInputSlots()).length;
for(int i = 0; i < j; i++)
{
int slot = ai[i];
if(SlimefunManager.isItemSimiliar(BlockStorage.getInventory(b).getItemInSlot(slot), SlimefunItems.ORGANIC_FOOD, false))
if(ChargableBlock.getCharge(b) < getEnergyConsumption())
{
return;
} else
{
ChargableBlock.addCharge(b, -getEnergyConsumption());
BlockStorage.getInventory(b).replaceExistingItem(slot, InvUtils.decreaseItem(BlockStorage.getInventory(b).getItemInSlot(slot), 1));
Animals.feed(n);
ParticleEffect.HEART.display(((LivingEntity)n).getEyeLocation(), 0.2F, 0.2F, 0.2F, 0.0F, 8);
return;
}
}
}
}
}
项目:Warzone
文件:SimpleDispenserTracker.java
public @Nullable
OfflinePlayer setOwner(@Nonnull Entity entity, @Nullable Player player) {
Preconditions.checkNotNull(entity, "tnt entity");
if(player != null) {
return this.ownedEntitys.put(entity, player);
} else {
return this.ownedEntitys.remove(entity);
}
}
项目:mczone
文件:GameEvents.java
@EventHandler
public void onCompassUse(PlayerInteractEvent event) {
Player p = event.getPlayer();
if (event.getItem() != null && event.getItem().getType() == Material.COMPASS) {
Boolean found = false;
for (int i = 0; i < 5000; i += 25) {
List<Entity> entities = p.getNearbyEntities(i, 256, i);
for (Entity e : entities) {
if (!(e instanceof Player))
continue;
Player t = (Player) e;
if (Gamer.get(t.getName()).isInvisible())
continue;
p.setCompassTarget(e.getLocation());
Chat.player(p, "&2[SG] &aCompass points to &7" + ((Player) e).getDisplayName() + "&a!");
found = true;
break;
}
if (found)
break;
}
if (!found) {
Chat.player(p, "&cNo players in range. Compass points to spawn location.");
Gamer g = Gamer.get(p.getName());
p.setCompassTarget(g.getLocation("spawn-block"));
}
}
}
项目:ProjectAres
文件:PGMListener.java
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void clearActiveEnderPearls(final PlayerDeathEvent event) {
for(Entity entity : event.getEntity().getWorld().getEntitiesByClass(EnderPearl.class)) {
if(((EnderPearl) entity).getShooter() == event.getEntity()) {
entity.remove();
}
}
}
项目:BlockBall
文件:CustomArmorstand.java
@Override
public boolean isSameEntity(Entity entity) {
if (!this.getSpigotEntity().isDead()) {
if (this.getBukkitEntity().getEntityId() == entity.getEntityId() || this.slime.getSpigotEntity().getEntityId() == entity.getEntityId())
return true;
}
return false;
}
项目:EchoPet
文件:PetEntityListener.java
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) // Highest because we don't want to trust other plugins modifying it.
public void onEntityDamage(EntityDamageEvent event) {
Entity e = event.getEntity();
if (ReflectionUtil.getEntityHandle(e) instanceof IEntityPet) {
IEntityPet entityPet = (IEntityPet) ReflectionUtil.getEntityHandle(e);
PetDamageEvent damageEvent = new PetDamageEvent(entityPet.getPet(), event.getCause(), event.getDamage());
EchoPet.getPlugin().getServer().getPluginManager().callEvent(damageEvent);
event.setDamage(damageEvent.getDamage());
event.setCancelled(damageEvent.isCancelled());
}
}
项目:ZentrelaRPG
文件:ShadowWarp.java
@Override
public boolean cast(final Player p, PlayerDataRPG pd, int level) {
if(!pd.isStealthed()) {
p.sendMessage(ChatColor.RED + "Shadow Warp can only be used while in stealth.");
return false;
}
Vector dir = p.getLocation().getDirection().normalize().multiply(0.3);
Location start = p.getLocation().add(0, p.getEyeHeight() * 0.75, 0).clone();
Location curr = start.clone();
Entity target = null;
for (int k = 0; k < 30; k++) {
for (Entity e : RMath.getNearbyEntities(curr, 1.5)) {
if (e != p) {
if (Spell.canDamage(e, true)) {
target = e;
break;
}
}
}
if(target != null)
break;
curr.add(dir);
if(!RParticles.isAirlike(curr.getBlock()))
break;
}
if (target == null) {
p.sendMessage(ChatColor.RED + "Failed to find a Shadow Warp target.");
return false;
}
Location loc = target.getLocation();
loc = loc.add(0, 0.3, 0);
loc.add(target.getLocation().getDirection().normalize().multiply(-2));
p.teleport(loc);
Spell.notify(p, "You teleport behind your target.");
return true;
}
项目:ArchersBattle
文件:ProjectileListener.java
@EventHandler
public void onHit(final ProjectileHitEvent e) {
if (!Utils.isArenaWorld(e.getEntity().getWorld())) {
return;
}
if (!e.getEntityType().equals(EntityType.ARROW)) {
return;
}
new BukkitRunnable() {
public void run() {
Entity arrow = e.getEntity();
arrow.remove();
}
}.runTaskLater(Main.getInstance(), 100L);
}
项目:ZentrelaRPG
文件:DropManager.java
public static void removeLabel(Item item) {
if (itemLabels.containsKey(item.getUniqueId())) {
Entity e = itemLabels.remove(item.getUniqueId());
if (e != null)
e.remove();
e = null;
}
}
项目:Uranium
文件:CraftTNTPrimed.java
public Entity getSource() {
net.minecraft.entity.EntityLivingBase source = getHandle().getTntPlacedBy();
if (source != null) {
Entity bukkitEntity = source.getBukkitEntity();
if (bukkitEntity.isValid()) {
return bukkitEntity;
}
}
return null;
}
项目:ProjectAres
文件:MasterResolver.java
@Override
public @Nullable PhysicalInfo resolveShooter(ProjectileSource source) {
if(source instanceof Entity) {
return entityTracker.resolveEntity((Entity) source);
} else if(source instanceof BlockProjectileSource) {
return blockTracker.resolveBlock(((BlockProjectileSource) source).getBlock());
}
return null;
}
项目:NavyCraft2-Lite
文件:MoveCraft_EntityListener.java
@EventHandler(priority = EventPriority.HIGH)
public void onEntityExplode(EntityExplodeEvent event)
{
Entity ent = event.getEntity();
if( (ent != null && ent instanceof TNTPrimed) )
{
if( event.getLocation() != null )
{
if( NavyCraft.shotTNTList.containsKey(ent.getUniqueId()) )
{
Craft checkCraft;
checkCraft = structureUpdate(event.getLocation(), NavyCraft.shotTNTList.get(ent.getUniqueId()));
if( checkCraft == null ) {
checkCraft = structureUpdate(event.getLocation().getBlock().getRelative(4,4,4).getLocation(), NavyCraft.shotTNTList.get(ent.getUniqueId()));
if( checkCraft == null ) {
checkCraft = structureUpdate(event.getLocation().getBlock().getRelative(-4,-4,-4).getLocation(), NavyCraft.shotTNTList.get(ent.getUniqueId()));
if( checkCraft == null ) {
checkCraft = structureUpdate(event.getLocation().getBlock().getRelative(2,-2,-2).getLocation(), NavyCraft.shotTNTList.get(ent.getUniqueId()));
if( checkCraft == null ) {
checkCraft = structureUpdate(event.getLocation().getBlock().getRelative(-2,2,2).getLocation(), NavyCraft.shotTNTList.get(ent.getUniqueId()));
}
}
}
}
NavyCraft.shotTNTList.remove(ent.getUniqueId());
}
else
structureUpdate(event.getLocation(), null);
}
}
}
项目:WC
文件:KillAllCMD.java
private List<Entity> worldClassEntities(World w, EntityType entityType){
List<Entity> entities = new ArrayList<>();
w.getEntitiesByClass(entityType.getEntityClass()).forEach(e -> {
if (e.getType() == entityType){
entities.add(e);
}
});
return entities;
}
项目:KingdomFactions
文件:KingdomFactionsPlugin.java
@Override
public void onDisable() {
ShopLogger.getInstance().disable();
for (Entity e : Utils.getInstance().getOverWorld().getEntities()) {
if (e instanceof LivingEntity) {
if (MonsterModule.getInstance().getGuard((LivingEntity) e) != null) {
MonsterModule.getInstance().getGuard((LivingEntity) e).kill();
}
}
}
MySQLModule.getInstance().closeConnection();
}