org.bukkit.scoreboard.Team Java Examples

The following examples show how to use org.bukkit.scoreboard.Team. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GScoreboard.java    From GlobalWarming with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Connect the player to the scoreboard
 * - Disconnects from any existing scoreboards
 * - Creates a new scoreboard for the world if required
 */
public void connect(GPlayer gPlayer) {
    if (gPlayer != null && isEnabled) {
        //Disconnect the player from the current scoreboard (if required):
        disconnect(gPlayer);

        //Connect online players to their associated-world scoreboards:
        Player onlinePlayer = gPlayer.getOnlinePlayer();
        if (onlinePlayer != null) {
            Scoreboard scoreboard = getScoreboard(gPlayer);
            onlinePlayer.setScoreboard(scoreboard);
            Team team = scoreboard.registerNewTeam(onlinePlayer.getName());
            team.addEntry(onlinePlayer.getName());
            update(gPlayer);
        }
    }
}
 
Example #2
Source File: ScoreboardModule.java    From CardinalPGM with MIT License 6 votes vote down vote up
public void renderObjective(GameObjective objective) {
    if (!objective.showOnScoreboard()) return;
    int score = currentScore;
    Team team = scoreboard.getTeam(objective.getScoreboardHandler().getNumber() + "-o");
    String prefix = objective.getScoreboardHandler().getPrefix(this.team);
    team.setPrefix(prefix);
    if (team.getEntries().size() > 0) {
        setScore(this.objective, new ArrayList<>(team.getEntries()).get(0), score);
    } else {
        String raw = (objective instanceof HillObjective ? "" : ChatColor.RESET) + " " + WordUtils.capitalizeFully(objective.getName().replaceAll("_", " "));
        while (used.contains(raw)) {
            raw =  raw + ChatColor.RESET;
        }
        team.addEntry(raw);
        setScore(this.objective, raw, score);
        used.add(raw);
    }
    currentScore++;
}
 
Example #3
Source File: SimpleScoreboard.java    From ScoreboardLib with GNU Lesser General Public License v3.0 6 votes vote down vote up
@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 : teamCache.rowKeySet()) {
        team.unregister();
    }
    // Stop updating
    updateTask.cancel();
}
 
Example #4
Source File: TeamRelationParser.java    From ProjectAres with GNU Affero General Public License v3.0 6 votes vote down vote up
@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);
    }
}
 
Example #5
Source File: ScoreboardModule.java    From CardinalPGM with MIT License 6 votes vote down vote up
public void renderTeamTitle(TeamModule teamModule) {
    Team team = scoreboard.getTeam(teamModule.getId() + "-t");
    team.setPrefix(teamModule.getColor() + Strings.trimTo(teamModule.getName(), 0, 14));
    team.setSuffix(Strings.trimTo(teamModule.getName(), 14, 30));
    if (team.getEntries().size() > 0) {
        setScore(objective, new ArrayList<>(team.getEntries()).get(0), currentScore);
    } else {
        String name = teamModule.getColor() + "";
        while (used.contains(name)) {
            name = teamModule.getColor() + name;
        }
        team.addEntry(name);
        setScore(objective, name, currentScore);
        used.add(name);
    }
    currentScore++;
}
 
Example #6
Source File: SentinelSBTeams.java    From Sentinel with MIT License 6 votes vote down vote up
@Override
public boolean isTarget(LivingEntity ent, String prefix, String value) {
    try {
        if (prefix.equals("sbteam") && ent instanceof Player) {
            Team t = Bukkit.getScoreboardManager().getMainScoreboard().getTeam(value);
            if (t != null) {
                if (t.hasEntry(((Player) ent).getName())) {
                    return true;
                }
            }
        }
    }
    catch (Exception ex) {
        ex.printStackTrace();
    }
    return false;
}
 
Example #7
Source File: TeamAddCommand.java    From UHC with MIT License 6 votes vote down vote up
@Override
protected boolean runCommand(CommandSender sender, OptionSet options) {
    final Team team = teamSpec.value(options);
    final Set<OfflinePlayer> players = Sets.newHashSet(playersSpec.values(options));
    players.removeAll(team.getPlayers());

    for (final OfflinePlayer player : players) {
        team.addPlayer(player);
    }

    final Set<OfflinePlayer> finalTeam = team.getPlayers();

    final String members = finalTeam.size() == 0
            ? ChatColor.DARK_GRAY + "No members"
            : Joiner.on(", ").join(Iterables.transform(team.getPlayers(), FunctionalUtil.PLAYER_NAME_FETCHER));

    sender.sendMessage(messages.evalTemplate(
            "added",
            ImmutableMap.of(
                    "count", players.size(),
                    "players", members
            )
    ));
    return false;
}
 
