Add RegionUtils.save
Dieser Commit ist enthalten in:
Ursprung
5baa457d3f
Commit
f73ef47513
@ -46,6 +46,8 @@ import java.util.List;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
|
import static de.steamwar.bausystem.region.RegionUtils.paste;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
public class Region {
|
public class Region {
|
||||||
|
|
||||||
@ -66,7 +68,7 @@ public class Region {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private YAPIONObject regionData;
|
YAPIONObject regionData;
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
private Prototype prototype;
|
private Prototype prototype;
|
||||||
@ -240,8 +242,7 @@ public class Region {
|
|||||||
}
|
}
|
||||||
if (linkedRegion != null) {
|
if (linkedRegion != null) {
|
||||||
if (regionConsumer.test(linkedRegion)) {
|
if (regionConsumer.test(linkedRegion)) {
|
||||||
linkedRegion.regionData.add("flagStorage", FlagStorage.toYAPION(linkedRegion.flagStorage));
|
RegionUtils.save(linkedRegion);
|
||||||
RegionLoader.save();
|
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -249,8 +250,7 @@ public class Region {
|
|||||||
if (region.name.equals(linkedRegionName)) {
|
if (region.name.equals(linkedRegionName)) {
|
||||||
linkedRegion = region;
|
linkedRegion = region;
|
||||||
if (regionConsumer.test(linkedRegion)) {
|
if (regionConsumer.test(linkedRegion)) {
|
||||||
linkedRegion.regionData.add("flagStorage", FlagStorage.toYAPION(linkedRegion.flagStorage));
|
RegionUtils.save(linkedRegion);
|
||||||
RegionLoader.save();
|
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -264,10 +264,9 @@ public class Region {
|
|||||||
if (!prototypes.contains(prototype)) {
|
if (!prototypes.contains(prototype)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
regionData.add("prototype", prototype.getName());
|
|
||||||
generatePrototypeData(prototype, minPoint);
|
generatePrototypeData(prototype, minPoint);
|
||||||
|
RegionUtils.save(this);
|
||||||
setLinkedRegion(region -> {
|
setLinkedRegion(region -> {
|
||||||
region.regionData.add("prototype", prototype.getName());
|
|
||||||
region.generatePrototypeData(prototype, region.minPoint);
|
region.generatePrototypeData(prototype, region.minPoint);
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
@ -275,8 +274,7 @@ public class Region {
|
|||||||
|
|
||||||
public void set(Flag flagType, Flag.Value<?> value) {
|
public void set(Flag flagType, Flag.Value<?> value) {
|
||||||
if (flagStorage.set(flagType, value)) {
|
if (flagStorage.set(flagType, value)) {
|
||||||
regionData.add("flagStorage", FlagStorage.toYAPION(flagStorage));
|
RegionUtils.save(this);
|
||||||
RegionLoader.save();
|
|
||||||
}
|
}
|
||||||
setLinkedRegion(region -> region.flagStorage.set(flagType, value));
|
setLinkedRegion(region -> region.flagStorage.set(flagType, value));
|
||||||
}
|
}
|
||||||
@ -387,14 +385,6 @@ public class Region {
|
|||||||
undoSessions.push(editSession);
|
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() {
|
public boolean isGlobal() {
|
||||||
return this == GlobalRegion.getInstance();
|
return this == GlobalRegion.getInstance();
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,18 @@
|
|||||||
package de.steamwar.bausystem.region;
|
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.RegionExtensionType;
|
||||||
import de.steamwar.bausystem.region.utils.RegionType;
|
import de.steamwar.bausystem.region.utils.RegionType;
|
||||||
|
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;
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
@UtilityClass
|
@UtilityClass
|
||||||
public class RegionUtils {
|
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)));
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren