<commit_before>package fr.aumgn.dac2.stage;

import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerQuitEvent;

import fr.aumgn.dac2.arena.Arena;

public class JoinStage implements Stage, Listener {

    private final Arena arena;

    public JoinStage(Arena arena) {
        this.arena = arena;
    }

    @Override
    public Arena getArena() {
        return arena;
    }

    @Override
    public void start() {
    }

    @Override
    public void stop() {
    }

    @Override
    public Listener[] getListeners() {
        return new Listener[] { this };
    }

    @Override
    public boolean contains(Player player) {
        return false;
    }

    @EventHandler
    public void onQuit(PlayerQuitEvent event) {
    }
}
<commit_msg>Add JoinStage<commit_after>package fr.aumgn.dac2.stage;

import java.util.List;
import java.util.Map;

import org.bukkit.entity.Player;
import org.bukkit.event.Listener;

import fr.aumgn.bukkitutils.localization.PluginMessages;
import fr.aumgn.bukkitutils.playerid.map.PlayersIdHashMap;
import fr.aumgn.bukkitutils.playerid.map.PlayersIdMap;
import fr.aumgn.bukkitutils.util.Util;
import fr.aumgn.dac2.DAC;
import fr.aumgn.dac2.arena.Arena;
import fr.aumgn.dac2.config.Color;

public class JoinStage implements Stage, Listener {

    private final DAC dac;
    private final Arena arena;
    private final Map<String, Color> colors;
    private final PlayersIdMap<Color> players;

    public JoinStage(DAC dac, Arena arena) {
        this.dac = dac;
        this.arena = arena;
        this.colors = dac.getColors().toMap();
        this.players = new PlayersIdHashMap<Color>();
    }

    @Override
    public Arena getArena() {
        return arena;
    }

    @Override
    public void start() {
        PluginMessages messages = dac.getMessages();
        Util.broadcast(messages.get("joinstage.start1", arena.getName()));
                //, "dac.game.watch");
        Util.broadcast(messages.get("joinstage.start2"));//, "dac.game.watch");
    }

    @Override
    public void stop() {
    }

    @Override
    public Listener[] getListeners() {
        return new Listener[0];
    }

    @Override
    public boolean contains(Player player) {
        return players.containsKey(player);
    }

    public void addPlayer(Player player, List<String> colorsName) {
        Color color = null;
        for (String rawColorName : colorsName) {
            String colorName = rawColorName.toLowerCase();
            if (colors.containsKey(colorName)) {
                color = colors.get(colorName);
                break;
            }
        }

        addPlayer(player, color);
    }

    public void addPlayer(Player player, Color color) {
        if (color == null || !colors.containsValue(color)) {
            // Get first color available
            color = colors.values().iterator().next();
        }

        players.put(player, color);
        colors.remove(color.getName());
    }
}

{'fraction_non_alphanumeric': 0.1106340819022457, 'fraction_numerical': 0.00297225891677675, 'mean_word_length': 2.5593419506462984, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '3307062', 'n_tokens_mistral': 947, 'n_tokens_neox': 920, 'n_words': 201}