Example #8
Source File: TagDataHandler.java    From TabooLib with MIT License 6 votes vote down vote up
private void updateTeamVariable(Scoreboard scoreboard, TagPlayerData playerData) {
    Team entryTeam = TagUtils.getTeamComputeIfAbsent(scoreboard, playerData.getTeamHash());
    if (!entryTeam.getEntries().contains(playerData.getNameDisplay())) {
        entryTeam.addEntry(playerData.getNameDisplay());
    }
    if (entryTeam.getPrefix() == null || !entryTeam.getPrefix().equals(playerData.getPrefix())) {
        entryTeam.setPrefix(playerData.getPrefix());
    }
    if (entryTeam.getSuffix() == null || !entryTeam.getSuffix().equals(playerData.getSuffix())) {
        entryTeam.setSuffix(playerData.getSuffix());
    }
    Team.OptionStatus option = entryTeam.getOption(Team.Option.NAME_TAG_VISIBILITY);
    if (option == Team.OptionStatus.ALWAYS && !playerData.isNameVisibility()) {
        entryTeam.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.NEVER);
    } else if (option == Team.OptionStatus.NEVER && playerData.isNameVisibility()) {
        entryTeam.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.ALWAYS);
    }
    if (TabooLib.getConfig().getBoolean("TABLIST-AUTO-CLEAN-TEAM", true)) {
        TagUtils.cleanEmptyTeamInScoreboard(scoreboard);
    }
}
 
Example #9
Source File: TeamRemoveCommand.java    From UHC with MIT License 6 votes vote down vote up
@Override
protected boolean runCommand(CommandSender sender, OptionSet options) {
    int count = 0;

    for (final OfflinePlayer player : playersSpec.values(options)) {
        final Team team = scoreboard.getPlayerTeam(player);

        if (team == null) {
            continue;
        }

        count++;

        team.removePlayer(player);
    }

    sender.sendMessage(messages.evalTemplate("removed", ImmutableMap.of("count", count)));
    return true;
}
 
Example #10
Source File: GScoreboard.java    From GlobalWarming with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Display a player's score
 * - Uses the player's associated-world scoreboard
 * - Note: the player may be in a different world, that's ok
 * - Player names are mapped to color warmth (based on their score)
 */
private void updatePlayerScore(GPlayer gPlayer) {
    if (gPlayer != null) {
        //Do not update associated-worlds with disabled climate-engines:
        // - Ignore offline players (e.g., someone completing an offline player's bounty)
        Player onlinePlayer = gPlayer.getOnlinePlayer();
        if (onlinePlayer != null && ClimateEngine.getInstance().isClimateEngineEnabled(gPlayer.getAssociatedWorldId())) {
            //Update the player's score:
            Scoreboard scoreboard = getScoreboard(gPlayer);
            if (scoreboard != null) {
                Objective objective = scoreboard.getObjective(GLOBAL_WARMING);
                if (objective != null) {
                    Team team = scoreboard.getPlayerTeam(onlinePlayer);
                    if (team != null) {
                        team.setColor(Colorizer.getScoreColor(gPlayer.getCarbonScore()));
                        objective.getScore(onlinePlayer).setScore(gPlayer.getCarbonScore());
                    }
                }
            }
        }
    }
}
 
Example #11
Source File: GScoreboard.java    From GlobalWarming with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * 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);
        }
    }
}
 
Example #12
Source File: ClearTeamsCommand.java    From UHC with MIT License 6 votes vote down vote up
@Override
protected boolean runCommand(CommandSender sender, OptionSet options) {
    Collection<Team> teams = teamSpec.values(options);

    if (teams.size() == 0) {
        teams = options.has(allSpec) ? module.getScoreboard().getTeams() : module.getTeams().values();
    }

    int count = 0;
    for (final Team team : teams) {
        for (final OfflinePlayer player : team.getPlayers()) {
            team.removePlayer(player);
            count++;
        }
    }

    sender.sendMessage(messages.evalTemplate("cleared", ImmutableMap.of("teams", teams.size(), "players", count)));
    return true;
}
 
