<commit_before>package in.twizmwaz.cardinal.teams;

import in.twizmwaz.cardinal.GameHandler;
import in.twizmwaz.cardinal.event.PlayerChangeTeamEvent;
import in.twizmwaz.cardinal.match.JoinType;
import in.twizmwaz.cardinal.module.GameObjective;
import in.twizmwaz.cardinal.regions.type.PointRegion;
import in.twizmwaz.cardinal.teams.spawns.Spawn;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import org.bukkit.scoreboard.Scoreboard;
import org.bukkit.scoreboard.Team;

import java.util.HashSet;
import java.util.List;
import java.util.Random;
import java.util.Set;
import java.util.logging.Level;

/**
 * Created by kevin on 11/17/14.
 */
public class PgmTeam {

    private Team scoreboardTeam;
    private String name;
    private String id;
    private int max;
    private int maxOverfill;
    private int respawnLimit;
    private ChatColor color;
    private boolean observer;
    private List<Spawn> spawns;
    private Set<GameObjective> objectives;
    private Scoreboard scoreboard;

    PgmTeam(String name, String id, int max, int maxOverfill, int respawnLimit, ChatColor color, boolean obs, Scoreboard scoreboard, List<Spawn> spawns) {
        this.observer = obs;
        this.name = name;
        this.id = id;
        this.max = max;
        this.maxOverfill = maxOverfill;
        this.respawnLimit = respawnLimit;
        this.color = color;
        this.scoreboard = scoreboard;
        this.scoreboardTeam = scoreboard.registerNewTeam(id);
        scoreboardTeam.setDisplayName(color + name);
        scoreboardTeam.setPrefix(color + "");
        this.spawns = spawns;
    }

    public void add(Player player, JoinType joinType) {
        PlayerChangeTeamEvent event = new PlayerChangeTeamEvent(player, this, joinType);
        Bukkit.getServer().getPluginManager().callEvent(event);
        if (!event.isCancelled()) {
            this.set(event);
        }

    }

    public void force(Player player, JoinType joinType) {
        PlayerChangeTeamEvent event = new PlayerChangeTeamEvent(player, this, joinType);
        Bukkit.getServer().getPluginManager().callEvent(event);
        this.set(event);
    }

    private void set(PlayerChangeTeamEvent event) {
        scoreboardTeam.addPlayer(event.getPlayer());
        event.getPlayer().setScoreboard(scoreboardTeam.getScoreboard());
        if (!event.getJoinType().equals(JoinType.JOIN)) {
            event.getPlayer().sendMessage(ChatColor.GRAY + "You have joined " + event.getNewTeam().getColor() + event.getNewTeam().getName());
        }
    }

    public void remove(Player player) {
        scoreboardTeam.removePlayer(player);
    }

    public boolean hasPlayer(Player player) {
        return scoreboardTeam.hasPlayer(player);
    }

    public Set<Player> getPlayers() {
        Set<Player> result = new HashSet<>(maxOverfill);
        for (OfflinePlayer offlinePlayer : scoreboardTeam.getPlayers()) {
            if (offlinePlayer instanceof Player) result.add((Player) offlinePlayer);
        }
        return result;
    }

    public Set<String> getPlayerNames() {
        return scoreboardTeam.getEntries();
    }

    public int getMax() {
        return max;
    }

    public String getName() {
        return name;<commit_msg>Fixed the team join message<commit_after>package in.twizmwaz.cardinal.teams;

import in.twizmwaz.cardinal.GameHandler;
import in.twizmwaz.cardinal.event.PlayerChangeTeamEvent;
import in.twizmwaz.cardinal.match.JoinType;
import in.twizmwaz.cardinal.module.GameObjective;
import in.twizmwaz.cardinal.regions.type.PointRegion;
import in.twizmwaz.cardinal.teams.spawns.Spawn;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import org.bukkit.scoreboard.Scoreboard;
import org.bukkit.scoreboard.Team;

import java.util.HashSet;
import java.util.List;
import java.util.Random;
import java.util.Set;
import java.util.logging.Level;

/**
 * Created by kevin on 11/17/14.
 */
public class PgmTeam {

    private Team scoreboardTeam;
    private String name;
    private String id;
    private int max;
    private int maxOverfill;
    private int respawnLimit;
    private ChatColor color;
    private boolean observer;
    private List<Spawn> spawns;
    private Set<GameObjective> objectives;
    private Scoreboard scoreboard;

    PgmTeam(String name, String id, int max, int maxOverfill, int respawnLimit, ChatColor color, boolean obs, Scoreboard scoreboard, List<Spawn> spawns) {
        this.observer = obs;
        this.name = name;
        this.id = id;
        this.max = max;
        this.maxOverfill = maxOverfill;
        this.respawnLimit = respawnLimit;
        this.color = color;
        this.scoreboard = scoreboard;
        this.scoreboardTeam = scoreboard.registerNewTeam(id);
        scoreboardTeam.setDisplayName(color + name);
        scoreboardTeam.setPrefix(color + "");
        this.spawns = spawns;
    }

    public void add(Player player, JoinType joinType) {
        PlayerChangeTeamEvent event = new PlayerChangeTeamEvent(player, this, joinType);
        Bukkit.getServer().getPluginManager().callEvent(event);
        if (!event.isCancelled()) {
            this.set(event);
        }

    }

    public void force(Player player, JoinType joinType) {
        PlayerChangeTeamEvent event = new PlayerChangeTeamEvent(player, this, joinType);
        Bukkit.getServer().getPluginManager().callEvent(event);
        this.set(event);
    }

    private void set(PlayerChangeTeamEvent event) {
        scoreboardTeam.addPlayer(event.getPlayer());
        event.getPlayer().setScoreboard(scoreboardTeam.getScoreboard());
        if (!event.getJoinType().equals(JoinType.JOIN)) {
            event.getPlayer().sendMessage(ChatColor.GRAY + "You joined the " + event.getNewTeam().getColor() + event.getNewTeam().getName());
        }
    }

    public void remove(Player player) {
        scoreboardTeam.removePlayer(player);
    }

    public boolean hasPlayer(Player player) {
        return scoreboardTeam.hasPlayer(player);
    }

    public Set<Player> getPlayers() {
        Set<Player> result = new HashSet<>(maxOverfill);
        for (OfflinePlayer offlinePlayer : scoreboardTeam.getPlayers()) {
            if (offlinePlayer instanceof Player) result.add((Player) offlinePlayer);
        }
        return result;
    }

    public Set<String> getPlayerNames() {
        return scoreboardTeam.getEntries();
    }

    public int getMax() {
        return max;
    }

    public String getName() {
        return name;
{'fraction_non_alphanumeric': 0.1032258064516129, 'fraction_numerical': 0.001800450112528132, 'mean_word_length': 3.2056782334384857, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3745226', 'n_tokens_mistral': 2033, 'n_tokens_neox': 1965, 'n_words': 421}