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


Java Player.canSee方法代码示例

本文整理汇总了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;
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:20,代码来源:FactionClaimForArgument.java

示例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;
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:23,代码来源:CraftServer.java

示例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;
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:27,代码来源:FactionAllyArgument.java

示例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;
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:21,代码来源:FactionShowArgument.java

示例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;
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:19,代码来源:FactionSetDtrArgument.java

示例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;
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:20,代码来源:FactionSetDtrRegenArgument.java

示例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;
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:33,代码来源:TeleportTimer.java

示例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);
}
 
开发者ID:iso2013,项目名称:MultiLineAPI,代码行数:14,代码来源:VisibilityUtil.java

示例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;
}
 
开发者ID:Alvin-LB,项目名称:NameTagChanger,代码行数:40,代码来源:NameTagChanger.java

示例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);
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:35,代码来源:PopperGizmo.java

示例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();
	}
}
 
开发者ID:ThEWiZ76,项目名称:KingdomFactions,代码行数:16,代码来源:FactionCommand.java

示例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;
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:28,代码来源:PlayerFaction.java

示例13: canSee

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public boolean canSee(Player player) {
    return player.canSee(player);
}
 
开发者ID:CyR1en,项目名称:Minecordbot,代码行数:5,代码来源:DiscordPlayerCommandSender.java


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