Example #13
Source File: CraftTeam.java    From Kettle with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void setOption(Option option, OptionStatus status) throws IllegalStateException {
    checkState();

    switch (option) {
        case NAME_TAG_VISIBILITY:
            team.setNameTagVisibility(EnumVisible.values()[status.ordinal()]);
            break;
        case DEATH_MESSAGE_VISIBILITY:
            team.setDeathMessageVisibility(EnumVisible.values()[status.ordinal()]);
            break;
        case COLLISION_RULE:
            team.setCollisionRule(net.minecraft.scoreboard.Team.CollisionRule.values()[status.ordinal()]);
            break;
        default:
            throw new IllegalArgumentException("Unrecognised option " + option);
    }
}
 
Example #14
Source File: QAMain.java    From QualityArmory with GNU General Public License v3.0 6 votes vote down vote up
/**
 * GUNLIST:
 * <p>
 * 2: P30 3 PKP 4 MP5K 5 AK47 6: AK 7 M16 8 Remmington 9 FNFal 10 RPG 11 UMP 12
 * SW1911 13 M40 14 Ammo 556 15 9mm 16 buckshot 17 rocketRPG 18 Enfield 19 Henry
 * 20 MouserC96
 * <p>
 * 22 Grenades
 */

@Override
public void onDisable() {
	for (Entry<MaterialStorage, CustomBaseObject> misc : miscRegister.entrySet()) {
		if (misc instanceof ThrowableItems) {
			for (Entry<Entity, ThrowableHolder> e : ThrowableItems.throwItems.entrySet()) {
				if (e.getKey() instanceof Item)
					e.getKey().remove();
			}
		}
	}

	for (Scoreboard s : coloredGunScoreboard)
		for (Team t : s.getTeams())
			t.unregister();

	for (Gunner g : gunners) {
		g.dispose();
	}
}
 
Example #15
Source File: TeamManager.java    From skRayFall with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Create a empty team.
 *
 * @param teamName The reference name of the team.
 */
public void createTeam(String teamName) {
    if (!teamMap.containsKey(teamName)) {
        Team team = teamBoard.registerNewTeam(teamName);
        teamMap.put(teamName, team);
        for (Object p : Bukkit.getServer().getOnlinePlayers().toArray()) {
            Player tempPlayer = (Player) p;
            if (!(tempPlayer.getScoreboard().getTeams().contains(teamMap.get(teamName)))) {
                // Debug
                Bukkit.broadcastMessage("Team Reg!");
                tempPlayer.getScoreboard().registerNewTeam(teamName);
            }
        }

    }
}
 
Example #16
Source File: Scoreboards.java    From askyblock with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Puts a player into a team of their own and sets the team suffix to be the level
 * @param playerUUID - the player's UUID
 */
public void setLevel(UUID playerUUID) {
    Player player = plugin.getServer().getPlayer(playerUUID);
    if (player == null) {
        // Player is offline...
        return;
    }
    // The default team name is their own name
    String teamName = player.getName();
    String level = String.valueOf(plugin.getPlayers().getIslandLevel(playerUUID));
    Team team = board.getTeam(teamName);
    if (team == null) {
        //Team does not exist
        team = board.registerNewTeam(teamName);
    }
    // Add the suffix
    team.setSuffix(Settings.teamSuffix.replace("[level]",String.valueOf(level)));
    //Adding player to team
    team.addPlayer(player);
    // Assign scoreboard to player
    player.setScoreboard(board);
}
 
Example #17
Source File: Scoreboards.java    From askyblock with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Sets the player's level explicitly
 * @param playerUUID - the player's UUID
 * @param l
 */
public void setLevel(UUID playerUUID, long l) {
    Player player = plugin.getServer().getPlayer(playerUUID);
    if (player == null) {
        // Player is offline...
        return;
    }
    // The default team name is their own name - must be 16 chars or less
    String teamName = player.getName();
    Team team = board.getTeam(teamName);
    if (team == null) {
        //Team does not exist
        team = board.registerNewTeam(teamName);
    }
    // Add the suffix
    team.setSuffix(Settings.teamSuffix.replace("[level]",String.valueOf(l)));
    //Adding player to team
    team.addPlayer(player);
    // Assign scoreboard to player
    player.setScoreboard(board);
}
 
Example #18
Source File: IslandGuard1_9.java    From askyblock with GNU General Public License v2.0 6 votes vote down vote up
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.");
        }
    }
}
 
Example #19
Source File: IslandGuard1_9.java    From askyblock with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Handles cleaning push protection on player quit
 * @param player
 */
