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


Java Player.getNearbyEntities方法代码示例

本文整理汇总了Java中org.bukkit.entity.Player.getNearbyEntities方法的典型用法代码示例。如果您正苦于以下问题:Java Player.getNearbyEntities方法的具体用法?Java Player.getNearbyEntities怎么用?Java Player.getNearbyEntities使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.entity.Player的用法示例。


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

示例1: PlaceCheckDoor

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler
 public void PlaceCheckDoor(BlockPlaceEvent e) {
     if(ConfigPatch.AntiInfSuagrenable){
if(e.isCancelled()){
	Player p = e.getPlayer();
             List<Entity> entities = p.getNearbyEntities(2, 2, 2);
             for(int i=0;i<entities.size();i++){
                 Entity ent = entities.get(i);
                 if(ent.getType() == EntityType.DROPPED_ITEM){
                     Item item = (Item)ent;
                     if(item.getItemStack().getType() == Material.SUGAR_CANE||item.getItemStack().getType() == Material.CACTUS){
                         ent.remove();
                     }
                 }
             }
}
     }
 }
 
开发者ID:GelandiAssociation,项目名称:EscapeLag,代码行数:19,代码来源:AntiInfSuagr.java

示例2: onInteract

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler
public void onInteract(PlayerBucketEmptyEvent e){
	Player p = e.getPlayer();
	for(Entity en : p.getNearbyEntities (4D, 4D, 4D)){
		if (en instanceof Player){
			if(en == p) continue;
			if(e.getBucket() == Material.LAVA_BUCKET){
				
				if(Files.user.getBoolean("Users." + en.getName() + ".pvp") == false){
						p.sendMessage(Message.prefix + ChatColor.DARK_RED + " No puedes poner ese bloque cerca de un jugador con el pvp desactivado.");
						e.setCancelled(true);
				}
			}
		}
	}
}
 
开发者ID:cadox8,项目名称:WC,代码行数:17,代码来源:PlayerEvent.java

示例3: onCommand

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@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;
}
 
开发者ID:GigaGamma,项目名称:SuperiorCraft,代码行数:22,代码来源:HoverBike.java

示例4: Compass

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler
public void Compass(PlayerInteractEvent event) {
	if (event.getItem() != null && event.getItem().getType() != Material.AIR && event.getItem().getType()==Material.COMPASS) {
		Player p = event.getPlayer();
		for (int i = 0; i < 500; i+=20) {
			List<Entity> entities = p.getNearbyEntities(i, 256, i);
			for (Entity e : entities) {
				if (e instanceof Player) {
					Player found = (Player) e;
					if (Team.getTeam(p)!=Team.getTeam(found)) {
						Chat.player(p, "&aCompass now points towards " + found.getDisplayName() + "&a!");
						p.setCompassTarget(e.getLocation());
						return;
					}
				}
			}
		}
		Chat.player(p, "&cNo enemy players found near you!");
	}
}
 
开发者ID:thekeenant,项目名称:mczone,代码行数:21,代码来源:Events.java

示例5: getNearbyEnemies

