forked from SteamWar/SteamWar
Improve Region.Area
This commit is contained in:
+2
-2
@@ -63,11 +63,11 @@ public class ColorCommand extends SWCommand {
|
||||
}
|
||||
region.getRegionData().set(Flag.COLOR, color);
|
||||
try {
|
||||
PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.FileProvider(region.getArea().getResetFile()))
|
||||
PasteBuilder pasteBuilder = new PasteBuilder(PasteBuilder.ClipboardProvider.EMPTY)
|
||||
.ignoreAir(true)
|
||||
.onlyColors(true)
|
||||
.color(color);
|
||||
region.getArea().reset(pasteBuilder, false);
|
||||
region.getArea().reset(p.getLocation(), pasteBuilder, false);
|
||||
RegionUtils.message(region, "REGION_REGION_COLORED");
|
||||
RegionUtils.message(region, "REGION_REGION_COLORED_FAILED");
|
||||
} catch (SecurityException e) {
|
||||
|
||||
+2
-34
@@ -29,9 +29,6 @@ import de.steamwar.bausystem.utils.PasteBuilder;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.linkage.LinkedInstance;
|
||||
import de.steamwar.sql.Punishment;
|
||||
import de.steamwar.sql.SchematicNode;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@@ -52,9 +49,9 @@ public class ResetCommand extends SWCommand {
|
||||
Region region = regionCheck(p);
|
||||
if (region == null) return;
|
||||
try {
|
||||
PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.FileProvider(region.getArea().getResetFile()))
|
||||
PasteBuilder pasteBuilder = new PasteBuilder(PasteBuilder.ClipboardProvider.EMPTY)
|
||||
.color(region.getRegionData().get(Flag.COLOR).getWithDefault());
|
||||
region.getArea().reset(pasteBuilder, false);
|
||||
region.getArea().reset(p.getLocation(), pasteBuilder, false);
|
||||
region.getRegionData().clear();
|
||||
RegionUtils.message(region, "REGION_RESET_RESETED");
|
||||
} catch (SecurityException e) {
|
||||
@@ -63,35 +60,6 @@ public class ResetCommand extends SWCommand {
|
||||
}
|
||||
}
|
||||
|
||||
@Register(description = "REGION_RESET_HELP_SCHEMATIC")
|
||||
public void schematicResetCommand(@Validator Player p, SchematicNode node) {
|
||||
Region region = regionCheck(p);
|
||||
if (region == null) return;
|
||||
|
||||
if (!p.getUniqueId().equals(bauServer.getOwner())) {
|
||||
if (Punishment.isPunished(SteamwarUser.get(bauServer.getOwner()), Punishment.PunishmentType.NoSchemReceiving, punishment -> BauSystem.MESSAGE.send("REGION_TB_NO_SCHEMRECEIVING", p, punishment.getEndTime()))) {
|
||||
return;
|
||||
}
|
||||
if (Punishment.isPunished(SteamwarUser.get(p.getUniqueId()), Punishment.PunishmentType.NoSchemSharing, punishment -> BauSystem.MESSAGE.send("REGION_TB_NO_SCHEMSHARING", p, punishment.getEndTime()))) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (node.isDir()) {
|
||||
BauSystem.MESSAGE.send("ONLY_SCHEMS", p);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.SchematicProvider(node))
|
||||
.color(region.getRegionData().get(Flag.COLOR).getWithDefault());
|
||||
region.getArea().reset(pasteBuilder, true);
|
||||
RegionUtils.message(region, "REGION_RESET_RESETED");
|
||||
} catch (SecurityException e) {
|
||||
BauSystem.MESSAGE.send("REGION_RESET_ERROR", p);
|
||||
Bukkit.getLogger().log(Level.WARNING, "Failed reset", e);
|
||||
}
|
||||
}
|
||||
|
||||
private Region regionCheck(Player player) {
|
||||
Region region = Region.getRegion(player.getLocation());
|
||||
if (region == RegionSystem.INSTANCE.getGlobalRegion()) {
|
||||
|
||||
+2
-8
@@ -108,13 +108,7 @@ public class TestblockCommand extends SWCommand {
|
||||
region.getRegionData().setTestblockSchematic(node);
|
||||
}
|
||||
|
||||
PasteBuilder.ClipboardProvider clipboardProvider;
|
||||
if (node == null) {
|
||||
clipboardProvider = new PasteBuilder.FileProvider(region.getTestblockArea().getResetFile());
|
||||
} else {
|
||||
clipboardProvider = new PasteBuilder.SchematicProvider(node);
|
||||
}
|
||||
|
||||
PasteBuilder.ClipboardProvider clipboardProvider = node == null ? PasteBuilder.ClipboardProvider.EMPTY : PasteBuilder.ClipboardProvider.schematic(node);
|
||||
try {
|
||||
PasteBuilder pasteBuilder = new PasteBuilder(clipboardProvider)
|
||||
.ignoreAir(ignoreAir)
|
||||
@@ -122,7 +116,7 @@ public class TestblockCommand extends SWCommand {
|
||||
.removeTNT(removeTNT)
|
||||
.removeWater(removeWater)
|
||||
.color(region.getRegionData().get(Flag.COLOR).getWithDefault());
|
||||
region.getTestblockArea().reset(pasteBuilder, regionExtensionType == RegionExtensionType.EXTENSION);
|
||||
region.getTestblockArea().reset(p.getLocation(), pasteBuilder, regionExtensionType == RegionExtensionType.EXTENSION);
|
||||
RegionUtils.message(region, "REGION_TB_DONE");
|
||||
} catch (SecurityException e) {
|
||||
BauSystem.MESSAGE.send("REGION_TB_ERROR", p);
|
||||
|
||||
+2
-10
@@ -50,16 +50,8 @@ public class ResetBauGuiItem extends BauGuiItem {
|
||||
|
||||
@Override
|
||||
public boolean click(ClickType click, Player p) {
|
||||
if (click == ClickType.LEFT) {
|
||||
p.closeInventory();
|
||||
resetCommand.genericResetCommand(p);
|
||||
} else {
|
||||
SchematicSelector selector = new SchematicSelector(p, SchematicSelector.selectSchematic(), node -> {
|
||||
p.closeInventory();
|
||||
resetCommand.schematicResetCommand(p, node);
|
||||
});
|
||||
selector.open();
|
||||
}
|
||||
p.closeInventory();
|
||||
resetCommand.genericResetCommand(p);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -33,12 +33,12 @@ public class StabFinalizer extends StabStep {
|
||||
@Override
|
||||
protected void start() {
|
||||
try {
|
||||
PasteBuilder.ClipboardProvider clipboardProvider = new PasteBuilder.ClipboardProviderImpl(data.clipboard);
|
||||
PasteBuilder.ClipboardProvider clipboardProvider = PasteBuilder.ClipboardProvider.clipboard(data.clipboard);
|
||||
PasteBuilder pasteBuilder = new PasteBuilder(clipboardProvider);
|
||||
if (data.region.getRegionData().has(Flag.COLOR).isReadable()) {
|
||||
pasteBuilder.color(data.region.getRegionData().get(Flag.COLOR).getWithDefault());
|
||||
}
|
||||
data.region.getTestblockArea().reset(pasteBuilder, true);
|
||||
data.region.getTestblockArea().reset(null, pasteBuilder, true);
|
||||
} catch (SecurityException e) {
|
||||
stop();
|
||||
throw e;
|
||||
|
||||
+2
-2
@@ -72,12 +72,12 @@ public class StabGenerator extends StabStep implements Listener {
|
||||
@Override
|
||||
protected void start() {
|
||||
try {
|
||||
PasteBuilder.ClipboardProvider clipboardProvider = new PasteBuilder.ClipboardProviderImpl(data.clipboard);
|
||||
PasteBuilder.ClipboardProvider clipboardProvider = PasteBuilder.ClipboardProvider.clipboard(data.clipboard);
|
||||
PasteBuilder pasteBuilder = new PasteBuilder(clipboardProvider);
|
||||
if (data.region.getRegionData().has(Flag.COLOR).isReadable()) {
|
||||
pasteBuilder.color(data.region.getRegionData().get(Flag.COLOR).getWithDefault());
|
||||
}
|
||||
data.region.getTestblockArea().reset(pasteBuilder, true);
|
||||
data.region.getTestblockArea().reset(null, pasteBuilder, true);
|
||||
} catch (SecurityException e) {
|
||||
stop();
|
||||
throw e;
|
||||
|
||||
@@ -29,7 +29,6 @@ import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.File;
|
||||
import java.util.UUID;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.stream.Stream;
|
||||
@@ -112,12 +111,7 @@ public interface Region extends RegionDataStore {
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getResetFile() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void place(PasteBuilder pasteBuilder, boolean extension) {
|
||||
public void place(Location location, PasteBuilder pasteBuilder, boolean extension) {
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -165,14 +159,11 @@ public interface Region extends RegionDataStore {
|
||||
return FlatteningWrapper.impl.copy(getMinPoint(extension), getMaxPoint(extension), getCopyPoint());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
File getResetFile();
|
||||
|
||||
default void reset(PasteBuilder pasteBuilder, boolean extension) {
|
||||
place(pasteBuilder, extension);
|
||||
default void reset(Location location, PasteBuilder pasteBuilder, boolean extension) {
|
||||
place(location, pasteBuilder, extension);
|
||||
}
|
||||
|
||||
void place(PasteBuilder pasteBuilder, boolean extension);
|
||||
void place(Location location, PasteBuilder pasteBuilder, boolean extension);
|
||||
|
||||
default void forEachChunk(BiConsumer<Integer, Integer> executor) {
|
||||
Point minPoint = getMinPoint(false);
|
||||
|
||||
@@ -42,7 +42,7 @@ import java.util.function.BiPredicate;
|
||||
@Getter
|
||||
public class PasteBuilder {
|
||||
|
||||
private final ClipboardProvider clipboardProvider;
|
||||
private ClipboardProvider clipboardProvider;
|
||||
private Point pastPoint;
|
||||
private boolean rotate;
|
||||
private boolean ignoreAir;
|
||||
@@ -53,21 +53,18 @@ public class PasteBuilder {
|
||||
private List<BiPredicate<BaseBlock, String>> predicates = new ArrayList<>();
|
||||
private List<BiConsumer<Clipboard, BlockVector3>> mappers = new ArrayList<>();
|
||||
|
||||
public PasteBuilder() {
|
||||
clipboardProvider = ClipboardProvider.EMPTY;
|
||||
}
|
||||
|
||||
public PasteBuilder(@NonNull ClipboardProvider clipboardProvider) {
|
||||
this.clipboardProvider = clipboardProvider;
|
||||
}
|
||||
|
||||
public PasteBuilder with(ClipboardProvider clipboardProvider) {
|
||||
return new PasteBuilder(clipboardProvider)
|
||||
.pastePoint(pastPoint)
|
||||
.rotate(rotate)
|
||||
.ignoreAir(ignoreAir)
|
||||
.reset(reset)
|
||||
.minPoint(minPoint)
|
||||
.maxPoint(maxPoint)
|
||||
.waterLevel(waterLevel)
|
||||
.predicates(predicates)
|
||||
.mappers(mappers);
|
||||
public PasteBuilder with(@NonNull ClipboardProvider clipboardProvider) {
|
||||
if (this.clipboardProvider != ClipboardProvider.EMPTY) return this;
|
||||
this.clipboardProvider = clipboardProvider;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PasteBuilder pastePoint(Point point) {
|
||||
@@ -212,6 +209,20 @@ public class PasteBuilder {
|
||||
}
|
||||
|
||||
public interface ClipboardProvider {
|
||||
ClipboardProvider EMPTY = new EmptyProvider();
|
||||
|
||||
static ClipboardProvider file(File file) {
|
||||
return new FileProvider(file);
|
||||
}
|
||||
|
||||
static ClipboardProvider schematic(SchematicNode schematic) {
|
||||
return new SchematicProvider(schematic);
|
||||
}
|
||||
|
||||
static ClipboardProvider clipboard(Clipboard clipboard) {
|
||||
return new ClipboardProviderImpl(clipboard);
|
||||
}
|
||||
|
||||
Clipboard getClipboard();
|
||||
|
||||
default <T extends ClipboardProvider> boolean is(Class<T> clazz) {
|
||||
@@ -223,12 +234,22 @@ public class PasteBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
private static class EmptyProvider implements ClipboardProvider {
|
||||
private EmptyProvider() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Clipboard getClipboard() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Getter
|
||||
public static class FileProvider implements ClipboardProvider {
|
||||
private final File file;
|
||||
private final Clipboard clipboard;
|
||||
|
||||
public FileProvider(File file) {
|
||||
private FileProvider(File file) {
|
||||
this.file = file;
|
||||
this.clipboard = FlatteningWrapper.impl.loadSchematic(file);
|
||||
}
|
||||
@@ -244,7 +265,7 @@ public class PasteBuilder {
|
||||
private final SchematicNode schematic;
|
||||
private final Clipboard clipboard;
|
||||
|
||||
public SchematicProvider(SchematicNode schematic) {
|
||||
private SchematicProvider(SchematicNode schematic) {
|
||||
this.schematic = schematic;
|
||||
try {
|
||||
this.clipboard = new SchematicData(schematic).load();
|
||||
@@ -263,7 +284,7 @@ public class PasteBuilder {
|
||||
public static class ClipboardProviderImpl implements ClipboardProvider {
|
||||
private final Clipboard clipboard;
|
||||
|
||||
public ClipboardProviderImpl(Clipboard clipboard) {
|
||||
private ClipboardProviderImpl(Clipboard clipboard) {
|
||||
this.clipboard = clipboard;
|
||||
}
|
||||
|
||||
|
||||
+2
-3
@@ -43,12 +43,11 @@ public class WireframeCommand extends SWCommand {
|
||||
Region region = regionCheck(p);
|
||||
if (region == null) return;
|
||||
|
||||
PasteBuilder.ClipboardProvider clipboardProvider = new PasteBuilder.FileProvider(region.getBuildArea().getResetFile());
|
||||
try {
|
||||
PasteBuilder pasteBuilder = new PasteBuilder(clipboardProvider)
|
||||
PasteBuilder pasteBuilder = new PasteBuilder(PasteBuilder.ClipboardProvider.EMPTY)
|
||||
.ignoreAir(true)
|
||||
.color(region.getRegionData().get(Flag.COLOR).getWithDefault());
|
||||
region.getBuildArea().reset(pasteBuilder, false);
|
||||
region.getBuildArea().reset(p.getLocation(), pasteBuilder, false);
|
||||
RegionUtils.message(region, "REGION_TB_DONE");
|
||||
} catch (SecurityException e) {
|
||||
BauSystem.MESSAGE.send("REGION_TB_ERROR", p);
|
||||
|
||||
+15
-1
@@ -23,7 +23,9 @@ import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.features.region.WireframeCommand;
|
||||
import de.steamwar.bausystem.region.dynamic.*;
|
||||
import de.steamwar.bausystem.region.dynamic.global.GlobalRegion;
|
||||
import de.steamwar.bausystem.region.dynamic.path.PathRegion;
|
||||
import de.steamwar.bausystem.shared.Pair;
|
||||
import de.steamwar.bausystem.utils.PasteBuilder;
|
||||
import lombok.NonNull;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
@@ -31,6 +33,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
@@ -94,7 +97,18 @@ public class DynamicRegionSystem implements RegionSystem {
|
||||
// [STDOUT] WET 2
|
||||
// [STDOUT] WET_SPECIAL 9
|
||||
regionTypeMap.forEach((type, regions) -> {
|
||||
System.out.println(type + " " + regions.size());
|
||||
if (type != RegionType.PATH) return;
|
||||
|
||||
MultiTileArea multiTileArea = new MultiTileArea() {
|
||||
@Override
|
||||
public void place(Location location, PasteBuilder pasteBuilder, boolean extension) {
|
||||
}
|
||||
};
|
||||
for (Region region : regions) {
|
||||
PathRegion pathRegion = (PathRegion) region;
|
||||
multiTileArea.addTile(pathRegion.getTile());
|
||||
}
|
||||
multiTileArea.quantize();
|
||||
});
|
||||
new DynamicRegionCommand();
|
||||
new WireframeCommand();
|
||||
|
||||
+1
-1
@@ -312,7 +312,7 @@ public class DynamicRegionVisualizer implements SWPlayer.Component, Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
dynamicRegion.getArea().place(new PasteBuilder(new PasteBuilder.FileProvider(dynamicRegion.getArea().getResetFile())), false);
|
||||
dynamicRegion.getArea().place(sourceTile.getCenterLocation(), new PasteBuilder(), false);
|
||||
dynamicRegion.updateNeighbours();
|
||||
|
||||
placement = null;
|
||||
|
||||
+1
-1
@@ -73,7 +73,7 @@ public abstract class DynamicRegion implements Region {
|
||||
// Updating world state for all neighbouring PathRegions
|
||||
list.forEach(data -> {
|
||||
if (needsFullReset.contains(data.getKey().getID())) {
|
||||
data.getKey().getArea().reset(null, false);
|
||||
data.getKey().getArea().reset(null,null, false); // TODO: Implement!
|
||||
} else {
|
||||
data.getKey().update(this, data.getValue().opposite());
|
||||
}
|
||||
|
||||
@@ -24,7 +24,10 @@ import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Location;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@Getter
|
||||
@EqualsAndHashCode
|
||||
@@ -134,6 +137,28 @@ public class Tile {
|
||||
return getId(tileX, tileZ);
|
||||
}
|
||||
|
||||
public Stream<Tile> neighboursPlus() {
|
||||
List<Tile> tiles = new ArrayList<>();
|
||||
add(-1, 0).ifPresent(tiles::add);
|
||||
add(1, 0).ifPresent(tiles::add);
|
||||
add(0, -1).ifPresent(tiles::add);
|
||||
add(0, 1).ifPresent(tiles::add);
|
||||
return tiles.stream();
|
||||
}
|
||||
|
||||
public Stream<Tile> neighboursRing() {
|
||||
List<Tile> tiles = new ArrayList<>();
|
||||
add(-1, -1).ifPresent(tiles::add);
|
||||
add(-1, 0).ifPresent(tiles::add);
|
||||
add(-1, 1).ifPresent(tiles::add);
|
||||
add(0, -1).ifPresent(tiles::add);
|
||||
add(0, 1).ifPresent(tiles::add);
|
||||
add(1, -1).ifPresent(tiles::add);
|
||||
add(1, 0).ifPresent(tiles::add);
|
||||
add(1, 1).ifPresent(tiles::add);
|
||||
return tiles.stream();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return tileX + ":" + tileZ;
|
||||
|
||||
+1
-7
@@ -67,14 +67,8 @@ public class GlobalRegion implements Region {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public File getResetFile() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void place(PasteBuilder pasteBuilder, boolean extension) {
|
||||
public void place(Location location, PasteBuilder pasteBuilder, boolean extension) {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+5
-11
@@ -28,9 +28,7 @@ import de.steamwar.bausystem.utils.PasteBuilder;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.NonNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import org.bukkit.Location;
|
||||
|
||||
@AllArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public class AreaBlock implements Region.Area {
|
||||
@@ -162,14 +160,10 @@ public class AreaBlock implements Region.Area {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable File getResetFile() {
|
||||
if (selector == null) return null;
|
||||
return selector.select(region.getID(), 0).orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void place(PasteBuilder pasteBuilder, boolean extension) {
|
||||
EditSession editSession = pasteBuilder.pastePoint(copyPoint)
|
||||
public void place(Location location, PasteBuilder pasteBuilder, boolean extension) {
|
||||
EditSession editSession = pasteBuilder
|
||||
.with(PasteBuilder.ClipboardProvider.file(selector.select(region.getID(), 0).orElse(null)))
|
||||
.pastePoint(copyPoint)
|
||||
.run();
|
||||
region.getHistory()
|
||||
.remember(editSession);
|
||||
|
||||
+2
-6
@@ -26,6 +26,7 @@ import de.steamwar.bausystem.region.dynamic.Tile;
|
||||
import de.steamwar.bausystem.region.dynamic.VariantSelector;
|
||||
import de.steamwar.bausystem.utils.PasteBuilder;
|
||||
import lombok.NonNull;
|
||||
import org.bukkit.Location;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
@@ -65,12 +66,7 @@ public class AreaTile implements Region.Area {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable File getResetFile() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void place(PasteBuilder pasteBuilder, boolean extension) {
|
||||
public void place(Location location, PasteBuilder pasteBuilder, boolean extension) {
|
||||
File resetFile = selector.select(regionIdentifier, 0).orElse(null);
|
||||
if (resetFile != null) PasteUtils.paste(resetFile, minPoint, 0);
|
||||
}
|
||||
|
||||
+27
-4
@@ -19,6 +19,7 @@
|
||||
|
||||
package de.steamwar.bausystem.region.dynamic.path;
|
||||
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.region.DynamicRegionSystem;
|
||||
import de.steamwar.bausystem.region.Point;
|
||||
@@ -31,11 +32,13 @@ import de.steamwar.bausystem.shared.Pair;
|
||||
import de.steamwar.bausystem.utils.PasteBuilder;
|
||||
import lombok.NonNull;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
import static de.steamwar.bausystem.region.RegionType.ConnectionType.*;
|
||||
|
||||
@@ -143,12 +146,32 @@ public class PathArea implements Region.Area {
|
||||
|
||||
@Override
|
||||
public @NonNull Point getCopyPoint() {
|
||||
return copyPoint;
|
||||
return Point.ZERO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable File getResetFile() {
|
||||
return null; // I know what I do!
|
||||
public boolean inRegion(Location location, boolean extension) {
|
||||
return inRegion(location.getBlockX(), location.getBlockZ(), extension);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean inRegion(int x, int z, boolean extension) {
|
||||
// TODO: Implement further!
|
||||
return Region.Area.super.inRegion(x, z, extension);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Clipboard copy(boolean extension) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forEachChunk(BiConsumer<Integer, Integer> executor) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChunkOutside(int chunkX, int chunkZ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void reset(PathSide side) {
|
||||
@@ -191,7 +214,7 @@ public class PathArea implements Region.Area {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void place(PasteBuilder pasteBuilder, boolean extension) {
|
||||
public void place(Location location, PasteBuilder pasteBuilder, boolean extension) {
|
||||
if (region.isGarden()) {
|
||||
File resetFile = GARDEN.select(regionIdentifier, 0).orElse(null);
|
||||
if (resetFile != null) {
|
||||
|
||||
+1
@@ -38,6 +38,7 @@ import java.util.UUID;
|
||||
public class PathRegion extends DynamicRegion {
|
||||
|
||||
private final PathArea area;
|
||||
@Getter
|
||||
private final Tile tile;
|
||||
|
||||
public PathRegion(UUID id, int minX, int minZ) {
|
||||
|
||||
+4
-8
@@ -30,6 +30,7 @@ import de.steamwar.bausystem.region.dynamic.VariantSelector;
|
||||
import de.steamwar.bausystem.utils.PasteBuilder;
|
||||
import lombok.NonNull;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
@@ -76,15 +77,10 @@ public class SpecialArea implements Region.Area {
|
||||
return copyPoint;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable File getResetFile() {
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean resetting = false;
|
||||
|
||||
@Override
|
||||
public void reset(PasteBuilder pasteBuilder, boolean extension) {
|
||||
public void reset(Location location, PasteBuilder pasteBuilder, boolean extension) {
|
||||
if (resetting) return;
|
||||
AtomicBoolean hasResetting = new AtomicBoolean(false);
|
||||
List<Region> regions = DynamicRegionSystem.INSTANCE.getConnectedRegions(region)
|
||||
@@ -102,13 +98,13 @@ public class SpecialArea implements Region.Area {
|
||||
final int offset = i / 10;
|
||||
final Region region = regions.get(i);
|
||||
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
|
||||
region.getArea().place(null, false);
|
||||
region.getArea().place(null, null, false); // TODO: Fix this!
|
||||
}, offset);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void place(PasteBuilder pasteBuilder, boolean extension) {
|
||||
public void place(Location location, PasteBuilder pasteBuilder, boolean extension) {
|
||||
File resetFile = resetFiles.select(regionIdentifier, 0).orElse(null);
|
||||
if (resetFile != null) PasteUtils.paste(resetFile, minPoint, 0);
|
||||
resetting = false;
|
||||
|
||||
+1
-7
@@ -73,14 +73,8 @@ public final class FixedGlobalRegion implements Region {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public File getResetFile() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void place(PasteBuilder pasteBuilder, boolean extension) {
|
||||
public void place(Location location, PasteBuilder pasteBuilder, boolean extension) {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+11
-25
@@ -31,6 +31,7 @@ import de.steamwar.sql.GameModeConfig;
|
||||
import de.steamwar.sql.SchematicType;
|
||||
import lombok.NonNull;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import yapion.hierarchy.types.YAPIONObject;
|
||||
|
||||
@@ -122,7 +123,7 @@ public class FixedRegion implements Region {
|
||||
@Override
|
||||
public boolean load() {
|
||||
if (!file.exists()) return false;
|
||||
EditSession editSession = new PasteBuilder(new PasteBuilder.FileProvider(file))
|
||||
EditSession editSession = new PasteBuilder(PasteBuilder.ClipboardProvider.file(file))
|
||||
.pastePoint(area.getMinPoint(false).add(prototype.getSizeX() / 2, 0, prototype.getSizeZ() / 2))
|
||||
.minPoint(area.getMinPoint(false))
|
||||
.maxPoint(area.getMaxPoint(false))
|
||||
@@ -174,15 +175,10 @@ public class FixedRegion implements Region {
|
||||
return minPoint;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public File getResetFile() {
|
||||
return prototype.getSkinMap().get(skin).getSchematicFile();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void place(PasteBuilder pasteBuilder, boolean extension) {
|
||||
pasteBuilder.reset(extension)
|
||||
public void place(Location location, PasteBuilder pasteBuilder, boolean extension) {
|
||||
pasteBuilder.with(PasteBuilder.ClipboardProvider.file(prototype.getSkinMap().get(skin).getSchematicFile()))
|
||||
.reset(extension)
|
||||
.minPoint(getMinPoint(extension))
|
||||
.maxPoint(getMaxPoint(extension))
|
||||
.waterLevel(waterLevel);
|
||||
@@ -227,15 +223,10 @@ public class FixedRegion implements Region {
|
||||
return copyPoint;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public File getResetFile() {
|
||||
return prototype.getSkinMap().get(skin).getBuildSchematicFile();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void place(PasteBuilder pasteBuilder, boolean extension) {
|
||||
pasteBuilder.reset(extension)
|
||||
public void place(Location location, PasteBuilder pasteBuilder, boolean extension) {
|
||||
pasteBuilder.with(PasteBuilder.ClipboardProvider.file(prototype.getSkinMap().get(skin).getBuildSchematicFile()))
|
||||
.reset(extension)
|
||||
.minPoint(getMinPoint(extension))
|
||||
.maxPoint(getMaxPoint(extension))
|
||||
.waterLevel(waterLevel);
|
||||
@@ -281,15 +272,10 @@ public class FixedRegion implements Region {
|
||||
return copyPoint;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public File getResetFile() {
|
||||
return prototype.getSkinMap().get(skin).getTestblockSchematicFile();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void place(PasteBuilder pasteBuilder, boolean extension) {
|
||||
pasteBuilder.reset(extension)
|
||||
public void place(Location location, PasteBuilder pasteBuilder, boolean extension) {
|
||||
pasteBuilder.with(PasteBuilder.ClipboardProvider.file(prototype.getSkinMap().get(skin).getTestblockSchematicFile()))
|
||||
.reset(extension)
|
||||
.minPoint(getMinPoint(extension))
|
||||
.maxPoint(getMaxPoint(extension))
|
||||
.waterLevel(waterLevel);
|
||||
|
||||
Reference in New Issue
Block a user