Java 类org.bukkit.scoreboard.Team 实例源码

项目:AlphaLibary    文件:GameTeam.java   
public GameTeam removePlayer(Player p, boolean updateTab) {

        TeamLeaveEvent event = new TeamLeaveEvent(p, this);
        Bukkit.getPluginManager().callEvent(event);

        if (event.isCancelled()) return this;

        if (members.contains(p.getName())) {

            if (updateTab) {
                if (p.getScoreboard() != null) {

                    Scoreboard s = p.getScoreboard();

                    if (s.getTeam(this.getTeamName()) != null) {
                        Team team = s.getTeam(this.getRawTeamName());

                        team.removeEntry(p.getName());
                    }
                }
            }

            members.remove(p.getName());
        }
        return this;
    }
项目:BukkitOldCombatMechanics    文件:OCMMain.java   
private void createTeam() {
    String name = "ocmInternal";
    Scoreboard scoreboard = Bukkit.getScoreboardManager().getMainScoreboard();

    Team team = null;

    for (Team t : scoreboard.getTeams()) {
        if (t.getName().equals(name)) {
            team = t;
            break;
        }
    }

    if (team == null)
        team = scoreboard.registerNewTeam(name);

    team.setOption(Team.Option.COLLISION_RULE, Team.OptionStatus.FOR_OWN_TEAM);
    team.setAllowFriendlyFire(true);
}
项目:Warzone    文件:ScoreboardManagerModule.java   
@EventHandler(priority = EventPriority.HIGHEST)
public void onTeamChange(TeamChangeEvent event) {
    for (MatchTeam matchTeam : TGM.get().getModule(TeamManagerModule.class).getTeams()) {
        for (PlayerContext playerContext : matchTeam.getMembers()) {
            SimpleScoreboard simpleScoreboard = getScoreboard(playerContext.getPlayer());

            if (simpleScoreboard == null) {
                simpleScoreboard = initScoreboard(playerContext);
            }

            if (event.getOldTeam() != null) {
                Team old = simpleScoreboard.getScoreboard().getTeam(event.getOldTeam().getId());
                old.removeEntry(event.getPlayerContext().getPlayer().getName());
            }

            Team to = simpleScoreboard.getScoreboard().getTeam(event.getTeam().getId());
            to.addEntry(event.getPlayerContext().getPlayer().getName());
        }
    }
}
项目:Warzone    文件:ScoreboardManagerModule.java   
private SimpleScoreboard initScoreboard(PlayerContext playerContext) {
    SimpleScoreboard simpleScoreboard = new SimpleScoreboard(ChatColor.AQUA + "Objectives");

    for (MatchTeam matchTeam : TGM.get().getModule(TeamManagerModule.class).getTeams()) {
        Team team = simpleScoreboard.getScoreboard().registerNewTeam(matchTeam.getId());
        team.setPrefix(matchTeam.getColor().toString());
        team.setCanSeeFriendlyInvisibles(false); // Fixes anti cheat entity visible when it shouldn't be
        team.setAllowFriendlyFire(false);
        team.setOption(Team.Option.COLLISION_RULE, Team.OptionStatus.NEVER);

        for (PlayerContext player : matchTeam.getMembers()) {
            team.addEntry(player.getPlayer().getName());
        }
    }

    Bukkit.getPluginManager().callEvent(new ScoreboardInitEvent(playerContext.getPlayer(), simpleScoreboard));

    simpleScoreboard.send(playerContext.getPlayer());
    scoreboards.put(playerContext.getPlayer(), simpleScoreboard);

    simpleScoreboard.update();

    return simpleScoreboard;
}
项目:ZentrelaRPG    文件:PlayerDataRPG.java   
@Override
public void setRank(Rank r) {
    rank = r;
    Team t = board.getEntryTeam(name);
    if (t != null)
        t.removeEntry(name);
    Team team = board.getTeam(rank.rankDisplayName);
    if (team == null) {
        team = board.registerNewTeam(rank.rankDisplayName);
        team.setPrefix(rank.nameColor + "");
        team.setAllowFriendlyFire(true);
        team.setOption(Team.Option.COLLISION_RULE, Team.OptionStatus.NEVER);
    }
    team.addEntry(name);
    save();
}
项目:ZentrelaRPG    文件:Party.java   
public void updatePlayer(String name, int hp, Rank rank, boolean inParty) {
    if (board == null)
        return;
    final Score score = board.getObjective("hpdisplay").getScore(name);
    score.setScore(hp);

    if (inParty) {
        final Score score_side = board.getObjective("partyhpside").getScore(name);
        score_side.setScore(hp);
    }

    Team team = board.getTeam(rank.rankDisplayName);
    if (team == null) {
        team = board.registerNewTeam(rank.rankDisplayName);
        team.setPrefix(rank.nameColor + "");
        team.setAllowFriendlyFire(true);
        team.setOption(Team.Option.COLLISION_RULE, Team.OptionStatus.NEVER);
    }
    if (!team.hasEntry(name))
        team.addEntry(name);
}
项目:ProjectAres    文件:TeamRelationParser.java   
@Override
protected Team.OptionStatus parseInternal(Node node, String text) throws FormatException, InvalidXMLException {
    switch(node.getValue()) {
        case "yes":
        case "on":
        case "true":
            return Team.OptionStatus.ALWAYS;

        case "no":
        case "off":
        case "false":
            return Team.OptionStatus.NEVER;

        case "ally":
        case "allies":
            return Team.OptionStatus.FOR_OWN_TEAM;

        case "enemy":
        case "enemies":
            return Team.OptionStatus.FOR_OTHER_TEAMS;

        default:
            throw new InvalidXMLException("Invalid team relationship", node);
    }
}
项目:ProjectAres    文件:ScoreboardMatchModule.java   
protected Team createPartyScoreboardTeam(Party party, Scoreboard scoreboard, boolean forObservers) {
    logger.fine("Creating team for party " + party + " on scoreboard " + toString(scoreboard));

    Team team = scoreboard.registerNewTeam(getScoreboardTeamName(party));
    updatePartyScoreboardTeam(party, team, forObservers);
    for(MatchPlayer player : party.getPlayers()) {
        team.addPlayer(player.getBukkit());
    }

    return team;
}
项目:ProjectAres    文件:Lobby.java   
private void setupScoreboard() {
    Scoreboard scoreboard = Bukkit.getScoreboardManager().getMainScoreboard();
    for(Team team : scoreboard.getTeams()) {
        team.unregister();
    }
    for(Objective objective : scoreboard.getObjectives()) {
        objective.unregister();
    }
}
项目:KingdomFactions    文件:ScoreBoard.java   
@SuppressWarnings("deprecation")
public void refreshPlayer(KingdomFactionsPlayer p) {
    Team team;
    if (getBoard().getTeam(p.getKingdom().getType().toString() + getExtraTeamSuffix(p)) == null) {
        team = getBoard().registerNewTeam(p.getKingdom().getType().toString() + getExtraTeamSuffix(p));
    } else {
        team = getBoard().getTeam(p.getKingdom().getType().toString() + getExtraTeamSuffix(p));
    }
    team.setOption(Team.Option.COLLISION_RULE, Team.OptionStatus.NEVER);

    if (p.isStaff()) {
        team.setPrefix(p.getKingdom().getType().getColor() + "" + ChatColor.BOLD + "");
    } else {
        team.setPrefix(p.getKingdom().getType().getColor() + "");
    }
    team.addPlayer(p.getPlayer());
}
项目:FactionsXL    文件:FTeamWrapper.java   
private void updatePrefix(FScoreboard fboard) {
    if (plugin.getFConfig().getDefaultScoreboardPrefixes()) {
        FPlayer fplayer = fboard.getFPlayer();
        Team team = teams.get(fboard);

        String prefix = plugin.getFConfig().getNametagPrefix();
        prefix = ParsingUtil.replaceRelationPlaceholders(prefix, faction, fplayer);
        prefix = ParsingUtil.replaceFactionPlaceholders(prefix, faction);
        // Avoid client bug
        if (prefix.length() > 16) {
            prefix = prefix.substring(0, 15);
        }

        if (team.getPrefix() == null || !team.getPrefix().equals(prefix)) {
            team.setPrefix(prefix);
        }
    }
}
项目:ProScoreboard    文件:ScoreHelper.java   
private ScoreHelper(Player player, boolean healthName, boolean healthTab) {
    this.player = player;
    scoreboard = Bukkit.getScoreboardManager().getNewScoreboard();
    sidebar = scoreboard.registerNewObjective("sidebar", "dummy");
    sidebar.setDisplaySlot(DisplaySlot.SIDEBAR);
    player.setScoreboard(scoreboard);
    // Create Teams
    for(int i=1; i<=15; i++) {
        Team team = scoreboard.registerNewTeam("SLOT_" + i);
        team.addEntry(genEntry(i));
    }

    if(healthName) {
        Objective hName = scoreboard.registerNewObjective("hname", "health");
        hName.setDisplaySlot(DisplaySlot.BELOW_NAME);
        hName.setDisplayName(ChatColor.RED + "❤");
    }

    if(healthTab) {
        Objective hTab = scoreboard.registerNewObjective("htab", "health");
        hTab.setDisplaySlot(DisplaySlot.PLAYER_LIST);
    }

    players.put(player.getUniqueId(), this);
}
项目:ProScoreboard    文件:ScoreHelper.java   
public void setSlot(int slot, String text) {
    Team team = scoreboard.getTeam("SLOT_" + slot);
    String entry = genEntry(slot);
    if(!scoreboard.getEntries().contains(entry)) {
        sidebar.getScore(entry).setScore(slot);
    }

    text = PlaceholderAPI.setPlaceholders(player, text);
    String pre = getFirstSplit(text);
    String suf = getFirstSplit(ChatColor.getLastColors(pre) + getSecondSplit(text));

    if(!team.getPrefix().equals(pre))
        team.setPrefix(pre);
    if(!team.getSuffix().equals(suf))
        team.setSuffix(suf);
}
项目:AlphaLibary    文件:SimpleScoreboard.java   
@Override
public void deactivate() {
    if (!activated) return;
    activated = false;
    // Set to the main scoreboard
    if (holder.isOnline()) {
        synchronized (this) {
            holder.setScoreboard((Bukkit.getScoreboardManager().getMainScoreboard()));
        }
    }
    // Unregister teams that are created for this scoreboard
    for (Team team : scoreboard.getTeams()) {
        team.unregister();
    }
    // Stop updating
    updateTask.cancel();
}
项目:MT_Core    文件:CustomScoreboards.java   
public CustomScoreboards(MortuusTerraCore main) {
    this.main = main;
    ScoreboardManager manager = Bukkit.getScoreboardManager();

    pkTeamsBoard = manager.getNewScoreboard();

    pkTeamsBoard.registerNewTeam("NEUTRAL");
    pkTeamsBoard.registerNewTeam("ORANGE");
    pkTeamsBoard.registerNewTeam("RED");

    pkTeamsBoard.getTeam("NEUTRAL").setPrefix(PKStates.NEUTRAL.getColor() + "");
    pkTeamsBoard.getTeam("ORANGE").setPrefix(PKStates.ORANGE.getColor() + "");
    pkTeamsBoard.getTeam("RED").setPrefix(PKStates.RED.getColor() + "");

    for (Team team : pkTeamsBoard.getTeams()) {
        team.setOption(Option.NAME_TAG_VISIBILITY, OptionStatus.ALWAYS);
    }
}
项目:Chambers    文件:PlayerScoreboard.java   
PlayerScoreboard(Player player) {
    this.player = player;
    this.scoreboard = Bukkit.getScoreboardManager().getNewScoreboard();
    this.objective = scoreboard.getObjective("SidebarWrapper") == null ? scoreboard.registerNewObjective("SidebarWrapper", "dummy") : scoreboard.getObjective("SidebarWrapper");
    this.objective.setDisplaySlot(DisplaySlot.SIDEBAR);
    this.objective.setDisplayName("");
    if (player.getScoreboard() != scoreboard) {
        player.setScoreboard(scoreboard);
    }
    update();
    this.teams = new HashMap<>();
    this.red = scoreboard.registerNewTeam("Red");
    this.blue = scoreboard.registerNewTeam("Blue");
    this.green = scoreboard.registerNewTeam("Green");
    this.yellow = scoreboard.registerNewTeam("Yellow");
    Arrays.stream(TeamType.values()).filter(teamType -> teamType.isPlayerTeam()).forEach(teamType -> {
        Team team = scoreboard.getTeam(teamType.getName());
        team.setPrefix(teamType.getColor().toString());
        team.setAllowFriendlyFire(false);
        team.setCanSeeFriendlyInvisibles(true);
        this.teams.put(teamType, team);
    });
}
项目:FastSpawn    文件:Teams.java   
@SuppressWarnings("deprecation")
public static void JoinTeam(Player player,String area){

    String worldconfig = plugin.getConfig().getString("area."+area+".world");
    World world = Bukkit.getServer().getWorld(worldconfig);
    String Location = plugin.getConfig().getString("area."+area+".Location");
    String[] location = Location.split(",");
    int x = Integer.parseInt(location[0]);
    int y = Integer.parseInt(location[1]);
    int z = Integer.parseInt(location[2]);

    Location location2 = new Location(world, x, y, z);
    player.teleport(location2);
    player.setGameMode(GameMode.SURVIVAL);

    Team team = board.getTeam(area);
    PlayerInWhereArea.put(player, team);
    team.addPlayer(player);
    player.playSound(player.getLocation(), Sound.CLICK, 2F, 15F);
    player.sendMessage(ChatColor.BLUE + "�A�[�J�F�C��");

}
项目:VanillaPlus    文件:PlayerManager.java   
public void refreshTeam(VPPlayer player){
    Team t2 = Bukkit.getScoreboardManager().getMainScoreboard().getPlayerTeam(player.getPlayer());
    if(t2 != null && !t2.getName().startsWith("_VP_"))
        return;
    if(player.isNick()){
        nick.addPlayer(player.getPlayer());
    }else{
        String name = intFormat.format(1000-player.getGroupLevel());
        Team t = Bukkit.getScoreboardManager().getMainScoreboard().getTeam(name);
        if(t == null)
            t = Bukkit.getScoreboardManager().getMainScoreboard().registerNewTeam(name);
        if(player.getPrefix().length()>16)
            t.setPrefix(player.getPrefix().substring(0, 16));
        else
            t.setPrefix(player.getPrefix());
        if(player.getSuffix().length()>16)
            t.setSuffix(player.getSuffix().substring(0, 16));
        else
            t.setSuffix(player.getSuffix());
        t.addPlayer(player.getPlayer());
    }
}
项目:Mega-Walls    文件:UserScoreboard.java   
public ScoreboardIndexableObject getEntryByValue(String value)
{
    Team team = getTeamByValue(value);

    if (team == null)
    {
        return null;
    }

    for (ScoreboardIndexableObject entry : entries)
    {
        if (team.getName().equals(String.valueOf(entry.getId())))
        {
            return entry;
        }
    }

    return null;
}
项目:Blur    文件:BlurTeam.java   
public void updateTeamFields(@Nonnull Team team, boolean updatePlayers) {
    if (!team.getDisplayName().equals(getName())) {
        team.setDisplayName(getName());
    }
    if (!team.getPrefix().equals(getChatPrefix())) {
        team.setPrefix(getChatPrefix());
    }
    if (!team.getOption(Option.NAME_TAG_VISIBILITY).equals(getNametagVisibility().getBukkit())) {
        team.setOption(Option.NAME_TAG_VISIBILITY, getNametagVisibility().getBukkit());
    }
    if (!team.getOption(Option.DEATH_MESSAGE_VISIBILITY).equals(getDeathMessageVisibility().getBukkit())) {
        team.setOption(Option.DEATH_MESSAGE_VISIBILITY, getDeathMessageVisibility().getBukkit());
    }
    if (!team.getOption(Option.COLLISION_RULE).equals(getCollisionRule().getBukkit())) {
        team.setOption(Option.COLLISION_RULE, getCollisionRule().getBukkit());
    }
    if (updatePlayers) {
        Set<String> oldEntries = players.stream().map(BlurPlayer::getName).collect(Collectors.toSet());
        oldEntries.removeAll(team.getEntries());
        oldEntries.forEach(team::removeEntry);
        for (BlurPlayer blurPlayer : players) {
            team.addEntry(blurPlayer.getName());
        }
    }
}
项目:Parties    文件:PartyHandler.java   
public void tag_removePlayer(Player player, Party party) {
    if (player != null) {
        // ProtocolLib
        if (Variables.tablist_enable && ProtocolHandler.isActive()) {
            ProtocolHandler.handleHF();
            ProtocolHandler.send(player.getUniqueId()); // Player is not present into the party anymore
            if (party != null)
                for (Player pl : party.getOnlinePlayers())
                    ProtocolHandler.send(pl.getUniqueId());
        }
        // Scoreboard
        if (Variables.tag_system || Variables.invisibleallies) {
            Team team = scoreboard.getEntryTeam(player.getName());
            if (team != null && team.getName().startsWith(plugin.getScoreboardPrefix()))
                team.removeEntry(player.getName());
        }
    }
}
项目:Parties    文件:PartyHandler.java   
public void tag_delete(Party party) {
    // ProtocolLib
    if (party != null && Variables.tablist_enable && ProtocolHandler.isActive()) {
        ProtocolHandler.handleHF();
        for (Player pl : party.getOnlinePlayers())
            ProtocolHandler.send(pl.getUniqueId());
    }
    // Scoreboard
    if (Variables.tag_system || Variables.invisibleallies) {
        Team t = scoreboard.getTeam(plugin.getScoreboardPrefix() + party.getName().toLowerCase());
        if (t != null) {
            for (String e : t.getEntries())
                t.removeEntry(e);
            t.unregister();
        }
    }
}
项目:BukkitOldCombatMechanics    文件:OCMTask.java   
public void addPlayerToScoreboard(Player p) {

        String name = p.getName();
        if (p.getScoreboard().getEntryTeam(p.getName()) != null) return;

        World w = p.getWorld();
        List<?> worlds = Config.getWorlds("disable-player-collision");

        if (worlds.isEmpty() || worlds.contains(w.getName())) {
            Team team = Bukkit.getScoreboardManager().getMainScoreboard().getTeam("ocmInternal");
            if (!team.getEntries().contains(name)) {
                team.addEntry(name);
            }
        } else if (!worlds.contains(w.getName())) {
            removePlayerFromScoreboard(p);
        }
    }
