forked from SteamWar/SteamWar
129 lines
3.3 KiB
Java
129 lines
3.3 KiB
Java
/*
|
|
* This file is a part of the SteamWar software.
|
|
*
|
|
* Copyright (C) 2024 SteamWar.de-Serverteam
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU Affero General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU Affero General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
package de.steamwar.bausystem.region;
|
|
|
|
import com.sk89q.worldedit.EditSession;
|
|
import de.steamwar.bausystem.region.flags.Flag;
|
|
import lombok.NonNull;
|
|
import org.bukkit.Location;
|
|
|
|
import java.io.File;
|
|
import java.util.Optional;
|
|
|
|
public final class FixedGlobalRegion implements Region {
|
|
|
|
public static final FixedGlobalRegion INSTANCE = new FixedGlobalRegion();
|
|
|
|
private static final Point MIN_POINT = new Point(Integer.MIN_VALUE, Integer.MIN_VALUE, Integer.MIN_VALUE);
|
|
private static final Point MAX_POINT = new Point(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE);
|
|
|
|
private final FlagStorage FLAG_STORAGE = FixedFlagStorage.createFromRegion(this); // TODO: Update to either File or Region creation!
|
|
|
|
private FixedGlobalRegion() {
|
|
}
|
|
|
|
@Override
|
|
public RegionType getType() {
|
|
return RegionType.GLOBAL;
|
|
}
|
|
|
|
@Override
|
|
public <T extends Enum<T> & Flag.Value<T>> RegionFlagPolicy hasFlag(@NonNull Flag<T> flag) {
|
|
if (flag.oneOf(Flag.TNT, Flag.FIRE, Flag.FREEZE, Flag.ITEMS, Flag.NO_GRAVITY)) {
|
|
return RegionFlagPolicy.WRITABLE;
|
|
}
|
|
return RegionFlagPolicy.NOT_APPLICABLE;
|
|
}
|
|
|
|
@Override
|
|
public <T extends Enum<T> & Flag.Value<T>> boolean setFlag(@NonNull Flag<T> flag, T value) {
|
|
return hasFlag(flag).isWritable() && FLAG_STORAGE.set(flag, value);
|
|
}
|
|
|
|
@Override
|
|
public <T extends Enum<T> & Flag.Value<T>> Optional<T> getFlag(@NonNull Flag<T> flag) {
|
|
if (hasFlag(flag).isReadable()) {
|
|
return Optional.ofNullable(FLAG_STORAGE.get(flag));
|
|
} else {
|
|
return Optional.empty();
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public Point getMinPoint() {
|
|
return MIN_POINT;
|
|
}
|
|
|
|
@Override
|
|
public Point getMaxPoint() {
|
|
return MAX_POINT;
|
|
}
|
|
|
|
@Override
|
|
public boolean inRegion(Location location) {
|
|
return true;
|
|
}
|
|
|
|
@Override
|
|
public Inner getBuildArea() {
|
|
return Inner.EMPTY;
|
|
}
|
|
|
|
@Override
|
|
public Inner getTestblockArea() {
|
|
return Inner.EMPTY;
|
|
}
|
|
|
|
@Override
|
|
public Optional<File> getGameModeConfig() {
|
|
return Optional.empty();
|
|
}
|
|
|
|
@Override
|
|
public Optional<EditSession> copy() {
|
|
return Optional.empty();
|
|
}
|
|
|
|
@Override
|
|
public boolean backup(boolean automatic) {
|
|
return false;
|
|
}
|
|
|
|
@Override
|
|
public void reset() {
|
|
|
|
}
|
|
|
|
@Override
|
|
public void remember(EditSession editSession) {
|
|
|
|
}
|
|
|
|
@Override
|
|
public boolean undo() {
|
|
return false;
|
|
}
|
|
|
|
@Override
|
|
public boolean redo() {
|
|
return false;
|
|
}
|
|
}
|