001/*
002 * PlotSquared, a land and world management plugin for Minecraft.
003 * Copyright (C) IntellectualSites <https://intellectualsites.com>
004 * Copyright (C) IntellectualSites team and contributors
005 *
006 * This program is free software: you can redistribute it and/or modify
007 * it under the terms of the GNU General Public License as published by
008 * the Free Software Foundation, either version 3 of the License, or
009 * (at your option) any later version.
010 *
011 * This program is distributed in the hope that it will be useful,
012 * but WITHOUT ANY WARRANTY; without even the implied warranty of
013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
014 * GNU General Public License for more details.
015 *
016 * You should have received a copy of the GNU General Public License
017 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
018 */
019package com.plotsquared.core.location;
020
021import com.intellectualsites.annotations.DoNotUse;
022import com.sk89q.worldedit.math.BlockVector3;
023import org.checkerframework.checker.nullness.qual.NonNull;
024
025/**
026 * Used internally for generation to reference locations in worlds that "don't exist yet". There is no guarantee that the world
027 * name provided by {@link UncheckedWorldLocation#getWorldName()} exists on the server.
028 *
029 * @since 6.9.0
030 */
031@DoNotUse
032public final class UncheckedWorldLocation extends Location {
033
034    private final String worldName;
035
036    /**
037     * @since 6.9.0
038     */
039    private UncheckedWorldLocation(
040            final @NonNull String worldName, final int x, final int y, final int z
041    ) {
042        super(World.nullWorld(), BlockVector3.at(x, y, z), 0f, 0f);
043        this.worldName = worldName;
044    }
045
046    /**
047     * Construct a new location with yaw and pitch equal to 0
048     *
049     * @param world World
050     * @param x     X coordinate
051     * @param y     Y coordinate
052     * @param z     Z coordinate
053     * @return New location
054     *
055     * @since 6.9.0
056     */
057    @DoNotUse
058    public static @NonNull UncheckedWorldLocation at(
059            final @NonNull String world, final int x, final int y, final int z
060    ) {
061        return new UncheckedWorldLocation(world, x, y, z);
062    }
063
064    @Override
065    @DoNotUse
066    public @NonNull String getWorldName() {
067        return this.worldName;
068    }
069
070}