mirror of
https://github.com/NLthijs48/AreaShop.git
synced 2024-11-16 15:25:11 +01:00
Use new schematic format when using WorldEdit 7
This commit is contained in:
parent
9e908cee73
commit
bd2f40f5c8
@ -67,7 +67,6 @@ public final class AreaShop extends JavaPlugin implements AreaShopInterface {
|
||||
// Folders and file names
|
||||
public static final String languageFolder = "lang";
|
||||
public static final String schematicFolder = "schem";
|
||||
public static final String schematicExtension = ".schematic";
|
||||
public static final String regionsFolder = "regions";
|
||||
public static final String groupsFile = "groups.yml";
|
||||
public static final String defaultFile = "default.yml";
|
||||
|
@ -740,7 +740,7 @@ public abstract class GeneralRegion implements GeneralRegionInterface, Comparabl
|
||||
return false;
|
||||
}
|
||||
// The path to save the schematic
|
||||
File saveFile = new File(plugin.getFileManager().getSchematicFolder() + File.separator + fileName + AreaShop.schematicExtension);
|
||||
File saveFile = new File(plugin.getFileManager().getSchematicFolder() + File.separator + fileName);
|
||||
// Create parent directories
|
||||
File parent = saveFile.getParentFile();
|
||||
if(parent != null && !parent.exists()) {
|
||||
@ -767,11 +767,7 @@ public abstract class GeneralRegion implements GeneralRegionInterface, Comparabl
|
||||
return false;
|
||||
}
|
||||
// The path to save the schematic
|
||||
File restoreFile = new File(plugin.getFileManager().getSchematicFolder() + File.separator + fileName + AreaShop.schematicExtension);
|
||||
if(!restoreFile.exists() || !restoreFile.isFile()) {
|
||||
AreaShop.info("Did not restore region " + getName() + ", schematic file does not exist: " + restoreFile.getAbsolutePath());
|
||||
return false;
|
||||
}
|
||||
File restoreFile = new File(plugin.getFileManager().getSchematicFolder() + File.separator + fileName);
|
||||
boolean result = plugin.getWorldEditHandler().restoreRegionBlocks(restoreFile, this);
|
||||
if(result) {
|
||||
AreaShop.debug("Restored schematic for region " + getName());
|
||||
|
@ -40,6 +40,11 @@ public class WorldEditHandler5 extends WorldEditInterface {
|
||||
|
||||
@Override
|
||||
public boolean restoreRegionBlocks(File file, GeneralRegionInterface regionInterface) {
|
||||
file = new File(file.getAbsolutePath() + ".schematic");
|
||||
if(!file.exists() || !file.isFile()) {
|
||||
pluginInterface.getLogger().info("Did not restore region " + regionInterface.getName() + ", schematic file does not exist: " + file.getAbsolutePath());
|
||||
return false;
|
||||
}
|
||||
boolean result = true;
|
||||
EditSession editSession = pluginInterface.getWorldEdit().getWorldEdit().getEditSessionFactory().getEditSession(new BukkitWorld(regionInterface.getWorld()), pluginInterface.getConfig().getInt("maximumBlocks"));
|
||||
// Get the origin and size of the region
|
||||
@ -57,7 +62,7 @@ public class WorldEditHandler5 extends WorldEditInterface {
|
||||
}
|
||||
clipBoard.place(editSession, origin, false);
|
||||
} catch(MaxChangedBlocksException e) {
|
||||
pluginInterface.getLogger().warning("Exeeded the block limit while restoring schematic of " + regionInterface.getName() + ", limit in exception: " + e.getBlockLimit() + ", limit passed by AreaShop: " + pluginInterface.getConfig().getInt("maximumBlocks"));
|
||||
pluginInterface.getLogger().warning("exceeded the block limit while restoring schematic of " + regionInterface.getName() + ", limit in exception: " + e.getBlockLimit() + ", limit passed by AreaShop: " + pluginInterface.getConfig().getInt("maximumBlocks"));
|
||||
result = false;
|
||||
} catch(DataException | IOException e) {
|
||||
otherException = e;
|
||||
@ -73,6 +78,7 @@ public class WorldEditHandler5 extends WorldEditInterface {
|
||||
|
||||
@Override
|
||||
public boolean saveRegionBlocks(File file, GeneralRegionInterface regionInterface) {
|
||||
file = new File(file.getAbsolutePath() + ".schematic");
|
||||
boolean result = true;
|
||||
ProtectedRegion region = regionInterface.getRegion();
|
||||
// Get the origin and size of the region
|
||||
|
@ -58,6 +58,11 @@ public class WorldEditHandler6 extends WorldEditInterface {
|
||||
|
||||
@Override
|
||||
public boolean restoreRegionBlocks(File file, GeneralRegionInterface regionInterface) {
|
||||
file = new File(file.getAbsolutePath() + ".schematic");
|
||||
if(!file.exists() || !file.isFile()) {
|
||||
pluginInterface.getLogger().info("Did not restore region " + regionInterface.getName() + ", schematic file does not exist: " + file.getAbsolutePath());
|
||||
return false;
|
||||
}
|
||||
com.sk89q.worldedit.world.World world = null;
|
||||
if(regionInterface.getName() != null) {
|
||||
world = LocalWorldAdapter.adapt(new BukkitWorld(regionInterface.getWorld()));
|
||||
@ -113,7 +118,7 @@ public class WorldEditHandler6 extends WorldEditInterface {
|
||||
}
|
||||
Operations.completeLegacy(copy);
|
||||
} catch(MaxChangedBlocksException e) {
|
||||
pluginInterface.getLogger().warning("Exeeded the block limit while restoring schematic of " + regionInterface.getName() + ", limit in exception: " + e.getBlockLimit() + ", limit passed by AreaShop: " + pluginInterface.getConfig().getInt("maximumBlocks"));
|
||||
pluginInterface.getLogger().warning("exceeded the block limit while restoring schematic of " + regionInterface.getName() + ", limit in exception: " + e.getBlockLimit() + ", limit passed by AreaShop: " + pluginInterface.getConfig().getInt("maximumBlocks"));
|
||||
return false;
|
||||
} catch(IOException e) {
|
||||
pluginInterface.getLogger().warning("An error occured while restoring schematic of " + regionInterface.getName() + ", enable debug to see the complete stacktrace");
|
||||
@ -126,6 +131,7 @@ public class WorldEditHandler6 extends WorldEditInterface {
|
||||
|
||||
@Override
|
||||
public boolean saveRegionBlocks(File file, GeneralRegionInterface regionInterface) {
|
||||
file = new File(file.getAbsolutePath() + ".schematic");
|
||||
com.sk89q.worldedit.world.World world = null;
|
||||
if(regionInterface.getWorld() != null) {
|
||||
world = LocalWorldAdapter.adapt(new BukkitWorld(regionInterface.getWorld()));
|
||||
@ -143,7 +149,7 @@ public class WorldEditHandler6 extends WorldEditInterface {
|
||||
try {
|
||||
Operations.completeLegacy(copy);
|
||||
} catch(MaxChangedBlocksException e) {
|
||||
pluginInterface.getLogger().warning("Exeeded the block limit while saving schematic of " + regionInterface.getName() + ", limit in exception: " + e.getBlockLimit() + ", limit passed by AreaShop: " + pluginInterface.getConfig().getInt("maximumBlocks"));
|
||||
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"));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -61,7 +61,20 @@ public class WorldEditHandler7 extends WorldEditInterface {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean restoreRegionBlocks(File file, GeneralRegionInterface regionInterface) {
|
||||
public boolean restoreRegionBlocks(File rawFile, GeneralRegionInterface regionInterface) {
|
||||
File file = null;
|
||||
for (BuiltInClipboardFormat format : BuiltInClipboardFormat.values()) {
|
||||
for (String extension : format.getFileExtensions()) {
|
||||
if (new File(rawFile.getAbsolutePath() + "." + extension).exists()) {
|
||||
file = new File(rawFile.getAbsolutePath() + "." + extension);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(file == null) {
|
||||
pluginInterface.getLogger().info("Did not restore region " + regionInterface.getName() + ", schematic file does not exist: " + rawFile.getAbsolutePath());
|
||||
return false;
|
||||
}
|
||||
|
||||
com.sk89q.worldedit.world.World world = null;
|
||||
if(regionInterface.getName() != null) {
|
||||
world = BukkitAdapter.adapt(regionInterface.getWorld());
|
||||
@ -122,7 +135,7 @@ public class WorldEditHandler7 extends WorldEditInterface {
|
||||
}
|
||||
Operations.completeLegacy(copy);
|
||||
} catch(MaxChangedBlocksException e) {
|
||||
pluginInterface.getLogger().warning("Exeeded the block limit while restoring schematic of " + regionInterface.getName() + ", limit in exception: " + e.getBlockLimit() + ", limit passed by AreaShop: " + pluginInterface.getConfig().getInt("maximumBlocks"));
|
||||
pluginInterface.getLogger().warning("exceeded the block limit while restoring schematic of " + regionInterface.getName() + ", limit in exception: " + e.getBlockLimit() + ", limit passed by AreaShop: " + pluginInterface.getConfig().getInt("maximumBlocks"));
|
||||
return false;
|
||||
} catch(IOException e) {
|
||||
pluginInterface.getLogger().warning("An error occured while restoring schematic of " + regionInterface.getName() + ", enable debug to see the complete stacktrace");
|
||||
@ -135,6 +148,7 @@ public class WorldEditHandler7 extends WorldEditInterface {
|
||||
|
||||
@Override
|
||||
public boolean saveRegionBlocks(File file, GeneralRegionInterface regionInterface) {
|
||||
file = new File(file.getAbsolutePath() + "." + BuiltInClipboardFormat.SPONGE_SCHEMATIC.getPrimaryFileExtension());
|
||||
com.sk89q.worldedit.world.World world = null;
|
||||
if(regionInterface.getWorld() != null) {
|
||||
world = BukkitAdapter.adapt(regionInterface.getWorld());
|
||||
@ -152,7 +166,7 @@ public class WorldEditHandler7 extends WorldEditInterface {
|
||||
try {
|
||||
Operations.completeLegacy(copy);
|
||||
} catch(MaxChangedBlocksException e) {
|
||||
pluginInterface.getLogger().warning("Exeeded the block limit while saving schematic of " + regionInterface.getName() + ", limit in exception: " + e.getBlockLimit() + ", limit passed by AreaShop: " + pluginInterface.getConfig().getInt("maximumBlocks"));
|
||||
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"));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user