SteamWar/BauSystem2.0
Archiviert
12
0

Add PrototypeLoader.loadedVersion

Add RegionLoader.loadedVersion
Dieser Commit ist enthalten in:
yoyosource 2021-05-05 12:18:36 +02:00
Ursprung 23fdcd132a
Commit ccf1e21287
4 geänderte Dateien mit 16 neuen und 0 gelöschten Zeilen

Datei anzeigen

@ -33,6 +33,7 @@ import java.io.IOException;
@UtilityClass @UtilityClass
public class PrototypeLoader { public class PrototypeLoader {
private int loadedVersion = 0;
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() {
@ -43,6 +44,12 @@ public class PrototypeLoader {
throw new SecurityException(e.getMessage(), e); throw new SecurityException(e.getMessage(), e);
} }
int currentVersion = yapionObject.getPlainValue("@version");
if (currentVersion != loadedVersion && loadedVersion != 0) {
throw new SecurityException("Version was not the specified version needed.");
}
loadedVersion = currentVersion;
yapionObject.forEach((key, yapionAnyType) -> { yapionObject.forEach((key, yapionAnyType) -> {
if (yapionAnyType instanceof YAPIONObject) { if (yapionAnyType instanceof YAPIONObject) {
new Prototype(key, (YAPIONObject) yapionAnyType); new Prototype(key, (YAPIONObject) yapionAnyType);

Datei anzeigen

@ -37,6 +37,7 @@ import java.io.IOException;
@UtilityClass @UtilityClass
public class RegionLoader { public class RegionLoader {
private int loadedVersion = 0;
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");
@ -56,6 +57,12 @@ public class RegionLoader {
throw new SecurityException(e.getMessage(), e); throw new SecurityException(e.getMessage(), e);
} }
int currentVersion = yapionObject.getPlainValue("@version");
if (currentVersion != loadedVersion && loadedVersion != 0) {
throw new SecurityException("Version was not the specified version needed.");
}
loadedVersion = currentVersion;
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();
try (BufferedInputStream bufferedInputStream = new BufferedInputStream(new FileInputStream(optionsFile))) { try (BufferedInputStream bufferedInputStream = new BufferedInputStream(new FileInputStream(optionsFile))) {

Datei anzeigen

@ -1,4 +1,5 @@
{ {
@version(1)
wg{ wg{
displayName(WarGear) displayName(WarGear)
schematic(sections4/WGArena.schem) schematic(sections4/WGArena.schem)

Datei anzeigen

@ -1,4 +1,5 @@
{ {
@version(1)
wg11{ wg11{
minX(-188) minX(-188)
minY(1) minY(1)