SteamWar/BauSystem2.0
Archiviert
12
0

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	BauSystem_Main/src/BauSystem.properties
Dieser Commit ist enthalten in:
Chaoscaot 2021-05-10 20:55:09 +02:00
Commit 97eeb78d03
11 geänderte Dateien mit 149 neuen und 84 gelöschten Zeilen

Datei anzeigen

@ -1,23 +1,7 @@
#
# This file is a part of the SteamWar software.
#
# Copyright (C) 2021 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/>.
#
PREFIX = §eBau§8System §8» PREFIX = §eBau§8System §8»
TIME = HH:mm:ss
DATE = ........
# Permission # Permission
PERMISSION_WORLD=Einstellungen vornehmen PERMISSION_WORLD=Einstellungen vornehmen
PERMISSION_WORLD_EDIT=WorldEdit verwenden PERMISSION_WORLD_EDIT=WorldEdit verwenden
@ -25,6 +9,7 @@ PERMISSION_CHANGE_YOU_ENABLE=§aDer Spieler darf nun {0}
PERMISSION_CHANGE_YOU_DISABLE=§cDer Spieler darf nun nicht mehr {0} PERMISSION_CHANGE_YOU_DISABLE=§cDer Spieler darf nun nicht mehr {0}
PERMISSION_CHANGE_OTHER_ENABLE=§aDu kannst nun auf der Welt von §6{0} §a{1} PERMISSION_CHANGE_OTHER_ENABLE=§aDu kannst nun auf der Welt von §6{0} §a{1}
PERMISSION_CHANGE_OTHER_DISABLE=§cDu kannst nun nicht mehr auf der Welt von §6{0} §c{1} PERMISSION_CHANGE_OTHER_DISABLE=§cDu kannst nun nicht mehr auf der Welt von §6{0} §c{1}
# Feature # Feature
FEATURE_OTHER_ITEMS_TELEPORT_GUI_NAME=Teleportieren FEATURE_OTHER_ITEMS_TELEPORT_GUI_NAME=Teleportieren
FEATURE_OTHER_ITEMS_TELEPORT_PLAYER_OFFLINE=§cDer Spieler ist Offline FEATURE_OTHER_ITEMS_TELEPORT_PLAYER_OFFLINE=§cDer Spieler ist Offline
@ -37,6 +22,17 @@ FEATURE_TRACER_GUI_AUTO_TRACE_INACTIVE=§eAuto-Tracer Aktivieren
FEATURE_TRACER_GUI_AUTO_TRACE_ACTIVE=§eAuto-Tracer Deaktivieren FEATURE_TRACER_GUI_AUTO_TRACE_ACTIVE=§eAuto-Tracer Deaktivieren
FEATURE_TRACER_GUI_SHOW_GUI=§eTrace Show Gui FEATURE_TRACER_GUI_SHOW_GUI=§eTrace Show Gui
FEATURE_TRACER_GUI_DELETE=§eTrace Löschen FEATURE_TRACER_GUI_DELETE=§eTrace Löschen
# Scoreboard
SCOREBOARD_TIME = Uhrzeit
SCOREBOARD_REGION = Region
SCOREBOARD_TRACE = Trace
SCOREBOARD_LOADER = Loader
SCOREBOARD_TPS = TPS
SCOREBOARD_TRACE_TICKS = Ticks
SCOREBOARD_TRACE_TNT_COUNT = Anzahl TNT
# Flags # Flags
FLAG_COLOR=Color FLAG_COLOR=Color
FLAG_TNT=TNT FLAG_TNT=TNT
@ -45,6 +41,15 @@ FLAG_FREEZE=Freeze
FLAG_PROTECT=Protect FLAG_PROTECT=Protect
FLAG_FIRE_ALLOW=§can FLAG_FIRE_ALLOW=§can
FLAG_FIRE_DENY=§aaus FLAG_FIRE_DENY=§aaus
FLAG_COLOR = Color
FLAG_TNT = TNT
FLAG_FIRE = Fire
FLAG_DAMAGE = Damage
FLAG_FREEZE = Freeze
FLAG_PROTECT = Protect
FLAG_FIRE_ALLOW = §can
FLAG_FIRE_DENY = §aaus
FLAG_FREEZE_ACTIVE = §aan FLAG_FREEZE_ACTIVE = §aan
FLAG_FREEZE_INACTIVE = §aaus FLAG_FREEZE_INACTIVE = §aaus
@ -56,7 +61,42 @@ FLAG_TNT_ALLOW = §aan
FLAG_TNT_DENY = §caus FLAG_TNT_DENY = §caus
FLAG_TNT_ONLY_TB = §7Kein §eBaurahmen FLAG_TNT_ONLY_TB = §7Kein §eBaurahmen
FLAG_DAMAGE_ALLOW = §aan
FLAG_DAMAGE_DENY = §caus
FLAG_COLOR_WHITE = §fWeiß
FLAG_COLOR_ORANGE = §6Orange
FLAG_COLOR_MAGENTA = §dMagenta
FLAG_COLOR_LIGHT-BLUE = §bHellblau
FLAG_COLOR_YELLOW = §eGelb
FLAG_COLOR_LIME = §aHellgrün
## This cannot be converted
FLAG_COLOR_PINK = §ePink
FLAG_COLOR_GRAY = §8Grau
FLAG_COLOR_LIGHT-GRAY = §7Hellgrau
FLAG_COLOR_CYAN = §3Cyan
FLAG_COLOR_PURPLE = §5Lila
FLAG_COLOR_BLUE = §1Blau
## This cannot be converted
FLAG_COLOR_BROWN = §eBraun
FLAG_COLOR_GREEN = §2Grün
FLAG_COLOR_RED = §cRot
FLAG_COLOR_BLACK = §0Schwarz
# Region # Region
REGION_TYPE_NORMAL = Normal REGION_TYPE_NORMAL = Normal
REGION_TYPE_BUILD = Baubereich REGION_TYPE_BUILD = Baubereich
REGION_TYPE_ONLY_TB = Testblock REGION_TYPE_ONLY_TB = Testblock
# Trace
TRACE_RECORD = §aan
TRACE_RECORD_AUTO = §an
TRACE_IDLE = §caus
TRACE_IDLE_AUTO = §eauto
# Loader
LOADER_OFF = §caus
LOADER_SETUP = §eSetup
LOADER_RUNNING = §aRunning
LOADER_PAUSE = §7Pause
LOADER_END = §8Finished

