diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/BackupScheduler.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/BackupScheduler.java index eb57e09f..512c0199 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/BackupScheduler.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/BackupScheduler.java @@ -1,5 +1,6 @@ package de.steamwar.bausystem.region; +import com.sk89q.worldedit.EditSession; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.region.flags.ChangedMode; import de.steamwar.bausystem.region.flags.Flag; @@ -21,7 +22,8 @@ public class BackupScheduler implements Enable { @Override public void run() { Iterator regionsToBackup = RegionSystem.INSTANCE.getRegions() - .filter(region -> region.isFlag(Flag.CHANGED, ChangedMode.HAS_CHANGE)) + .filter(region -> region.getFlags().has(Flag.CHANGED).isReadable()) + .filter(region -> region.getFlags().get(Flag.CHANGED).get() == ChangedMode.HAS_CHANGE) .iterator(); if (!regionsToBackup.hasNext()) return; doBackup(regionsToBackup); @@ -39,9 +41,10 @@ public class BackupScheduler implements Enable { } Region region = regionsToBackup.next(); - if (region.backup(true)) { - region.setFlag(Flag.CHANGED, ChangedMode.NO_CHANGE); - } + EditSession editSession = region.getArea() + .copy(false); + // TODO: Implement saving EditSession to schematic! + region.getFlags().set(Flag.CHANGED, ChangedMode.NO_CHANGE); } }.runTaskTimer(BauSystem.getInstance(), 0, 20 * 60); } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Color.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Color.java deleted file mode 100644 index 72052d74..00000000 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Color.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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 . - */ - -package de.steamwar.bausystem.region; - -import lombok.Getter; -import lombok.RequiredArgsConstructor; - -@RequiredArgsConstructor -@Getter -public enum Color { - WHITE('f'), - ORANGE('6'), - MAGENTA('5'), - LIGHT_BLUE('b'), - YELLOW('e'), - LIME('a'), - PINK('d'), - GRAY('8'), - LIGHT_GRAY('7'), - CYAN('3'), - PURPLE('5'), - BLUE('9'), - BROWN('e'), - GREEN('2'), - RED('c'), - BLACK('1'); - - private final char colorCode; -} diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java index d3f51f88..0b7cd049 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java @@ -61,7 +61,7 @@ public interface Region { boolean inRegion(Location location, boolean extension); - Optional copy(boolean extension); + EditSession copy(boolean extension); void reset(@Nullable SchematicNode schematicNode, boolean extension); diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/ColorMode.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/ColorMode.java index e266d874..1f7db755 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/ColorMode.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/ColorMode.java @@ -19,33 +19,32 @@ package de.steamwar.bausystem.region.flags; -import de.steamwar.bausystem.region.Color; import lombok.AllArgsConstructor; import lombok.Getter; @Getter @AllArgsConstructor public enum ColorMode implements Flag.Value { - WHITE("FLAG_COLOR_WHITE", Color.WHITE), - ORANGE("FLAG_COLOR_ORANGE", Color.ORANGE), - MAGENTA("FLAG_COLOR_MAGENTA", Color.MAGENTA), - LIGHT_BLUE("FLAG_COLOR_LIGHT_BLUE", Color.LIGHT_BLUE), - YELLOW("FLAG_COLOR_YELLOW", Color.YELLOW), - LIME("FLAG_COLOR_LIME", Color.LIME), - PINK("FLAG_COLOR_PINK", Color.PINK), - GRAY("FLAG_COLOR_GRAY", Color.GRAY), - LIGHT_GRAY("FLAG_COLOR_LIGHT_GRAY", Color.LIGHT_GRAY), - CYAN("FLAG_COLOR_CYAN", Color.CYAN), - PURPLE("FLAG_COLOR_PURPLE", Color.PURPLE), - BLUE("FLAG_COLOR_BLUE", Color.BLUE), - BROWN("FLAG_COLOR_BROWN", Color.BROWN), - GREEN("FLAG_COLOR_GREEN", Color.GREEN), - RED("FLAG_COLOR_RED", Color.RED), - BLACK("FLAG_COLOR_BLACK", Color.BLACK); + WHITE("FLAG_COLOR_WHITE", 'f'), + ORANGE("FLAG_COLOR_ORANGE", '6'), + MAGENTA("FLAG_COLOR_MAGENTA", '5'), + LIGHT_BLUE("FLAG_COLOR_LIGHT_BLUE", 'b'), + YELLOW("FLAG_COLOR_YELLOW", 'e'), + LIME("FLAG_COLOR_LIME", 'a'), + PINK("FLAG_COLOR_PINK", 'd'), + GRAY("FLAG_COLOR_GRAY", '8'), + LIGHT_GRAY("FLAG_COLOR_LIGHT_GRAY", '7'), + CYAN("FLAG_COLOR_CYAN", '3'), + PURPLE("FLAG_COLOR_PURPLE", '5'), + BLUE("FLAG_COLOR_BLUE", '9'), + BROWN("FLAG_COLOR_BROWN", 'e'), + GREEN("FLAG_COLOR_GREEN", '2'), + RED("FLAG_COLOR_RED", 'c'), + BLACK("FLAG_COLOR_BLACK", '1'); private static ColorMode[] values; private final String chatValue; - private final Color color; + private final char colorCode; @Override public ColorMode[] getValues() { diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/utils/RegionType.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/utils/RegionType.java index 79d83ff7..1ea7e577 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/utils/RegionType.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/utils/RegionType.java @@ -15,25 +15,25 @@ import java.util.function.Predicate; public enum RegionType implements EnumDisplay { NORMAL("REGION_TYPE_NORMAL", region -> true, - region -> null, - (region, extension) -> region.getMinPoint(), - (region, extension) -> region.getMaxPoint()), + Region::getArea, + (region, extension) -> region.getArea().getMinPoint(false), + (region, extension) -> region.getArea().getMaxPoint(false)), BUILD("REGION_TYPE_BUILD", region -> region.getBuildArea().isPresent(), - Region::getBuildArea, - (region, extension) -> region.getBuildArea().getMinPoint(extension), - (region, extension) -> region.getBuildArea().getMaxPoint(extension)), + region -> region.getBuildArea().get(), + (region, extension) -> region.getBuildArea().get().getMinPoint(extension), + (region, extension) -> region.getBuildArea().get().getMaxPoint(extension)), TESTBLOCK("REGION_TYPE_ONLY_TB", region -> region.getTestblockArea().isPresent(), - Region::getTestblockArea, - (region, extension) -> region.getTestblockArea().getMinPoint(extension), - (region, extension) -> region.getTestblockArea().getMaxPoint(extension)), + region -> region.getTestblockArea().get(), + (region, extension) -> region.getTestblockArea().get().getMinPoint(extension), + (region, extension) -> region.getTestblockArea().get().getMaxPoint(extension)), ; private String chatValue; private Predicate hasType; - private Function toInner; + private Function toInner; private BiFunction toMinPoint; private BiFunction toMaxPoint; }