SteamWar/BauSystem2.0
Archiviert
12
0

Add PrototypeLoader

Dieser Commit ist enthalten in:
yoyosource 2021-04-18 16:21:03 +02:00
Ursprung 72cfa5682c
Commit 1f0d90f7ba
5 geänderte Dateien mit 42 neuen und 7 gelöschten Zeilen

Datei anzeigen

@ -46,7 +46,7 @@ dependencies {
implementation project(":BauSystem_15")
implementation project(":BauSystem_API")
implementation 'yoyosource:YAPION:0.25.0'
implementation 'yoyosource:YAPION:0.25.1'
compileOnly 'org.projectlombok:lombok:1.18.6'
testCompileOnly 'org.projectlombok:lombok:1.18.6'

Datei anzeigen

@ -21,6 +21,7 @@ package de.steamwar.bausystem;
import de.steamwar.bausystem.config.ColorConfig;
import de.steamwar.bausystem.linkage.LinkageUtils;
import de.steamwar.bausystem.region.loader.PrototypeLoader;
import lombok.Getter;
import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin;
@ -37,6 +38,8 @@ public class BauSystem extends JavaPlugin implements Listener {
instance = this;
SWUtils.setBausystem(instance);
PrototypeLoader.load();
LinkageUtils.link();
}

Datei anzeigen

@ -62,12 +62,12 @@ public class Prototype {
floorOffset = yapionObject.getPlainValueOrDefault("floorOffset", 0);
waterOffset = yapionObject.getPlainValueOrDefault("waterOffset", 0);
if (yapionObject.hasValue("testblock", YAPIONType.OBJECT)) {
if (yapionObject.containsKey("testblock", YAPIONType.OBJECT)) {
testblock = new SubPrototype(yapionObject.getObject("testblock"));
} else {
testblock = null;
}
if (yapionObject.hasValue("build", YAPIONType.OBJECT)) {
if (yapionObject.containsKey("build", YAPIONType.OBJECT)) {
build = new SubPrototype(yapionObject.getObject("build"));
} else {
build = null;
@ -103,13 +103,13 @@ public class Prototype {
sizeY = yapionObject.getPlainValue("sizeY");
sizeZ = yapionObject.getPlainValue("sizeZ");
if (yapionObject.hasValue("schematic", String.class)) {
if (yapionObject.containsKey("schematic", String.class)) {
schematicFile = new File(yapionObject.getValue("schematic", String.class).get());
} else {
schematicFile = null;
}
if (yapionObject.hasValue("extensionX", Integer.class)) {
if (yapionObject.containsKey("extensionX", Integer.class)) {
extensionNegativeX = yapionObject.getPlainValue("extensionX");
extensionPositiveX = yapionObject.getPlainValue("extensionX");
} else {
@ -117,7 +117,7 @@ public class Prototype {
extensionPositiveX = yapionObject.getPlainValueOrDefault("extensionPositiveX", 0);
}
if (yapionObject.hasValue("extensionY", Integer.class)) {
if (yapionObject.containsKey("extensionY", Integer.class)) {
extensionNegativeY = yapionObject.getPlainValue("extensionY");
extensionPositiveY = yapionObject.getPlainValue("extensionY");
} else {
@ -125,7 +125,7 @@ public class Prototype {
extensionPositiveY = yapionObject.getPlainValueOrDefault("extensionPositiveY", 0);
}
if (yapionObject.hasValue("extensionZ", Integer.class)) {
if (yapionObject.containsKey("extensionZ", Integer.class)) {
extensionNegativeZ = yapionObject.getPlainValue("extensionZ");
extensionPositiveZ = yapionObject.getPlainValue("extensionZ");
} else {

Datei anzeigen

@ -19,8 +19,36 @@
package de.steamwar.bausystem.region.loader;
import de.steamwar.bausystem.region.Prototype;
import lombok.experimental.UtilityClass;
import org.bukkit.Bukkit;
import yapion.hierarchy.types.YAPIONObject;
import yapion.parser.YAPIONParser;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.logging.Level;
@UtilityClass
public class PrototypeLoader {
public void load() {
File file = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "prototypes.yapion");
YAPIONObject yapionObject = null;
try (BufferedInputStream bufferedInputStream = new BufferedInputStream(new FileInputStream(file))) {
yapionObject = YAPIONParser.parse(bufferedInputStream);
} catch (IOException e) {
Bukkit.getLogger().log(Level.SEVERE, e.getMessage(), e);
Bukkit.shutdown();
return;
}
yapionObject.forEach((key, yapionAnyType) -> {
if (yapionAnyType instanceof YAPIONObject) {
new Prototype(key, (YAPIONObject) yapionAnyType);
}
});
}
}

Datei anzeigen

@ -23,4 +23,8 @@ import lombok.experimental.UtilityClass;
@UtilityClass
public class RegionLoader {
public void load() {
}
}