<commit_before>package com.Acrobot.ChestShop.Protection;

import com.Acrobot.ChestShop.Config.Config;
import com.Acrobot.ChestShop.Config.Property;
import com.Acrobot.ChestShop.Listeners.blockBreak;
import com.Acrobot.ChestShop.Utils.uLongName;
import com.Acrobot.ChestShop.Utils.uSign;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.Sign;
import org.bukkit.entity.Player;

import java.util.ArrayList;

/**
 * @author Acrobot
 */
public class Security {
    private static final BlockFace[] faces = {BlockFace.UP, BlockFace.EAST, BlockFace.WEST, BlockFace.NORTH, BlockFace.SOUTH};
    private static final BlockFace[] blockFaces = {BlockFace.UP, BlockFace.DOWN, BlockFace.EAST, BlockFace.WEST, BlockFace.NORTH, BlockFace.SOUTH};
    public static ArrayList<Protection> protections = new ArrayList<Protection>();

    public static boolean protect(String name, Block block) {
        boolean works = false;
        for (int i = 0; i < protections.size() && !works; i++) works = protections.get(i).protect(name, block);
        return works;
    }

    public static boolean canAccess(Player player, Block block) {
        boolean works = true;
        for (int i = 0; i < protections.size() && works; i++) works = protections.get(i).canAccess(player, block);
        return works;
    }

    public static boolean isProtected(Block block) {
        boolean isProt = false;
        for (int i = 0; i < protections.size() && !isProt; i++) isProt = protections.get(i).isProtected(block);
        return isProt;
    }

    public static boolean canPlaceSign(Player p, Sign sign) {
        return !anotherShopFound(blockBreak.getAttachedFace(sign), sign.getBlock(), p) && canBePlaced(p, sign.getBlock());
    }

    private static boolean canBePlaced(Player p, Block signBlock) {
        for (BlockFace bf : blockFaces) {
            Block block = signBlock.getRelative(bf);

            if (block.getType() != Material.CHEST) continue;
            if (isProtected(block) && !canAccess(p, block)) return false;
        }<commit_msg>Added getDefaultProtection() method so the objects gets created only once<commit_after>package com.Acrobot.ChestShop.Protection;

import com.Acrobot.ChestShop.Config.Config;
import com.Acrobot.ChestShop.Config.Property;
import com.Acrobot.ChestShop.Listeners.blockBreak;
import com.Acrobot.ChestShop.Protection.Plugins.Default;
import com.Acrobot.ChestShop.Utils.uLongName;
import com.Acrobot.ChestShop.Utils.uSign;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.Sign;
import org.bukkit.entity.Player;

import java.util.ArrayList;

/**
 * @author Acrobot
 */
public class Security {
    private static final BlockFace[] faces = {BlockFace.UP, BlockFace.EAST, BlockFace.WEST, BlockFace.NORTH, BlockFace.SOUTH};
    private static final BlockFace[] blockFaces = {BlockFace.UP, BlockFace.DOWN, BlockFace.EAST, BlockFace.WEST, BlockFace.NORTH, BlockFace.SOUTH};
    public static ArrayList<Protection> protections = new ArrayList<Protection>();
    private static Default defaultProtection = new Default();

    public static Default getDefaultProtection() {
        return defaultProtection;
    }

    public static boolean protect(String name, Block block) {
        boolean works = false;
        for (int i = 0; i < protections.size() && !works; i++){
            works = protections.get(i).protect(name, block);
        }
        return works;
    }

    public static boolean canAccess(Player player, Block block) {
        boolean works = true;
        for (int i = 0; i < protections.size() && works; i++){
            works = protections.get(i).canAccess(player, block);
        }
        return works;
    }

    public static boolean isProtected(Block block) {
        boolean isProt = false;
        for (int i = 0; i < protections.size() && !isProt; i++){
            isProt = protections.get(i).isProtected(block);
        }
        return isProt;
    }

    public static boolean canPlaceSign(Player p, Sign sign) {
        return !anotherShopFound(blockBreak.getAttachedFace(sign), sign.getBlock(), p) && canBePlaced(p, sign.getBlock());
    }

    private static boolean canBePlaced(Player p, Block signBlock) {
        for (BlockFace bf : blockFaces) {
            Block block = signBlock.getRelative(bf);

            if (block.getType() != Material.CHEST) continue;
            if (isProtected(block) && !canAccess(p, block)) return false;
        }
{'fraction_non_alphanumeric': 0.11579179532421703, 'fraction_numerical': 0.0013233348037053375, 'mean_word_length': 3.4287109375, 'pattern_counts': {'":': 0, '<': 13, '<?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': '6711283', 'n_tokens_mistral': 1407, 'n_tokens_neox': 1348, 'n_words': 341}