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.plot.world;
020
021import com.plotsquared.core.location.Location;
022import com.plotsquared.core.plot.PlotArea;
023import com.plotsquared.core.plot.PlotWorld;
024import com.sk89q.worldedit.regions.CuboidRegion;
025import org.checkerframework.checker.nullness.qual.NonNull;
026import org.checkerframework.checker.nullness.qual.Nullable;
027
028import java.util.Collection;
029import java.util.Collections;
030
031/**
032 * Ordinary plot world with a single plot area
033 */
034public class StandardPlotWorld extends PlotWorld {
035
036    private final PlotArea area;
037
038    public StandardPlotWorld(final @NonNull String world, final @Nullable PlotArea area) {
039        super(world);
040        this.area = area;
041    }
042
043    @Override
044    public @Nullable PlotArea getArea(final @NonNull Location location) {
045        return this.area;
046    }
047
048    @Override
049    public @NonNull Collection<PlotArea> getAreas() {
050        if (this.area == null) {
051            return Collections.emptyList();
052        }
053        return Collections.singletonList(this.area);
054    }
055
056    @Override
057    public @NonNull Collection<PlotArea> getAreasInRegion(final @NonNull CuboidRegion region) {
058        return this.getAreas();
059    }
060
061}