<commit_before>package com.gmail.stefvanschiedev.buildinggame.events.player.signs;

import com.gmail.stefvanschiedev.buildinggame.managers.arenas.SignManager;
import com.gmail.stefvanschiedev.buildinggame.utils.GameState;
import org.bukkit.ChatColor;
import org.bukkit.block.Sign;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;

import com.gmail.stefvanschiedev.buildinggame.managers.arenas.ArenaManager;
import com.gmail.stefvanschiedev.buildinggame.managers.messages.MessageManager;
import com.gmail.stefvanschiedev.buildinggame.utils.arena.Arena;

public class ClickJoinSign implements Listener {

	@EventHandler
	public void onPlayerInteract(PlayerInteractEvent e) {
		Player player = e.getPlayer();
		
		if (e.getAction() != Action.RIGHT_CLICK_BLOCK) {
			return;
		}
		
		if (!(e.getClickedBlock().getState() instanceof Sign)) {
			return;
		}
		
		Sign sign = (Sign) e.getClickedBlock().getState();
		
		Arena arena = null;
		
		for (Arena a : ArenaManager.getInstance().getArenas()) {
			if (a.getSigns().contains(sign)) {
				arena = a;
			}
		}
		
		if (arena == null && SignManager.getInstance().getRandomJoinSigns().contains(sign)) {
            arena = getRandomArena();

            if (arena == null) {
                MessageManager.getInstance().send(player, ChatColor.RED + "Unable to join an arena right now");
                return;
            }
		}

		if (ArenaManager.getInstance().getArena(player) != null) {
			MessageManager.getInstance().send(player, ChatColor.RED + "You're already in an arena");
			return;
		}
		
		arena.join(player);
	}

	private static Arena getRandomArena() {
	    Arena arena = null;

	    for (Arena a : ArenaManager.getInstance().getArenas()) {
	        if ((a.getState() != GameState.WAITING && a.getState() != GameState.STARTING) || a.isFull() || a.getPlayers() < (arena == null ? 0 : arena.getPlayers()))<commit_msg>All signs would work like join signs<commit_after>package com.gmail.stefvanschiedev.buildinggame.events.player.signs;

import com.gmail.stefvanschiedev.buildinggame.managers.arenas.SignManager;
import com.gmail.stefvanschiedev.buildinggame.utils.GameState;
import org.bukkit.ChatColor;
import org.bukkit.block.Sign;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;

import com.gmail.stefvanschiedev.buildinggame.managers.arenas.ArenaManager;
import com.gmail.stefvanschiedev.buildinggame.managers.messages.MessageManager;
import com.gmail.stefvanschiedev.buildinggame.utils.arena.Arena;

public class ClickJoinSign implements Listener {

	@EventHandler
	public void onPlayerInteract(PlayerInteractEvent e) {
		Player player = e.getPlayer();
		
		if (e.getAction() != Action.RIGHT_CLICK_BLOCK)
			return;
		
		if (!(e.getClickedBlock().getState() instanceof Sign))
			return;
		
		Sign sign = (Sign) e.getClickedBlock().getState();

		Arena arena = null;

		for (Arena a : ArenaManager.getInstance().getArenas()) {
            if (a.getSigns().contains(sign))
                arena = a;
        }

		if (arena == null) {
		    if (SignManager.getInstance().getRandomJoinSigns().contains(sign)) {
                arena = getRandomArena();

                if (arena == null)
                    MessageManager.getInstance().send(player, ChatColor.RED + "Unable to join an arena right now");
                else if (ArenaManager.getInstance().getArena(player) != null)
                    MessageManager.getInstance().send(player, ChatColor.RED + "You're already in an arena");
                else
                    arena.join(player);
            }
        } else {
            if (ArenaManager.getInstance().getArena(player) != null)
                MessageManager.getInstance().send(player, ChatColor.RED + "You're already in an arena");
            else
                arena.join(player);
        }
	}

	private static Arena getRandomArena() {
	    Arena arena = null;

	    for (Arena a : ArenaManager.getInstance().getArenas()) {
	        if ((a.getState() != GameState.WAITING && a.getState() != GameState.STARTING) || a.isFull() || a.getPlayers() < (arena == null ? 0 : arena.getPlayers()))
{'fraction_non_alphanumeric': 0.12663155484314176, 'fraction_numerical': 0.0004579803068468056, 'mean_word_length': 3.376753507014028, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '835457', 'n_tokens_mistral': 1441, 'n_tokens_neox': 1338, 'n_words': 251}