forked from SteamWar/SteamWar
88 lines
2.7 KiB
Java
88 lines
2.7 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.regionnew;
|
|
|
|
import org.bukkit.Location;
|
|
|
|
import java.lang.reflect.InvocationTargetException;
|
|
import java.util.Optional;
|
|
import java.util.stream.Stream;
|
|
|
|
public interface RegionSystem {
|
|
|
|
RegionSystem REGION_SYSTEM = init();
|
|
|
|
void load();
|
|
void save();
|
|
|
|
Region getGlobalRegion();
|
|
|
|
Region get(Location location);
|
|
Optional<Region> getRegion(String name);
|
|
|
|
Stream<Region> getRegions();
|
|
|
|
boolean isModular();
|
|
|
|
private static RegionSystem init() {
|
|
try {
|
|
return (RegionSystem) Class.forName("de.steamwar.bausystem.regionnew.FixedRegionSystem").getConstructor().newInstance();
|
|
} catch (ClassNotFoundException | NoSuchMethodException | InstantiationException | IllegalAccessException |
|
|
InvocationTargetException e) {
|
|
return new RegionSystem() {
|
|
@Override
|
|
public void load() {
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
|
|
@Override
|
|
public void save() {
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
|
|
@Override
|
|
public Region getGlobalRegion() {
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
|
|
@Override
|
|
public Region get(Location location) {
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
|
|
@Override
|
|
public Optional<Region> getRegion(String name) {
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
|
|
@Override
|
|
public Stream<Region> getRegions() {
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
|
|
@Override
|
|
public boolean isModular() {
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
};
|
|
}
|
|
}
|
|
}
|