private void removePush(Player player)
{
    try {
        scoreboard = player.getScoreboard();
        if(scoreboard !=null)
        {
            //Player Remove
            Team pTeam = scoreboard.getTeam(NO_PUSH_TEAM_NAME);
            if (pTeam != null) {
                pTeam.removeEntry(player.getName());
            }
        }
    } catch (Exception e) {
        plugin.getLogger().severe("Error trying to remove player from push scoreboard");
        plugin.getLogger().severe(player.getName() + " : " + e.getMessage());
        e.printStackTrace();
    }
}
 
Example #20
Source File: ScoreboardMatchModule.java    From PGM with GNU Affero General Public License v3.0 6 votes vote down vote up
protected void updatePartyScoreboardTeam(Party party, Team team, boolean forObservers) {
  match.getLogger().fine("Updating scoreboard team " + toString(team) + " for party " + party);

  team.setDisplayName(TextTranslations.translateLegacy(party.getName(), null));
  team.setPrefix(party.getColor().toString());
  team.setSuffix(ChatColor.WHITE.toString());

  team.setCanSeeFriendlyInvisibles(true);
  team.setAllowFriendlyFire(false);

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

    team.setNameTagVisibility(nameTags);
  } else {
    team.setNameTagVisibility(NameTagVisibility.ALWAYS);
  }
}
 
Example #21
Source File: IslandGuard1_9.java    From askyblock with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Handles push protection
 * @param player
 */
public void setPush(Player player) {
    scoreboard = player.getScoreboard();
    if (scoreboard == null) {
        //plugin.getLogger().info("1.9 " +"DEBUG: initializing scoreboard");
        scoreboard = Bukkit.getScoreboardManager().getNewScoreboard();
    }
    if (Settings.allowPushing) {
        if (scoreboard.getTeam(NO_PUSH_TEAM_NAME) != null) {
            //plugin.getLogger().info("1.9 " +"DEBUG: unregistering the team");
            scoreboard.getTeam(NO_PUSH_TEAM_NAME).unregister();
        }
        return;
    }
    // Try and get what team the player is on right now
    Team pushTeam = scoreboard.getEntryTeam(player.getName());
    if (pushTeam == null) {
        // It doesn't exist yet, so make it
        pushTeam = scoreboard.getTeam(NO_PUSH_TEAM_NAME);
        if (pushTeam == null) {
            pushTeam = scoreboard.registerNewTeam(NO_PUSH_TEAM_NAME);
        }
        // Add the player to the team
        pushTeam.addEntry(player.getName()); 
    }
    if (pushTeam.getName().equals(NO_PUSH_TEAM_NAME)) {
        //plugin.getLogger().info("1.9 " +"DEBUG: pushing not allowed");
        pushTeam.setOption(Team.Option.COLLISION_RULE, Team.OptionStatus.NEVER);               
    } else {
        //plugin.getLogger().info("1.9 " +"DEBUG: player is already in another team");
    }
}
 
Example #22
Source File: Scoreboards.java    From CardinalPGM with MIT License 5 votes vote down vote up
public static String getNextConversion(Objective objective, int slot, Team team, String string, String insert, String addition, Set<String> used, boolean doNotInterruptColorCodes) {
    while (used.contains(Scoreboards.getConversion(string, insert))) {
        insert += addition;
    }
    String steam = Scoreboards.convertToScoreboard(team, string, insert, doNotInterruptColorCodes);
    used.add(steam);
    if (slot == 0) {
        objective.getScore(steam).setScore(1);
    }
    objective.getScore(steam).setScore(slot);
    return steam;
}
 
Example #23
Source File: IslandGuard1_9.java    From askyblock with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Triggers a push protection change or not
 * @param e - event
 */
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onPlayerJoin(final PlayerJoinEvent e) {
    if (Settings.allowPushing) {           
        Team t = e.getPlayer().getScoreboard().getTeam(NO_PUSH_TEAM_NAME);
        if (t != null) {
            t.unregister();
        }
        return;
    }
    setPush(e.getPlayer());
}
 
