mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-12 08:18:35 +00:00
A lot of removals, upstream merges, and maybe more.
This commit is contained in:
@ -19,7 +19,6 @@
|
||||
|
||||
package com.sk89q.worldedit.command;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import com.boydti.fawe.config.Commands;
|
||||
import com.boydti.fawe.config.Settings;
|
||||
@ -29,10 +28,9 @@ import com.boydti.fawe.object.clipboard.MultiClipboardHolder;
|
||||
import com.boydti.fawe.object.clipboard.URIClipboardHolder;
|
||||
import com.boydti.fawe.object.clipboard.remap.ClipboardRemapper;
|
||||
import com.boydti.fawe.object.schematic.StructureFormat;
|
||||
import com.boydti.fawe.object.schematic.visualizer.SchemVis;
|
||||
//import com.boydti.fawe.object.schematic.visualizer.SchemVis;
|
||||
import com.boydti.fawe.util.MainUtil;
|
||||
import com.boydti.fawe.util.chat.Message;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.sk89q.minecraft.util.commands.Command;
|
||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||
import com.sk89q.minecraft.util.commands.CommandException;
|
||||
@ -49,42 +47,28 @@ 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.ClipboardFormats;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardReader;
|
||||
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.util.command.binding.Switch;
|
||||
import com.sk89q.worldedit.util.command.parametric.Optional;
|
||||
import com.sk89q.worldedit.util.io.Closer;
|
||||
import com.sk89q.worldedit.util.io.file.FilenameException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
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.InputStream;
|
||||
import java.io.*;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.nio.channels.Channels;
|
||||
import java.nio.channels.ReadableByteChannel;
|
||||
import java.nio.file.Files;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.LongAdder;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static com.boydti.fawe.util.ReflectionUtils.as;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* Commands that work with schematic files.
|
||||
@ -111,7 +95,7 @@ public class SchematicCommands extends MethodCommands {
|
||||
aliases = {"loadall"},
|
||||
usage = "[<format>] <filename|url>",
|
||||
help = "Load multiple clipboards\n" +
|
||||
"The -r flag will apply random rotation",
|
||||
"The -r flag will apply random rotation",
|
||||
desc = "Load multiple clipboards (paste will randomly choose one)"
|
||||
)
|
||||
@Deprecated
|
||||
@ -135,9 +119,7 @@ public class SchematicCommands extends MethodCommands {
|
||||
|
||||
@Command(
|
||||
aliases = {"clear"},
|
||||
usage = "",
|
||||
desc = "Clear your clipboard",
|
||||
min = 0,
|
||||
max = 0
|
||||
)
|
||||
@CommandPermissions({"worldedit.clipboard.clear", "worldedit.schematic.clear"})
|
||||
@ -165,7 +147,6 @@ public class SchematicCommands extends MethodCommands {
|
||||
uri = new File(root, fileName).toURI();
|
||||
}
|
||||
|
||||
boolean removed = false;
|
||||
ClipboardHolder clipboard = session.getClipboard();
|
||||
if (clipboard instanceof URIClipboardHolder) {
|
||||
URIClipboardHolder identifiable = (URIClipboardHolder) clipboard;
|
||||
@ -205,11 +186,15 @@ public class SchematicCommands extends MethodCommands {
|
||||
player.print(BBC.getPrefix() + "Remapped schematic");
|
||||
}
|
||||
|
||||
@Command(aliases = {"load"}, usage = "[<format>] <filename>", desc = "Load a schematic into your clipboard")
|
||||
@Command(
|
||||
aliases = {"load"},
|
||||
usage = "[<format>] <filename>",
|
||||
desc = "Load a schematic into your clipboard"
|
||||
)
|
||||
@Deprecated
|
||||
@CommandPermissions({"worldedit.clipboard.load", "worldedit.schematic.load", "worldedit.schematic.load.asset", "worldedit.schematic.load.web", "worldedit.schematic.load.other"})
|
||||
public void load(final Player player, final LocalSession session, @Optional() final String formatName, String filename) throws FilenameException {
|
||||
final LocalConfiguration config = this.worldEdit.getConfiguration();
|
||||
public void load(Player player, LocalSession session, @Optional() String formatName, String filename) throws FilenameException {
|
||||
LocalConfiguration config = worldEdit.getConfiguration();
|
||||
ClipboardFormat format = formatName == null ? null : ClipboardFormats.findByAlias(formatName);
|
||||
InputStream in = null;
|
||||
try {
|
||||
@ -225,13 +210,12 @@ public class SchematicCommands extends MethodCommands {
|
||||
ReadableByteChannel rbc = Channels.newChannel(url.openStream());
|
||||
in = Channels.newInputStream(rbc);
|
||||
uri = url.toURI();
|
||||
if (format == null) format = BuiltInClipboardFormat.MCEDIT_SCHEMATIC;
|
||||
} else {
|
||||
if (!player.hasPermission("worldedit.schematic.load") && !player.hasPermission("worldedit.clipboard.load")) {
|
||||
BBC.NO_PERM.send(player, "worldedit.clipboard.load");
|
||||
return;
|
||||
}
|
||||
File working = this.worldEdit.getWorkingDirectoryFile(config.saveDir);
|
||||
File working = worldEdit.getWorkingDirectoryFile(config.saveDir);
|
||||
File dir = Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS ? new File(working, player.getUniqueId().toString()) : working;
|
||||
File f;
|
||||
if (filename.startsWith("#")) {
|
||||
@ -264,7 +248,7 @@ public class SchematicCommands extends MethodCommands {
|
||||
}
|
||||
}
|
||||
if (f == null || !f.exists() || !MainUtil.isInSubDirectory(working, f)) {
|
||||
player.printError(BBC.getPrefix() + "Schematic " + filename + " does not exist! (" + ((f == null) ? false : f.exists()) + "|" + f + "|" + (f == null ? false : !MainUtil.isInSubDirectory(working, f)) + ")");
|
||||
player.printError(BBC.getPrefix() + "Schematic " + filename + " does not exist! (" + ((f != null) && f.exists()) + "|" + f + "|" + (f != null && !MainUtil.isInSubDirectory(working, f)) + ")");
|
||||
return;
|
||||
}
|
||||
if (format == null) {
|
||||
@ -294,17 +278,22 @@ public class SchematicCommands extends MethodCommands {
|
||||
}
|
||||
}
|
||||
|
||||
@Command(aliases = {"save"}, usage = "[format] <filename>", desc = "Save a schematic into your clipboard", help = "The default format for 1.13 is schem")
|
||||
@Command(
|
||||
aliases = {"save"},
|
||||
usage = "[format] <filename>",
|
||||
desc = "Save a schematic into your clipboard",
|
||||
help = "The default format for 1.13 is schem"
|
||||
)
|
||||
@Deprecated
|
||||
@CommandPermissions({"worldedit.clipboard.save", "worldedit.schematic.save", "worldedit.schematic.save.other"})
|
||||
public void save(final Player player, final LocalSession session, @Optional("schem") final String formatName, String filename, @Switch('g') boolean global, @Switch('f') boolean allowOverwrite) throws CommandException, WorldEditException {
|
||||
final LocalConfiguration config = this.worldEdit.getConfiguration();
|
||||
final ClipboardFormat format = ClipboardFormats.findByAlias(formatName);
|
||||
public void save(Player player, LocalSession session, @Optional("schem") String formatName, String filename, @Switch('g') boolean global, @Switch('f') boolean allowOverwrite) throws CommandException, WorldEditException {
|
||||
LocalConfiguration config = worldEdit.getConfiguration();
|
||||
ClipboardFormat format = ClipboardFormats.findByAlias(formatName);
|
||||
if (format == null) {
|
||||
player.printError(BBC.getPrefix() + "Unknown schematic format: " + formatName);
|
||||
return;
|
||||
}
|
||||
File working = this.worldEdit.getWorkingDirectoryFile(config.saveDir);
|
||||
File working = worldEdit.getWorkingDirectoryFile(config.saveDir);
|
||||
File dir = !global && Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS ? new File(working, player.getUniqueId().toString()) : working;
|
||||
if (filename.contains("../")) {
|
||||
if (!player.hasPermission("worldedit.schematic.save.other")) {
|
||||
@ -316,7 +305,7 @@ public class SchematicCommands extends MethodCommands {
|
||||
filename = filename.substring(3);
|
||||
}
|
||||
}
|
||||
File f = this.worldEdit.getSafeSaveFile(player, dir, filename, format.getPrimaryFileExtension(), format.getPrimaryFileExtension());
|
||||
File f = worldEdit.getSafeSaveFile(player, dir, filename, format.getPrimaryFileExtension(), format.getPrimaryFileExtension());
|
||||
if (f.getName().replaceAll("." + format.getPrimaryFileExtension(), "").isEmpty()) {
|
||||
File directory = f.getParentFile();
|
||||
if (directory.exists()) {
|
||||
@ -345,14 +334,14 @@ public class SchematicCommands extends MethodCommands {
|
||||
BBC.SCHEMATIC_MOVE_EXISTS.send(player, f.getName());
|
||||
}
|
||||
try (FileOutputStream fos = new FileOutputStream(f)) {
|
||||
final ClipboardHolder holder = session.getClipboard();
|
||||
final Clipboard clipboard = holder.getClipboard();
|
||||
final Transform transform = holder.getTransform();
|
||||
final Clipboard target;
|
||||
ClipboardHolder holder = session.getClipboard();
|
||||
Clipboard clipboard = holder.getClipboard();
|
||||
Transform transform = holder.getTransform();
|
||||
Clipboard target;
|
||||
|
||||
// If we have a transform, bake it into the copy
|
||||
if (!transform.isIdentity()) {
|
||||
final FlattenedClipboardTransform result = FlattenedClipboardTransform.transform(clipboard, transform);
|
||||
FlattenedClipboardTransform result = FlattenedClipboardTransform.transform(clipboard, transform);
|
||||
target = new BlockArrayClipboard(result.getTransformedRegion(), UUID.randomUUID());
|
||||
target.setOrigin(clipboard.getOrigin());
|
||||
Operations.completeLegacy(result.copyTo(target));
|
||||
@ -386,12 +375,19 @@ public class SchematicCommands extends MethodCommands {
|
||||
}
|
||||
}
|
||||
|
||||
@Command(aliases = {"move", "m"}, usage = "<directory>", desc = "Move your loaded schematic", help = "Move your currently loaded schematics", min = 1, max = 1)
|
||||
@Command(
|
||||
aliases = {"move", "m"},
|
||||
usage = "<directory>",
|
||||
desc = "Move your loaded schematic",
|
||||
help = "Move your currently loaded schematics",
|
||||
min = 1,
|
||||
max = 1
|
||||
)
|
||||
@CommandPermissions({"worldedit.schematic.move", "worldedit.schematic.move.other"})
|
||||
public void move(final Player player, final LocalSession session, String directory) throws WorldEditException, IOException {
|
||||
final LocalConfiguration config = this.worldEdit.getConfiguration();
|
||||
final File working = this.worldEdit.getWorkingDirectoryFile(config.saveDir);
|
||||
final File dir = Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS ? new File(working, player.getUniqueId().toString()) : working;
|
||||
public void move(Player player, LocalSession session, String directory) throws WorldEditException, IOException {
|
||||
LocalConfiguration config = worldEdit.getConfiguration();
|
||||
File working = worldEdit.getWorkingDirectoryFile(config.saveDir);
|
||||
File dir = Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS ? new File(working, player.getUniqueId().toString()) : working;
|
||||
File destDir = new File(dir, directory);
|
||||
if (!MainUtil.isInSubDirectory(working, destDir)) {
|
||||
player.printError(BBC.getPrefix() + "Directory " + destDir + " does not exist!");
|
||||
@ -432,7 +428,14 @@ public class SchematicCommands extends MethodCommands {
|
||||
}
|
||||
}
|
||||
|
||||
@Command(aliases = {"delete", "d"}, usage = "<filename|*>", desc = "Delete a saved schematic", help = "Delete a schematic from the schematic list", min = 1, max = 1)
|
||||
@Command(
|
||||
aliases = {"delete", "d"},
|
||||
usage = "<filename|*>",
|
||||
desc = "Delete a saved schematic",
|
||||
help = "Delete a schematic from the schematic list",
|
||||
min = 1,
|
||||
max = 1
|
||||
)
|
||||
@CommandPermissions({"worldedit.schematic.delete", "worldedit.schematic.delete.other"})
|
||||
public void delete(final Player player, final LocalSession session, final CommandContext args) throws WorldEditException, IOException {
|
||||
final LocalConfiguration config = this.worldEdit.getConfiguration();
|
||||
@ -490,7 +493,11 @@ public class SchematicCommands extends MethodCommands {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Command(aliases = {"formats", "listformats", "f"}, desc = "List available formats", max = 0)
|
||||
@Command(
|
||||
aliases = {"formats", "listformats", "f"},
|
||||
desc = "List available formats",
|
||||
max = 0
|
||||
)
|
||||
@CommandPermissions("worldedit.schematic.formats")
|
||||
public void formats(final Actor actor) throws WorldEditException {
|
||||
BBC.SCHEMATIC_FORMAT.send(actor);
|
||||
@ -515,12 +522,11 @@ public class SchematicCommands extends MethodCommands {
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
@Command(
|
||||
aliases = {"show"},
|
||||
desc = "Show a schematic",
|
||||
usage = "[global|mine|<filter>]",
|
||||
min = 0,
|
||||
max = -1,
|
||||
flags = "dnp",
|
||||
help = "List all schematics in the schematics directory\n" +
|
||||
" -f <format> restricts by format\n"
|
||||
@ -578,13 +584,12 @@ public class SchematicCommands extends MethodCommands {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
@Command(
|
||||
aliases = {"list", "ls", "all"},
|
||||
desc = "List saved schematics",
|
||||
usage = "[global|mine|<filter>] [page=1]",
|
||||
min = 0,
|
||||
max = -1,
|
||||
flags = "dnp",
|
||||
help = "List all schematics in the schematics directory\n" +
|
||||
" -p <page> prints the requested page\n" +
|
||||
|
@ -183,8 +183,8 @@ public class UtilityCommands extends MethodCommands {
|
||||
desc = "Generate the heightmap interface: https://github.com/boy0001/HeightMap"
|
||||
)
|
||||
@CommandPermissions("fawe.admin")
|
||||
public void heightmapInterface(FawePlayer player, @Optional("100") int min, @Optional("200") int max) throws IOException {
|
||||
player.sendMessage("Please wait while we generate the minified heightmaps.");
|
||||
public void heightmapInterface(Player player, @Optional("100") int min, @Optional("200") int max) throws IOException {
|
||||
player.print("Please wait while we generate the minified heightmaps.");
|
||||
File srcFolder = MainUtil.getFile(Fawe.imp().getDirectory(), Settings.IMP.PATHS.HEIGHTMAP);
|
||||
|
||||
File webSrc = new File(Fawe.imp().getDirectory(), "web" + File.separator + "heightmap");
|
||||
@ -206,7 +206,7 @@ public class UtilityCommands extends MethodCommands {
|
||||
BufferedImage img = MainUtil.readImage(file);
|
||||
BufferedImage minImg = ImageUtil.getScaledInstance(img, min, min, RenderingHints.VALUE_INTERPOLATION_BILINEAR, true);
|
||||
BufferedImage maxImg = max == -1 ? img : ImageUtil.getScaledInstance(img, max, max, RenderingHints.VALUE_INTERPOLATION_BILINEAR, true);
|
||||
player.sendMessage("Writing " + name);
|
||||
player.print("Writing " + name);
|
||||
File minFile = new File(minImages, name);
|
||||
File maxFile = new File(maxImages, name);
|
||||
minFile.getParentFile().mkdirs();
|
||||
@ -231,9 +231,9 @@ public class UtilityCommands extends MethodCommands {
|
||||
config.append("// The local source for the image (used in commands)\n");
|
||||
config.append("var src_local = \"file://\";\n");
|
||||
File configFile = new File(webSrc, "config.js");
|
||||
player.sendMessage("Writing " + configFile);
|
||||
player.print("Writing " + configFile);
|
||||
Files.write(configFile.toPath(), config.toString().getBytes());
|
||||
player.sendMessage("Done! See: `FastAsyncWorldEdit/web/heightmap`");
|
||||
player.print("Done! See: `FastAsyncWorldEdit/web/heightmap`");
|
||||
}
|
||||
|
||||
@Command(
|
||||
|
@ -98,7 +98,6 @@ public class SelectionCommand extends SimpleCommand<Operation> {
|
||||
CuboidRegion cuboid = (CuboidRegion) selection;
|
||||
RegionFunction function = ((RegionVisitor) operation).function;
|
||||
RegionWrapper current = new RegionWrapper(cuboid.getMinimumPoint(), cuboid.getMaximumPoint());
|
||||
FawePlayer fp = FawePlayer.wrap(player);
|
||||
FaweRegionExtent regionExtent = editSession.getRegionExtent();
|
||||
|
||||
if (function instanceof BlockReplace && regionExtent == null || regionExtent.isGlobal()) {
|
||||
|
Reference in New Issue
Block a user