<commit_before>package com.untamedears.PrisonPearl;

import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.BlockState;
import org.bukkit.entity.Entity;
import org.bukkit.entity.HumanEntity;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;

public class PrisonPearl {
	private short id;
	private String imprisonedname;
	private Player player;
	private Item item;
	private Location blocklocation;
	
	public PrisonPearl(short id, String imprisonedname, Player holderplayer) {
		this.id = id;
		this.imprisonedname = imprisonedname;
		this.player = holderplayer;
	}
	
	public <ItemBlock extends BlockState & InventoryHolder> PrisonPearl(short id, String imprisonedname, Location blocklocation) {
		this.id = id;
		this.imprisonedname = imprisonedname;
		this.blocklocation = blocklocation;
	}
	
	public static PrisonPearl makeFromLocation(short id, String imprisonedname, Location loc) {
		BlockState bs = loc.getBlock().getState();
		if (bs instanceof InventoryHolder)
			return new PrisonPearl(id, imprisonedname, loc);
		else
			return null;
	}
	
	public short getID() {
		return id;
	}
	
	public String getImprisonedName() {
		return imprisonedname;
	}
	
	public Player getImprisonedPlayer() {
		return Bukkit.getPlayerExact(imprisonedname);
	}
	
	public Player getHolderPlayer() {
		return player;
	}
	
	public BlockState getHolderBlockState() {
		if (blocklocation != null)
			return blocklocation.getBlock().getState();
		else
			return null;
	}
	
	public Item getHolderItem() {
		return item;
	}
	
	public String getHolderName() {
		if (player != null) {
			return player.getName();
		} else if (item != null) {
			return "nobody";
		} else if (blocklocation != null) {
			switch (getHolderBlockState().getType()) {
			case CHEST:
				return "a chest";
			case FURNACE:
				return "a furnace";
			case BREWING_STAND:
				return "a brewing stand";
			case DISPENSER:
				return "a dispenser";
			default:
				System.err.println("PrisonPearl " + id + " is inside an unknown block");
				return "an unknown block"; 
			}
		} else {
			System.err.println("PrisonPearl " + id + " has no player, item, nor location");
			return "unknown"; 
		}
	}
	
	public Location getLocation() {
		if (player != null) {
			return player.getLocation();
		} else if (item != null) {
			return item.getLocation();
		} else if (blocklocation != null) {
			return blocklocation;
		} else {
			throw new RuntimeException("PrisonPearl " + id + " has no player, item, nor location");
		}
	}
	
	public String describeLocation() {
		Location loc = getLocation();
		Vector vec = loc.toVector();
		String str = loc.getWorld().getName() + " " + vec.getBlockX() + " " + vec.getBlockY() + " " + vec.getBlockZ();
		
		return "held by " + getHolderName() + " at " + str;
	}
	
	public boolean verifyLocation() {
		if (item != null) {
			Chunk chunk = item.getLocation().getChunk();
			for (Entity entity : chunk.getEntities()) {
				if (entity == item)
					return true;
			}
			<commit_msg>Allow players to be freed in a three high room<commit_after>package com.untamedears.PrisonPearl;

import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.BlockState;
import org.bukkit.entity.Entity;
import org.bukkit.entity.HumanEntity;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;

public class PrisonPearl {
	private short id;
	private String imprisonedname;
	private Player player;
	private Item item;
	private Location blocklocation;
	
	public PrisonPearl(short id, String imprisonedname, Player holderplayer) {
		this.id = id;
		this.imprisonedname = imprisonedname;
		this.player = holderplayer;
	}
	
	public <ItemBlock extends BlockState & InventoryHolder> PrisonPearl(short id, String imprisonedname, Location blocklocation) {
		this.id = id;
		this.imprisonedname = imprisonedname;
		this.blocklocation = blocklocation;
	}
	
	public static PrisonPearl makeFromLocation(short id, String imprisonedname, Location loc) {
		BlockState bs = loc.getBlock().getState();
		if (bs instanceof InventoryHolder)
			return new PrisonPearl(id, imprisonedname, loc);
		else
			return null;
	}
	
	public short getID() {
		return id;
	}
	
	public String getImprisonedName() {
		return imprisonedname;
	}
	
	public Player getImprisonedPlayer() {
		return Bukkit.getPlayerExact(imprisonedname);
	}
	
	public Player getHolderPlayer() {
		return player;
	}
	
	public BlockState getHolderBlockState() {
		if (blocklocation != null)
			return blocklocation.getBlock().getState();
		else
			return null;
	}
	
	public Item getHolderItem() {
		return item;
	}
	
	public String getHolderName() {
		if (player != null) {
			return player.getName();
		} else if (item != null) {
			return "nobody";
		} else if (blocklocation != null) {
			switch (getHolderBlockState().getType()) {
			case CHEST:
				return "a chest";
			case FURNACE:
				return "a furnace";
			case BREWING_STAND:
				return "a brewing stand";
			case DISPENSER:
				return "a dispenser";
			default:
				System.err.println("PrisonPearl " + id + " is inside an unknown block");
				return "an unknown block"; 
			}
		} else {
			System.err.println("PrisonPearl " + id + " has no player, item, nor location");
			return "unknown"; 
		}
	}
	
	public Location getLocation() {
		if (player != null) {
			return player.getLocation().add(0, .5, 0);
		} else if (item != null) {
			return item.getLocation();
		} else if (blocklocation != null) {
			return blocklocation;
		} else {
			throw new RuntimeException("PrisonPearl " + id + " has no player, item, nor location");
		}
	}
	
	public String describeLocation() {
		Location loc = getLocation();
		Vector vec = loc.toVector();
		String str = loc.getWorld().getName() + " " + vec.getBlockX() + " " + vec.getBlockY() + " " + vec.getBlockZ();
		
		return "held by " + getHolderName() + " at " + str;
	}
	
	public boolean verifyLocation() {
		if (item != null) {
			Chunk chunk = item.getLocation().getChunk();
			for (Entity entity : chunk.getEntities()) {
				if (entity == item)
					return true;
			}
			
{'fraction_non_alphanumeric': 0.11591507825817449, 'fraction_numerical': 0.00046490004649000463, 'mean_word_length': 3.8308383233532934, 'pattern_counts': {'":': 0, '<': 5, '<?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': '6533729', 'n_tokens_mistral': 2360, 'n_tokens_neox': 2009, 'n_words': 551}