<commit_before>package vg.civcraft.mc.citadel.reinforcement;

import java.util.UUID;

import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
import org.bukkit.material.Openable;

import vg.civcraft.mc.citadel.Citadel;
import vg.civcraft.mc.citadel.reinforcementtypes.ReinforcementType;
import vg.civcraft.mc.namelayer.GroupManager.PlayerType;
import vg.civcraft.mc.namelayer.NameAPI;
import vg.civcraft.mc.namelayer.group.Group;
import vg.civcraft.mc.namelayer.group.groups.PublicGroup;
import vg.civcraft.mc.namelayer.permission.GroupPermission;
import vg.civcraft.mc.namelayer.permission.PermissionType;

public class PlayerReinforcement extends Reinforcement{

	private Group g;
	private GroupPermission gp;
	private boolean isInsecure = false;
	private ItemStack stack;
	
	public PlayerReinforcement(Location loc, int health,
			int creation, Group g, ItemStack stack) {
		super(loc, stack.getType(), health, creation);
		this.g = g;
		this.stack = stack;
		gp = NameAPI.getGroupManager().getPermissionforGroup(g);
	}
	
	/**
	 * Returns true if the player has access to do the specified 
	 * PermissionType on this reinforcement.
	 * @param PermissionType
	 * @param Player
	 * @return true if the player has access or false if the player
	 * doesn't have access to that specified permission or isn't on the
	 * group.
	 */
	public boolean isAccessible(Player p, PermissionType... pType){
		return isAccessible(p.getUniqueId(), pType);
	}
	
	public boolean isAccessible(UUID u, PermissionType... pType){
		checkValid();
		PlayerType type = g.getPlayerType(u);
		// if it is a public group we want it to check even if no
				// PlayerType
				
		if (type == null && !(g instanceof PublicGroup))
			return false;
		return gp.isAccessible(type, pType);
	}
	/**
	 * Is used to see if a player has permission to bypass a reinforcement.
	 * @param The Player who wants to bypass a Reinforcemet.
	 * @return Returns if the Player can or not.
	 */
	public boolean isBypassable(Player p){
		checkValid();
		PlayerType type = g.getPlayerType(p.getUniqueId());
		if (type == null)
			return false;
		return gp.isAccessible(type, PermissionType.BLOCKS);
	}
	
	/**
	 * @return return false if it is secure, return true if it is insecure.
	 */
	public boolean isInsecure(){
		return isInsecure;
	}
	/**
	 * Toggles whether or not the block is insecure.
	 */
	public void toggleInsecure() {
        this.setInsecure(!this.isInsecure());
    }
	/**
	 * Set the status of either insecure or secure.
	 * Mostly used with hoppers to allow or disallow the transfer of items
	 * from one hopper to another if they are on separate groups.
	 * @param bool
	 */
	public void setInsecure(boolean bool){
		isInsecure = bool;
	}
	/**
	 * @return Returns the percent of the reinforcement.
	 */
    public double getHealth() {
        return (double)getDurability() / ((double)ReinforcementType.
        		getReinforcementType(stack).getHitPoints());
    }
    /**
     * @return Returns in textual form the health of the reinforcement.
     */
    public String getHealthText() {
        double health = getHealth();
        if (health > 0.75) {
            return "excellently";
        } else if (health > 0.50) {
            return "well";
        } else if (health > 0.25) {
            return "decently";
        } else {
            return "poorly";
        }
    }
    /**
     * Returns true if the block has an inventory that can be opened.
     * @return boolean
     */
    public boolean isSecurable() {
        Block block = getLocation().getBlock();
        return block.getState() instanceof InventoryHolder
                || block.getState().getData() instanceof Openable;
    }
    /**
     * Returns the group this PlayerReinforcement is associated with.
     * @return group
     */
    public Group getGroup(){
    	checkValid();
    	return g;
    }
    /**
     * Sets the Group for this reinforcement
     * @param Group
     */
    public void setGroup(Group g){
    	this.g = g;
    	this.gp = NameAPI.getGroupManager().getPermissionforGroup(g);
    }
    /**
     * @return ItemStack associated with this reinforcement
     */
    public ItemStack getStackRepresentation(){
    	return stack;
    }
    /**
     * @return A string representation of a reinforcement's health, material, ect.
     */
    public String getStatus() {
        String verb;
        if (isSecurable()) {
            verb = "Locked";
        } else {
            verb = "Reinforced";
        }
        return String.format("%s %s with %s",
                verb,
                getHealthText(),
                getMaterial().name());
    }
    
    private void checkValid(){
    	if (!g.isValid()){ // incase it was recently merged/ deleted.
    		String group = Citadel.getCitadelDatabase().getSavedGroupName(this);
    		g = NameAPI.getGroupManager().getGroup(group);
    		gp = NameAPI.getGroupManager().getPermissionforGroup(g);
    	}
    }
}
<commit_msg>Misclicked<commit_after>package vg.civcraft.mc.citadel.reinforcement;

import java.util.UUID;

import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
import org.bukkit.material.Openable;

