diff --git a/hooks/areashop-fawe-1-15/pom.xml b/hooks/areashop-fawe-1-15/pom.xml
index 1254a0c4..10b6b963 100644
--- a/hooks/areashop-fawe-1-15/pom.xml
+++ b/hooks/areashop-fawe-1-15/pom.xml
@@ -32,7 +32,7 @@
com.intellectualsites.fawe
FAWE-Bukkit
- 1.16-343
+ 1.16-380
provided
diff --git a/hooks/areashop-fawe-1-15/src/main/java/me/wiefferink/areashop/handlers/fawe/v1_15/FastAsyncWorldEditHandler.java b/hooks/areashop-fawe-1-15/src/main/java/me/wiefferink/areashop/handlers/fawe/v1_15/FastAsyncWorldEditHandler.java
index b24bd8d9..fc5dface 100644
--- a/hooks/areashop-fawe-1-15/src/main/java/me/wiefferink/areashop/handlers/fawe/v1_15/FastAsyncWorldEditHandler.java
+++ b/hooks/areashop-fawe-1-15/src/main/java/me/wiefferink/areashop/handlers/fawe/v1_15/FastAsyncWorldEditHandler.java
@@ -1,11 +1,8 @@
package me.wiefferink.areashop.handlers.fawe.v1_15;
-import com.boydti.fawe.Fawe;
import com.boydti.fawe.FaweAPI;
-import com.boydti.fawe.FaweCache;
-import com.boydti.fawe.bukkit.FaweBukkit;
import com.boydti.fawe.object.FaweLimit;
-import com.boydti.fawe.object.FaweOutputStream;
+import com.boydti.fawe.object.RelightMode;
import com.sk89q.jnbt.NBTInputStream;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.IncompleteRegionException;
@@ -14,27 +11,17 @@
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
-import com.sk89q.worldedit.extent.clipboard.io.BuiltInClipboardFormat;
-import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
-import com.sk89q.worldedit.extent.clipboard.io.ClipboardReader;
-import com.sk89q.worldedit.extent.clipboard.io.ClipboardWriter;
-import com.sk89q.worldedit.extent.clipboard.io.FastSchematicReader;
-import com.sk89q.worldedit.extent.clipboard.io.FastSchematicWriter;
+import com.sk89q.worldedit.extent.clipboard.io.*;
import com.sk89q.worldedit.extent.transform.BlockTransformExtent;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.mask.Mask2D;
-import com.sk89q.worldedit.function.mask.RegionMask;
import com.sk89q.worldedit.function.operation.ForwardExtentCopy;
-import com.sk89q.worldedit.function.operation.Operation;
import com.sk89q.worldedit.function.operation.Operations;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.CuboidRegion;
-import com.sk89q.worldedit.regions.Polygonal2DRegion;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.session.ClipboardHolder;
import com.sk89q.worldedit.util.io.Closer;
-import com.sk89q.worldguard.protection.regions.GlobalProtectedRegion;
-import com.sk89q.worldguard.protection.regions.ProtectedPolygonalRegion;
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import com.sk89q.worldguard.protection.regions.RegionType;
import me.wiefferink.areashop.interfaces.AreaShopInterface;
@@ -44,12 +31,7 @@
import org.apache.commons.lang.exception.ExceptionUtils;
import org.bukkit.entity.Player;
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
+import java.io.*;
import java.util.zip.GZIPInputStream;
// Future: this class could use the schematic save/paste api of FAWE: https://github.com/boy0001/FastAsyncWorldedit/wiki/Pasting-a-schematic
@@ -60,6 +42,25 @@ public FastAsyncWorldEditHandler(AreaShopInterface pluginInterface) {
super(pluginInterface);
}
+ private Mask newMask(final ProtectedRegion region) {
+ return new Mask() {
+ @Override
+ public boolean test(BlockVector3 vector) {
+ return region.contains(vector);
+ }
+
+ @Override
+ public Mask2D toMask2D() {
+ return null;
+ }
+
+ @Override
+ public Mask copy() {
+ return this;
+ }
+ };
+ }
+
@Override
public boolean restoreRegionBlocks(File rawFile, GeneralRegionInterface regionInterface) {
// TODO implement using the FastAsyncWorldEdit api to paste async
@@ -67,9 +68,9 @@ public boolean restoreRegionBlocks(File rawFile, GeneralRegionInterface regionIn
ClipboardFormat format = null;
for (ClipboardFormat formatOption : BuiltInClipboardFormat.values()) {
if (new File(rawFile.getAbsolutePath() + "." + formatOption.getPrimaryFileExtension())
- .exists()) {
+ .exists()) {
file = new File(
- rawFile.getAbsolutePath() + "." + formatOption.getPrimaryFileExtension());
+ rawFile.getAbsolutePath() + "." + formatOption.getPrimaryFileExtension());
format = formatOption;
break;
}
@@ -99,31 +100,30 @@ public boolean restoreRegionBlocks(File rawFile, GeneralRegionInterface regionIn
ProtectedRegion region = regionInterface.getRegion();
// Get the origin and size of the region
BlockVector3 origin = BlockVector3
- .at(region.getMinimumPoint().getBlockX(), region.getMinimumPoint().getBlockY(),
- region.getMinimumPoint().getBlockZ());
+ .at(region.getMinimumPoint().getBlockX(), region.getMinimumPoint().getBlockY(),
+ region.getMinimumPoint().getBlockZ());
// Read the schematic and paste it into the world
- try (Closer closer = Closer.create()) {
- FileInputStream fis = closer.register(new FileInputStream(file));
- BufferedInputStream bis = closer.register(new BufferedInputStream(fis));
- NBTInputStream nbtStream = new NBTInputStream(new GZIPInputStream(bis));
- ClipboardReader reader = new FastSchematicReader(nbtStream);
+ try (Closer closer = Closer.create(); FileInputStream fis = closer.register(new FileInputStream(file));
+ BufferedInputStream bis = closer.register(new BufferedInputStream(fis));
+ NBTInputStream nbtStream = new NBTInputStream(new GZIPInputStream(bis));
+ ClipboardReader reader = new FastSchematicReader(nbtStream)) {
LocalSession session =
- new LocalSession(pluginInterface.getWorldEdit().getLocalConfiguration());
+ new LocalSession(pluginInterface.getWorldEdit().getLocalConfiguration());
Clipboard clipboard = reader.read();
if (clipboard.getDimensions().getY() != regionInterface.getHeight()
- || clipboard.getDimensions().getX() != regionInterface.getWidth()
- || clipboard.getDimensions().getZ() != regionInterface.getDepth()) {
+ || clipboard.getDimensions().getX() != regionInterface.getWidth()
+ || clipboard.getDimensions().getZ() != regionInterface.getDepth()) {
pluginInterface.getLogger().warning(
- "Size of the region " + regionInterface.getName()
- + " is not the same as the schematic to restore!");
+ "Size of the region " + regionInterface.getName()
+ + " is not the same as the schematic to restore!");
pluginInterface.debugI(
- "schematic|region, x:" + clipboard.getDimensions().getX() + "|"
- + regionInterface.getWidth() + ", y:" + clipboard.getDimensions().getY()
- + "|" + regionInterface.getHeight() + ", z:" + clipboard.getDimensions()
- .getZ() + "|" + regionInterface.getDepth());
+ "schematic|region, x:" + clipboard.getDimensions().getX() + "|"
+ + regionInterface.getWidth() + ", y:" + clipboard.getDimensions().getY()
+ + "|" + regionInterface.getHeight() + ", z:" + clipboard.getDimensions()
+ .getZ() + "|" + regionInterface.getDepth());
}
clipboard.setOrigin(clipboard.getMinimumPoint());
ClipboardHolder clipboardHolder = new ClipboardHolder(clipboard);
@@ -140,15 +140,7 @@ public boolean restoreRegionBlocks(File rawFile, GeneralRegionInterface regionIn
// Mask to region (for polygon and other weird shaped regions)
// TODO make this more efficient (especially for polygon regions)
if (region.getType() != RegionType.CUBOID) {
- copy.setSourceMask(new Mask() {
- @Override public boolean test(BlockVector3 vector) {
- return region.contains(vector);
- }
-
- @Override public Mask2D toMask2D() {
- return null;
- }
- });
+ copy.setSourceMask(newMask(region));
}
Operations.completeLegacy(copy);
} catch (MaxChangedBlocksException e) {
@@ -187,43 +179,44 @@ public boolean restoreRegionBlocks(File rawFile, GeneralRegionInterface regionIn
}
if (world == null) {
pluginInterface.getLogger().warning(
- "Did not save region " + regionInterface.getName() + ", world not found: "
- + regionInterface.getWorldName());
+ "Did not save region " + regionInterface.getName() + ", world not found: "
+ + regionInterface.getWorldName());
return false;
}
- EditSession editSession =
- pluginInterface.getWorldEdit().getWorldEdit().getEditSessionFactory()
- .getEditSession(world, pluginInterface.getConfig().getInt("maximumBlocks"));
+ final FaweLimit limit = new FaweLimit();
+ limit.MAX_CHANGES = pluginInterface.getConfig().getInt("maximumBlocks");
+ EditSession editSession = FaweAPI.getEditSessionBuilder(world).limit(limit).relightMode(RelightMode.OPTIMAL).build();
// Create a clipboard
CuboidRegion selection =
- new CuboidRegion(world, regionInterface.getRegion().getMinimumPoint(),
- regionInterface.getRegion().getMaximumPoint());
+ new CuboidRegion(world, regionInterface.getRegion().getMinimumPoint(),
+ regionInterface.getRegion().getMaximumPoint());
BlockArrayClipboard clipboard = new BlockArrayClipboard(selection);
clipboard.setOrigin(regionInterface.getRegion().getMinimumPoint());
ForwardExtentCopy copy = new ForwardExtentCopy(editSession,
- new CuboidRegion(world, regionInterface.getRegion().getMinimumPoint(),
- regionInterface.getRegion().getMaximumPoint()), clipboard,
- regionInterface.getRegion().getMinimumPoint());
+ new CuboidRegion(world, regionInterface.getRegion().getMinimumPoint(),
+ regionInterface.getRegion().getMaximumPoint()), clipboard,
+ regionInterface.getRegion().getMinimumPoint());
try {
Operations.completeLegacy(copy);
} catch (MaxChangedBlocksException e) {
pluginInterface.getLogger().warning(
- "Exceeded the block limit while saving schematic of " + regionInterface.getName()
- + ", limit in exception: " + e.getBlockLimit() + ", limit passed by AreaShop: "
- + pluginInterface.getConfig().getInt("maximumBlocks"));
+ "Exceeded the block limit while saving schematic of " + regionInterface.getName()
+ + ", limit in exception: " + e.getBlockLimit() + ", limit passed by AreaShop: "
+ + pluginInterface.getConfig().getInt("maximumBlocks"));
return false;
}
- try (Closer closer = Closer.create()) {
- FileOutputStream fos = closer.register(new FileOutputStream(file));
- BufferedOutputStream bos = closer.register(new BufferedOutputStream(fos));
+ try (Closer closer = Closer.create();
+ FileOutputStream fos = closer.register(new FileOutputStream(file));
+ BufferedOutputStream bos = closer.register(new BufferedOutputStream(fos))) {
+
ClipboardWriter writer = closer.register(format.getWriter(bos));
writer.write(clipboard);
} catch (IOException e) {
pluginInterface.getLogger().warning(
- "An error occured while saving schematic of " + regionInterface.getName()
- + ", enable debug to see the complete stacktrace");
+ "An error occured while saving schematic of " + regionInterface.getName()
+ + ", enable debug to see the complete stacktrace");
pluginInterface.debugI(ExceptionUtils.getStackTrace(e));
return false;
} catch (Exception e) {
diff --git a/hooks/areashop-worldedit-7/src/main/java/me/wiefferink/areashop/handlers/worldedit/v7/WorldEditHandler.java b/hooks/areashop-worldedit-7/src/main/java/me/wiefferink/areashop/handlers/worldedit/v7/WorldEditHandler.java
index a416ee9a..2807c0de 100644
--- a/hooks/areashop-worldedit-7/src/main/java/me/wiefferink/areashop/handlers/worldedit/v7/WorldEditHandler.java
+++ b/hooks/areashop-worldedit-7/src/main/java/me/wiefferink/areashop/handlers/worldedit/v7/WorldEditHandler.java
@@ -99,10 +99,10 @@ public boolean restoreRegionBlocks(File rawFile, GeneralRegionInterface regionIn
BlockVector3 origin = BlockVector3.at(region.getMinimumPoint().getBlockX(), region.getMinimumPoint().getBlockY(), region.getMinimumPoint().getBlockZ());
// Read the schematic and paste it into the world
- try(Closer closer = Closer.create()) {
+ try(Closer closer = Closer.create();
FileInputStream fis = closer.register(new FileInputStream(file));
BufferedInputStream bis = closer.register(new BufferedInputStream(fis));
- ClipboardReader reader = format.getReader(bis);
+ ClipboardReader reader = format.getReader(bis)) {
//WorldData worldData = world.getWorldData();
LocalSession session = new LocalSession(pluginInterface.getWorldEdit().getLocalConfiguration());
@@ -195,10 +195,9 @@ public boolean saveRegionBlocks(File file, GeneralRegionInterface regionInterfac
return false;
}
- try(Closer closer = Closer.create()) {
- FileOutputStream fos = closer.register(new FileOutputStream(file));
+ try(Closer closer = Closer.create(); FileOutputStream fos = closer.register(new FileOutputStream(file));
BufferedOutputStream bos = closer.register(new BufferedOutputStream(fos));
- ClipboardWriter writer = closer.register(format.getWriter(bos));
+ ClipboardWriter writer = closer.register(format.getWriter(bos));) {
writer.write(clipboard);
} catch(IOException e) {
pluginInterface.getLogger().warning("An error occured while saving schematic of " + regionInterface.getName() + ", enable debug to see the complete stacktrace");