Improve Region some more
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
package de.steamwar.bausystem.region;
|
package de.steamwar.bausystem.region;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.EditSession;
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.region.flags.ChangedMode;
|
import de.steamwar.bausystem.region.flags.ChangedMode;
|
||||||
import de.steamwar.bausystem.region.flags.Flag;
|
import de.steamwar.bausystem.region.flags.Flag;
|
||||||
@@ -21,7 +22,8 @@ public class BackupScheduler implements Enable {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
Iterator<Region> regionsToBackup = RegionSystem.INSTANCE.getRegions()
|
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();
|
.iterator();
|
||||||
if (!regionsToBackup.hasNext()) return;
|
if (!regionsToBackup.hasNext()) return;
|
||||||
doBackup(regionsToBackup);
|
doBackup(regionsToBackup);
|
||||||
@@ -39,9 +41,10 @@ public class BackupScheduler implements Enable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Region region = regionsToBackup.next();
|
Region region = regionsToBackup.next();
|
||||||
if (region.backup(true)) {
|
EditSession editSession = region.getArea()
|
||||||
region.setFlag(Flag.CHANGED, ChangedMode.NO_CHANGE);
|
.copy(false);
|
||||||
}
|
// TODO: Implement saving EditSession to schematic!
|
||||||
|
region.getFlags().set(Flag.CHANGED, ChangedMode.NO_CHANGE);
|
||||||
}
|
}
|
||||||
}.runTaskTimer(BauSystem.getInstance(), 0, 20 * 60);
|
}.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);
|
boolean inRegion(Location location, boolean extension);
|
||||||
|
|
||||||
Optional<EditSession> copy(boolean extension);
|
EditSession copy(boolean extension);
|
||||||
|
|
||||||
void reset(@Nullable SchematicNode schematicNode, boolean extension);
|
void reset(@Nullable SchematicNode schematicNode, boolean extension);
|
||||||
|
|
||||||
|
|||||||
@@ -19,33 +19,32 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.region.flags;
|
package de.steamwar.bausystem.region.flags;
|
||||||
|
|
||||||
import de.steamwar.bausystem.region.Color;
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public enum ColorMode implements Flag.Value<ColorMode> {
|
public enum ColorMode implements Flag.Value<ColorMode> {
|
||||||
WHITE("FLAG_COLOR_WHITE", Color.WHITE),
|
WHITE("FLAG_COLOR_WHITE", 'f'),
|
||||||
ORANGE("FLAG_COLOR_ORANGE", Color.ORANGE),
|
ORANGE("FLAG_COLOR_ORANGE", '6'),
|
||||||
MAGENTA("FLAG_COLOR_MAGENTA", Color.MAGENTA),
|
MAGENTA("FLAG_COLOR_MAGENTA", '5'),
|
||||||
LIGHT_BLUE("FLAG_COLOR_LIGHT_BLUE", Color.LIGHT_BLUE),
|
LIGHT_BLUE("FLAG_COLOR_LIGHT_BLUE", 'b'),
|
||||||
YELLOW("FLAG_COLOR_YELLOW", Color.YELLOW),
|
YELLOW("FLAG_COLOR_YELLOW", 'e'),
|
||||||
LIME("FLAG_COLOR_LIME", Color.LIME),
|
LIME("FLAG_COLOR_LIME", 'a'),
|
||||||
PINK("FLAG_COLOR_PINK", Color.PINK),
|
PINK("FLAG_COLOR_PINK", 'd'),
|
||||||
GRAY("FLAG_COLOR_GRAY", Color.GRAY),
|
GRAY("FLAG_COLOR_GRAY", '8'),
|
||||||
LIGHT_GRAY("FLAG_COLOR_LIGHT_GRAY", Color.LIGHT_GRAY),
|
LIGHT_GRAY("FLAG_COLOR_LIGHT_GRAY", '7'),
|
||||||
CYAN("FLAG_COLOR_CYAN", Color.CYAN),
|
CYAN("FLAG_COLOR_CYAN", '3'),
|
||||||
PURPLE("FLAG_COLOR_PURPLE", Color.PURPLE),
|
PURPLE("FLAG_COLOR_PURPLE", '5'),
|
||||||
BLUE("FLAG_COLOR_BLUE", Color.BLUE),
|
BLUE("FLAG_COLOR_BLUE", '9'),
|
||||||
BROWN("FLAG_COLOR_BROWN", Color.BROWN),
|
BROWN("FLAG_COLOR_BROWN", 'e'),
|
||||||
GREEN("FLAG_COLOR_GREEN", Color.GREEN),
|
GREEN("FLAG_COLOR_GREEN", '2'),
|
||||||
RED("FLAG_COLOR_RED", Color.RED),
|
RED("FLAG_COLOR_RED", 'c'),
|
||||||
BLACK("FLAG_COLOR_BLACK", Color.BLACK);
|
BLACK("FLAG_COLOR_BLACK", '1');
|
||||||
|
|
||||||
private static ColorMode[] values;
|
private static ColorMode[] values;
|
||||||
private final String chatValue;
|
private final String chatValue;
|
||||||
private final Color color;
|
private final char colorCode;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ColorMode[] getValues() {
|
public ColorMode[] getValues() {
|
||||||
|
|||||||
@@ -15,25 +15,25 @@ import java.util.function.Predicate;
|
|||||||
public enum RegionType implements EnumDisplay {
|
public enum RegionType implements EnumDisplay {
|
||||||
NORMAL("REGION_TYPE_NORMAL",
|
NORMAL("REGION_TYPE_NORMAL",
|
||||||
region -> true,
|
region -> true,
|
||||||
region -> null,
|
Region::getArea,
|
||||||
(region, extension) -> region.getMinPoint(),
|
(region, extension) -> region.getArea().getMinPoint(false),
|
||||||
(region, extension) -> region.getMaxPoint()),
|
(region, extension) -> region.getArea().getMaxPoint(false)),
|
||||||
BUILD("REGION_TYPE_BUILD",
|
BUILD("REGION_TYPE_BUILD",
|
||||||
region -> region.getBuildArea().isPresent(),
|
region -> region.getBuildArea().isPresent(),
|
||||||
Region::getBuildArea,
|
region -> region.getBuildArea().get(),
|
||||||
(region, extension) -> region.getBuildArea().getMinPoint(extension),
|
(region, extension) -> region.getBuildArea().get().getMinPoint(extension),
|
||||||
(region, extension) -> region.getBuildArea().getMaxPoint(extension)),
|
(region, extension) -> region.getBuildArea().get().getMaxPoint(extension)),
|
||||||
TESTBLOCK("REGION_TYPE_ONLY_TB",
|
TESTBLOCK("REGION_TYPE_ONLY_TB",
|
||||||
region -> region.getTestblockArea().isPresent(),
|
region -> region.getTestblockArea().isPresent(),
|
||||||
Region::getTestblockArea,
|
region -> region.getTestblockArea().get(),
|
||||||
(region, extension) -> region.getTestblockArea().getMinPoint(extension),
|
(region, extension) -> region.getTestblockArea().get().getMinPoint(extension),
|
||||||
(region, extension) -> region.getTestblockArea().getMaxPoint(extension)),
|
(region, extension) -> region.getTestblockArea().get().getMaxPoint(extension)),
|
||||||
;
|
;
|
||||||
|
|
||||||
private String chatValue;
|
private String chatValue;
|
||||||
|
|
||||||
private Predicate<Region> hasType;
|
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> toMinPoint;
|
||||||
private BiFunction<Region, Boolean, Point> toMaxPoint;
|
private BiFunction<Region, Boolean, Point> toMaxPoint;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user