本文整理汇总了Java中org.bukkit.entity.Player.canSee方法的典型用法代码示例。如果您正苦于以下问题:Java Player.canSee方法的具体用法?Java Player.canSee怎么用?Java Player.canSee使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.entity.Player
的用法示例。
在下文中一共展示了Player.canSee方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onTabComplete
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args)
{
if ((args.length != 2) || (!(sender instanceof Player)))
{
return Collections.emptyList();
}
if (args[1].isEmpty()) {
return null;
}
Player player = (Player)sender;
List<String> results = new ArrayList(this.plugin.getFactionManager().getFactionNameMap().keySet());
for (Player target : Bukkit.getOnlinePlayers()) {
if ((player.canSee(target)) && (!results.contains(target.getName()))) {
results.add(target.getName());
}
}
return results;
}
示例2: tabCompleteChat
import org.bukkit.entity.Player; //导入方法依赖的package包/类
public List<String> tabCompleteChat(Player player, String message) {
List<String> completions = new ArrayList<String>();
PlayerChatTabCompleteEvent event = new PlayerChatTabCompleteEvent(player, message, completions);
String token = event.getLastToken();
for (Player p : getOnlinePlayers()) {
if (player.canSee(p) && StringUtil.startsWithIgnoreCase(p.getName(), token)) {
completions.add(p.getName());
}
}
pluginManager.callEvent(event);
Iterator<?> it = completions.iterator();
while (it.hasNext()) {
Object current = it.next();
if (!(current instanceof String)) {
// Sanity
it.remove();
}
}
Collections.sort(completions, String.CASE_INSENSITIVE_ORDER);
return completions;
}
示例3: onTabComplete
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
if (args.length != 2 || !(sender instanceof Player)) {
return Collections.emptyList();
}
Player player = (Player) sender;
PlayerFaction playerFaction = plugin.getFactionManager().getPlayerFaction(player);
if (playerFaction == null) {
return Collections.emptyList();
}
List<String> results = new ArrayList<>();
for (Player target : Bukkit.getOnlinePlayers()) {
if (!target.equals(player) && player.canSee(target) && !results.contains(target.getName())) {
Faction targetFaction = plugin.getFactionManager().getPlayerFaction(target);
if (targetFaction != null && playerFaction != targetFaction) {
if (playerFaction.getRequestedRelations().get(targetFaction.getUniqueID()) != RELATION && playerFaction.getRelations().get(targetFaction.getUniqueID()) != RELATION) {
results.add(targetFaction.getName());
}
}
}
}
return results;
}
示例4: onTabComplete
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
if (args.length != 2 || !(sender instanceof Player)) {
return Collections.emptyList();
}
if (args[1].isEmpty()) {
return null;
}
Player player = (Player) sender;
List<String> results = new ArrayList<>(plugin.getFactionManager().getFactionNameMap().keySet());
for (Player target : Bukkit.getOnlinePlayers()) {
if (player.canSee(target) && !results.contains(target.getName())) {
results.add(target.getName());
}
}
return results;
}
示例5: onTabComplete
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
if (args.length != 2 || !(sender instanceof Player)) {
return Collections.emptyList();
} else if (args[1].isEmpty()) {
return null;
} else {
Player player = (Player) sender;
List<String> results = new ArrayList<>(plugin.getFactionManager().getFactionNameMap().keySet());
for (Player target : Bukkit.getOnlinePlayers()) {
if (player.canSee(target) && !results.contains(target.getName())) {
results.add(target.getName());
}
}
return results;
}
}
示例6: onTabComplete
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
if (args.length != 2) {
return Collections.emptyList();
} else if (args[1].isEmpty()) {
return null;
} else {
List<String> results = new ArrayList<>(plugin.getFactionManager().getFactionNameMap().keySet());
Player senderPlayer = sender instanceof Player ? ((Player) sender) : null;
for (Player player : Bukkit.getOnlinePlayers()) {
// Make sure the player can see.
if (senderPlayer == null || senderPlayer.canSee(player)) {
results.add(player.getName());
}
}
return results;
}
}
示例7: 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;
}
示例8: isViewable
import org.bukkit.entity.Player; //导入方法依赖的package包/类
public static boolean isViewable(Player viewer, Entity target, boolean bypassGameMode) {
if (target instanceof Player) {
if (vanishNoPacket) {
if (manager.isVanished((Player) target)) return false;
}
if (!viewer.canSee((Player) target)) return false;
if (((Player) target).getGameMode() == GameMode.SPECTATOR) return false;
}
if (target instanceof LivingEntity) {
if (((LivingEntity) target).hasPotionEffect(PotionEffectType.INVISIBILITY)) return false;
}
return !(viewer.getGameMode() == GameMode.SPECTATOR && !bypassGameMode);
}
示例9: updatePlayer
import org.bukkit.entity.Player; //导入方法依赖的package包/类
private void updatePlayer(Player player, String oldName) {
Validate.isTrue(enabled, "NameTagChanger is disabled");
GameProfileWrapper newProfile = gameProfiles.get(player.getUniqueId());
if (newProfile == null) {
newProfile = packetHandler.getDefaultPlayerProfile(player);
}
List<Team> scoreboardTeamsToUpdate = Lists.newArrayList();
sendingPackets = true;
for (Player otherPlayer : Bukkit.getOnlinePlayers()) {
if (otherPlayer.equals(player)) {
if (otherPlayer.getScoreboard().getEntryTeam(player.getName()) != null) {
scoreboardTeamsToUpdate.add(otherPlayer.getScoreboard().getEntryTeam(player.getName()));
}
continue;
}
if (otherPlayer.canSee(player)) {
packetHandler.sendTabListRemovePacket(player, otherPlayer);
packetHandler.sendTabListAddPacket(player, newProfile, otherPlayer);
if (otherPlayer.getWorld().equals(player.getWorld())) {
packetHandler.sendEntityDestroyPacket(player, otherPlayer);
packetHandler.sendNamedEntitySpawnPacket(player, otherPlayer);
}
}
// The player we want to rename is in a scoreboard team.
if (otherPlayer.getScoreboard().getEntryTeam(player.getName()) != null) {
scoreboardTeamsToUpdate.add(otherPlayer.getScoreboard().getEntryTeam(player.getName()));
}
}
if (oldName != null) {
String newName = newProfile.getName();
for (Team team : scoreboardTeamsToUpdate) {
Bukkit.getOnlinePlayers().stream().filter(p -> p.getScoreboard() == team.getScoreboard()).forEach(p -> {
packetHandler.sendScoreboardRemovePacket(oldName, p, team.getName());
packetHandler.sendScoreboardAddPacket(newName, p, team.getName());
});
}
}
sendingPackets = false;
}
示例10: entityDamage
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler
public void entityDamage(final EntityDamageEvent event) {
if(!(event instanceof EntityDamageByEntityEvent)) return;
EntityDamageByEntityEvent realEvent = (EntityDamageByEntityEvent) event;
if(!(realEvent.getDamager() instanceof Player) || !(realEvent.getEntity() instanceof Player)) return;
final Player damager = (Player) realEvent.getDamager();
final Player victim = (Player) realEvent.getEntity();
if(victim.hasPermission(GizmoConfig.EXEMPT_PERMISSION)) return;
if(!(Gizmos.gizmoMap.get(damager) instanceof PopperGizmo)) return;
if(damager.getItemInHand().getType() != this.getIcon()) return;
if(!damager.canSee(victim)) return;
damager.hidePlayer(victim);
damager.playSound(damager.getLocation(), Sound.BLOCK_LAVA_POP, 1f, 2f);
Integer count = poppedCount.get(damager);
if(count == null) count = 0;
count++;
poppedCount.put(damager, count);
if(count % 10 == 0) {
RaindropUtil.giveRaindrops(
Users.playerId(damager), 1, null,
new TranslatableComponent("gizmo.popper.raindropsResult", new Component(String.valueOf(count), net.md_5.bungee.api.ChatColor.GOLD))
);
}
event.setCancelled(true);
}
示例11: getPlayer
import org.bukkit.entity.Player; //导入方法依赖的package包/类
private String getPlayer(CommandSender sender, FactionMember player) {
if (player.isOnline()) {
if (sender instanceof Player) {
Player p = (Player) sender;
if (p.canSee(player.toBukkitPlayer())) {
return ChatColor.GREEN + player.getName();
} else {
return ChatColor.RED + player.getName();
}
}
return ChatColor.GREEN + player.getName();
} else {
return ChatColor.RED + player.getName();
}
}
示例12: getOnlineMembers
import org.bukkit.entity.Player; //导入方法依赖的package包/类
/**
* Gets the online members in this {@link Faction} that are visible to a {@link CommandSender}.
* <p>
* The key is the {@link UUID} of the member
* </p>
* <p>
* The value is the {@link FactionMember}
* </p>
*
* @param sender
* the {@link CommandSender} to get for
* @return a set of online members visible to sender
*/
public Map<UUID, FactionMember> getOnlineMembers(CommandSender sender) {
Player senderPlayer = sender instanceof Player ? ((Player) sender) : null;
Map<UUID, FactionMember> results = new HashMap<>();
for (Map.Entry<UUID, FactionMember> entry : members.entrySet()) {
Player target = Bukkit.getPlayer(entry.getKey());
if (target == null || (senderPlayer != null && !senderPlayer.canSee(target))) {
continue;
}
results.put(entry.getKey(), entry.getValue());
}
return results;
}
示例13: canSee
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public boolean canSee(Player player) {
return player.canSee(player);
}