當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。