diff --git a/BauSystem_12/pom.xml b/BauSystem_12/pom.xml
index 96b45cf..b75a39f 100644
--- a/BauSystem_12/pom.xml
+++ b/BauSystem_12/pom.xml
@@ -45,11 +45,5 @@
1.0
compile
-
- steamwar
- FAWE
- 1.12
- provided
-
\ No newline at end of file
diff --git a/BauSystem_12/src/de/steamwar/bausystem/world/Region_12.java b/BauSystem_12/src/de/steamwar/bausystem/world/Region_12.java
index fcf0f83..d21e014 100644
--- a/BauSystem_12/src/de/steamwar/bausystem/world/Region_12.java
+++ b/BauSystem_12/src/de/steamwar/bausystem/world/Region_12.java
@@ -1,13 +1,19 @@
package de.steamwar.bausystem.world;
-import com.boydti.fawe.FaweAPI;
-import com.boydti.fawe.object.schematic.Schematic;
+import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.Vector;
+import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.bukkit.BukkitWorld;
+import com.sk89q.worldedit.extent.clipboard.Clipboard;
+import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
+import com.sk89q.worldedit.function.operation.Operations;
import com.sk89q.worldedit.math.transform.AffineTransform;
+import com.sk89q.worldedit.session.ClipboardHolder;
+import com.sk89q.worldedit.world.World;
import org.bukkit.Bukkit;
import java.io.File;
+import java.io.FileInputStream;
import java.io.IOException;
import java.util.Objects;
@@ -15,15 +21,23 @@ public class Region_12 {
private Region_12(){}
static void paste(File file, int x, int y, int z, boolean rotate){
- Schematic schem;
+ World w = new BukkitWorld(Bukkit.getWorlds().get(0));
+ Clipboard clipboard;
try {
- schem = FaweAPI.load(file);
- }catch(IOException e){
+ clipboard = Objects.requireNonNull(ClipboardFormat.findByFile(file)).getReader(new FileInputStream(file)).read(w.getWorldData());
+ } catch (NullPointerException | IOException e) {
throw new SecurityException("Bausystem schematic not found", e);
}
- Vector dimensions = Objects.requireNonNull(schem.getClipboard()).getDimensions();
+
+ paste(clipboard, x, y, z, rotate);
+ }
+
+ static void paste(Clipboard clipboard, int x, int y, int z, boolean rotate){
+ World w = new BukkitWorld(Bukkit.getWorlds().get(0));
+
+ Vector dimensions = clipboard.getDimensions();
Vector v = new Vector(x, y, z);
- Vector offset = new Vector(schem.getClipboard().getRegion().getMinimumPoint()).subtract(schem.getClipboard().getOrigin());
+ Vector offset = clipboard.getRegion().getMinimumPoint().subtract(clipboard.getOrigin());
AffineTransform aT = new AffineTransform();
if(rotate){
aT = aT.rotateY(180);
@@ -31,6 +45,11 @@ public class Region_12 {
}else{
v = v.subtract(dimensions.getX()/2 - dimensions.getX()%2, 0, dimensions.getZ()/2 - dimensions.getZ()%2).subtract(offset);
}
- schem.paste(new BukkitWorld(Bukkit.getWorlds().get(0)), v, false, true, aT).flushQueue();
+
+ EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(w, -1);
+ ClipboardHolder ch = new ClipboardHolder(clipboard, w.getWorldData());
+ ch.setTransform(aT);
+ Operations.completeBlindly(ch.createPaste(e, w.getWorldData()).to(v).build());
+ e.flushQueue();
}
}
diff --git a/BauSystem_15/src/de/steamwar/bausystem/world/Region_15.java b/BauSystem_15/src/de/steamwar/bausystem/world/Region_15.java
index 6996193..761622d 100644
--- a/BauSystem_15/src/de/steamwar/bausystem/world/Region_15.java
+++ b/BauSystem_15/src/de/steamwar/bausystem/world/Region_15.java
@@ -1,9 +1,15 @@
package de.steamwar.bausystem.world;
+import com.sk89q.worldedit.EditSession;
+import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
+import com.sk89q.worldedit.bukkit.BukkitWorld;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats;
+import com.sk89q.worldedit.function.operation.Operations;
import com.sk89q.worldedit.math.BlockVector3;
+import com.sk89q.worldedit.math.transform.AffineTransform;
+import com.sk89q.worldedit.session.ClipboardHolder;
import com.sk89q.worldedit.world.block.BaseBlock;
import net.minecraft.server.v1_15_R1.BlockPosition;
import net.minecraft.server.v1_15_R1.WorldServer;
@@ -28,6 +34,36 @@ public class Region_15 {
throw new SecurityException("Bausystem schematic not found", e);
}
+ paste(clipboard, x, y, z, rotate);
+ }
+
+ static void paste(Clipboard clipboard, int x, int y, int z, boolean rotate){
+ BlockVector3 dimensions = clipboard.getDimensions();
+ BlockVector3 v = BlockVector3.at(x, y, z);
+ BlockVector3 offset = clipboard.getRegion().getMinimumPoint().subtract(clipboard.getOrigin());
+ AffineTransform aT = new AffineTransform();
+ if(rotate){
+ aT = aT.rotateY(180);
+ v = v.add(dimensions.getX()/2 + dimensions.getX()%2, 0, dimensions.getZ()/2 + dimensions.getZ()%2).subtract(offset.multiply(-1, 1, -1)).subtract(1, 0, 1);
+ }else{
+ v = v.subtract(dimensions.getX()/2 - dimensions.getX()%2, 0, dimensions.getZ()/2 - dimensions.getZ()%2).subtract(offset);
+ }
+
+ EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(new BukkitWorld(Bukkit.getWorlds().get(0)), -1);
+ ClipboardHolder ch = new ClipboardHolder(clipboard);
+ ch.setTransform(aT);
+ Operations.completeBlindly(ch.createPaste(e).to(v).build());
+ e.flushSession();
+ }
+
+ static void fastpaste(File file, int x, int y, int z, boolean rotate){
+ Clipboard clipboard;
+ try {
+ clipboard = Objects.requireNonNull(ClipboardFormats.findByFile(file)).getReader(new FileInputStream(file)).read();
+ } catch (NullPointerException | IOException e) {
+ throw new SecurityException("Bausystem schematic not found", e);
+ }
+
BlockVector3 dimensions = clipboard.getDimensions();
BlockVector3 v = BlockVector3.at(x, y, z);
BlockVector3 offset = clipboard.getRegion().getMinimumPoint().subtract(clipboard.getOrigin());
diff --git a/BauSystem_Main/pom.xml b/BauSystem_Main/pom.xml
index 4643612..38fa619 100644
--- a/BauSystem_Main/pom.xml
+++ b/BauSystem_Main/pom.xml
@@ -67,5 +67,11 @@
1.15
provided
+
+ steamwar
+ WorldEdit
+ 1.15
+ provided
+
\ No newline at end of file
diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandReset.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandReset.java
index 8df6984..26050a3 100644
--- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandReset.java
+++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandReset.java
@@ -4,6 +4,7 @@ import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.world.ArenaSection;
import de.steamwar.bausystem.world.Welt;
+import de.steamwar.sql.Schematic;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
@@ -28,7 +29,16 @@ public class CommandReset implements CommandExecutor {
for(ArenaSection section : BauSystem.getSections()){
if(section.inRegion(player.getLocation())){
try {
- section.reset();
+ if(args.length > 0){
+ Schematic schem = Schematic.getSchemFromDB(args[0], player.getUniqueId());
+ if(schem == null){
+ player.sendMessage(BauSystem.PREFIX + "§cSchematic nicht gefunden");
+ return false;
+ }
+ section.reset(schem);
+ }else{
+ section.fastreset();
+ }
player.sendMessage(BauSystem.PREFIX + "§7Region zurückgesetzt");
}catch(Exception e){
player.sendMessage(BauSystem.PREFIX + "§cFehler beim Zurücksetzen der Region");
diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTestblock.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTestblock.java
index fb92f38..abcbc93 100644
--- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTestblock.java
+++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTestblock.java
@@ -4,11 +4,15 @@ import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.world.ArenaSection;
import de.steamwar.bausystem.world.Welt;
+import de.steamwar.sql.NoClipboardException;
+import de.steamwar.sql.Schematic;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
+import java.io.IOException;
+
public class CommandTestblock implements CommandExecutor {
@Override
@@ -24,7 +28,21 @@ public class CommandTestblock implements CommandExecutor {
for(ArenaSection section : BauSystem.getSections()){
if(section.inRegion(player.getLocation())){
- section.getTestblock().reset();
+ if(args.length > 0){
+ Schematic schem = Schematic.getSchemFromDB(args[0], player.getUniqueId());
+ if(schem == null){
+ player.sendMessage(BauSystem.PREFIX + "§cSchematic nicht gefunden");
+ return false;
+ }
+ try {
+ section.getTestblock().reset(schem);
+ } catch (IOException | NoClipboardException e) {
+ player.sendMessage(BauSystem.PREFIX + "§cFehler beim Laden der Schematic");
+ throw new SecurityException("Failed to load Testblock Schematic", e);
+ }
+ }else{
+ section.getTestblock().reset();
+ }
player.sendMessage(BauSystem.PREFIX + "§7Testblock zurückgesetzt");
return false;
}
diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/Region.java b/BauSystem_Main/src/de/steamwar/bausystem/world/Region.java
index a2a52c3..a39bb02 100644
--- a/BauSystem_Main/src/de/steamwar/bausystem/world/Region.java
+++ b/BauSystem_Main/src/de/steamwar/bausystem/world/Region.java
@@ -1,11 +1,15 @@
package de.steamwar.bausystem.world;
+import com.sk89q.worldedit.extent.clipboard.Clipboard;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.core.Core;
+import de.steamwar.sql.NoClipboardException;
+import de.steamwar.sql.Schematic;
import org.bukkit.Location;
import org.bukkit.configuration.ConfigurationSection;
import java.io.File;
+import java.io.IOException;
public class Region {
final int sizeX;
@@ -38,11 +42,20 @@ public class Region {
return min <= l && l <= min + size;
}
+ public void fastreset(){
+ File file = new File(BauSystem.SECTION_PATH + schematic);
+ fastpaste(file, minX + sizeX/2, minY, minZ + sizeZ/2, rotate);
+ }
+
public void reset(){
File file = new File(BauSystem.SECTION_PATH + schematic);
paste(file, minX + sizeX/2, minY, minZ + sizeZ/2, rotate);
}
+ public void reset(Schematic schem) throws IOException, NoClipboardException {
+ paste(schem.load(), minX + sizeX/2, minY, minZ + sizeZ/2, rotate);
+ }
+
static void paste(File file, int x, int y, int z, boolean rotate){
switch(Core.getVersion()){
case 15:
@@ -52,4 +65,24 @@ public class Region {
Region_12.paste(file, x, y, z, rotate);
}
}
+
+ private static void fastpaste(File file, int x, int y, int z, boolean rotate){
+ switch(Core.getVersion()){
+ case 15:
+ Region_15.fastpaste(file, x, y, z, rotate);
+ break;
+ default:
+ Region_12.paste(file, x, y, z, rotate);
+ }
+ }
+
+ private static void paste(Clipboard clipboard, int x, int y, int z, boolean rotate){
+ switch(Core.getVersion()){
+ case 15:
+ Region_15.paste(clipboard, x, y, z, rotate);
+ break;
+ default:
+ Region_12.paste(clipboard, x, y, z, rotate);
+ }
+ }
}