package de.teleportsuite.models;

import org.bukkit.Location;
import org.bukkit.World;

public class Portal {
    private final String name;
    private final String world;
    private final int x1, y1, z1, x2, y2, z2;
    private final String targetServer;
    private final TeleportLocation destination;

    public Portal(String name, String world, int x1, int y1, int z1, int x2, int y2, int z2,
                  String targetServer, TeleportLocation destination) {
        this.name = name; this.world = world;
        this.x1 = x1; this.y1 = y1; this.z1 = z1;
        this.x2 = x2; this.y2 = y2; this.z2 = z2;
        this.targetServer = targetServer; this.destination = destination;
    }

    public boolean contains(Location loc) {
        if (!loc.getWorld().getName().equals(world)) return false;
        int bx = loc.getBlockX(), by = loc.getBlockY(), bz = loc.getBlockZ();
        return bx >= Math.min(x1,x2) && bx <= Math.max(x1,x2) &&
               by >= Math.min(y1,y2) && by <= Math.max(y1,y2) &&
               bz >= Math.min(z1,z2) && bz <= Math.max(z1,z2);
    }

    public String getName() { return name; }
    public String getWorld() { return world; }
    public String getTargetServer() { return targetServer; }
    public TeleportLocation getDestination() { return destination; }
}
