org.bukkit.scoreboard.Scoreboard#getTeam ( )源码实例Demo

下面列出了org.bukkit.scoreboard.Scoreboard#getTeam ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: GlobalWarming   文件: GScoreboard.java
/**
 * Disconnect the player from the scoreboard
 * - Removes the player from their team (i.e., player-color)
 * - Removes their score from the scoreboard
 * - The scoreboard will still be displayed on the player's client
 * until a new scoreboard is assigned or the user exits
 */
public void disconnect(GPlayer gPlayer) {
    if (!isEnabled) {
        return;
    }
    UUID associatedWorldId = gPlayer.getAssociatedWorldId();
    Scoreboard scoreboard = getScoreboard(associatedWorldId, false);
    if (scoreboard != null) {
        //Remove the team (i.e., player-color)
        OfflinePlayer player = Bukkit.getOfflinePlayer(gPlayer.getUuid());
        Team team = scoreboard.getTeam(player.getName());
        if (team != null) {
            team.removeEntry(player.getName());
            team.unregister();
        }

        //Remove the player's score:
        scoreboard.resetScores(player.getName());

        //Delete unused scoreboards:
        if (scoreboard.getEntries().size() == 0) {
            scoreboards.remove(associatedWorldId);
        }
    }
}
 
源代码2 项目: askyblock   文件: IslandGuard1_9.java
public IslandGuard1_9(final ASkyBlock plugin) {
    this.plugin = plugin;
    this.thrownPotions = new HashMap<>();
    if (!Settings.allowPushing) {
        // try to remove the team from the scoreboard
        try {
            ScoreboardManager manager = plugin.getServer().getScoreboardManager();
            if (manager != null) {
                Scoreboard scoreboard = manager.getMainScoreboard();
                if (scoreboard != null) {
                    Team pTeam = scoreboard.getTeam(NO_PUSH_TEAM_NAME);
                    if (pTeam != null) {
                        pTeam.unregister();
                    }
                }
            }
        } catch (Exception e) {
            plugin.getLogger().warning("Problem removing no push from scoreboard.");
        }
    }
}
 
源代码3 项目: Assemble   文件: AssembleBoardEntry.java
public void setup() {
	final Scoreboard scoreboard = this.board.getScoreboard();

	if (scoreboard == null) {
		return;
	}

	String teamName = this.identifier;

	// This shouldn't happen, but just in case
	if (teamName.length() > 16) {
		teamName = teamName.substring(0, 16);
	}

	Team team = scoreboard.getTeam(teamName);

	// Register the team if it does not exist
	if (team == null) {
		team = scoreboard.registerNewTeam(teamName);
	}

	// Add the entry to the team
	if (team.getEntries() == null || team.getEntries().isEmpty() || !team.getEntries().contains(this.identifier)) {
		team.addEntry(this.identifier);
	}

	// Add the entry if it does not exist
	if (!this.board.getEntries().contains(this)) {
		this.board.getEntries().add(this);
	}

	this.team = team;
}
 
源代码4 项目: TabooLib   文件: TagUtils.java
public static Team getTeamComputeIfAbsent(Scoreboard scoreboard, String teamName) {
    Team team = scoreboard.getTeam(teamName);
    if (team == null) {
        scoreboard.registerNewTeam(teamName);
    }
    return scoreboard.getTeam(teamName);
}
 
源代码5 项目: 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);
}
 
源代码6 项目: QualityArmory   文件: QAMain.java
public static Scoreboard registerGlowTeams(Scoreboard sb) {
	if (sb.getTeam("QA_RED") == null) {
		for (ChatColor c : ChatColor.values()) {
			if (sb.getTeam("QA_" + c.name() + "") == null)
				sb.registerNewTeam("QA_" + c.name() + "").setPrefix(c + "");
		}
	}
	return sb;
}
 
源代码7 项目: FunnyGuilds   文件: IndividualPrefix.java
protected void addPlayer(String player) {
    if (player == null) {
        return;
    }
    
    User user = User.get(player);
    if (!user.hasGuild()) {
        return;
    }
    
    Scoreboard scoreboard = getScoreboard();
    Team team = scoreboard.getEntryTeam(player);
    
    if (team != null) {
        team.removeEntry(player);
    }
    
    team = scoreboard.getTeam(user.getGuild().getTag());
    if (team == null) {
        addGuild(user.getGuild());
        team = scoreboard.getTeam(user.getGuild().getTag());
    }
    
    if (this.getUser().hasGuild()) {
        if (this.getUser().equals(user) || this.getUser().getGuild().getMembers().contains(user)) {
            team.setPrefix(replace(FunnyGuilds.getInstance().getPluginConfiguration().prefixOur, "{TAG}", user.getGuild().getTag()));
        }
    }
    
    team.addEntry(player);
}
 
源代码8 项目: KTP   文件: UHTeam.java
public UHTeam(String name, String displayName, ChatColor color, UHPlugin plugin) {
	this.name = name;
	this.displayName = displayName;
	this.color = color;
	this.plugin = plugin;
	
	Scoreboard sb = this.plugin.getScoreboard();
	sb.registerNewTeam(this.name);

	Team t = sb.getTeam(this.name);
	t.setDisplayName(this.displayName);
	t.setCanSeeFriendlyInvisibles(true);
	t.setPrefix(this.color+"");
}
 
源代码9 项目: NovaGuilds   文件: TagUtils.java
/**
 * Refreshes tag of a player
 *
 * @param p target player
 */
@SuppressWarnings("deprecation")
public static void refresh(Player p) {
	if(!Config.TAGAPI_ENABLED.getBoolean()) {
		return;
	}

	Scoreboard board = p.getScoreboard();
	for(Player player : CompatibilityUtils.getOnlinePlayers()) {
		NovaPlayer nPlayerLoop = PlayerManager.getPlayer(player);

		String tName = "ng_" + player.getName();
		if(tName.length() > 16) {
			tName = tName.substring(0, 16);
		}

		Team team = board.getTeam(tName);

		if(team == null) {
			team = board.registerNewTeam(tName);
			team.addPlayer(player);
		}

		//Points
		Objective pointsObjective = board.getObjective("points");
		if(Config.POINTSBELOWNAME.getBoolean()) {
			if(pointsObjective == null) {
				pointsObjective = board.registerNewObjective("points", "dummy");
				pointsObjective.setDisplaySlot(DisplaySlot.BELOW_NAME);
				pointsObjective.setDisplayName(Message.MISC_POINTSBELOWNAME.get());
			}

			Score score = pointsObjective.getScore(player);
			score.setScore(nPlayerLoop.getPoints());
		}
		else if(pointsObjective != null) {
			pointsObjective.unregister();
		}

		//set tag
		PreparedTag tag = new PreparedTagScoreboardImpl(PlayerManager.getPlayer(player));
		tag.setTagColorFor(PlayerManager.getPlayer(p));
		team.setPrefix(tag.get());
	}
}