mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 09:47:38 +00:00
/schematic save should not check if the file exists.
This commit is contained in:
parent
932513d8a1
commit
2bbf5d2793
@ -25,7 +25,6 @@ import com.sk89q.minecraft.util.commands.CommandContext;
|
|||||||
import com.sk89q.minecraft.util.commands.CommandException;
|
import com.sk89q.minecraft.util.commands.CommandException;
|
||||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.EmptyClipboardException;
|
|
||||||
import com.sk89q.worldedit.FilenameException;
|
import com.sk89q.worldedit.FilenameException;
|
||||||
import com.sk89q.worldedit.FilenameResolutionException;
|
import com.sk89q.worldedit.FilenameResolutionException;
|
||||||
import com.sk89q.worldedit.LocalConfiguration;
|
import com.sk89q.worldedit.LocalConfiguration;
|
||||||
@ -34,10 +33,14 @@ import com.sk89q.worldedit.WorldEdit;
|
|||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.entity.Player;
|
import com.sk89q.worldedit.entity.Player;
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
|
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
|
||||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||||
|
import com.sk89q.worldedit.extent.clipboard.CuboidClipboardTransform;
|
||||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
|
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
|
||||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardReader;
|
import com.sk89q.worldedit.extent.clipboard.io.ClipboardReader;
|
||||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardWriter;
|
import com.sk89q.worldedit.extent.clipboard.io.ClipboardWriter;
|
||||||
|
import com.sk89q.worldedit.function.operation.Operations;
|
||||||
|
import com.sk89q.worldedit.math.transform.Transform;
|
||||||
import com.sk89q.worldedit.session.ClipboardHolder;
|
import com.sk89q.worldedit.session.ClipboardHolder;
|
||||||
import com.sk89q.worldedit.util.command.parametric.Optional;
|
import com.sk89q.worldedit.util.command.parametric.Optional;
|
||||||
import com.sk89q.worldedit.world.registry.WorldData;
|
import com.sk89q.worldedit.world.registry.WorldData;
|
||||||
@ -139,17 +142,12 @@ public class SchematicCommands {
|
|||||||
)
|
)
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@CommandPermissions({ "worldedit.clipboard.save", "worldedit.schematic.save" })
|
@CommandPermissions({ "worldedit.clipboard.save", "worldedit.schematic.save" })
|
||||||
public void save(Player player, LocalSession session, @Optional("schematic") String formatName, String filename) throws FilenameException, CommandException, EmptyClipboardException {
|
public void save(Player player, LocalSession session, @Optional("schematic") String formatName, String filename) throws CommandException, WorldEditException {
|
||||||
LocalConfiguration config = worldEdit.getConfiguration();
|
LocalConfiguration config = worldEdit.getConfiguration();
|
||||||
|
|
||||||
File dir = worldEdit.getWorkingDirectoryFile(config.saveDir);
|
File dir = worldEdit.getWorkingDirectoryFile(config.saveDir);
|
||||||
File f = worldEdit.getSafeSaveFile(player, dir, filename, "schematic", "schematic");
|
File f = worldEdit.getSafeSaveFile(player, dir, filename, "schematic", "schematic");
|
||||||
|
|
||||||
if (!f.exists()) {
|
|
||||||
player.printError("Schematic " + filename + " does not exist!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ClipboardFormat format = ClipboardFormat.findByAlias(formatName);
|
ClipboardFormat format = ClipboardFormat.findByAlias(formatName);
|
||||||
if (format == null) {
|
if (format == null) {
|
||||||
player.printError("Unknown schematic format: " + formatName);
|
player.printError("Unknown schematic format: " + formatName);
|
||||||
@ -157,6 +155,19 @@ public class SchematicCommands {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ClipboardHolder holder = session.getClipboard();
|
ClipboardHolder holder = session.getClipboard();
|
||||||
|
Clipboard clipboard = holder.getClipboard();
|
||||||
|
Transform transform = holder.getTransform();
|
||||||
|
Clipboard target;
|
||||||
|
|
||||||
|
// If we have a transform, we have to make a copy so we can save
|
||||||
|
// this transformed copy
|
||||||
|
if (!transform.isIdentity()) {
|
||||||
|
CuboidClipboardTransform result = CuboidClipboardTransform.transform(clipboard, transform, holder.getWorldData());
|
||||||
|
target = new BlockArrayClipboard(result.getTransformedRegion());
|
||||||
|
Operations.completeLegacy(result.copyTo(target));
|
||||||
|
} else {
|
||||||
|
target = clipboard;
|
||||||
|
}
|
||||||
|
|
||||||
Closer closer = Closer.create();
|
Closer closer = Closer.create();
|
||||||
try {
|
try {
|
||||||
@ -171,7 +182,7 @@ public class SchematicCommands {
|
|||||||
FileOutputStream fos = closer.register(new FileOutputStream(f));
|
FileOutputStream fos = closer.register(new FileOutputStream(f));
|
||||||
BufferedOutputStream bos = closer.register(new BufferedOutputStream(fos));
|
BufferedOutputStream bos = closer.register(new BufferedOutputStream(fos));
|
||||||
ClipboardWriter writer = closer.register(format.getWriter(bos));
|
ClipboardWriter writer = closer.register(format.getWriter(bos));
|
||||||
writer.write(holder.getClipboard(), holder.getWorldData());
|
writer.write(target, holder.getWorldData());
|
||||||
log.info(player.getName() + " saved " + f.getCanonicalPath());
|
log.info(player.getName() + " saved " + f.getCanonicalPath());
|
||||||
player.print(filename + " saved.");
|
player.print(filename + " saved.");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
Loading…
Reference in New Issue
Block a user