mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-01 02:46:41 +00:00
Minor upstream changes and obviously more command work
This commit is contained in:
@ -19,6 +19,9 @@
|
||||
|
||||
package com.sk89q.worldedit.command;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
import static org.enginehub.piston.part.CommandParts.arg;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
@ -29,8 +32,6 @@ import com.sk89q.worldedit.command.factory.ReplaceFactory;
|
||||
import com.sk89q.worldedit.command.factory.TreeGeneratorFactory;
|
||||
import com.sk89q.worldedit.command.util.CommandPermissions;
|
||||
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
|
||||
import com.sk89q.worldedit.command.util.CommandQueued;
|
||||
import com.sk89q.worldedit.command.util.CommandQueuedConditionGenerator;
|
||||
import com.sk89q.worldedit.command.util.PermissionCondition;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.function.Contextual;
|
||||
@ -45,6 +46,7 @@ import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
|
||||
import com.sk89q.worldedit.util.formatting.text.format.TextDecoration;
|
||||
import java.util.stream.Collectors;
|
||||
import org.enginehub.piston.CommandManager;
|
||||
import org.enginehub.piston.CommandManagerService;
|
||||
import org.enginehub.piston.CommandParameters;
|
||||
@ -55,11 +57,6 @@ import org.enginehub.piston.inject.Key;
|
||||
import org.enginehub.piston.part.CommandArgument;
|
||||
import org.enginehub.piston.part.SubCommandPart;
|
||||
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
import static org.enginehub.piston.part.CommandParts.arg;
|
||||
|
||||
@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class)
|
||||
public class ApplyBrushCommands {
|
||||
|
||||
|
@ -63,12 +63,11 @@ public class BrushOptionsCommands {
|
||||
@Command(
|
||||
name = "savebrush",
|
||||
aliases = {"save"},
|
||||
desc = "Save your current brush",
|
||||
descFooter = "Save your current brush use the -g flag to save globally"
|
||||
desc = "Save your current brush"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.save")
|
||||
public void saveBrush(Player player, LocalSession session, String name,
|
||||
@Switch(name = 'g', desc = "TODO") boolean root) throws WorldEditException, IOException {
|
||||
@Switch(name = 'g', desc = "Save the brush globally") boolean root) throws WorldEditException, IOException {
|
||||
BrushTool tool = session.getBrushTool(player);
|
||||
if (tool != null) {
|
||||
root |= name.startsWith("../");
|
||||
@ -134,8 +133,7 @@ public class BrushOptionsCommands {
|
||||
@Command(
|
||||
name = "/listbrush",
|
||||
desc = "List saved brushes",
|
||||
descFooter = "List all brushes in the brush directory\n" +
|
||||
" -p <page> prints the requested page\n"
|
||||
descFooter = "List all brushes in the brush directory"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.list")
|
||||
public void list(Actor actor, InjectedValueAccess args,
|
||||
|
@ -42,6 +42,7 @@ import com.sk89q.worldedit.command.util.CommandPermissions;
|
||||
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
|
||||
import com.sk89q.worldedit.command.util.Logging;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.function.GroundFunction;
|
||||
import com.sk89q.worldedit.function.generator.FloraGenerator;
|
||||
import com.sk89q.worldedit.function.mask.ExistingBlockMask;
|
||||
@ -69,6 +70,7 @@ import com.sk89q.worldedit.regions.RegionOperationException;
|
||||
import com.sk89q.worldedit.regions.Regions;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.util.TreeGenerator.TreeType;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import java.util.ArrayList;
|
||||
@ -84,7 +86,7 @@ import org.enginehub.piston.inject.InjectedValueAccess;
|
||||
* Commands that operate on regions.
|
||||
*/
|
||||
@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class)
|
||||
public class RegionCommands extends MethodCommands {
|
||||
public class RegionCommands {
|
||||
|
||||
private final WorldEdit worldEdit;
|
||||
|
||||
@ -103,7 +105,7 @@ public class RegionCommands extends MethodCommands {
|
||||
desc = "Get the light at a position"
|
||||
)
|
||||
@CommandPermissions("worldedit.light.fix")
|
||||
public void fixlighting(Player player) throws WorldEditException {
|
||||
public void fixLighting(Player player) throws WorldEditException {
|
||||
FawePlayer fp = FawePlayer.wrap(player);
|
||||
final Location loc = player.getLocation();
|
||||
Region selection = fp.getSelection();
|
||||
@ -121,7 +123,7 @@ public class RegionCommands extends MethodCommands {
|
||||
desc = "Get the light at a position"
|
||||
)
|
||||
@CommandPermissions("worldedit.light.fix")
|
||||
public void getlighting(Player player, EditSession editSession) throws WorldEditException {
|
||||
public void getLighting(Player player, EditSession editSession) throws WorldEditException {
|
||||
FawePlayer fp = FawePlayer.wrap(player);
|
||||
final Location loc = player.getLocation();
|
||||
int block = editSession.getBlockLight(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
@ -134,7 +136,7 @@ public class RegionCommands extends MethodCommands {
|
||||
desc = "Removing lighting in a selection"
|
||||
)
|
||||
@CommandPermissions("worldedit.light.remove")
|
||||
public void removelighting(Player player) {
|
||||
public void removeLighting(Player player) {
|
||||
FawePlayer fp = FawePlayer.wrap(player);
|
||||
Region selection = fp.getSelection();
|
||||
if (selection == null) {
|
||||
@ -190,7 +192,7 @@ public class RegionCommands extends MethodCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.region.line")
|
||||
@Logging(REGION)
|
||||
public int line(Player player, EditSession editSession,
|
||||
public int line(Actor actor, EditSession editSession,
|
||||
@Selection Region region,
|
||||
@Arg(desc = "The pattern of blocks to place")
|
||||
Pattern pattern,
|
||||
@ -199,7 +201,7 @@ public class RegionCommands extends MethodCommands {
|
||||
@Switch(name = 'h', desc = "Generate only a shell")
|
||||
boolean shell) throws WorldEditException {
|
||||
if (!(region instanceof CuboidRegion)) {
|
||||
player.printError("//line only works with cuboid selections");
|
||||
actor.printError("//line only works with cuboid selections");
|
||||
return 0;
|
||||
}
|
||||
checkCommandArgument(thickness >= 0, "Thickness must be >= 0");
|
||||
@ -209,7 +211,7 @@ public class RegionCommands extends MethodCommands {
|
||||
BlockVector3 pos2 = cuboidregion.getPos2();
|
||||
int blocksChanged = editSession.drawLine(pattern, pos1, pos2, thickness, !shell);
|
||||
|
||||
BBC.VISITOR_BLOCK.send(player, blocksChanged);
|
||||
BBC.VISITOR_BLOCK.send(actor, blocksChanged);
|
||||
return blocksChanged;
|
||||
}
|
||||
|
||||
@ -340,11 +342,11 @@ public class RegionCommands extends MethodCommands {
|
||||
)
|
||||
@Logging(REGION)
|
||||
@CommandPermissions("worldedit.region.center")
|
||||
public void center(Player player, EditSession editSession, @Selection Region region,
|
||||
public void center(Actor actor, EditSession editSession, @Selection Region region,
|
||||
@Arg(desc = "The pattern of blocks to set")
|
||||
Pattern pattern) throws WorldEditException {
|
||||
int affected = editSession.center(region, pattern);
|
||||
BBC.VISITOR_BLOCK.send(player, affected);
|
||||
BBC.VISITOR_BLOCK.send(actor, affected);
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -458,18 +460,11 @@ public class RegionCommands extends MethodCommands {
|
||||
|
||||
@Command(
|
||||
name = "/move",
|
||||
desc = "Move the contents of the selection",
|
||||
descFooter =
|
||||
"Moves the contents of the selection.\n" +
|
||||
"The -s flag shifts the selection to the target location.\n" +
|
||||
"The -b also copies biomes\n" +
|
||||
"The -e ignores entities\n" +
|
||||
"The -a ignores air blocks.\n" +
|
||||
"Optionally fills the old location with <leave-id>."
|
||||
)
|
||||
desc = "Move the contents of the selection"
|
||||
)
|
||||
@CommandPermissions("worldedit.region.move")
|
||||
@Logging(ORIENTATION_REGION)
|
||||
public void move(FawePlayer player, EditSession editSession, LocalSession session,
|
||||
public void move(FawePlayer player, World world, EditSession editSession, LocalSession session,
|
||||
@Selection Region region,
|
||||
@Arg(desc = "# of blocks to move", def = "1")
|
||||
int count,
|
||||
@ -482,23 +477,21 @@ public class RegionCommands extends MethodCommands {
|
||||
boolean moveSelection,
|
||||
@Switch(name = 'a', desc = "Ignore air blocks")
|
||||
boolean ignoreAirBlocks,
|
||||
@Switch(name = 'b', desc = "TODO")
|
||||
@Switch(name = 'b', desc = "Copy Biomes")
|
||||
boolean copyBiomes,
|
||||
@Switch(name = 'e', desc = "TODO")
|
||||
@Switch(name = 'e', desc = "Ignore entities")
|
||||
boolean skipEntities,
|
||||
@Switch(name = 'a', desc = "TODO")
|
||||
boolean skipAir,
|
||||
InjectedValueAccess context) throws WorldEditException {
|
||||
checkCommandArgument(count >= 1, "Count must be >= 1");
|
||||
player.checkConfirmationRegion(() -> {
|
||||
int affected = editSession.moveRegion(region, direction, count, !skipAir, !skipEntities, copyBiomes, replace);
|
||||
int affected = editSession.moveRegion(region, direction, count, !ignoreAirBlocks, !skipEntities, copyBiomes, replace);
|
||||
|
||||
if (moveSelection) {
|
||||
try {
|
||||
region.shift(direction.multiply(count));
|
||||
|
||||
session.getRegionSelector(player.getWorld()).learnChanges();
|
||||
session.getRegionSelector(player.getWorld()).explainRegionAdjust(player.getPlayer(), session);
|
||||
session.getRegionSelector(world).learnChanges();
|
||||
session.getRegionSelector(world).explainRegionAdjust(player.getPlayer(), session);
|
||||
} catch (RegionOperationException e) {
|
||||
player.printError(e.getMessage());
|
||||
}
|
||||
@ -533,7 +526,7 @@ public class RegionCommands extends MethodCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.region.stack")
|
||||
@Logging(ORIENTATION_REGION)
|
||||
public void stack(FawePlayer player, EditSession editSession, LocalSession session,
|
||||
public void stack(FawePlayer player, World world, EditSession editSession, LocalSession session,
|
||||
@Selection Region region,
|
||||
@Arg(desc = "# of copies to stack", def = "1")
|
||||
int count,
|
||||
@ -542,11 +535,15 @@ public class RegionCommands extends MethodCommands {
|
||||
BlockVector3 direction,
|
||||
@Switch(name = 's', desc = "Shift the selection to the last stacked copy")
|
||||
boolean moveSelection,
|
||||
@Switch(name = 'b', desc = "//TODO") boolean copyBiomes,
|
||||
@Switch(name = 'e', desc = "//TODO") boolean skipEntities,
|
||||
@Switch(name = 'b', desc = "Copy Biomes")
|
||||
boolean copyBiomes,
|
||||
@Switch(name = 'e', desc = "Skip entities")
|
||||
boolean skipEntities,
|
||||
@Switch(name = 'a', desc = "Ignore air blocks")
|
||||
boolean ignoreAirBlocks,
|
||||
@Switch(name = 'm', desc = "TODO") Mask sourceMask, InjectedValueAccess context) throws WorldEditException {
|
||||
@Switch(name = 'm', desc = "TODO")
|
||||
Mask sourceMask,
|
||||
InjectedValueAccess context) throws WorldEditException {
|
||||
player.checkConfirmationStack(() -> {
|
||||
if (sourceMask != null) {
|
||||
editSession.addSourceMask(sourceMask);
|
||||
@ -555,14 +552,15 @@ public class RegionCommands extends MethodCommands {
|
||||
|
||||
if (moveSelection) {
|
||||
try {
|
||||
final BlockVector3 size = region.getMaximumPoint().subtract(region.getMinimumPoint()).add(1, 1, 1);
|
||||
final BlockVector3 shiftVector = BlockVector3.at(direction.getX() * size.getX() * count, direction.getY() * size.getY() * count, direction.getZ() * size.getZ() * count);
|
||||
final BlockVector3 size = region.getMaximumPoint().subtract(region.getMinimumPoint());
|
||||
|
||||
final BlockVector3 shiftVector = direction.toVector3().multiply(count * (Math.abs(direction.dot(size)) + 1)).toBlockPoint();
|
||||
region.shift(shiftVector);
|
||||
|
||||
session.getRegionSelector(player.getWorld()).learnChanges();
|
||||
session.getRegionSelector(player.getWorld()).explainRegionAdjust(player.getPlayer(), session);
|
||||
session.getRegionSelector(world).learnChanges();
|
||||
session.getRegionSelector(world).explainRegionAdjust(player.getPlayer(), session);
|
||||
} catch (RegionOperationException e) {
|
||||
player.sendMessage(e.getMessage());
|
||||
player.toWorldEditPlayer().printError(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@ -670,11 +668,12 @@ public class RegionCommands extends MethodCommands {
|
||||
public void hollow(FawePlayer player, EditSession editSession,
|
||||
@Selection Region region,
|
||||
@Arg(desc = "Thickness of the shell to leave", def = "0")
|
||||
@Range(min = 0) int thickness,
|
||||
int thickness,
|
||||
@Arg(desc = "The pattern of blocks to replace the hollowed area with", def = "air")
|
||||
Pattern pattern,
|
||||
@Switch(name = 'm', desc = "Mask to hollow with") Mask mask,
|
||||
InjectedValueAccess context) throws WorldEditException {
|
||||
checkCommandArgument(thickness >= 0, "Thickness must be >= 0");
|
||||
Mask finalMask = mask == null ? new SolidBlockMask(editSession) : mask;
|
||||
player.checkConfirmationRegion(() -> {
|
||||
int affected = editSession.hollowOutRegion(region, thickness, pattern, finalMask);
|
||||
@ -688,14 +687,15 @@ public class RegionCommands extends MethodCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.region.forest")
|
||||
@Logging(REGION)
|
||||
public void forest(Player player, EditSession editSession, @Selection Region region,
|
||||
public int forest(Actor actor, EditSession editSession, @Selection Region region,
|
||||
@Arg(desc = "The type of tree to place", def = "tree")
|
||||
TreeType type,
|
||||
@Arg(desc = "The density of the forest", def = "5")
|
||||
double density) throws WorldEditException {
|
||||
checkCommandArgument(0 <= density && density <= 100, "Density must be in [0, 100]");
|
||||
int affected = editSession.makeForest(region, density / 100, type);
|
||||
BBC.COMMAND_TREE.send(player, affected);
|
||||
BBC.COMMAND_TREE.send(actor, affected);
|
||||
return affected;
|
||||
}
|
||||
|
||||
@Command(
|
||||
|
@ -201,7 +201,7 @@ public class SchematicCommands {
|
||||
desc = "Load a schematic into your clipboard"
|
||||
)
|
||||
@CommandPermissions({"worldedit.clipboard.load", "worldedit.schematic.load", "worldedit.schematic.load.asset", "worldedit.schematic.load.web", "worldedit.schematic.load.other"})
|
||||
public void load(Player player, LocalSession session,
|
||||
public void load(Actor actor, LocalSession session,
|
||||
@Arg(desc = "File name.")
|
||||
String filename,
|
||||
@Arg(desc = "Format name.", def = "sponge")
|
||||
@ -213,8 +213,8 @@ public class SchematicCommands {
|
||||
try {
|
||||
URI uri;
|
||||
if (filename.startsWith("url:")) {
|
||||
if (!player.hasPermission("worldedit.schematic.load.web")) {
|
||||
BBC.NO_PERM.send(player, "worldedit.schematic.load.web");
|
||||
if (!actor.hasPermission("worldedit.schematic.load.web")) {
|
||||
BBC.NO_PERM.send(actor, "worldedit.schematic.load.web");
|
||||
return;
|
||||
}
|
||||
UUID uuid = UUID.fromString(filename.substring(4));
|
||||
@ -225,7 +225,7 @@ public class SchematicCommands {
|
||||
uri = url.toURI();
|
||||
} else {
|
||||
File saveDir = worldEdit.getWorkingDirectoryFile(config.saveDir);
|
||||
File dir = Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS ? new File(saveDir, player.getUniqueId().toString()) : saveDir;
|
||||
File dir = Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS ? new File(saveDir, actor.getUniqueId().toString()) : saveDir;
|
||||
File file;
|
||||
if (filename.startsWith("#")) {
|
||||
String[] extensions;
|
||||
@ -234,14 +234,14 @@ public class SchematicCommands {
|
||||
} else {
|
||||
extensions = ClipboardFormats.getFileExtensionArray();
|
||||
}
|
||||
file = player.openFileOpenDialog(extensions);
|
||||
file = actor.openFileOpenDialog(extensions);
|
||||
if (file == null || !file.exists()) {
|
||||
player.printError("Schematic " + filename + " does not exist! (" + file + ")");
|
||||
actor.printError("Schematic " + filename + " does not exist! (" + file + ")");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS && !player.hasPermission("worldedit.schematic.load.other") && Pattern.compile("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}").matcher(filename).find()) {
|
||||
BBC.NO_PERM.send(player, "worldedit.schematic.load.other");
|
||||
if (Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS && !actor.hasPermission("worldedit.schematic.load.other") && Pattern.compile("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}").matcher(filename).find()) {
|
||||
BBC.NO_PERM.send(actor, "worldedit.schematic.load.other");
|
||||
return;
|
||||
}
|
||||
if (format == null && filename.matches(".*\\.[\\w].*")) {
|
||||
@ -257,25 +257,25 @@ public class SchematicCommands {
|
||||
}
|
||||
}
|
||||
if (file == null || !file.exists() || !MainUtil.isInSubDirectory(saveDir, file)) {
|
||||
player.printError("Schematic " + filename + " does not exist! (" + (file != null && file.exists()) + "|" + file + "|" + (file != null && !MainUtil.isInSubDirectory(saveDir, file)) + ")");
|
||||
actor.printError("Schematic " + filename + " does not exist! (" + (file != null && file.exists()) + "|" + file + "|" + (file != null && !MainUtil.isInSubDirectory(saveDir, file)) + ")");
|
||||
return;
|
||||
}
|
||||
if (format == null) {
|
||||
format = ClipboardFormats.findByFile(file);
|
||||
if (format == null) {
|
||||
BBC.CLIPBOARD_INVALID_FORMAT.send(player, file.getName());
|
||||
BBC.CLIPBOARD_INVALID_FORMAT.send(actor, file.getName());
|
||||
return;
|
||||
}
|
||||
}
|
||||
in = new FileInputStream(file);
|
||||
uri = file.toURI();
|
||||
}
|
||||
format.hold(player, uri, in);
|
||||
BBC.SCHEMATIC_LOADED.send(player, filename);
|
||||
format.hold(actor, uri, in);
|
||||
BBC.SCHEMATIC_LOADED.send(actor, filename);
|
||||
} catch (IllegalArgumentException e) {
|
||||
player.printError("Unknown filename: " + filename);
|
||||
actor.printError("Unknown filename: " + filename);
|
||||
} catch (URISyntaxException | IOException e) {
|
||||
player.printError("File could not be read or it does not exist: " + e.getMessage());
|
||||
actor.printError("File could not be read or it does not exist: " + e.getMessage());
|
||||
log.warn("Failed to load a saved clipboard", e);
|
||||
} finally {
|
||||
if (in != null) {
|
||||
|
Reference in New Issue
Block a user