import vg.civcraft.mc.citadel.Citadel;
import vg.civcraft.mc.citadel.reinforcementtypes.ReinforcementType;
import vg.civcraft.mc.namelayer.GroupManager.PlayerType;
import vg.civcraft.mc.namelayer.NameAPI;
import vg.civcraft.mc.namelayer.group.Group;
import vg.civcraft.mc.namelayer.group.groups.PublicGroup;
import vg.civcraft.mc.namelayer.permission.GroupPermission;
import vg.civcraft.mc.namelayer.permission.PermissionType;

public class PlayerReinforcement extends Reinforcement{

	private int group_id;
	private Group g;
	private GroupPermission gp;
	private boolean isInsecure = false;
	private ItemStack stack;
	
	public PlayerReinforcement(Location loc, int health,
			int creation, Group g, ItemStack stack, int group_id) {
		super(loc, stack.getType(), health, creation);
		this.g = g;
		this.stack = stack;
		gp = NameAPI.getGroupManager().getPermissionforGroup(g);
		this.group_id = group_id;
	}
	
	/**
	 * Returns true if the player has access to do the specified 
	 * PermissionType on this reinforcement.
	 * @param PermissionType
	 * @param Player
	 * @return true if the player has access or false if the player
	 * doesn't have access to that specified permission or isn't on the
	 * group.
	 */
	public boolean isAccessible(Player p, PermissionType... pType){
		return isAccessible(p.getUniqueId(), pType);
	}
	
	public boolean isAccessible(UUID u, PermissionType... pType){
		checkValid();
		PlayerType type = g.getPlayerType(u);
		// if it is a public group we want it to check even if no
				// PlayerType
				
		if (type == null && !(g instanceof PublicGroup))
			return false;
		return gp.isAccessible(type, pType);
	}
	/**
	 * Is used to see if a player has permission to bypass a reinforcement.
	 * @param The Player who wants to bypass a Reinforcemet.
	 * @return Returns if the Player can or not.
	 */
	public boolean isBypassable(Player p){
		checkValid();
		PlayerType type = g.getPlayerType(p.getUniqueId());
		if (type == null)
			return false;
		return gp.isAccessible(type, PermissionType.BLOCKS);
	}
	
	/**
	 * @return return false if it is secure, return true if it is insecure.
	 */
	public boolean isInsecure(){
		return isInsecure;
	}
	/**
	 * Toggles whether or not the block is insecure.
	 */
	public void toggleInsecure() {
        this.setInsecure(!this.isInsecure());
    }
	/**
	 * Set the status of either insecure or secure.
	 * Mostly used with hoppers to allow or disallow the transfer of items
	 * from one hopper to another if they are on separate groups.
	 * @param bool
	 */
	public void setInsecure(boolean bool){
		isInsecure = bool;
	}
	/**
	 * @return Returns the percent of the reinforcement.
	 */
    public double getHealth() {
        return (double)getDurability() / ((double)ReinforcementType.
        		getReinforcementType(stack).getHitPoints());
    }
    /**
     * @return Returns in textual form the health of the reinforcement.
     */
    public String getHealthText() {
        double health = getHealth();
        if (health > 0.75) {
            return "excellently";
        } else if (health > 0.50) {
            return "well";
        } else if (health > 0.25) {
            return "decently";
        } else {
            return "poorly";
        }
    }
    /**
     * Returns true if the block has an inventory that can be opened.
     * @return boolean
     */
    public boolean isSecurable() {
        Block block = getLocation().getBlock();
        return block.getState() instanceof InventoryHolder
                || block.getState().getData() instanceof Openable;
    }
    /**
     * Returns the group this PlayerReinforcement is associated with.
     * @return group
     */
    public Group getGroup(){
    	checkValid();
    	return g;
    }
    /**
     * Sets the Group for this reinforcement
     * @param Group
     */
    public void setGroup(Group g){
    	this.g = g;
    	this.gp = NameAPI.getGroupManager().getPermissionforGroup(g);
    }
    /**
     * @return ItemStack associated with this reinforcement
     */
    public ItemStack getStackRepresentation(){
    	return stack;
    }
    /**
     * @return A string representation of a reinforcement's health, material, ect.
     */
    public String getStatus() {
        String verb;
        if (isSecurable()) {
            verb = "Locked";
        } else {
            verb = "Reinforced";
        }
        return String.format("%s %s with %s",
                verb,
                getHealthText(),
                getMaterial().name());
    }
    
    private void checkValid(){
    	if (!g.isValid()){ // incase it was recently merged/ deleted.
    		String group = Citadel.getCitadelDatabase().getSavedGroupName(this);
    		g = NameAPI.getGroupManager().getGroup(group);
    		gp = NameAPI.getGroupManager().getPermissionforGroup(g);
    	}
    }
    /**
     * Note this is different to the group id of a Group.
     * If a reinforcement is made with Group 1 and then is merged into Group 0 then this will return the group_id
     * of Group 1.
     * @return Returns the value of the group_id from the group it was created with.
     */
    public int getGroupId(){
    	return group_id;
    }
}

{'fraction_non_alphanumeric': 0.10283923653973981, 'fraction_numerical': 0.0019941126198841515, 'mean_word_length': 2.789852464915437, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '5044182', 'n_tokens_mistral': 3302, 'n_tokens_neox': 3074, 'n_words': 945}