TestBlockPaste-Without-Water #146
@ -130,6 +130,7 @@ public class FlatteningWrapper15 implements FlatteningWrapper {
|
|||||||
try (EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(new BukkitWorld(Bukkit.getWorlds().get(0)), -1)) {
|
try (EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(new BukkitWorld(Bukkit.getWorlds().get(0)), -1)) {
|
||||||
Clipboard clipboard = pasteBuilder.getClipboard();
|
Clipboard clipboard = pasteBuilder.getClipboard();
|
||||||
|
|
||||||
|
if (!pasteBuilder.getMappers().isEmpty()) {
|
||||||
BlockVector3 minimum = clipboard.getRegion().getMinimumPoint();
|
BlockVector3 minimum = clipboard.getRegion().getMinimumPoint();
|
||||||
for (int x = 0; x < clipboard.getDimensions().getX(); x++) {
|
for (int x = 0; x < clipboard.getDimensions().getX(); x++) {
|
||||||
for (int y = 0; y < clipboard.getDimensions().getY(); y++) {
|
for (int y = 0; y < clipboard.getDimensions().getY(); y++) {
|
||||||
@ -139,11 +140,12 @@ public class FlatteningWrapper15 implements FlatteningWrapper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!pasteBuilder.getPredicates().isEmpty()) {
|
||||||
e.setMask(new Mask() {
|
e.setMask(new Mask() {
|
||||||
@Override
|
@Override
|
||||||
public boolean test(BlockVector3 blockVector3) {
|
public boolean test(BlockVector3 blockVector3) {
|
||||||
if (pasteBuilder.getPredicates().isEmpty()) return true;
|
|
||||||
BaseBlock block = clipboard.getFullBlock(blockVector3);
|
BaseBlock block = clipboard.getFullBlock(blockVector3);
|
||||||
zOnlyKroks markierte diese Unterhaltung als gelöst
Veraltet
|
|||||||
String blockName = block.toString().toLowerCase();
|
String blockName = block.toString().toLowerCase();
|
||||||
for (BiPredicate<BaseBlock, String> predicate : pasteBuilder.getPredicates()) {
|
for (BiPredicate<BaseBlock, String> predicate : pasteBuilder.getPredicates()) {
|
||||||
@ -158,6 +160,7 @@ public class FlatteningWrapper15 implements FlatteningWrapper {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
zOnlyKroks markierte diese Unterhaltung als gelöst
Veraltet
Lixfel
hat
Waterlogged-Blöcke werden ebenso Probleme machen. Da könnte man auf ein contains waterlogged=true machen oder ggf. statt über Strings auch direkt über die WorldEdit-Materials/-Blocks, aber das wäre ein größerer Umbau. Waterlogged-Blöcke werden ebenso Probleme machen. Da könnte man auf ein contains waterlogged=true machen oder ggf. statt über Strings auch direkt über die WorldEdit-Materials/-Blocks, aber das wäre ein größerer Umbau.
|
|||||||
|
}
|
||||||
|
|
||||||
ClipboardHolder ch = new ClipboardHolder(clipboard);
|
ClipboardHolder ch = new ClipboardHolder(clipboard);
|
||||||
BlockVector3 dimensions = clipboard.getDimensions();
|
BlockVector3 dimensions = clipboard.getDimensions();
|
||||||
|
@ -19,10 +19,15 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.features.backup;
|
package de.steamwar.bausystem.features.backup;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.EditSession;
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.Permission;
|
import de.steamwar.bausystem.Permission;
|
||||||
|
import de.steamwar.bausystem.region.Color;
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
|
import de.steamwar.bausystem.region.flags.Flag;
|
||||||
|
import de.steamwar.bausystem.region.flags.flagvalues.ColorMode;
|
||||||
import de.steamwar.bausystem.region.tags.Tag;
|
import de.steamwar.bausystem.region.tags.Tag;
|
||||||
|
import de.steamwar.bausystem.utils.PasteBuilder;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.command.SWCommandUtils;
|
import de.steamwar.command.SWCommandUtils;
|
||||||
import de.steamwar.command.TypeMapper;
|
import de.steamwar.command.TypeMapper;
|
||||||
@ -85,7 +90,14 @@ public class BackupCommand extends SWCommand {
|
|||||||
BauSystem.MESSAGE.send("BACKUP_LOAD_FAILURE", p);
|
BauSystem.MESSAGE.send("BACKUP_LOAD_FAILURE", p);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
region.reset(backupFile);
|
EditSession editSession = new PasteBuilder(new PasteBuilder.FileProvider(backupFile))
|
||||||
|
.pastePoint(region.getMinPoint().add(region.getPrototype().getSizeX() / 2, 0, region.getPrototype().getSizeZ() / 2))
|
||||||
|
.color(region.getPlain(Flag.COLOR, ColorMode.class).getColor())
|
||||||
|
.minPoint(region.getMinPoint())
|
||||||
|
.maxPoint(region.getMaxPoint())
|
||||||
|
.waterLevel(region.getWaterLevel())
|
||||||
|
.run();
|
||||||
|
region.remember(editSession);
|
||||||
BauSystem.MESSAGE.send("BACKUP_LOAD", p);
|
BauSystem.MESSAGE.send("BACKUP_LOAD", p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@ import de.steamwar.bausystem.region.flags.Flag;
|
|||||||
import de.steamwar.bausystem.region.flags.flagvalues.ColorMode;
|
import de.steamwar.bausystem.region.flags.flagvalues.ColorMode;
|
||||||
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.utils.PasteBuilder;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.command.TypeValidator;
|
import de.steamwar.command.TypeValidator;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
@ -64,10 +65,13 @@ public class ColorCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
region.set(Flag.COLOR, color);
|
region.set(Flag.COLOR, color);
|
||||||
try {
|
try {
|
||||||
region.reset(null, RegionType.NORMAL, RegionExtensionType.NORMAL, true, true,false,false);
|
PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.FileProvider(region.getResetFile(RegionType.NORMAL)))
|
||||||
|
.ignoreAir(true)
|
||||||
|
.onlyColors();
|
||||||
|
region.reset(pasteBuilder, RegionType.NORMAL, RegionExtensionType.NORMAL);
|
||||||
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 (IOException e) {
|
} catch (SecurityException e) {
|
||||||
BauSystem.MESSAGE.send("REGION_REGION_FAILED_COLORED", p);
|
BauSystem.MESSAGE.send("REGION_REGION_FAILED_COLORED", p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,7 @@ import de.steamwar.bausystem.region.Region;
|
|||||||
import de.steamwar.bausystem.region.RegionUtils;
|
import de.steamwar.bausystem.region.RegionUtils;
|
||||||
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.utils.PasteBuilder;
|
||||||
import de.steamwar.command.PreviousArguments;
|
import de.steamwar.command.PreviousArguments;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.command.TypeMapper;
|
import de.steamwar.command.TypeMapper;
|
||||||
@ -99,9 +100,11 @@ public class RegionCommand extends SWCommand {
|
|||||||
if(checkGlobalRegion(region, p)) return;
|
if(checkGlobalRegion(region, p)) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
region.reset(null, RegionType.NORMAL, RegionExtensionType.NORMAL, true, false,false,false);
|
PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.FileProvider(region.getResetFile(RegionType.NORMAL)))
|
||||||
|
.ignoreAir(true);
|
||||||
|
region.reset(pasteBuilder, RegionType.NORMAL, RegionExtensionType.NORMAL);
|
||||||
RegionUtils.message(region, "REGION_REGION_RESTORED");
|
RegionUtils.message(region, "REGION_REGION_RESTORED");
|
||||||
} catch (IOException e) {
|
} catch (SecurityException e) {
|
||||||
BauSystem.MESSAGE.send("REGION_REGION_FAILED_RESTORE", p);
|
BauSystem.MESSAGE.send("REGION_REGION_FAILED_RESTORE", p);
|
||||||
Bukkit.getLogger().log(Level.WARNING, "Failed restore", e);
|
Bukkit.getLogger().log(Level.WARNING, "Failed restore", e);
|
||||||
}
|
}
|
||||||
@ -118,9 +121,11 @@ public class RegionCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
region.reset(node, RegionType.NORMAL, RegionExtensionType.NORMAL, true,false,false,false);
|
PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.SchematicProvider(node))
|
||||||
|
.ignoreAir(true);
|
||||||
|
region.reset(pasteBuilder, RegionType.NORMAL, RegionExtensionType.NORMAL);
|
||||||
RegionUtils.message(region, "REGION_REGION_RESTORED");
|
RegionUtils.message(region, "REGION_REGION_RESTORED");
|
||||||
} catch (IOException e) {
|
} catch (SecurityException e) {
|
||||||
BauSystem.MESSAGE.send("REGION_REGION_FAILED_RESTORE", p);
|
BauSystem.MESSAGE.send("REGION_REGION_FAILED_RESTORE", p);
|
||||||
Bukkit.getLogger().log(Level.WARNING, "Failed restore", e);
|
Bukkit.getLogger().log(Level.WARNING, "Failed restore", e);
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,7 @@ import de.steamwar.bausystem.region.Region;
|
|||||||
import de.steamwar.bausystem.region.RegionUtils;
|
import de.steamwar.bausystem.region.RegionUtils;
|
||||||
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.utils.PasteBuilder;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.command.TypeValidator;
|
import de.steamwar.command.TypeValidator;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
@ -55,9 +56,10 @@ public class ResetCommand extends SWCommand {
|
|||||||
Region region = regionCheck(p);
|
Region region = regionCheck(p);
|
||||||
if (region == null) return;
|
if (region == null) return;
|
||||||
try {
|
try {
|
||||||
region.reset(null,RegionType.NORMAL, RegionExtensionType.NORMAL,false,false,false,false);
|
PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.FileProvider(region.getResetFile(RegionType.NORMAL)))
|
||||||
|
region.reset(pasteBuilder, RegionType.NORMAL, RegionExtensionType.NORMAL);
|
||||||
RegionUtils.message(region, "REGION_RESET_RESETED");
|
RegionUtils.message(region, "REGION_RESET_RESETED");
|
||||||
} catch (IOException e) {
|
} catch (SecurityException e) {
|
||||||
BauSystem.MESSAGE.send("REGION_RESET_ERROR", p);
|
BauSystem.MESSAGE.send("REGION_RESET_ERROR", p);
|
||||||
Bukkit.getLogger().log(Level.WARNING, "Failed testblock", e);
|
Bukkit.getLogger().log(Level.WARNING, "Failed testblock", e);
|
||||||
}
|
}
|
||||||
@ -82,9 +84,10 @@ public class ResetCommand extends SWCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
region.reset(node, RegionType.NORMAL,RegionExtensionType.NORMAL,false,false,false,false);
|
PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.SchematicProvider(node));
|
||||||
|
region.reset(pasteBuilder, RegionType.NORMAL, RegionExtensionType.NORMAL);
|
||||||
RegionUtils.message(region, "REGION_RESET_RESETED");
|
RegionUtils.message(region, "REGION_RESET_RESETED");
|
||||||
} catch (IOException e) {
|
} catch (SecurityException e) {
|
||||||
BauSystem.MESSAGE.send("REGION_RESET_ERROR", p);
|
BauSystem.MESSAGE.send("REGION_RESET_ERROR", p);
|
||||||
Bukkit.getLogger().log(Level.WARNING, "Failed reset", e);
|
Bukkit.getLogger().log(Level.WARNING, "Failed reset", e);
|
||||||
}
|
}
|
||||||
|
@ -24,8 +24,11 @@ import de.steamwar.bausystem.Permission;
|
|||||||
import de.steamwar.bausystem.config.BauServer;
|
import de.steamwar.bausystem.config.BauServer;
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.bausystem.region.RegionUtils;
|
import de.steamwar.bausystem.region.RegionUtils;
|
||||||
|
import de.steamwar.bausystem.region.flags.Flag;
|
||||||
|
import de.steamwar.bausystem.region.flags.flagvalues.ColorMode;
|
||||||
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.utils.PasteBuilder;
|
||||||
import de.steamwar.command.PreviousArguments;
|
import de.steamwar.command.PreviousArguments;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.command.TypeMapper;
|
import de.steamwar.command.TypeMapper;
|
||||||
@ -96,9 +99,16 @@ public class TestblockCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
region.reset(node, RegionType.TESTBLOCK, regionExtensionType, ignoreAir, onlyColors, removeTNT, removeWater);
|
PasteBuilder.ClipboardProvider clipboardProvider = node == null ? new PasteBuilder.FileProvider(region.getResetFile(RegionType.TESTBLOCK)) : new PasteBuilder.SchematicProvider(node);
|
||||||
|
PasteBuilder pasteBuilder = new PasteBuilder(clipboardProvider)
|
||||||
|
.ignoreAir(ignoreAir)
|
||||||
|
.onlyColors(onlyColors)
|
||||||
|
.removeTNT(removeTNT)
|
||||||
|
.removeWater(removeWater)
|
||||||
|
.color(region.getPlain(Flag.COLOR, ColorMode.class).getColor());
|
||||||
|
region.reset(pasteBuilder, RegionType.TESTBLOCK, regionExtensionType);
|
||||||
RegionUtils.message(region, "REGION_TB_DONE");
|
RegionUtils.message(region, "REGION_TB_DONE");
|
||||||
} catch (IOException e) {
|
} catch (SecurityException e) {
|
||||||
BauSystem.MESSAGE.send("REGION_TB_ERROR", p);
|
BauSystem.MESSAGE.send("REGION_TB_ERROR", p);
|
||||||
Bukkit.getLogger().log(Level.WARNING, "Failed testblock", e);
|
Bukkit.getLogger().log(Level.WARNING, "Failed testblock", e);
|
||||||
}
|
}
|
||||||
|
@ -22,19 +22,17 @@ package de.steamwar.bausystem.region;
|
|||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
||||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.region.flags.Flag;
|
import de.steamwar.bausystem.region.flags.Flag;
|
||||||
import de.steamwar.bausystem.region.flags.flagvalues.ColorMode;
|
|
||||||
import de.steamwar.bausystem.region.flags.flagvalues.TNTMode;
|
import de.steamwar.bausystem.region.flags.flagvalues.TNTMode;
|
||||||
import de.steamwar.bausystem.region.tags.Tag;
|
import de.steamwar.bausystem.region.tags.Tag;
|
||||||
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.shared.SizedStack;
|
import de.steamwar.bausystem.shared.SizedStack;
|
||||||
import de.steamwar.bausystem.utils.FlatteningWrapper;
|
import de.steamwar.bausystem.utils.FlatteningWrapper;
|
||||||
|
import de.steamwar.bausystem.utils.PasteBuilder;
|
||||||
import de.steamwar.core.Core;
|
import de.steamwar.core.Core;
|
||||||
import de.steamwar.sql.SchematicData;
|
import de.steamwar.sql.SchematicType;
|
||||||
import de.steamwar.sql.SchematicNode;
|
|
||||||
import lombok.AccessLevel;
|
import lombok.AccessLevel;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
@ -45,7 +43,6 @@ import yapion.hierarchy.types.YAPIONType;
|
|||||||
import yapion.hierarchy.types.YAPIONValue;
|
import yapion.hierarchy.types.YAPIONValue;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@ -53,8 +50,6 @@ import java.util.function.ObjIntConsumer;
|
|||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static de.steamwar.bausystem.region.RegionUtils.paste;
|
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
public class Region {
|
public class Region {
|
||||||
|
|
||||||
@ -413,13 +408,22 @@ public class Region {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reset(File file) {
|
public File getResetFile(RegionType regionType) {
|
||||||
EditSession editSession = paste(file, minPoint.add(prototype.getSizeX() / 2, 0, prototype.getSizeZ() / 2), new PasteOptions(false, false, Color.YELLOW, false, false, getMinPoint(RegionType.NORMAL, RegionExtensionType.NORMAL), getMaxPoint(RegionType.NORMAL, RegionExtensionType.NORMAL), waterLevel, false,false,false));
|
if (!hasReset(regionType)) {
|
||||||
initSessions();
|
return null;
|
||||||
undoSessions.push(editSession);
|
}
|
||||||
|
switch (regionType) {
|
||||||
|
case TESTBLOCK:
|
||||||
|
return prototype.getSkinMap().get(skin).getTestblockSchematicFile();
|
||||||
|
case BUILD:
|
||||||
|
return prototype.getSkinMap().get(skin).getBuildSchematicFile();
|
||||||
|
default:
|
||||||
|
case NORMAL:
|
||||||
|
return prototype.getSkinMap().get(skin).getSchematicFile();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
zOnlyKroks markierte diese Unterhaltung als gelöst
Veraltet
YoyoNow
hat
Muss diese Änderung eigentlich wirklich sein? Muss diese Änderung eigentlich wirklich sein?
|
|||||||
public void reset(SchematicNode schematic, RegionType regionType, RegionExtensionType regionExtensionType, boolean ignoreAir, boolean onlyColors,boolean removeTNT, boolean removeWater) throws IOException {
|
public void reset(PasteBuilder pasteBuilder, RegionType regionType, RegionExtensionType regionExtensionType) {
|
||||||
if (!hasReset(regionType)) {
|
if (!hasReset(regionType)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -427,54 +431,50 @@ public class Region {
|
|||||||
regionExtensionType = RegionExtensionType.NORMAL;
|
regionExtensionType = RegionExtensionType.NORMAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
PasteOptions pasteOptions = new PasteOptions((schematic != null && (schematic.getSchemtype().fightType() || schematic.getSchemtype().check())), ignoreAir, getPlain(Flag.COLOR, ColorMode.class).getColor(), onlyColors, regionExtensionType == RegionExtensionType.EXTENSION, getMinPoint(regionType, regionExtensionType), getMaxPoint(regionType, regionExtensionType), waterLevel, regionType == RegionType.TESTBLOCK,removeTNT,removeWater);
|
pasteBuilder.reset(regionExtensionType == RegionExtensionType.EXTENSION)
|
||||||
|
.minPoint(getMinPoint(regionType, regionExtensionType))
|
||||||
|
.maxPoint(getMaxPoint(regionType, regionExtensionType))
|
||||||
|
.waterLevel(waterLevel);
|
||||||
|
if (pasteBuilder.getClipboardProvider().is(PasteBuilder.SchematicProvider.class)) {
|
||||||
|
SchematicType schematicType = pasteBuilder.getClipboardProvider().as(PasteBuilder.SchematicProvider.class).getSchematic().getSchemtype();
|
||||||
|
pasteBuilder.rotate(schematicType.fightType() || schematicType.check());
|
||||||
|
}
|
||||||
|
|
||||||
Point pastePoint;
|
|
||||||
File tempFile = null;
|
|
||||||
Clipboard clipboard = null;
|
|
||||||
switch (regionType) {
|
switch (regionType) {
|
||||||
case BUILD:
|
case BUILD:
|
||||||
pastePoint = minPointBuild.add(prototype.getBuild().getSizeX() / 2, 0, prototype.getBuild().getSizeZ() / 2);
|
pasteBuilder.pastePoint(minPointBuild.add(prototype.getBuild().getSizeX() / 2, 0, prototype.getBuild().getSizeZ() / 2));
|
||||||
if (schematic == null) {
|
|
||||||
tempFile = prototype.getSkinMap().get(skin).getBuildSchematicFile();
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case TESTBLOCK:
|
case TESTBLOCK:
|
||||||
pastePoint = minPointTestblock.add(prototype.getTestblock().getSizeX() / 2, 0, 0);
|
Point pastePoint = minPointTestblock.add(prototype.getTestblock().getSizeX() / 2, 0, 0);
|
||||||
if (schematic == null) {
|
if (!pasteBuilder.getClipboardProvider().is(PasteBuilder.SchematicProvider.class)) {
|
||||||
tempFile = prototype.getSkinMap().get(skin).getTestblockSchematicFile();
|
|
||||||
pastePoint = pastePoint.add(0, 0, prototype.getTestblock().getSizeZ() / 2);
|
pastePoint = pastePoint.add(0, 0, prototype.getTestblock().getSizeZ() / 2);
|
||||||
zOnlyKroks markierte diese Unterhaltung als gelöst
Veraltet
YoyoNow
hat
hier dann einfach den hier dann einfach den `isTextBlock` Boolean zu einem `regionType == RegionType.TESTBLOCK` ersetzten, dann brauchst du die ganzen booleans nicht.
|
|||||||
} else {
|
} else {
|
||||||
clipboard = new SchematicData(schematic).load();
|
int dz = Math.abs(pasteBuilder.getClipboard().getOrigin().getZ() - pasteBuilder.getClipboard().getMinimumPoint().getZ());
|
||||||
int dz = Math.abs(clipboard.getOrigin().getZ() - clipboard.getMinimumPoint().getZ());
|
|
||||||
if (dz < 2 || dz > prototype.getTestblock().getSizeZ()) {
|
if (dz < 2 || dz > prototype.getTestblock().getSizeZ()) {
|
||||||
pastePoint = pastePoint.add(0, 0, prototype.getTestblock().getSizeZ() / 2);
|
pastePoint = pastePoint.add(0, 0, prototype.getTestblock().getSizeZ() / 2);
|
||||||
} else if (clipboard.getDimensions().getZ() != prototype.getTestblock().getSizeZ()) {
|
} else if (pasteBuilder.getClipboard().getDimensions().getZ() != prototype.getTestblock().getSizeZ()) {
|
||||||
pastePoint = pastePoint.add(0, 0, clipboard.getDimensions().getZ() / 2 - (clipboard.getOrigin().getZ() - clipboard.getMinimumPoint().getZ()) - 1);
|
pastePoint = pastePoint.add(0, 0, pasteBuilder.getClipboard().getDimensions().getZ() / 2 - (pasteBuilder.getClipboard().getOrigin().getZ() - pasteBuilder.getClipboard().getMinimumPoint().getZ()) - 1);
|
||||||
} else {
|
} else {
|
||||||
pastePoint = pastePoint.add(0, 0, prototype.getTestblock().getSizeZ() / 2);
|
pastePoint = pastePoint.add(0, 0, prototype.getTestblock().getSizeZ() / 2);
|
||||||
}
|
}
|
||||||
if (schematic.getSchemtype().getKuerzel().equalsIgnoreCase("wg")) {
|
SchematicType schematicType = pasteBuilder.getClipboardProvider().as(PasteBuilder.SchematicProvider.class).getSchematic().getSchemtype();
|
||||||
|
if (schematicType.getKuerzel().equalsIgnoreCase("wg")) {
|
||||||
pastePoint = pastePoint.add(0, 0, 1);
|
pastePoint = pastePoint.add(0, 0, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
pasteBuilder.pastePoint(pastePoint);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
case NORMAL:
|
case NORMAL:
|
||||||
pastePoint = minPoint.add(prototype.getSizeX() / 2, 0, prototype.getSizeZ() / 2);
|
pasteBuilder.pastePoint(minPoint.add(prototype.getSizeX() / 2, 0, prototype.getSizeZ() / 2));
|
||||||
if (schematic == null) {
|
|
||||||
tempFile = prototype.getSkinMap().get(skin).getSchematicFile();
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
EditSession editSession = null;
|
initSessions();
|
||||||
if (schematic != null) {
|
undoSessions.push(pasteBuilder.run());
|
||||||
editSession = paste(clipboard != null ? clipboard : new SchematicData(schematic).load(), pastePoint, pasteOptions);
|
|
||||||
} else {
|
|
||||||
editSession = paste(tempFile, pastePoint, pasteOptions);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void remember(EditSession editSession) {
|
||||||
initSessions();
|
initSessions();
|
||||||
undoSessions.push(editSession);
|
undoSessions.push(editSession);
|
||||||
}
|
}
|
||||||
|
@ -81,14 +81,6 @@ public class RegionUtils {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
static EditSession paste(File file, Point pastePoint, PasteOptions pasteOptions) {
|
|
||||||
return FlatteningWrapper.impl.paste(file, pastePoint, pasteOptions);
|
|
||||||
}
|
|
||||||
|
|
||||||
static EditSession paste(Clipboard clipboard, Point pastePoint, PasteOptions pasteOptions) {
|
|
||||||
return FlatteningWrapper.impl.paste(clipboard, pastePoint, pasteOptions);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void save(Region region) {
|
static void save(Region region) {
|
||||||
if (region.getPrototype() != null) {
|
if (region.getPrototype() != null) {
|
||||||
region.regionData.add("prototype", region.getPrototype().getName());
|
region.regionData.add("prototype", region.getPrototype().getName());
|
||||||
|
@ -21,24 +21,29 @@ package de.steamwar.bausystem.utils;
|
|||||||
|
|
||||||
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 com.sk89q.worldedit.function.pattern.WaterloggedRemover;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
|
import de.steamwar.bausystem.region.Color;
|
||||||
import de.steamwar.bausystem.region.Point;
|
import de.steamwar.bausystem.region.Point;
|
||||||
import de.steamwar.sql.SchematicData;
|
import de.steamwar.sql.SchematicData;
|
||||||
import de.steamwar.sql.SchematicNode;
|
import de.steamwar.sql.SchematicNode;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
import lombok.NonNull;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
import java.util.function.BiPredicate;
|
import java.util.function.BiPredicate;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
public class PasteBuilder {
|
public class PasteBuilder {
|
||||||
|
|
||||||
private final Clipboard clipboard;
|
private final ClipboardProvider clipboardProvider;
|
||||||
private Point pastPoint;
|
private Point pastPoint;
|
||||||
private boolean rotate;
|
private boolean rotate;
|
||||||
private boolean ignoreAir;
|
private boolean ignoreAir;
|
||||||
@ -49,20 +54,8 @@ 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(SchematicNode schematic) {
|
public PasteBuilder(@NonNull ClipboardProvider clipboardProvider) {
|
||||||
try {
|
this.clipboardProvider = clipboardProvider;
|
||||||
this.clipboard = new SchematicData(schematic).load();
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new SecurityException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public PasteBuilder(Clipboard clipboard) {
|
|
||||||
this.clipboard = clipboard;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PasteBuilder(File file) {
|
|
||||||
this.clipboard = FlatteningWrapper.impl.loadSchematic(file);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public PasteBuilder pastePoint(Point point) {
|
public PasteBuilder pastePoint(Point point) {
|
||||||
@ -70,18 +63,18 @@ public class PasteBuilder {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PasteBuilder rotate() {
|
public PasteBuilder rotate(boolean rotate) {
|
||||||
this.rotate = true;
|
this.rotate = rotate;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PasteBuilder ignoreAir() {
|
public PasteBuilder ignoreAir(boolean ignoreAir) {
|
||||||
this.ignoreAir = true;
|
this.ignoreAir = ignoreAir;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PasteBuilder reset() {
|
public PasteBuilder reset(boolean reset) {
|
||||||
this.reset = true;
|
this.reset = reset;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,7 +103,160 @@ public class PasteBuilder {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PasteBuilder color(Color color) {
|
||||||
|
if (color == Color.PINK) return this;
|
||||||
|
|
||||||
|
BaseBlock WOOL = Objects.requireNonNull(BlockTypes.PINK_WOOL).getDefaultState().toBaseBlock();
|
||||||
|
BaseBlock CLAY = Objects.requireNonNull(BlockTypes.PINK_TERRACOTTA).getDefaultState().toBaseBlock();
|
||||||
|
BaseBlock GLAZED = Objects.requireNonNull(BlockTypes.PINK_GLAZED_TERRACOTTA).getDefaultState().toBaseBlock();
|
||||||
|
BaseBlock GLASS = Objects.requireNonNull(BlockTypes.PINK_STAINED_GLASS).getDefaultState().toBaseBlock();
|
||||||
|
BaseBlock GLASS_PANE = Objects.requireNonNull(BlockTypes.PINK_STAINED_GLASS_PANE).getDefaultState().toBaseBlock();
|
||||||
|
BaseBlock CONCRETE = Objects.requireNonNull(BlockTypes.PINK_CONCRETE).getDefaultState().toBaseBlock();
|
||||||
|
BaseBlock CONCRETE_POWDER = Objects.requireNonNull(BlockTypes.PINK_CONCRETE_POWDER).getDefaultState().toBaseBlock();
|
||||||
|
BaseBlock CARPET = Objects.requireNonNull(BlockTypes.PINK_CARPET).getDefaultState().toBaseBlock();
|
||||||
|
|
||||||
|
BaseBlock wool = Objects.requireNonNull(BlockTypes.get(color.name().toLowerCase() + "_wool")).getDefaultState().toBaseBlock();
|
||||||
|
BaseBlock clay = Objects.requireNonNull(BlockTypes.get(color.name().toLowerCase() + "_terracotta")).getDefaultState().toBaseBlock();
|
||||||
|
BaseBlock glazed = Objects.requireNonNull(BlockTypes.get(color.name().toLowerCase() + "_glazed_terracotta")).getDefaultState().toBaseBlock();
|
||||||
|
BaseBlock glass = Objects.requireNonNull(BlockTypes.get(color.name().toLowerCase() + "_stained_glass")).getDefaultState().toBaseBlock();
|
||||||
|
BaseBlock glassPane = Objects.requireNonNull(BlockTypes.get(color.name().toLowerCase() + "_stained_glass_pane")).getDefaultState().toBaseBlock();
|
||||||
|
BaseBlock carpet = Objects.requireNonNull(BlockTypes.get(color.name().toLowerCase() + "_carpet")).getDefaultState().toBaseBlock();
|
||||||
|
BaseBlock concrete = Objects.requireNonNull(BlockTypes.get(color.name().toLowerCase() + "_concrete")).getDefaultState().toBaseBlock();
|
||||||
|
BaseBlock concretePowder = Objects.requireNonNull(BlockTypes.get(color.name().toLowerCase() + "_concrete_powder")).getDefaultState().toBaseBlock();
|
||||||
|
|
||||||
|
return map((clipboard, blockVector3) -> {
|
||||||
|
BaseBlock block = clipboard.getFullBlock(blockVector3);
|
||||||
|
if (block.equals(WOOL)) {
|
||||||
|
clipboard.setBlock(blockVector3, wool);
|
||||||
|
} else if (block.equals(CLAY)) {
|
||||||
|
clipboard.setBlock(blockVector3, clay);
|
||||||
|
} else if (block.equals(GLAZED)) {
|
||||||
|
clipboard.setBlock(blockVector3, glazed);
|
||||||
|
} else if (block.equals(GLASS)) {
|
||||||
|
clipboard.setBlock(blockVector3, glass);
|
||||||
|
} else if (block.equals(GLASS_PANE)) {
|
||||||
|
clipboard.setBlock(blockVector3, glassPane);
|
||||||
|
} else if (block.equals(CARPET)) {
|
||||||
|
clipboard.setBlock(blockVector3, carpet);
|
||||||
|
} else if (block.equals(CONCRETE)) {
|
||||||
|
clipboard.setBlock(blockVector3, concrete);
|
||||||
|
} else if (block.equals(CONCRETE_POWDER)) {
|
||||||
|
clipboard.setBlock(blockVector3, concretePowder);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public PasteBuilder onlyColors(boolean onlyColors) {
|
||||||
|
if (!onlyColors) return this;
|
||||||
|
return only((baseBlock, s) -> {
|
||||||
|
return s.endsWith("_wool") || s.endsWith("_terracotta") || s.endsWith("_glazed_terracotta") || s.endsWith("_stained_glass") || s.endsWith("_stained_glass_pane") || s.endsWith("_carpet") || s.endsWith("_concrete") || s.endsWith("_concrete_powder");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public PasteBuilder removeTNT(boolean removeTNT) {
|
||||||
|
if (!removeTNT) return this;
|
||||||
|
BaseBlock tnt = Objects.requireNonNull(BlockTypes.get("tnt")).getDefaultState().toBaseBlock();
|
||||||
|
BaseBlock air = Objects.requireNonNull(BlockTypes.get("air")).getDefaultState().toBaseBlock();
|
||||||
|
|
||||||
|
return map((clipboard, blockVector3) -> {
|
||||||
|
BaseBlock baseBlock = clipboard.getFullBlock(blockVector3);
|
||||||
|
if (baseBlock.equals(tnt)) {
|
||||||
|
clipboard.setBlock(blockVector3, air);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public PasteBuilder removeWater(boolean removeWater) {
|
||||||
|
if (!removeWater) return this;
|
||||||
|
BaseBlock water = Objects.requireNonNull(BlockTypes.get("water")).getDefaultState().toBaseBlock();
|
||||||
|
BaseBlock air = Objects.requireNonNull(BlockTypes.get("air")).getDefaultState().toBaseBlock();
|
||||||
|
WaterloggedRemover waterloggedRemover = new WaterloggedRemover(getClipboard());
|
||||||
|
|
||||||
|
return map((clipboard, blockVector3) -> {
|
||||||
|
BaseBlock baseBlock = clipboard.getFullBlock(blockVector3);
|
||||||
|
if (baseBlock.equals(water)) {
|
||||||
|
clipboard.setBlock(blockVector3, air);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String blockName = clipboard.getFullBlock(blockVector3).getBlockType().getName();
|
||||||
|
if (blockName.equals("Water")) {
|
||||||
|
clipboard.setBlock(blockVector3, air);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
clipboard.setBlock(blockVector3, waterloggedRemover.applyBlock(blockVector3));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public Clipboard getClipboard() {
|
||||||
|
return clipboardProvider.getClipboard();
|
||||||
|
}
|
||||||
|
|
||||||
public EditSession run() {
|
public EditSession run() {
|
||||||
|
if (pastPoint == null) {
|
||||||
|
throw new IllegalStateException("pastePoint is null");
|
||||||
|
}
|
||||||
return FlatteningWrapper.impl.paste(this);
|
return FlatteningWrapper.impl.paste(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public interface ClipboardProvider {
|
||||||
|
Clipboard getClipboard();
|
||||||
|
|
||||||
|
default <T extends ClipboardProvider> boolean is(Class<T> clazz) {
|
||||||
|
return clazz.isInstance(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
default <T extends ClipboardProvider> T as(Class<T> clazz) {
|
||||||
|
return clazz.cast(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
public static class FileProvider implements ClipboardProvider {
|
||||||
|
private final File file;
|
||||||
|
private final Clipboard clipboard;
|
||||||
|
|
||||||
|
public FileProvider(File file) {
|
||||||
|
this.file = file;
|
||||||
|
this.clipboard = FlatteningWrapper.impl.loadSchematic(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Clipboard getClipboard() {
|
||||||
|
return clipboard;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
public static class SchematicProvider implements ClipboardProvider {
|
||||||
|
private final SchematicNode schematic;
|
||||||
|
private final Clipboard clipboard;
|
||||||
|
|
||||||
|
public SchematicProvider(SchematicNode schematic) {
|
||||||
|
this.schematic = schematic;
|
||||||
|
try {
|
||||||
|
this.clipboard = new SchematicData(schematic).load();
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new SecurityException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Clipboard getClipboard() {
|
||||||
|
return clipboard;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
public static class ClipboardProviderImpl implements ClipboardProvider {
|
||||||
|
private final Clipboard clipboard;
|
||||||
|
|
||||||
|
public ClipboardProviderImpl(Clipboard clipboard) {
|
||||||
|
this.clipboard = clipboard;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Clipboard getClipboard() {
|
||||||
|
return clipboard;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren
Warum schreibst das hier immer rein und machst es nicht optional anhand von dem color flag?