package dev.loki.window; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; public class Window { private final Location bottomLocation; private final Location topLocation; private boolean blocked; public Window(Location bottomLocation) { this.bottomLocation = bottomLocation; this.topLocation = bottomLocation.clone().add(0, 1, 0); this.blocked = false; } public Location getBottomLocation() { return bottomLocation; } public Location getTopLocation() { return topLocation; } public Location getVaultTarget(boolean killerVault) { if (killerVault) { return bottomLocation.clone().add(0, -0.5, 0); } return topLocation.clone().add(0, 0.5, 0); } public boolean isBlocked() { return blocked; } public void setBlocked(boolean blocked) { this.blocked = blocked; } public boolean isValid() { Block bottom = bottomLocation.getBlock(); Block top = topLocation.getBlock(); return bottom.getType().isSolid() || bottom.getType() == Material.AIR; } public boolean isVaultable(PlayerContext ctx) { if (blocked && !ctx.isKiller()) return false; if (!isValid()) return false; Location playerLoc = ctx.getLocation(); return getDistance(playerLoc) <= 2.5; } public double getDistance(Location location) { return bottomLocation.distance(location); } public void reset() { this.blocked = false; } public record PlayerContext(boolean isKiller, Location location) { public boolean isKiller() { return isKiller; } public Location getLocation() { return location; } } }