Datei anzeigen

@ -208,10 +208,10 @@ public class Loader implements Listener {
@AllArgsConstructor @AllArgsConstructor
public enum Stage implements EnumDisplay { public enum Stage implements EnumDisplay {
SETUP("§eSetup"), SETUP("LOADER_SETUP"),
RUNNING("§aRunning"), RUNNING("LOADER_RUNNING"),
PAUSE("§7Pause"), PAUSE("LOADER_PAUSE"),
END("§8Finished"); END("LOADER_END");
@Getter @Getter
private String chatValue; private String chatValue;

Datei anzeigen

@ -46,7 +46,7 @@ public class TracerBauGuiItem extends BauGuiItem {
@Override @Override
public ItemStack getItem(Player player) { public ItemStack getItem(Player player) {
return new SWItem(Material.OBSERVER, ColorConfig.HIGHLIGHT + "Tracer", Arrays.asList(ColorConfig.BASE + "Status: " + RecordStateMachine.getRecordStatus().getName()), false, clickType -> { return new SWItem(Material.OBSERVER, ColorConfig.HIGHLIGHT + "Tracer", Arrays.asList(ColorConfig.BASE + "Status: " + BauSystem.MESSAGE.parse(RecordStateMachine.getRecordStatus().getName(), player)), false, clickType -> {
}).getItemStack(); }).getItemStack();
} }

Datei anzeigen

@ -21,10 +21,10 @@ package de.steamwar.bausystem.features.tracer.record;
public enum RecordStatus { public enum RecordStatus {
RECORD("§aan", true, "§cTNT-Tracer muss gestoppt werden"), RECORD("TRACE_RECORD", true, "§cTNT-Tracer muss gestoppt werden"),
RECORD_AUTO("§aan", true, "§cTNT-Tracer darf nicht aufnehmen"), RECORD_AUTO("TRACE_RECORD_AUTO", true, "§cTNT-Tracer darf nicht aufnehmen"),
IDLE("§caus", false, "§cAuto-Tracer gestoppt"), IDLE("TRACE_IDLE", false, "§cAuto-Tracer gestoppt"),
IDLE_AUTO("§eauto", false, "§aAuto-Tracer gestartet"); IDLE_AUTO("TRACE_IDLE_AUTO", false, "§aAuto-Tracer gestartet");
String name; String name;
boolean tracing; boolean tracing;

Datei anzeigen

@ -1,5 +1,6 @@
package de.steamwar.bausystem.features.world; package de.steamwar.bausystem.features.world;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.loader.Loader; import de.steamwar.bausystem.features.loader.Loader;
import de.steamwar.bausystem.features.tpslimit.TPSLimitUtils; import de.steamwar.bausystem.features.tpslimit.TPSLimitUtils;
import de.steamwar.bausystem.features.tpslimit.TPSWarpUtils; import de.steamwar.bausystem.features.tpslimit.TPSWarpUtils;
@ -46,31 +47,37 @@ public class BauScoreboard implements Listener {
private HashMap<String, Integer> sidebar(Player p) { private HashMap<String, Integer> sidebar(Player p) {
Region region = Region.getRegion(p.getLocation()); Region region = Region.getRegion(p.getLocation());
String colorCode = BauSystem.MESSAGE.parse(region.get(Flag.COLOR).getChatValue(), p).substring(0, 2);
List<String> strings = new ArrayList<>(); List<String> strings = new ArrayList<>();
strings.add("§1"); strings.add("§1");
strings.add("§eUhrzeit§8: §7" + new SimpleDateFormat("HH:mm:ss").format(Calendar.getInstance().getTime())); strings.add(colorCode + BauSystem.MESSAGE.parse("SCOREBOARD_TIME", p) + "§8: §7" + new SimpleDateFormat(BauSystem.MESSAGE.parse("TIME", p)).format(Calendar.getInstance().getTime()));
if (GlobalRegion.getInstance() != region) { if (GlobalRegion.getInstance() != region) {
strings.add("§eRegion§8: §7" + region.getDisplayName()); strings.add(colorCode + BauSystem.MESSAGE.parse("SCOREBOARD_REGION", p) + "§8: §7" + region.getDisplayName());
} }
strings.add("§2"); strings.add("§2");
strings.add("§eTNT§8: " + region.get(Flag.TNT).getChatValue()); for (Flag flag : Flag.getFlags()) {
strings.add("§eFreeze§8: " + region.get(Flag.FREEZE).getChatValue()); if (!flag.getRegionPredicate().test(region)) {
strings.add("§eFire§8: " + region.get(Flag.FIRE).getChatValue()); continue;
if (region.getFloorLevel() != 0) { }
strings.add("§eProtect§8: " + region.get(Flag.PROTECT).getChatValue()); String message = BauSystem.MESSAGE.parse(region.get(flag).getChatValue(), p).replace("§e", colorCode);
strings.add(colorCode + BauSystem.MESSAGE.parse(flag.getChatValue(), p) + "§8: " + message);
} }
strings.add("§eTrace§8: " + RecordStateMachine.getRecordStatus().getName());
strings.add("§3");
strings.add(colorCode + BauSystem.MESSAGE.parse("SCOREBOARD_TRACE", p) + "§8: " + BauSystem.MESSAGE.parse(RecordStateMachine.getRecordStatus().getName(), p));
Loader loader = Loader.getLoader(p); Loader loader = Loader.getLoader(p);
strings.add("§eLoader§8: " + (loader != null ? ("§a" + loader.getStage().getChatValue()) : "§caus")); strings.add(colorCode + BauSystem.MESSAGE.parse("SCOREBOARD_LOADER", p) + "§8: " + BauSystem.MESSAGE.parse(loader != null ? loader.getStage().getChatValue() : "LOADER_OFF", p));
if (RecordStateMachine.getRecordStatus().isTracing()) { if (RecordStateMachine.getRecordStatus().isTracing()) {
strings.add("§3"); strings.add("§4");
strings.add("§eTicks§8: §7" + traceTicks()); strings.add(colorCode + BauSystem.MESSAGE.parse("SCOREBOARD_TRACE_TICKS", p) + "§8: §7" + traceTicks());
strings.add("§eAnzahl TNT§8: §7" + RecordStateMachine.size()); strings.add(colorCode + BauSystem.MESSAGE.parse("SCOREBOARD_TRACE_TNT_COUNT", p) + "§8: §7" + RecordStateMachine.size());
} }
strings.add("§4"); strings.add("§5");
strings.add("§eTPS§8: " + tpsColor() + TPSWarpUtils.getTps(TPSWatcher.TPSType.ONE_SECOND) + tpsLimit()); strings.add(colorCode + BauSystem.MESSAGE.parse("SCOREBOARD_TPS", p) + "§8 " + tpsColor() + TPSWarpUtils.getTps(TPSWatcher.TPSType.ONE_SECOND) + tpsLimit());
int i = strings.size(); int i = strings.size();
HashMap<String, Integer> result = new HashMap<>(); HashMap<String, Integer> result = new HashMap<>();

Datei anzeigen

@ -195,9 +195,12 @@ public class Region {
} }
private boolean inRegion(Location location, Point minPoint, Point maxPoint) { private boolean inRegion(Location location, Point minPoint, Point maxPoint) {
return location.getBlockX() >= minPoint.getX() && location.getBlockX() <= maxPoint.getX() && int blockX = location.getBlockX();
location.getBlockY() >= minPoint.getY() && location.getBlockY() <= maxPoint.getY() && int blockY = location.getBlockY();
location.getBlockZ() >= minPoint.getZ() && location.getBlockZ() <= maxPoint.getZ(); int blockZ = location.getBlockZ();
return blockX >= minPoint.getX() && blockX <= maxPoint.getX() &&
blockY >= minPoint.getY() && blockY <= maxPoint.getY() &&
blockZ >= minPoint.getZ() && blockZ <= maxPoint.getZ();
} }
public boolean hasType(RegionType regionType) { public boolean hasType(RegionType regionType) {

Datei anzeigen

@ -20,15 +20,27 @@ import org.bukkit.entity.Player;
public class RegionUtils { public class RegionUtils {
public void actionBar(Region region, String s) { public void actionBar(Region region, String s) {
Bukkit.getOnlinePlayers().stream().filter(player -> region.inRegion(player.getLocation(), RegionType.NORMAL, RegionExtensionType.NORMAL)).forEach(player -> player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(s))); Bukkit.getOnlinePlayers()
.stream()
.filter(player -> region.inRegion(player.getLocation(), RegionType.NORMAL, RegionExtensionType.NORMAL))
.filter(player -> !region.isGlobal() || Region.getRegion(player.getLocation()).isGlobal())
.forEach(player -> player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(s)));
} }
public static void message(Region region, String s) { public static void message(Region region, String s) {
Bukkit.getOnlinePlayers().stream().filter(player -> region.inRegion(player.getLocation(), RegionType.NORMAL, RegionExtensionType.NORMAL)).forEach(player -> player.sendMessage(s)); Bukkit.getOnlinePlayers()
.stream()
.filter(player -> region.inRegion(player.getLocation(), RegionType.NORMAL, RegionExtensionType.NORMAL))
.filter(player -> !region.isGlobal() || Region.getRegion(player.getLocation()).isGlobal())
.forEach(player -> player.sendMessage(s));
} }
public static void message(Region region, Function<Player, String> function) { public static void message(Region region, Function<Player, String> function) {
Bukkit.getOnlinePlayers().stream().filter(player -> region.inRegion(player.getLocation(), RegionType.NORMAL, RegionExtensionType.NORMAL)).forEach(player -> { Bukkit.getOnlinePlayers()
.stream()
.filter(player -> region.inRegion(player.getLocation(), RegionType.NORMAL, RegionExtensionType.NORMAL))
.filter(player -> !region.isGlobal() || Region.getRegion(player.getLocation()).isGlobal())
.forEach(player -> {
String message = function.apply(player); String message = function.apply(player);
if (message == null) { if (message == null) {
return; return;

Datei anzeigen

@ -19,9 +19,11 @@
package de.steamwar.bausystem.region.flags; package de.steamwar.bausystem.region.flags;
import de.steamwar.bausystem.region.Region;
import de.steamwar.bausystem.region.flags.flagvalues.*; import de.steamwar.bausystem.region.flags.flagvalues.*;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.Set; import java.util.Set;
import java.util.function.Predicate;
import de.steamwar.bausystem.shared.EnumDisplay; import de.steamwar.bausystem.shared.EnumDisplay;
import lombok.Getter; import lombok.Getter;
@ -29,12 +31,12 @@ import lombok.Getter;
@Getter @Getter
public enum Flag implements EnumDisplay { public enum Flag implements EnumDisplay {
COLOR("FLAG_COLOR", ColorMode.class, ColorMode.YELLOW), COLOR("FLAG_COLOR", ColorMode.class, ColorMode.YELLOW, region -> false),
TNT("FLAG_TNT", TNTMode.class, TNTMode.ONLY_TB), TNT("FLAG_TNT", TNTMode.class, TNTMode.ONLY_TB, region -> true),
FIRE("FLAG_FIRE", FireMode.class, FireMode.ALLOW), FIRE("FLAG_FIRE", FireMode.class, FireMode.ALLOW, region -> true),
DAMAGE("FLAG_DAMAGE", DamageMode.class, DamageMode.ALLOW), DAMAGE("FLAG_DAMAGE", DamageMode.class, DamageMode.ALLOW, region -> false),
FREEZE("FLAG_FREEZE", FreezeMode.class, FreezeMode.INACTIVE), FREEZE("FLAG_FREEZE", FreezeMode.class, FreezeMode.INACTIVE, region -> true),
PROTECT("FLAG_PROTECT", ProtectMode.class, ProtectMode.INACTIVE); PROTECT("FLAG_PROTECT", ProtectMode.class, ProtectMode.INACTIVE, region -> region.getFloorLevel() != 0);
@Getter @Getter
private static final Set<Flag> flags; private static final Set<Flag> flags;
@ -47,20 +49,20 @@ public enum Flag implements EnumDisplay {
private final Class<? extends Value<?>> valueType; private final Class<? extends Value<?>> valueType;
private final Flag.Value<?> defaultValue; private final Flag.Value<?> defaultValue;
private final Value<?>[] values; private final Value<?>[] values;
private final Predicate<Region> regionPredicate;
<T extends Enum<T> & Value<T>> Flag(String chatValue, final Class<? extends Value<T>> valueType, final Flag.Value<T> defaultValue) { <T extends Enum<T> & Value<T>> Flag(String chatValue, final Class<? extends Value<T>> valueType, final Flag.Value<T> defaultValue, Predicate<Region> regionPredicate) {
this.chatValue = chatValue; this.chatValue = chatValue;
this.valueType = valueType; this.valueType = valueType;
this.defaultValue = defaultValue; this.defaultValue = defaultValue;
this.values = defaultValue.getValues(); this.values = defaultValue.getValues();
this.regionPredicate = regionPredicate;
} }
public Value<?> getFlagValueOf(final String name) { public Value<?> getFlagValueOf(final String name) {
return this.defaultValue.getValueOf(name); return this.defaultValue.getValueOf(name);
} }
@Override @Override
public String toString() { public String toString() {
return this.name().toLowerCase(); return this.name().toLowerCase();

Datei anzeigen

@ -27,28 +27,27 @@ import lombok.Getter;
@Getter @Getter
@AllArgsConstructor @AllArgsConstructor
public enum ColorMode implements Flag.Value<ColorMode> { public enum ColorMode implements Flag.Value<ColorMode> {
WHITE(Color.WHITE), WHITE("FLAG_COLOR_WHITE", Color.WHITE),
ORANGE(Color.ORANGE), ORANGE("FLAG_COLOR_ORANGE", Color.ORANGE),
MAGENTA(Color.MAGENTA), MAGENTA("FLAG_COLOR_MAGENTA", Color.MAGENTA),
LIGHT_BLUE(Color.LIGHT_BLUE), LIGHT_BLUE("FLAG_COLOR_LIGHT-BLUE", Color.LIGHT_BLUE),
YELLOW(Color.YELLOW), YELLOW("FLAG_COLOR_YELLOW", Color.YELLOW),
LIME(Color.LIME), LIME("FLAG_COLOR_LIME", Color.LIME),
PINK(Color.PINK), PINK("FLAG_COLOR_PINK", Color.PINK),
GRAY(Color.GRAY), GRAY("FLAG_COLOR_GRAY", Color.GRAY),
LIGHT_GRAY(Color.LIGHT_GRAY), LIGHT_GRAY("FLAG_COLOR_LIGHT-GRAY", Color.LIGHT_GRAY),
CYAN(Color.CYAN), CYAN("FLAG_COLOR_CYAN", Color.CYAN),
PURPLE(Color.PURPLE), PURPLE("FLAG_COLOR_PURPLE", Color.PURPLE),
BLUE(Color.BLUE), BLUE("FLAG_COLOR_BLUE", Color.BLUE),
BROWN(Color.BROWN), BROWN("FLAG_COLOR_BROWN", Color.BROWN),
GREEN(Color.GREEN), GREEN("FLAG_COLOR_GREEN", Color.GREEN),
RED(Color.RED), RED("FLAG_COLOR_RED", Color.RED),
BLACK(Color.BLACK); BLACK("FLAG_COLOR_BLACK", Color.BLACK);
private static ColorMode[] values; private static ColorMode[] values;
private final String chatValue;
private final Color color; private final Color color;
private final String chatValue = name();
@Override @Override
public ColorMode[] getValues() { public ColorMode[] getValues() {
if (ColorMode.values == null) { if (ColorMode.values == null) {

Datei anzeigen

@ -22,6 +22,8 @@ package de.steamwar.bausystem.region.loader;
import de.steamwar.bausystem.region.Prototype; import de.steamwar.bausystem.region.Prototype;
import lombok.experimental.UtilityClass; import lombok.experimental.UtilityClass;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import yapion.hierarchy.diff.DiffBase;
import yapion.hierarchy.diff.YAPIONDiff;
import yapion.hierarchy.types.YAPIONObject; import yapion.hierarchy.types.YAPIONObject;
import yapion.parser.YAPIONParser; import yapion.parser.YAPIONParser;
@ -33,7 +35,7 @@ import java.io.IOException;
@UtilityClass @UtilityClass
public class PrototypeLoader { public class PrototypeLoader {
private int loadedVersion = 0; private YAPIONObject loaded = null;
public static final File file = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "prototypes.yapion"); public static final File file = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "prototypes.yapion");
public void load() { public void load() {
@ -44,11 +46,10 @@ public class PrototypeLoader {
throw new SecurityException(e.getMessage(), e); throw new SecurityException(e.getMessage(), e);
} }
int currentVersion = yapionObject.getPlainValueOrDefault("@version", -1); if (loaded != null && new YAPIONDiff(loaded, yapionObject).getDiffs().stream().anyMatch(diffBase -> !(diffBase instanceof DiffBase.DiffChange))) {
if (currentVersion != loadedVersion && loadedVersion != 0) {
throw new SecurityException("Version was not the specified version needed."); throw new SecurityException("Version was not the specified version needed.");
} }
loadedVersion = currentVersion; loaded = yapionObject;
yapionObject.forEach((key, yapionAnyType) -> { yapionObject.forEach((key, yapionAnyType) -> {
if (yapionAnyType instanceof YAPIONObject) { if (yapionAnyType instanceof YAPIONObject) {

Datei anzeigen

@ -24,6 +24,8 @@ import de.steamwar.bausystem.region.GlobalRegion;
import de.steamwar.bausystem.region.Prototype; import de.steamwar.bausystem.region.Prototype;
import lombok.experimental.UtilityClass; import lombok.experimental.UtilityClass;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import yapion.hierarchy.diff.DiffBase;
import yapion.hierarchy.diff.YAPIONDiff;
import yapion.hierarchy.output.FileOutput; import yapion.hierarchy.output.FileOutput;
import yapion.hierarchy.types.YAPIONObject; import yapion.hierarchy.types.YAPIONObject;
import yapion.hierarchy.types.YAPIONType; import yapion.hierarchy.types.YAPIONType;
@ -37,7 +39,7 @@ import java.io.IOException;
@UtilityClass @UtilityClass
public class RegionLoader { public class RegionLoader {
private int loadedVersion = 0; private YAPIONObject loaded = null;
private YAPIONObject optionsYapionObject; private YAPIONObject optionsYapionObject;
public static final File file = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "regions.yapion"); public static final File file = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "regions.yapion");
@ -57,11 +59,10 @@ public class RegionLoader {
throw new SecurityException(e.getMessage(), e); throw new SecurityException(e.getMessage(), e);
} }
int currentVersion = yapionObject.getPlainValueOrDefault("@version", -1); if (loaded != null && new YAPIONDiff(loaded, yapionObject).getDiffs().stream().anyMatch(diffBase -> !(diffBase instanceof DiffBase.DiffChange))) {
if (currentVersion != loadedVersion && loadedVersion != 0) {
throw new SecurityException("Version was not the specified version needed."); throw new SecurityException("Version was not the specified version needed.");
} }
loadedVersion = currentVersion; loaded = yapionObject;
File optionsFile = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "options.yapion"); File optionsFile = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "options.yapion");
optionsYapionObject = new YAPIONObject(); optionsYapionObject = new YAPIONObject();