Add PrototypeLoader
Dieser Commit ist enthalten in:
Ursprung
72cfa5682c
Commit
1f0d90f7ba
@ -46,7 +46,7 @@ dependencies {
|
|||||||
implementation project(":BauSystem_15")
|
implementation project(":BauSystem_15")
|
||||||
implementation project(":BauSystem_API")
|
implementation project(":BauSystem_API")
|
||||||
|
|
||||||
implementation 'yoyosource:YAPION:0.25.0'
|
implementation 'yoyosource:YAPION:0.25.1'
|
||||||
|
|
||||||
compileOnly 'org.projectlombok:lombok:1.18.6'
|
compileOnly 'org.projectlombok:lombok:1.18.6'
|
||||||
testCompileOnly 'org.projectlombok:lombok:1.18.6'
|
testCompileOnly 'org.projectlombok:lombok:1.18.6'
|
||||||
|
@ -21,6 +21,7 @@ package de.steamwar.bausystem;
|
|||||||
|
|
||||||
import de.steamwar.bausystem.config.ColorConfig;
|
import de.steamwar.bausystem.config.ColorConfig;
|
||||||
import de.steamwar.bausystem.linkage.LinkageUtils;
|
import de.steamwar.bausystem.linkage.LinkageUtils;
|
||||||
|
import de.steamwar.bausystem.region.loader.PrototypeLoader;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
@ -37,6 +38,8 @@ public class BauSystem extends JavaPlugin implements Listener {
|
|||||||
instance = this;
|
instance = this;
|
||||||
SWUtils.setBausystem(instance);
|
SWUtils.setBausystem(instance);
|
||||||
|
|
||||||
|
PrototypeLoader.load();
|
||||||
|
|
||||||
LinkageUtils.link();
|
LinkageUtils.link();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,12 +62,12 @@ public class Prototype {
|
|||||||
floorOffset = yapionObject.getPlainValueOrDefault("floorOffset", 0);
|
floorOffset = yapionObject.getPlainValueOrDefault("floorOffset", 0);
|
||||||
waterOffset = yapionObject.getPlainValueOrDefault("waterOffset", 0);
|
waterOffset = yapionObject.getPlainValueOrDefault("waterOffset", 0);
|
||||||
|
|
||||||
if (yapionObject.hasValue("testblock", YAPIONType.OBJECT)) {
|
if (yapionObject.containsKey("testblock", YAPIONType.OBJECT)) {
|
||||||
testblock = new SubPrototype(yapionObject.getObject("testblock"));
|
testblock = new SubPrototype(yapionObject.getObject("testblock"));
|
||||||
} else {
|
} else {
|
||||||
testblock = null;
|
testblock = null;
|
||||||
}
|
}
|
||||||
if (yapionObject.hasValue("build", YAPIONType.OBJECT)) {
|
if (yapionObject.containsKey("build", YAPIONType.OBJECT)) {
|
||||||
build = new SubPrototype(yapionObject.getObject("build"));
|
build = new SubPrototype(yapionObject.getObject("build"));
|
||||||
} else {
|
} else {
|
||||||
build = null;
|
build = null;
|
||||||
@ -103,13 +103,13 @@ public class Prototype {
|
|||||||
sizeY = yapionObject.getPlainValue("sizeY");
|
sizeY = yapionObject.getPlainValue("sizeY");
|
||||||
sizeZ = yapionObject.getPlainValue("sizeZ");
|
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());
|
schematicFile = new File(yapionObject.getValue("schematic", String.class).get());
|
||||||
} else {
|
} else {
|
||||||
schematicFile = null;
|
schematicFile = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (yapionObject.hasValue("extensionX", Integer.class)) {
|
if (yapionObject.containsKey("extensionX", Integer.class)) {
|
||||||
extensionNegativeX = yapionObject.getPlainValue("extensionX");
|
extensionNegativeX = yapionObject.getPlainValue("extensionX");
|
||||||
extensionPositiveX = yapionObject.getPlainValue("extensionX");
|
extensionPositiveX = yapionObject.getPlainValue("extensionX");
|
||||||
} else {
|
} else {
|
||||||
@ -117,7 +117,7 @@ public class Prototype {
|
|||||||
extensionPositiveX = yapionObject.getPlainValueOrDefault("extensionPositiveX", 0);
|
extensionPositiveX = yapionObject.getPlainValueOrDefault("extensionPositiveX", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (yapionObject.hasValue("extensionY", Integer.class)) {
|
if (yapionObject.containsKey("extensionY", Integer.class)) {
|
||||||
extensionNegativeY = yapionObject.getPlainValue("extensionY");
|
extensionNegativeY = yapionObject.getPlainValue("extensionY");
|
||||||
extensionPositiveY = yapionObject.getPlainValue("extensionY");
|
extensionPositiveY = yapionObject.getPlainValue("extensionY");
|
||||||
} else {
|
} else {
|
||||||
@ -125,7 +125,7 @@ public class Prototype {
|
|||||||
extensionPositiveY = yapionObject.getPlainValueOrDefault("extensionPositiveY", 0);
|
extensionPositiveY = yapionObject.getPlainValueOrDefault("extensionPositiveY", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (yapionObject.hasValue("extensionZ", Integer.class)) {
|
if (yapionObject.containsKey("extensionZ", Integer.class)) {
|
||||||
extensionNegativeZ = yapionObject.getPlainValue("extensionZ");
|
extensionNegativeZ = yapionObject.getPlainValue("extensionZ");
|
||||||
extensionPositiveZ = yapionObject.getPlainValue("extensionZ");
|
extensionPositiveZ = yapionObject.getPlainValue("extensionZ");
|
||||||
} else {
|
} else {
|
||||||
|
@ -19,8 +19,36 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.region.loader;
|
package de.steamwar.bausystem.region.loader;
|
||||||
|
|
||||||
|
import de.steamwar.bausystem.region.Prototype;
|
||||||
import lombok.experimental.UtilityClass;
|
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
|
@UtilityClass
|
||||||
public class PrototypeLoader {
|
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);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,4 +23,8 @@ import lombok.experimental.UtilityClass;
|
|||||||
|
|
||||||
@UtilityClass
|
@UtilityClass
|
||||||
public class RegionLoader {
|
public class RegionLoader {
|
||||||
|
|
||||||
|
public void load() {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren