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

import java.sql.Timestamp;
import java.text.DecimalFormat;
import java.util.logging.Level;

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.CitadelConfigManager;
import vg.civcraft.mc.citadel.Utility;
import vg.civcraft.mc.citadel.reinforcementtypes.ReinforcementType;
import vg.civcraft.mc.namelayer.GroupManager;
import vg.civcraft.mc.namelayer.NameAPI;
import vg.civcraft.mc.namelayer.group.Group;
import vg.civcraft.mc.namelayer.permission.PermissionType;

public class PlayerReinforcement extends Reinforcement{
	private transient int gid;
	private Group g;
	private static GroupManager gm;
	private boolean isInsecure = false;
	private ItemStack stack;
	
	public PlayerReinforcement(Location loc, int health,
			int creation, int acid, Group g, ItemStack stack) {
		super(loc, stack.getType(), health, creation, acid);
		this.g = g;
		this.stack = stack;
		if (gm == null) {
			gm = NameAPI.getGroupManager();
		}
		this.gid = g.getGroupId();
	}	
	
	public boolean canBypass(Player p) {
		checkValid();
		if (g == null) {
			return false;
		}
		return gm.hasAccess(g.getName(), p.getUniqueId(), PermissionType.getPermission("BYPASS_REINFORCEMENT"));
	}
	
	public boolean canAccessCrops(Player p) {
		checkValid();
		if (g == null) {
			return false;
		}
		return gm.hasAccess(g.getName(), p.getUniqueId(), PermissionType.getPermission("CROPS"));
	}
	
	public boolean canAccessChests(Player p) {
		checkValid();
		if (g == null) {
			return false;
		}
		return gm.hasAccess(g.getName(), p.getUniqueId(), PermissionType.getPermission("CHESTS"));
	}
	
	public boolean canAccessDoors(Player p) {
		checkValid();
		if (g == null) {
			return false;
		}
		return gm.hasAccess(g.getName(), p.getUniqueId(), PermissionType.getPermission("DOORS"));
	}
	
	public boolean canViewInformation(Player p) {
		checkValid();
		if (g == null) {
			return false;
		}
		return gm.hasAccess(g.getName(), p.getUniqueId(), PermissionType.getPermission("REINFORCEMENT_INFO"));
	}
	
	public boolean canMakeInsecure(Player p) {
		checkValid();
		if (g == null) {
			return false;
		}
		return gm.hasAccess(g.getName(), p.getUniqueId(), PermissionType.getPermission("INSECURE_REINFORCEMENT"));
	}
	
	public boolean canAcid(Player p) {
		checkValid();
		if (g == null) {
			return false;
		}
		return gm.hasAccess(g.getName(), p.getUniqueId(), PermissionType.getPermission("ACIDBLOCK"));
	}
	
	public boolean isSecurable() {
		return (isContainer() || isDoor());
	}
	
	public int getDamageMultiplier(){
		if (g == null){
			return 1;
		}
		Timestamp ts = NameAPI.getGroupManager().getTimestamp(g.getName());
		
		long shiftMultiplier = ((System.currentTimeMillis() - ts.getTime()) / (long)86400000) / (long)Citadel.getReinforcementManager().getDayMultiplier();
		if (shiftMultiplier > 0) {
			return 1 << shiftMultiplier;
		}
		return 1;
	}
	<commit_msg>Changing access to GM to use ID when possible, which should be resistent stable against namelayer merges and such<commit_after>package vg.civcraft.mc.citadel.reinforcement;

import java.sql.Timestamp;
import java.text.DecimalFormat;
import java.util.logging.Level;

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.CitadelConfigManager;
import vg.civcraft.mc.citadel.Utility;
import vg.civcraft.mc.citadel.reinforcementtypes.ReinforcementType;
import vg.civcraft.mc.namelayer.GroupManager;
import vg.civcraft.mc.namelayer.NameAPI;
import vg.civcraft.mc.namelayer.group.Group;
import vg.civcraft.mc.namelayer.permission.PermissionType;

public class PlayerReinforcement extends Reinforcement{
	private transient int gid;
	private Group g;
	private static GroupManager gm;
	private boolean isInsecure = false;
	private ItemStack stack;
	
	public PlayerReinforcement(Location loc, int health,
			int creation, int acid, Group g, ItemStack stack) {
		super(loc, stack.getType(), health, creation, acid);
		this.g = g;
		this.stack = stack;
		if (gm == null) {
			gm = NameAPI.getGroupManager();
		}
		this.gid = g.getGroupId();
	}	
	
	public boolean canBypass(Player p) {
		checkValid();
		if (g == null) {
			return false;
		}
		return gm.hasAccess(g, p.getUniqueId(), PermissionType.getPermission("BYPASS_REINFORCEMENT"));
	}
	
	public boolean canAccessCrops(Player p) {
		checkValid();
		if (g == null) {
			return false;
		}
		return gm.hasAccess(g, p.getUniqueId(), PermissionType.getPermission("CROPS"));
	}
	
	public boolean canAccessChests(Player p) {
		checkValid();
		if (g == null) {
			return false;
		}
		return gm.hasAccess(g, p.getUniqueId(), PermissionType.getPermission("CHESTS"));
	}
	
	public boolean canAccessDoors(Player p) {
		checkValid();
		if (g == null) {
			return false;
		}
		return gm.hasAccess(g, p.getUniqueId(), PermissionType.getPermission("DOORS"));
	}
	
	public boolean canViewInformation(Player p) {
		checkValid();
		if (g == null) {
			return false;
		}
		return gm.hasAccess(g, p.getUniqueId(), PermissionType.getPermission("REINFORCEMENT_INFO"));
	}
	
	public boolean canMakeInsecure(Player p) {
		checkValid();
		if (g == null) {
			return false;
		}
		return gm.hasAccess(g, p.getUniqueId(), PermissionType.getPermission("INSECURE_REINFORCEMENT"));
	}
	
	public boolean canAcid(Player p) {
		checkValid();
		if (g == null) {
			return false;
		}
		return gm.hasAccess(g, p.getUniqueId(), PermissionType.getPermission("ACIDBLOCK"));
	}
	
	public boolean isSecurable() {
		return (isContainer() || isDoor());
	}
	
	public int getDamageMultiplier(){
		checkValid();
		if (g == null){
			return 1;
		}
		Timestamp ts = NameAPI.getGroupManager().getTimestamp(g.getName());
		
		long shiftMultiplier = ((System.currentTimeMillis() - ts.getTime()) / (long)86400000) / (long)Citadel.getReinforcementManager().getDayMultiplier();
		if (shiftMultiplier > 0) {
			return 1 << shiftMultiplier;
		}
		return 1;
	}
	
{'fraction_non_alphanumeric': 0.13023477157360405, 'fraction_numerical': 0.0038071065989847717, 'mean_word_length': 4.604444444444445, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, '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': '937727', 'n_tokens_mistral': 2385, 'n_tokens_neox': 2138, 'n_words': 453}