From 435e986777d5b073a7185e25a831c50b2ae73b83 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sun, 18 Apr 2021 15:22:18 +0200 Subject: [PATCH 1/5] Implement Prototype creation --- .../de/steamwar/bausystem/region/Prototype.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/region/Prototype.java b/BauSystem_Main/src/de/steamwar/bausystem/region/Prototype.java index 86f453bd..c784f423 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/region/Prototype.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/region/Prototype.java @@ -22,9 +22,16 @@ package de.steamwar.bausystem.region; import yapion.hierarchy.types.YAPIONObject; import java.io.File; +import java.util.HashMap; +import java.util.Map; public class Prototype { + private static final Map PROTOTYPE_MAP = new HashMap<>(); + + private final String name; + private final String displayName; + private final int sizeX; private final int sizeY; private final int sizeZ; @@ -37,7 +44,12 @@ public class Prototype { private final SubPrototype testblock; private final SubPrototype build; - public Prototype(YAPIONObject yapionObject) { + public Prototype(String name, YAPIONObject yapionObject) { + PROTOTYPE_MAP.put(name, this); + + this.name = name; + displayName = yapionObject.getPlainValueOrDefault("displayName", name); + sizeX = yapionObject.getPlainValue("sizeX"); sizeY = yapionObject.getPlainValue("sizeY"); sizeZ = yapionObject.getPlainValue("sizeZ"); @@ -105,7 +117,10 @@ public class Prototype { extensionPositiveZ = yapionObject.getPlainValueOrDefault("extensionPositiveZ", 0); } } + } + public Region generateRegion() { + return null; } } From 2bac2b9fb525be422838f6c99d196e4c14964b39 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sun, 18 Apr 2021 15:34:31 +0200 Subject: [PATCH 2/5] Add Region Data --- .../steamwar/bausystem/region/Prototype.java | 2 ++ .../de/steamwar/bausystem/region/Region.java | 25 +++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/region/Prototype.java b/BauSystem_Main/src/de/steamwar/bausystem/region/Prototype.java index c784f423..9c7aa190 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/region/Prototype.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/region/Prototype.java @@ -19,12 +19,14 @@ package de.steamwar.bausystem.region; +import lombok.Getter; import yapion.hierarchy.types.YAPIONObject; import java.io.File; import java.util.HashMap; import java.util.Map; +@Getter public class Prototype { private static final Map PROTOTYPE_MAP = new HashMap<>(); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java b/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java index c34946cb..e11c04f6 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java @@ -19,5 +19,30 @@ package de.steamwar.bausystem.region; +import java.util.Set; + public class Region { + + private Prototype prototype; + private Set alternativePrototypes; + + private Point minPoint; + private Point maxPoint; + + private Point minPointTestblock; + private Point maxPointTestblock; + + private Point minPointTestblockExtension; + private Point maxPointTestblockExtension; + + private Point minPointBuild; + private Point maxPointBuild; + + private Point minPointBuildExtension; + private Point maxPointBuildExtension; + + private Region linkedRegion = null; // Nullable + + private FlagStorage flagStorage; + } From 72cfa5682cb654c54aa80ecfa17ea4a9145a8583 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sun, 18 Apr 2021 15:48:15 +0200 Subject: [PATCH 3/5] Add PrototypeLoader Add RegionLoader --- .../steamwar/bausystem/region/Prototype.java | 28 ++++++++++++++----- .../de/steamwar/bausystem/region/Region.java | 3 ++ .../region/loader/PrototypeLoader.java | 26 +++++++++++++++++ .../bausystem/region/loader/RegionLoader.java | 26 +++++++++++++++++ 4 files changed, 76 insertions(+), 7 deletions(-) create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/region/loader/PrototypeLoader.java create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/region/loader/RegionLoader.java diff --git a/BauSystem_Main/src/de/steamwar/bausystem/region/Prototype.java b/BauSystem_Main/src/de/steamwar/bausystem/region/Prototype.java index 9c7aa190..0352007e 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/region/Prototype.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/region/Prototype.java @@ -21,6 +21,7 @@ package de.steamwar.bausystem.region; import lombok.Getter; import yapion.hierarchy.types.YAPIONObject; +import yapion.hierarchy.types.YAPIONType; import java.io.File; import java.util.HashMap; @@ -43,8 +44,8 @@ public class Prototype { private final int floorOffset; private final int waterOffset; - private final SubPrototype testblock; - private final SubPrototype build; + private final SubPrototype testblock; // Nullable + private final SubPrototype build; // Nullable public Prototype(String name, YAPIONObject yapionObject) { PROTOTYPE_MAP.put(name, this); @@ -61,10 +62,19 @@ public class Prototype { floorOffset = yapionObject.getPlainValueOrDefault("floorOffset", 0); waterOffset = yapionObject.getPlainValueOrDefault("waterOffset", 0); - testblock = new SubPrototype(yapionObject.getObject("testblock")); - build = new SubPrototype(yapionObject.getObject("build")); + if (yapionObject.hasValue("testblock", YAPIONType.OBJECT)) { + testblock = new SubPrototype(yapionObject.getObject("testblock")); + } else { + testblock = null; + } + if (yapionObject.hasValue("build", YAPIONType.OBJECT)) { + build = new SubPrototype(yapionObject.getObject("build")); + } else { + build = null; + } } + @Getter public static class SubPrototype { private final int offsetX; @@ -75,7 +85,7 @@ public class Prototype { private final int sizeY; private final int sizeZ; - private final File schematicFile; + private final File schematicFile; // Nullable private final int extensionNegativeX; private final int extensionPositiveX; @@ -93,7 +103,11 @@ public class Prototype { sizeY = yapionObject.getPlainValue("sizeY"); sizeZ = yapionObject.getPlainValue("sizeZ"); - schematicFile = new File(yapionObject.getValue("schematic", String.class).get()); + if (yapionObject.hasValue("schematic", String.class)) { + schematicFile = new File(yapionObject.getValue("schematic", String.class).get()); + } else { + schematicFile = null; + } if (yapionObject.hasValue("extensionX", Integer.class)) { extensionNegativeX = yapionObject.getPlainValue("extensionX"); @@ -121,7 +135,7 @@ public class Prototype { } } - public Region generateRegion() { + public static Region generateRegion(YAPIONObject regionConfig, YAPIONObject regionData) { return null; } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java b/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java index e11c04f6..e482fc89 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java @@ -19,8 +19,11 @@ package de.steamwar.bausystem.region; +import lombok.Getter; + import java.util.Set; +@Getter public class Region { private Prototype prototype; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/region/loader/PrototypeLoader.java b/BauSystem_Main/src/de/steamwar/bausystem/region/loader/PrototypeLoader.java new file mode 100644 index 00000000..079d53ac --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/region/loader/PrototypeLoader.java @@ -0,0 +1,26 @@ +/* + * 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 . + */ + +package de.steamwar.bausystem.region.loader; + +import lombok.experimental.UtilityClass; + +@UtilityClass +public class PrototypeLoader { +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/region/loader/RegionLoader.java b/BauSystem_Main/src/de/steamwar/bausystem/region/loader/RegionLoader.java new file mode 100644 index 00000000..6a26a07b --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/region/loader/RegionLoader.java @@ -0,0 +1,26 @@ +/* + * 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 . + */ + +package de.steamwar.bausystem.region.loader; + +import lombok.experimental.UtilityClass; + +@UtilityClass +public class RegionLoader { +} From f16bc06d7cdd66fd724c9eddf479da3bedfd098b Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sun, 18 Apr 2021 16:09:53 +0200 Subject: [PATCH 4/5] Add more Detoblock nad TpsCommand Signed-off-by: Chaoscaot --- .../features/detonator/Detoblock.java | 2 +- .../features/detonator/Detonator.java | 48 +++++++++++------- .../bausystem/features/other/TpsCommand.java | 50 +++++++++++++++++++ .../bausystem/features/world/SignEdit.java | 6 ++- 4 files changed, 86 insertions(+), 20 deletions(-) create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/other/TpsCommand.java diff --git a/BauSystem_API/src/de/steamwar/bausystem/features/detonator/Detoblock.java b/BauSystem_API/src/de/steamwar/bausystem/features/detonator/Detoblock.java index ce97930d..10163594 100644 --- a/BauSystem_API/src/de/steamwar/bausystem/features/detonator/Detoblock.java +++ b/BauSystem_API/src/de/steamwar/bausystem/features/detonator/Detoblock.java @@ -31,7 +31,7 @@ public enum Detoblock { WEIGHTED_PRESSURE_PLATE(20, "Druckplatte"), TRIPWIRE(30, "Tripwire"), NOTEBLOCK(1, "Noteblock"), - REDSTONETORCH(0, true, "Redstonefackel"), + DAYLIGHTSENSOR(0, true, "Tageslichtsensor"), POWERABLE(0, true, "Aktivierbarer Block"), INVALID(-1, "Invalider"); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/detonator/Detonator.java b/BauSystem_Main/src/de/steamwar/bausystem/features/detonator/Detonator.java index aa6e9546..899beb4f 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/detonator/Detonator.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/detonator/Detonator.java @@ -31,10 +31,8 @@ import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; -import org.bukkit.block.data.BlockData; -import org.bukkit.block.data.Lightable; -import org.bukkit.block.data.Openable; -import org.bukkit.block.data.Powerable; +import org.bukkit.block.data.*; +import org.bukkit.block.data.type.DaylightDetector; import org.bukkit.block.data.type.Switch; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; @@ -105,7 +103,7 @@ public class Detonator { invalid.forEach(detonator::removeLocation); if (!invalid.isEmpty()) { int invalidPoints = invalid.size(); - p.sendMessage(BauSystem.PREFIX + ColorConfig.DISABLE + invalid.size() + " Punkt" + (invalidPoints > 1 ? "e" : "") + "konnte" + (invalidPoints > 1 ? "n" : "") + " nicht ausgeführt werden und wurde" + (invalidPoints > 1 ? "e" : "") + " entfernt"); + p.sendMessage(BauSystem.PREFIX + ColorConfig.DISABLE + invalid.size() + " Punkt" + (invalidPoints > 1 ? "e" : "") + " konnte" + (invalidPoints > 1 ? "n" : "") + " nicht ausgeführt werden und wurde" + (invalidPoints > 1 ? "n" : "") + " entfernt"); detonator.write(); } @@ -119,13 +117,18 @@ public class Detonator { public static void updateButton(Block block, Detoblock detoblock) { if (block.getBlockData() instanceof Switch) { Switch sw = (Switch) block.getBlockData(); - update(block.getRelative(sw.getFacing().getOppositeFace())); + FaceAttachable.AttachedFace face = sw.getAttachedFace(); + if (face == FaceAttachable.AttachedFace.FLOOR) { + update(block.getRelative(BlockFace.DOWN)); + } else if (face == FaceAttachable.AttachedFace.CEILING) { + update(block.getRelative(BlockFace.UP)); + } else { + update(block.getRelative(sw.getFacing().getOppositeFace())); + } } else if (detoblock == Detoblock.TRIPWIRE) { update(block); } else if (detoblock == Detoblock.PRESSURE_PLATE || detoblock == Detoblock.WEIGHTED_PRESSURE_PLATE) { update(block.getRelative(BlockFace.DOWN)); - } else if (detoblock == Detoblock.REDSTONETORCH) { - update(block.getRelative(BlockFace.UP)); } } @@ -145,9 +148,17 @@ public class Detonator { Openable openable = (Openable) data; openable.setOpen(state); } - if (data instanceof Lightable) { - Lightable lightable = (Lightable) data; - lightable.setLit(state); + if (data instanceof DaylightDetector) { + DaylightDetector detector = (DaylightDetector) data; + detector.setInverted(state); + } + if (data instanceof AnaloguePowerable) { + AnaloguePowerable powerable = (AnaloguePowerable) data; + if (block.getType() == Material.REDSTONE_WIRE) { + powerable.setPower(state ? 15 : 0); + } else { + powerable.setPower(state ? 1 : 0); + } } block.setBlockData(data); } @@ -158,9 +169,13 @@ public class Detonator { Powerable pow = (Powerable) data; return pow.isPowered(); } - if (data instanceof Lightable) { - Lightable lightable = (Lightable) data; - return lightable.isLit(); + if (data instanceof DaylightDetector) { + DaylightDetector detector = (DaylightDetector) data; + return detector.isInverted(); + } + if (data instanceof AnaloguePowerable) { + AnaloguePowerable powerable = (AnaloguePowerable) data; + return powerable.getPower() > 0; } return false; } @@ -193,9 +208,8 @@ public class Detonator { return Detoblock.TRIPWIRE; case NOTE_BLOCK: return Detoblock.NOTEBLOCK; - case REDSTONE_TORCH: - case REDSTONE_WALL_TORCH: - return Detoblock.REDSTONETORCH; + case DAYLIGHT_DETECTOR: + return Detoblock.DAYLIGHTSENSOR; default: if (block.getBlockData() instanceof Powerable) { return Detoblock.POWERABLE; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/other/TpsCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/other/TpsCommand.java new file mode 100644 index 00000000..8c45ed11 --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/other/TpsCommand.java @@ -0,0 +1,50 @@ +/* + * 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 . + */ + +package de.steamwar.bausystem.features.other; + +import de.steamwar.bausystem.config.ColorConfig; +import de.steamwar.bausystem.features.tpslimit.TPSWarpUtils; +import de.steamwar.bausystem.linkage.LinkageType; +import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.command.SWCommand; +import de.steamwar.core.TPSWatcher; +import org.bukkit.entity.Player; + +@Linked(LinkageType.COMMAND) +public class TpsCommand extends SWCommand { + + protected TpsCommand() { + super("tps"); + } + + @Register(help = true) + public void genericCommand(Player p, String... args) { + p.sendMessage(ColorConfig.BASE + "TPS:"); + p.sendMessage(ColorConfig.HIGHLIGHT.toString() + TPSWarpUtils.getTps(TPSWatcher.TPSType.ONE_SECOND) + ColorConfig.OTHER + ", " + + ColorConfig.HIGHLIGHT + TPSWarpUtils.getTps(TPSWatcher.TPSType.TEN_SECONDS) + ColorConfig.OTHER + ", " + + ColorConfig.HIGHLIGHT + TPSWarpUtils.getTps(TPSWatcher.TPSType.ONE_MINUTE)); + } + + @Register + public void genericCommand(Player p, TPSWatcher.TPSType type) { + p.sendMessage(ColorConfig.BASE + "TPS:"); + p.sendMessage(ColorConfig.HIGHLIGHT.toString() + TPSWarpUtils.getTps(type)); + } +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/world/SignEdit.java b/BauSystem_Main/src/de/steamwar/bausystem/features/world/SignEdit.java index 4b9ada3e..dc15ef2a 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/world/SignEdit.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/world/SignEdit.java @@ -30,6 +30,7 @@ import de.steamwar.bausystem.linkage.LinkageType; import de.steamwar.bausystem.linkage.Linked; import org.bukkit.Bukkit; import org.bukkit.ChatColor; +import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.Sign; import org.bukkit.entity.Player; @@ -46,9 +47,10 @@ public class SignEdit implements Listener { @EventHandler public void editSign(PlayerInteractEvent event) { - if (event.getAction() != Action.LEFT_CLICK_BLOCK || + if (event.getAction() != Action.RIGHT_CLICK_BLOCK || !event.getClickedBlock().getType().name().contains("SIGN") || - !event.getPlayer().isSneaking()) + !event.getPlayer().isSneaking() || + (event.getItem() != null && event.getItem().getType() != Material.AIR)) return; event.setCancelled(true); From 1f0d90f7baf56b8cab56f4afa6d9a91ea2d5d18d Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sun, 18 Apr 2021 16:21:03 +0200 Subject: [PATCH 5/5] Add PrototypeLoader --- BauSystem_Main/build.gradle | 2 +- .../src/de/steamwar/bausystem/BauSystem.java | 3 ++ .../steamwar/bausystem/region/Prototype.java | 12 ++++---- .../region/loader/PrototypeLoader.java | 28 +++++++++++++++++++ .../bausystem/region/loader/RegionLoader.java | 4 +++ 5 files changed, 42 insertions(+), 7 deletions(-) diff --git a/BauSystem_Main/build.gradle b/BauSystem_Main/build.gradle index c22c6828..80be0760 100644 --- a/BauSystem_Main/build.gradle +++ b/BauSystem_Main/build.gradle @@ -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' diff --git a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java index ae41d271..f989a3b6 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java @@ -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(); } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/region/Prototype.java b/BauSystem_Main/src/de/steamwar/bausystem/region/Prototype.java index 0352007e..9571754c 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/region/Prototype.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/region/Prototype.java @@ -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 { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/region/loader/PrototypeLoader.java b/BauSystem_Main/src/de/steamwar/bausystem/region/loader/PrototypeLoader.java index 079d53ac..c504f073 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/region/loader/PrototypeLoader.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/region/loader/PrototypeLoader.java @@ -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); + } + }); + } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/region/loader/RegionLoader.java b/BauSystem_Main/src/de/steamwar/bausystem/region/loader/RegionLoader.java index 6a26a07b..3ce6a823 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/region/loader/RegionLoader.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/region/loader/RegionLoader.java @@ -23,4 +23,8 @@ import lombok.experimental.UtilityClass; @UtilityClass public class RegionLoader { + + public void load() { + + } }