Example #24
Source File: TeamPMCommand.java    From UHC with MIT License 5 votes vote down vote up
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    if (!(sender instanceof Player)) {
        sender.sendMessage(messages.getRaw("players only"));
        return true;
    }

    if (args.length == 0) {
        sender.sendMessage(messages.getRaw("no message"));
        return true;
    }

    final Team team = module.getScoreboard().getPlayerTeam((OfflinePlayer) sender);

    if (team == null) {
        sender.sendMessage(messages.getRaw("not in team"));
        return true;
    }

    final Iterable<Player> online = Iterables.filter(
            Iterables.transform(team.getPlayers(), FunctionalUtil.ONLINE_VERSION),
            Predicates.notNull()
    );

    final Map<String, String> context = ImmutableMap.<String, String>builder()
            .put("team prefix", team.getPrefix())
            .put("team display name", team.getDisplayName())
            .put("team name", team.getName())
            .put("sender", sender.getName())
            .put("message", Joiner.on(" ").join(args))
            .build();

    final String message = messages.evalTemplate("message format", context);
    for (final Player player : online) {
        player.sendMessage(message);
    }
    return true;
}
 
Example #25
Source File: ScoreboardModule.java    From CardinalPGM with MIT License 5 votes vote down vote up
@EventHandler
public void onMatchEndEvent(MatchEndEvent event) {
    for (TeamModule team : Teams.getTeams()) {
        Team scoreboardTeam = scoreboard.getTeam(team.getId());
        if (!team.isObserver()) scoreboardTeam.setOption(Team.Option.COLLISION_RULE, Team.OptionStatus.NEVER);
    }
}
 
Example #26
Source File: Scoreboards.java    From CardinalPGM with MIT License 5 votes vote down vote up
public static String convertToScoreboard(Team team, String string, String insertColor, boolean doNotInterruptColorCodes) {
    int max1 = 16 - insertColor.length();
    int max2 = 32 - (insertColor.length() * 2);
    int max3 = 48 - (insertColor.length() * 2);
    if (string.length() > max1) {
        if (string.substring(max1 - 1, max1).equals("ยง") && doNotInterruptColorCodes && !insertColor.equals("")) {
            max1--;
            max2--;
            max3--;
        }
    }
    if (string.length() > max3) {
        string = string.substring(0, max3);
    }
    if (string.length() <= max1) {
        team.setPrefix("");
        team.addEntry(insertColor + string);
        team.setSuffix("");
        return insertColor + string;
    } else if (string.length() <= max2) {
        team.setPrefix(insertColor + string.substring(0, max1));
        team.addEntry(insertColor + string.substring(max1));
        team.setSuffix("");
        return insertColor + string.substring(max1);
    } else if (string.length() <= max3) {
        team.setPrefix(insertColor + string.substring(0, max1));
        team.addEntry(insertColor + string.substring(max1, max2));
        team.setSuffix(string.substring(max2));
        return insertColor + string.substring(max1, max2);
    }
    return null;
}
 
Example #27
Source File: ScoreboardModule.java    From CardinalPGM with MIT License 5 votes vote down vote up
@EventHandler
public void onMatchStartEvent(MatchStartEvent event) {
    for (TeamModule team : Teams.getTeams()) {
        Team scoreboardTeam = scoreboard.getTeam(team.getId());
        if (!team.isObserver()) scoreboardTeam.setOption(Team.Option.COLLISION_RULE, Team.OptionStatus.NEVER);
    }
}
 
Example #28
Source File: BukkitScoreboard.java    From VoxelGamesLibv2 with MIT License 5 votes vote down vote up
@Override
@Nonnull
public StringScoreboardLine createAndAddLine(int pos, @Nonnull String content) {
    Team team = scoreboard.registerNewTeam("line" + pos);
    BukkitStringScoreboardLine scoreboardLine = new BukkitStringScoreboardLine(content, team);
    addLine(pos, scoreboardLine);
    String entry = scoreboardLine.setScore(pos);
    objective.getScore(entry).setScore(pos);
    scoreboardLine.setValue(content);
    return scoreboardLine;
}
 
Example #29
Source File: BukkitScoreboard.java    From VoxelGamesLibv2 with MIT License 5 votes vote down vote up
@Override
@Nonnull
public StringScoreboardLine createAndAddLine(@Nonnull String content) {
    Team team = scoreboard.registerNewTeam("line" + RandomUtil.generateString(8));
    BukkitStringScoreboardLine scoreboardLine = new BukkitStringScoreboardLine(content, team);
    int score = addLine(scoreboardLine);
    String entry = scoreboardLine.setScore(score);
    objective.getScore(entry).setScore(score);
    scoreboardLine.setValue(content);
    return scoreboardLine;
}
 
Example #30
Source File: IndividualPrefix.java    From FunnyGuilds with Apache License 2.0 5 votes vote down vote up
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);
}