项目:GamePlate    文件:ScoreboardModule.java   
@EventHandler
public void onTeamChange(PlayerChangeTeamEvent event) {
    Team team = this.simpleScoreboard.getScoreboard().getTeam(event.getNewTeam().getId());

    if (event.getOldTeam() != null) {
        Team oldTeam = this.simpleScoreboard.getScoreboard().getTeam(event.getOldTeam().getId());
        if (oldTeam != null) {
            oldTeam.removePlayer(event.getPlayer());
        }
    }

    if (team != null) {
       team.addPlayer(event.getPlayer());
    }

    if (event.getNewTeam().getId().equals(this.teamModule.getId())) {
        simpleScoreboard.send(event.getPlayer());
    }
}
项目:Arcade2    文件:MatchGame.java   
@Override
public void onEnable() {
    this.match = new Match(this.getPlugin(), this.getGame(), this.getObservers());
    this.getObservers().setMatch(this.getMatch());

    this.startCountdown = new MatchStartCountdown(this.getPlugin(), this.getMatch());
    this.getStartCountdown().setGame(this.getGame());

    Team bukkit = Observers.createBukkitTeam(this.getGame().getScoreboard().getScoreboard(), this.getObservers());
    this.getObservers().setBukkit(bukkit);

    this.getGame().addVisiblityFilter(new MatchVisibilityFilter(this.getMatch())); // visibility filter
    this.getGame().setMetadata(MatchModule.class, MatchModule.METADATA_MATCH, this.getMatch());

    for (ArcadePlayer player : this.getPlugin().getPlayers()) {
        if (player.getGamePlayer() != null) {
            this.getObservers().join(player.getGamePlayer(), false);
        }
    }
}
项目:CompactNPCLib    文件:NPCPlayer.java   
public void refreshScoreboard() {
    Team team = getScoreboardTeam();

    for (String entry : team.getEntries()) {
        team.removeEntry(entry);
    }
    team.addEntry(getBukkitEntity().getName());

    team.setPrefix(Strings.nullToEmpty(scoreboardPrefix));
    team.setSuffix(Strings.nullToEmpty(scoreboardSuffix));

    if (nameHidden) {
        //          team.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.NEVER);
        team.setNameTagVisibility(NameTagVisibility.NEVER);
    } else {
        //          team.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.ALWAYS);
        team.setNameTagVisibility(NameTagVisibility.ALWAYS);
    }
}
项目:iZenith-PVP    文件:IPlayer.java   
@SuppressWarnings("deprecation")
public void setGhost(boolean ghost) {
    this.ghost = ghost;
    setTeam();
    config.set("ghost", ghost);
    try {
        config.save(file);
    } catch (IOException e) {
        e.printStackTrace();
    }
    if (!ghost) {
        player.removePotionEffect(PotionEffectType.INVISIBILITY);
    } else {
        player.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 9999999, 0));

        player.setHealth(40);

        for (Team team : Vars.teams) {
            if (team.getName().equals("Ghost")) {
                team.addPlayer(player);
            }
        }
    }
}
项目:iZenith-PVP    文件:Util.java   
public static void initScoreboard() {
    try {
        Vars.scoreboard.registerNewTeam("Member").setPrefix(parseColors("&7"));
        Vars.scoreboard.registerNewTeam("Iron").setPrefix(parseColors("&f"));
        Vars.scoreboard.registerNewTeam("Gold").setPrefix(parseColors("&6"));
        Vars.scoreboard.registerNewTeam("Emerald").setPrefix(parseColors("&a"));
        Vars.scoreboard.registerNewTeam("Diamond").setPrefix(parseColors("&b"));
        Vars.scoreboard.registerNewTeam("Admin").setPrefix(parseColors("&c"));
        Vars.scoreboard.registerNewTeam("Owner").setPrefix(parseColors("&4"));
        Team ghost = Vars.scoreboard.registerNewTeam("Ghost");
        ghost.setNameTagVisibility(NameTagVisibility.NEVER);
        ghost.setCanSeeFriendlyInvisibles(false);
    } catch (Exception e) {
    }
    for (Team t : Vars.scoreboard.getTeams()) {
        Vars.teams.add(t);
    }
}
项目:LeagueOfLegends    文件:ScoreBoard.java   
@SuppressWarnings("deprecation")
private ScoreBoard(Player p, ScoreBoardType t) {
    if(chlist.isEmpty()) addChars();
    player = p;
    if(p.getName().equals("luxdev")) p.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 1728000, 300, true, false, Color.BLACK));
    type = t;
    boards.put(p, this);
    board = Bukkit.getScoreboardManager().getNewScoreboard();
    score = board.registerNewObjective("score", "dummy");
    score.setDisplaySlot(DisplaySlot.SIDEBAR);
    score.setDisplayName(replaceString(TITLE[titleindex]));

    int index = 15;
    for(String s : content.get(t)) {
        Team team = board.registerNewTeam("Team:" + index);
        OfflinePlayer op = Bukkit.getOfflinePlayer((String)chlist.get(index - 1));
        team.addPlayer(op);
        lines.put(team, s);
        setContent(team, s);
        score.getScore(op).setScore(index--);
    }
    player.setScoreboard(board);
}
项目:CloudNet    文件:CloudServer.java   
private void addTeamEntry(Player target, Player all, PermissionGroup permissionGroup)
{
    Team team = all.getScoreboard().getTeam(permissionGroup.getTagId() + permissionGroup.getName());
    if (team == null)
        team = all.getScoreboard().registerNewTeam(permissionGroup.getTagId() + permissionGroup.getName());

    team.setPrefix(ChatColor.translateAlternateColorCodes('&', permissionGroup.getPrefix()));
    team.setSuffix(ChatColor.translateAlternateColorCodes('&', permissionGroup.getSuffix()));

    team.addEntry(target.getName());

    target.setDisplayName(ChatColor.translateAlternateColorCodes('&', permissionGroup.getDisplay() + target.getName()));
}
项目:Uranium    文件:CraftScoreboard.java   
public Team registerNewTeam(String name) throws IllegalArgumentException {
    Validate.notNull(name, "Team name cannot be null");
    Validate.isTrue(name.length() <= 16, "Team name '" + name + "' is longer than the limit of 16 characters");
    Validate.isTrue(board.getTeam(name) == null, "Team name '" + name + "' is already in use");

    return new CraftTeam(this, board.createTeam(name));
}
项目:NameTagChanger    文件:NameTagChanger.java   
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;
}
项目:ProjectAres    文件:ParserManifest.java   
@Override
protected void configure() {
    NumberFactory.numberTypes().forEach(type -> bindNumber((Class) type));

    bindPrimitiveParser(Boolean.class).to(BooleanParser.class);
    bindPrimitiveParser(String.class).to(StringParser.class);
    bindPrimitiveParser(Duration.class).to(DurationParser.class);
    bindPrimitiveParser(ImVector.class).to(new TypeLiteral<VectorParser<Double>>(){});
    bindPrimitiveParser(Vector.class).to((TypeLiteral) new TypeLiteral<PrimitiveParser<ImVector>>(){});
    bindPrimitiveParser(Team.OptionStatus.class).to(TeamRelationParser.class);
    bindPrimitiveParser(MessageTemplate.class).to(MessageTemplateParser.class);
    bindPrimitiveParser(Material.class).to(MaterialParser.class);
    bindPrimitiveParser(MaterialData.class).to(MaterialDataParser.class);
    bindPrimitiveParser(Attribute.class).to(AttributeParser.class);

    bind(PercentageParser.class);
    bind(PercentagePropertyFactory.class);

    install(new EnumPropertyManifest<ChatColor>(){});
    install(new EnumPropertyManifest<EntityType>(){});
    install(new EnumPropertyManifest<DyeColor>(){});
    // etc...

    install(new PropertyManifest<>(Boolean.class));
    install(new PropertyManifest<>(String.class));
    install(new PropertyManifest<>(Duration.class, DurationProperty.class));
    install(new PropertyManifest<>(ImVector.class));
    install(new PropertyManifest<>(Vector.class));
    install(new PropertyManifest<>(MessageTemplate.class, MessageTemplateProperty.class));
}
项目:ProjectAres    文件:ScoreboardMatchModule.java   
protected void updatePartyScoreboardTeam(Party party, Team team, boolean forObservers) {
    logger.fine("Updating scoreboard team " + toString(team) + " for party " + party);

    team.setDisplayName(party.getName());
    team.setPrefix(party.getColor().toString());
    team.setSuffix(ChatColor.WHITE.toString());

    team.setCanSeeFriendlyInvisibles(true);
    team.setAllowFriendlyFire(getMatch().getMapInfo().friendlyFire);
    team.setOption(Team.Option.COLLISION_RULE, Team.OptionStatus.NEVER);

    if(!forObservers && party instanceof Competitor) {
        Team.OptionStatus nameTags = ((Competitor) party).getNameTagVisibility();

        // #HACK until this is fixed https://bugs.mojang.com/browse/MC-48730 we need to
        // ensure enemy name tags are always hidden for GS.
        if(getMatch().getMatchModule(GhostSquadronMatchModule.class) != null) {
            switch(nameTags) {
                case ALWAYS: nameTags = Team.OptionStatus.FOR_OWN_TEAM; break;
                case FOR_OTHER_TEAMS: nameTags = Team.OptionStatus.NEVER; break;
            }
        }

        team.setOption(Team.Option.NAME_TAG_VISIBILITY, nameTags);
    } else {
        team.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.ALWAYS);
    }
}
项目:ProjectAres    文件:SidebarMatchModule.java   
private String renderBlitz(Competitor competitor, Party viewingParty) {
    BlitzMatchModule bmm = getMatch().needMatchModule(BlitzMatchModule.class);
    if(competitor instanceof tc.oc.pgm.teams.Team) {
        return ChatColor.WHITE.toString() + bmm.getRemainingPlayers(competitor);
    } else if(competitor instanceof Tribute && bmm.getConfig().getNumLives() > 1) {
        return ChatColor.WHITE.toString() + bmm.lifeManager.getLives(competitor.getPlayers().iterator().next().getPlayerId());
    } else {
        return "";
    }
}
项目:ProjectAres    文件:PlayerAppearanceChanger.java   
/**
 * Release any resources being used to maintain the given player's appearance
 */
