SteamWar/BauSystem2.0
Archiviert
12
0

Update RegionUtils

Update RegionLoader to new WorldData system

Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
yoyosource 2021-08-23 18:06:22 +02:00
Ursprung 31d2605319
Commit d16ed943cf
3 geänderte Dateien mit 6 neuen und 22 gelöschten Zeilen

Datei anzeigen

@ -25,6 +25,7 @@ import de.steamwar.bausystem.linkage.LinkageUtils;
import de.steamwar.bausystem.region.loader.PrototypeLoader; import de.steamwar.bausystem.region.loader.PrototypeLoader;
import de.steamwar.bausystem.region.loader.RegionLoader; import de.steamwar.bausystem.region.loader.RegionLoader;
import de.steamwar.bausystem.region.loader.Updater; import de.steamwar.bausystem.region.loader.Updater;
import de.steamwar.bausystem.worlddata.WorldData;
import de.steamwar.message.Message; import de.steamwar.message.Message;
import de.steamwar.scoreboard.SWScoreboard; import de.steamwar.scoreboard.SWScoreboard;
import lombok.Getter; import lombok.Getter;
@ -84,7 +85,7 @@ public class BauSystem extends JavaPlugin implements Listener {
public void onDisable() { public void onDisable() {
LinkageUtils.unlink(); LinkageUtils.unlink();
RegionLoader.save(); WorldData.write();
Config.getInstance().saveAll(); Config.getInstance().saveAll();
} }

Datei anzeigen

@ -22,9 +22,9 @@ package de.steamwar.bausystem.region;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.extent.clipboard.Clipboard;
import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.region.loader.RegionLoader;
import de.steamwar.bausystem.region.utils.RegionExtensionType; import de.steamwar.bausystem.region.utils.RegionExtensionType;
import de.steamwar.bausystem.region.utils.RegionType; import de.steamwar.bausystem.region.utils.RegionType;
import de.steamwar.bausystem.worlddata.WorldData;
import de.steamwar.core.VersionedCallable; import de.steamwar.core.VersionedCallable;
import lombok.experimental.UtilityClass; import lombok.experimental.UtilityClass;
import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.ChatMessageType;
@ -83,7 +83,7 @@ public class RegionUtils {
region.regionData.add("prototype", region.getPrototype().getName()); region.regionData.add("prototype", region.getPrototype().getName());
} }
region.regionData.add("flagStorage", FlagStorage.toYAPION(region.getFlagStorage())); region.regionData.add("flagStorage", FlagStorage.toYAPION(region.getFlagStorage()));
RegionLoader.save(); WorldData.write();
} }
} }

Datei anzeigen

@ -22,6 +22,7 @@ package de.steamwar.bausystem.region.loader;
import de.steamwar.bausystem.region.FlagStorage; import de.steamwar.bausystem.region.FlagStorage;
import de.steamwar.bausystem.region.GlobalRegion; import de.steamwar.bausystem.region.GlobalRegion;
import de.steamwar.bausystem.region.Prototype; import de.steamwar.bausystem.region.Prototype;
import de.steamwar.bausystem.worlddata.WorldData;
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.DiffBase;
@ -40,17 +41,8 @@ import java.io.IOException;
public class RegionLoader { public class RegionLoader {
private YAPIONObject loaded = null; private YAPIONObject loaded = null;
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");
public void save() {
try {
optionsYapionObject.toYAPION(new FileOutput(new File(Bukkit.getWorlds().get(0).getWorldFolder(), "options.yapion"))).close();
} catch (IOException e) {
// Ignored
}
}
public void load() { public void load() {
YAPIONObject yapionObject = null; YAPIONObject yapionObject = null;
try (BufferedInputStream bufferedInputStream = new BufferedInputStream(new FileInputStream(file))) { try (BufferedInputStream bufferedInputStream = new BufferedInputStream(new FileInputStream(file))) {
@ -64,16 +56,7 @@ public class RegionLoader {
} }
loaded = yapionObject; loaded = yapionObject;
File optionsFile = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "options.yapion"); YAPIONObject optionsYapionObject = WorldData.getRegionsData();
optionsYapionObject = new YAPIONObject();
if (optionsFile.length() != 0) {
try (BufferedInputStream bufferedInputStream = new BufferedInputStream(new FileInputStream(optionsFile))) {
optionsYapionObject = YAPIONParser.parse(bufferedInputStream);
} catch (IOException e) {
// Ignored
}
}
yapionObject.forEach((key, yapionAnyType) -> { yapionObject.forEach((key, yapionAnyType) -> {
if (key.equals("global")) { if (key.equals("global")) {
return; return;