SteamWar/BauSystem2.0
Archiviert
12
0

Add RegionUtils.save

Dieser Commit ist enthalten in:
yoyosource 2021-04-20 13:46:51 +02:00
Ursprung 5baa457d3f
Commit f73ef47513
2 geänderte Dateien mit 27 neuen und 17 gelöschten Zeilen

Datei anzeigen

@ -46,6 +46,8 @@ import java.util.List;
import java.util.Set;
import java.util.function.Predicate;
import static de.steamwar.bausystem.region.RegionUtils.paste;
@Getter
public class Region {
@ -66,7 +68,7 @@ public class Region {
}
}
private YAPIONObject regionData;
YAPIONObject regionData;
private String name;
private Prototype prototype;
@ -240,8 +242,7 @@ public class Region {
}
if (linkedRegion != null) {
if (regionConsumer.test(linkedRegion)) {
linkedRegion.regionData.add("flagStorage", FlagStorage.toYAPION(linkedRegion.flagStorage));
RegionLoader.save();
RegionUtils.save(linkedRegion);
}
return;
}
@ -249,8 +250,7 @@ public class Region {
if (region.name.equals(linkedRegionName)) {
linkedRegion = region;
if (regionConsumer.test(linkedRegion)) {
linkedRegion.regionData.add("flagStorage", FlagStorage.toYAPION(linkedRegion.flagStorage));
RegionLoader.save();
RegionUtils.save(linkedRegion);
}
return;
}
@ -264,10 +264,9 @@ public class Region {
if (!prototypes.contains(prototype)) {
return;
}
regionData.add("prototype", prototype.getName());
generatePrototypeData(prototype, minPoint);
RegionUtils.save(this);
setLinkedRegion(region -> {
region.regionData.add("prototype", prototype.getName());
region.generatePrototypeData(prototype, region.minPoint);
return true;
});
@ -275,8 +274,7 @@ public class Region {
public void set(Flag flagType, Flag.Value<?> value) {
if (flagStorage.set(flagType, value)) {
regionData.add("flagStorage", FlagStorage.toYAPION(flagStorage));
RegionLoader.save();
RegionUtils.save(this);
}
setLinkedRegion(region -> region.flagStorage.set(flagType, value));
}
@ -387,14 +385,6 @@ public class Region {
undoSessions.push(editSession);
}
private EditSession paste(File file, Point pastePoint, PasteOptions pasteOptions) {
return VersionedCallable.call(new VersionedCallable<>(() -> Region_15.paste(file, pastePoint, pasteOptions), 15));
}
private EditSession paste(Clipboard clipboard, Point pastePoint, PasteOptions pasteOptions) {
return VersionedCallable.call(new VersionedCallable<>(() -> Region_15.paste(clipboard, pastePoint, pasteOptions), 15));
}
public boolean isGlobal() {
return this == GlobalRegion.getInstance();
}

Datei anzeigen

@ -1,12 +1,18 @@
package de.steamwar.bausystem.region;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import de.steamwar.bausystem.region.loader.RegionLoader;
import de.steamwar.bausystem.region.utils.RegionExtensionType;
import de.steamwar.bausystem.region.utils.RegionType;
import de.steamwar.core.VersionedCallable;
import lombok.experimental.UtilityClass;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Bukkit;
import java.io.File;
@UtilityClass
public class RegionUtils {
@ -14,4 +20,18 @@ public class RegionUtils {
Bukkit.getOnlinePlayers().stream().filter(player -> region.inRegion(player.getLocation(), RegionType.NORMAL, RegionExtensionType.NORMAL)).forEach(player -> player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(s)));
}
static EditSession paste(File file, Point pastePoint, PasteOptions pasteOptions) {
return VersionedCallable.call(new VersionedCallable<>(() -> Region_15.paste(file, pastePoint, pasteOptions), 15));
}
static EditSession paste(Clipboard clipboard, Point pastePoint, PasteOptions pasteOptions) {
return VersionedCallable.call(new VersionedCallable<>(() -> Region_15.paste(clipboard, pastePoint, pasteOptions), 15));
}
static void save(Region region) {
region.regionData.add("prototype", region.getPrototype().getName());
region.regionData.add("flagStorage", FlagStorage.toYAPION(region.getFlagStorage()));
RegionLoader.save();
}
}