diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionType.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionType.java
index fd16e54d..9d58655b 100644
--- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionType.java
+++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionType.java
@@ -28,6 +28,11 @@ public enum RegionType {
GLOBAL(true),
NORMAL(false),
+
+ SPAWN(false),
+ SPAWN_PATH(false),
+ SPAWN_EXTENSION(false),
+ PATH(false),
;
private final boolean global;
diff --git a/BauSystem/BauSystem_RegionDynamic/build.gradle.kts b/BauSystem/BauSystem_RegionDynamic/build.gradle.kts
index b33f5f0a..26348a9e 100644
--- a/BauSystem/BauSystem_RegionDynamic/build.gradle.kts
+++ b/BauSystem/BauSystem_RegionDynamic/build.gradle.kts
@@ -43,5 +43,4 @@ dependencies {
compileOnly(libs.fawe18)
implementation(libs.luaj)
- implementation(files("$projectDir/../libs/YAPION-SNAPSHOT.jar"))
}
diff --git a/BauSystem/BauSystem_RegionDynamic/src/de/steamwar/bausystem/region/DynamicRegionSystem.java b/BauSystem/BauSystem_RegionDynamic/src/de/steamwar/bausystem/region/DynamicRegionSystem.java
index e9d8a972..374a54d5 100644
--- a/BauSystem/BauSystem_RegionDynamic/src/de/steamwar/bausystem/region/DynamicRegionSystem.java
+++ b/BauSystem/BauSystem_RegionDynamic/src/de/steamwar/bausystem/region/DynamicRegionSystem.java
@@ -66,9 +66,7 @@ public class DynamicRegionSystem implements RegionSystem {
if (tile.isEmpty()) return DynamicGlobalRegion.INSTANCE;
UUID uuid = tileMap.get(tile.get());
if (uuid == null) return DynamicGlobalRegion.INSTANCE;
- Region region = regionMap.get(uuid);
- if (region == null) return DynamicGlobalRegion.INSTANCE;
- return region;
+ return regionMap.getOrDefault(uuid, DynamicGlobalRegion.INSTANCE);
}
@Override
diff --git a/BauSystem/BauSystem_RegionDynamic/src/de/steamwar/bausystem/region/dynamic/RegionDataRepository.java b/BauSystem/BauSystem_RegionDynamic/src/de/steamwar/bausystem/region/dynamic/RegionDataRepository.java
new file mode 100644
index 00000000..fb81ec95
--- /dev/null
+++ b/BauSystem/BauSystem_RegionDynamic/src/de/steamwar/bausystem/region/dynamic/RegionDataRepository.java
@@ -0,0 +1,100 @@
+/*
+ * This file is a part of the SteamWar software.
+ *
+ * Copyright (C) 2020 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 .
+ */
+
+package de.steamwar.bausystem.region.dynamic;
+
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParser;
+import de.steamwar.bausystem.region.FlagStorage;
+import de.steamwar.bausystem.region.RegionBackups;
+import de.steamwar.bausystem.region.flags.Flag;
+import lombok.NonNull;
+import lombok.SneakyThrows;
+import lombok.experimental.UtilityClass;
+import org.bukkit.Bukkit;
+
+import javax.annotation.Nullable;
+import java.io.File;
+import java.io.FileReader;
+import java.time.format.DateTimeFormatter;
+import java.util.List;
+import java.util.Optional;
+
+@UtilityClass
+public class RegionDataRepository {
+
+ private static File regionDataFolder = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "regions");
+
+ static {
+ regionDataFolder.mkdirs();
+ }
+
+ public File getRegionDirectory(DynamicRegion region) {
+ File file = new File(regionDataFolder, region.getID().toString());
+ file.mkdirs();
+ return file;
+ }
+
+ public void loadFlagStorage(DynamicRegion region, FlagStorage storage) {
+ File file = getRegionDirectory(region);
+ file = new File(file, "flags.json");
+ loadFlagStorage(file, storage);
+ }
+
+ @SneakyThrows
+ private void loadFlagStorage(File file, FlagStorage storage) {
+ JsonObject jsonObject = JsonParser.parseReader(new FileReader(file)).getAsJsonObject();
+ for (Flag flag : Flag.getFlags()) {
+ Flag.Value> value;
+ try {
+ value = flag.valueOfValue(jsonObject.get(flag.name()).getAsString());
+ } catch (IllegalArgumentException e) {
+ continue;
+ }
+ storage.getBackedMap().put(flag, value);
+ }
+ }
+
+ private static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy.MM.dd'_'HH:mm:ss");
+ public RegionBackups getBackups(DynamicRegion region) {
+ if (region.getType().isGlobal()) {
+ return RegionBackups.EMPTY;
+ }
+
+ File directory = new File(getRegionDirectory(region), "backup");
+ directory.mkdirs();
+ return new RegionBackups() {
+ @Override
+ public Optional create(BackupType backupType) {
+ return Optional.empty();
+ }
+
+ @Override
+ public @NonNull List list() {
+ return List.of();
+ }
+
+ @Nullable
+ @Override
+ public Backup get(String name) {
+ return null;
+ }
+ };
+ }
+}