import org.bukkit.entity.Player; //导入方法依赖的package包/类
/**
 * 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;
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:33,代码来源:TeleportTimer.java

示例6: BlockPlaceEvent

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler
public void BlockPlaceEvent(BlockPlaceEvent e){
    Player p = e.getPlayer();
    Block b = e.getBlock();

    if (e.getItemInHand().getType() == Material.DROPPER && e.getItemInHand().getEnchantments() != null && e.getItemInHand().getEnchantments().containsKey(Enchantment.ARROW_DAMAGE)) {
        Casino c = new Casino(e.getBlockPlaced().getLocation());
        c.effect();
    }

    for(Entity en : p.getNearbyEntities (4D, 4D, 4D)){
        if (en instanceof Player){
            if(en == p) continue;
            if(b.getType() == Material.FIRE){

                if(Files.user.getBoolean("Users." + en.getName() + ".pvp") == false){
                    p.sendMessage(Utils.colorize(PAData.SURVIVAL.getPrefix() + ChatColor.DARK_RED + " No puedes poner ese bloque cerca de un jugador con el pvp desactivado."));
                    e.setCancelled(true);
                }
            }
        }
    }
}
 
开发者ID:cadox8,项目名称:PA,代码行数:24,代码来源:PlayerEvents.java

示例7: onInteract

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler
public void onInteract(PlayerBucketEmptyEvent e){
    Player p = e.getPlayer();
    for(Entity en : p.getNearbyEntities (4D, 4D, 4D)){
        if (en instanceof Player){
            if(en == p) continue;
            if(e.getBucket() == Material.LAVA_BUCKET){

                if(Files.user.getBoolean("Users." + en.getName() + ".pvp") == false){
                    p.sendMessage(Utils.colorize(PAData.SURVIVAL.getPrefix() + ChatColor.DARK_RED + " No puedes poner ese bloque cerca de un jugador con el pvp desactivado."));
                    e.setCancelled(true);
                }
            }
        }
    }
}
 
开发者ID:cadox8,项目名称:PA,代码行数:17,代码来源:PlayerEvents.java

示例8: handleDetonate

import org.bukkit.entity.Player; //导入方法依赖的package包/类
private void handleDetonate(Player player, Rune rune) {
	player.spawnParticle(Particle.EXPLOSION_HUGE, player.getLocation(), 1);
	player.playSound(player.getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 1F, 1F);
	for(Entity entity : player.getNearbyEntities(3D, 3D, 3D)) {
		if(!(entity instanceof Player)) {
			continue;
		}
		Player target = (Player) entity;
		
		if(Utility.canAttack(player, target)) {
			if(target.getHealth() > 6) {
				target.setHealth(target.getHealth() - 6);
			}
			else {
				target.damage(1000000D, player);
			}
		}
	}
	finish(player, false);
}
 
开发者ID:benNek,项目名称:AsgardAscension,代码行数:21,代码来源:RuneManager.java

示例9: executePlayer

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public void executePlayer(Player p, PlayerDataRPG pd, String[] args) {
    for (Entity e : p.getNearbyEntities(5, 5, 5)) {
        if (e instanceof Item) {
            DropManager.removeLabel((Item) e);
            e.remove();
        }
    }
    p.sendMessage("cleared nearby items");
}
 
开发者ID:edasaki,项目名称:ZentrelaRPG,代码行数:11,代码来源:ClearNearbyCommand.java

示例10: loop

import org.bukkit.entity.Player; //导入方法依赖的package包/类
public void loop() {
	for (Player p : Bukkit.getOnlinePlayers()) {
		for (Entity bl : p.getNearbyEntities(0.24, 2, 0.24)) {
			if (bl.getCustomName() != null && bl.getCustomName().equals(getName())) {
				for (Entity ent : p.getNearbyEntities(0.2, 0.2, 0.2)) {
					if (ent.getCustomName() != null && ent.getCustomName().equals("HoverBike")) {
						for (String tag : ent.getScoreboardTags()) {
							if (tag.startsWith("speed:") && Integer.valueOf(tag.split(":")[1]) > 18) {
								Police.create(p.getLocation().add(-10, 2, -10), p);
								p.sendMessage("&6[Warning] Don't go past stops!".replace('&', '�'));
								p.sendMessage("&9[Police] Pull over!".replace('&', '�'));
								
								for (Entity pli : p.getNearbyEntities(50, 50, 50)) {
									if (pli.getCustomName() != null && pli.getCustomName().equals("Officer")) {
										((PigZombie) pli).setTarget(p);
									}
								}
							}
							else {
								if (!ent.getScoreboardTags().contains("stopcooldown")) {
									((Pig) ent).removePotionEffect(PotionEffectType.SPEED);
									((Pig) ent).addPotionEffect(new PotionEffect(PotionEffectType.SLOW, Integer.MAX_VALUE, 255, true, false));
									((Pig) ent).setVelocity(new Vector(0, 0, 0));
								} else {
									ent.getScoreboardTags().remove("stopcooldown");
								}
							}
						}
					}
				}
			}
		}
	}
}
 
开发者ID:GigaGamma,项目名称:SuperiorCraft,代码行数:35,代码来源:StopBlock.java

示例11: getTargetLiving

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public LivingEntity getTargetLiving() {
	if (livingEntityTarget != null)
		return livingEntityTarget;
	int range = 100;
	Player player = getPlayer();
	BlockIterator iterator = new BlockIterator(player, range);
	List<Entity> entities = player.getNearbyEntities(range, range, range);
	while (iterator.hasNext()) {
		Block block = iterator.next();
		for (Entity entity : entities) {
			if (entity instanceof LivingEntity) {
				int accuracy = 2;
				for (int offX = -accuracy; offX < accuracy; offX++) {
					for (int offY = -accuracy; offY < accuracy; offY++) {
						for (int offZ = -accuracy; offZ < accuracy; offZ++) {
							if (entity.getLocation().getBlock().getRelative(offX, offY, offZ).equals(block)) {
								return livingEntityTarget = (LivingEntity) entity;
							}
						}
					}
				}
			}
		}
	}
	return livingEntityTarget = null;
}
 
开发者ID:mcardy,项目名称:MystiCraft,代码行数:28,代码来源:PlayerCaster.java

示例12: onCompassUse

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@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"));
		}
	}
}
 
开发者ID:thekeenant,项目名称:mczone,代码行数:30,代码来源:GameEvents.java

示例13: getEntityPlayerLookingAt

import org.bukkit.entity.Player; //导入方法依赖的package包/类
/**
 * Performs a raytrace to check which entity the player is probably looking at
 *
 * @param player    Player to check
 * @param range     Max distance to search against
 * @param tolerance How close we want the search to be
 * @return entity player is looking at, or null if we couldn't find one
 */
@Nullable
public static Entity getEntityPlayerLookingAt(Player player, int range, double tolerance) {
    List<Entity> entities = player.getNearbyEntities(range, range, range);

    for (Block block : player.getLineOfSight(null, range)) {
        final Location location = block.getLocation();
        for (Entity entity : entities) {
            // X
            if (!(Math.abs(entity.getLocation().getX() - location.getX()) < tolerance)) {
                continue;
            }

            // Y
            if (!(Math.abs(entity.getLocation().getY() - location.getY()) < tolerance)) {
                continue;
            }

            // Z
            if (!(Math.abs(entity.getLocation().getX() - location.getX()) < tolerance)) {
                continue;
            }

            return entity;
        }
    }

    return null;
}
 
开发者ID:zachbr,项目名称:Debuggery,代码行数:37,代码来源:PlatformUtil.java

示例14: BlockPlaceEvent

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler
public void BlockPlaceEvent(org.bukkit.event.block.BlockPlaceEvent e){
	Player p = e.getPlayer();
	Block b = e.getBlock();
	
	for(Entity en : p.getNearbyEntities (4D, 4D, 4D)){
		
		if (en instanceof Player){
			
			if(en == p) continue;
			
			if(b.getType() == Material.FIRE){
						
				if(Files.user.getBoolean("Users." + en.getName() + ".pvp") == false){
						p.sendMessage(Message.prefix + ChatColor.DARK_RED + " No puedes poner ese bloque cerca de un jugador con el pvp desactivado.");
						e.setCancelled(true);
				}
				
			}
			
		}
		
	}
	
}
 
开发者ID:cadox8,项目名称:WC,代码行数:26,代码来源:PlayerEvent.java


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