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