public void cleanupAfterPlayer(Player player) {
    if(config.overheadFlair()) {
        // Remove players from their "overhead flair team" on quit
        final Team team = player.getServer().getScoreboardManager().getMainScoreboard().getPlayerTeam(player);
        if(team != null) {
            scheduler.debounceTask(() -> team.removePlayer(player));
        }
    }
}
项目:ProjectAres    文件:PlayerAppearanceChanger.java   
/**
 * Sets a prefix for a player's overhead name by adding them to a scoreboard team.
 * Don't use this if scoreboard teams are being used for any other purpose.
 */
private static void setOverheadNamePrefix(Player player, String prefix) {
    final Scoreboard scoreboard = player.getServer().getScoreboardManager().getMainScoreboard();
    prefix = prefix.substring(0, Math.min(prefix.length(), 14));

    Team team = scoreboard.getTeam(prefix);
    if(team == null) {
        team = scoreboard.registerNewTeam(prefix);
        team.setPrefix(prefix);
        team.setOption(Team.Option.COLLISION_RULE, Team.OptionStatus.NEVER);
    }
    team.addPlayer(player);
}
项目:FactionsXL    文件:FTeamWrapper.java   
private void add(FScoreboard fboard) {
    Scoreboard board = fboard.getScoreboard();
    Team team = board.registerNewTeam(teamName);
    teams.put(fboard, team);

    for (OfflinePlayer player : getPlayers()) {
        team.addEntry(player.getName());
    }

    updatePrefix(fboard);
}
项目:FactionsXL    文件:FTeamWrapper.java   
private void addPlayer(OfflinePlayer player) {
    if (members.add(player)) {
        for (Team team : teams.values()) {
            team.addEntry(player.getName());
        }
    }
}
项目:FactionsXL    文件:FTeamWrapper.java   
private void removePlayer(OfflinePlayer player) {
    if (members.remove(player)) {
        for (Team team : teams.values()) {
            team.removeEntry(player.getName());
        }
    }
}