Improve Region some more
This commit is contained in:
@ -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<Region> 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);
|
||||
}
|
||||
|
||||
@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
@ -61,7 +61,7 @@ public interface Region {
|
||||
|
||||
boolean inRegion(Location location, boolean extension);
|
||||
|
||||
Optional<EditSession> copy(boolean extension);
|
||||
EditSession copy(boolean extension);
|
||||
|
||||
void reset(@Nullable SchematicNode schematicNode, boolean extension);
|
||||
|
||||
|
||||
@ -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<ColorMode> {
|
||||
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() {
|
||||
|
||||
@ -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<Region> hasType;
|
||||
private Function<Region, Region.Inner> toInner;
|
||||
private Function<Region, Region.Area> toInner;
|
||||
private BiFunction<Region, Boolean, Point> toMinPoint;
|
||||
private BiFunction<Region, Boolean, Point> toMaxPoint;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user