forked from SteamWar/SteamWar
Implement Area for FixedRegion
This commit is contained in:
@@ -19,7 +19,8 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.region;
|
package de.steamwar.bausystem.region;
|
||||||
|
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||||
|
import de.steamwar.bausystem.utils.FlatteningWrapper;
|
||||||
import de.steamwar.bausystem.utils.PasteBuilder;
|
import de.steamwar.bausystem.utils.PasteBuilder;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@@ -100,7 +101,7 @@ public interface Region {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EditSession copy(boolean extension) {
|
public Clipboard copy(boolean extension) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,7 +147,9 @@ public interface Region {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
EditSession copy(boolean extension);
|
default Clipboard copy(boolean extension) {
|
||||||
|
return FlatteningWrapper.impl.copy(getMinPoint(extension), getMaxPoint(extension), getCopyPoint());
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
File getResetFile();
|
File getResetFile();
|
||||||
|
|||||||
+52
-28
@@ -26,6 +26,7 @@ import de.steamwar.bausystem.region.flags.Flag;
|
|||||||
import de.steamwar.bausystem.region.flags.TestblockMode;
|
import de.steamwar.bausystem.region.flags.TestblockMode;
|
||||||
import de.steamwar.bausystem.utils.PasteBuilder;
|
import de.steamwar.bausystem.utils.PasteBuilder;
|
||||||
import de.steamwar.core.Core;
|
import de.steamwar.core.Core;
|
||||||
|
import de.steamwar.sql.SchematicType;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
import yapion.hierarchy.types.YAPIONObject;
|
import yapion.hierarchy.types.YAPIONObject;
|
||||||
|
|
||||||
@@ -36,9 +37,10 @@ import java.util.UUID;
|
|||||||
|
|
||||||
public class FixedRegion implements Region {
|
public class FixedRegion implements Region {
|
||||||
|
|
||||||
private UUID uuid;
|
private final UUID uuid;
|
||||||
private FixedFlagStorage flagStorage;
|
private final FixedFlagStorage flagStorage;
|
||||||
private Prototype prototype;
|
private final Prototype prototype;
|
||||||
|
private final String skin;
|
||||||
|
|
||||||
private final Area area;
|
private final Area area;
|
||||||
private final Area build;
|
private final Area build;
|
||||||
@@ -52,7 +54,7 @@ public class FixedRegion implements Region {
|
|||||||
uuid = UUID.nameUUIDFromBytes(name.getBytes(StandardCharsets.UTF_8));
|
uuid = UUID.nameUUIDFromBytes(name.getBytes(StandardCharsets.UTF_8));
|
||||||
this.flagStorage = flagStorage;
|
this.flagStorage = flagStorage;
|
||||||
this.prototype = prototype;
|
this.prototype = prototype;
|
||||||
System.out.println(name + " " + prototype + " " + flagStorage);
|
this.skin = prototype.getDefaultSkin();
|
||||||
|
|
||||||
Point minPoint;
|
Point minPoint;
|
||||||
if (regionConfig.containsKey("minX", Integer.class) && regionConfig.containsKey("minY", Integer.class) && regionConfig.containsKey("minZ", Integer.class)) {
|
if (regionConfig.containsKey("minX", Integer.class) && regionConfig.containsKey("minY", Integer.class) && regionConfig.containsKey("minZ", Integer.class)) {
|
||||||
@@ -78,21 +80,24 @@ public class FixedRegion implements Region {
|
|||||||
return minPoint;
|
return minPoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public EditSession copy(boolean extension) {
|
|
||||||
return null; // TODO: Implement
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public File getResetFile() {
|
public File getResetFile() {
|
||||||
return null; // TODO: Implement
|
return prototype.getSkinMap().get(skin).getSchematicFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void reset(PasteBuilder pasteBuilder, boolean extension) {
|
public void reset(PasteBuilder pasteBuilder, boolean extension) {
|
||||||
// TODO: Implement
|
pasteBuilder.reset(extension)
|
||||||
|
.minPoint(getMinPoint(extension))
|
||||||
|
.maxPoint(getMaxPoint(extension))
|
||||||
|
.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());
|
||||||
|
}
|
||||||
|
pasteBuilder.pastePoint(minPoint.add(prototype.getSizeX() / 2, 0, prototype.getSizeY() / 2));
|
||||||
|
regionHistory.remember(pasteBuilder.run());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -128,21 +133,24 @@ public class FixedRegion implements Region {
|
|||||||
return copyPoint;
|
return copyPoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public EditSession copy(boolean extension) {
|
|
||||||
return null; // TODO: Implement
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public File getResetFile() {
|
public File getResetFile() {
|
||||||
return null; // TODO: Implement
|
return prototype.getSkinMap().get(skin).getBuildSchematicFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void reset(PasteBuilder pasteBuilder, boolean extension) {
|
public void reset(PasteBuilder pasteBuilder, boolean extension) {
|
||||||
// TODO: Implement
|
pasteBuilder.reset(extension)
|
||||||
|
.minPoint(getMinPoint(extension))
|
||||||
|
.maxPoint(getMaxPoint(extension))
|
||||||
|
.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());
|
||||||
|
}
|
||||||
|
pasteBuilder.pastePoint(minPointBuild.add(prototype.getBuild().getSizeX() / 2, 0, prototype.getBuild().getSizeZ() / 2));
|
||||||
|
regionHistory.remember(pasteBuilder.run());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
@@ -181,21 +189,37 @@ public class FixedRegion implements Region {
|
|||||||
return copyPoint;
|
return copyPoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public EditSession copy(boolean extension) {
|
|
||||||
return null; // TODO: Implement
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public File getResetFile() {
|
public File getResetFile() {
|
||||||
return null; // TODO: Implement
|
return prototype.getSkinMap().get(skin).getTestblockSchematicFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void reset(PasteBuilder pasteBuilder, boolean extension) {
|
public void reset(PasteBuilder pasteBuilder, boolean extension) {
|
||||||
// TODO: Implement
|
pasteBuilder.reset(extension)
|
||||||
|
.minPoint(getMinPoint(extension))
|
||||||
|
.maxPoint(getMaxPoint(extension))
|
||||||
|
.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 = minPointTestblock.add(prototype.getTestblock().getSizeX() / 2, 0, prototype.getTestblock().getSizeZ() / 2);
|
||||||
|
if (pasteBuilder.getClipboardProvider().is(PasteBuilder.SchematicProvider.class)) {
|
||||||
|
SchematicType schematicType = pasteBuilder.getClipboardProvider().as(PasteBuilder.SchematicProvider.class).getSchematic().getSchemtype();
|
||||||
|
if (schematicType.getKuerzel().equalsIgnoreCase("wg")) {
|
||||||
|
pastePoint = pastePoint.add(0, 0, 1);
|
||||||
|
}
|
||||||
|
if (schematicType.getKuerzel().equalsIgnoreCase("ws")) {
|
||||||
|
pastePoint = pastePoint.add(-1, 0, 1);
|
||||||
|
}
|
||||||
|
if (schematicType.getKuerzel().equalsIgnoreCase("as")) {
|
||||||
|
pastePoint = pastePoint.add(-1, 0, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pasteBuilder.pastePoint(pastePoint);
|
||||||
|
regionHistory.remember(pasteBuilder.run());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user