mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-06-11 20:13:55 +00:00
Major command changes that don't work yet.
This commit is contained in:
@ -25,7 +25,7 @@ import com.sk89q.worldedit.extension.factory.DefaultTransformParser;
|
||||
import com.sk89q.worldedit.extension.factory.parser.mask.DefaultMaskParser;
|
||||
import com.sk89q.worldedit.extension.factory.parser.pattern.DefaultPatternParser;
|
||||
import com.sk89q.worldedit.extension.platform.Capability;
|
||||
import com.sk89q.worldedit.extension.platform.CommandManager;
|
||||
import com.sk89q.worldedit.extension.platform.PlatformCommandManager;
|
||||
import com.sk89q.worldedit.extension.platform.Platform;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
@ -152,7 +152,7 @@ public class FaweAPI {
|
||||
* @param aliases The aliases to give the command (or none)
|
||||
*/
|
||||
public static void registerCommands(Object clazz, String... aliases) {
|
||||
CommandManager.getInstance().registerCommands(clazz, aliases);
|
||||
PlatformCommandManager.getInstance().registerCommands(clazz, aliases);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,11 +1,24 @@
|
||||
package com.boydti.fawe.command;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.boydti.fawe.FaweAPI;
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import com.boydti.fawe.jnbt.anvil.*;
|
||||
import com.boydti.fawe.jnbt.anvil.filters.*;
|
||||
import com.boydti.fawe.jnbt.anvil.MCAClipboard;
|
||||
import com.boydti.fawe.jnbt.anvil.MCAFile;
|
||||
import com.boydti.fawe.jnbt.anvil.MCAFilter;
|
||||
import com.boydti.fawe.jnbt.anvil.MCAFilterCounter;
|
||||
import com.boydti.fawe.jnbt.anvil.MCAQueue;
|
||||
import com.boydti.fawe.jnbt.anvil.filters.DebugFixP2Roads;
|
||||
import com.boydti.fawe.jnbt.anvil.filters.DeleteBiomeFilterSimple;
|
||||
import com.boydti.fawe.jnbt.anvil.filters.DeleteOldFilter;
|
||||
import com.boydti.fawe.jnbt.anvil.filters.DeleteUnclaimedFilter;
|
||||
import com.boydti.fawe.jnbt.anvil.filters.DeleteUninhabitedFilter;
|
||||
import com.boydti.fawe.jnbt.anvil.filters.PlotTrimFilter;
|
||||
import com.boydti.fawe.jnbt.anvil.filters.RemapFilter;
|
||||
import com.boydti.fawe.jnbt.anvil.filters.RemoveLayerFilter;
|
||||
import com.boydti.fawe.jnbt.anvil.filters.SetPatternFilter;
|
||||
import com.boydti.fawe.jnbt.anvil.filters.TrimAirFilter;
|
||||
import com.boydti.fawe.jnbt.anvil.history.IAnvilHistory;
|
||||
import com.boydti.fawe.jnbt.anvil.history.NullAnvilHistory;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
@ -14,17 +27,16 @@ import com.boydti.fawe.object.RegionWrapper;
|
||||
import com.boydti.fawe.object.RunnableVal4;
|
||||
import com.boydti.fawe.object.changeset.AnvilHistory;
|
||||
import com.boydti.fawe.object.clipboard.remap.ClipboardRemapper;
|
||||
import com.boydti.fawe.object.mask.FaweBlockMatcher;
|
||||
import com.boydti.fawe.util.MainUtil;
|
||||
import com.boydti.fawe.util.SetQueue;
|
||||
import com.boydti.fawe.util.StringMan;
|
||||
import com.sk89q.minecraft.util.commands.Command;
|
||||
import org.enginehub.piston.annotation.Command;
|
||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||
import com.sk89q.worldedit.*;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.function.pattern.RandomPattern;
|
||||
import com.sk89q.worldedit.internal.annotation.Selection;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
@ -33,15 +45,10 @@ import com.sk89q.worldedit.util.command.binding.Switch;
|
||||
import com.sk89q.worldedit.util.command.parametric.Optional;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.RandomAccessFile;
|
||||
import java.util.*;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
@Command(aliases = {"/anvil"}, desc = "Manipulate billions of blocks: [More Info](https://github.com/boy0001/FastAsyncWorldedit/wiki/Anvil-API)")
|
||||
public class AnvilCommands {
|
||||
|
||||
@ -139,9 +146,7 @@ public class AnvilCommands {
|
||||
desc = "Replace all blocks in the selection with another",
|
||||
help = "Replace all blocks in the selection with another\n" +
|
||||
"The -d flag disabled wildcard data matching\n",
|
||||
flags = "df",
|
||||
min = 2,
|
||||
max = 4
|
||||
flags = "df"
|
||||
)
|
||||
@CommandPermissions("worldedit.anvil.replaceall")
|
||||
public void replaceAll(Player player, String folder, @Optional String from, String to, @Switch('d') boolean useData) throws WorldEditException {
|
||||
@ -164,9 +169,7 @@ public class AnvilCommands {
|
||||
aliases = {"remapall"},
|
||||
usage = "<folder>",
|
||||
help = "Remap the world between MCPE/PC values",
|
||||
desc = "Remap the world between MCPE/PC values",
|
||||
min = 1,
|
||||
max = 1
|
||||
desc = "Remap the world between MCPE/PC values"
|
||||
)
|
||||
@CommandPermissions("worldedit.anvil.remapall")
|
||||
public void remapall(Player player, String folder) throws WorldEditException {
|
||||
@ -188,9 +191,7 @@ public class AnvilCommands {
|
||||
help = "Delete all chunks which haven't been occupied for `age-ticks` (20t = 1s) and \n" +
|
||||
"Have not been accessed since `file-duration` (ms) after creation and\n" +
|
||||
"Have not been used in the past `chunk-inactivity` (ms)" +
|
||||
"The auto-save interval is the recommended value for `file-duration` and `chunk-inactivity`",
|
||||
min = 2,
|
||||
max = 3
|
||||
"The auto-save interval is the recommended value for `file-duration` and `chunk-inactivity`"
|
||||
)
|
||||
@CommandPermissions("worldedit.anvil.deleteallunvisited")
|
||||
public void deleteAllUnvisited(Player player, String folder, int inhabitedTicks, @Optional("60000") int fileDurationMillis) throws WorldEditException {
|
||||
@ -220,7 +221,7 @@ public class AnvilCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"deleteunclaimed"},
|
||||
name = "deleteunclaimed",
|
||||
usage = "<age-ticks> [file-age=60000]",
|
||||
desc = "(Supports: WG, P2, GP) Delete all chunks which haven't been occupied AND claimed",
|
||||
help = "(Supports: WG, P2, GP) Delete all chunks which aren't claimed AND haven't been occupied for `age-ticks` (20t = 1s) and \n" +
|
||||
@ -245,9 +246,7 @@ public class AnvilCommands {
|
||||
help = "Delete regions which haven't been accessed in a certain amount of time\n" +
|
||||
"You can use seconds (s), minutes (m), hours (h), days (d), weeks (w), years (y)\n" +
|
||||
"(months are not a unit of time)\n" +
|
||||
"E.g. 8h5m12s\n",
|
||||
min = 2,
|
||||
max = 3
|
||||
"E.g. 8h5m12s\n"
|
||||
)
|
||||
@CommandPermissions("worldedit.anvil.deletealloldregions")
|
||||
public void deleteAllOldRegions(Player player, String folder, String time) throws WorldEditException {
|
||||
@ -258,7 +257,7 @@ public class AnvilCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"trimallplots", },
|
||||
name = "trimallplots",
|
||||
desc = "Trim chunks in a Plot World",
|
||||
help = "Trim chunks in a Plot World\n" +
|
||||
"Unclaimed chunks will be deleted\n" +
|
||||
@ -278,7 +277,7 @@ public class AnvilCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"deletebiomechunks", },
|
||||
name = "deletebiomechunks",
|
||||
desc = "Delete chunks matching a specific biome"
|
||||
)
|
||||
@CommandPermissions("worldedit.anvil.trimallair")
|
||||
@ -289,7 +288,7 @@ public class AnvilCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"trimallair", },
|
||||
name = "trimallair",
|
||||
desc = "Trim all air in the world"
|
||||
)
|
||||
@CommandPermissions("worldedit.anvil.trimallair")
|
||||
@ -300,7 +299,7 @@ public class AnvilCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"debugfixroads", },
|
||||
name = "debugfixroads",
|
||||
desc = "debug - do not use"
|
||||
)
|
||||
@CommandPermissions("worldedit.anvil.debugfixroads")
|
||||
@ -314,9 +313,7 @@ public class AnvilCommands {
|
||||
aliases = {"replaceallpattern", "reap", "repallpat"},
|
||||
usage = "<folder> [from-block] <to-pattern>",
|
||||
desc = "Replace all blocks in the selection with another",
|
||||
flags = "dm",
|
||||
min = 2,
|
||||
max = 4
|
||||
flags = "dm"
|
||||
)
|
||||
@CommandPermissions("worldedit.anvil.replaceall")
|
||||
public void replaceAllPattern(Player player, String folder, @Optional String from, final Pattern to, @Switch('d') boolean useData, @Switch('m') boolean useMap) throws WorldEditException {
|
||||
@ -346,9 +343,7 @@ public class AnvilCommands {
|
||||
aliases = {"countall"},
|
||||
usage = "<folder> [hasSky] <id>",
|
||||
desc = "Count all blocks in a world",
|
||||
flags = "d",
|
||||
min = 2,
|
||||
max = 3
|
||||
flags = "d"
|
||||
)
|
||||
@CommandPermissions("worldedit.anvil.countall")
|
||||
public void countAll(Player player, EditSession editSession, String folder, String arg, @Switch('d') boolean useData) throws WorldEditException {
|
||||
|
@ -4,7 +4,7 @@ import com.boydti.fawe.config.Commands;
|
||||
import com.boydti.fawe.jnbt.anvil.HeightMapMCAGenerator;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
import com.boydti.fawe.object.changeset.CFIChangeSet;
|
||||
import com.sk89q.minecraft.util.commands.Command;
|
||||
import org.enginehub.piston.annotation.Command;
|
||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||
import com.sk89q.minecraft.util.commands.CommandException;
|
||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||
@ -28,12 +28,9 @@ public class CFICommand extends MethodCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"cfi", "createfromimage"},
|
||||
usage = "",
|
||||
min = 0,
|
||||
max = -1,
|
||||
anyFlags = true,
|
||||
desc = "Start CreateFromImage"
|
||||
name = "cfi",
|
||||
aliases = {"cfi", "createfromimage"},
|
||||
desc = "Start CreateFromImage"
|
||||
)
|
||||
@CommandPermissions("worldedit.anvil.cfi")
|
||||
public void cfi(FawePlayer fp, CommandContext context) throws CommandException, IOException {
|
||||
@ -51,49 +48,49 @@ public class CFICommand extends MethodCommands {
|
||||
|
||||
private void dispatch(FawePlayer fp, CFICommands.CFISettings settings, CommandContext context) throws CommandException {
|
||||
if (!settings.hasGenerator()) {
|
||||
switch (context.argsLength()) {
|
||||
case 0: {
|
||||
String hmCmd = child.alias() + " ";
|
||||
if (settings.image == null) {
|
||||
hmCmd += "image";
|
||||
} else {
|
||||
hmCmd = Commands.getAlias(CFICommands.class, "heightmap") + " " + settings.imageArg;
|
||||
}
|
||||
child.msg("What do you want to use as the base?").newline()
|
||||
.text("&7[&aHeightMap&7]").cmdTip(hmCmd).text(" - A heightmap like ").text("&7[&athis&7]").linkTip("http://i.imgur.com/qCd30MR.jpg")
|
||||
.newline()
|
||||
.text("&7[&aEmpty&7]").cmdTip(child.alias() + " empty").text("- An empty map of a specific size")
|
||||
.send(fp);
|
||||
break;
|
||||
if (context.argsLength() == 0) {
|
||||
String hmCmd = child.alias() + " ";
|
||||
if (settings.image == null) {
|
||||
hmCmd += "image";
|
||||
} else {
|
||||
hmCmd =
|
||||
Commands.getAlias(CFICommands.class, "heightmap") + " " + settings.imageArg;
|
||||
}
|
||||
default: {
|
||||
String remaining = context.getJoinedStrings(0);
|
||||
if (!dispatcher.contains(context.getString(0))) {
|
||||
switch (context.argsLength()) {
|
||||
case 1: {
|
||||
String cmd = Commands.getAlias(CFICommands.class, "heightmap") + " " + context.getJoinedStrings(0);
|
||||
dispatcher.call(cmd, context.getLocals(), new String[0]);
|
||||
return;
|
||||
}
|
||||
case 2: {
|
||||
String cmd = Commands.getAlias(CFICommands.class, "empty") + " " + context.getJoinedStrings(0);
|
||||
dispatcher.call(cmd, context.getLocals(), new String[0]);
|
||||
return;
|
||||
}
|
||||
child.msg("What do you want to use as the base?").newline()
|
||||
.text("[HeightMap]").cmdTip(hmCmd).text(" - A heightmap like ")
|
||||
.text("[this]").linkTip("http://i.imgur.com/qCd30MR.jpg")
|
||||
.newline()
|
||||
.text("[Empty]").cmdTip(child.alias() + " empty")
|
||||
.text("- An empty map of a specific size")
|
||||
.send(fp);
|
||||
} else {
|
||||
String remaining = context.getJoinedStrings(0);
|
||||
if (!dispatcher.contains(context.getString(0))) {
|
||||
switch (context.argsLength()) {
|
||||
case 1: {
|
||||
String cmd =
|
||||
Commands.getAlias(CFICommands.class, "heightmap") + " " + context
|
||||
.getJoinedStrings(0);
|
||||
dispatcher.call(cmd, context.getLocals(), new String[0]);
|
||||
return;
|
||||
}
|
||||
case 2: {
|
||||
String cmd =
|
||||
Commands.getAlias(CFICommands.class, "empty") + " " + context
|
||||
.getJoinedStrings(0);
|
||||
dispatcher.call(cmd, context.getLocals(), new String[0]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
dispatcher.call(remaining, context.getLocals(), new String[0]);
|
||||
}
|
||||
dispatcher.call(remaining, context.getLocals(), new String[0]);
|
||||
}
|
||||
} else {
|
||||
switch (context.argsLength()) {
|
||||
case 0:
|
||||
settings.setCategory("");
|
||||
child.mainMenu(fp);
|
||||
break;
|
||||
default:
|
||||
dispatcher.call(context.getJoinedStrings(0), context.getLocals(), new String[0]);
|
||||
break;
|
||||
if (context.argsLength() == 0) {
|
||||
settings.setCategory("");
|
||||
child.mainMenu(fp);
|
||||
} else {
|
||||
dispatcher.call(context.getJoinedStrings(0), context.getLocals(), new String[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,9 @@ import com.boydti.fawe.util.TaskManager;
|
||||
import com.boydti.fawe.util.TextureUtil;
|
||||
import com.boydti.fawe.util.chat.Message;
|
||||
import com.boydti.fawe.util.image.ImageUtil;
|
||||
import com.sk89q.minecraft.util.commands.Command;
|
||||
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
|
||||
import java.util.stream.IntStream;
|
||||
import org.enginehub.piston.annotation.Command;
|
||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||
import com.sk89q.minecraft.util.commands.CommandException;
|
||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||
@ -72,10 +74,11 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
import org.enginehub.piston.annotation.CommandContainer;
|
||||
|
||||
import static com.boydti.fawe.util.image.ImageUtil.load;
|
||||
|
||||
@Command(aliases = {"/cfi"}, desc = "Create a world from images: [More Info](https://git.io/v5iDy)")
|
||||
@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class)
|
||||
public class CFICommands extends MethodCommands {
|
||||
|
||||
private final Dispatcher dispathcer;
|
||||
@ -99,17 +102,14 @@ public class CFICommands extends MethodCommands {
|
||||
|
||||
@Command(
|
||||
aliases = {"heightmap"},
|
||||
usage = "<url>",
|
||||
desc = "Start CFI with a height map as a base"
|
||||
)
|
||||
@CommandPermissions("worldedit.anvil.cfi")
|
||||
public void heightmap(FawePlayer fp, FawePrimitiveBinding.ImageUri image, @Optional("1") double yscale) throws ParameterException {
|
||||
if (yscale != 0) {
|
||||
int[] raw = ((DataBufferInt) image.load().getRaster().getDataBuffer()).getData();
|
||||
int[] table = new int[256];
|
||||
for (int i = 0; i < table.length; i++) {
|
||||
table[i] = Math.min(255, (int) (i * yscale));
|
||||
}
|
||||
int[] table = IntStream.range(0, 256).map(i -> Math.min(255, (int) (i * yscale)))
|
||||
.toArray();
|
||||
for (int i = 0; i < raw.length; i++) {
|
||||
int color = raw[i];
|
||||
int red = table[(color >> 16) & 0xFF];
|
||||
@ -123,8 +123,7 @@ public class CFICommands extends MethodCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"empty"},
|
||||
usage = "<width> <length>",
|
||||
name = "empty",
|
||||
desc = "Start CFI with an empty map as a base"
|
||||
)
|
||||
@CommandPermissions("worldedit.anvil.cfi")
|
||||
@ -135,8 +134,7 @@ public class CFICommands extends MethodCommands {
|
||||
|
||||
private String generateName() {
|
||||
DateFormat df = new SimpleDateFormat("dd.MM.yyyy HH.mm.ss");
|
||||
String data = df.format(new Date());
|
||||
return data;
|
||||
return df.format(new Date());
|
||||
}
|
||||
|
||||
private void setup(HeightMapMCAGenerator generator, FawePlayer fp) {
|
||||
@ -149,8 +147,7 @@ public class CFICommands extends MethodCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"brush"},
|
||||
usage = "",
|
||||
name = "brush",
|
||||
desc = "Info about using brushes with CFI"
|
||||
)
|
||||
@CommandPermissions("worldedit.anvil.cfi")
|
||||
@ -166,23 +163,23 @@ public class CFICommands extends MethodCommands {
|
||||
} else {
|
||||
msg = msg("This is not supported with your platform/version").newline();
|
||||
}
|
||||
msg.text("&8< &7[&aBack&7]").cmdTip(alias()).send(fp);
|
||||
msg.text("< [Back]").cmdTip(alias()).send(fp);
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"cancel", "exit"},
|
||||
usage = "",
|
||||
name = "cancel",
|
||||
aliases = {"exit"},
|
||||
desc = "Cancel creation"
|
||||
)
|
||||
@CommandPermissions("worldedit.anvil.cfi")
|
||||
public void cancel(FawePlayer fp) throws ParameterException, IOException {
|
||||
public void cancel(FawePlayer fp) {
|
||||
getSettings(fp).remove();
|
||||
fp.sendMessage("Cancelled!");
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"done", "create"},
|
||||
usage = "",
|
||||
name = "done",
|
||||
aliases = "create",
|
||||
desc = "Create the world"
|
||||
)
|
||||
@CommandPermissions("worldedit.anvil.cfi")
|
||||
@ -240,8 +237,7 @@ public class CFICommands extends MethodCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"column", "setcolumn"},
|
||||
usage = "<pattern> [url|mask]",
|
||||
name = "column",
|
||||
desc = "Set the floor and main block"
|
||||
)
|
||||
@CommandPermissions("worldedit.anvil.cfi")
|
||||
@ -256,8 +252,7 @@ public class CFICommands extends MethodCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"floor", "setfloor"},
|
||||
usage = "<pattern> [url|mask]",
|
||||
name = "floor",
|
||||
desc = "Set the floor (default: grass)"
|
||||
)
|
||||
@CommandPermissions("worldedit.anvil.cfi")
|
||||
@ -276,8 +271,7 @@ public class CFICommands extends MethodCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"main", "setmain"},
|
||||
usage = "<pattern> [url|mask]",
|
||||
name = "main",
|
||||
desc = "Set the main block (default: stone)"
|
||||
)
|
||||
@CommandPermissions("worldedit.anvil.cfi")
|
||||
@ -296,10 +290,10 @@ public class CFICommands extends MethodCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "overlay",
|
||||
aliases = {"overlay", "setoverlay"},
|
||||
usage = "<pattern> [url|mask]",
|
||||
desc = "Set the overlay block",
|
||||
help = "Change the block directly above the floor (default: air)\n" +
|
||||
descFooter = "Change the block directly above the floor (default: air)\n" +
|
||||
"e.g. Tallgrass"
|
||||
)
|
||||
@CommandPermissions("worldedit.anvil.cfi")
|
||||
@ -314,9 +308,8 @@ public class CFICommands extends MethodCommands {
|
||||
|
||||
@Command(
|
||||
aliases = {"smooth"},
|
||||
usage = "<radius> <iterations> [image|mask]",
|
||||
desc = "Smooth the terrain",
|
||||
help = "Smooth terrain within an image-mask, or worldedit mask\n" +
|
||||
descFooter = "Smooth terrain within an image-mask, or worldedit mask\n" +
|
||||
" - You can use !0 as the mask to smooth everything\n" +
|
||||
" - This supports smoothing snow layers (set the floor to 78:7)\n" +
|
||||
" - A good value for radius and iterations would be 1 8."
|
||||
@ -335,8 +328,7 @@ public class CFICommands extends MethodCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"snow"},
|
||||
usage = "[image|mask]",
|
||||
name = "snow",
|
||||
desc = "Create some snow"
|
||||
)
|
||||
@CommandPermissions("worldedit.anvil.cfi")
|
||||
@ -351,10 +343,9 @@ public class CFICommands extends MethodCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"biomepriority", "palettebiomepriority", "setpalettebiomepriority"},
|
||||
usage = "[percent=50]",
|
||||
name = "biomepriority",
|
||||
desc = "Set the biome priority",
|
||||
help = "Increase or decrease biome priority when using blockBiomeColor.\n" +
|
||||
descFooter = "Increase or decrease biome priority when using blockBiomeColor.\n" +
|
||||
"A value of 50 is the default\n" +
|
||||
"Above 50 will prefer to color with biomes\n" +
|
||||
"Below 50 will prefer to color with blocks"
|
||||
@ -366,10 +357,9 @@ public class CFICommands extends MethodCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"paletteblocks", "colorpaletterblocks", "setcolorpaletteblocks"},
|
||||
usage = "<blocks|#clipboard|*>",
|
||||
name = "paletteblocks",
|
||||
desc = "Set the blocks used for coloring",
|
||||
help = "Allow only specific blocks to be used for coloring\n" +
|
||||
descFooter = "Allow only specific blocks to be used for coloring\n" +
|
||||
"`blocks` is a list of blocks e.g. stone,bedrock,wool\n" +
|
||||
"`#clipboard` will only use the blocks present in your clipboard."
|
||||
)
|
||||
@ -377,15 +367,15 @@ public class CFICommands extends MethodCommands {
|
||||
public void paletteblocks(FawePlayer fp, Player player, LocalSession session, @Optional String arg) throws ParameterException, EmptyClipboardException, InputParseException, FileNotFoundException {
|
||||
if (arg == null) {
|
||||
msg("What blocks do you want to color with?").newline()
|
||||
.text("&7[&aAll&7]").cmdTip(alias() + " PaletteBlocks *").text(" - All available blocks")
|
||||
.text("[All]").cmdTip(alias() + " PaletteBlocks *").text(" - All available blocks")
|
||||
.newline()
|
||||
.text("&7[&aClipboard&7]").cmdTip(alias() + " PaletteBlocks #clipboard").text(" - The blocks in your clipboard")
|
||||
.text("[Clipboard]").cmdTip(alias() + " PaletteBlocks #clipboard").text(" - The blocks in your clipboard")
|
||||
.newline()
|
||||
.text("&7[&aList&7]").suggestTip(alias() + " PaletteBlocks stone,gravel").text(" - A comma separated list of blocks")
|
||||
.text("[List]").suggestTip(alias() + " PaletteBlocks stone,gravel").text(" - A comma separated list of blocks")
|
||||
.newline()
|
||||
.text("&7[&aComplexity&7]").cmdTip(alias() + " Complexity").text(" - Block textures within a complexity range")
|
||||
.text("[Complexity]").cmdTip(alias() + " Complexity").text(" - Block textures within a complexity range")
|
||||
.newline()
|
||||
.text("&8< &7[&aBack&7]").cmdTip(alias() + " " + Commands.getAlias(CFICommands.class, "coloring"))
|
||||
.text("< [Back]").cmdTip(alias() + " " + Commands.getAlias(CFICommands.class, "coloring"))
|
||||
.send(fp);
|
||||
return;
|
||||
}
|
||||
@ -444,10 +434,9 @@ public class CFICommands extends MethodCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"randomization", "paletterandomization"},
|
||||
usage = "<true|false>",
|
||||
name = "randomization",
|
||||
desc = "Set whether randomization is enabled",
|
||||
help = "This is enabled by default, randomization will add some random variation in the blocks used to closer match the provided image.\n" +
|
||||
descFooter = "This is enabled by default, randomization will add some random variation in the blocks used to closer match the provided image.\n" +
|
||||
"If disabled, the closest block to the color will always be used.\n" +
|
||||
"Randomization will allow mixing biomes when coloring with biomes"
|
||||
)
|
||||
@ -458,10 +447,9 @@ public class CFICommands extends MethodCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"complexity", "palettecomplexity"},
|
||||
usage = "<minPercent> <maxPercent>",
|
||||
name = "complexity",
|
||||
desc = "Set the complexity for coloring",
|
||||
help = "Set the complexity for coloring\n" +
|
||||
descFooter = "Set the complexity for coloring\n" +
|
||||
"Filter out blocks to use based on their complexity, which is a measurement of how much color variation there is in the texture for that block.\n" +
|
||||
"Glazed terracotta is complex, and not very pleasant for terrain, whereas stone and wool are simpler textures.\n" +
|
||||
"Using 0 73 for the min/max would use the simplest 73% of blocks for coloring, and is a reasonable value."
|
||||
@ -475,10 +463,9 @@ public class CFICommands extends MethodCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"schem", "schematic", "schems", "schematics", "addschems"},
|
||||
usage = "[url] <mask> <file|folder|url> <rarity> <distance> <rotate=true>",
|
||||
name = "schem",
|
||||
desc = "Populate schematics",
|
||||
help = "Populate a schematic on the terrain\n" +
|
||||
descFooter = "Populate a schematic on the terrain\n" +
|
||||
" - Change the mask (e.g. angle mask) to only place the schematic in specific locations.\n" +
|
||||
" - The rarity is a value between 0 and 100.\n" +
|
||||
" - The distance is the spacing between each schematic"
|
||||
@ -502,10 +489,9 @@ public class CFICommands extends MethodCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"biome", "setbiome"},
|
||||
usage = "<biome> [image|mask]",
|
||||
name = "biome",
|
||||
desc = "Set the biome",
|
||||
help = "Set the biome in specific parts of the map.\n" +
|
||||
descFooter = "Set the biome in specific parts of the map.\n" +
|
||||
" - If an image is used, the biome will have a chance to be set based on how white the pixel is (white #FFF = 100% chance)" +
|
||||
" - The whiteOnly parameter determines if only white values on the image are set" +
|
||||
" - If a mask is used, the biome will be set anywhere the mask applies"
|
||||
@ -522,7 +508,7 @@ public class CFICommands extends MethodCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"caves", "addcaves"},
|
||||
name = "caves",
|
||||
desc = "Generate vanilla caves"
|
||||
)
|
||||
@CommandPermissions("worldedit.anvil.cfi")
|
||||
@ -533,10 +519,9 @@ public class CFICommands extends MethodCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"ore", "addore"},
|
||||
usage = "<mask=stone> <pattern> <size> <frequency> <rarity> <minY> <maxY>",
|
||||
name = "ore",
|
||||
desc = "Add an ore",
|
||||
help = "Use a specific pattern and settings to generate ore"
|
||||
descFooter = "Use a specific pattern and settings to generate ore"
|
||||
)
|
||||
@CommandPermissions("worldedit.anvil.cfi")
|
||||
public void ore(FawePlayer fp, Mask mask, Pattern pattern, int size, int frequency, int rariry, int minY, int maxY) throws ParameterException, WorldEditException {
|
||||
@ -546,8 +531,7 @@ public class CFICommands extends MethodCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"ores", "addores"},
|
||||
usage = "<mask=stone>",
|
||||
name = "ores",
|
||||
desc = "Generate the vanilla ores"
|
||||
)
|
||||
@CommandPermissions("worldedit.anvil.cfi")
|
||||
@ -558,10 +542,9 @@ public class CFICommands extends MethodCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"height", "setheight"},
|
||||
usage = "<height|image>",
|
||||
name = "height",
|
||||
desc = "Set the height",
|
||||
help = "Set the terrain height either based on an image heightmap, or a numeric value."
|
||||
descFooter = "Set the terrain height either based on an image heightmap, or a numeric value."
|
||||
)
|
||||
@CommandPermissions("worldedit.anvil.cfi")
|
||||
public void height(FawePlayer fp, String arg) throws ParameterException, WorldEditException {
|
||||
@ -576,10 +559,8 @@ public class CFICommands extends MethodCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"water", "waterid"},
|
||||
usage = "<block>",
|
||||
desc = "Change the block used for water\n" +
|
||||
"e.g. Lava"
|
||||
name = "water",
|
||||
desc = "Change the block used for water\ne.g. Lava"
|
||||
)
|
||||
@CommandPermissions("worldedit.anvil.cfi")
|
||||
public void waterId(FawePlayer fp, BlockStateHolder block) throws ParameterException, WorldEditException {
|
||||
@ -592,9 +573,7 @@ public class CFICommands extends MethodCommands {
|
||||
|
||||
@Command(
|
||||
aliases = {"baseid", "bedrockid"},
|
||||
usage = "<block>",
|
||||
desc = "Change the block used for the base\n" +
|
||||
"e.g. Bedrock"
|
||||
desc = "Change the block used for the base\ne.g. Bedrock"
|
||||
)
|
||||
@CommandPermissions("worldedit.anvil.cfi")
|
||||
public void baseId(FawePlayer fp, BlockStateHolder block) throws ParameterException, WorldEditException {
|
||||
@ -607,7 +586,6 @@ public class CFICommands extends MethodCommands {
|
||||
|
||||
@Command(
|
||||
aliases = {"worldthickness", "width", "thickness"},
|
||||
usage = "<height>",
|
||||
desc = "Set the thickness of the generated world\n" +
|
||||
" - A value of 0 is the default and will not modify the height"
|
||||
)
|
||||
@ -620,7 +598,6 @@ public class CFICommands extends MethodCommands {
|
||||
|
||||
@Command(
|
||||
aliases = {"floorthickness", "floorheight", "floorwidth"},
|
||||
usage = "<height>",
|
||||
desc = "Set the thickness of the top layer\n" +
|
||||
" - A value of 0 is the default and will only set the top block"
|
||||
)
|
||||
@ -659,7 +636,6 @@ public class CFICommands extends MethodCommands {
|
||||
|
||||
@Command(
|
||||
aliases = {"waterheight", "sealevel", "setwaterheight"},
|
||||
usage = "<height>",
|
||||
desc = "Set the level water is generated at\n" +
|
||||
"Set the level water is generated at\n" +
|
||||
" - By default water is disabled (with a value of 0)"
|
||||
@ -785,14 +761,14 @@ public class CFICommands extends MethodCommands {
|
||||
|
||||
int biomePriority = gen.getBiomePriority();
|
||||
|
||||
Message msg = msg("&8>>&7 Current Settings &8<<&7").newline()
|
||||
.text("&7Randomization ").text("&7[&a" + (Boolean.toString(rand).toUpperCase()) + "&7]").cmdTip(alias() + " randomization " + (!rand))
|
||||
Message msg = msg(">> Current Settings <<").newline()
|
||||
.text("Randomization ").text("[" + (Boolean.toString(rand).toUpperCase()) + "]").cmdTip(alias() + " randomization " + (!rand))
|
||||
.newline()
|
||||
.text("&7Mask ").text("&7[&a" + mask + "&7]").cmdTip(alias() + " mask")
|
||||
.text("Mask ").text("[" + mask + "]").cmdTip(alias() + " mask")
|
||||
.newline()
|
||||
.text("&7Blocks ").text("&7[&a" + blocks + "&7]").tooltip(blockList).command(alias() + " paletteBlocks")
|
||||
.text("Blocks ").text("[" + blocks + "]").tooltip(blockList).command(alias() + " paletteBlocks")
|
||||
.newline()
|
||||
.text("&7BiomePriority ").text("&7[&a" + biomePriority + "&7]").cmdTip(alias() + " biomepriority")
|
||||
.text("BiomePriority ").text("[" + biomePriority + "]").cmdTip(alias() + " biomepriority")
|
||||
.newline();
|
||||
|
||||
if (settings.image != null) {
|
||||
@ -802,19 +778,19 @@ public class CFICommands extends MethodCommands {
|
||||
if (settings.mask != null) colorArgs.append(" " + settings.maskArg);
|
||||
if (!settings.whiteOnly) colorArgs.append(" -w");
|
||||
|
||||
msg.text("&7Image: ")
|
||||
.text("&7[&a" + settings.imageArg + "&7]").cmdTip(alias() + " " + Commands.getAlias(CFICommands.class, "image"))
|
||||
msg.text("Image: ")
|
||||
.text("[" + settings.imageArg + "]").cmdTip(alias() + " " + Commands.getAlias(CFICommands.class, "image"))
|
||||
.newline().newline()
|
||||
.text("&cLet's Color&7: ")
|
||||
.text("&cLet's Color: ")
|
||||
.cmdOptions(alias() + " ", colorArgs.toString(), "Biomes", "Blocks", "BlockAndBiome", "Glass")
|
||||
.newline();
|
||||
} else {
|
||||
msg.newline().text("You can color a world using an image like ")
|
||||
.text("&7[&aThis&7]").linkTip("http://i.imgur.com/vJYinIU.jpg").newline()
|
||||
.text("[This]").linkTip("http://i.imgur.com/vJYinIU.jpg").newline()
|
||||
.text("&cYou MUST provide an image: ")
|
||||
.text("&7[&aNone&7]").cmdTip(alias() + " " + Commands.getAlias(Command.class, "image")).newline();
|
||||
.text("[None]").cmdTip(alias() + " " + Commands.getAlias(Command.class, "image")).newline();
|
||||
}
|
||||
msg.text("&8< &7[&aBack&7]").cmdTip(alias()).send(fp);
|
||||
msg.text("< [Back]").cmdTip(alias()).send(fp);
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -835,12 +811,12 @@ public class CFICommands extends MethodCommands {
|
||||
|
||||
StringBuilder cmd = new StringBuilder(alias() + " mask ");
|
||||
|
||||
msg("&8>>&7 Current Settings &8<<&7").newline()
|
||||
.text("&7Image Mask ").text("&7[&a" + settings.imageMaskArg + "&7]").suggestTip(cmd + "http://")
|
||||
msg(">> Current Settings <<").newline()
|
||||
.text("Image Mask ").text("[" + settings.imageMaskArg + "]").suggestTip(cmd + "http://")
|
||||
.newline()
|
||||
.text("&7WorldEdit Mask ").text("&7[&a" + settings.maskArg + "&7]").suggestTip(cmd + "<mask>")
|
||||
.text("WorldEdit Mask ").text("[" + settings.maskArg + "]").suggestTip(cmd + "<mask>")
|
||||
.newline()
|
||||
.text("&8< &7[&aBack&7]").cmdTip(alias() + " " + settings.getCategory()).send(fp);
|
||||
.text("< [Back]").cmdTip(alias() + " " + settings.getCategory()).send(fp);
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -861,10 +837,10 @@ public class CFICommands extends MethodCommands {
|
||||
if (pattern != null) {
|
||||
dispathcer.call(settings.getCategory(), context.getLocals(), new String[0]);
|
||||
} else {
|
||||
msg("&8>>&7 Current Settings &8<<&7").newline()
|
||||
.text("&7Pattern ").text("&7[&aClick Here&7]").suggestTip(cmd + " stone")
|
||||
msg(">> Current Settings <<").newline()
|
||||
.text("Pattern ").text("[Click Here]").suggestTip(cmd + " stone")
|
||||
.newline()
|
||||
.text("&8< &7[&aBack&7]").cmdTip(alias() + " " + settings.getCategory()).send(fp);
|
||||
.text("< [Back]").cmdTip(alias() + " " + settings.getCategory()).send(fp);
|
||||
}
|
||||
}
|
||||
|
||||
@ -902,9 +878,9 @@ public class CFICommands extends MethodCommands {
|
||||
StringBuilder cmd = new StringBuilder(alias() + " image ");
|
||||
if (image == null) {
|
||||
msg("Please provide an image:").newline()
|
||||
.text("From a URL: ").text("&7[&aClick Here&7]").suggestTip(cmd + "http://")
|
||||
.text("From a URL: ").text("[Click Here]").suggestTip(cmd + "http://")
|
||||
.newline()
|
||||
.text("From a file: ").text("&7[&aClick Here&7]").suggestTip(cmd + "file://")
|
||||
.text("From a file: ").text("[Click Here]").suggestTip(cmd + "file://")
|
||||
.send(fp);
|
||||
} else {
|
||||
if (settings.hasGenerator()) {
|
||||
@ -931,7 +907,7 @@ public class CFICommands extends MethodCommands {
|
||||
msg("What would you like to populate?").newline()
|
||||
.text("(You will need to type these commands)").newline()
|
||||
.cmdOptions(alias() + " ", "", "Ores", "Ore", "Caves", "Schematics", "Smooth")
|
||||
.newline().text("&8< &7[&aBack&7]").cmdTip(alias())
|
||||
.newline().text("< [Back]").cmdTip(alias())
|
||||
.send(fp);
|
||||
}
|
||||
|
||||
@ -966,49 +942,49 @@ public class CFICommands extends MethodCommands {
|
||||
String waterHeight = Commands.getAlias(CFICommands.class, "waterheight");
|
||||
String snow = Commands.getAlias(CFICommands.class, "snow");
|
||||
|
||||
Message msg = msg("&8>>&7 Current Settings &8<<&7").newline()
|
||||
.text("&7Mask ").text("&7[&a" + mask + "&7]").cmdTip(alias() + " mask")
|
||||
Message msg = msg(">> Current Settings <<").newline()
|
||||
.text("Mask ").text("[" + mask + "]").cmdTip(alias() + " mask")
|
||||
.newline()
|
||||
.text("&7Pattern ").text("&7[&a" + pattern + "&7]").cmdTip(alias() + " pattern")
|
||||
.text("Pattern ").text("[" + pattern + "]").cmdTip(alias() + " pattern")
|
||||
.newline()
|
||||
.newline()
|
||||
.text("&8>>&7 Components &8<<&7")
|
||||
.text(">> Components <<")
|
||||
.newline()
|
||||
.text("&7[&aHeight&7]").suggestTip(alias() + " " + alias("height") + " 120").text(" - Terrain height for whole map")
|
||||
.text("[Height]").suggestTip(alias() + " " + alias("height") + " 120").text(" - Terrain height for whole map")
|
||||
.newline()
|
||||
.text("&7[&aWaterHeight&7]").suggestTip(alias() + " " + alias("waterheight") + " 60").text(" - Sea level for whole map")
|
||||
.text("[WaterHeight]").suggestTip(alias() + " " + alias("waterheight") + " 60").text(" - Sea level for whole map")
|
||||
.newline()
|
||||
.text("&7[&aFloorThickness&7]").suggestTip(alias() + " " + alias("floorthickness") + " 60").text(" - Floor thickness of entire map")
|
||||
.text("[FloorThickness]").suggestTip(alias() + " " + alias("floorthickness") + " 60").text(" - Floor thickness of entire map")
|
||||
.newline()
|
||||
.text("&7[&aWorldThickness&7]").suggestTip(alias() + " " + alias("worldthickness") + " 60").text(" - World thickness of entire map")
|
||||
.text("[WorldThickness]").suggestTip(alias() + " " + alias("worldthickness") + " 60").text(" - World thickness of entire map")
|
||||
.newline()
|
||||
.text("&7[&aSnow&7]").suggestTip(alias() + " " + alias("snow") + maskArgs).text(" - Set snow in the masked areas")
|
||||
.text("[Snow]").suggestTip(alias() + " " + alias("snow") + maskArgs).text(" - Set snow in the masked areas")
|
||||
.newline();
|
||||
|
||||
if (pattern != null) {
|
||||
String disabled = "You must specify a pattern";
|
||||
msg
|
||||
.text("&7[&cWaterId&7]").tooltip(disabled).newline()
|
||||
.text("&7[&cBedrockId&7]").tooltip(disabled).newline()
|
||||
.text("&7[&cFloor&7]").tooltip(disabled).newline()
|
||||
.text("&7[&cMain&7]").tooltip(disabled).newline()
|
||||
.text("&7[&cColumn&7]").tooltip(disabled).newline()
|
||||
.text("&7[&cOverlay&7]").tooltip(disabled).newline();
|
||||
.text("[&cWaterId]").tooltip(disabled).newline()
|
||||
.text("[&cBedrockId]").tooltip(disabled).newline()
|
||||
.text("[&cFloor]").tooltip(disabled).newline()
|
||||
.text("[&cMain]").tooltip(disabled).newline()
|
||||
.text("[&cColumn]").tooltip(disabled).newline()
|
||||
.text("[&cOverlay]").tooltip(disabled).newline();
|
||||
} else {
|
||||
StringBuilder compArgs = new StringBuilder();
|
||||
compArgs.append(" " + settings.patternArg + maskArgs);
|
||||
|
||||
msg
|
||||
.text("&7[&aWaterId&7]").cmdTip(alias() + " waterId " + pattern).text(" - Water id for whole map").newline()
|
||||
.text("&7[&aBedrockId&7]").cmdTip(alias() + " baseId " + pattern).text(" - Bedrock id for whole map").newline()
|
||||
.text("&7[&aFloor&7]").cmdTip(alias() + " floor" + compArgs).text(" - Set the floor in the masked areas").newline()
|
||||
.text("&7[&aMain&7]").cmdTip(alias() + " main" + compArgs).text(" - Set the main block in the masked areas").newline()
|
||||
.text("&7[&aColumn&7]").cmdTip(alias() + " column" + compArgs).text(" - Set the columns in the masked areas").newline()
|
||||
.text("&7[&aOverlay&7]").cmdTip(alias() + " overlay" + compArgs).text(" - Set the overlay in the masked areas").newline();
|
||||
.text("[WaterId]").cmdTip(alias() + " waterId " + pattern).text(" - Water id for whole map").newline()
|
||||
.text("[BedrockId]").cmdTip(alias() + " baseId " + pattern).text(" - Bedrock id for whole map").newline()
|
||||
.text("[Floor]").cmdTip(alias() + " floor" + compArgs).text(" - Set the floor in the masked areas").newline()
|
||||
.text("[Main]").cmdTip(alias() + " main" + compArgs).text(" - Set the main block in the masked areas").newline()
|
||||
.text("[Column]").cmdTip(alias() + " column" + compArgs).text(" - Set the columns in the masked areas").newline()
|
||||
.text("[Overlay]").cmdTip(alias() + " overlay" + compArgs).text(" - Set the overlay in the masked areas").newline();
|
||||
}
|
||||
|
||||
msg.newline()
|
||||
.text("&8< &7[&aBack&7]").cmdTip(alias())
|
||||
.text("< [Back]").cmdTip(alias())
|
||||
.send(fp);
|
||||
}
|
||||
|
||||
@ -1160,9 +1136,9 @@ public class CFICommands extends MethodCommands {
|
||||
protected void mainMenu(FawePlayer fp) {
|
||||
msg("What do you want to do now?").newline()
|
||||
.cmdOptions(alias() + " ", "", "Coloring", "Component", "Populate", "Brush")
|
||||
.newline().text("&3<> &7[&aView&7]").command(alias() + " " + Commands.getAlias(CFICommands.class, "download")).tooltip("View full resolution image")
|
||||
.newline().text("&4>< &7[&aCancel&7]").cmdTip(alias() + " " + Commands.getAlias(CFICommands.class, "cancel"))
|
||||
.newline().text("&2>> &7[&aDone&7]").cmdTip(alias() + " " + Commands.getAlias(CFICommands.class, "done"))
|
||||
.newline().text("<> [View]").command(alias() + " " + Commands.getAlias(CFICommands.class, "download")).tooltip("View full resolution image")
|
||||
.newline().text(">< [Cancel]").cmdTip(alias() + " " + Commands.getAlias(CFICommands.class, "cancel"))
|
||||
.newline().text("&2>> [Done]").cmdTip(alias() + " " + Commands.getAlias(CFICommands.class, "done"))
|
||||
.send(fp);
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ package com.boydti.fawe.config;
|
||||
import com.boydti.fawe.configuration.ConfigurationSection;
|
||||
import com.boydti.fawe.configuration.file.YamlConfiguration;
|
||||
import com.boydti.fawe.util.StringMan;
|
||||
import com.sk89q.minecraft.util.commands.Command;
|
||||
import org.enginehub.piston.annotation.Command;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.annotation.Annotation;
|
||||
@ -31,53 +31,6 @@ public class Commands {
|
||||
}
|
||||
}
|
||||
|
||||
public static Command fromArgs(String[] aliases, String usage, String desc, int min, Integer max, String flags, String help, boolean queued) {
|
||||
int finalMax = max == null ? -1 : max;
|
||||
return new Command() {
|
||||
@Override
|
||||
public Class<? extends Annotation> annotationType() {
|
||||
return Command.class;
|
||||
}
|
||||
@Override
|
||||
public String[] aliases() {
|
||||
return aliases;
|
||||
}
|
||||
@Override
|
||||
public String usage() {
|
||||
return usage;
|
||||
}
|
||||
@Override
|
||||
public String desc() {
|
||||
return desc;
|
||||
}
|
||||
@Override
|
||||
public int min() {
|
||||
return min;
|
||||
}
|
||||
@Override
|
||||
public int max() {
|
||||
return finalMax;
|
||||
}
|
||||
@Override
|
||||
public String flags() {
|
||||
return flags;
|
||||
}
|
||||
@Override
|
||||
public String help() {
|
||||
return help;
|
||||
}
|
||||
@Override
|
||||
public boolean anyFlags() {
|
||||
return !(flags.isEmpty() || flags.matches("[a-z]+"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean queued() {
|
||||
return queued;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static Command translate(Class clazz, final Command command) {
|
||||
if (cmdConfig == null || command instanceof TranslatedCommand) {
|
||||
return command;
|
||||
|
@ -250,23 +250,28 @@ public abstract class MappedFaweQueue<WORLD, CHUNK, CHUNKSECTIONS, SECTION> impl
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Settings getSettings() {
|
||||
return settings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSettings(Settings settings) {
|
||||
this.settings = settings == null ? Settings.IMP : settings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWorld(String world) {
|
||||
this.world = world;
|
||||
this.weWorld = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWEWorld() {
|
||||
return weWorld != null ? weWorld : (weWorld = FaweAPI.getWorld(world));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWorldName() {
|
||||
return world;
|
||||
}
|
||||
@ -288,52 +293,59 @@ public abstract class MappedFaweQueue<WORLD, CHUNK, CHUNKSECTIONS, SECTION> impl
|
||||
|
||||
@Override
|
||||
public boolean supports(Capability capability) {
|
||||
if (capability == Capability.CHANGE_TASKS) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return capability == Capability.CHANGE_TASKS;
|
||||
}
|
||||
|
||||
public void setSessions(ConcurrentLinkedDeque<EditSession> sessions) {
|
||||
this.sessions = sessions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getModified() {
|
||||
return modified;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setModified(long modified) {
|
||||
this.modified = modified;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RunnableVal2<ProgressType, Integer> getProgressTask() {
|
||||
return progressTask;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProgressTask(RunnableVal2<ProgressType, Integer> progressTask) {
|
||||
this.progressTask = progressTask;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setChangeTask(RunnableVal2<FaweChunk, FaweChunk> changeTask) {
|
||||
this.changeTask = changeTask;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RunnableVal2<FaweChunk, FaweChunk> getChangeTask() {
|
||||
return changeTask;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SetQueue.QueueStage getStage() {
|
||||
return stage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStage(SetQueue.QueueStage stage) {
|
||||
this.stage = stage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addNotifyTask(Runnable runnable) {
|
||||
this.tasks.add(runnable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addTask(Runnable whenFree) {
|
||||
tasks.add(whenFree);
|
||||
}
|
||||
|
@ -1,16 +1,14 @@
|
||||
package com.boydti.fawe.jnbt;
|
||||
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import com.boydti.fawe.object.RunnableVal2;
|
||||
import com.boydti.fawe.object.exception.FaweException;
|
||||
|
||||
import com.sk89q.jnbt.NBTInputStream;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class NBTStreamer {
|
||||
private final NBTInputStream is;
|
||||
@ -27,7 +25,7 @@ public class NBTStreamer {
|
||||
* @throws IOException
|
||||
*/
|
||||
public void readFully() throws IOException {
|
||||
is.readNamedTagLazy(node -> readers.get(node));
|
||||
is.readNamedTagLazy(readers::get);
|
||||
is.close();
|
||||
}
|
||||
|
||||
|
@ -122,7 +122,7 @@ public class SchematicStreamer extends NBTStreamer {
|
||||
ByteReader biomeReader = new ByteReader() {
|
||||
@Override
|
||||
public void run(int index, int value) {
|
||||
fc.setBiome(index, BiomeTypes.get(value));
|
||||
fc.setBiome(index, BiomeTypes.register(value));
|
||||
}
|
||||
};
|
||||
NBTStreamReader<Integer, Integer> initializer23 = new NBTStreamReader<Integer, Integer>() {
|
||||
|
@ -1,11 +1,7 @@
|
||||
package com.boydti.fawe.jnbt.anvil;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.example.SimpleIntFaweChunk;
|
||||
import com.boydti.fawe.jnbt.anvil.HeightMapMCADrawer;
|
||||
import com.boydti.fawe.jnbt.anvil.MCAChunk;
|
||||
import com.boydti.fawe.jnbt.anvil.MCAWriter;
|
||||
import com.boydti.fawe.object.*;
|
||||
import com.boydti.fawe.object.brush.visualization.VirtualWorld;
|
||||
import com.boydti.fawe.object.change.StreamChange;
|
||||
@ -930,7 +926,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
||||
public BiomeType getBiomeType(int x, int z) throws FaweException.FaweChunkLoadException {
|
||||
int index = z * getWidth() + x;
|
||||
if (index < 0 || index >= getArea()) index = Math.floorMod(index, getArea());
|
||||
return BiomeTypes.get(biomes.getByte(index));
|
||||
return BiomeTypes.register(biomes.getByte(index));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -9,14 +9,25 @@ import com.boydti.fawe.object.number.MutableLong;
|
||||
import com.boydti.fawe.util.MainUtil;
|
||||
import com.boydti.fawe.util.MathMan;
|
||||
import com.boydti.fawe.util.ReflectionUtils;
|
||||
import com.sk89q.jnbt.*;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.jnbt.IntTag;
|
||||
import com.sk89q.jnbt.ListTag;
|
||||
import com.sk89q.jnbt.NBTConstants;
|
||||
import com.sk89q.jnbt.NBTInputStream;
|
||||
import com.sk89q.jnbt.NBTOutputStream;
|
||||
import com.sk89q.jnbt.Tag;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.biome.BiomeTypes;
|
||||
|
||||
import java.io.DataOutput;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
public class MCAChunk extends FaweChunk<Void> {
|
||||
@ -105,12 +116,9 @@ public class MCAChunk extends FaweChunk<Void> {
|
||||
}
|
||||
out.writeNamedTag("HeightMap", heightMap);
|
||||
out.writeNamedTagName("Sections", NBTConstants.TYPE_LIST);
|
||||
nbtOut.getOutputStream().writeByte(NBTConstants.TYPE_COMPOUND);
|
||||
int len = 0;
|
||||
for (int[] id : ids) {
|
||||
if (id != null) len++;
|
||||
}
|
||||
nbtOut.getOutputStream().writeInt(len);
|
||||
nbtOut.writeByte(NBTConstants.TYPE_COMPOUND);
|
||||
int len = (int) Arrays.stream(ids).filter(Objects::nonNull).count();
|
||||
nbtOut.writeInt(len);
|
||||
for (int layer = 0; layer < ids.length; layer++) {
|
||||
int[] idLayer = ids[layer];
|
||||
if (idLayer == null) {
|
||||
@ -131,8 +139,7 @@ public class MCAChunk extends FaweChunk<Void> {
|
||||
buffer = new byte[8192];
|
||||
}
|
||||
FastByteArrayOutputStream buffered = new FastByteArrayOutputStream(buffer);
|
||||
DataOutputStream dataOut = new DataOutputStream(buffered);
|
||||
try (NBTOutputStream nbtOut = new NBTOutputStream((DataOutput) dataOut)) {
|
||||
try (NBTOutputStream nbtOut = new NBTOutputStream(buffered)) {
|
||||
write(nbtOut);
|
||||
}
|
||||
return buffered.toByteArray();
|
||||
@ -603,14 +610,14 @@ public class MCAChunk extends FaweChunk<Void> {
|
||||
public BiomeType[] getBiomeArray() {
|
||||
BiomeType[] arr = new BiomeType[256];
|
||||
for (int i = 0; i < arr.length; i++) {
|
||||
arr[i] = BiomeTypes.get(biomes[i]);
|
||||
arr[i] = BiomeTypes.register(biomes[i]);
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeType getBiomeType(int x, int z) {
|
||||
return BiomeTypes.get(biomes[(x & 15) + ((z & 15) << 4)]);
|
||||
return BiomeTypes.register(biomes[(x & 15) + ((z & 15) << 4)]);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -4,7 +4,6 @@ import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.object.FaweChunk;
|
||||
import com.boydti.fawe.object.io.FastByteArrayOutputStream;
|
||||
import com.boydti.fawe.util.MathMan;
|
||||
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.jnbt.ListTag;
|
||||
import com.sk89q.jnbt.NBTConstants;
|
||||
@ -15,9 +14,6 @@ import com.sk89q.worldedit.world.block.BlockID;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
import java.io.DataOutput;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@ -224,8 +220,7 @@ public class WritableMCAChunk extends FaweChunk<Void> {
|
||||
buffer = new byte[8192];
|
||||
}
|
||||
FastByteArrayOutputStream buffered = new FastByteArrayOutputStream(buffer);
|
||||
DataOutputStream dataOut = new DataOutputStream(buffered);
|
||||
try (NBTOutputStream nbtOut = new NBTOutputStream((DataOutput) dataOut)) {
|
||||
try (NBTOutputStream nbtOut = new NBTOutputStream(buffered)) {
|
||||
write(nbtOut);
|
||||
}
|
||||
return buffered.toByteArray();
|
||||
|
@ -24,10 +24,9 @@ import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.event.platform.CommandEvent;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extension.platform.Capability;
|
||||
import com.sk89q.worldedit.extension.platform.CommandManager;
|
||||
import com.sk89q.worldedit.extension.platform.PlatformCommandManager;
|
||||
import com.sk89q.worldedit.extension.platform.PlatformManager;
|
||||
import com.sk89q.worldedit.extension.platform.PlayerProxy;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
@ -46,8 +45,6 @@ import com.sk89q.worldedit.regions.selector.Polygonal2DRegionSelector;
|
||||
import com.sk89q.worldedit.session.ClipboardHolder;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
@ -59,6 +56,7 @@ import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class FawePlayer<T> extends Metadatable {
|
||||
|
||||
@ -152,74 +150,70 @@ public abstract class FawePlayer<T> extends Metadatable {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
private void setConfirmTask(@Nullable Runnable task, CommandContext context, String command) {
|
||||
if (task != null) {
|
||||
Runnable newTask = () -> CommandManager.getInstance().handleCommandTask(() -> {
|
||||
task.run();
|
||||
return null;
|
||||
}, context.getLocals());
|
||||
setMeta("cmdConfirm", newTask);
|
||||
} else {
|
||||
setMeta("cmdConfirm", new CommandEvent(getPlayer(), command));
|
||||
}
|
||||
private void setConfirmTask(@NotNull Runnable task, CommandContext context) {
|
||||
Runnable newTask = () -> PlatformCommandManager.getInstance().handleCommandTask(() -> {
|
||||
task.run();
|
||||
return null;
|
||||
}, context.getLocals());
|
||||
setMeta("cmdConfirm", newTask);
|
||||
}
|
||||
|
||||
public void checkConfirmation(@Nullable Runnable task, String command, int times, int limit, CommandContext context) throws RegionOperationException {
|
||||
public void checkConfirmation(@NotNull Runnable task, String command, int times, int limit, CommandContext context) throws RegionOperationException {
|
||||
if (command != null && !getMeta("cmdConfirmRunning", false)) {
|
||||
if (times > limit) {
|
||||
setConfirmTask(task, context, command);
|
||||
setConfirmTask(task, context);
|
||||
String volume = "<unspecified>";
|
||||
throw new RegionOperationException(BBC.WORLDEDIT_CANCEL_REASON_CONFIRM.f(0, times, command, volume));
|
||||
}
|
||||
}
|
||||
if (task != null) task.run();
|
||||
task.run();
|
||||
}
|
||||
|
||||
public void checkConfirmationRadius(@Nullable Runnable task, String command, int radius, CommandContext context) throws RegionOperationException {
|
||||
public void checkConfirmationRadius(@NotNull Runnable task, String command, int radius, CommandContext context) throws RegionOperationException {
|
||||
if (command != null && !getMeta("cmdConfirmRunning", false)) {
|
||||
if (radius > 0) {
|
||||
if (radius > 448) {
|
||||
setConfirmTask(task, context, command);
|
||||
setConfirmTask(task, context);
|
||||
long volume = (long) (Math.PI * ((double) radius * radius));
|
||||
throw new RegionOperationException(BBC.WORLDEDIT_CANCEL_REASON_CONFIRM.f(0, radius, command, NumberFormat.getNumberInstance().format(volume)));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (task != null) task.run();
|
||||
task.run();
|
||||
}
|
||||
|
||||
public void checkConfirmationStack(@Nullable Runnable task, String command, Region region, int times, CommandContext context) throws RegionOperationException {
|
||||
public void checkConfirmationStack(@NotNull Runnable task, String command, Region region, int times, CommandContext context) throws RegionOperationException {
|
||||
if (command != null && !getMeta("cmdConfirmRunning", false)) {
|
||||
if (region != null) {
|
||||
BlockVector3 min = region.getMinimumPoint();
|
||||
BlockVector3 max = region.getMaximumPoint();
|
||||
long area = (long) ((max.getX() - min.getX()) * (max.getZ() - min.getZ() + 1)) * times;
|
||||
if (area > 2 << 18) {
|
||||
setConfirmTask(task, context, command);
|
||||
setConfirmTask(task, context);
|
||||
BlockVector3 base = max.subtract(min).add(BlockVector3.ONE);
|
||||
long volume = (long) base.getX() * base.getZ() * base.getY() * times;
|
||||
throw new RegionOperationException(BBC.WORLDEDIT_CANCEL_REASON_CONFIRM.f(min, max, command, NumberFormat.getNumberInstance().format(volume)));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (task != null) task.run();
|
||||
task.run();
|
||||
}
|
||||
|
||||
public void checkConfirmationRegion(@Nullable Runnable task, String command, Region region, CommandContext context) throws RegionOperationException {
|
||||
public void checkConfirmationRegion(@NotNull Runnable task, String command, Region region, CommandContext context) throws RegionOperationException {
|
||||
if (command != null && !getMeta("cmdConfirmRunning", false)) {
|
||||
if (region != null) {
|
||||
BlockVector3 min = region.getMinimumPoint();
|
||||
BlockVector3 max = region.getMaximumPoint();
|
||||
long area = (max.getX() - min.getX()) * (max.getZ() - min.getZ() + 1);
|
||||
if (area > 2 << 18) {
|
||||
setConfirmTask(task, context, command);
|
||||
setConfirmTask(task, context);
|
||||
BlockVector3 base = max.subtract(min).add(BlockVector3.ONE);
|
||||
long volume = (long) base.getX() * base.getZ() * base.getY();
|
||||
throw new RegionOperationException(BBC.WORLDEDIT_CANCEL_REASON_CONFIRM.f(min, max, command, NumberFormat.getNumberInstance().format(volume)));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (task != null) task.run();
|
||||
task.run();
|
||||
}
|
||||
|
||||
public synchronized boolean confirm() {
|
||||
|
@ -175,12 +175,6 @@ public interface FaweQueue extends HasFaweQueue, Extent {
|
||||
fc.fillCuboid(0, 15, minY, maxY, 0, 15, combinedId);
|
||||
fc.optimize();
|
||||
|
||||
int bcx = (current.minX) >> 4;
|
||||
int bcz = (current.minZ) >> 4;
|
||||
|
||||
int tcx = (current.maxX) >> 4;
|
||||
int tcz = (current.maxZ) >> 4;
|
||||
// [chunkx, chunkz, pos1x, pos1z, pos2x, pos2z, isedge]
|
||||
MainUtil.chunkTaskSync(current, new RunnableVal<int[]>() {
|
||||
@Override
|
||||
public void run(int[] value) {
|
||||
@ -228,6 +222,7 @@ public interface FaweQueue extends HasFaweQueue, Extent {
|
||||
|
||||
File getSaveFolder();
|
||||
|
||||
@Override
|
||||
default int getMaxY() {
|
||||
World weWorld = getWEWorld();
|
||||
return weWorld == null ? 255 : weWorld.getMaxY();
|
||||
@ -452,7 +447,7 @@ public interface FaweQueue extends HasFaweQueue, Extent {
|
||||
try {
|
||||
return getCombinedId4Data(x, y, z);
|
||||
} catch (FaweException ignore) {
|
||||
session.debug(BBC.WORLDEDIT_FAILED_LOAD_CHUNK, x >> 4, z >> 4);
|
||||
BBC.WORLDEDIT_FAILED_LOAD_CHUNK.send(session.getPlayer(),x >> 4, z >> 4);
|
||||
return def;
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
|
@ -125,6 +125,7 @@ public class RegionWrapper extends CuboidRegion {
|
||||
return this.minX + "," + this.minY + "," + this.minZ + "->" + this.maxX + "," + this.maxY + "," + this.maxZ;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGlobal() {
|
||||
return minX == Integer.MIN_VALUE && minZ == Integer.MIN_VALUE && maxX == Integer.MAX_VALUE && maxZ == Integer.MAX_VALUE && minY <= 0 && maxY >= 255;
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extension.input.InputParseException;
|
||||
import com.sk89q.worldedit.extension.input.ParserContext;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extension.platform.CommandManager;
|
||||
import com.sk89q.worldedit.extension.platform.PlatformCommandManager;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.internal.expression.Expression;
|
||||
@ -62,7 +62,7 @@ public class BrushSettings {
|
||||
}
|
||||
|
||||
public static BrushSettings get(BrushTool tool, Player player, LocalSession session, Map<String, Object> settings) throws CommandException, InputParseException {
|
||||
Dispatcher dispatcher = CommandManager.getInstance().getDispatcher();
|
||||
Dispatcher dispatcher = PlatformCommandManager.getInstance().getCommandManager();
|
||||
Dispatcher brushDispatcher = (Dispatcher) (dispatcher.get("brush").getCallable());
|
||||
if (brushDispatcher == null) {
|
||||
return null;
|
||||
|
@ -10,7 +10,7 @@ import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.command.tool.brush.Brush;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.event.platform.CommandEvent;
|
||||
import com.sk89q.worldedit.extension.platform.CommandManager;
|
||||
import com.sk89q.worldedit.extension.platform.PlatformCommandManager;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.selector.CuboidRegionSelector;
|
||||
@ -48,7 +48,7 @@ public class CommandBrush implements Brush {
|
||||
List<String> cmds = StringMan.split(replaced, ';');
|
||||
for (String cmd : cmds) {
|
||||
CommandEvent event = new CommandEvent(wePlayer, cmd);
|
||||
CommandManager.getInstance().handleCommandOnCurrentThread(event);
|
||||
PlatformCommandManager.getInstance().handleCommandOnCurrentThread(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.event.platform.CommandEvent;
|
||||
import com.sk89q.worldedit.extension.platform.CommandManager;
|
||||
import com.sk89q.worldedit.extension.platform.PlatformCommandManager;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.selector.CuboidRegionSelector;
|
||||
@ -42,7 +42,7 @@ public class ScatterCommand extends ScatterBrush {
|
||||
List<String> cmds = StringMan.split(replaced, ';');
|
||||
for (String cmd : cmds) {
|
||||
CommandEvent event = new CommandEvent(wePlayer, cmd);
|
||||
CommandManager.getInstance().handleCommandOnCurrentThread(event);
|
||||
PlatformCommandManager.getInstance().handleCommandOnCurrentThread(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,6 @@ public interface HeightMap {
|
||||
default void applyHeightMapData(int[][] data, EditSession session, BlockVector3 pos, int size, double yscale, boolean smooth, boolean towards, boolean layers) throws MaxChangedBlocksException {
|
||||
BlockVector3 top = session.getMaximumPoint();
|
||||
int maxY = top.getBlockY();
|
||||
int diameter = 2 * size + 1;
|
||||
Location min = new Location(session.getWorld(), pos.subtract(size, maxY, size).toVector3());
|
||||
BlockVector3 max = pos.add(size, maxY, size);
|
||||
Region region = new CuboidRegion(session.getWorld(), min.toBlockPoint(), max);
|
||||
@ -34,6 +33,7 @@ public interface HeightMap {
|
||||
if (smooth) {
|
||||
try {
|
||||
HeightMapFilter filter = (HeightMapFilter) HeightMapFilter.class.getConstructors()[0].newInstance(GaussianKernel.class.getConstructors()[0].newInstance(5, 1));
|
||||
int diameter = 2 * size + 1;
|
||||
data[1] = filter.filter(data[1], diameter, diameter);
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.boydti.fawe.object.brush.visualization;
|
||||
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.example.SimpleIntFaweChunk;
|
||||
import com.boydti.fawe.object.FaweChunk;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
@ -8,9 +7,9 @@ import com.boydti.fawe.object.RunnableVal2;
|
||||
import com.boydti.fawe.object.exception.FaweException;
|
||||
import com.boydti.fawe.util.SetQueue;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.worldedit.*;
|
||||
import com.sk89q.worldedit.world.biome.BiomeTypes;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||
import com.sk89q.worldedit.function.operation.Operation;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
@ -20,10 +19,10 @@ import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.util.TreeGenerator;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.biome.BiomeTypes;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.weather.WeatherType;
|
||||
import com.sk89q.worldedit.world.weather.WeatherTypes;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
@ -4,7 +4,6 @@ import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.history.UndoContext;
|
||||
import com.sk89q.worldedit.history.change.Change;
|
||||
import com.sk89q.worldedit.math.MutableBlockVector2;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.biome.BiomeTypes;
|
||||
|
||||
public class MutableBiomeChange implements Change {
|
||||
@ -26,11 +25,11 @@ public class MutableBiomeChange implements Change {
|
||||
|
||||
@Override
|
||||
public void undo(UndoContext context) throws WorldEditException {
|
||||
context.getExtent().setBiome(mutable, BiomeTypes.get(from));
|
||||
context.getExtent().setBiome(mutable, BiomeTypes.register(from));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void redo(UndoContext context) throws WorldEditException {
|
||||
context.getExtent().setBiome(mutable, BiomeTypes.get(to));
|
||||
context.getExtent().setBiome(mutable, BiomeTypes.register(to));
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,11 @@ import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.config.Settings;
|
||||
import com.boydti.fawe.database.DBHandler;
|
||||
import com.boydti.fawe.database.RollbackDatabase;
|
||||
import com.boydti.fawe.object.*;
|
||||
import com.boydti.fawe.object.FaweInputStream;
|
||||
import com.boydti.fawe.object.FaweOutputStream;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
import com.boydti.fawe.object.IntegerPair;
|
||||
import com.boydti.fawe.object.RegionWrapper;
|
||||
import com.boydti.fawe.util.MainUtil;
|
||||
import com.sk89q.jnbt.NBTInputStream;
|
||||
import com.sk89q.jnbt.NBTOutputStream;
|
||||
@ -13,12 +17,11 @@ import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
import java.io.DataOutput;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
@ -291,7 +294,7 @@ public class DiskStorageHistory extends FaweStreamChangeSet {
|
||||
}
|
||||
enttFile.getParentFile().mkdirs();
|
||||
enttFile.createNewFile();
|
||||
osENTCT = new NBTOutputStream((DataOutput) getCompressedOS(new FileOutputStream(enttFile)));
|
||||
osENTCT = new NBTOutputStream(getCompressedOS(new FileOutputStream(enttFile)));
|
||||
return osENTCT;
|
||||
}
|
||||
|
||||
@ -302,7 +305,7 @@ public class DiskStorageHistory extends FaweStreamChangeSet {
|
||||
}
|
||||
entfFile.getParentFile().mkdirs();
|
||||
entfFile.createNewFile();
|
||||
osENTCF = new NBTOutputStream((DataOutput) getCompressedOS(new FileOutputStream(entfFile)));
|
||||
osENTCF = new NBTOutputStream(getCompressedOS(new FileOutputStream(entfFile)));
|
||||
return osENTCF;
|
||||
}
|
||||
|
||||
@ -313,7 +316,7 @@ public class DiskStorageHistory extends FaweStreamChangeSet {
|
||||
}
|
||||
nbttFile.getParentFile().mkdirs();
|
||||
nbttFile.createNewFile();
|
||||
osNBTT = new NBTOutputStream((DataOutput) getCompressedOS(new FileOutputStream(nbttFile)));
|
||||
osNBTT = new NBTOutputStream(getCompressedOS(new FileOutputStream(nbttFile)));
|
||||
return osNBTT;
|
||||
}
|
||||
|
||||
@ -324,7 +327,7 @@ public class DiskStorageHistory extends FaweStreamChangeSet {
|
||||
}
|
||||
nbtfFile.getParentFile().mkdirs();
|
||||
nbtfFile.createNewFile();
|
||||
osNBTF = new NBTOutputStream((DataOutput) getCompressedOS(new FileOutputStream(nbtfFile)));
|
||||
osNBTF = new NBTOutputStream(getCompressedOS(new FileOutputStream(nbtfFile)));
|
||||
return osNBTF;
|
||||
}
|
||||
|
||||
@ -343,8 +346,7 @@ public class DiskStorageHistory extends FaweStreamChangeSet {
|
||||
if (!bioFile.exists()) {
|
||||
return null;
|
||||
}
|
||||
FaweInputStream is = MainUtil.getCompressedIS(new FileInputStream(bioFile));
|
||||
return is;
|
||||
return MainUtil.getCompressedIS(new FileInputStream(bioFile));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -391,8 +393,8 @@ public class DiskStorageHistory extends FaweStreamChangeSet {
|
||||
// skip mode
|
||||
gis.skipFully(1);
|
||||
// origin
|
||||
ox = ((gis.read() << 24) + (gis.read() << 16) + (gis.read() << 8) + (gis.read() << 0));
|
||||
oz = ((gis.read() << 24) + (gis.read() << 16) + (gis.read() << 8) + (gis.read() << 0));
|
||||
ox = ((gis.read() << 24) + (gis.read() << 16) + (gis.read() << 8) + gis.read());
|
||||
oz = ((gis.read() << 24) + (gis.read() << 16) + (gis.read() << 8) + gis.read());
|
||||
setOrigin(ox, oz);
|
||||
DiskStorageSummary summary = new DiskStorageSummary(ox, oz);
|
||||
if (!requiredRegion.isIn(ox, oz)) {
|
||||
@ -432,8 +434,8 @@ public class DiskStorageHistory extends FaweStreamChangeSet {
|
||||
// skip mode
|
||||
gis.skipFully(1);
|
||||
// origin
|
||||
ox = ((gis.read() << 24) + (gis.read() << 16) + (gis.read() << 8) + (gis.read() << 0));
|
||||
oz = ((gis.read() << 24) + (gis.read() << 16) + (gis.read() << 8) + (gis.read() << 0));
|
||||
ox = ((gis.read() << 24) + (gis.read() << 16) + (gis.read() << 8) + gis.read());
|
||||
oz = ((gis.read() << 24) + (gis.read() << 16) + (gis.read() << 8) + gis.read());
|
||||
setOrigin(ox, oz);
|
||||
fis.close();
|
||||
gis.close();
|
||||
@ -446,8 +448,6 @@ public class DiskStorageHistory extends FaweStreamChangeSet {
|
||||
|
||||
public static class DiskStorageSummary {
|
||||
|
||||
private final int z;
|
||||
private final int x;
|
||||
public int[] blocks;
|
||||
|
||||
public int minX;
|
||||
@ -458,8 +458,6 @@ public class DiskStorageHistory extends FaweStreamChangeSet {
|
||||
|
||||
public DiskStorageSummary(int x, int z) {
|
||||
blocks = new int[BlockTypes.states.length];
|
||||
this.x = x;
|
||||
this.z = z;
|
||||
minX = x;
|
||||
maxX = x;
|
||||
minZ = z;
|
||||
@ -485,7 +483,7 @@ public class DiskStorageHistory extends FaweStreamChangeSet {
|
||||
for (int i = 0; i < blocks.length; i++) {
|
||||
if (blocks[i] != 0) {
|
||||
BlockState state = BlockTypes.states[i];
|
||||
map.put(state, (Integer) blocks[i]);
|
||||
map.put(state, blocks[i]);
|
||||
}
|
||||
}
|
||||
return map;
|
||||
@ -498,18 +496,14 @@ public class DiskStorageHistory extends FaweStreamChangeSet {
|
||||
for (Map.Entry<BlockState, Integer> entry : map.entrySet()) {
|
||||
BlockState id = entry.getKey();
|
||||
int changes = entry.getValue();
|
||||
double percent = ((changes * 1000l) / count) / 10d;
|
||||
newMap.put(id, (Double) percent);
|
||||
double percent = (changes * 1000L / count) / 10d;
|
||||
newMap.put(id, percent);
|
||||
}
|
||||
return newMap;
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
int count = 0;
|
||||
for (int block : blocks) {
|
||||
count += block;
|
||||
}
|
||||
return count;
|
||||
return Arrays.stream(blocks).sum();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,8 +9,6 @@ import com.boydti.fawe.util.MainUtil;
|
||||
import com.sk89q.jnbt.NBTInputStream;
|
||||
import com.sk89q.jnbt.NBTOutputStream;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
@ -189,7 +187,7 @@ public class MemoryOptimizedHistory extends FaweStreamChangeSet {
|
||||
return entCStreamZip;
|
||||
}
|
||||
entCStream = new FastByteArrayOutputStream(Settings.IMP.HISTORY.BUFFER_SIZE);
|
||||
return entCStreamZip = new NBTOutputStream((DataOutput) getCompressedOS(entCStream));
|
||||
return entCStreamZip = new NBTOutputStream(getCompressedOS(entCStream));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -198,7 +196,7 @@ public class MemoryOptimizedHistory extends FaweStreamChangeSet {
|
||||
return entRStreamZip;
|
||||
}
|
||||
entRStream = new FastByteArrayOutputStream(Settings.IMP.HISTORY.BUFFER_SIZE);
|
||||
return entRStreamZip = new NBTOutputStream((DataOutput) getCompressedOS(entRStream));
|
||||
return entRStreamZip = new NBTOutputStream(getCompressedOS(entRStream));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -207,7 +205,7 @@ public class MemoryOptimizedHistory extends FaweStreamChangeSet {
|
||||
return tileCStreamZip;
|
||||
}
|
||||
tileCStream = new FastByteArrayOutputStream(Settings.IMP.HISTORY.BUFFER_SIZE);
|
||||
return tileCStreamZip = new NBTOutputStream((DataOutput) getCompressedOS(tileCStream));
|
||||
return tileCStreamZip = new NBTOutputStream(getCompressedOS(tileCStream));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -216,7 +214,7 @@ public class MemoryOptimizedHistory extends FaweStreamChangeSet {
|
||||
return tileRStreamZip;
|
||||
}
|
||||
tileRStream = new FastByteArrayOutputStream(Settings.IMP.HISTORY.BUFFER_SIZE);
|
||||
return tileRStreamZip = new NBTOutputStream((DataOutput) getCompressedOS(tileRStream));
|
||||
return tileRStreamZip = new NBTOutputStream(getCompressedOS(tileRStream));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -144,7 +144,7 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
||||
return null;
|
||||
}
|
||||
int biomeId = mbb.get(HEADER_SIZE + (volume << 2) + index) & 0xFF;
|
||||
return BiomeTypes.get(biomeId);
|
||||
return BiomeTypes.register(biomeId);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.boydti.fawe.object.clipboard;
|
||||
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.config.Settings;
|
||||
import com.boydti.fawe.jnbt.NBTStreamer;
|
||||
import com.boydti.fawe.object.IntegerTrio;
|
||||
@ -9,10 +8,8 @@ import com.boydti.fawe.util.ReflectionUtils;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.jnbt.IntTag;
|
||||
import com.sk89q.jnbt.Tag;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.world.biome.BiomeTypes;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
@ -122,7 +119,7 @@ public class MemoryOptimizedClipboard extends FaweClipboard {
|
||||
if (!hasBiomes()) {
|
||||
return null;
|
||||
}
|
||||
return BiomeTypes.get(biomes[index]);
|
||||
return BiomeTypes.register(biomes[index]);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -41,6 +41,7 @@ public class FastWorldEditExtent extends AbstractDelegateExtent implements HasFa
|
||||
this.queue = queue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FaweQueue getQueue() {
|
||||
return queue;
|
||||
}
|
||||
|
@ -48,6 +48,7 @@ public abstract class FaweRegionExtent extends ResettableExtent {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean contains(BlockVector3 p) {
|
||||
return contains(p.getBlockX(), p.getBlockY(), p.getBlockZ());
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package com.boydti.fawe.object.extent;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.boydti.fawe.util.ExtentTraverser;
|
||||
import com.boydti.fawe.util.ReflectionUtils;
|
||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||
@ -7,12 +9,10 @@ import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
public class ResettableExtent extends AbstractDelegateExtent implements Serializable {
|
||||
public ResettableExtent(Extent parent) {
|
||||
super(parent);
|
||||
@ -41,7 +41,7 @@ public class ResettableExtent extends AbstractDelegateExtent implements Serializ
|
||||
return this;
|
||||
}
|
||||
|
||||
private void writeObject(java.io.ObjectOutputStream stream) throws IOException {
|
||||
private void writeObject(ObjectOutputStream stream) throws IOException {
|
||||
stream.defaultWriteObject();
|
||||
Extent extent = getExtent();
|
||||
boolean next = extent instanceof ResettableExtent;
|
||||
@ -62,4 +62,4 @@ public class ResettableExtent extends AbstractDelegateExtent implements Serializ
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -34,13 +34,13 @@ public class SolidPlaneMask extends SolidBlockMask implements ResettableMask {
|
||||
originZ = vector.getBlockZ();
|
||||
mode = 0;
|
||||
Extent extent = getExtent();
|
||||
if (!extent.getBlockType(mutable.setComponents(originX - 1, originY, originZ)).getMaterial().isAir() && !extent.getBlockType(mutable.setComponents(originX + 1, originY, originZ)).getMaterial().isAir()) {
|
||||
if (!extent.getBlock(mutable.setComponents(originX - 1, originY, originZ)).getMaterial().isAir() && !extent.getBlock(mutable.setComponents(originX + 1, originY, originZ)).getMaterial().isAir()) {
|
||||
mode &= 1;
|
||||
}
|
||||
if (!extent.getBlockType(mutable.setComponents(originX, originY, originZ - 1)).getMaterial().isAir() && !extent.getBlockType(mutable.setComponents(originX, originY, originZ + 1)).getMaterial().isAir()) {
|
||||
if (!extent.getBlock(mutable.setComponents(originX, originY, originZ - 1)).getMaterial().isAir() && !extent.getBlock(mutable.setComponents(originX, originY, originZ + 1)).getMaterial().isAir()) {
|
||||
mode &= 4;
|
||||
}
|
||||
if (!extent.getBlockType(mutable.setComponents(originX, originY - 1, originZ + 1)).getMaterial().isAir() && !extent.getBlockType(mutable.setComponents(originX, originY + 1, originZ + 1)).getMaterial().isAir()) {
|
||||
if (!extent.getBlock(mutable.setComponents(originX, originY - 1, originZ + 1)).getMaterial().isAir() && !extent.getBlock(mutable.setComponents(originX, originY + 1, originZ + 1)).getMaterial().isAir()) {
|
||||
mode &= 2;
|
||||
}
|
||||
if (Integer.bitCount(mode) >= 3) {
|
||||
|
@ -4,16 +4,13 @@ import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.util.TextureHolder;
|
||||
import com.boydti.fawe.util.TextureUtil;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
|
||||
public class AverageColorPattern extends AbstractExtentPattern {
|
||||
private transient TextureHolder holder;
|
||||
@ -36,7 +33,7 @@ public class AverageColorPattern extends AbstractExtentPattern {
|
||||
|
||||
@Override
|
||||
public boolean apply(Extent extent, BlockVector3 setPosition, BlockVector3 getPosition) throws WorldEditException {
|
||||
BlockType blockType = extent.getBlockType(getPosition);
|
||||
BlockType blockType = extent.getBlock(getPosition).getBlockType();
|
||||
TextureUtil util = holder.getTextureUtil();
|
||||
int currentColor = util.getColor(blockType);
|
||||
if (currentColor == 0) return false;
|
||||
@ -46,8 +43,8 @@ public class AverageColorPattern extends AbstractExtentPattern {
|
||||
return extent.setBlock(setPosition, newBlock.getDefaultState());
|
||||
}
|
||||
|
||||
private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException {
|
||||
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
|
||||
stream.defaultReadObject();
|
||||
holder = Fawe.get().getCachedTextureUtil(true, 0, 100);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,15 +4,13 @@ import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.util.TextureHolder;
|
||||
import com.boydti.fawe.util.TextureUtil;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.function.pattern.AbstractPattern;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
|
||||
public class DesaturatePattern extends AbstractPattern {
|
||||
private transient TextureHolder holder;
|
||||
@ -27,7 +25,7 @@ public class DesaturatePattern extends AbstractPattern {
|
||||
|
||||
@Override
|
||||
public BaseBlock apply(BlockVector3 position) {
|
||||
BlockType block = extent.getBlockType(position);
|
||||
BlockType block = extent.getBlock(position).getBlockType();
|
||||
TextureUtil util = holder.getTextureUtil();
|
||||
int color = util.getColor(block);
|
||||
int r = (color >> 16) & 0xFF;
|
||||
@ -44,7 +42,7 @@ public class DesaturatePattern extends AbstractPattern {
|
||||
|
||||
@Override
|
||||
public boolean apply(Extent extent, BlockVector3 setPosition, BlockVector3 getPosition) throws WorldEditException {
|
||||
BlockType block = extent.getBlockType(getPosition);
|
||||
BlockType block = extent.getBlock(getPosition).getBlockType();
|
||||
TextureUtil util = holder.getTextureUtil();
|
||||
int color = util.getColor(block);
|
||||
int r = (color >> 16) & 0xFF;
|
||||
@ -66,8 +64,8 @@ public class DesaturatePattern extends AbstractPattern {
|
||||
return extent.setBlock(setPosition, newBlock.getDefaultState());
|
||||
}
|
||||
|
||||
private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException {
|
||||
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
|
||||
stream.defaultReadObject();
|
||||
holder = Fawe.get().getCachedTextureUtil(true, 0, 100);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,16 +4,14 @@ import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.util.TextureHolder;
|
||||
import com.boydti.fawe.util.TextureUtil;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.function.pattern.AbstractPattern;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
|
||||
public class SaturatePattern extends AbstractPattern {
|
||||
private transient TextureHolder holder;
|
||||
@ -29,7 +27,7 @@ public class SaturatePattern extends AbstractPattern {
|
||||
|
||||
@Override
|
||||
public BaseBlock apply(BlockVector3 position) {
|
||||
BlockType block = extent.getBlockType(position);
|
||||
BlockType block = extent.getBlock(position).getBlockType();
|
||||
TextureUtil util = holder.getTextureUtil();
|
||||
int currentColor = util.getColor(block);
|
||||
int newColor = util.multiplyColor(currentColor, color);
|
||||
@ -38,7 +36,7 @@ public class SaturatePattern extends AbstractPattern {
|
||||
|
||||
@Override
|
||||
public boolean apply(Extent extent, BlockVector3 setPosition, BlockVector3 getPosition) throws WorldEditException {
|
||||
BlockType block = extent.getBlockType(getPosition);
|
||||
BlockType block = extent.getBlock(getPosition).getBlockType();
|
||||
TextureUtil util = holder.getTextureUtil();
|
||||
int currentColor = util.getColor(block);
|
||||
if (currentColor == 0) return false;
|
||||
@ -48,8 +46,8 @@ public class SaturatePattern extends AbstractPattern {
|
||||
return extent.setBlock(setPosition, newBlock.getDefaultState());
|
||||
}
|
||||
|
||||
private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException {
|
||||
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
|
||||
stream.defaultReadObject();
|
||||
holder = Fawe.get().getCachedTextureUtil(true, 0, 100);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,20 +1,16 @@
|
||||
package com.boydti.fawe.object.pattern;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.util.TextureUtil;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.function.pattern.AbstractPattern;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
public class ShadePattern extends AbstractPattern {
|
||||
private transient TextureUtil util;
|
||||
private final Extent extent;
|
||||
@ -29,7 +25,7 @@ public class ShadePattern extends AbstractPattern {
|
||||
|
||||
@Override
|
||||
public BaseBlock apply(BlockVector3 position) {
|
||||
BlockType block = extent.getBlockType(position);
|
||||
BlockType block = extent.getBlock(position).getBlockType();
|
||||
return (darken ? util.getDarkerBlock(block) : util.getLighterBlock(block)).getDefaultState().toBaseBlock();
|
||||
}
|
||||
|
||||
@ -37,4 +33,4 @@ public class ShadePattern extends AbstractPattern {
|
||||
stream.defaultReadObject();
|
||||
util = Fawe.get().getCachedTextureUtil(true, 0, 100);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -38,6 +38,7 @@ import javax.annotation.Nullable;
|
||||
|
||||
public interface IDelegateFaweQueue extends FaweQueue {
|
||||
|
||||
@Override
|
||||
FaweQueue getQueue();
|
||||
|
||||
@Override
|
||||
|
@ -88,6 +88,7 @@ public class FuzzyRegion extends AbstractRegion {
|
||||
setMinMax(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(int x, int y, int z) {
|
||||
return set.contains(x, y, z);
|
||||
}
|
||||
|
@ -154,8 +154,4 @@ public class FuzzyRegionSelector extends AbstractDelegateExtent implements Regio
|
||||
return lines;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BlockVector3> getVerticies() {
|
||||
return positions;
|
||||
}
|
||||
}
|
||||
|
@ -229,8 +229,4 @@ public class PolyhedralRegionSelector implements RegionSelector, CUIRegion {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BlockVector3> getVerticies() {
|
||||
return new ArrayList<>(region.getVertices());
|
||||
}
|
||||
}
|
||||
|
@ -176,7 +176,7 @@ public class Schematic {
|
||||
if (transform != null) {
|
||||
copy.setTransform(transform);
|
||||
}
|
||||
copy.setCopyBiomes(!(clipboard instanceof BlockArrayClipboard) || ((BlockArrayClipboard) clipboard).IMP.hasBiomes());
|
||||
copy.setCopyingBiomes(!(clipboard instanceof BlockArrayClipboard) || ((BlockArrayClipboard) clipboard).IMP.hasBiomes());
|
||||
if (extent instanceof EditSession) {
|
||||
EditSession editSession = (EditSession) extent;
|
||||
Mask sourceMask = editSession.getSourceMask();
|
||||
|
@ -27,12 +27,12 @@ public class Fast2DIterator implements Iterable<BlockVector2> {
|
||||
}
|
||||
|
||||
public Fast2DIterator(@Nonnull Iterable<? extends BlockVector2> iter, @Nullable HasFaweQueue editSession) {
|
||||
this(iter, (FaweQueue) (editSession != null ? editSession.getQueue() : null));
|
||||
this(iter, editSession != null ? editSession.getQueue() : null);
|
||||
}
|
||||
|
||||
public Fast2DIterator(@Nonnull Iterable<? extends BlockVector2> iter, @Nullable FaweQueue faweQueue) {
|
||||
this.iterable = iter;
|
||||
this.queue = faweQueue != null && faweQueue instanceof MappedFaweQueue ? (MappedFaweQueue) faweQueue : null;
|
||||
this.queue = faweQueue instanceof MappedFaweQueue ? (MappedFaweQueue) faweQueue : null;
|
||||
}
|
||||
|
||||
public Iterable<? extends BlockVector2> getIterable() {
|
||||
|
@ -8,7 +8,6 @@ import com.boydti.fawe.util.EditSessionBuilder;
|
||||
import com.boydti.fawe.util.IOUtil;
|
||||
import com.boydti.fawe.util.SetQueue;
|
||||
import com.boydti.fawe.util.TaskManager;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.RegionWrapper;
|
||||
@ -27,7 +26,6 @@ import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.SpongeSchematicWriter;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.File;
|
||||
|
@ -20,7 +20,7 @@ import com.github.intellectualsites.plotsquared.plot.object.RunnableVal3;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.worlds.SinglePlotArea;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.SetupUtils;
|
||||
import com.sk89q.worldedit.event.platform.CommandEvent;
|
||||
import com.sk89q.worldedit.extension.platform.CommandManager;
|
||||
import com.sk89q.worldedit.extension.platform.PlatformCommandManager;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "replaceall",
|
||||
@ -57,7 +57,7 @@ public class ReplaceAll extends Command {
|
||||
FakePlayer actor = FakePlayer.getConsole();
|
||||
String cmd = "/replaceallpattern " + worldName + " " + StringMan.join(args, " ");
|
||||
CommandEvent event = new CommandEvent(actor, cmd);
|
||||
CommandManager.getInstance().handleCommandOnCurrentThread(event);
|
||||
PlatformCommandManager.getInstance().handleCommandOnCurrentThread(event);
|
||||
TaskManager.IMP.sync(new RunnableVal<Object>() {
|
||||
@Override
|
||||
public void run(Object value) {
|
||||
|
@ -25,7 +25,7 @@ public final class BrushCache {
|
||||
return item.hasNbtData() ? item.getNbtData() : null;
|
||||
}
|
||||
|
||||
private static final Object getKey(BaseItem item) {
|
||||
private static Object getKey(BaseItem item) {
|
||||
return item.getNativeItem();
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ package com.boydti.fawe.util;
|
||||
|
||||
import com.boydti.fawe.command.AnvilCommands;
|
||||
import com.boydti.fawe.command.CFICommands;
|
||||
import com.sk89q.minecraft.util.commands.Command;
|
||||
import org.enginehub.piston.annotation.Command;
|
||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||
import com.sk89q.minecraft.util.commands.NestedCommand;
|
||||
import com.sk89q.worldedit.command.BiomeCommands;
|
||||
|
@ -4,21 +4,27 @@ import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.FaweAPI;
|
||||
import com.boydti.fawe.config.Settings;
|
||||
import com.boydti.fawe.logging.rollback.RollbackOptimizedHistory;
|
||||
import com.boydti.fawe.object.*;
|
||||
import com.boydti.fawe.object.FaweLimit;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
import com.boydti.fawe.object.FaweQueue;
|
||||
import com.boydti.fawe.object.NullChangeSet;
|
||||
import com.boydti.fawe.object.RegionWrapper;
|
||||
import com.boydti.fawe.object.changeset.DiskStorageHistory;
|
||||
import com.boydti.fawe.object.changeset.FaweChangeSet;
|
||||
import com.boydti.fawe.object.changeset.MemoryOptimizedHistory;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.event.extent.EditSessionEvent;
|
||||
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.util.eventbus.EventBus;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import java.util.UUID;
|
||||
|
||||
public class EditSessionBuilder {
|
||||
private World world;
|
||||
@ -102,8 +108,8 @@ public class EditSessionBuilder {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param disk If it should be stored on disk
|
||||
* @param uuid The uuid to store it under (if on disk)
|
||||
* @param disk If it should be stored on disk
|
||||
* @param uuid The uuid to store it under (if on disk)
|
||||
* @param compression Compression level (0-9)
|
||||
* @return
|
||||
*/
|
||||
@ -180,17 +186,15 @@ public class EditSessionBuilder {
|
||||
return this;
|
||||
}
|
||||
|
||||
public EditSessionBuilder eventBus(@Nullable EventBus eventBus) {
|
||||
this.eventBus = eventBus;
|
||||
return this;
|
||||
}
|
||||
|
||||
public EditSessionBuilder event(@Nullable EditSessionEvent event) {
|
||||
this.event = event;
|
||||
return this;
|
||||
}
|
||||
|
||||
public EditSession build() {
|
||||
return new EditSession(worldName, world, queue, player, limit, changeSet, allowedRegions, autoQueue, fastmode, checkMemory, combineStages, blockBag, eventBus, event);
|
||||
if (eventBus == null) {
|
||||
eventBus = WorldEdit.getInstance().getEventBus();
|
||||
}
|
||||
return new EditSession(worldName, world, queue, player, limit, changeSet, allowedRegions, autoQueue, fastmode, checkMemory, combineStages, blockBag, eventBus, event);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package com.boydti.fawe.util;
|
||||
|
||||
import static java.lang.System.arraycopy;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import com.boydti.fawe.config.Settings;
|
||||
@ -12,7 +14,6 @@ import com.boydti.fawe.object.RunnableVal2;
|
||||
import com.boydti.fawe.object.changeset.CPUOptimizedChangeSet;
|
||||
import com.boydti.fawe.object.changeset.FaweStreamChangeSet;
|
||||
import com.boydti.fawe.object.io.AbstractDelegateOutputStream;
|
||||
|
||||
import com.github.luben.zstd.ZstdInputStream;
|
||||
import com.github.luben.zstd.ZstdOutputStream;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
@ -27,20 +28,19 @@ import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats;
|
||||
import com.sk89q.worldedit.history.changeset.ChangeSet;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import static java.lang.System.arraycopy;
|
||||
import net.jpountz.lz4.LZ4BlockInputStream;
|
||||
import net.jpountz.lz4.LZ4BlockOutputStream;
|
||||
import net.jpountz.lz4.LZ4Compressor;
|
||||
import net.jpountz.lz4.LZ4Factory;
|
||||
import net.jpountz.lz4.LZ4FastDecompressor;
|
||||
import net.jpountz.lz4.LZ4InputStream;
|
||||
import net.jpountz.lz4.LZ4Utils;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.*;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.*;
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.PrintWriter;
|
||||
import java.lang.reflect.Array;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.MalformedURLException;
|
||||
@ -77,6 +77,15 @@ import java.util.zip.GZIPInputStream;
|
||||
import java.util.zip.Inflater;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.imageio.ImageIO;
|
||||
import net.jpountz.lz4.LZ4BlockInputStream;
|
||||
import net.jpountz.lz4.LZ4BlockOutputStream;
|
||||
import net.jpountz.lz4.LZ4Compressor;
|
||||
import net.jpountz.lz4.LZ4Factory;
|
||||
import net.jpountz.lz4.LZ4FastDecompressor;
|
||||
import net.jpountz.lz4.LZ4InputStream;
|
||||
import net.jpountz.lz4.LZ4Utils;
|
||||
|
||||
public class MainUtil {
|
||||
/*
|
||||
@ -853,33 +862,4 @@ public class MainUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public static void warnDeprecated(Class... alternatives) {
|
||||
StackTraceElement[] stacktrace = new RuntimeException().getStackTrace();
|
||||
if (stacktrace.length > 1) {
|
||||
for (int i = 1; i < stacktrace.length; i++) {
|
||||
StackTraceElement stack = stacktrace[i];
|
||||
String s = stack.toString();
|
||||
if (s.startsWith("com.sk89q")) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
StackTraceElement creatorElement = stacktrace[1];
|
||||
String className = creatorElement.getClassName();
|
||||
Class clazz = Class.forName(className);
|
||||
String creator = clazz.getSimpleName();
|
||||
String packageName = clazz.getPackage().getName();
|
||||
|
||||
StackTraceElement deprecatedElement = stack;
|
||||
String myName = Class.forName(deprecatedElement.getClassName()).getSimpleName();
|
||||
Fawe.debug("@" + creator + " used by " + myName + "." + deprecatedElement.getMethodName() + "():" + deprecatedElement.getLineNumber() + " is deprecated.");
|
||||
Fawe.debug(" - Alternatives: " + StringMan.getString(alternatives));
|
||||
} catch (Throwable throwable) {
|
||||
throwable.printStackTrace();
|
||||
} finally {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -171,16 +171,7 @@ public class SetQueue {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (pool.getQueuedSubmissionCount() != 0 || pool.getRunningThreadCount() != 0 || pool.getQueuedTaskCount() != 0) {
|
||||
// if (Fawe.get().isJava8())
|
||||
{
|
||||
pool.awaitQuiescence(Long.MAX_VALUE, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
// else {
|
||||
// pool.shutdown();
|
||||
// pool.awaitTermination(Long.MAX_VALUE, TimeUnit.MILLISECONDS);
|
||||
// pool = new ForkJoinPool();
|
||||
// completer = new ExecutorCompletionService(pool);
|
||||
// }
|
||||
pool.awaitQuiescence(Long.MAX_VALUE, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
queue.endSet(parallel);
|
||||
} catch (Throwable e) {
|
||||
|
@ -3,8 +3,9 @@ package com.boydti.fawe.util.chat;
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class Message {
|
||||
@ -75,7 +76,7 @@ public class Message {
|
||||
}
|
||||
|
||||
public Message command(String command) {
|
||||
Fawe.get().getChatManager().command(this, (WorldEdit.getInstance().getConfiguration().noDoubleSlash ? "" : "/") + command);
|
||||
Fawe.get().getChatManager().command(this, ("/") + command);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@ import com.boydti.fawe.util.MainUtil;
|
||||
import com.boydti.fawe.util.StringMan;
|
||||
import com.sk89q.minecraft.util.commands.CommandLocals;
|
||||
import com.sk89q.minecraft.util.commands.Link;
|
||||
import com.sk89q.worldedit.extension.platform.CommandManager;
|
||||
import com.sk89q.worldedit.extension.platform.PlatformCommandManager;
|
||||
import com.sk89q.worldedit.util.command.CommandCallable;
|
||||
import com.sk89q.worldedit.util.command.CommandMapping;
|
||||
import com.sk89q.worldedit.util.command.Description;
|
||||
@ -57,7 +57,7 @@ public class UsageMessage extends Message {
|
||||
String prefix = !commandString.isEmpty() ? commandString + " " : "";
|
||||
|
||||
List<CommandMapping> list = new ArrayList<>(dispatcher.getCommands());
|
||||
list.sort(new PrimaryAliasComparator(CommandManager.COMMAND_CLEAN_PATTERN));
|
||||
list.sort(new PrimaryAliasComparator(PlatformCommandManager.COMMAND_CLEAN_PATTERN));
|
||||
|
||||
for (CommandMapping mapping : list) {
|
||||
boolean perm = locals == null || mapping.getCallable().testPermission(locals);
|
||||
|
@ -87,8 +87,9 @@ public class SchemSync implements Runnable {
|
||||
UtilityCommands.allFiles(dir.listFiles(), true, new Consumer<File>() {
|
||||
@Override
|
||||
public void accept(File file) {
|
||||
String path = dir.toURI().relativize(file.toURI()).getPath();
|
||||
try {
|
||||
String path = dir.toURI()
|
||||
.relativize(file.toURI()).getPath();
|
||||
out.writeUTF(path);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
|
@ -23,6 +23,7 @@ import com.sk89q.worldedit.util.Direction;
|
||||
import com.sk89q.worldedit.util.HandSide;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.util.TargetBlock;
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
@ -120,6 +121,10 @@ public class PlayerWrapper extends AbstractPlayerActor {
|
||||
parent.printError(msg);
|
||||
}
|
||||
|
||||
@Override public void print(Component component) {
|
||||
parent.print(component);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getGroups() {
|
||||
return parent.getGroups();
|
||||
|
@ -181,6 +181,18 @@ public class CompoundTagBuilder {
|
||||
return put(key, new StringTag(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the given key from the compound tag. Does nothing if the key doesn't exist.
|
||||
*
|
||||
* @param key the key
|
||||
* @return this object
|
||||
*/
|
||||
public CompoundTagBuilder remove(String key) {
|
||||
checkNotNull(key);
|
||||
entries.remove(key);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Put all the entries from the given map into this map.
|
||||
*
|
||||
|
@ -1,10 +1,9 @@
|
||||
package com.sk89q.jnbt;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import net.jpountz.lz4.LZ4BlockInputStream;
|
||||
|
||||
public abstract class CompressedCompoundTag<T> extends CompoundTag {
|
||||
private T in;
|
||||
@ -20,7 +19,7 @@ public abstract class CompressedCompoundTag<T> extends CompoundTag {
|
||||
return super.getValue();
|
||||
}
|
||||
|
||||
public abstract DataInputStream adapt(T src) throws IOException;
|
||||
public abstract LZ4BlockInputStream adapt(T src) throws IOException;
|
||||
|
||||
public T getSource() {
|
||||
return in;
|
||||
|
@ -2,15 +2,12 @@ package com.sk89q.jnbt;
|
||||
|
||||
import com.boydti.fawe.object.io.FastByteArrayOutputStream;
|
||||
import com.boydti.fawe.object.io.FastByteArraysInputStream;
|
||||
import com.boydti.fawe.object.io.PGZIPOutputStream;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.SpongeSchematicWriter;
|
||||
import net.jpountz.lz4.LZ4BlockInputStream;
|
||||
import net.jpountz.lz4.LZ4BlockOutputStream;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
|
||||
public class CompressedSchematicTag extends CompressedCompoundTag<Clipboard> {
|
||||
public CompressedSchematicTag(Clipboard holder) {
|
||||
@ -18,7 +15,7 @@ public class CompressedSchematicTag extends CompressedCompoundTag<Clipboard> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataInputStream adapt(Clipboard src) throws IOException {
|
||||
public LZ4BlockInputStream adapt(Clipboard src) throws IOException {
|
||||
FastByteArrayOutputStream blocksOut = new FastByteArrayOutputStream();
|
||||
try (LZ4BlockOutputStream lz4out = new LZ4BlockOutputStream(blocksOut)) {
|
||||
NBTOutputStream nbtOut = new NBTOutputStream(lz4out);
|
||||
@ -27,6 +24,6 @@ public class CompressedSchematicTag extends CompressedCompoundTag<Clipboard> {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
FastByteArraysInputStream in = new FastByteArraysInputStream(blocksOut.toByteArrays());
|
||||
return new DataInputStream(new LZ4BlockInputStream(in));
|
||||
return new LZ4BlockInputStream(in);
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,8 @@ package com.sk89q.jnbt;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* The {@code TAG_Int_Array} tag.
|
||||
*/
|
||||
@ -48,7 +50,7 @@ public final class IntArrayTag extends Tag {
|
||||
public String toString() {
|
||||
StringBuilder hex = new StringBuilder();
|
||||
for (int b : value) {
|
||||
String hexDigits = Integer.toHexString(b).toUpperCase();
|
||||
String hexDigits = Integer.toHexString(b).toUpperCase(Locale.ROOT);
|
||||
if (hexDigits.length() == 1) {
|
||||
hex.append("0");
|
||||
}
|
||||
|
@ -21,6 +21,8 @@ package com.sk89q.jnbt;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* The {@code TAG_Long_Array} tag.
|
||||
*/
|
||||
@ -48,7 +50,7 @@ public class LongArrayTag extends Tag {
|
||||
public String toString() {
|
||||
StringBuilder hex = new StringBuilder();
|
||||
for (long b : value) {
|
||||
String hexDigits = Long.toHexString(b).toUpperCase();
|
||||
String hexDigits = Long.toHexString(b).toUpperCase(Locale.ROOT);
|
||||
if (hexDigits.length() == 1) {
|
||||
hex.append("0");
|
||||
}
|
||||
|
@ -152,39 +152,21 @@ public final class NBTInputStream implements Closeable {
|
||||
if (reader instanceof NBTStreamer.ByteReader) {
|
||||
NBTStreamer.ByteReader byteReader = (NBTStreamer.ByteReader) reader;
|
||||
int i = 0;
|
||||
if (is instanceof InputStream) {
|
||||
DataInputStream dis = is;
|
||||
if (length > 1024) {
|
||||
if (buf == null) {
|
||||
buf = new byte[1024];
|
||||
}
|
||||
int left = length;
|
||||
for (; left > 1024; left -= 1024) {
|
||||
dis.readFully(buf);
|
||||
for (byte b : buf) {
|
||||
byteReader.run(i++, b & 0xFF);
|
||||
}
|
||||
DataInputStream dis = is;
|
||||
if (length > 1024) {
|
||||
if (buf == null) {
|
||||
buf = new byte[1024];
|
||||
}
|
||||
int left = length;
|
||||
for (; left > 1024; left -= 1024) {
|
||||
dis.readFully(buf);
|
||||
for (byte b : buf) {
|
||||
byteReader.run(i++, b & 0xFF);
|
||||
}
|
||||
}
|
||||
for (; i < length; i++) {
|
||||
byteReader.run(i, dis.read());
|
||||
}
|
||||
} else {
|
||||
if (length > 1024) {
|
||||
if (buf == null) {
|
||||
buf = new byte[1024];
|
||||
}
|
||||
int left = length;
|
||||
for (; left > 1024; left -= 1024) {
|
||||
is.readFully(buf);
|
||||
for (byte b : buf) {
|
||||
byteReader.run(i++, b & 0xFF);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (; i < length; i++) {
|
||||
byteReader.run(i, is.readByte() & 0xFF);
|
||||
}
|
||||
}
|
||||
for (; i < length; i++) {
|
||||
byteReader.run(i, dis.read());
|
||||
}
|
||||
} else if (reader instanceof NBTStreamer.LazyReader) {
|
||||
reader.accept(length, is);
|
||||
@ -410,88 +392,6 @@ public final class NBTInputStream implements Closeable {
|
||||
}
|
||||
}
|
||||
|
||||
public Object readDataPayload(int type, int depth) throws IOException {
|
||||
switch (type) {
|
||||
case NBTConstants.TYPE_END:
|
||||
if (depth == 0) {
|
||||
throw new IOException(
|
||||
"TAG_End found without a TAG_Compound/TAG_List tag preceding it.");
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
case NBTConstants.TYPE_BYTE:
|
||||
return is.readByte();
|
||||
case NBTConstants.TYPE_SHORT:
|
||||
return is.readShort();
|
||||
case NBTConstants.TYPE_INT:
|
||||
return is.readInt();
|
||||
case NBTConstants.TYPE_LONG:
|
||||
return is.readLong();
|
||||
case NBTConstants.TYPE_FLOAT:
|
||||
return is.readFloat();
|
||||
case NBTConstants.TYPE_DOUBLE:
|
||||
return is.readDouble();
|
||||
case NBTConstants.TYPE_BYTE_ARRAY:
|
||||
int length = is.readInt();
|
||||
byte[] bytes = new byte[length];
|
||||
is.readFully(bytes);
|
||||
return bytes;
|
||||
case NBTConstants.TYPE_STRING:
|
||||
length = is.readShort();
|
||||
bytes = new byte[length];
|
||||
is.readFully(bytes);
|
||||
return new String(bytes, NBTConstants.CHARSET);
|
||||
case NBTConstants.TYPE_LIST:
|
||||
int childType = is.readByte();
|
||||
if (childType == NBTConstants.TYPE_LIST) {
|
||||
childType = NBTConstants.TYPE_COMPOUND;
|
||||
}
|
||||
length = is.readInt();
|
||||
ArrayList<Object> list = new ArrayList<>();
|
||||
for (int i = 0; i < length; ++i) {
|
||||
Object obj = readDataPayload(childType, depth + 1);
|
||||
if (obj == null) {
|
||||
throw new IOException("TAG_End not permitted in a list.");
|
||||
}
|
||||
list.add(obj);
|
||||
}
|
||||
|
||||
return list;
|
||||
case NBTConstants.TYPE_COMPOUND:
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
while (true) {
|
||||
int newType = is.readByte();
|
||||
String name = readNamedTagName(newType);
|
||||
Object data = readDataPayload(newType, depth + 1);
|
||||
if (data == null) {
|
||||
break;
|
||||
} else {
|
||||
map.put(name, data);
|
||||
}
|
||||
}
|
||||
|
||||
return map;
|
||||
case NBTConstants.TYPE_INT_ARRAY: {
|
||||
length = is.readInt();
|
||||
int[] data = new int[length];
|
||||
for (int i = 0; i < length; i++) {
|
||||
data[i] = is.readInt();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
case NBTConstants.TYPE_LONG_ARRAY: {
|
||||
length = is.readInt();
|
||||
long[] data = new long[length];
|
||||
for (int i = 0; i < length; i++) {
|
||||
data[i] = is.readLong();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
default:
|
||||
throw new IOException("Invalid tag type: " + type + ".");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the payload of a tag given the type.
|
||||
*
|
||||
@ -560,22 +460,20 @@ public final class NBTInputStream implements Closeable {
|
||||
}
|
||||
|
||||
return new CompoundTag(tagMap);
|
||||
case NBTConstants.TYPE_INT_ARRAY: {
|
||||
case NBTConstants.TYPE_INT_ARRAY:
|
||||
length = is.readInt();
|
||||
int[] data = new int[length];
|
||||
for (int i = 0; i < length; i++) {
|
||||
data[i] = is.readInt();
|
||||
}
|
||||
return new IntArrayTag(data);
|
||||
}
|
||||
case NBTConstants.TYPE_LONG_ARRAY: {
|
||||
case NBTConstants.TYPE_LONG_ARRAY:
|
||||
length = is.readInt();
|
||||
long[] longData = new long[length];
|
||||
for (int i = 0; i < length; i++) {
|
||||
longData[i] = is.readLong();
|
||||
}
|
||||
return new LongArrayTag(longData);
|
||||
}
|
||||
default:
|
||||
throw new IOException("Invalid tag type: " + type + ".");
|
||||
}
|
||||
@ -583,13 +481,7 @@ public final class NBTInputStream implements Closeable {
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
if (is instanceof AutoCloseable) {
|
||||
try {
|
||||
((AutoCloseable) is).close();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
is.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -19,8 +19,6 @@
|
||||
|
||||
package com.sk89q.jnbt;
|
||||
|
||||
import com.boydti.fawe.object.io.LittleEndianOutputStream;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.io.Closeable;
|
||||
@ -45,7 +43,7 @@ public final class NBTOutputStream extends OutputStream implements Closeable, Da
|
||||
/**
|
||||
* The output stream.
|
||||
*/
|
||||
private DataOutput os;
|
||||
private final DataOutputStream os;
|
||||
|
||||
/**
|
||||
* Creates a new {@code NBTOutputStream}, which will write data to the
|
||||
@ -60,23 +58,10 @@ public final class NBTOutputStream extends OutputStream implements Closeable, Da
|
||||
this.os = new DataOutputStream(os);
|
||||
}
|
||||
|
||||
public NBTOutputStream(DataOutput os) throws IOException {
|
||||
this.os = os;
|
||||
}
|
||||
|
||||
public DataOutput getOutputStream() {
|
||||
return os;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use a little endian output stream
|
||||
*/
|
||||
public void setLittleEndian() {
|
||||
if (!(os instanceof LittleEndianOutputStream)) {
|
||||
this.os = new LittleEndianOutputStream((OutputStream) os);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a tag.
|
||||
*
|
||||
@ -159,7 +144,7 @@ public final class NBTOutputStream extends OutputStream implements Closeable, Da
|
||||
writeNamedEmptyList(name, NBTConstants.TYPE_COMPOUND);
|
||||
}
|
||||
|
||||
public void writeNamedEmptyList(String name, int type) throws IOException {
|
||||
private void writeNamedEmptyList(String name, int type) throws IOException {
|
||||
writeNamedTagName(name, NBTConstants.TYPE_LIST);
|
||||
os.writeByte(type);
|
||||
os.writeInt(0);
|
||||
@ -420,7 +405,7 @@ public final class NBTOutputStream extends OutputStream implements Closeable, Da
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
if (os instanceof Closeable) ((Closeable) os).close();
|
||||
os.close();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -500,6 +485,6 @@ public final class NBTOutputStream extends OutputStream implements Closeable, Da
|
||||
*/
|
||||
@Override
|
||||
public void flush() throws IOException {
|
||||
if (os instanceof Flushable) ((Flushable) os).flush();
|
||||
((Flushable) os).flush();
|
||||
}
|
||||
}
|
||||
|
@ -30,6 +30,7 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@ -60,6 +61,7 @@ import java.util.Set;
|
||||
* @param <T> command sender class
|
||||
*/
|
||||
@SuppressWarnings("ProtectedField")
|
||||
@Deprecated
|
||||
public abstract class CommandsManager<T> {
|
||||
|
||||
protected static final Logger logger =
|
||||
@ -253,7 +255,7 @@ public abstract class CommandsManager<T> {
|
||||
* @return true if the command exists
|
||||
*/
|
||||
public boolean hasCommand(String command) {
|
||||
return commands.get(null).containsKey(command.toLowerCase());
|
||||
return commands.get(null).containsKey(command.toLowerCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -433,7 +435,7 @@ public abstract class CommandsManager<T> {
|
||||
String cmdName = args[level];
|
||||
|
||||
Map<String, Method> map = commands.get(parent);
|
||||
Method method = map.get(cmdName.toLowerCase());
|
||||
Method method = map.get(cmdName.toLowerCase(Locale.ROOT));
|
||||
|
||||
if (method == null) {
|
||||
if (parent == null) { // Root
|
||||
|
@ -0,0 +1,24 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* This package contains the old command system. It is no longer in use. Please switch
|
||||
* to Piston, Intake, ACF, or similar systems.
|
||||
*/
|
||||
package com.sk89q.minecraft.util.commands;
|
@ -310,7 +310,7 @@ public final class StringUtil {
|
||||
}
|
||||
|
||||
public static List<String> parseListInQuotes(String[] input, char delimiter, char quoteOpen, char quoteClose, boolean appendLeftover) {
|
||||
List<String> parsableBlocks = new ArrayList<>();
|
||||
List<String> parsableBlocks = new ArrayList<>();
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
for (String split : input) {
|
||||
if (split.indexOf(quoteOpen) != -1 && split.indexOf(quoteClose) == -1) {
|
||||
|
@ -19,6 +19,12 @@
|
||||
|
||||
package com.sk89q.worldedit;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.sk89q.worldedit.regions.Regions.asFlatRegion;
|
||||
import static com.sk89q.worldedit.regions.Regions.maximumBlockY;
|
||||
import static com.sk89q.worldedit.regions.Regions.minimumBlockY;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.FaweAPI;
|
||||
import com.boydti.fawe.config.BBC;
|
||||
@ -26,7 +32,6 @@ import com.boydti.fawe.config.Settings;
|
||||
import com.boydti.fawe.example.MappedFaweQueue;
|
||||
import com.boydti.fawe.jnbt.anvil.MCAQueue;
|
||||
import com.boydti.fawe.jnbt.anvil.MCAWorld;
|
||||
import com.boydti.fawe.logging.LoggingChangeSet;
|
||||
import com.boydti.fawe.logging.rollback.RollbackOptimizedHistory;
|
||||
import com.boydti.fawe.object.FaweLimit;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
@ -44,7 +49,17 @@ import com.boydti.fawe.object.changeset.FaweChangeSet;
|
||||
import com.boydti.fawe.object.changeset.MemoryOptimizedHistory;
|
||||
import com.boydti.fawe.object.collection.LocalBlockVectorSet;
|
||||
import com.boydti.fawe.object.exception.FaweException;
|
||||
import com.boydti.fawe.object.extent.*;
|
||||
import com.boydti.fawe.object.extent.FastWorldEditExtent;
|
||||
import com.boydti.fawe.object.extent.FaweRegionExtent;
|
||||
import com.boydti.fawe.object.extent.HeightBoundExtent;
|
||||
import com.boydti.fawe.object.extent.MultiRegionExtent;
|
||||
import com.boydti.fawe.object.extent.NullExtent;
|
||||
import com.boydti.fawe.object.extent.ProcessedWEExtent;
|
||||
import com.boydti.fawe.object.extent.ResettableExtent;
|
||||
import com.boydti.fawe.object.extent.SingleRegionExtent;
|
||||
import com.boydti.fawe.object.extent.SlowExtent;
|
||||
import com.boydti.fawe.object.extent.SourceMaskExtent;
|
||||
import com.boydti.fawe.object.extent.StripNBTExtent;
|
||||
import com.boydti.fawe.object.function.SurfaceRegionFunction;
|
||||
import com.boydti.fawe.object.mask.ResettableMask;
|
||||
import com.boydti.fawe.object.pattern.ExistingPattern;
|
||||
@ -58,9 +73,6 @@ import com.boydti.fawe.util.Perm;
|
||||
import com.boydti.fawe.util.SetQueue;
|
||||
import com.boydti.fawe.util.TaskManager;
|
||||
import com.boydti.fawe.wrappers.WorldWrapper;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import com.google.common.base.Supplier;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||
@ -81,7 +93,16 @@ import com.sk89q.worldedit.function.block.BlockReplace;
|
||||
import com.sk89q.worldedit.function.block.Naturalizer;
|
||||
import com.sk89q.worldedit.function.generator.ForestGenerator;
|
||||
import com.sk89q.worldedit.function.generator.GardenPatchGenerator;
|
||||
import com.sk89q.worldedit.function.mask.*;
|
||||
import com.sk89q.worldedit.function.mask.BlockMaskBuilder;
|
||||
import com.sk89q.worldedit.function.mask.BlockTypeMask;
|
||||
import com.sk89q.worldedit.function.mask.BoundedHeightMask;
|
||||
import com.sk89q.worldedit.function.mask.ExistingBlockMask;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.mask.MaskIntersection;
|
||||
import com.sk89q.worldedit.function.mask.MaskUnion;
|
||||
import com.sk89q.worldedit.function.mask.Masks;
|
||||
import com.sk89q.worldedit.function.mask.NoiseFilter2D;
|
||||
import com.sk89q.worldedit.function.mask.RegionMask;
|
||||
import com.sk89q.worldedit.function.operation.ChangeSetExecutor;
|
||||
import com.sk89q.worldedit.function.operation.ForwardExtentCopy;
|
||||
import com.sk89q.worldedit.function.operation.Operation;
|
||||
@ -122,15 +143,13 @@ import com.sk89q.worldedit.regions.EllipsoidRegion;
|
||||
import com.sk89q.worldedit.regions.FlatRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.regions.Regions;
|
||||
import static com.sk89q.worldedit.regions.Regions.asFlatRegion;
|
||||
import static com.sk89q.worldedit.regions.Regions.maximumBlockY;
|
||||
import static com.sk89q.worldedit.regions.Regions.minimumBlockY;
|
||||
import com.sk89q.worldedit.regions.shape.ArbitraryBiomeShape;
|
||||
import com.sk89q.worldedit.regions.shape.ArbitraryShape;
|
||||
import com.sk89q.worldedit.regions.shape.RegionShape;
|
||||
import com.sk89q.worldedit.regions.shape.WorldEditExpressionEnvironment;
|
||||
import com.sk89q.worldedit.util.Countable;
|
||||
import com.sk89q.worldedit.util.Direction;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.util.TreeGenerator;
|
||||
import com.sk89q.worldedit.util.eventbus.EventBus;
|
||||
import com.sk89q.worldedit.world.SimpleWorld;
|
||||
@ -144,11 +163,7 @@ import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import com.sk89q.worldedit.world.weather.WeatherType;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@ -156,6 +171,11 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* An {@link Extent} that handles history, {@link BlockBag}s, change limits,
|
||||
@ -229,20 +249,17 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
public static final UUID CONSOLE = UUID.fromString("1-1-3-3-7");
|
||||
|
||||
@Deprecated
|
||||
public EditSession(@Nonnull World world, @Nullable FaweQueue queue, @Nullable FawePlayer player, @Nullable FaweLimit limit, @Nullable FaweChangeSet changeSet, @Nullable RegionWrapper[] allowedRegions, @Nullable Boolean autoQueue, @Nullable Boolean fastmode, @Nullable Boolean checkMemory, @Nullable Boolean combineStages, @Nullable BlockBag blockBag, @Nullable EventBus bus, @Nullable EditSessionEvent event) {
|
||||
public EditSession(@Nonnull World world, @Nullable FaweQueue queue, @Nullable FawePlayer player, @Nullable FaweLimit limit, @Nullable FaweChangeSet changeSet, @Nullable RegionWrapper[] allowedRegions, @Nullable Boolean autoQueue, @Nullable Boolean fastmode, @Nullable Boolean checkMemory, @Nullable Boolean combineStages, @Nullable BlockBag blockBag, @NotNull EventBus bus, @Nullable EditSessionEvent event) {
|
||||
this(null, world, queue, player, limit, changeSet, allowedRegions, autoQueue, fastmode, checkMemory, combineStages, blockBag, bus, event);
|
||||
}
|
||||
|
||||
public EditSession(@Nullable String worldName, @Nullable World world, @Nullable FaweQueue queue, @Nullable FawePlayer player, @Nullable FaweLimit limit, @Nullable FaweChangeSet changeSet, @Nullable Region[] allowedRegions, @Nullable Boolean autoQueue, @Nullable Boolean fastmode, @Nullable Boolean checkMemory, @Nullable Boolean combineStages, @Nullable BlockBag blockBag, @Nullable EventBus bus, @Nullable EditSessionEvent event) {
|
||||
public EditSession(@Nullable String worldName, @Nullable World world, @Nullable FaweQueue queue, @Nullable FawePlayer player, @Nullable FaweLimit limit, @Nullable FaweChangeSet changeSet, @Nullable Region[] allowedRegions, @Nullable Boolean autoQueue, @Nullable Boolean fastmode, @Nullable Boolean checkMemory, @Nullable Boolean combineStages, @Nullable BlockBag blockBag, @NotNull EventBus bus, @Nullable EditSessionEvent event) {
|
||||
super(world);
|
||||
this.worldName = worldName == null ? world == null ? queue == null ? "" : queue.getWorldName() : world.getName() : worldName;
|
||||
if (world == null && this.worldName != null) world = FaweAPI.getWorld(this.worldName);
|
||||
|
||||
this.world = world;
|
||||
|
||||
if (bus == null) {
|
||||
bus = WorldEdit.getInstance().getEventBus();
|
||||
}
|
||||
if (event == null) {
|
||||
event = new EditSessionEvent(world, player == null ? null : (player.getPlayer()), -1, null);
|
||||
}
|
||||
@ -344,13 +361,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
if (this.limit.SPEED_REDUCTION > 0) {
|
||||
this.bypassHistory = new SlowExtent(this.bypassHistory, this.limit.SPEED_REDUCTION);
|
||||
}
|
||||
if (changeSet instanceof NullChangeSet && Fawe.imp().getBlocksHubApi() != null && player != null) {
|
||||
changeSet = LoggingChangeSet.wrap(player, changeSet);
|
||||
}
|
||||
if (!(changeSet instanceof NullChangeSet)) {
|
||||
if (!(changeSet instanceof LoggingChangeSet) && player != null && Fawe.imp().getBlocksHubApi() != null) {
|
||||
changeSet = LoggingChangeSet.wrap(player, changeSet);
|
||||
}
|
||||
if (this.blockBag != null) {
|
||||
changeSet = new BlockBagChangeSet(changeSet, blockBag, limit.INVENTORY_MODE == 1);
|
||||
}
|
||||
@ -416,7 +427,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
|
||||
public void resetLimit() {
|
||||
this.limit.set(this.originalLimit);
|
||||
ExtentTraverser<ProcessedWEExtent> find = new ExtentTraverser(extent).find(ProcessedWEExtent.class);
|
||||
ExtentTraverser<ProcessedWEExtent> find = new ExtentTraverser<>(extent).find(ProcessedWEExtent.class);
|
||||
if (find != null && find.get() != null) {
|
||||
find.get().setLimit(this.limit);
|
||||
}
|
||||
@ -455,7 +466,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
* @return FaweRegionExtent (may be null)
|
||||
*/
|
||||
public FaweRegionExtent getRegionExtent() {
|
||||
ExtentTraverser<FaweRegionExtent> traverser = new ExtentTraverser(this.extent).find(FaweRegionExtent.class);
|
||||
ExtentTraverser<FaweRegionExtent> traverser = new ExtentTraverser<>(this.extent).find(FaweRegionExtent.class);
|
||||
return traverser == null ? null : traverser.get();
|
||||
}
|
||||
|
||||
@ -467,6 +478,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
return bypassHistory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Extent getExtent() {
|
||||
return extent;
|
||||
}
|
||||
@ -532,27 +544,17 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a debug message to the Actor responsible for this EditSession (or Console)
|
||||
*
|
||||
* @param message
|
||||
* @param args
|
||||
*/
|
||||
public void debug(BBC message, Object... args) {
|
||||
message.send(player, args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the FaweQueue this EditSession uses to queue the changes<br>
|
||||
* - Note: All implementation queues for FAWE are instances of NMSMappedFaweQueue
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public FaweQueue getQueue() {
|
||||
return queue;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
private AbstractDelegateExtent wrapExtent(Extent extent, EventBus eventBus, EditSessionEvent event, Stage stage) {
|
||||
event = event.clone(stage);
|
||||
event.setExtent(extent);
|
||||
@ -739,7 +741,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
* @return mask, may be null
|
||||
*/
|
||||
public Mask getMask() {
|
||||
ExtentTraverser<MaskingExtent> maskingExtent = new ExtentTraverser(this.extent).find(MaskingExtent.class);
|
||||
ExtentTraverser<MaskingExtent> maskingExtent = new ExtentTraverser<>(this.extent).find(MaskingExtent.class);
|
||||
return maskingExtent != null ? maskingExtent.get().getMask() : null;
|
||||
}
|
||||
|
||||
@ -749,18 +751,18 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
* @return mask, may be null
|
||||
*/
|
||||
public Mask getSourceMask() {
|
||||
ExtentTraverser<SourceMaskExtent> maskingExtent = new ExtentTraverser(this.extent).find(SourceMaskExtent.class);
|
||||
ExtentTraverser<SourceMaskExtent> maskingExtent = new ExtentTraverser<>(this.extent).find(SourceMaskExtent.class);
|
||||
return maskingExtent != null ? maskingExtent.get().getMask() : null;
|
||||
}
|
||||
|
||||
public void addTransform(ResettableExtent transform) {
|
||||
wrapped = true;
|
||||
if (transform == null) {
|
||||
ExtentTraverser<AbstractDelegateExtent> traverser = new ExtentTraverser(this.extent).find(ResettableExtent.class);
|
||||
ExtentTraverser traverser = new ExtentTraverser(this.extent).find(ResettableExtent.class);
|
||||
AbstractDelegateExtent next = extent;
|
||||
while (traverser != null && traverser.get() instanceof ResettableExtent) {
|
||||
traverser = traverser.next();
|
||||
next = traverser.get();
|
||||
next = (AbstractDelegateExtent) traverser.get();
|
||||
}
|
||||
this.extent = next;
|
||||
return;
|
||||
@ -770,7 +772,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
}
|
||||
|
||||
public @Nullable ResettableExtent getTransform() {
|
||||
ExtentTraverser<AbstractDelegateExtent> traverser = new ExtentTraverser(this.extent).find(ResettableExtent.class);
|
||||
ExtentTraverser traverser = new ExtentTraverser(this.extent).find(ResettableExtent.class);
|
||||
if (traverser != null) {
|
||||
return (ResettableExtent) traverser.get();
|
||||
}
|
||||
@ -788,7 +790,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
} else {
|
||||
new MaskTraverser(mask).reset(this);
|
||||
}
|
||||
ExtentTraverser<SourceMaskExtent> maskingExtent = new ExtentTraverser(this.extent).find(SourceMaskExtent.class);
|
||||
ExtentTraverser<SourceMaskExtent> maskingExtent = new ExtentTraverser<>(this.extent).find(SourceMaskExtent.class);
|
||||
if (maskingExtent != null && maskingExtent.get() != null) {
|
||||
Mask oldMask = maskingExtent.get().getMask();
|
||||
if (oldMask instanceof ResettableMask) {
|
||||
@ -845,7 +847,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
* @return the survival simulation extent
|
||||
*/
|
||||
public SurvivalModeExtent getSurvivalExtent() {
|
||||
ExtentTraverser<SurvivalModeExtent> survivalExtent = new ExtentTraverser(this.extent).find(SurvivalModeExtent.class);
|
||||
ExtentTraverser<SurvivalModeExtent> survivalExtent = new ExtentTraverser<>(this.extent).find(SurvivalModeExtent.class);
|
||||
if (survivalExtent != null) {
|
||||
return survivalExtent.get();
|
||||
} else {
|
||||
@ -878,7 +880,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
if (history == null) {
|
||||
return;
|
||||
}
|
||||
ExtentTraverser traverseHistory = new ExtentTraverser(this.extent).find(HistoryExtent.class);
|
||||
ExtentTraverser<HistoryExtent> traverseHistory = new ExtentTraverser<>(this.extent).find(HistoryExtent.class);
|
||||
if (disableHistory) {
|
||||
if (traverseHistory != null && traverseHistory.exists()) {
|
||||
ExtentTraverser beforeHistory = traverseHistory.previous();
|
||||
@ -890,7 +892,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
}
|
||||
}
|
||||
} else if (traverseHistory == null || !traverseHistory.exists()) {
|
||||
ExtentTraverser traverseBypass = new ExtentTraverser(this.extent).find(bypassHistory);
|
||||
ExtentTraverser traverseBypass = new ExtentTraverser<>(this.extent).find(bypassHistory);
|
||||
if (traverseBypass != null) {
|
||||
ExtentTraverser beforeHistory = traverseBypass.previous();
|
||||
beforeHistory.setNext(history);
|
||||
@ -939,19 +941,19 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
*
|
||||
* @return a map of missing blocks
|
||||
*/
|
||||
public Map<com.sk89q.worldedit.world.block.BlockType, Integer> popMissingBlocks() {
|
||||
public Map<BlockType, Integer> popMissingBlocks() {
|
||||
BlockBag bag = getBlockBag();
|
||||
if (bag != null) {
|
||||
bag.flushChanges();
|
||||
|
||||
Map<com.sk89q.worldedit.world.block.BlockType, Integer> missingBlocks;
|
||||
Map<BlockType, Integer> missingBlocks;
|
||||
ChangeSet changeSet = getChangeSet();
|
||||
|
||||
|
||||
if (changeSet instanceof BlockBagChangeSet) {
|
||||
missingBlocks = ((BlockBagChangeSet) changeSet).popMissing();
|
||||
} else {
|
||||
ExtentTraverser<BlockBagExtent> find = new ExtentTraverser(extent).find(BlockBagExtent.class);
|
||||
ExtentTraverser<BlockBagExtent> find = new ExtentTraverser<>(extent).find(BlockBagExtent.class);
|
||||
if (find != null && find.get() != null) {
|
||||
missingBlocks = find.get().popMissing();
|
||||
} else {
|
||||
@ -1065,6 +1067,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
return getLazyBlock(position.getBlockX(), position.getBlockY(), position.getBlockZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getLazyBlock(int x, int y, int z) {
|
||||
return extent.getLazyBlock(x, y, z);
|
||||
}
|
||||
@ -1083,18 +1086,6 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
return extent.getFullBlock(position);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a block type at the given position.
|
||||
*
|
||||
* @param position the position
|
||||
* @return the block type
|
||||
* @deprecated Use {@link #getLazyBlock(BlockVector3)} or {@link #getBlock(BlockVector3)}
|
||||
*/
|
||||
@Deprecated
|
||||
public BlockType getBlockType(final BlockVector3 position) {
|
||||
return getBlockType(position.getBlockX(), position.getBlockY(), position.getBlockZ());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the highest solid 'terrain' block.
|
||||
*
|
||||
@ -1104,6 +1095,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
* @param maxY maximal height
|
||||
* @return height of highest block found or 'minY'
|
||||
*/
|
||||
@Override
|
||||
public int getHighestTerrainBlock(int x, int z, int minY, int maxY) {
|
||||
for (int y = maxY; y >= minY; --y) {
|
||||
if (getBlock(x, y, z).getBlockType().getMaterial().isMovementBlocker()) {
|
||||
@ -1123,6 +1115,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
* @param filter a mask of blocks to consider, or null to consider any solid (movement-blocking) block
|
||||
* @return height of highest block found or 'minY'
|
||||
*/
|
||||
@Override
|
||||
public int getHighestTerrainBlock(int x, int z, int minY, int maxY, Mask filter) {
|
||||
for (int y = maxY; y >= minY; --y) {
|
||||
if (filter.test(mutablebv.setComponents(x, y, z))) {
|
||||
@ -1209,6 +1202,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public <B extends BlockStateHolder<B>> boolean setBlock(int x, int y, int z, B block) {
|
||||
this.changes++;
|
||||
try {
|
||||
@ -1301,7 +1295,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Entity createEntity(com.sk89q.worldedit.util.Location location, final BaseEntity entity) {
|
||||
public Entity createEntity(Location location, final BaseEntity entity) {
|
||||
return this.extent.createEntity(location, entity);
|
||||
}
|
||||
|
||||
@ -1472,12 +1466,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
}
|
||||
if (searchIDs.size() == 1) {
|
||||
final BlockType id = searchIDs.iterator().next();
|
||||
RegionVisitor visitor = new RegionVisitor(region, new RegionFunction() {
|
||||
@Override
|
||||
public boolean apply(BlockVector3 position) throws WorldEditException {
|
||||
return getBlockType(position) == id;
|
||||
}
|
||||
}, this);
|
||||
RegionVisitor visitor = new RegionVisitor(region, position -> getBlock(position).getBlockType() == id, this);
|
||||
Operations.completeBlindly(visitor);
|
||||
return visitor.getAffected();
|
||||
}
|
||||
@ -1489,23 +1478,14 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
}
|
||||
|
||||
public int countBlock(final Region region, final boolean[] ids) {
|
||||
RegionVisitor visitor = new RegionVisitor(region, new RegionFunction() {
|
||||
@Override
|
||||
public boolean apply(BlockVector3 position) throws WorldEditException {
|
||||
return ids[getBlockType(position).getInternalId()];
|
||||
}
|
||||
}, this);
|
||||
RegionVisitor visitor = new RegionVisitor(region,
|
||||
position -> ids[getBlock(position).getInternalId()], this);
|
||||
Operations.completeBlindly(visitor);
|
||||
return visitor.getAffected();
|
||||
}
|
||||
|
||||
public int countBlock(final Region region, final Mask mask) {
|
||||
RegionVisitor visitor = new RegionVisitor(region, new RegionFunction() {
|
||||
@Override
|
||||
public boolean apply(BlockVector3 position) throws WorldEditException {
|
||||
return mask.test(position);
|
||||
}
|
||||
}, this);
|
||||
RegionVisitor visitor = new RegionVisitor(region, mask::test, this);
|
||||
Operations.completeBlindly(visitor);
|
||||
return visitor.getAffected();
|
||||
}
|
||||
@ -1519,12 +1499,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
*/
|
||||
public int countBlocks(Region region, Set<BaseBlock> searchBlocks) {
|
||||
Mask mask = new BlockMaskBuilder().addBlocks(searchBlocks).build(extent);
|
||||
RegionVisitor visitor = new RegionVisitor(region, new RegionFunction() {
|
||||
@Override
|
||||
public boolean apply(BlockVector3 position) throws WorldEditException {
|
||||
return mask.test(position);
|
||||
}
|
||||
}, this);
|
||||
RegionVisitor visitor = new RegionVisitor(region, mask::test, this);
|
||||
Operations.completeBlindly(visitor);
|
||||
return visitor.getAffected();
|
||||
}
|
||||
@ -1534,30 +1509,27 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
final int startPerformY = region.getMinimumPoint().getBlockY();
|
||||
final int startCheckY = fullHeight ? 0 : startPerformY;
|
||||
final int endY = region.getMaximumPoint().getBlockY();
|
||||
RegionVisitor visitor = new RegionVisitor(flat, new RegionFunction() {
|
||||
@Override
|
||||
public boolean apply(BlockVector3 pos) throws WorldEditException {
|
||||
int x = pos.getBlockX();
|
||||
int z = pos.getBlockZ();
|
||||
int freeSpot = startCheckY;
|
||||
for (int y = startCheckY; y <= endY; y++) {
|
||||
if (y < startPerformY) {
|
||||
if (!getBlockType(x, y, z).getMaterial().isAir()) {
|
||||
freeSpot = y + 1;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
BlockType block = getBlockType(x, y, z);
|
||||
if (!block.getMaterial().isAir()) {
|
||||
if (freeSpot != y) {
|
||||
setBlock(x, freeSpot, z, block);
|
||||
setBlock(x, y, z, replace);
|
||||
}
|
||||
freeSpot++;
|
||||
RegionVisitor visitor = new RegionVisitor(flat, pos -> {
|
||||
int x = pos.getBlockX();
|
||||
int z = pos.getBlockZ();
|
||||
int freeSpot = startCheckY;
|
||||
for (int y = startCheckY; y <= endY; y++) {
|
||||
if (y < startPerformY) {
|
||||
if (!getBlockType(x, y, z).getMaterial().isAir()) {
|
||||
freeSpot = y + 1;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
BlockType block = getBlockType(x, y, z);
|
||||
if (!block.getMaterial().isAir()) {
|
||||
if (freeSpot != y) {
|
||||
setBlock(x, freeSpot, z, block);
|
||||
setBlock(x, y, z, replace);
|
||||
}
|
||||
freeSpot++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}, this);
|
||||
Operations.completeBlindly(visitor);
|
||||
return this.changes;
|
||||
@ -1574,7 +1546,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
* @return number of blocks affected
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
public int fillDirection(final BlockVector3 origin, final Pattern pattern, final double radius, final int depth, BlockVector3 direction) {
|
||||
public int fillDirection(final BlockVector3 origin, final Pattern pattern, final double radius, final int depth, BlockVector3 direction) throws MaxChangedBlocksException {
|
||||
checkNotNull(origin);
|
||||
checkNotNull(pattern);
|
||||
checkArgument(radius >= 0, "radius >= 0");
|
||||
@ -1727,12 +1699,11 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
FaweRegionExtent regionExtent = getRegionExtent();
|
||||
if (!(region instanceof CuboidRegion)) return false;
|
||||
if (regionExtent != null) {
|
||||
if (!(region instanceof CuboidRegion)) return false;
|
||||
BlockVector3 pos1 = region.getMinimumPoint();
|
||||
BlockVector3 pos2 = region.getMaximumPoint();
|
||||
boolean contains = false;
|
||||
for (Region current : regionExtent.getRegions()) {
|
||||
if (current.contains((int) pos1.getX(), pos1.getBlockY(), pos1.getBlockZ()) && current.contains(pos2.getBlockX(), pos2.getBlockY(), pos2.getBlockZ())) {
|
||||
if (current.contains(pos1.getX(), pos1.getBlockY(), pos1.getBlockZ()) && current.contains(pos2.getBlockX(), pos2.getBlockY(), pos2.getBlockZ())) {
|
||||
contains = true;
|
||||
break;
|
||||
}
|
||||
@ -1745,8 +1716,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
return false;
|
||||
if (getChangeTask() != getChangeSet()) return false;
|
||||
if (!Masks.isNull(getMask()) || !Masks.isNull(getSourceMask())) return false;
|
||||
if (getBlockBag() != null) return false;
|
||||
return true;
|
||||
return getBlockBag() == null;
|
||||
}
|
||||
|
||||
public boolean hasExtraExtents() {
|
||||
@ -1772,7 +1742,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
getWorld(), // Causes clamping of Y range
|
||||
position.add(adjustment.multiply(-1)),
|
||||
position.add(adjustment));
|
||||
Pattern pattern = (BlockTypes.AIR.getDefaultState());
|
||||
Pattern pattern = BlockTypes.AIR.getDefaultState();
|
||||
return replaceBlocks(region, mask, pattern);
|
||||
}
|
||||
|
||||
@ -1787,7 +1757,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
public <B extends BlockStateHolder<B>> int setBlocks(Region region, B block) throws MaxChangedBlocksException {
|
||||
checkNotNull(region);
|
||||
checkNotNull(block);
|
||||
boolean hasNbt = block instanceof BaseBlock && ((BaseBlock)block).hasNbtData();
|
||||
boolean hasNbt = block instanceof BaseBlock && block.hasNbtData();
|
||||
|
||||
if (canBypassAll(region, false, true) && !hasNbt) {
|
||||
return changes = queue.setBlocks((CuboidRegion) region, block.getInternalId());
|
||||
@ -1845,7 +1815,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
public <B extends BlockStateHolder<B>> int replaceBlocks(Region region, Set<BaseBlock> filter, B replacement) throws MaxChangedBlocksException {
|
||||
return replaceBlocks(region, filter, (replacement));
|
||||
return replaceBlocks(region, filter, replacement);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1917,7 +1887,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
public <B extends BlockStateHolder<B>> int makeCuboidFaces(Region region, B block) throws MaxChangedBlocksException {
|
||||
return makeCuboidFaces(region, (block));
|
||||
return makeCuboidFaces(region, block);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1969,7 +1939,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
public <B extends BlockStateHolder<B>> int makeCuboidWalls(Region region, B block) throws MaxChangedBlocksException {
|
||||
return makeCuboidWalls(region, (block));
|
||||
return makeCuboidWalls(region, block);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2094,7 +2064,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
BlockVector3 to = region.getMinimumPoint();
|
||||
ForwardExtentCopy copy = new ForwardExtentCopy(this, region, this, to);
|
||||
copy.setCopyingEntities(copyEntities);
|
||||
copy.setCopyBiomes(copyBiomes);
|
||||
copy.setCopyingBiomes(copyBiomes);
|
||||
copy.setRepetitions(count);
|
||||
copy.setTransform(new AffineTransform().translate(dir.multiply(size)));
|
||||
Mask sourceMask = getSourceMask();
|
||||
@ -2140,8 +2110,8 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
ForwardExtentCopy copy = new ForwardExtentCopy(this, region, this, to);
|
||||
|
||||
if (replacement == null) replacement = BlockTypes.AIR.getDefaultState();
|
||||
final BlockReplace remove = replacement instanceof ExistingPattern ? null : new BlockReplace(this, replacement);
|
||||
copy.setCopyBiomes(copyBiomes);
|
||||
BlockReplace remove = replacement instanceof ExistingPattern ? null : new BlockReplace(this, replacement);
|
||||
copy.setCopyingBiomes(copyBiomes);
|
||||
copy.setCopyingEntities(copyEntities);
|
||||
copy.setSourceFunction(remove); // Remove
|
||||
copy.setRemovingEntities(true);
|
||||
@ -2170,7 +2140,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
* @return number of blocks moved
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
public int moveCuboidRegion(Region region, BlockVector3 dir, int distance, boolean copyAir, Pattern replacement) {
|
||||
public int moveCuboidRegion(Region region, BlockVector3 dir, int distance, boolean copyAir, Pattern replacement) throws MaxChangedBlocksException {
|
||||
return moveRegion(region, dir, distance, copyAir, true, false, replacement);
|
||||
}
|
||||
|
||||
@ -2214,7 +2184,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
if (waterlogged) {
|
||||
replace = new BlockReplace(this, new WaterloggedRemover(this));
|
||||
} else {
|
||||
replace = new BlockReplace(this, (BlockTypes.AIR.getDefaultState()));
|
||||
replace = new BlockReplace(this, BlockTypes.AIR.getDefaultState());
|
||||
}
|
||||
RecursiveVisitor visitor = new RecursiveVisitor(mask, replace, (int) (radius * 2 + 1), this);
|
||||
|
||||
@ -2256,7 +2226,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
blockMask
|
||||
);
|
||||
|
||||
BlockReplace replace = new BlockReplace(this, (fluid.getDefaultState()));
|
||||
BlockReplace replace = new BlockReplace(this, fluid.getDefaultState());
|
||||
NonRisingVisitor visitor = new NonRisingVisitor(mask, replace);
|
||||
|
||||
// Around the origin in a 3x3 block
|
||||
@ -2298,15 +2268,15 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
* @return number of blocks changed
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
public int makeCylinder(BlockVector3 pos, Pattern block, double radiusX, double radiusZ, int height, boolean filled) throws MaxChangedBlocksException{
|
||||
public int makeCylinder(BlockVector3 pos, Pattern block, double radiusX, double radiusZ, int height, boolean filled) throws MaxChangedBlocksException {
|
||||
return makeCylinder(pos, block, radiusX, radiusZ, height, 0, filled);
|
||||
}
|
||||
|
||||
public int makeHollowCylinder(BlockVector3 pos, final Pattern block, double radiusX, double radiusZ, int height, double thickness) {
|
||||
public int makeHollowCylinder(BlockVector3 pos, final Pattern block, double radiusX, double radiusZ, int height, double thickness) throws MaxChangedBlocksException {
|
||||
return makeCylinder(pos, block, radiusX, radiusZ, height, thickness, false);
|
||||
}
|
||||
|
||||
private int makeCylinder(BlockVector3 pos, final Pattern block, double radiusX, double radiusZ, int height, double thickness, final boolean filled) {
|
||||
private int makeCylinder(BlockVector3 pos, Pattern block, double radiusX, double radiusZ, int height, double thickness, boolean filled) throws MaxChangedBlocksException {
|
||||
int affected = 0;
|
||||
|
||||
radiusX += 0.5;
|
||||
@ -2322,12 +2292,12 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
|
||||
if (posv.getBlockY() < 0) {
|
||||
posv.mutY(0);
|
||||
} else if (((posv.getBlockY() + height) - 1) > maxY) {
|
||||
height = (maxY - posv.getBlockY()) + 1;
|
||||
} else if (posv.getBlockY() + height - 1 > maxY) {
|
||||
height = maxY - posv.getBlockY() + 1;
|
||||
}
|
||||
|
||||
final double invRadiusX = 1 / (radiusX);
|
||||
final double invRadiusZ = 1 / (radiusZ);
|
||||
final double invRadiusX = 1 / radiusX;
|
||||
final double invRadiusZ = 1 / radiusZ;
|
||||
|
||||
int px = posv.getBlockX();
|
||||
int py = posv.getBlockY();
|
||||
@ -2336,7 +2306,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
|
||||
final int ceilRadiusX = (int) Math.ceil(radiusX);
|
||||
final int ceilRadiusZ = (int) Math.ceil(radiusZ);
|
||||
double dx, dxz, dz;
|
||||
double distanceSq;
|
||||
double nextXn = 0;
|
||||
|
||||
if (thickness != 0) {
|
||||
@ -2350,15 +2320,13 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
nextMinXn = (x + 1) * minInvRadiusX;
|
||||
double nextZn = 0;
|
||||
double nextMinZn = 0;
|
||||
dx = xn * xn;
|
||||
forZ: for (int z = 0; z <= ceilRadiusZ; ++z) {
|
||||
final double zn = nextZn;
|
||||
double dz2 = nextMinZn * nextMinZn;
|
||||
nextZn = (z + 1) * invRadiusZ;
|
||||
nextMinZn = (z + 1) * minInvRadiusZ;
|
||||
dz = zn * zn;
|
||||
dxz = dx + dz;
|
||||
if (dxz > 1) {
|
||||
distanceSq = lengthSq(xn, zn);
|
||||
if (distanceSq > 1) {
|
||||
if (z == 0) {
|
||||
break forX;
|
||||
}
|
||||
@ -2381,14 +2349,14 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
forX: for (int x = 0; x <= ceilRadiusX; ++x) {
|
||||
final double xn = nextXn;
|
||||
nextXn = (x + 1) * invRadiusX;
|
||||
double dx = xn * xn;
|
||||
double nextZn = 0;
|
||||
dx = xn * xn;
|
||||
forZ: for (int z = 0; z <= ceilRadiusZ; ++z) {
|
||||
final double zn = nextZn;
|
||||
nextZn = (z + 1) * invRadiusZ;
|
||||
dz = zn * zn;
|
||||
dxz = dx + dz;
|
||||
if (dxz > 1) {
|
||||
double dz = zn * zn;
|
||||
distanceSq = lengthSq(xn,zn);
|
||||
if (distanceSq > 1) {
|
||||
if (z == 0) {
|
||||
break forX;
|
||||
}
|
||||
@ -2414,7 +2382,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
return this.changes;
|
||||
}
|
||||
|
||||
public int makeCircle(BlockVector3 pos, final Pattern block, double radiusX, double radiusY, double radiusZ, boolean filled, Vector3 normal) {
|
||||
public int makeCircle(BlockVector3 pos, final Pattern block, double radiusX, double radiusY, double radiusZ, boolean filled, Vector3 normal) throws MaxChangedBlocksException {
|
||||
radiusX += 0.5;
|
||||
radiusY += 0.5;
|
||||
radiusZ += 0.5;
|
||||
@ -2549,20 +2517,18 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
double nextXn = invRadiusX;
|
||||
forX: for (int x = 0; x <= ceilRadiusX; ++x) {
|
||||
final double xn = nextXn;
|
||||
double dx = xn * xn;
|
||||
nextXn = (x + 1) * invRadiusX;
|
||||
double nextZn = invRadiusZ;
|
||||
double dx = xn * xn;
|
||||
forZ: for (int z = 0; z <= ceilRadiusZ; ++z) {
|
||||
final double zn = nextZn;
|
||||
double dz = zn * zn;
|
||||
double dxz = dx + dz;
|
||||
nextZn = (z + 1) * invRadiusZ;
|
||||
double nextYn = invRadiusY;
|
||||
|
||||
forY: for (int y = 0; y <= ceilRadiusY; ++y) {
|
||||
final double yn = nextYn;
|
||||
double dy = yn * yn;
|
||||
double dxyz = dxz + dy;
|
||||
double dxyz = lengthSq(zn, yn, zn);
|
||||
nextYn = (y + 1) * invRadiusY;
|
||||
|
||||
if (dxyz > 1) {
|
||||
@ -2576,7 +2542,8 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
}
|
||||
|
||||
if (!filled) {
|
||||
if (nextXn * nextXn + dy + dz <= 1 && nextYn * nextYn + dx + dz <= 1 && nextZn * nextZn + dx + dy <= 1) {
|
||||
double dy = yn * yn;
|
||||
if (lengthSq(nextXn, yn, zn) <= 1 && lengthSq(xn, nextYn, zn) <= 1 && lengthSq(xn, yn, nextZn) <= 1) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@ -2763,11 +2730,13 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
* @return number of blocks affected
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
public int green(BlockVector3 position, double radius, final boolean onlyNormalDirt)
|
||||
public int green(BlockVector3 position, double radius, boolean onlyNormalDirt)
|
||||
throws MaxChangedBlocksException {
|
||||
int affected = 0;
|
||||
final double radiusSq = radius * radius;
|
||||
|
||||
final int ox = position.getBlockX();
|
||||
final int oy = position.getBlockY();
|
||||
final int oz = position.getBlockZ();
|
||||
|
||||
final BlockState grass = BlockTypes.GRASS_BLOCK.getDefaultState();
|
||||
@ -2776,27 +2745,25 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
for (int x = ox - ceilRadius; x <= ox + ceilRadius; ++x) {
|
||||
int dx = x - ox;
|
||||
int dx2 = dx * dx;
|
||||
for (int z = oz - ceilRadius; z <= (oz + ceilRadius); ++z) {
|
||||
for (int z = oz - ceilRadius; z <= oz + ceilRadius; ++z) {
|
||||
int dz = z - oz;
|
||||
int dz2 = dz * dz;
|
||||
if (dx2 + dz2 > radiusSq) {
|
||||
continue;
|
||||
}
|
||||
loop:
|
||||
|
||||
for (int y = maxY; y >= 1; --y) {
|
||||
BlockType block = getBlockType(x, y, z);
|
||||
switch (block.getInternalId()) {
|
||||
case BlockID.COARSE_DIRT:
|
||||
if (onlyNormalDirt) break loop;
|
||||
case BlockID.DIRT:
|
||||
this.setBlock(x, y, z, BlockTypes.GRASS_BLOCK.getDefaultState());
|
||||
break loop;
|
||||
case BlockID.WATER:
|
||||
case BlockID.LAVA:
|
||||
default:
|
||||
if (block.getMaterial().isMovementBlocker()) {
|
||||
break loop;
|
||||
}
|
||||
final BlockState block = getBlock(x, y, z);
|
||||
|
||||
if (block.getBlockType() == BlockTypes.DIRT ||
|
||||
(!onlyNormalDirt && block.getBlockType() == BlockTypes.COARSE_DIRT)) {
|
||||
this.setBlock(x, y, z, grass);
|
||||
|
||||
break;
|
||||
} else if (block.getBlockType() == BlockTypes.WATER || block.getBlockType() == BlockTypes.LAVA) {
|
||||
break;
|
||||
} else if (block.getBlockType().getMaterial().isMovementBlocker()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2813,11 +2780,11 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
* @return number of patches created
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
public int makePumpkinPatches(final BlockVector3 position, final int apothem) {
|
||||
public int makePumpkinPatches(BlockVector3 position, int apothem) throws MaxChangedBlocksException {
|
||||
return makePumpkinPatches(position, apothem, 0.02);
|
||||
}
|
||||
|
||||
public int makePumpkinPatches(final BlockVector3 position, final int apothem, double density) {
|
||||
public int makePumpkinPatches(BlockVector3 position, int apothem, double density) throws MaxChangedBlocksException {
|
||||
// We want to generate pumpkins
|
||||
GardenPatchGenerator generator = new GardenPatchGenerator(this);
|
||||
generator.setPlant(GardenPatchGenerator.getPumpkinPattern());
|
||||
@ -2846,7 +2813,6 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
public int makeForest(BlockVector3 basePosition, int size, double density, TreeGenerator.TreeType treeType) throws MaxChangedBlocksException {
|
||||
try {
|
||||
for (int x = basePosition.getBlockX() - size; x <= (basePosition.getBlockX() + size); ++x) {
|
||||
for (int z = basePosition.getBlockZ() - size; z <= (basePosition.getBlockZ() + size); ++z) {
|
||||
// Don't want to be in the ground
|
||||
@ -2873,7 +2839,6 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (MaxChangedBlocksException ignore) {}
|
||||
return this.changes;
|
||||
}
|
||||
|
||||
@ -2928,7 +2893,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
}
|
||||
} else {
|
||||
for (final BlockVector3 pt : region) {
|
||||
BlockType type = getBlockType(pt);
|
||||
BlockType type = getBlock(pt).getBlockType();
|
||||
counter[type.getInternalId()]++;
|
||||
}
|
||||
}
|
||||
@ -3100,6 +3065,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
final RValue x = expression.getVariable("x", false).optimize();
|
||||
final RValue y = expression.getVariable("y", false).optimize();
|
||||
final RValue z = expression.getVariable("z", false).optimize();
|
||||
|
||||
final WorldEditExpressionEnvironment environment = new WorldEditExpressionEnvironment(this, unit, zero);
|
||||
expression.setEnvironment(environment);
|
||||
final Vector3 zero2 = zero.add(0.5, 0.5, 0.5);
|
||||
@ -3142,7 +3108,6 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
public int hollowOutRegion(Region region, int thickness, Pattern pattern) throws MaxChangedBlocksException {
|
||||
try {
|
||||
final Set<BlockVector3> outside = new LocalBlockVectorSet();
|
||||
|
||||
final BlockVector3 min = region.getMinimumPoint();
|
||||
@ -3201,12 +3166,12 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
}
|
||||
}
|
||||
this.changes++;
|
||||
try {
|
||||
pattern.apply(this.extent, position, position);
|
||||
} catch (WorldEditException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} catch (WorldEditException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
return changes;
|
||||
}
|
||||
|
||||
@ -3276,12 +3241,12 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
}
|
||||
Set<BlockVector3> newVset;
|
||||
if (flat) {
|
||||
newVset = this.getStretched(vset, radius);
|
||||
newVset = getStretched(vset, radius);
|
||||
if (!filled) {
|
||||
newVset = this.getOutline(newVset);
|
||||
}
|
||||
} else {
|
||||
newVset = this.getBallooned(vset, radius);
|
||||
newVset = getBallooned(vset, radius);
|
||||
if (!filled) {
|
||||
newVset = this.getHollowed(newVset);
|
||||
}
|
||||
@ -3324,16 +3289,20 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
interpol.setNodes(nodes);
|
||||
double splinelength = interpol.arcLength(0, 1);
|
||||
for (double loop = 0; loop <= 1; loop += 1D / splinelength / quality) {
|
||||
final BlockVector3 tipv = interpol.getPosition(loop).toBlockPoint();
|
||||
BlockVector3 tipv = interpol.getPosition(loop).toBlockPoint();
|
||||
if (radius == 0) {
|
||||
pattern.apply(this, tipv, tipv);
|
||||
try {
|
||||
pattern.apply(this, tipv, tipv);
|
||||
} catch (WorldEditException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
vset.add(tipv);
|
||||
}
|
||||
}
|
||||
Set<BlockVector3> newVset;
|
||||
if (radius != 0) {
|
||||
newVset = this.getBallooned(vset, radius);
|
||||
newVset = getBallooned(vset, radius);
|
||||
if (!filled) {
|
||||
newVset = this.getHollowed(newVset);
|
||||
}
|
||||
@ -3342,7 +3311,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
return changes;
|
||||
}
|
||||
|
||||
private Set<BlockVector3> getBallooned(Set<BlockVector3> vset, double radius) {
|
||||
private static Set<BlockVector3> getBallooned(Set<BlockVector3> vset, double radius) {
|
||||
if (radius < 1) {
|
||||
return vset;
|
||||
}
|
||||
@ -3352,9 +3321,9 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
for (BlockVector3 v : vset) {
|
||||
int tipx = v.getBlockX(), tipy = v.getBlockY(), tipz = v.getBlockZ();
|
||||
|
||||
for (int loopx = tipx - ceilrad; loopx <= (tipx + ceilrad); loopx++) {
|
||||
for (int loopy = tipy - ceilrad; loopy <= (tipy + ceilrad); loopy++) {
|
||||
for (int loopz = tipz - ceilrad; loopz <= (tipz + ceilrad); loopz++) {
|
||||
for (int loopx = tipx - ceilrad; loopx <= tipx + ceilrad; loopx++) {
|
||||
for (int loopy = tipy - ceilrad; loopy <= tipy + ceilrad; loopy++) {
|
||||
for (int loopz = tipz - ceilrad; loopz <= tipz + ceilrad; loopz++) {
|
||||
if (MathMan.hypot(loopx - tipx, loopy - tipy, loopz - tipz) <= radius) {
|
||||
returnset.add(loopx, loopy, loopz);
|
||||
}
|
||||
@ -3365,7 +3334,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
return returnset;
|
||||
}
|
||||
|
||||
public Set<BlockVector3> getStretched(final Set<BlockVector3> vset, final double radius) {
|
||||
public static Set<BlockVector3> getStretched(Set<BlockVector3> vset, double radius) {
|
||||
if (radius < 1) {
|
||||
return vset;
|
||||
}
|
||||
@ -3373,8 +3342,8 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
final int ceilrad = (int) Math.ceil(radius);
|
||||
for (final BlockVector3 v : vset) {
|
||||
final int tipx = v.getBlockX(), tipy = v.getBlockY(), tipz = v.getBlockZ();
|
||||
for (int loopx = tipx - ceilrad; loopx <= (tipx + ceilrad); loopx++) {
|
||||
for (int loopz = tipz - ceilrad; loopz <= (tipz + ceilrad); loopz++) {
|
||||
for (int loopx = tipx - ceilrad; loopx <= tipx + ceilrad; loopx++) {
|
||||
for (int loopz = tipz - ceilrad; loopz <= tipz + ceilrad; loopz++) {
|
||||
if (MathMan.hypot(loopx - tipx, 0, loopz - tipz) <= radius) {
|
||||
returnset.add(loopx, v.getBlockY(), loopz);
|
||||
}
|
||||
@ -3384,7 +3353,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
return returnset;
|
||||
}
|
||||
|
||||
public Set<BlockVector3> getOutline(final Set<BlockVector3> vset) {
|
||||
public Set<BlockVector3> getOutline(Set<BlockVector3> vset) {
|
||||
final LocalBlockVectorSet returnset = new LocalBlockVectorSet();
|
||||
final LocalBlockVectorSet newset = new LocalBlockVectorSet();
|
||||
newset.addAll(vset);
|
||||
@ -3400,7 +3369,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
return returnset;
|
||||
}
|
||||
|
||||
public Set<BlockVector3> getHollowed(final Set<BlockVector3> vset) {
|
||||
public Set<BlockVector3> getHollowed(Set<BlockVector3> vset) {
|
||||
final Set<BlockVector3> returnset = new LocalBlockVectorSet();
|
||||
final LocalBlockVectorSet newset = new LocalBlockVectorSet();
|
||||
newset.addAll(vset);
|
||||
@ -3421,6 +3390,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
private void recurseHollow(Region region, BlockVector3 origin, Set<BlockVector3> outside) {
|
||||
final LocalBlockVectorSet queue = new LocalBlockVectorSet();
|
||||
queue.add(origin);
|
||||
|
||||
while (!queue.isEmpty()) {
|
||||
final BlockVector3 current = queue.getIndex(0);
|
||||
queue.remove(current);
|
||||
@ -3518,6 +3488,10 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
return worldName;
|
||||
}
|
||||
|
||||
@Override public @org.jetbrains.annotations.Nullable Path getStoragePath() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBlockLightLevel(BlockVector3 position) {
|
||||
return queue.getEmmittedLight(position.getBlockX(), position.getBlockY(), position.getBlockZ());
|
||||
@ -3666,12 +3640,6 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
return false;
|
||||
}
|
||||
|
||||
// public void dropItem(BlockVector3 position, BaseItemStack item) {
|
||||
// if (getWorld() != null) {
|
||||
// getWorld().dropItem(position, item);
|
||||
// }
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void simulateBlockMine(BlockVector3 position) {
|
||||
TaskManager.IMP.sync((Supplier<Object>) () -> {
|
||||
|
@ -20,13 +20,13 @@
|
||||
package com.sk89q.worldedit;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.sk89q.worldedit.extension.input.InputParseException;
|
||||
import com.sk89q.worldedit.extent.NullExtent;
|
||||
import com.sk89q.worldedit.function.mask.BlockMask;
|
||||
import com.sk89q.worldedit.function.mask.BlockMaskBuilder;
|
||||
import com.sk89q.worldedit.util.logging.LogFormat;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import com.sk89q.worldedit.world.registry.LegacyMapper;
|
||||
import com.sk89q.worldedit.world.snapshot.SnapshotRepository;
|
||||
|
||||
@ -59,11 +59,10 @@ public abstract class LocalConfiguration {
|
||||
public boolean logCommands = false;
|
||||
public String logFile = "";
|
||||
public String logFormat = LogFormat.DEFAULT_FORMAT;
|
||||
public boolean registerHelp = true; // what is the point of this, it's not even used
|
||||
public boolean registerHelp = true; // unused
|
||||
public String wandItem = "minecraft:wooden_axe";
|
||||
public boolean superPickaxeDrop = true;
|
||||
public boolean superPickaxeManyDrop = true;
|
||||
public boolean noDoubleSlash = false;
|
||||
public boolean useInventory = false;
|
||||
public boolean useInventoryOverride = false;
|
||||
public boolean useInventoryCreativeOverride = false;
|
||||
@ -76,7 +75,7 @@ public abstract class LocalConfiguration {
|
||||
public Set<String> allowedDataCycleBlocks = new HashSet<>();
|
||||
public String saveDir = "schematics";
|
||||
public String scriptsDir = "craftscripts";
|
||||
public boolean showHelpInfo = true;
|
||||
public boolean showHelpInfo = true; // unused
|
||||
public int butcherDefaultRadius = -1;
|
||||
public int butcherMaxRadius = -1;
|
||||
public boolean allowSymlinks = false;
|
||||
@ -158,7 +157,11 @@ public abstract class LocalConfiguration {
|
||||
if (disallowedBlocksMask == null) {
|
||||
BlockMaskBuilder builder = new BlockMaskBuilder();
|
||||
for (String blockRegex : disallowedBlocks) {
|
||||
builder.addRegex(blockRegex);
|
||||
try {
|
||||
builder.addRegex(blockRegex);
|
||||
} catch (InputParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
disallowedBlocksMask = builder.build(new NullExtent());
|
||||
}
|
||||
|
@ -19,6 +19,8 @@
|
||||
|
||||
package com.sk89q.worldedit;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.config.Settings;
|
||||
import com.boydti.fawe.object.FaweInputStream;
|
||||
@ -39,8 +41,6 @@ import com.boydti.fawe.util.StringMan;
|
||||
import com.boydti.fawe.util.TextureHolder;
|
||||
import com.boydti.fawe.util.TextureUtil;
|
||||
import com.boydti.fawe.wrappers.WorldWrapper;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import com.sk89q.jchronic.Chronic;
|
||||
import com.sk89q.jchronic.Options;
|
||||
import com.sk89q.jchronic.utils.Span;
|
||||
@ -71,19 +71,19 @@ import com.sk89q.worldedit.regions.selector.CuboidRegionSelector;
|
||||
import com.sk89q.worldedit.regions.selector.RegionSelectorType;
|
||||
import com.sk89q.worldedit.session.ClipboardHolder;
|
||||
import com.sk89q.worldedit.session.request.Request;
|
||||
import com.sk89q.worldedit.util.Countable;
|
||||
import com.sk89q.worldedit.util.HandSide;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.item.ItemType;
|
||||
import com.sk89q.worldedit.world.item.ItemTypes;
|
||||
import com.sk89q.worldedit.world.snapshot.Snapshot;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.time.ZoneId;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
@ -93,17 +93,19 @@ import java.util.Map;
|
||||
import java.util.TimeZone;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Stores session information.
|
||||
*/
|
||||
public class LocalSession implements TextureHolder {
|
||||
|
||||
public transient static int MAX_HISTORY_SIZE = 15;
|
||||
public static transient int MAX_HISTORY_SIZE = 15;
|
||||
|
||||
// Non-session related fields
|
||||
private transient LocalConfiguration config;
|
||||
private transient final AtomicBoolean dirty = new AtomicBoolean();
|
||||
private final transient AtomicBoolean dirty = new AtomicBoolean();
|
||||
private transient int failedCuiAttempts = 0;
|
||||
|
||||
// Session related
|
||||
@ -127,7 +129,6 @@ public class LocalSession implements TextureHolder {
|
||||
});
|
||||
private transient volatile Integer historyNegativeIndex;
|
||||
private transient ClipboardHolder clipboard;
|
||||
private transient boolean toolControl = true;
|
||||
private transient boolean superPickaxe = false;
|
||||
private transient BlockTool pickaxeMode = new SinglePickaxe();
|
||||
private transient boolean hasTool = false;
|
||||
@ -143,18 +144,21 @@ public class LocalSession implements TextureHolder {
|
||||
private transient Mask sourceMask;
|
||||
private transient TextureUtil texture;
|
||||
private transient ResettableExtent transform = null;
|
||||
private transient TimeZone timezone = TimeZone.getDefault();
|
||||
private transient ZoneId timezone = ZoneId.systemDefault();
|
||||
private transient World currentWorld;
|
||||
private transient UUID uuid;
|
||||
private transient volatile long historySize = 0;
|
||||
|
||||
private transient VirtualWorld virtual;
|
||||
private transient BlockVector3 cuiTemporaryBlock;
|
||||
private transient List<Countable<BlockState>> lastDistribution;
|
||||
|
||||
// Saved properties
|
||||
private String lastScript;
|
||||
private RegionSelectorType defaultSelector;
|
||||
private boolean useServerCUI = false; // Save this to not annoy players.
|
||||
private String wandItem;
|
||||
private String navWandItem;
|
||||
|
||||
/**
|
||||
* Construct the object.
|
||||
@ -193,11 +197,6 @@ public class LocalSession implements TextureHolder {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param uuid
|
||||
* @param world
|
||||
* @return If any loading occured
|
||||
*/
|
||||
public boolean loadSessionHistoryFromDisk(UUID uuid, World world) {
|
||||
if (world == null || uuid == null) {
|
||||
return false;
|
||||
@ -344,7 +343,7 @@ public class LocalSession implements TextureHolder {
|
||||
*
|
||||
* @return the timezone
|
||||
*/
|
||||
public TimeZone getTimeZone() {
|
||||
public ZoneId getTimeZone() {
|
||||
return timezone;
|
||||
}
|
||||
|
||||
@ -353,7 +352,7 @@ public class LocalSession implements TextureHolder {
|
||||
*
|
||||
* @param timezone the user's timezone
|
||||
*/
|
||||
public void setTimezone(TimeZone timezone) {
|
||||
public void setTimezone(ZoneId timezone) {
|
||||
checkNotNull(timezone);
|
||||
this.timezone = timezone;
|
||||
}
|
||||
@ -409,7 +408,6 @@ public class LocalSession implements TextureHolder {
|
||||
}
|
||||
loadSessionHistoryFromDisk(player.getUniqueId(), world);
|
||||
if (changeSet instanceof FaweChangeSet) {
|
||||
int size = getHistoryNegativeIndex();
|
||||
ListIterator<Object> iter = history.listIterator();
|
||||
int i = 0;
|
||||
int cutoffIndex = history.size() - getHistoryNegativeIndex();
|
||||
@ -454,9 +452,8 @@ public class LocalSession implements TextureHolder {
|
||||
return;
|
||||
}
|
||||
// Don't store anything if no changes were made
|
||||
if (editSession.size() == 0) {
|
||||
return;
|
||||
}
|
||||
if (editSession.size() == 0) return;
|
||||
|
||||
FaweChangeSet changeSet = (FaweChangeSet) editSession.getChangeSet();
|
||||
if (changeSet.isEmpty()) {
|
||||
return;
|
||||
@ -468,7 +465,6 @@ public class LocalSession implements TextureHolder {
|
||||
}
|
||||
// Destroy any sessions after this undo point
|
||||
if (append) {
|
||||
int size = getHistoryNegativeIndex();
|
||||
ListIterator<Object> iter = history.listIterator();
|
||||
int i = 0;
|
||||
int cutoffIndex = history.size() - getHistoryNegativeIndex();
|
||||
@ -518,7 +514,7 @@ public class LocalSession implements TextureHolder {
|
||||
loadSessionHistoryFromDisk(player.getUniqueId(), fp.getWorldForEditing());
|
||||
if (getHistoryNegativeIndex() < history.size()) {
|
||||
FaweChangeSet changeSet = getChangeSet(history.get(getHistoryIndex()));
|
||||
EditSession newEditSession = new EditSessionBuilder(changeSet.getWorld())
|
||||
try (EditSession newEditSession = new EditSessionBuilder(changeSet.getWorld())
|
||||
.allowedRegionsEverywhere()
|
||||
.checkMemory(false)
|
||||
.changeSetNull()
|
||||
@ -526,11 +522,12 @@ public class LocalSession implements TextureHolder {
|
||||
.limitUnprocessed(fp)
|
||||
.player(fp)
|
||||
.blockBag(getBlockBag(player))
|
||||
.build();
|
||||
newEditSession.setBlocks(changeSet, ChangeSetExecutor.Type.UNDO);
|
||||
setDirty();
|
||||
historyNegativeIndex++;
|
||||
return newEditSession;
|
||||
.build()) {
|
||||
newEditSession.setBlocks(changeSet, ChangeSetExecutor.Type.UNDO);
|
||||
setDirty();
|
||||
historyNegativeIndex++;
|
||||
return newEditSession;
|
||||
}
|
||||
} else {
|
||||
int size = history.size();
|
||||
if (getHistoryNegativeIndex() != size) {
|
||||
@ -556,7 +553,7 @@ public class LocalSession implements TextureHolder {
|
||||
setDirty();
|
||||
historyNegativeIndex--;
|
||||
FaweChangeSet changeSet = getChangeSet(history.get(getHistoryIndex()));
|
||||
EditSession newEditSession = new EditSessionBuilder(changeSet.getWorld())
|
||||
try (EditSession newEditSession = new EditSessionBuilder(changeSet.getWorld())
|
||||
.allowedRegionsEverywhere()
|
||||
.checkMemory(false)
|
||||
.changeSetNull()
|
||||
@ -564,9 +561,10 @@ public class LocalSession implements TextureHolder {
|
||||
.limitUnprocessed(fp)
|
||||
.player(fp)
|
||||
.blockBag(getBlockBag(player))
|
||||
.build();
|
||||
newEditSession.setBlocks(changeSet, ChangeSetExecutor.Type.REDO);
|
||||
return newEditSession;
|
||||
.build()) {
|
||||
newEditSession.setBlocks(changeSet, ChangeSetExecutor.Type.REDO);
|
||||
return newEditSession;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
@ -707,27 +705,6 @@ public class LocalSession implements TextureHolder {
|
||||
return world;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the world selection.
|
||||
*
|
||||
* @return the current selection
|
||||
*/
|
||||
public Region getWorldSelection() throws IncompleteRegionException {
|
||||
return getSelection(getSelectionWorld());
|
||||
}
|
||||
|
||||
/**
|
||||
* This is an alias for {@link #getSelection(World)}.
|
||||
* It enables CraftScripts to get a world selection as it is
|
||||
* not possible to use getSelection which have two default
|
||||
* implementations.
|
||||
*
|
||||
* @return Get the selection region in the world.
|
||||
*/
|
||||
public Region getWorldSelection(World world) throws IncompleteRegionException {
|
||||
return getSelection(world);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the clipboard.
|
||||
*
|
||||
@ -783,21 +760,20 @@ public class LocalSession implements TextureHolder {
|
||||
}
|
||||
|
||||
/**
|
||||
* See if tool control is enabled.
|
||||
*
|
||||
* @return true if enabled
|
||||
* @return true always - see deprecation notice
|
||||
* @deprecated The wand is now a tool that can be bound/unbound.
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean isToolControlEnabled() {
|
||||
return toolControl;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change tool control setting.
|
||||
*
|
||||
* @param toolControl true to enable tool control
|
||||
* @param toolControl unused - see deprecation notice
|
||||
* @deprecated The wand is now a tool that can be bound/unbound.
|
||||
*/
|
||||
@Deprecated
|
||||
public void setToolControl(boolean toolControl) {
|
||||
this.toolControl = toolControl;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -962,15 +938,12 @@ public class LocalSession implements TextureHolder {
|
||||
|
||||
@Nullable
|
||||
public Tool getTool(Player player) {
|
||||
if (!Settings.IMP.EXPERIMENTAL.PERSISTENT_BRUSHES && !hasTool) {
|
||||
return null;
|
||||
}
|
||||
BaseItem item = player.getItemInHand(HandSide.MAIN_HAND);
|
||||
return getTool(item, player);
|
||||
}
|
||||
|
||||
public Tool getTool(BaseItem item, Player player) {
|
||||
if (Settings.IMP.EXPERIMENTAL.PERSISTENT_BRUSHES && item.getNativeItem() != null) {
|
||||
if (item.getNativeItem() != null) {
|
||||
BrushTool tool = BrushCache.getTool(player, this, item);
|
||||
if (tool != null) return tool;
|
||||
}
|
||||
@ -987,7 +960,7 @@ public class LocalSession implements TextureHolder {
|
||||
* @throws InvalidToolBindException if the item can't be bound to that item
|
||||
*/
|
||||
public BrushTool getBrushTool(ItemType item) throws InvalidToolBindException {
|
||||
return getBrushTool(item.getDefaultState(), null, true);
|
||||
return getBrushTool(item, null, true);
|
||||
}
|
||||
|
||||
public BrushTool getBrushTool(Player player) throws InvalidToolBindException {
|
||||
@ -995,17 +968,19 @@ public class LocalSession implements TextureHolder {
|
||||
}
|
||||
|
||||
public BrushTool getBrushTool(Player player, boolean create) throws InvalidToolBindException {
|
||||
BaseItem item = player.getItemInHand(HandSide.MAIN_HAND);
|
||||
ItemType item = player.getItemInHand(HandSide.MAIN_HAND).getType();
|
||||
return getBrushTool(item, player, create);
|
||||
}
|
||||
public BrushTool getBrushTool(ItemType item, boolean create) throws InvalidToolBindException {
|
||||
return getBrushTool(item, null, create);
|
||||
}
|
||||
|
||||
|
||||
public BrushTool getBrushTool(BaseItem item, Player player, boolean create) throws InvalidToolBindException {
|
||||
Tool tool = getTool(item, player);
|
||||
public BrushTool getBrushTool(ItemType item, Player player, boolean create) throws InvalidToolBindException {
|
||||
Tool tool = getTool(item.getDefaultState(), player);
|
||||
if (!(tool instanceof BrushTool)) {
|
||||
if (create) {
|
||||
tool = new BrushTool();
|
||||
setTool(item, tool, player);
|
||||
setTool(item.getDefaultState(), tool, player);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
@ -1032,7 +1007,7 @@ public class LocalSession implements TextureHolder {
|
||||
setTool(item.getDefaultState(), tool, null);
|
||||
}
|
||||
|
||||
public void setTool(@Nullable Tool tool, Player player) throws InvalidToolBindException {
|
||||
public void setTool(Player player, @Nullable Tool tool) throws InvalidToolBindException {
|
||||
BaseItemStack item = player.getItemInHand(HandSide.MAIN_HAND);
|
||||
setTool(item, tool, player);
|
||||
}
|
||||
@ -1047,7 +1022,7 @@ public class LocalSession implements TextureHolder {
|
||||
throw new InvalidToolBindException(type, "Already used for the navigation wand");
|
||||
}
|
||||
Tool previous;
|
||||
if (player != null && (tool instanceof BrushTool || tool == null) && Settings.IMP.EXPERIMENTAL.PERSISTENT_BRUSHES && item.getNativeItem() != null) {
|
||||
if (player != null && (tool instanceof BrushTool || tool == null) && item.getNativeItem() != null) {
|
||||
previous = BrushCache.getCachedTool(item);
|
||||
BrushCache.setTool(item, (BrushTool) tool);
|
||||
if (tool != null) {
|
||||
@ -1068,7 +1043,7 @@ public class LocalSession implements TextureHolder {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (previous != null && player != null && previous instanceof BrushTool) {
|
||||
if (player != null && previous instanceof BrushTool) {
|
||||
BrushTool brushTool = (BrushTool) previous;
|
||||
brushTool.clear(player);
|
||||
}
|
||||
@ -1259,9 +1234,9 @@ public class LocalSession implements TextureHolder {
|
||||
*
|
||||
* @param text the message
|
||||
*/
|
||||
public void handleCUIInitializationMessage(String text) {
|
||||
public void handleCUIInitializationMessage(String text, Actor actor) {
|
||||
checkNotNull(text);
|
||||
if (this.failedCuiAttempts > 3) {
|
||||
if (this.hasCUISupport || this.failedCuiAttempts > 3) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1271,13 +1246,18 @@ public class LocalSession implements TextureHolder {
|
||||
this.failedCuiAttempts ++;
|
||||
return;
|
||||
}
|
||||
setCUISupport(true);
|
||||
|
||||
int version;
|
||||
try {
|
||||
setCUIVersion(Integer.parseInt(split[1]));
|
||||
version = Integer.parseInt(split[1]);
|
||||
} catch (NumberFormatException e) {
|
||||
WorldEdit.logger.warn("Error while reading CUI init message: " + e.getMessage());
|
||||
this.failedCuiAttempts ++;
|
||||
return;
|
||||
}
|
||||
setCUISupport(true);
|
||||
setCUIVersion(version);
|
||||
dispatchCUISelection(actor);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1327,9 +1307,10 @@ public class LocalSession implements TextureHolder {
|
||||
public Calendar detectDate(String input) {
|
||||
checkNotNull(input);
|
||||
|
||||
Time.setTimeZone(getTimeZone());
|
||||
TimeZone tz = TimeZone.getTimeZone(getTimeZone());
|
||||
Time.setTimeZone(tz);
|
||||
Options opt = new com.sk89q.jchronic.Options();
|
||||
opt.setNow(Calendar.getInstance(getTimeZone()));
|
||||
opt.setNow(Calendar.getInstance(tz));
|
||||
Span date = Chronic.parse(input, opt);
|
||||
if (date == null) {
|
||||
return null;
|
||||
@ -1349,16 +1330,13 @@ public class LocalSession implements TextureHolder {
|
||||
|
||||
BlockBag blockBag = getBlockBag(player);
|
||||
|
||||
World world = player.getWorld();
|
||||
boolean isPlayer = player.isPlayer();
|
||||
EditSessionBuilder builder = new EditSessionBuilder(world);
|
||||
if (player.isPlayer()) builder.player(FawePlayer.wrap(player));
|
||||
builder.blockBag(blockBag);
|
||||
builder.fastmode(fastMode);
|
||||
|
||||
EditSession editSession = builder.build();
|
||||
|
||||
// Create an edit session
|
||||
EditSession editSession = WorldEdit.getInstance().getEditSessionFactory()
|
||||
.getEditSession(player.isPlayer() ? player.getWorld() : null,
|
||||
getBlockChangeLimit(), blockBag, player);
|
||||
Request.request().setEditSession(editSession);
|
||||
|
||||
editSession.setFastMode(fastMode);
|
||||
if (mask != null) {
|
||||
editSession.setMask(mask);
|
||||
}
|
||||
@ -1368,6 +1346,7 @@ public class LocalSession implements TextureHolder {
|
||||
if (transform != null) {
|
||||
editSession.addTransform(transform);
|
||||
}
|
||||
|
||||
return editSession;
|
||||
}
|
||||
|
||||
@ -1465,6 +1444,38 @@ public class LocalSession implements TextureHolder {
|
||||
return tmp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the preferred wand item for this user, or {@code null} to use the default
|
||||
* @return item id of wand item, or {@code null}
|
||||
*/
|
||||
public String getWandItem() {
|
||||
return wandItem;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the preferred navigation wand item for this user, or {@code null} to use the default
|
||||
* @return item id of nav wand item, or {@code null}
|
||||
*/
|
||||
public String getNavWandItem() {
|
||||
return navWandItem;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last block distribution stored in this session.
|
||||
*
|
||||
* @return block distribution or {@code null}
|
||||
*/
|
||||
public List<Countable<BlockState>> getLastDistribution() {
|
||||
return lastDistribution == null ? null : Collections.unmodifiableList(lastDistribution);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a block distribution in this session.
|
||||
*/
|
||||
public void setLastDistribution(List<Countable<BlockState>> dist) {
|
||||
lastDistribution = dist;
|
||||
}
|
||||
|
||||
public ResettableExtent getTransform() {
|
||||
return transform;
|
||||
}
|
||||
|
@ -32,6 +32,7 @@ public class UnknownDirectionException extends WorldEditException {
|
||||
* @param dir the input that was tried
|
||||
*/
|
||||
public UnknownDirectionException(String dir) {
|
||||
super("Unknown direction: " + dir);
|
||||
this.dir = dir;
|
||||
}
|
||||
|
||||
|
@ -19,9 +19,13 @@
|
||||
|
||||
package com.sk89q.worldedit;
|
||||
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import static com.sk89q.worldedit.event.platform.Interaction.HIT;
|
||||
import static com.sk89q.worldedit.event.platform.Interaction.OPEN;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.util.concurrent.ListeningExecutorService;
|
||||
import com.google.common.util.concurrent.MoreExecutors;
|
||||
import com.sk89q.worldedit.blocks.BaseItem;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.event.platform.BlockInteractEvent;
|
||||
@ -48,6 +52,7 @@ import com.sk89q.worldedit.scripting.RhinoCraftScriptEngine;
|
||||
import com.sk89q.worldedit.session.SessionManager;
|
||||
import com.sk89q.worldedit.util.Direction;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.util.concurrency.EvenMoreExecutors;
|
||||
import com.sk89q.worldedit.util.eventbus.EventBus;
|
||||
import com.sk89q.worldedit.util.io.file.FileSelectionAbortedException;
|
||||
import com.sk89q.worldedit.util.io.file.FilenameException;
|
||||
@ -60,11 +65,6 @@ import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.registry.BundledBlockData;
|
||||
import com.sk89q.worldedit.world.registry.BundledItemData;
|
||||
import com.sk89q.worldedit.world.registry.LegacyMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.script.ScriptException;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
@ -76,10 +76,12 @@ import java.nio.file.Paths;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.sk89q.worldedit.event.platform.Interaction.HIT;
|
||||
import static com.sk89q.worldedit.event.platform.Interaction.OPEN;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.script.ScriptException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* The entry point and container for a working implementation of WorldEdit.
|
||||
@ -105,6 +107,7 @@ public final class WorldEdit {
|
||||
private final PlatformManager platformManager = new PlatformManager(this);
|
||||
private final EditSessionFactory editSessionFactory = new EditSessionFactory.EditSessionFactoryImpl(eventBus);
|
||||
private final SessionManager sessions = new SessionManager(this);
|
||||
private final ListeningExecutorService executorService = MoreExecutors.listeningDecorator(EvenMoreExecutors.newBoundedCachedThreadPool(0, 1, 20));
|
||||
private final Supervisor supervisor = new SimpleSupervisor();
|
||||
|
||||
private final BlockFactory blockFactory = new BlockFactory(this);
|
||||
@ -155,7 +158,7 @@ public final class WorldEdit {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the supervisor.
|
||||
* Get the supervisor. Internal, not for API use.
|
||||
*
|
||||
* @return the supervisor
|
||||
*/
|
||||
@ -163,6 +166,15 @@ public final class WorldEdit {
|
||||
return supervisor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the executor service. Internal, not for API use.
|
||||
*
|
||||
* @return the executor service
|
||||
*/
|
||||
public ListeningExecutorService getExecutorService() {
|
||||
return executorService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the block factory from which new {@link BlockStateHolder}s can be
|
||||
* constructed.
|
||||
@ -307,6 +319,17 @@ public final class WorldEdit {
|
||||
if (exts.size() != 1) {
|
||||
exts = exts.subList(0, 1);
|
||||
}
|
||||
} else {
|
||||
int dot = filename.lastIndexOf('.');
|
||||
if (dot < 0 || dot == filename.length() - 1) {
|
||||
String currentExt = filename.substring(dot + 1);
|
||||
if (exts.contains(currentExt) && checkFilename(filename)) {
|
||||
File f = new File(dir, filename);
|
||||
if (f.exists()) {
|
||||
return f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
File result = null;
|
||||
for (Iterator<String> iter = exts.iterator(); iter.hasNext() && (result == null || (!isSave && !result.exists()));) {
|
||||
@ -321,7 +344,7 @@ public final class WorldEdit {
|
||||
private File getSafeFileWithExtension(File dir, String filename, String extension) {
|
||||
if (extension != null) {
|
||||
int dot = filename.lastIndexOf('.');
|
||||
if (dot < 0 || !filename.substring(dot).equalsIgnoreCase(extension)) {
|
||||
if (dot < 0 || dot == filename.length() - 1 || !filename.substring(dot + 1).equalsIgnoreCase(extension)) {
|
||||
filename += "." + extension;
|
||||
}
|
||||
}
|
||||
@ -396,16 +419,15 @@ public final class WorldEdit {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the direction vector for a player's direction. May return
|
||||
* null if a direction could not be found.
|
||||
* Get the direction vector for a player's direction.
|
||||
*
|
||||
* @param player the player
|
||||
* @param dirStr the direction string
|
||||
* @return a direction vector
|
||||
* @throws UnknownDirectionException thrown if the direction is not known
|
||||
* @throws UnknownDirectionException thrown if the direction is not known, or a relative direction is used with null player
|
||||
*/
|
||||
public BlockVector3 getDirection(Player player, String dirStr) throws UnknownDirectionException {
|
||||
dirStr = dirStr.toLowerCase();
|
||||
public BlockVector3 getDirection(@Nullable Player player, String dirStr) throws UnknownDirectionException {
|
||||
dirStr = dirStr.toLowerCase(Locale.ROOT);
|
||||
|
||||
final Direction dir = getPlayerDirection(player, dirStr);
|
||||
|
||||
@ -417,16 +439,15 @@ public final class WorldEdit {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the direction vector for a player's direction. May return
|
||||
* null if a direction could not be found.
|
||||
* Get the direction vector for a player's direction.
|
||||
*
|
||||
* @param player the player
|
||||
* @param dirStr the direction string
|
||||
* @return a direction vector
|
||||
* @throws UnknownDirectionException thrown if the direction is not known
|
||||
* @throws UnknownDirectionException thrown if the direction is not known, or a relative direction is used with null player
|
||||
*/
|
||||
public BlockVector3 getDiagonalDirection(Player player, String dirStr) throws UnknownDirectionException {
|
||||
dirStr = dirStr.toLowerCase();
|
||||
public BlockVector3 getDiagonalDirection(@Nullable Player player, String dirStr) throws UnknownDirectionException {
|
||||
dirStr = dirStr.toLowerCase(Locale.ROOT);
|
||||
|
||||
final Direction dir = getPlayerDirection(player, dirStr);
|
||||
|
||||
@ -438,15 +459,14 @@ public final class WorldEdit {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the direction vector for a player's direction. May return
|
||||
* null if a direction could not be found.
|
||||
* Get the direction vector for a player's direction.
|
||||
*
|
||||
* @param player the player
|
||||
* @param dirStr the direction string
|
||||
* @return a direction enum value
|
||||
* @throws UnknownDirectionException thrown if the direction is not known
|
||||
* @throws UnknownDirectionException thrown if the direction is not known, or a relative direction is used with null player
|
||||
*/
|
||||
private Direction getPlayerDirection(Player player, String dirStr) throws UnknownDirectionException {
|
||||
private Direction getPlayerDirection(@Nullable Player player, String dirStr) throws UnknownDirectionException {
|
||||
final Direction dir;
|
||||
|
||||
switch (dirStr.charAt(0)) {
|
||||
@ -490,19 +510,19 @@ public final class WorldEdit {
|
||||
|
||||
case 'm': // me
|
||||
case 'f': // forward
|
||||
dir = player.getCardinalDirection(0);
|
||||
dir = getDirectionRelative(player, 0);
|
||||
break;
|
||||
|
||||
case 'b': // back
|
||||
dir = player.getCardinalDirection(180);
|
||||
dir = getDirectionRelative(player, 180);
|
||||
break;
|
||||
|
||||
case 'l': // left
|
||||
dir = player.getCardinalDirection(-90);
|
||||
dir = getDirectionRelative(player, -90);
|
||||
break;
|
||||
|
||||
case 'r': // right
|
||||
dir = player.getCardinalDirection(90);
|
||||
dir = getDirectionRelative(player, 90);
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -511,6 +531,13 @@ public final class WorldEdit {
|
||||
return dir;
|
||||
}
|
||||
|
||||
private Direction getDirectionRelative(Player player, int yawOffset) throws UnknownDirectionException {
|
||||
if (player != null) {
|
||||
return player.getCardinalDirection(yawOffset);
|
||||
}
|
||||
throw new UnknownDirectionException("Only a player can use relative directions");
|
||||
}
|
||||
|
||||
/**
|
||||
* Flush a block bag's changes to a player.
|
||||
*
|
||||
@ -650,9 +677,9 @@ public final class WorldEdit {
|
||||
|
||||
try {
|
||||
engine = new RhinoCraftScriptEngine();
|
||||
} catch (NoClassDefFoundError e) {
|
||||
} catch (NoClassDefFoundError ignored) {
|
||||
player.printError("Failed to find an installed script engine.");
|
||||
player.printError("Please see http://wiki.sk89q.com/wiki/WorldEdit/Installation");
|
||||
player.printError("Please see https://worldedit.readthedocs.io/en/latest/usage/other/craftscripts/");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -19,16 +19,13 @@
|
||||
|
||||
package com.sk89q.worldedit.blocks;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.worldedit.command.tool.Tool;
|
||||
import com.sk89q.worldedit.world.NbtValued;
|
||||
import com.sk89q.worldedit.world.item.ItemType;
|
||||
import com.sk89q.worldedit.world.item.ItemTypes;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* Represents an item, without an amount value. See {@link BaseItemStack}
|
||||
* for an instance with stack amount information.
|
||||
|
@ -0,0 +1,144 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.command;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.blocks.BaseItem;
|
||||
import com.sk89q.worldedit.command.factory.ItemUseFactory;
|
||||
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.PermissionCondition;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.function.Contextual;
|
||||
import com.sk89q.worldedit.function.RegionFunction;
|
||||
import com.sk89q.worldedit.function.factory.Apply;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.internal.annotation.Direction;
|
||||
import com.sk89q.worldedit.internal.command.CommandRegistrationHandler;
|
||||
import com.sk89q.worldedit.regions.factory.RegionFactory;
|
||||
import com.sk89q.worldedit.util.TreeGenerator;
|
||||
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 org.enginehub.piston.CommandManager;
|
||||
import org.enginehub.piston.CommandManagerService;
|
||||
import org.enginehub.piston.CommandParameters;
|
||||
import org.enginehub.piston.annotation.Command;
|
||||
import org.enginehub.piston.annotation.CommandContainer;
|
||||
import org.enginehub.piston.annotation.param.Arg;
|
||||
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 {
|
||||
|
||||
private static final CommandArgument REGION_FACTORY = arg(TranslatableComponent.of("shape"), TextComponent.of("The shape of the region"))
|
||||
.defaultsTo(ImmutableList.of())
|
||||
.ofTypes(ImmutableList.of(Key.of(RegionFactory.class)))
|
||||
.build();
|
||||
|
||||
private static final CommandArgument RADIUS = arg(TranslatableComponent.of("radius"), TextComponent.of("The size of the brush"))
|
||||
.defaultsTo(ImmutableList.of("5"))
|
||||
.ofTypes(ImmutableList.of(Key.of(double.class)))
|
||||
.build();
|
||||
|
||||
public static void register(CommandManagerService service, CommandManager commandManager, CommandRegistrationHandler registration) {
|
||||
commandManager.register("apply", builder -> {
|
||||
builder.description(TextComponent.of("Apply brush, apply a function to every block"));
|
||||
builder.action(org.enginehub.piston.Command.Action.NULL_ACTION);
|
||||
|
||||
CommandManager manager = service.newCommandManager();
|
||||
registration.register(
|
||||
manager,
|
||||
ApplyBrushCommandsRegistration.builder(),
|
||||
new ApplyBrushCommands()
|
||||
);
|
||||
|
||||
builder.condition(new PermissionCondition(ImmutableSet.of("worldedit.brush.apply")));
|
||||
|
||||
builder.addParts(REGION_FACTORY, RADIUS);
|
||||
builder.addPart(SubCommandPart.builder(TranslatableComponent.of("type"), TextComponent.of("Type of brush to use"))
|
||||
.withCommands(manager.getAllCommands().collect(Collectors.toList()))
|
||||
.required()
|
||||
.build());
|
||||
});
|
||||
}
|
||||
|
||||
private void setApplyBrush(CommandParameters parameters, Player player, LocalSession localSession,
|
||||
Contextual<? extends RegionFunction> generatorFactory) throws WorldEditException {
|
||||
double radius = requireNonNull(RADIUS.value(parameters).asSingle(double.class));
|
||||
RegionFactory regionFactory = REGION_FACTORY.value(parameters).asSingle(RegionFactory.class);
|
||||
BrushCommands.setOperationBasedBrush(player, localSession, radius,
|
||||
new Apply(generatorFactory), regionFactory, "worldedit.brush.apply");
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "forest",
|
||||
desc = "Plant trees"
|
||||
)
|
||||
public void forest(CommandParameters parameters,
|
||||
Player player, LocalSession localSession,
|
||||
@Arg(desc = "The type of tree to plant")
|
||||
TreeGenerator.TreeType type) throws WorldEditException {
|
||||
setApplyBrush(parameters, player, localSession, new TreeGeneratorFactory(type));
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "item",
|
||||
desc = "Use an item"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.item")
|
||||
public void item(CommandParameters parameters,
|
||||
Player player, LocalSession localSession,
|
||||
@Arg(desc = "The type of item to use")
|
||||
BaseItem item,
|
||||
@Arg(desc = "The direction in which the item will be applied", def = "up")
|
||||
@Direction(includeDiagonals = true)
|
||||
com.sk89q.worldedit.util.Direction direction) throws WorldEditException {
|
||||
player.print(TextComponent.builder().append("WARNING: ", TextColor.RED, TextDecoration.BOLD)
|
||||
.append("This brush simulates item usages. Its effects may not work on all platforms, may not be undo-able," +
|
||||
" and may cause strange interactions with other mods/plugins. Use at your own risk.").build());
|
||||
setApplyBrush(parameters, player, localSession, new ItemUseFactory(item, direction));
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "set",
|
||||
desc = "Place a block"
|
||||
)
|
||||
public void set(CommandParameters parameters,
|
||||
Player player, LocalSession localSession,
|
||||
@Arg(desc = "The pattern of blocks to use")
|
||||
Pattern pattern) throws WorldEditException {
|
||||
setApplyBrush(parameters, player, localSession, new ReplaceFactory(pattern));
|
||||
}
|
||||
|
||||
}
|
@ -19,25 +19,23 @@
|
||||
|
||||
package com.sk89q.worldedit.command;
|
||||
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import com.boydti.fawe.config.Commands;
|
||||
import com.boydti.fawe.object.visitor.Fast2DIterator;
|
||||
import com.boydti.fawe.util.chat.Message;
|
||||
import static com.sk89q.worldedit.command.util.Logging.LogMode.REGION;
|
||||
|
||||
import com.sk89q.minecraft.util.commands.Command;
|
||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||
import com.sk89q.minecraft.util.commands.Logging;
|
||||
import static com.sk89q.minecraft.util.commands.Logging.LogMode.REGION;
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import com.boydti.fawe.object.visitor.Fast2DIterator;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
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.command.util.WorldEditAsyncCommandBuilder;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extension.platform.Capability;
|
||||
import com.sk89q.worldedit.function.FlatRegionFunction;
|
||||
import com.sk89q.worldedit.function.FlatRegionMaskingFilter;
|
||||
import com.sk89q.worldedit.function.RegionFunction;
|
||||
import com.sk89q.worldedit.function.biome.BiomeReplace;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.mask.Mask2D;
|
||||
@ -45,106 +43,84 @@ import com.sk89q.worldedit.function.operation.Operations;
|
||||
import com.sk89q.worldedit.function.visitor.FlatRegionVisitor;
|
||||
import com.sk89q.worldedit.function.visitor.RegionVisitor;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.regions.FlatRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.regions.Regions;
|
||||
import com.sk89q.worldedit.util.Countable;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.util.command.binding.Switch;
|
||||
import com.sk89q.worldedit.util.formatting.component.PaginationBox;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.biome.BiomeData;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.biome.BiomeTypes;
|
||||
import com.sk89q.worldedit.world.registry.BiomeRegistry;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import org.enginehub.piston.annotation.Command;
|
||||
import org.enginehub.piston.annotation.CommandContainer;
|
||||
import org.enginehub.piston.annotation.param.Arg;
|
||||
import org.enginehub.piston.annotation.param.ArgFlag;
|
||||
import org.enginehub.piston.annotation.param.Switch;
|
||||
|
||||
/**
|
||||
* Implements biome-related commands such as "/biomelist".
|
||||
*/
|
||||
@Command(aliases = {}, desc = "Change, list and inspect biomes")
|
||||
public class BiomeCommands extends MethodCommands {
|
||||
@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class)
|
||||
public class BiomeCommands {
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
*
|
||||
* @param worldEdit reference to WorldEdit
|
||||
*/
|
||||
public BiomeCommands(WorldEdit worldEdit) {
|
||||
super(worldEdit);
|
||||
}
|
||||
|
||||
private BiomeRegistry getBiomeRegistry() {
|
||||
return worldEdit.getPlatformManager().queryCapability(Capability.GAME_HOOKS).getRegistries().getBiomeRegistry();
|
||||
public BiomeCommands() {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "biomelist", "biomels" },
|
||||
usage = "[page]",
|
||||
desc = "Gets all biomes available.",
|
||||
max = 1
|
||||
name = "biomelist",
|
||||
aliases = { "biomels" },
|
||||
desc = "Gets all biomes available."
|
||||
)
|
||||
@CommandPermissions("worldedit.biome.list")
|
||||
public void biomeList(Player player, CommandContext args) throws WorldEditException {
|
||||
int page;
|
||||
int offset;
|
||||
int count = 0;
|
||||
public void biomeList(Actor actor,
|
||||
@ArgFlag(name = 'p', desc = "Page number.", def = "1")
|
||||
int page) {
|
||||
WorldEditAsyncCommandBuilder.createAndSendMessage(actor, () -> {
|
||||
BiomeRegistry biomeRegistry = WorldEdit.getInstance().getPlatformManager()
|
||||
.queryCapability(Capability.GAME_HOOKS).getRegistries().getBiomeRegistry();
|
||||
|
||||
if (args.argsLength() == 0 || (page = args.getInteger(0)) < 2) {
|
||||
page = 1;
|
||||
offset = 0;
|
||||
} else {
|
||||
offset = (page - 1) * 19;
|
||||
}
|
||||
|
||||
BiomeRegistry biomeRegistry = getBiomeRegistry();
|
||||
Collection<BiomeType> biomes = BiomeTypes.values();
|
||||
int totalPages = biomes.size() / 19 + 1;
|
||||
Message msg = BBC.BIOME_LIST_HEADER.m(page, totalPages);
|
||||
String setBiome = Commands.getAlias(BiomeCommands.class, "/setbiome");
|
||||
for (BiomeType biome : biomes) {
|
||||
if (offset > 0) {
|
||||
offset--;
|
||||
} else {
|
||||
BiomeData data = biomeRegistry.getData(biome);
|
||||
if (data != null) {
|
||||
msg.newline().text(data.getName()).cmdTip(setBiome + " " + data.getName());
|
||||
} else {
|
||||
msg.newline().text("<? #" + biome.getId() + ">").cmdTip(setBiome + " " + biome.getId());
|
||||
}
|
||||
if (++count == 18) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
msg.newline().paginate(getCommand().aliases()[0], page, totalPages);
|
||||
msg.send(player);
|
||||
PaginationBox paginationBox = PaginationBox.fromStrings("Available Biomes", "/biomelist -p %page%",
|
||||
BiomeType.REGISTRY.values().stream()
|
||||
.map(biomeType -> {
|
||||
String id = biomeType.getId();
|
||||
final BiomeData data = biomeRegistry.getData(biomeType);
|
||||
if (data != null) {
|
||||
String name = data.getName();
|
||||
return id + " (" + name + ")";
|
||||
} else {
|
||||
return id;
|
||||
}
|
||||
})
|
||||
.collect(Collectors.toList()));
|
||||
return paginationBox.create(page);
|
||||
}, null);
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "biomeinfo" },
|
||||
flags = "pt",
|
||||
name = "biomeinfo",
|
||||
desc = "Get the biome of the targeted block.",
|
||||
help =
|
||||
"Get the biome of the block.\n" +
|
||||
"By default use all the blocks contained in your selection.\n" +
|
||||
"-t use the block you are looking at.\n" +
|
||||
"-p use the block you are currently in",
|
||||
max = 0
|
||||
descFooter = "By default, uses all blocks in your selection."
|
||||
)
|
||||
@CommandPermissions("worldedit.biome.info")
|
||||
public void biomeInfo(Player player, LocalSession session, final EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
BiomeRegistry biomeRegistry = getBiomeRegistry();
|
||||
Collection<BiomeType> values = BiomeTypes.values();
|
||||
final int[] biomes = new int[values.size()];
|
||||
public void biomeInfo(Player player, LocalSession session, EditSession editSession,
|
||||
@Switch(name = 't', desc = "Use the block you are looking at.")
|
||||
boolean useLineOfSight,
|
||||
@Switch(name = 'p', desc = "Use the block you are currently in.")
|
||||
boolean usePosition) throws WorldEditException {
|
||||
BiomeRegistry biomeRegistry = WorldEdit.getInstance().getPlatformManager()
|
||||
.queryCapability(Capability.GAME_HOOKS).getRegistries().getBiomeRegistry();
|
||||
Set<BiomeType> biomes = new HashSet<>();
|
||||
String qualifier;
|
||||
|
||||
int size = 0;
|
||||
if (args.hasFlag('t')) {
|
||||
if (useLineOfSight) {
|
||||
Location blockPosition = player.getBlockTrace(300);
|
||||
if (blockPosition == null) {
|
||||
BBC.NO_BLOCK.send(player);
|
||||
@ -152,68 +128,56 @@ public class BiomeCommands extends MethodCommands {
|
||||
}
|
||||
|
||||
BiomeType biome = player.getWorld().getBiome(blockPosition.toBlockPoint().toBlockVector2());
|
||||
biomes[biome.getInternalId()]++;
|
||||
size = 1;
|
||||
} else if (args.hasFlag('p')) {
|
||||
biomes.add(biome);
|
||||
|
||||
qualifier = "at line of sight point";
|
||||
} else if (usePosition) {
|
||||
BiomeType biome = player.getWorld().getBiome(player.getLocation().toBlockPoint().toBlockVector2());
|
||||
biomes[biome.getInternalId()]++;
|
||||
size = 1;
|
||||
biomes.add(biome);
|
||||
|
||||
qualifier = "at your position";
|
||||
} else {
|
||||
World world = player.getWorld();
|
||||
Region region = session.getSelection(world);
|
||||
|
||||
if (region instanceof FlatRegion) {
|
||||
for (BlockVector2 pt : new Fast2DIterator(((FlatRegion) region).asFlatRegion(), editSession)) {
|
||||
biomes[editSession.getBiome(pt).getInternalId()]++;
|
||||
size++;
|
||||
biomes.add(world.getBiome(pt));
|
||||
}
|
||||
} else {
|
||||
RegionVisitor visitor = new RegionVisitor(region, new RegionFunction() {
|
||||
@Override
|
||||
public boolean apply(BlockVector3 position) throws WorldEditException {
|
||||
biomes[editSession.getBiome(position.toBlockVector2()).getInternalId()]++;
|
||||
return true;
|
||||
}
|
||||
RegionVisitor visitor = new RegionVisitor(region, position -> {
|
||||
biomes.add(world.getBiome(position.toBlockVector2()));
|
||||
return true;
|
||||
}, editSession);
|
||||
Operations.completeBlindly(visitor);
|
||||
size += visitor.getAffected();
|
||||
}
|
||||
|
||||
qualifier = "in your selection";
|
||||
}
|
||||
|
||||
BBC.BIOME_LIST_HEADER.send(player, 1, 1);
|
||||
|
||||
List<Countable<BiomeType>> distribution = new ArrayList<>();
|
||||
for (int i = 0; i < biomes.length; i++) {
|
||||
int count = biomes[i];
|
||||
if (count != 0) {
|
||||
distribution.add(new Countable<>(BiomeTypes.get(i), count));
|
||||
player.print(biomes.size() != 1 ? "Biomes " + qualifier + ":" : "Biome " + qualifier + ":");
|
||||
for (BiomeType biome : biomes) {
|
||||
BiomeData data = biomeRegistry.getData(biome);
|
||||
if (data != null) {
|
||||
player.print(" " + data.getName());
|
||||
} else {
|
||||
player.print(" <unknown #" + biome.getId() + ">");
|
||||
}
|
||||
}
|
||||
Collections.sort(distribution);
|
||||
for (Countable<BiomeType> c : distribution) {
|
||||
BiomeData data = biomeRegistry.getData(c.getID());
|
||||
String str = String.format("%-7s (%.3f%%) %s #%d",
|
||||
String.valueOf(c.getAmount()),
|
||||
c.getAmount() / (double) size * 100,
|
||||
data == null ? "Unknown" : data.getName(),
|
||||
c.getID().getInternalId());
|
||||
player.print(str);
|
||||
}
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "/setbiome" },
|
||||
usage = "<biome>",
|
||||
flags = "p",
|
||||
desc = "Sets the biome of the player's current block or region.",
|
||||
help =
|
||||
"Set the biome of the region.\n" +
|
||||
"By default use all the blocks contained in your selection.\n" +
|
||||
"-p use the block you are currently in"
|
||||
name = "/setbiome",
|
||||
desc = "Sets the biome of your current block or region.",
|
||||
descFooter = "By default, uses all the blocks in your selection"
|
||||
)
|
||||
@Logging(REGION)
|
||||
@CommandPermissions("worldedit.biome.set")
|
||||
public void setBiome(Player player, LocalSession session, EditSession editSession, BiomeType target, @Switch('p') boolean atPosition) throws WorldEditException {
|
||||
public void setBiome(Player player, LocalSession session, EditSession editSession,
|
||||
@Arg(desc = "Biome type.") BiomeType target,
|
||||
@Switch(name = 'p', desc = "Use your current position")
|
||||
boolean atPosition) throws WorldEditException {
|
||||
World world = player.getWorld();
|
||||
Region region;
|
||||
Mask mask = editSession.getMask();
|
||||
@ -233,8 +197,9 @@ public class BiomeCommands extends MethodCommands {
|
||||
Operations.completeLegacy(visitor);
|
||||
|
||||
BBC.BIOME_CHANGED.send(player, visitor.getAffected());
|
||||
if (!player.hasPermission("fawe.tips"))
|
||||
if (!player.hasPermission("fawe.tips")) {
|
||||
BBC.TIP_BIOME_PATTERN.or(BBC.TIP_BIOME_MASK).send(player);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -11,30 +11,27 @@ import com.boydti.fawe.object.extent.ResettableExtent;
|
||||
import com.boydti.fawe.object.io.PGZIPOutputStream;
|
||||
import com.boydti.fawe.util.MainUtil;
|
||||
import com.boydti.fawe.util.MathMan;
|
||||
import com.sk89q.minecraft.util.commands.Command;
|
||||
|
||||
import org.enginehub.piston.annotation.Command;
|
||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.blocks.BaseItem;
|
||||
import com.sk89q.worldedit.command.tool.BrushTool;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.event.platform.CommandEvent;
|
||||
import com.sk89q.worldedit.extension.input.ParserContext;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extension.platform.CommandManager;
|
||||
import com.sk89q.worldedit.extension.platform.PlatformCommandManager;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.util.HandSide;
|
||||
import com.sk89q.worldedit.util.command.binding.Range;
|
||||
import com.sk89q.worldedit.util.command.binding.Switch;
|
||||
import com.sk89q.worldedit.util.command.parametric.Optional;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
@ -163,16 +160,14 @@ public class BrushOptionsCommands extends MethodCommands {
|
||||
max = 0
|
||||
)
|
||||
public void none(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||
session.setTool(null, player);
|
||||
session.setTool(player, null);
|
||||
BBC.TOOL_NONE.send(player);
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"/", ","},
|
||||
usage = "[on|off]",
|
||||
desc = "Toggle the super pickaxe function",
|
||||
min = 0,
|
||||
max = 1
|
||||
desc = "Toggle the super pickaxe function"
|
||||
)
|
||||
@CommandPermissions("worldedit.superpickaxe")
|
||||
public void togglePickaxe(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||
@ -210,8 +205,8 @@ public class BrushOptionsCommands extends MethodCommands {
|
||||
session.setTool(item, null, player);
|
||||
String cmd = "brush " + args.getJoinedStrings(0);
|
||||
CommandEvent event = new CommandEvent(player, cmd);
|
||||
CommandManager.getInstance().handleCommandOnCurrentThread(event);
|
||||
BrushTool newTool = session.getBrushTool(item, player, false);
|
||||
PlatformCommandManager.getInstance().handleCommandOnCurrentThread(event);
|
||||
BrushTool newTool = session.getBrushTool(item.getType(), player, false);
|
||||
if (newTool != null && tool != null) {
|
||||
newTool.setSecondary(tool.getSecondary());
|
||||
}
|
||||
@ -231,8 +226,8 @@ public class BrushOptionsCommands extends MethodCommands {
|
||||
session.setTool(item, null, player);
|
||||
String cmd = "brush " + args.getJoinedStrings(0);
|
||||
CommandEvent event = new CommandEvent(player, cmd);
|
||||
CommandManager.getInstance().handleCommandOnCurrentThread(event);
|
||||
BrushTool newTool = session.getBrushTool(item, player, false);
|
||||
PlatformCommandManager.getInstance().handleCommandOnCurrentThread(event);
|
||||
BrushTool newTool = session.getBrushTool(item.getType(), player, false);
|
||||
if (newTool != null && tool != null) {
|
||||
newTool.setPrimary(tool.getPrimary());
|
||||
}
|
||||
|
@ -1,77 +0,0 @@
|
||||
package com.sk89q.worldedit.command;
|
||||
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import com.boydti.fawe.object.brush.BrushSettings;
|
||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||
import com.sk89q.minecraft.util.commands.CommandLocals;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.command.tool.BrushTool;
|
||||
import com.sk89q.worldedit.command.tool.InvalidToolBindException;
|
||||
import com.sk89q.worldedit.command.tool.brush.Brush;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.util.command.CallableProcessor;
|
||||
import com.sk89q.worldedit.util.command.CommandCallable;
|
||||
import com.sk89q.worldedit.util.command.parametric.AParametricCallable;
|
||||
|
||||
public class BrushProcessor extends MethodCommands implements CallableProcessor<BrushSettings> {
|
||||
private final WorldEdit worldEdit;
|
||||
|
||||
public BrushProcessor(WorldEdit worldEdit) {
|
||||
this.worldEdit = worldEdit;
|
||||
}
|
||||
|
||||
public WorldEdit getWorldEdit() {
|
||||
return worldEdit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BrushSettings process(CommandLocals locals, BrushSettings settings) throws WorldEditException {
|
||||
Actor actor = locals.get(Actor.class);
|
||||
LocalSession session = worldEdit.getSessionManager().get(actor);
|
||||
session.setTool(null, (Player) actor);
|
||||
BrushTool tool = session.getBrushTool((Player) actor);
|
||||
if (tool != null) {
|
||||
tool.setPrimary(settings);
|
||||
tool.setSecondary(settings);
|
||||
BBC.BRUSH_EQUIPPED.send(actor, ((String) locals.get("arguments")).split(" ")[1]);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public BrushSettings set(LocalSession session, CommandContext context, Brush brush) throws InvalidToolBindException {
|
||||
CommandLocals locals = context.getLocals();
|
||||
Actor actor = locals.get(Actor.class);
|
||||
BrushSettings bs = new BrushSettings();
|
||||
|
||||
BrushTool tool = session.getBrushTool((Player) actor, false);
|
||||
if (tool != null) {
|
||||
BrushSettings currentContext = tool.getContext();
|
||||
if (currentContext != null) {
|
||||
Brush currentBrush = currentContext.getBrush();
|
||||
if (currentBrush != null && currentBrush.getClass() == brush.getClass()) {
|
||||
bs = currentContext;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CommandCallable callable = locals.get(CommandCallable.class);
|
||||
String[] perms;
|
||||
if (callable != null && callable instanceof AParametricCallable) {
|
||||
perms = ((AParametricCallable) callable).getPermissions();
|
||||
} else {
|
||||
perms = getPermissions();
|
||||
}
|
||||
bs.addPermissions(perms);
|
||||
|
||||
if (locals != null) {
|
||||
String args = (String) locals.get("arguments");
|
||||
if (args != null) {
|
||||
bs.addSetting(BrushSettings.SettingType.BRUSH, args.substring(args.indexOf(' ') + 1));
|
||||
}
|
||||
}
|
||||
return bs.setBrush(brush);
|
||||
}
|
||||
}
|
@ -19,36 +19,47 @@
|
||||
|
||||
package com.sk89q.worldedit.command;
|
||||
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import com.sk89q.minecraft.util.commands.Command;
|
||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||
import com.sk89q.minecraft.util.commands.Logging;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.LocalConfiguration;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.sk89q.worldedit.command.util.Logging.LogMode.REGION;
|
||||
import static com.sk89q.worldedit.internal.anvil.ChunkDeleter.DELCHUNKS_FILE_NAME;
|
||||
|
||||
import com.google.gson.JsonIOException;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
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.internal.anvil.ChunkDeleter;
|
||||
import com.sk89q.worldedit.internal.anvil.ChunkDeletionInfo;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.MathUtils;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.util.formatting.component.PaginationBox;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.event.ClickEvent;
|
||||
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
|
||||
import com.sk89q.worldedit.world.storage.LegacyChunkStore;
|
||||
import com.sk89q.worldedit.world.storage.McRegionChunkStore;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.sk89q.minecraft.util.commands.Logging.LogMode.REGION;
|
||||
import java.util.stream.Collectors;
|
||||
import org.enginehub.piston.annotation.Command;
|
||||
import org.enginehub.piston.annotation.CommandContainer;
|
||||
import org.enginehub.piston.annotation.param.ArgFlag;
|
||||
import org.enginehub.piston.exception.StopExecutionException;
|
||||
|
||||
/**
|
||||
* Commands for working with chunks.
|
||||
*/
|
||||
@Command(aliases = {}, desc = "[legacy] Inspect chunks: [More Info](http://wiki.sk89q.com/wiki/WorldEdit/Chunk_tools)")
|
||||
@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class)
|
||||
public class ChunkCommands {
|
||||
|
||||
private final WorldEdit worldEdit;
|
||||
@ -59,131 +70,101 @@ public class ChunkCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"chunkinfo"},
|
||||
usage = "",
|
||||
desc = "Get information about the chunk that you are inside",
|
||||
min = 0,
|
||||
max = 0
|
||||
name = "chunkinfo",
|
||||
desc = "Get information about the chunk you're inside"
|
||||
)
|
||||
@CommandPermissions("worldedit.chunkinfo")
|
||||
public void chunkInfo(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||
public void chunkInfo(Player player) {
|
||||
Location pos = player.getBlockIn();
|
||||
int chunkX = (int) Math.floor(pos.getBlockX() / 16.0);
|
||||
int chunkZ = (int) Math.floor(pos.getBlockZ() / 16.0);
|
||||
|
||||
String folder1 = Integer.toString(MathUtils.divisorMod(chunkX, 64), 36);
|
||||
String folder2 = Integer.toString(MathUtils.divisorMod(chunkZ, 64), 36);
|
||||
String filename = "c." + Integer.toString(chunkX, 36)
|
||||
+ "." + Integer.toString(chunkZ, 36) + ".dat";
|
||||
|
||||
final BlockVector2 chunkPos = BlockVector2.at(chunkX, chunkZ);
|
||||
player.print("Chunk: " + chunkX + ", " + chunkZ);
|
||||
player.print("Old format: " + folder1 + "/" + folder2 + "/" + filename);
|
||||
player.print("McRegion: region/" + McRegionChunkStore.getFilename(
|
||||
BlockVector2.at(chunkX, chunkZ)));
|
||||
player.print("Old format: " + LegacyChunkStore.getFilename(chunkPos));
|
||||
player.print("McRegion: region/" + McRegionChunkStore.getFilename(chunkPos));
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"listchunks"},
|
||||
usage = "",
|
||||
desc = "List chunks that your selection includes",
|
||||
min = 0,
|
||||
max = 0
|
||||
name = "listchunks",
|
||||
desc = "List chunks that your selection includes"
|
||||
)
|
||||
@CommandPermissions("worldedit.listchunks")
|
||||
public void listChunks(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
public void listChunks(Player player, LocalSession session,
|
||||
@ArgFlag(name = 'p', desc = "Page number.", def = "1") int page) throws WorldEditException {
|
||||
Set<BlockVector2> chunks = session.getSelection(player.getWorld()).getChunks();
|
||||
|
||||
for (BlockVector2 chunk : chunks) {
|
||||
player.print(LegacyChunkStore.getFilename(chunk));
|
||||
}
|
||||
PaginationBox paginationBox = PaginationBox.fromStrings("Selected Chunks", "/listchunks -p %page%",
|
||||
chunks.stream().map(LegacyChunkStore::getFilename).collect(Collectors.toList()));
|
||||
player.print(paginationBox.create(page));
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"delchunks"},
|
||||
usage = "",
|
||||
desc = "Deprecated, use anvil commands",
|
||||
min = 0,
|
||||
max = 0
|
||||
name = "delchunks",
|
||||
desc = "Delete chunks that your selection includes"
|
||||
)
|
||||
@CommandPermissions("worldedit.delchunks")
|
||||
@Logging(REGION)
|
||||
public void deleteChunks(Player player, LocalSession session) throws WorldEditException {
|
||||
player.print("Note that this command does not yet support the mcregion format.");
|
||||
LocalConfiguration config = worldEdit.getConfiguration();
|
||||
|
||||
Set<BlockVector2> chunks = session.getSelection(player.getWorld()).getChunks();
|
||||
FileOutputStream out = null;
|
||||
|
||||
if (config.shellSaveType == null) {
|
||||
player.printError("Shell script type must be configured: 'bat' or 'bash' expected.");
|
||||
} else if (config.shellSaveType.equalsIgnoreCase("bat")) {
|
||||
try {
|
||||
out = new FileOutputStream("worldedit-delchunks.bat");
|
||||
OutputStreamWriter writer = new OutputStreamWriter(out, "UTF-8");
|
||||
writer.write("@ECHO off\r\n");
|
||||
writer.write("ECHO This batch file was generated by FAWE.\r\n");
|
||||
writer.write("ECHO It contains a list of chunks that were in the selected region\r\n");
|
||||
writer.write("ECHO at the time that the /delchunks command was used. Run this file\r\n");
|
||||
writer.write("ECHO in order to delete the chunk files listed in this file.\r\n");
|
||||
writer.write("ECHO.\r\n");
|
||||
writer.write("PAUSE\r\n");
|
||||
|
||||
for (BlockVector2 chunk : chunks) {
|
||||
String filename = LegacyChunkStore.getFilename(chunk);
|
||||
writer.write("ECHO " + filename + "\r\n");
|
||||
writer.write("DEL \"world/" + filename + "\"\r\n");
|
||||
}
|
||||
|
||||
writer.write("ECHO Complete.\r\n");
|
||||
writer.write("PAUSE\r\n");
|
||||
writer.close();
|
||||
player.print("worldedit-delchunks.bat written. Run it when no one is near the region.");
|
||||
} catch (IOException e) {
|
||||
player.printError("Error occurred: " + e.getMessage());
|
||||
} finally {
|
||||
if (out != null) {
|
||||
try {
|
||||
out.close();
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (config.shellSaveType.equalsIgnoreCase("bash")) {
|
||||
try {
|
||||
out = new FileOutputStream("worldedit-delchunks.sh");
|
||||
OutputStreamWriter writer = new OutputStreamWriter(out, "UTF-8");
|
||||
writer.write("#!/bin/bash\n");
|
||||
writer.write("echo This shell file was generated by FAWE.\n");
|
||||
writer.write("echo It contains a list of chunks that were in the selected region\n");
|
||||
writer.write("echo at the time that the /delchunks command was used. Run this file\n");
|
||||
writer.write("echo in order to delete the chunk files listed in this file.\n");
|
||||
writer.write("echo\n");
|
||||
writer.write("read -p \"Press any key to continue...\"\n");
|
||||
|
||||
for (BlockVector2 chunk : chunks) {
|
||||
String filename = LegacyChunkStore.getFilename(chunk);
|
||||
writer.write("echo " + filename + "\n");
|
||||
writer.write("rm \"world/" + filename + "\"\n");
|
||||
}
|
||||
|
||||
writer.write("echo Complete.\n");
|
||||
writer.write("read -p \"Press any key to continue...\"\n");
|
||||
writer.close();
|
||||
player.print("worldedit-delchunks.sh written. Run it when no one is near the region.");
|
||||
player.print("You will have to chmod it to be executable.");
|
||||
} catch (IOException e) {
|
||||
player.printError("Error occurred: " + e.getMessage());
|
||||
} finally {
|
||||
if (out != null) {
|
||||
try {
|
||||
out.close();
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
player.printError("Shell script type must be configured: 'bat' or 'bash' expected.");
|
||||
public void deleteChunks(Player player, LocalSession session,
|
||||
@ArgFlag(name = 'o', desc = "Only delete chunks older than the specified time.", def = "")
|
||||
ZonedDateTime beforeTime) throws WorldEditException {
|
||||
Path worldDir = player.getWorld().getStoragePath();
|
||||
if (worldDir == null) {
|
||||
throw new StopExecutionException(TextComponent.of("Couldn't find world folder for this world."));
|
||||
}
|
||||
|
||||
File chunkFile = worldEdit.getWorkingDirectoryFile(DELCHUNKS_FILE_NAME);
|
||||
Path chunkPath = chunkFile.toPath();
|
||||
ChunkDeletionInfo currentInfo = null;
|
||||
if (Files.exists(chunkPath)) {
|
||||
try {
|
||||
currentInfo = ChunkDeleter.readInfo(chunkFile.toPath());
|
||||
} catch (IOException e) {
|
||||
throw new StopExecutionException(TextComponent.of("Error reading existing chunk file."));
|
||||
}
|
||||
}
|
||||
if (currentInfo == null) {
|
||||
currentInfo = new ChunkDeletionInfo();
|
||||
currentInfo.batches = new ArrayList<>();
|
||||
}
|
||||
|
||||
ChunkDeletionInfo.ChunkBatch newBatch = new ChunkDeletionInfo.ChunkBatch();
|
||||
newBatch.worldPath = worldDir.toAbsolutePath().normalize().toString();
|
||||
newBatch.backup = true;
|
||||
final Region selection = session.getSelection(player.getWorld());
|
||||
if (selection instanceof CuboidRegion) {
|
||||
newBatch.minChunk = BlockVector2.at(selection.getMinimumPoint().getBlockX() >> 4, selection.getMinimumPoint().getBlockZ() >> 4);
|
||||
newBatch.maxChunk = BlockVector2.at(selection.getMaximumPoint().getBlockX() >> 4, selection.getMaximumPoint().getBlockZ() >> 4);
|
||||
} else {
|
||||
// this has a possibility to OOM for very large selections still
|
||||
Set<BlockVector2> chunks = selection.getChunks();
|
||||
newBatch.chunks = new ArrayList<>(chunks);
|
||||
}
|
||||
if (beforeTime != null) {
|
||||
newBatch.deletionPredicates = new ArrayList<>();
|
||||
ChunkDeletionInfo.DeletionPredicate timePred = new ChunkDeletionInfo.DeletionPredicate();
|
||||
timePred.property = "modification";
|
||||
timePred.comparison = "<";
|
||||
timePred.value = String.valueOf((int) beforeTime.toOffsetDateTime().toEpochSecond());
|
||||
newBatch.deletionPredicates.add(timePred);
|
||||
}
|
||||
currentInfo.batches.add(newBatch);
|
||||
|
||||
try {
|
||||
ChunkDeleter.writeInfo(currentInfo, chunkPath);
|
||||
} catch (IOException | JsonIOException e) {
|
||||
throw new StopExecutionException(TextComponent.of("Failed to write chunk list: " + e.getMessage()));
|
||||
}
|
||||
|
||||
player.print(String.format("%d chunk(s) have been marked for deletion the next time the server starts.",
|
||||
newBatch.getChunkCount()));
|
||||
if (currentInfo.batches.size() > 1) {
|
||||
player.printDebug(String.format("%d chunks total marked for deletion. (May have overlaps).",
|
||||
currentInfo.batches.stream().mapToInt(ChunkDeletionInfo.ChunkBatch::getChunkCount).sum()));
|
||||
}
|
||||
player.print(TextComponent.of("You can mark more chunks for deletion, or to stop now, run: ", TextColor.LIGHT_PURPLE)
|
||||
.append(TextComponent.of("/stop", TextColor.AQUA)
|
||||
.clickEvent(ClickEvent.of(ClickEvent.Action.SUGGEST_COMMAND, "/stop"))));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -36,16 +36,18 @@ import com.boydti.fawe.util.ImgurUtility;
|
||||
import com.boydti.fawe.util.MainUtil;
|
||||
import com.boydti.fawe.util.MaskTraverser;
|
||||
|
||||
import com.sk89q.minecraft.util.commands.Command;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||
import com.sk89q.minecraft.util.commands.CommandException;
|
||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||
import com.sk89q.minecraft.util.commands.Logging;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.LocalConfiguration;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.command.util.CommandPermissions;
|
||||
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
|
||||
import com.sk89q.worldedit.command.util.Logging;
|
||||
import static com.sk89q.worldedit.command.util.Logging.LogMode.PLACEMENT;
|
||||
import static com.sk89q.worldedit.command.util.Logging.LogMode.REGION;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.event.extent.PasteEvent;
|
||||
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
|
||||
@ -71,8 +73,11 @@ import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.regions.RegionSelector;
|
||||
import com.sk89q.worldedit.regions.selector.CuboidRegionSelector;
|
||||
import com.sk89q.worldedit.session.ClipboardHolder;
|
||||
import com.sk89q.worldedit.util.command.binding.Switch;
|
||||
import com.sk89q.worldedit.util.command.parametric.Optional;
|
||||
import org.enginehub.piston.annotation.Command;
|
||||
import org.enginehub.piston.annotation.CommandContainer;
|
||||
import org.enginehub.piston.annotation.param.Arg;
|
||||
import org.enginehub.piston.annotation.param.ArgFlag;
|
||||
import org.enginehub.piston.annotation.param.Switch;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@ -86,16 +91,11 @@ import java.util.Set;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.sk89q.minecraft.util.commands.Logging.LogMode.PLACEMENT;
|
||||
import static com.sk89q.minecraft.util.commands.Logging.LogMode.REGION;
|
||||
|
||||
|
||||
/**
|
||||
* Clipboard commands.
|
||||
*/
|
||||
@Command(aliases = {}, desc = "Related commands to copy and pasting blocks: [More Info](https://goo.gl/z2ScQR)")
|
||||
public class ClipboardCommands extends MethodCommands {
|
||||
@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class)
|
||||
public class ClipboardCommands {
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
@ -107,79 +107,36 @@ public class ClipboardCommands extends MethodCommands {
|
||||
checkNotNull(worldEdit);
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "/lazycopy" },
|
||||
flags = "em",
|
||||
desc = "Lazily copy the selection to the clipboard",
|
||||
help = "Lazily copy the selection to the clipboard\n" +
|
||||
"Flags:\n" +
|
||||
" -e skips copying entities\n" +
|
||||
" -m sets a source mask so that excluded blocks become air\n" +
|
||||
" -b copies biomes\n" +
|
||||
"WARNING: Pasting entities cannot yet be undone!",
|
||||
max = 0
|
||||
)
|
||||
@CommandPermissions("worldedit.clipboard.lazycopy")
|
||||
public void lazyCopy(Player player, LocalSession session, EditSession editSession,
|
||||
@Selection final Region region, @Switch('e') boolean skipEntities,
|
||||
@Switch('m') Mask mask, @Switch('b') boolean copyBiomes) throws WorldEditException {
|
||||
BlockVector3 min = region.getMinimumPoint();
|
||||
BlockVector3 max = region.getMaximumPoint();
|
||||
long volume = (((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1));
|
||||
FaweLimit limit = FawePlayer.wrap(player).getLimit();
|
||||
if (volume >= limit.MAX_CHECKS) {
|
||||
throw new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_CHECKS);
|
||||
}
|
||||
session.setClipboard(null);
|
||||
final BlockVector3 origin = region.getMinimumPoint();
|
||||
final int mx = origin.getBlockX();
|
||||
final int my = origin.getBlockY();
|
||||
final int mz = origin.getBlockZ();
|
||||
ReadOnlyClipboard lazyClipboard = ReadOnlyClipboard.of(editSession, region, !skipEntities, copyBiomes);
|
||||
|
||||
BlockArrayClipboard clipboard = new BlockArrayClipboard(region, lazyClipboard);
|
||||
clipboard.setOrigin(session.getPlacementPosition(player));
|
||||
session.setClipboard(new ClipboardHolder(clipboard));
|
||||
BBC.COMMAND_COPY.send(player, region.getArea());
|
||||
if (!player.hasPermission("fawe.tips"))
|
||||
BBC.TIP_PASTE.or(BBC.TIP_LAZYCOPY, BBC.TIP_DOWNLOAD, BBC.TIP_ROTATE, BBC.TIP_COPYPASTE, BBC.TIP_REPLACE_MARKER, BBC.TIP_COPY_PATTERN).send(player);
|
||||
}
|
||||
|
||||
|
||||
@Command(
|
||||
aliases = { "/copy", "/c" },
|
||||
flags = "em",
|
||||
desc = "Copy the selection to the clipboard",
|
||||
help = "Copy the selection to the clipboard\n" +
|
||||
"Flags:\n" +
|
||||
" -e skips copying entities\n" +
|
||||
" -m sets a source mask so that excluded blocks become air\n" +
|
||||
" -b copies biomes\n" +
|
||||
"WARNING: Pasting entities cannot yet be undone!",
|
||||
min = 0,
|
||||
max = 0
|
||||
name = "/copy",
|
||||
desc = "Copy the selection to the clipboard"
|
||||
)
|
||||
@CommandPermissions("worldedit.clipboard.copy")
|
||||
public void copy(FawePlayer fp, Player player, LocalSession session, EditSession editSession,
|
||||
@Selection Region region, @Switch('e') boolean skipEntities,
|
||||
@Switch('m') Mask mask, CommandContext context, @Switch('b') boolean copyBiomes) throws WorldEditException {
|
||||
BlockVector3 min = region.getMinimumPoint();
|
||||
BlockVector3 max = region.getMaximumPoint();
|
||||
@Selection Region region,
|
||||
@Switch(name = 'e', desc = "Also copy entities")
|
||||
boolean copyEntities,
|
||||
@Switch(name = 'b', desc = "Also copy biomes")
|
||||
boolean copyBiomes,
|
||||
@ArgFlag(name = 'm', desc = "Set the exclude mask, matching blocks become air", def = "")
|
||||
Mask mask, CommandContext context) throws WorldEditException {
|
||||
BlockVector3 min = region.getMinimumPoint();
|
||||
BlockVector3 max = region.getMaximumPoint();
|
||||
long volume = (((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1));
|
||||
FaweLimit limit = FawePlayer.wrap(player).getLimit();
|
||||
if (volume >= limit.MAX_CHECKS) {
|
||||
throw new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_CHECKS);
|
||||
}
|
||||
BlockVector3 pos = session.getPlacementPosition(player);
|
||||
fp.checkConfirmationRegion(() -> {
|
||||
session.setClipboard(null);
|
||||
BlockArrayClipboard clipboard = new BlockArrayClipboard(region, player.getUniqueId());
|
||||
session.setClipboard(new ClipboardHolder(clipboard));
|
||||
|
||||
clipboard.setOrigin(pos);
|
||||
clipboard.setOrigin(session.getPlacementPosition(player));
|
||||
ForwardExtentCopy copy = new ForwardExtentCopy(editSession, region, clipboard, region.getMinimumPoint());
|
||||
copy.setCopyingEntities(!skipEntities);
|
||||
copy.setCopyBiomes(copyBiomes);
|
||||
copy.setCopyingEntities(copyEntities);
|
||||
copy.setCopyingBiomes(copyBiomes);
|
||||
Mask sourceMask = editSession.getSourceMask();
|
||||
if (sourceMask != null) {
|
||||
new MaskTraverser(sourceMask).reset(editSession);
|
||||
@ -198,23 +155,52 @@ public class ClipboardCommands extends MethodCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"/lazycut"},
|
||||
flags = "em",
|
||||
desc = "Lazily cut the selection to the clipboard",
|
||||
help = "Lazily cut the selection to the clipboard\n" +
|
||||
"Flags:\n" +
|
||||
" -e skips entity copy\n" +
|
||||
" -m sets a source mask so that excluded blocks become air\n" +
|
||||
" -b copies biomes\n" +
|
||||
"WARNING: Pasting entities cannot yet be undone!",
|
||||
max = 0
|
||||
name = "/lazycopy",
|
||||
desc = "Lazily copy the selection to the clipboard"
|
||||
)
|
||||
@CommandPermissions("worldedit.clipboard.lazycopy")
|
||||
public void lazyCopy(Player player, LocalSession session, EditSession editSession,
|
||||
@Selection Region region,
|
||||
@Switch(name = 'e', desc = "Also copy entities")
|
||||
boolean copyEntities,
|
||||
@ArgFlag(name = 'm', desc = "Set the exclude mask, matching blocks become air", def = "")
|
||||
Mask mask,
|
||||
@Switch(name = 'b', desc = "Also copy biomes")
|
||||
boolean copyBiomes) throws WorldEditException {
|
||||
BlockVector3 min = region.getMinimumPoint();
|
||||
BlockVector3 max = region.getMaximumPoint();
|
||||
long volume = (((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1));
|
||||
FaweLimit limit = FawePlayer.wrap(player).getLimit();
|
||||
if (volume >= limit.MAX_CHECKS) {
|
||||
throw new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_CHECKS);
|
||||
}
|
||||
session.setClipboard(null);
|
||||
ReadOnlyClipboard lazyClipboard = ReadOnlyClipboard.of(editSession, region, copyEntities, copyBiomes);
|
||||
|
||||
BlockArrayClipboard clipboard = new BlockArrayClipboard(region, lazyClipboard);
|
||||
clipboard.setOrigin(session.getPlacementPosition(player));
|
||||
session.setClipboard(new ClipboardHolder(clipboard));
|
||||
BBC.COMMAND_COPY.send(player, region.getArea());
|
||||
if (!player.hasPermission("fawe.tips")) {
|
||||
BBC.TIP_PASTE.or(BBC.TIP_LAZYCOPY, BBC.TIP_DOWNLOAD, BBC.TIP_ROTATE, BBC.TIP_COPYPASTE, BBC.TIP_REPLACE_MARKER, BBC.TIP_COPY_PATTERN).send(player);
|
||||
}
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "/lazycut",
|
||||
desc = "Lazily cut the selection to the clipboard"
|
||||
)
|
||||
@CommandPermissions("worldedit.clipboard.lazycut")
|
||||
public void lazyCut(Player player, LocalSession session, EditSession editSession,
|
||||
@Selection final Region region, @Switch('e') boolean skipEntities,
|
||||
@Switch('m') Mask mask, @Switch('b') boolean copyBiomes) throws WorldEditException {
|
||||
BlockVector3 min = region.getMinimumPoint();
|
||||
BlockVector3 max = region.getMaximumPoint();
|
||||
@Selection final Region region,
|
||||
@Switch(name = 'e', desc = "Also copy entities")
|
||||
boolean copyEntities,
|
||||
@ArgFlag(name = 'm', desc = "Set the exclude mask, matching blocks become air", def = "")
|
||||
Mask mask,
|
||||
@Switch(name = 'b', desc = "Also copy biomes")
|
||||
boolean copyBiomes) throws WorldEditException {
|
||||
BlockVector3 min = region.getMinimumPoint();
|
||||
BlockVector3 max = region.getMaximumPoint();
|
||||
long volume = (((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1));
|
||||
FaweLimit limit = FawePlayer.wrap(player).getLimit();
|
||||
if (volume >= limit.MAX_CHECKS) {
|
||||
@ -224,11 +210,7 @@ public class ClipboardCommands extends MethodCommands {
|
||||
throw new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_CHANGES);
|
||||
}
|
||||
session.setClipboard(null);
|
||||
final BlockVector3 origin = region.getMinimumPoint();
|
||||
final int mx = origin.getBlockX();
|
||||
final int my = origin.getBlockY();
|
||||
final int mz = origin.getBlockZ();
|
||||
ReadOnlyClipboard lazyClipboard = new WorldCutClipboard(editSession, region, !skipEntities, copyBiomes);
|
||||
ReadOnlyClipboard lazyClipboard = new WorldCutClipboard(editSession, region, copyEntities, copyBiomes);
|
||||
BlockArrayClipboard clipboard = new BlockArrayClipboard(region, lazyClipboard);
|
||||
clipboard.setOrigin(session.getPlacementPosition(player));
|
||||
session.setClipboard(new ClipboardHolder(clipboard));
|
||||
@ -236,25 +218,25 @@ public class ClipboardCommands extends MethodCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "/cut" },
|
||||
flags = "em",
|
||||
usage = "[leave-id]",
|
||||
name = "/cut",
|
||||
desc = "Cut the selection to the clipboard",
|
||||
help = "Copy the selection to the clipboard\n" +
|
||||
"Flags:\n" +
|
||||
" -e skips entity copy\n" +
|
||||
" -m sets a source mask so that excluded blocks become air\n" +
|
||||
" -b copies biomes\n" +
|
||||
"WARNING: Cutting and pasting entities cannot yet be undone!",
|
||||
max = 1
|
||||
descFooter = "WARNING: Cutting and pasting entities cannot be undone!"
|
||||
)
|
||||
@CommandPermissions("worldedit.clipboard.cut")
|
||||
@Logging(REGION)
|
||||
public void cut(FawePlayer fp, Player player, LocalSession session, EditSession editSession,
|
||||
@Selection Region region, @Optional("air") Pattern leavePattern, @Switch('e') boolean skipEntities,
|
||||
@Switch('m') Mask mask, @Switch('b') boolean copyBiomes, CommandContext context) throws WorldEditException {
|
||||
BlockVector3 min = region.getMinimumPoint();
|
||||
BlockVector3 max = region.getMaximumPoint();
|
||||
@Selection Region region,
|
||||
@Arg(desc = "Pattern to leave in place of the selection", def = "air")
|
||||
Pattern leavePattern,
|
||||
@Switch(name = 'e', desc = "Also cut entities")
|
||||
boolean copyEntities,
|
||||
@Switch(name = 'b', desc = "Also copy biomes, source biomes are unaffected")
|
||||
boolean copyBiomes,
|
||||
@ArgFlag(name = 'm', desc = "Set the exclude mask, matching blocks become air", def = "")
|
||||
Mask mask,
|
||||
CommandContext context) throws WorldEditException {
|
||||
BlockVector3 min = region.getMinimumPoint();
|
||||
BlockVector3 max = region.getMaximumPoint();
|
||||
long volume = (((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1));
|
||||
FaweLimit limit = FawePlayer.wrap(player).getLimit();
|
||||
if (volume >= limit.MAX_CHECKS) {
|
||||
@ -263,16 +245,15 @@ public class ClipboardCommands extends MethodCommands {
|
||||
if (volume >= limit.MAX_CHANGES) {
|
||||
throw new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_CHANGES);
|
||||
}
|
||||
BlockVector3 pos = session.getPlacementPosition(player);
|
||||
fp.checkConfirmationRegion(() -> {
|
||||
session.setClipboard(null);
|
||||
BlockArrayClipboard clipboard = new BlockArrayClipboard(region, player.getUniqueId());
|
||||
clipboard.setOrigin(pos);
|
||||
clipboard.setOrigin(session.getPlacementPosition(player));
|
||||
ForwardExtentCopy copy = new ForwardExtentCopy(editSession, region, clipboard, region.getMinimumPoint());
|
||||
copy.setSourceFunction(new BlockReplace(editSession, leavePattern));
|
||||
copy.setCopyingEntities(!skipEntities);
|
||||
copy.setCopyingEntities(copyEntities);
|
||||
copy.setRemovingEntities(true);
|
||||
copy.setCopyBiomes(copyBiomes);
|
||||
copy.setCopyingBiomes(copyBiomes);
|
||||
Mask sourceMask = editSession.getSourceMask();
|
||||
if (sourceMask != null) {
|
||||
new MaskTraverser(sourceMask).reset(editSession);
|
||||
@ -286,18 +267,20 @@ public class ClipboardCommands extends MethodCommands {
|
||||
session.setClipboard(new ClipboardHolder(clipboard));
|
||||
|
||||
BBC.COMMAND_CUT_SLOW.send(player, region.getArea());
|
||||
if (!player.hasPermission("fawe.tips")) BBC.TIP_LAZYCUT.send(player);
|
||||
if (!player.hasPermission("fawe.tips")) {
|
||||
BBC.TIP_LAZYCUT.send(player);
|
||||
}
|
||||
}, getArguments(context), region, context);
|
||||
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"download"},
|
||||
name = "download",
|
||||
desc = "Downloads your clipboard through the configured web interface"
|
||||
)
|
||||
@Deprecated
|
||||
@CommandPermissions({"worldedit.clipboard.download"})
|
||||
public void download(final Player player, final LocalSession session, @Optional("schem") final String formatName) throws CommandException, WorldEditException {
|
||||
public void download(final Player player, final LocalSession session, @Optional("schem") final String formatName) throws WorldEditException {
|
||||
final ClipboardFormat format = ClipboardFormats.findByAlias(formatName);
|
||||
if (format == null) {
|
||||
BBC.CLIPBOARD_INVALID_FORMAT.send(player, formatName);
|
||||
@ -334,7 +317,9 @@ public class ClipboardCommands extends MethodCommands {
|
||||
try (ZipOutputStream zos = new ZipOutputStream(out)) {
|
||||
for (File file : files) {
|
||||
String fileName = file.getName();
|
||||
if (MainUtil.isInSubDirectory(working, file)) fileName = working.toURI().relativize(file.toURI()).getPath();
|
||||
if (MainUtil.isInSubDirectory(working, file)) {
|
||||
fileName = working.toURI().relativize(file.toURI()).getPath();
|
||||
}
|
||||
ZipEntry ze = new ZipEntry(fileName);
|
||||
zos.putNextEntry(ze);
|
||||
Files.copy(file.toPath(), zos);
|
||||
@ -376,32 +361,28 @@ public class ClipboardCommands extends MethodCommands {
|
||||
}
|
||||
url = FaweAPI.upload(target, format);
|
||||
}
|
||||
if (url == null) {
|
||||
BBC.GENERATING_LINK_FAILED.send(player);
|
||||
} else {
|
||||
String urlText = url.toString();
|
||||
if (Settings.IMP.WEB.SHORTEN_URLS) {
|
||||
try {
|
||||
urlText = MainUtil.getText("https://empcraft.com/s/?" + URLEncoder.encode(url.toString(), "UTF-8"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
BBC.DOWNLOAD_LINK.send(player, urlText);
|
||||
}
|
||||
}
|
||||
if (url == null) {
|
||||
BBC.GENERATING_LINK_FAILED.send(player);
|
||||
} else {
|
||||
String urlText = url.toString();
|
||||
if (Settings.IMP.WEB.SHORTEN_URLS) {
|
||||
try {
|
||||
urlText = MainUtil.getText("https://empcraft.com/s/?" + URLEncoder.encode(url.toString(), "UTF-8"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
BBC.DOWNLOAD_LINK.send(player, urlText);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"asset", "createasset", "makeasset"},
|
||||
usage = "[category]",
|
||||
desc = "Create an asset",
|
||||
help = "Saves your clipboard to the asset web interface",
|
||||
min = 1,
|
||||
max = 1
|
||||
name = "asset",
|
||||
desc = "Saves your clipboard to the asset web interface",
|
||||
)
|
||||
@CommandPermissions({"worldedit.clipboard.asset"})
|
||||
public void asset(final Player player, final LocalSession session, String category) throws CommandException, WorldEditException {
|
||||
public void asset(final Player player, final LocalSession session, String category) throws WorldEditException {
|
||||
final ClipboardFormat format = BuiltInClipboardFormat.MCEDIT_SCHEMATIC;
|
||||
ClipboardHolder holder = session.getClipboard();
|
||||
Clipboard clipboard = holder.getClipboard();
|
||||
@ -429,35 +410,25 @@ public class ClipboardCommands extends MethodCommands {
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void paste(Player player, LocalSession session, EditSession editSession,
|
||||
@Switch('a') boolean ignoreAirBlocks, @Switch('o') boolean atOrigin,
|
||||
@Switch('s') boolean selectPasted) throws WorldEditException {
|
||||
this.paste(player, session, editSession, ignoreAirBlocks, false, false, atOrigin, selectPasted);
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "/paste" },
|
||||
usage = "",
|
||||
flags = "saobe",
|
||||
desc = "Paste the clipboard's contents",
|
||||
help =
|
||||
"Pastes the clipboard's contents.\n" +
|
||||
"Flags:\n" +
|
||||
" -a skips air blocks\n" +
|
||||
" -b skips pasting biomes\n" +
|
||||
" -e skips pasting entities\n" +
|
||||
" -o pastes at the original position\n" +
|
||||
" -s selects the region after pasting",
|
||||
min = 0,
|
||||
max = 0
|
||||
name = "/paste",
|
||||
desc = "Paste the clipboard's contents"
|
||||
)
|
||||
@CommandPermissions("worldedit.clipboard.paste")
|
||||
@Logging(PLACEMENT)
|
||||
public void paste(Player player, LocalSession session, EditSession editSession,
|
||||
@Switch('a') boolean ignoreAirBlocks, @Switch('o') boolean atOrigin,
|
||||
@Switch('b') boolean ignoreBiomes, @Switch('e') boolean ignoreEntities,
|
||||
@Switch('s') boolean selectPasted) throws WorldEditException {
|
||||
@Switch(name = 'a', desc = "Skip air blocks")
|
||||
boolean ignoreAirBlocks,
|
||||
@Switch(name = 'o', desc = "Paste at the original position")
|
||||
boolean atOrigin,
|
||||
@Switch(name = 's', desc = "Select the region after pasting")
|
||||
boolean selectPasted,
|
||||
@Switch(name = 'e', desc = "Paste entities if available")
|
||||
boolean pasteEntities,
|
||||
@Switch(name = 'b', desc = "Paste biomes if available")
|
||||
boolean pasteBiomes,
|
||||
@ArgFlag(name = 'm', desc = "Only paste blocks matching this mask", def = "")
|
||||
Mask sourceMask) throws WorldEditException {
|
||||
|
||||
ClipboardHolder holder = session.getClipboard();
|
||||
if (holder.getTransform().isIdentity() && editSession.getSourceMask() == null) {
|
||||
@ -473,8 +444,9 @@ public class ClipboardCommands extends MethodCommands {
|
||||
.createPaste(editSession)
|
||||
.to(to)
|
||||
.ignoreAirBlocks(ignoreAirBlocks)
|
||||
.ignoreBiomes(ignoreBiomes)
|
||||
.ignoreEntities(ignoreEntities)
|
||||
.copyBiomes(pasteBiomes)
|
||||
.copyEntities(pasteEntities)
|
||||
.maskSource(sourceMask)
|
||||
.build();
|
||||
Operations.completeLegacy(operation);
|
||||
|
||||
@ -488,39 +460,36 @@ public class ClipboardCommands extends MethodCommands {
|
||||
selector.explainRegionAdjust(player, session);
|
||||
}
|
||||
BBC.COMMAND_PASTE.send(player, to);
|
||||
if (!player.hasPermission("fawe.tips"))
|
||||
if (!player.hasPermission("fawe.tips")) {
|
||||
BBC.TIP_COPYPASTE.or(BBC.TIP_SOURCE_MASK, BBC.TIP_REPLACE_MARKER).send(player, to);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkPaste(Player player, EditSession editSession, BlockVector3 to, ClipboardHolder holder, Clipboard clipboard) {
|
||||
URI uri = null;
|
||||
if (holder instanceof URIClipboardHolder) uri = ((URIClipboardHolder) holder).getURI(clipboard);
|
||||
if (holder instanceof URIClipboardHolder) {
|
||||
uri = ((URIClipboardHolder) holder).getURI(clipboard);
|
||||
}
|
||||
PasteEvent event = new PasteEvent(player, clipboard, uri, editSession, to);
|
||||
worldEdit.getEventBus().post(event);
|
||||
if (event.isCancelled()) throw new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MANUAL);
|
||||
if (event.isCancelled()) {
|
||||
throw new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MANUAL);
|
||||
}
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"/place"},
|
||||
usage = "",
|
||||
flags = "sao",
|
||||
name = "/place",
|
||||
desc = "Place the clipboard's contents without applying transformations (e.g. rotate)",
|
||||
help =
|
||||
"Places the clipboard's contents without applying transformations (e.g. rotate).\n" +
|
||||
"Flags:\n" +
|
||||
" -a skips air blocks\n" +
|
||||
" -o pastes at the original position\n" +
|
||||
" -s selects the region after pasting",
|
||||
min = 0,
|
||||
max = 0
|
||||
)
|
||||
|
||||
// Skips all transforms
|
||||
@CommandPermissions("worldedit.clipboard.place")
|
||||
@Logging(PLACEMENT)
|
||||
public void place(Player player, LocalSession session, final EditSession editSession,
|
||||
@Switch('a') final boolean ignoreAirBlocks, @Switch('o') boolean atOrigin,
|
||||
@Switch('s') boolean selectPasted) throws WorldEditException {
|
||||
@Switch(name = 'a', desc = "Skip air blocks")
|
||||
boolean ignoreAirBlocks,
|
||||
@Switch(name = 'o', desc = "Paste at the original position")
|
||||
boolean atOrigin,
|
||||
@Switch(name = 's', desc = "Select the region after pasting")
|
||||
boolean selectPasted) throws WorldEditException {
|
||||
ClipboardHolder holder = session.getClipboard();
|
||||
final Clipboard clipboard = holder.getClipboard();
|
||||
final BlockVector3 origin = clipboard.getOrigin();
|
||||
@ -532,8 +501,8 @@ public class ClipboardCommands extends MethodCommands {
|
||||
|
||||
Region region = clipboard.getRegion().clone();
|
||||
if (selectPasted) {
|
||||
BlockVector3 clipboardOffset = clipboard.getRegion().getMinimumPoint().subtract(clipboard.getOrigin());
|
||||
BlockVector3 realTo = to.add(holder.getTransform().apply(clipboardOffset.toVector3()).toBlockPoint());
|
||||
BlockVector3 clipboardOffset = clipboard.getRegion().getMinimumPoint().subtract(clipboard.getOrigin());
|
||||
BlockVector3 realTo = to.add(holder.getTransform().apply(clipboardOffset.toVector3()).toBlockPoint());
|
||||
BlockVector3 max = realTo.add(holder.getTransform().apply(region.getMaximumPoint().subtract(region.getMinimumPoint()).toVector3()).toBlockPoint());
|
||||
RegionSelector selector = new CuboidRegionSelector(player.getWorld(), realTo, max);
|
||||
session.setRegionSelector(player.getWorld(), selector);
|
||||
@ -548,38 +517,46 @@ public class ClipboardCommands extends MethodCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "/rotate" },
|
||||
usage = "<y-axis> [<x-axis>] [<z-axis>]",
|
||||
name = "/rotate",
|
||||
desc = "Rotate the contents of the clipboard",
|
||||
help = "Non-destructively rotate the contents of the clipboard.\n" +
|
||||
"Angles are provided in degrees and a positive angle will result in a clockwise rotation. " +
|
||||
"Multiple rotations can be stacked. Interpolation is not performed so angles should be a multiple of 90 degrees.\n"
|
||||
descFooter = "Non-destructively rotate the contents of the clipboard.\n" +
|
||||
"Angles are provided in degrees and a positive angle will result in a clockwise rotation. " +
|
||||
"Multiple rotations can be stacked. Interpolation is not performed so angles should be a multiple of 90 degrees.\n"
|
||||
)
|
||||
@CommandPermissions("worldedit.clipboard.rotate")
|
||||
public void rotate(Player player, LocalSession session, Double yRotate, @Optional Double xRotate, @Optional Double zRotate) throws WorldEditException {
|
||||
public void rotate(Player player, LocalSession session,
|
||||
@Arg(desc = "Amount to rotate on the y-axis")
|
||||
double yRotate,
|
||||
@Arg(desc = "Amount to rotate on the x-axis", def = "0")
|
||||
double xRotate,
|
||||
@Arg(desc = "Amount to rotate on the z-axis", def = "0")
|
||||
double zRotate) throws WorldEditException {
|
||||
if (Math.abs(yRotate % 90) > 0.001 ||
|
||||
Math.abs(xRotate % 90) > 0.001 ||
|
||||
Math.abs(zRotate % 90) > 0.001) {
|
||||
player.printDebug("Note: Interpolation is not yet supported, so angles that are multiples of 90 is recommended.");
|
||||
}
|
||||
|
||||
ClipboardHolder holder = session.getClipboard();
|
||||
AffineTransform transform = new AffineTransform();
|
||||
transform = transform.rotateY(-(yRotate != null ? yRotate : 0));
|
||||
transform = transform.rotateX(-(xRotate != null ? xRotate : 0));
|
||||
transform = transform.rotateZ(-(zRotate != null ? zRotate : 0));
|
||||
transform = transform.rotateY(-yRotate);
|
||||
transform = transform.rotateX(-xRotate);
|
||||
transform = transform.rotateZ(-zRotate);
|
||||
holder.setTransform(holder.getTransform().combine(transform));
|
||||
BBC.COMMAND_ROTATE.send(player);
|
||||
if (!player.hasPermission("fawe.tips"))
|
||||
if (!player.hasPermission("fawe.tips")) {
|
||||
BBC.TIP_FLIP.or(BBC.TIP_DEFORM, BBC.TIP_TRANSFORM).send(player);
|
||||
}
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "/flip" },
|
||||
usage = "[<direction>]",
|
||||
desc = "Flip the contents of the clipboard",
|
||||
help =
|
||||
"Flips the contents of the clipboard across the point from which the copy was made.\n",
|
||||
min = 0,
|
||||
max = 1
|
||||
name = "/flip",
|
||||
desc = "Flip the contents of the clipboard across the origin"
|
||||
)
|
||||
@CommandPermissions("worldedit.clipboard.flip")
|
||||
public void flip(Player player, LocalSession session,
|
||||
@Optional(Direction.AIM) @Direction BlockVector3 direction) throws WorldEditException {
|
||||
@Arg(desc = "The direction to flip, defaults to look direction.", def = Direction.AIM)
|
||||
@Direction BlockVector3 direction) throws WorldEditException {
|
||||
ClipboardHolder holder = session.getClipboard();
|
||||
AffineTransform transform = new AffineTransform();
|
||||
transform = transform.scale(direction.abs().multiply(-2).add(1, 1, 1).toVector3());
|
||||
@ -588,11 +565,8 @@ public class ClipboardCommands extends MethodCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "clearclipboard" },
|
||||
usage = "",
|
||||
desc = "Clear your clipboard",
|
||||
min = 0,
|
||||
max = 0
|
||||
name = "clearclipboard",
|
||||
desc = "Clear your clipboard"
|
||||
)
|
||||
@CommandPermissions("worldedit.clipboard.clear")
|
||||
public void clearClipboard(Player player, LocalSession session) throws WorldEditException {
|
||||
|
@ -0,0 +1,152 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.command;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.sk89q.worldedit.IncompleteRegionException;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.command.util.Logging;
|
||||
import com.sk89q.worldedit.command.util.PermissionCondition;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.internal.annotation.Direction;
|
||||
import com.sk89q.worldedit.internal.annotation.MultiDirection;
|
||||
import com.sk89q.worldedit.internal.command.CommandRegistrationHandler;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.regions.RegionOperationException;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
import org.enginehub.piston.Command;
|
||||
import org.enginehub.piston.CommandManager;
|
||||
import org.enginehub.piston.CommandManagerService;
|
||||
import org.enginehub.piston.annotation.CommandContainer;
|
||||
import org.enginehub.piston.annotation.param.Arg;
|
||||
import org.enginehub.piston.inject.Key;
|
||||
import org.enginehub.piston.part.SubCommandPart;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static com.sk89q.worldedit.command.util.Logging.LogMode.REGION;
|
||||
import static com.sk89q.worldedit.internal.command.CommandUtil.requireIV;
|
||||
|
||||
/**
|
||||
* Extracted from {@link SelectionCommands} to allow importing of {@link Command}.
|
||||
*/
|
||||
@CommandContainer
|
||||
public class ExpandCommands {
|
||||
|
||||
public static void register(CommandRegistrationHandler registration,
|
||||
CommandManager commandManager,
|
||||
CommandManagerService commandManagerService) {
|
||||
// Collect the general expand command
|
||||
CommandManager collect = commandManagerService.newCommandManager();
|
||||
|
||||
registration.register(
|
||||
collect,
|
||||
ExpandCommandsRegistration.builder(),
|
||||
new ExpandCommands()
|
||||
);
|
||||
|
||||
Command expandBaseCommand = collect.getCommand("/expand")
|
||||
.orElseThrow(() -> new IllegalStateException("No /expand command"));
|
||||
|
||||
commandManager.register("/expand", command -> {
|
||||
command.condition(new PermissionCondition(ImmutableSet.of("worldedit.selection.expand")));
|
||||
|
||||
command.addPart(SubCommandPart.builder(
|
||||
TranslatableComponent.of("vert"),
|
||||
TextComponent.of("Vertical expansion sub-command")
|
||||
)
|
||||
.withCommands(ImmutableSet.of(createVertCommand(commandManager)))
|
||||
.optional()
|
||||
.build());
|
||||
|
||||
command.addParts(expandBaseCommand.getParts());
|
||||
command.action(expandBaseCommand.getAction());
|
||||
command.description(expandBaseCommand.getDescription());
|
||||
});
|
||||
}
|
||||
|
||||
private static Command createVertCommand(CommandManager commandManager) {
|
||||
return commandManager.newCommand("vert")
|
||||
.description(TextComponent.of("Vertically expand the selection to world limits."))
|
||||
.action(parameters -> {
|
||||
expandVert(
|
||||
requireIV(Key.of(LocalSession.class), "localSession", parameters),
|
||||
requireIV(Key.of(Player.class), "localSession", parameters)
|
||||
);
|
||||
return 1;
|
||||
})
|
||||
.build();
|
||||
}
|
||||
|
||||
private static void expandVert(LocalSession session, Player player) throws IncompleteRegionException {
|
||||
Region region = session.getSelection(player.getWorld());
|
||||
try {
|
||||
int oldSize = region.getArea();
|
||||
region.expand(
|
||||
BlockVector3.at(0, (player.getWorld().getMaxY() + 1), 0),
|
||||
BlockVector3.at(0, -(player.getWorld().getMaxY() + 1), 0));
|
||||
session.getRegionSelector(player.getWorld()).learnChanges();
|
||||
int newSize = region.getArea();
|
||||
session.getRegionSelector(player.getWorld()).explainRegionAdjust(player, session);
|
||||
player.print("Region expanded " + (newSize - oldSize)
|
||||
+ " blocks [top-to-bottom].");
|
||||
} catch (RegionOperationException e) {
|
||||
player.printError(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@org.enginehub.piston.annotation.Command(
|
||||
name = "/expand",
|
||||
desc = "Expand the selection area"
|
||||
)
|
||||
@Logging(REGION)
|
||||
public void expand(Player player, LocalSession session,
|
||||
@Arg(desc = "Amount to expand the selection by, can be `vert` to expand to the whole vertical column")
|
||||
int amount,
|
||||
@Arg(desc = "Amount to expand the selection by in the other direction", def = "0")
|
||||
int reverseAmount,
|
||||
@Arg(desc = "Direction to expand", def = Direction.AIM)
|
||||
@MultiDirection
|
||||
List<BlockVector3> direction) throws WorldEditException {
|
||||
Region region = session.getSelection(player.getWorld());
|
||||
int oldSize = region.getArea();
|
||||
|
||||
if (reverseAmount == 0) {
|
||||
for (BlockVector3 dir : direction) {
|
||||
region.expand(dir.multiply(amount));
|
||||
}
|
||||
} else {
|
||||
for (BlockVector3 dir : direction) {
|
||||
region.expand(dir.multiply(amount), dir.multiply(-reverseAmount));
|
||||
}
|
||||
}
|
||||
|
||||
session.getRegionSelector(player.getWorld()).learnChanges();
|
||||
int newSize = region.getArea();
|
||||
|
||||
session.getRegionSelector(player.getWorld()).explainRegionAdjust(player, session);
|
||||
|
||||
player.print("Region expanded " + (newSize - oldSize) + " block(s).");
|
||||
}
|
||||
|
||||
}
|
@ -33,12 +33,9 @@ import com.sk89q.worldedit.math.transform.Transform;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* Helper class to 'bake' a transform into a clipboard.
|
||||
* <p>
|
||||
*
|
||||
* <p>This class needs a better name and may need to be made more generic.</p>
|
||||
*
|
||||
* @see Clipboard
|
||||
@ -52,7 +49,7 @@ public class FlattenedClipboardTransform {
|
||||
/**
|
||||
* Create a new instance.
|
||||
*
|
||||
* @param original the original clipboard
|
||||
* @param original the original clipboard
|
||||
* @param transform the transform
|
||||
*/
|
||||
private FlattenedClipboardTransform(Clipboard original, Transform transform) {
|
||||
@ -94,10 +91,10 @@ public class FlattenedClipboardTransform {
|
||||
|
||||
Vector3 newMinimum = corners[0];
|
||||
Vector3 newMaximum = corners[0];
|
||||
|
||||
for (int i = 1; i < corners.length; i++) {
|
||||
Vector3 cbv = corners[i];
|
||||
newMinimum = newMinimum.getMinimum(cbv);
|
||||
newMaximum = newMaximum.getMaximum(cbv);
|
||||
newMinimum = newMinimum.getMinimum(corners[i]);
|
||||
newMaximum = newMaximum.getMaximum(corners[i]);
|
||||
}
|
||||
|
||||
// After transformation, the points may not really sit on a block,
|
||||
@ -119,13 +116,16 @@ public class FlattenedClipboardTransform {
|
||||
if (transform != null && !transform.isIdentity()) extent = new BlockTransformExtent(original, transform);
|
||||
ForwardExtentCopy copy = new ForwardExtentCopy(extent, original.getRegion(), original.getOrigin(), target, original.getOrigin());
|
||||
copy.setTransform(transform);
|
||||
if (original.hasBiomes()) {
|
||||
copy.setCopyingBiomes(true);
|
||||
}
|
||||
return copy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new instance to bake the transform with.
|
||||
*
|
||||
* @param original the original clipboard
|
||||
* @param original the original clipboard
|
||||
* @param transform the transform
|
||||
* @return a builder
|
||||
*/
|
||||
@ -133,5 +133,4 @@ public class FlattenedClipboardTransform {
|
||||
return new FlattenedClipboardTransform(original, transform);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,284 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.command;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.LocalConfiguration;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.command.util.CommandPermissions;
|
||||
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
|
||||
import com.sk89q.worldedit.command.util.WorldEditAsyncCommandBuilder;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extension.input.DisallowedUsageException;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.util.formatting.component.PaginationBox;
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
import com.sk89q.worldedit.world.item.ItemType;
|
||||
import org.enginehub.piston.annotation.Command;
|
||||
import org.enginehub.piston.annotation.CommandContainer;
|
||||
import org.enginehub.piston.annotation.param.Arg;
|
||||
import org.enginehub.piston.annotation.param.ArgFlag;
|
||||
import org.enginehub.piston.annotation.param.Switch;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* General WorldEdit commands.
|
||||
*/
|
||||
@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class)
|
||||
public class GeneralCommands {
|
||||
|
||||
private final WorldEdit worldEdit;
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
*
|
||||
* @param worldEdit reference to WorldEdit
|
||||
*/
|
||||
public GeneralCommands(WorldEdit worldEdit) {
|
||||
checkNotNull(worldEdit);
|
||||
this.worldEdit = worldEdit;
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "/limit",
|
||||
desc = "Modify block change limit"
|
||||
)
|
||||
@CommandPermissions("worldedit.limit")
|
||||
public void limit(Player player, LocalSession session,
|
||||
@Arg(desc = "The limit to set", def = "")
|
||||
Integer limit) {
|
||||
|
||||
LocalConfiguration config = worldEdit.getConfiguration();
|
||||
boolean mayDisable = player.hasPermission("worldedit.limit.unrestricted");
|
||||
|
||||
limit = limit == null ? config.defaultChangeLimit : Math.max(-1, limit);
|
||||
if (!mayDisable && config.maxChangeLimit > -1) {
|
||||
if (limit > config.maxChangeLimit) {
|
||||
player.printError("Your maximum allowable limit is " + config.maxChangeLimit + ".");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
session.setBlockChangeLimit(limit);
|
||||
player.print("Block change limit set to " + limit + "."
|
||||
+ (limit == config.defaultChangeLimit ? "" : " (Use //limit to go back to the default.)"));
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "/timeout",
|
||||
desc = "Modify evaluation timeout time."
|
||||
)
|
||||
@CommandPermissions("worldedit.timeout")
|
||||
public void timeout(Player player, LocalSession session,
|
||||
@Arg(desc = "The timeout time to set", def = "")
|
||||
Integer limit) {
|
||||
LocalConfiguration config = worldEdit.getConfiguration();
|
||||
boolean mayDisable = player.hasPermission("worldedit.timeout.unrestricted");
|
||||
|
||||
limit = limit == null ? config.calculationTimeout : Math.max(-1, limit);
|
||||
if (!mayDisable && config.maxCalculationTimeout > -1) {
|
||||
if (limit > config.maxCalculationTimeout) {
|
||||
player.printError("Your maximum allowable timeout is " + config.maxCalculationTimeout + " ms.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
session.setTimeout(limit);
|
||||
player.print("Timeout time set to " + limit + " ms."
|
||||
+ (limit == config.calculationTimeout ? "" : " (Use //timeout to go back to the default.)"));
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "/fast",
|
||||
desc = "Toggle fast mode"
|
||||
)
|
||||
@CommandPermissions("worldedit.fast")
|
||||
public void fast(Player player, LocalSession session,
|
||||
@Arg(desc = "The new fast mode state", def = "")
|
||||
Boolean fastMode) {
|
||||
boolean hasFastMode = session.hasFastMode();
|
||||
if (fastMode != null && fastMode == hasFastMode) {
|
||||
player.printError("Fast mode already " + (fastMode ? "enabled" : "disabled") + ".");
|
||||
return;
|
||||
}
|
||||
|
||||
if (hasFastMode) {
|
||||
session.setFastMode(false);
|
||||
player.print("Fast mode disabled.");
|
||||
} else {
|
||||
session.setFastMode(true);
|
||||
player.print("Fast mode enabled. Lighting in the affected chunks may be wrong and/or you may need to rejoin to see changes.");
|
||||
}
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "/reorder",
|
||||
desc = "Sets the reorder mode of WorldEdit"
|
||||
)
|
||||
@CommandPermissions("worldedit.reorder")
|
||||
public void reorderMode(Player player, LocalSession session,
|
||||
@Arg(desc = "The reorder mode", def = "")
|
||||
EditSession.ReorderMode reorderMode) {
|
||||
if (reorderMode == null) {
|
||||
player.print("The reorder mode is " + session.getReorderMode().getDisplayName());
|
||||
} else {
|
||||
session.setReorderMode(reorderMode);
|
||||
player.print("The reorder mode is now " + session.getReorderMode().getDisplayName());
|
||||
}
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "/drawsel",
|
||||
desc = "Toggle drawing the current selection"
|
||||
)
|
||||
@CommandPermissions("worldedit.drawsel")
|
||||
public void drawSelection(Player player, LocalSession session,
|
||||
@Arg(desc = "The new draw selection state", def = "")
|
||||
Boolean drawSelection) throws WorldEditException {
|
||||
if (!WorldEdit.getInstance().getConfiguration().serverSideCUI) {
|
||||
throw new DisallowedUsageException("This functionality is disabled in the configuration!");
|
||||
}
|
||||
boolean useServerCui = session.shouldUseServerCUI();
|
||||
if (drawSelection != null && drawSelection == useServerCui) {
|
||||
player.printError("Server CUI already " + (useServerCui ? "enabled" : "disabled") + ".");
|
||||
return;
|
||||
}
|
||||
if (useServerCui) {
|
||||
session.setUseServerCUI(false);
|
||||
session.updateServerCUI(player);
|
||||
player.print("Server CUI disabled.");
|
||||
} else {
|
||||
session.setUseServerCUI(true);
|
||||
session.updateServerCUI(player);
|
||||
player.print("Server CUI enabled. This only supports cuboid regions, with a maximum size of 32x32x32.");
|
||||
}
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "gmask",
|
||||
aliases = {"/gmask"},
|
||||
desc = "Set the global mask"
|
||||
)
|
||||
@CommandPermissions("worldedit.global-mask")
|
||||
public void gmask(Player player, LocalSession session,
|
||||
@Arg(desc = "The mask to set", def = "")
|
||||
Mask mask) {
|
||||
if (mask == null) {
|
||||
session.setMask(null);
|
||||
player.print("Global mask disabled.");
|
||||
} else {
|
||||
session.setMask(mask);
|
||||
player.print("Global mask set.");
|
||||
}
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "toggleplace",
|
||||
aliases = {"/toggleplace"},
|
||||
desc = "Switch between your position and pos1 for placement"
|
||||
)
|
||||
public void togglePlace(Player player, LocalSession session) {
|
||||
if (session.togglePlacementPosition()) {
|
||||
player.print("Now placing at pos #1.");
|
||||
} else {
|
||||
player.print("Now placing at the block you stand in.");
|
||||
}
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "searchitem",
|
||||
aliases = {"/searchitem", "/l", "/search"},
|
||||
desc = "Search for an item"
|
||||
)
|
||||
@CommandPermissions("worldedit.searchitem")
|
||||
public void searchItem(Actor actor,
|
||||
@Switch(name = 'b', desc = "Only search for blocks")
|
||||
boolean blocksOnly,
|
||||
@Switch(name = 'i', desc = "Only search for items")
|
||||
boolean itemsOnly,
|
||||
@ArgFlag(name = 'p', desc = "Page of results to return", def = "1")
|
||||
int page,
|
||||
@Arg(desc = "Search query", variable = true)
|
||||
List<String> query) {
|
||||
String search = String.join(" ", query);
|
||||
if (search.length() <= 2) {
|
||||
actor.printError("Enter a longer search string (len > 2).");
|
||||
return;
|
||||
}
|
||||
if (blocksOnly && itemsOnly) {
|
||||
actor.printError("You cannot use both the 'b' and 'i' flags simultaneously.");
|
||||
return;
|
||||
}
|
||||
|
||||
WorldEditAsyncCommandBuilder.createAndSendMessage(actor, new ItemSearcher(search, blocksOnly, itemsOnly, page),
|
||||
"(Please wait... searching items.)");
|
||||
}
|
||||
|
||||
private static class ItemSearcher implements Callable<Component> {
|
||||
private final boolean blocksOnly;
|
||||
private final boolean itemsOnly;
|
||||
private final String search;
|
||||
private final int page;
|
||||
|
||||
ItemSearcher(String search, boolean blocksOnly, boolean itemsOnly, int page) {
|
||||
this.blocksOnly = blocksOnly;
|
||||
this.itemsOnly = itemsOnly;
|
||||
this.search = search;
|
||||
this.page = page;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component call() throws Exception {
|
||||
String command = "/searchitem " + (blocksOnly ? "-b " : "") + (itemsOnly ? "-i " : "") + "-p %page% " + search;
|
||||
Map<String, String> results = new TreeMap<>();
|
||||
String idMatch = search.replace(' ', '_');
|
||||
String nameMatch = search.toLowerCase(Locale.ROOT);
|
||||
for (ItemType searchType : ItemType.REGISTRY) {
|
||||
if (blocksOnly && !searchType.hasBlockType()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (itemsOnly && searchType.hasBlockType()) {
|
||||
continue;
|
||||
}
|
||||
final String id = searchType.getId();
|
||||
String name = searchType.getName();
|
||||
final boolean hasName = !name.equals(id);
|
||||
name = name.toLowerCase(Locale.ROOT);
|
||||
if (id.contains(idMatch) || (hasName && name.contains(nameMatch))) {
|
||||
results.put(id, name + (hasName ? " (" + id + ")" : ""));
|
||||
}
|
||||
}
|
||||
List<String> list = new ArrayList<>(results.values());
|
||||
return PaginationBox.fromStrings("Search results for '" + search + "'", command, list).create(page);
|
||||
}
|
||||
}
|
||||
}
|
@ -27,21 +27,27 @@ import com.boydti.fawe.util.MainUtil;
|
||||
import com.boydti.fawe.util.MathMan;
|
||||
import com.boydti.fawe.util.TextureUtil;
|
||||
import com.boydti.fawe.util.image.ImageUtil;
|
||||
import com.sk89q.minecraft.util.commands.Command;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||
import com.sk89q.minecraft.util.commands.Logging;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.command.util.CommandPermissions;
|
||||
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
|
||||
import com.sk89q.worldedit.command.util.Logging;
|
||||
import static com.sk89q.worldedit.command.util.Logging.LogMode.ALL;
|
||||
import static com.sk89q.worldedit.command.util.Logging.LogMode.PLACEMENT;
|
||||
import static com.sk89q.worldedit.command.util.Logging.LogMode.POSITION;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.function.RegionFunction;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.operation.Operations;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.function.visitor.RegionVisitor;
|
||||
import com.sk89q.worldedit.internal.annotation.Radii;
|
||||
import com.sk89q.worldedit.internal.annotation.Selection;
|
||||
import static com.sk89q.worldedit.internal.command.CommandUtil.checkCommandArgument;
|
||||
import com.sk89q.worldedit.internal.expression.ExpressionException;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
@ -49,29 +55,26 @@ import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.util.TreeGenerator.TreeType;
|
||||
import com.sk89q.worldedit.util.command.binding.Range;
|
||||
import com.sk89q.worldedit.util.command.binding.Switch;
|
||||
import com.sk89q.worldedit.util.command.binding.Text;
|
||||
import com.sk89q.worldedit.util.command.parametric.Optional;
|
||||
import com.sk89q.worldedit.util.command.parametric.ParameterException;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import org.enginehub.piston.annotation.Command;
|
||||
import org.enginehub.piston.annotation.CommandContainer;
|
||||
import org.enginehub.piston.annotation.param.Arg;
|
||||
import org.enginehub.piston.annotation.param.Switch;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.List;
|
||||
import java.awt.RenderingHints;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
|
||||
import static com.sk89q.minecraft.util.commands.Logging.LogMode.ALL;
|
||||
import static com.sk89q.minecraft.util.commands.Logging.LogMode.PLACEMENT;
|
||||
import static com.sk89q.minecraft.util.commands.Logging.LogMode.POSITION;
|
||||
|
||||
|
||||
/**
|
||||
* Commands for the generation of shapes and other objects.
|
||||
*/
|
||||
@Command(aliases = {}, desc = "Create structures and features: [More Info](https://goo.gl/KuLFRW)")
|
||||
public class GenerationCommands extends MethodCommands {
|
||||
@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class)
|
||||
public class GenerationCommands {
|
||||
|
||||
private final WorldEdit worldEdit;
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
@ -79,18 +82,28 @@ public class GenerationCommands extends MethodCommands {
|
||||
* @param worldEdit reference to WorldEdit
|
||||
*/
|
||||
public GenerationCommands(WorldEdit worldEdit) {
|
||||
super(worldEdit);
|
||||
checkNotNull(worldEdit);
|
||||
this.worldEdit = worldEdit;
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"/caves"},
|
||||
name = "/caves",
|
||||
usage = "[size=8] [freq=40] [rarity=7] [minY=8] [maxY=127] [sysFreq=1] [sysRarity=25] [pocketRarity=0] [pocketMin=0] [pocketMax=3]",
|
||||
desc = "Generates caves",
|
||||
help = "Generates a cave network"
|
||||
desc = "Generates a cave network"
|
||||
)
|
||||
@CommandPermissions("worldedit.generation.caves")
|
||||
@Logging(PLACEMENT)
|
||||
public void caves(FawePlayer fp, LocalSession session, EditSession editSession, @Selection Region region, @Optional("8") int size, @Optional("40") int frequency, @Optional("7") int rarity, @Optional("8") int minY, @Optional("127") int maxY, @Optional("1") int systemFrequency, @Optional("25") int individualRarity, @Optional("0") int pocketChance, @Optional("0") int pocketMin, @Optional("3") int pocketMax, CommandContext context) throws WorldEditException {
|
||||
public void caves(FawePlayer fp, LocalSession session, EditSession editSession, @Selection Region region,
|
||||
@Arg(desc = "TODO", def = "8") int size,
|
||||
@Arg(desc = "TODO", def = "40") int frequency,
|
||||
@Arg(desc = "TODO", def = "7") int rarity,
|
||||
@Arg(desc = "TODO", def = "8") int minY,
|
||||
@Arg(desc = "TODO", def = "127") int maxY,
|
||||
@Arg(desc = "TODO", def = "1") int systemFrequency,
|
||||
@Arg(desc = "TODO", def = "25") int individualRarity,
|
||||
@Arg(desc = "TODO", def = "0") int pocketChance,
|
||||
@Arg(desc = "TODO", def = "0") int pocketMin,
|
||||
@Arg(desc = "TODO", def = "3") int pocketMax, CommandContext context) throws WorldEditException {
|
||||
fp.checkConfirmationRegion(() -> {
|
||||
CavesGen gen = new CavesGen(size, frequency, rarity, minY, maxY, systemFrequency, individualRarity, pocketChance, pocketMin, pocketMax);
|
||||
editSession.generate(region, gen);
|
||||
@ -98,14 +111,10 @@ public class GenerationCommands extends MethodCommands {
|
||||
}, getArguments(context), region, context);
|
||||
}
|
||||
|
||||
// public void addOre(Mask mask, Pattern material, int size, int frequency, int rarity, int minY, int maxY) throws WorldEditException {
|
||||
|
||||
@Command(
|
||||
aliases = {"/ores"},
|
||||
desc = "Generates ores",
|
||||
help = "Generates ores",
|
||||
min = 1,
|
||||
max = 1
|
||||
name = "/ores",
|
||||
desc = "Generates ores"
|
||||
)
|
||||
@CommandPermissions("worldedit.generation.ore")
|
||||
@Logging(PLACEMENT)
|
||||
@ -119,59 +128,49 @@ public class GenerationCommands extends MethodCommands {
|
||||
@Command(
|
||||
aliases = {"/image", "/img"},
|
||||
desc = "Generate an image",
|
||||
usage = "<imgur> [randomize=true] [complexity=100] [dimensions=100,100]",
|
||||
min = 1,
|
||||
max = 4
|
||||
usage = "<imgur> [randomize=true] [complexity=100] [dimensions=100,100]"
|
||||
)
|
||||
@CommandPermissions("worldedit.generation.image")
|
||||
@Logging(PLACEMENT)
|
||||
public void image(Player player, LocalSession session, EditSession editSession, String arg, @Optional("true") boolean randomize, @Optional("100") int threshold, @Optional BlockVector2 dimensions) throws WorldEditException, IOException {
|
||||
public void image(Player player, LocalSession session, EditSession editSession, String arg, @Optional("true") boolean randomize,
|
||||
@Arg(desc = "TODO", def = "100") int threshold, @Optional BlockVector2 dimensions) throws WorldEditException, IOException {
|
||||
TextureUtil tu = Fawe.get().getCachedTextureUtil(randomize, 0, threshold);
|
||||
URL url = new URL(arg);
|
||||
if (!url.getHost().equalsIgnoreCase("i.imgur.com") && !url.getHost().equalsIgnoreCase("empcraft.com")) {
|
||||
throw new IOException("Only i.imgur.com or empcraft.com/ui links are allowed!");
|
||||
}
|
||||
FawePlayer<Object> fp = FawePlayer.wrap(player);
|
||||
BufferedImage image = MainUtil.readImage(url);
|
||||
if (dimensions != null) {
|
||||
image = ImageUtil.getScaledInstance(image, dimensions.getBlockX(), dimensions.getBlockZ(), RenderingHints.VALUE_INTERPOLATION_BILINEAR, false);
|
||||
}
|
||||
|
||||
// MutableBlockVector3 pos1 = new MutableBlockVector3(player.getLocation().toBlockPoint());
|
||||
// MutableBlockVector3 pos2 = new MutableBlockVector3(pos1.add(image.getWidth() - 1, 0, image.getHeight() - 1));
|
||||
BlockVector3 pos1 = player.getLocation().toBlockPoint();
|
||||
BlockVector3 pos2 = pos1.add(image.getWidth() - 1, 0, image.getHeight() - 1);
|
||||
CuboidRegion region = new CuboidRegion(pos1, pos2);
|
||||
int[] count = new int[1];
|
||||
final BufferedImage finalImage = image;
|
||||
RegionVisitor visitor = new RegionVisitor(region, new RegionFunction() {
|
||||
@Override
|
||||
public boolean apply(BlockVector3 pos) throws WorldEditException {
|
||||
try {
|
||||
int x = pos.getBlockX() - pos1.getBlockX();
|
||||
int z = pos.getBlockZ() - pos1.getBlockZ();
|
||||
int color = finalImage.getRGB(x, z);
|
||||
BlockType block = tu.getNearestBlock(color);
|
||||
count[0]++;
|
||||
if (block != null) return editSession.setBlock(pos, block.getDefaultState());
|
||||
return false;
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
RegionVisitor visitor = new RegionVisitor(region, pos -> {
|
||||
try {
|
||||
int x = pos.getBlockX() - pos1.getBlockX();
|
||||
int z = pos.getBlockZ() - pos1.getBlockZ();
|
||||
int color = finalImage.getRGB(x, z);
|
||||
BlockType block = tu.getNearestBlock(color);
|
||||
count[0]++;
|
||||
if (block != null) return editSession.setBlock(pos, block.getDefaultState());
|
||||
return false;
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}, editSession);
|
||||
Operations.completeBlindly(visitor);
|
||||
BBC.VISITOR_BLOCK.send(player, editSession.getBlockChangeCount());
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"/ore"},
|
||||
name = "/ore",
|
||||
usage = "<mask> <pattern> <size> <freq> <rarity> <minY> <maxY>",
|
||||
desc = "Generates ores",
|
||||
help = "Generates ores",
|
||||
min = 7,
|
||||
max = 7
|
||||
desc = "Generates ores"
|
||||
)
|
||||
@CommandPermissions("worldedit.generation.ore")
|
||||
@Logging(PLACEMENT)
|
||||
@ -183,20 +182,24 @@ public class GenerationCommands extends MethodCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "/hcyl" },
|
||||
name = "/hcyl",
|
||||
usage = "<pattern> <radius>[,<radius>] [height]",
|
||||
desc = "Generates a hollow cylinder.",
|
||||
help =
|
||||
"Generates a hollow cylinder.\n" +
|
||||
"By specifying 2 radii, separated by a comma,\n" +
|
||||
"you can generate elliptical cylinders.\n" +
|
||||
"The 1st radius is north/south, the 2nd radius is east/west.",
|
||||
min = 2,
|
||||
max = 4
|
||||
"The 1st radius is north/south, the 2nd radius is east/west."
|
||||
)
|
||||
@CommandPermissions("worldedit.generation.cylinder")
|
||||
@Logging(PLACEMENT)
|
||||
public void hcyl(FawePlayer fp, Player player, LocalSession session, EditSession editSession, Pattern pattern, BlockVector2 radius, @Optional("1") int height, @Range(min = 1) @Optional("1") double thickness, CommandContext context) throws WorldEditException {
|
||||
public void hcyl(FawePlayer fp, Player player, LocalSession session, EditSession editSession,
|
||||
@Arg(desc = "The pattern of blocks to generate")
|
||||
Pattern pattern,
|
||||
BlockVector2 radius,
|
||||
@Arg(desc = "The height of the cylinder", def = "1")
|
||||
int height,
|
||||
@Range(min = 1) @Optional("1") double thickness, CommandContext context) throws WorldEditException {
|
||||
double max = MathMan.max(radius.getBlockX(), radius.getBlockZ());
|
||||
worldEdit.checkMaxRadius(max);
|
||||
BlockVector3 pos = session.getPlacementPosition(player);
|
||||
@ -207,21 +210,24 @@ public class GenerationCommands extends MethodCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "/cyl" },
|
||||
usage = "<pattern> <radius>[,<radius>] [height]",
|
||||
flags = "h",
|
||||
name = "/cyl",
|
||||
desc = "Generates a cylinder.",
|
||||
help =
|
||||
"Generates a cylinder.\n" +
|
||||
"By specifying 2 radii, separated by a comma,\n" +
|
||||
"you can generate elliptical cylinders.\n" +
|
||||
"The 1st radius is north/south, the 2nd radius is east/west.",
|
||||
min = 2,
|
||||
max = 3
|
||||
"The 1st radius is north/south, the 2nd radius is east/west."
|
||||
)
|
||||
@CommandPermissions("worldedit.generation.cylinder")
|
||||
@Logging(PLACEMENT)
|
||||
public void cyl(FawePlayer fp, Player player, LocalSession session, EditSession editSession, Pattern pattern, BlockVector2 radius, @Optional("1") int height, @Switch('h') boolean hollow, CommandContext context) throws WorldEditException {
|
||||
public void cyl(FawePlayer fp, Player player, LocalSession session, EditSession editSession,
|
||||
@Arg(desc = "The pattern of blocks to generate")
|
||||
Pattern pattern,
|
||||
BlockVector2 radius,
|
||||
@Arg(desc = "The height of the cylinder", def = "1")
|
||||
int height,
|
||||
@Switch(name = 'h', desc = "Make a hollow cylinder")
|
||||
boolean hollow, CommandContext context) throws WorldEditException {
|
||||
double max = Math.max(radius.getBlockX(), radius.getBlockZ());
|
||||
worldEdit.checkMaxRadius(max);
|
||||
BlockVector3 pos = session.getPlacementPosition(player);
|
||||
@ -232,104 +238,151 @@ public class GenerationCommands extends MethodCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "/hsphere" },
|
||||
name = "/hsphere",
|
||||
usage = "<pattern> <radius>[,<radius>,<radius>] [raised?]",
|
||||
desc = "Generates a hollow sphere.",
|
||||
help =
|
||||
"Generates a hollow sphere.\n" +
|
||||
"By specifying 3 radii, separated by commas,\n" +
|
||||
"you can generate an ellipsoid. The order of the ellipsoid radii\n" +
|
||||
"is north/south, up/down, east/west.",
|
||||
min = 2,
|
||||
max = 3
|
||||
"is north/south, up/down, east/west."
|
||||
)
|
||||
@CommandPermissions("worldedit.generation.sphere")
|
||||
@Logging(PLACEMENT)
|
||||
public void hsphere(FawePlayer fp, Player player, LocalSession session, EditSession editSession, Pattern pattern, BlockVector3 radius, @Optional("false") boolean raised, CommandContext context) throws WorldEditException {
|
||||
sphere(fp, player, session, editSession, pattern, radius, raised, true, context);
|
||||
public void hsphere(FawePlayer fp, Player player, LocalSession session, EditSession editSession,
|
||||
@Arg(desc = "The pattern of blocks to generate")
|
||||
Pattern pattern,
|
||||
@Arg(desc = "The radii of the sphere. Order is N/S, U/D, E/W")
|
||||
@Radii(3)
|
||||
List<Double> radii,
|
||||
@Switch(name = 'r', desc = "Raise the bottom of the sphere to the placement position")
|
||||
boolean raised,
|
||||
CommandContext context) throws WorldEditException {
|
||||
sphere(fp, player, session, editSession, pattern, radii, raised, true, context);
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "/sphere" },
|
||||
usage = "<pattern> <radius>[,<radius>,<radius>] [raised?]",
|
||||
flags = "h",
|
||||
name = "/sphere",
|
||||
desc = "Generates a filled sphere.",
|
||||
help =
|
||||
"Generates a filled sphere.\n" +
|
||||
"By specifying 3 radii, separated by commas,\n" +
|
||||
"you can generate an ellipsoid. The order of the ellipsoid radii\n" +
|
||||
"is north/south, up/down, east/west.",
|
||||
min = 2,
|
||||
max = 3
|
||||
"is north/south, up/down, east/west."
|
||||
)
|
||||
@CommandPermissions("worldedit.generation.sphere")
|
||||
@Logging(PLACEMENT)
|
||||
public void sphere(FawePlayer fp, Player player, LocalSession session, EditSession editSession, Pattern pattern, BlockVector3 radius, @Optional("false") boolean raised, @Switch('h') boolean hollow, CommandContext context) throws WorldEditException {
|
||||
double max = MathMan.max(radius.getBlockX(), radius.getBlockY(), radius.getBlockZ());
|
||||
worldEdit.checkMaxRadius(max);
|
||||
public int sphere(FawePlayer fp, Player player, LocalSession session, EditSession editSession,
|
||||
@Arg(desc = "The pattern of blocks to generate")
|
||||
Pattern pattern,
|
||||
@Arg(desc = "The radii of the sphere. Order is N/S, U/D, E/W")
|
||||
@Radii(3)
|
||||
List<Double> radii,
|
||||
@Switch(name = 'r', desc = "Raise the bottom of the sphere to the placement position")
|
||||
boolean raised,
|
||||
@Switch(name = 'h', desc = "Make a hollow sphere")
|
||||
boolean hollow) throws WorldEditException {
|
||||
final double radiusX, radiusY, radiusZ;
|
||||
switch (radii.size()) {
|
||||
case 1:
|
||||
radiusX = radiusY = radiusZ = Math.max(1, radii.get(0));
|
||||
break;
|
||||
|
||||
case 3:
|
||||
radiusX = Math.max(1, radii.get(0));
|
||||
radiusY = Math.max(1, radii.get(1));
|
||||
radiusZ = Math.max(1, radii.get(2));
|
||||
break;
|
||||
|
||||
default:
|
||||
player.printError("You must either specify 1 or 3 radius values.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
worldEdit.checkMaxRadius(radiusX);
|
||||
worldEdit.checkMaxRadius(radiusY);
|
||||
worldEdit.checkMaxRadius(radiusZ);
|
||||
|
||||
BlockVector3 pos = session.getPlacementPosition(player);
|
||||
BlockVector3 finalPos = raised ? pos.add(0, radius.getY(), 0) : pos;
|
||||
BlockVector3 finalPos;
|
||||
if (raised) {
|
||||
finalPos = pos.add(0, (int) radiusY, 0);
|
||||
} else {
|
||||
finalPos = pos;
|
||||
}
|
||||
fp.checkConfirmationRadius(() -> {
|
||||
int affected = editSession.makeSphere(finalPos, pattern, radius.getX(), radius.getY(), radius.getZ(), !hollow);
|
||||
int affected = editSession.makeSphere(finalPos, pattern, radiusX, radiusY, radiusZ, !hollow);
|
||||
player.findFreePosition();
|
||||
BBC.VISITOR_BLOCK.send(fp, affected);
|
||||
}, getArguments(context), (int) max, context);
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "forestgen" },
|
||||
usage = "[size] [type] [density]",
|
||||
desc = "Generate a forest",
|
||||
min = 0,
|
||||
max = 3
|
||||
name = "forestgen",
|
||||
desc = "Generate a forest"
|
||||
)
|
||||
@CommandPermissions("worldedit.generation.forest")
|
||||
@Logging(POSITION)
|
||||
public void forestGen(Player player, LocalSession session, EditSession editSession, @Optional("10") int size,
|
||||
@Optional("tree") TreeType type, @Optional("5") @Range(min = 0, max = 100) double density) throws WorldEditException {
|
||||
public int forestGen(Player player, LocalSession session, EditSession editSession,
|
||||
@Arg(desc = "The size of the forest, in blocks", def = "10")
|
||||
int size,
|
||||
@Arg(desc = "The type of forest", def = "tree")
|
||||
TreeType type,
|
||||
@Arg(desc = "The density of the forest, between 0 and 100", def = "5")
|
||||
double density) throws WorldEditException {
|
||||
checkCommandArgument(0 <= density && density <= 100, "Density must be between 0 and 100");
|
||||
density = density / 100;
|
||||
int affected = editSession.makeForest(session.getPlacementPosition(player), size, density, type);
|
||||
player.print(affected + " trees created.");
|
||||
return affected;
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "pumpkins" },
|
||||
usage = "[size=10] [density=0.02]",
|
||||
desc = "Generate pumpkin patches",
|
||||
min = 0,
|
||||
max = 2
|
||||
name = "pumpkins",
|
||||
desc = "Generate pumpkin patches"
|
||||
)
|
||||
@CommandPermissions("worldedit.generation.pumpkins")
|
||||
@Logging(POSITION)
|
||||
public void pumpkins(Player player, LocalSession session, EditSession editSession, @Optional("10") int apothem, @Optional("0.02") double density) throws WorldEditException, ParameterException {
|
||||
public int pumpkins(Player player, LocalSession session, EditSession editSession,
|
||||
@Arg(desc = "The size of the patch", def = "10")
|
||||
int size,
|
||||
@Arg(desc = "//TODO", def = "10")
|
||||
int apothem,
|
||||
@Arg(desc = "//TODO ", def = "0.02")
|
||||
double density) throws WorldEditException {
|
||||
int affected = editSession.makePumpkinPatches(session.getPlacementPosition(player), apothem, density);
|
||||
BBC.COMMAND_PUMPKIN.send(player, affected);
|
||||
return affected;
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "/hpyramid" },
|
||||
usage = "<pattern> <size>",
|
||||
desc = "Generate a hollow pyramid",
|
||||
min = 2,
|
||||
max = 2
|
||||
name = "/hpyramid",
|
||||
desc = "Generate a hollow pyramid"
|
||||
)
|
||||
@CommandPermissions("worldedit.generation.pyramid")
|
||||
@Logging(PLACEMENT)
|
||||
public void hollowPyramid(FawePlayer fp, Player player, LocalSession session, EditSession editSession, Pattern pattern, @Range(min = 1) int size, CommandContext context) throws WorldEditException {
|
||||
public void hollowPyramid(FawePlayer fp, Player player, LocalSession session, EditSession editSession,
|
||||
@Arg(desc = "The pattern of blocks to set")
|
||||
Pattern pattern,
|
||||
@Arg(desc = "The size of the pyramid")
|
||||
int size, CommandContext context) throws WorldEditException {
|
||||
pyramid(fp, player, session, editSession, pattern, size, true, context);
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "/pyramid" },
|
||||
usage = "<pattern> <size>",
|
||||
flags = "h",
|
||||
desc = "Generate a filled pyramid",
|
||||
min = 2,
|
||||
max = 2
|
||||
name = "/pyramid",
|
||||
desc = "Generate a filled pyramid"
|
||||
)
|
||||
@CommandPermissions("worldedit.generation.pyramid")
|
||||
@Logging(PLACEMENT)
|
||||
public void pyramid(FawePlayer fp, Player player, LocalSession session, EditSession editSession, Pattern pattern, @Range(min = 1) int size, @Switch('h') boolean hollow, CommandContext context) throws WorldEditException {
|
||||
public void pyramid(FawePlayer fp, Player player, LocalSession session, EditSession editSession,
|
||||
@Arg(desc = "The pattern of blocks to set")
|
||||
Pattern pattern,
|
||||
@Arg(desc = "The size of the pyramid")
|
||||
int size,
|
||||
@Switch(name = 'h', desc = "Make a hollow pyramid")
|
||||
boolean hollow,
|
||||
CommandContext context) throws WorldEditException {
|
||||
BlockVector3 pos = session.getPlacementPosition(player);
|
||||
worldEdit.checkMaxRadius(size);
|
||||
fp.checkConfirmationRadius(() -> {
|
||||
@ -339,36 +392,28 @@ public class GenerationCommands extends MethodCommands {
|
||||
}, getArguments(context), size, context);
|
||||
}
|
||||
|
||||
|
||||
@Command(
|
||||
aliases = { "/generate", "/gen", "/g" },
|
||||
usage = "<pattern> <expression>",
|
||||
name = "/generate",
|
||||
aliases = { "/gen", "/g" },
|
||||
desc = "Generates a shape according to a formula.",
|
||||
help =
|
||||
"Generates a shape according to a formula that is expected to\n" +
|
||||
"return positive numbers (true) if the point is inside the shape\n" +
|
||||
"Optionally set type/data to the desired block.\n" +
|
||||
"Flags:\n" +
|
||||
" -h to generate a hollow shape\n" +
|
||||
" -r to use raw minecraft coordinates\n" +
|
||||
" -o is like -r, except offset from placement.\n" +
|
||||
" -c is like -r, except offset selection center.\n" +
|
||||
"If neither -r nor -o is given, the selection is mapped to -1..1\n" +
|
||||
"See also tinyurl.com/wesyntax.",
|
||||
flags = "hroc",
|
||||
min = 2,
|
||||
max = -1
|
||||
descFooter = "See also https://tinyurl.com/wesyntax."
|
||||
)
|
||||
@CommandPermissions("worldedit.generation.shape")
|
||||
@Logging(ALL)
|
||||
public void generate(FawePlayer fp, Player player, LocalSession session, EditSession editSession,
|
||||
@Selection Region region,
|
||||
Pattern pattern,
|
||||
@Text String expression,
|
||||
@Switch('h') boolean hollow,
|
||||
@Switch('r') boolean useRawCoords,
|
||||
@Switch('o') boolean offset,
|
||||
@Switch('c') boolean offsetCenter, CommandContext context) throws WorldEditException {
|
||||
public int generate(FawePlayer fp, Player player, LocalSession session, EditSession editSession,
|
||||
@Selection Region region,
|
||||
@Arg(desc = "The pattern of blocks to set")
|
||||
Pattern pattern,
|
||||
@Arg(desc = "Expression to test block placement locations and set block type", variable = true)
|
||||
List<String> expression,
|
||||
@Switch(name = 'h', desc = "Generate a hollow shape")
|
||||
boolean hollow,
|
||||
@Switch(name = 'r', desc = "Use the game's coordinate origin")
|
||||
boolean useRawCoords,
|
||||
@Switch(name = 'o', desc = "Use the placement's coordinate origin")
|
||||
boolean offset,
|
||||
@Switch(name = 'c', desc = "Use the selection's center as origin")
|
||||
boolean offsetCenter) throws WorldEditException {
|
||||
|
||||
final Vector3 zero;
|
||||
Vector3 unit;
|
||||
@ -399,47 +444,42 @@ public class GenerationCommands extends MethodCommands {
|
||||
|
||||
final Vector3 unit1 = unit;
|
||||
|
||||
final int affected = 0;
|
||||
fp.checkConfirmationRegion(() -> {
|
||||
try {
|
||||
final int affected = editSession.makeShape(region, zero, unit1, pattern, expression, hollow);
|
||||
affected = editSession.makeShape(region, zero, unit1, pattern, String.join(" ", expression), hollow, session.getTimeout());
|
||||
player.findFreePosition();
|
||||
BBC.VISITOR_BLOCK.send(fp, affected);
|
||||
} catch (ExpressionException e) {
|
||||
fp.sendMessage(e.getMessage());
|
||||
player.printError(e.getMessage());
|
||||
return 0;
|
||||
}
|
||||
}, getArguments(context), region, context);
|
||||
return affected;
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "/generatebiome", "/genbiome", "/gb" },
|
||||
usage = "<biome> <expression>",
|
||||
name = "/generatebiome",
|
||||
aliases = { "/genbiome", "/gb" },
|
||||
desc = "Sets biome according to a formula.",
|
||||
help =
|
||||
"Generates a shape according to a formula that is expected to\n" +
|
||||
"return positive numbers (true) if the point is inside the shape\n" +
|
||||
"Sets the biome of blocks in that shape.\n" +
|
||||
"Flags:\n" +
|
||||
" -h to generate a hollow shape\n" +
|
||||
" -r to use raw minecraft coordinates\n" +
|
||||
" -o is like -r, except offset from placement.\n" +
|
||||
" -c is like -r, except offset selection center.\n" +
|
||||
"If neither -r nor -o is given, the selection is mapped to -1..1\n" +
|
||||
"See also tinyurl.com/wesyntax.",
|
||||
flags = "hroc",
|
||||
min = 2,
|
||||
max = -1
|
||||
descFooter = "See also https://tinyurl.com/wesyntax."
|
||||
)
|
||||
@CommandPermissions("worldedit.generation.shape.biome")
|
||||
@Logging(ALL)
|
||||
public void generateBiome(FawePlayer fp, Player player, LocalSession session, EditSession editSession,
|
||||
@Selection Region region,
|
||||
BiomeType target,
|
||||
@Text String expression,
|
||||
@Switch('h') boolean hollow,
|
||||
@Switch('r') boolean useRawCoords,
|
||||
@Switch('o') boolean offset,
|
||||
@Switch('c') boolean offsetCenter,
|
||||
CommandContext context) throws WorldEditException {
|
||||
public int generateBiome(Player player, LocalSession session, EditSession editSession,
|
||||
@Selection Region region,
|
||||
@Arg(desc = "The biome type to set")
|
||||
BiomeType target,
|
||||
@Arg(desc = "Expression to test block placement locations and set biome type", variable = true)
|
||||
List<String> expression,
|
||||
@Switch(name = 'h', desc = "Generate a hollow shape")
|
||||
boolean hollow,
|
||||
@Switch(name = 'r', desc = "Use the game's coordinate origin")
|
||||
boolean useRawCoords,
|
||||
@Switch(name = 'o', desc = "Use the placement's coordinate origin")
|
||||
boolean offset,
|
||||
@Switch(name = 'c', desc = "Use the selection's center as origin")
|
||||
boolean offsetCenter) throws WorldEditException {
|
||||
final Vector3 zero;
|
||||
Vector3 unit;
|
||||
|
||||
@ -475,7 +515,7 @@ public class GenerationCommands extends MethodCommands {
|
||||
player.findFreePosition();
|
||||
BBC.VISITOR_FLAT.send(fp, affected);
|
||||
} catch (ExpressionException e) {
|
||||
fp.toWorldEditPlayer().printError(e.getMessage());
|
||||
player.printError(e.getMessage());
|
||||
}
|
||||
}, getArguments(context), region, context);
|
||||
}
|
||||
|
@ -2,16 +2,29 @@ package com.sk89q.worldedit.command;
|
||||
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import com.boydti.fawe.util.StringMan;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.sk89q.minecraft.util.commands.Command;
|
||||
import org.enginehub.piston.annotation.Command;
|
||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.extension.platform.CommandManager;
|
||||
import com.sk89q.worldedit.util.command.*;
|
||||
import com.sk89q.worldedit.extension.platform.PlatformCommandManager;
|
||||
import com.sk89q.worldedit.util.command.CommandCallable;
|
||||
import com.sk89q.worldedit.util.command.CommandMapping;
|
||||
import com.sk89q.worldedit.util.command.DelegateCallable;
|
||||
import com.sk89q.worldedit.util.command.Dispatcher;
|
||||
import com.sk89q.worldedit.util.command.PrimaryAliasComparator;
|
||||
import com.sk89q.worldedit.util.command.parametric.AParametricCallable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
public abstract class HelpBuilder implements Runnable {
|
||||
private final CommandCallable callable;
|
||||
@ -45,7 +58,6 @@ public abstract class HelpBuilder implements Runnable {
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
|
||||
boolean isRootLevel = true;
|
||||
List<String> visited = new ArrayList<>();
|
||||
|
||||
// Create the message
|
||||
@ -61,10 +73,10 @@ public abstract class HelpBuilder implements Runnable {
|
||||
Map<String, Map<CommandMapping, String>> grouped = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
|
||||
for (CommandMapping mapping : aliases) {
|
||||
CommandCallable c = mapping.getCallable();
|
||||
String group;
|
||||
if (c instanceof DelegateCallable) {
|
||||
c = ((DelegateCallable) c).getParent();
|
||||
}
|
||||
String group;
|
||||
if (c instanceof AParametricCallable) {
|
||||
Command command = ((AParametricCallable) c).getCommand();
|
||||
if (command != null && command.aliases().length != 0) {
|
||||
@ -94,6 +106,7 @@ public abstract class HelpBuilder implements Runnable {
|
||||
Map<CommandMapping, String> mappings = effectiveLength == 1 ? grouped.get(cat) : null;
|
||||
if (mappings == null) {
|
||||
// Drill down to the command
|
||||
boolean isRootLevel = true;
|
||||
for (int i = 0; i < effectiveLength; i++) {
|
||||
String command = args.getString(i);
|
||||
|
||||
@ -142,12 +155,11 @@ public abstract class HelpBuilder implements Runnable {
|
||||
found.add(closest);
|
||||
displayFailure(BBC.HELP_SUGGEST.f(arg, StringMan.join(found, ", ")));
|
||||
return;
|
||||
} else {
|
||||
String msg = String.format("The sub-command '%s' under '%s' could not be found.",
|
||||
command, Joiner.on(" ").join(visited));
|
||||
displayFailure(msg);
|
||||
return;
|
||||
}
|
||||
String msg = String.format("The sub-command '%s' under '%s' could not be found.",
|
||||
command, Joiner.on(" ").join(visited));
|
||||
displayFailure(msg);
|
||||
return;
|
||||
}
|
||||
visited.add(args.getString(i));
|
||||
isRootLevel = false;
|
||||
@ -160,7 +172,7 @@ public abstract class HelpBuilder implements Runnable {
|
||||
}
|
||||
if (!(callable instanceof Dispatcher)) {
|
||||
// TODO interactive box
|
||||
String cmd = (WorldEdit.getInstance().getConfiguration().noDoubleSlash ? "" : "/") + Joiner.on(" ").join(visited);
|
||||
String cmd = "/" + Joiner.on(" ").join(visited);
|
||||
displayUsage(callable, cmd);
|
||||
return;
|
||||
}
|
||||
@ -181,7 +193,7 @@ public abstract class HelpBuilder implements Runnable {
|
||||
return;
|
||||
}
|
||||
}
|
||||
aliases.sort(new PrimaryAliasComparator(CommandManager.COMMAND_CLEAN_PATTERN));
|
||||
aliases.sort(new PrimaryAliasComparator(PlatformCommandManager.COMMAND_CLEAN_PATTERN));
|
||||
|
||||
// Calculate pagination
|
||||
int offset = perPage * Math.max(0, page);
|
||||
@ -194,15 +206,12 @@ public abstract class HelpBuilder implements Runnable {
|
||||
int end = Math.min(offset + perPage, aliases.size());
|
||||
List<CommandMapping> subAliases = aliases.subList(offset, end);
|
||||
List<String> subPrefixes = prefixes.subList(offset, end);
|
||||
Map<CommandMapping, String> commandMap = new LinkedHashMap<>();
|
||||
for (int i = 0; i < subAliases.size(); i++) {
|
||||
commandMap.put(subAliases.get(i), subPrefixes.get(i));
|
||||
}
|
||||
Map<CommandMapping, String> commandMap = IntStream.range(0, subAliases.size()).boxed().collect(Collectors.toMap(subAliases::get, subPrefixes::get, (a, b) -> b, LinkedHashMap::new));
|
||||
String visitedString = Joiner.on(" ").join(visited);
|
||||
displayCommands(commandMap, visitedString, page, pageTotal, effectiveLength);
|
||||
}
|
||||
} else {
|
||||
String cmd = (WorldEdit.getInstance().getConfiguration().noDoubleSlash ? "" : "/") + Joiner.on(" ").join(visited);
|
||||
String cmd = "/" + Joiner.on(" ").join(visited);
|
||||
displayUsage(callable, cmd);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
|
@ -27,17 +27,18 @@ import com.boydti.fawe.database.DBHandler;
|
||||
import com.boydti.fawe.database.RollbackDatabase;
|
||||
import com.boydti.fawe.logging.rollback.RollbackOptimizedHistory;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
import com.boydti.fawe.object.FaweQueue;
|
||||
import com.boydti.fawe.object.RegionWrapper;
|
||||
import com.boydti.fawe.object.RunnableVal;
|
||||
import com.boydti.fawe.object.changeset.DiskStorageHistory;
|
||||
import com.boydti.fawe.regions.FaweMaskManager;
|
||||
import com.boydti.fawe.util.MainUtil;
|
||||
import com.boydti.fawe.util.MathMan;
|
||||
import com.sk89q.minecraft.util.commands.Command;
|
||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||
import com.sk89q.worldedit.*;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.command.util.CommandPermissions;
|
||||
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
@ -49,11 +50,14 @@ import com.sk89q.worldedit.world.World;
|
||||
import java.io.File;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import org.enginehub.piston.annotation.Command;
|
||||
import org.enginehub.piston.annotation.CommandContainer;
|
||||
import org.enginehub.piston.annotation.param.Arg;
|
||||
|
||||
/**
|
||||
* Commands to undo, redo, and clear history.
|
||||
*/
|
||||
@Command(aliases = {}, desc = "Commands to undo, redo, and clear history: [More Info](http://wiki.sk89q.com/wiki/WorldEdit/Features#History)")
|
||||
@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class)
|
||||
public class HistoryCommands extends MethodCommands {
|
||||
|
||||
/**
|
||||
@ -66,13 +70,12 @@ public class HistoryCommands extends MethodCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "fawerollback",
|
||||
aliases = {"/frb", "frb", "fawerollback", "/fawerollback", "/rollback"},
|
||||
usage = "<user=Empire92> <radius=5> <time=3d4h>",
|
||||
desc = "Undo a specific edit. " +
|
||||
" - The time uses s, m, h, d, y.\n" +
|
||||
" - Import from disk: /frb #import",
|
||||
min = 1,
|
||||
max = 3
|
||||
" - The time uses s, m, h, d, y.\n" +
|
||||
" - Import from disk: /frb #import"
|
||||
)
|
||||
@CommandPermissions("worldedit.history.rollback")
|
||||
public void faweRollback(final Player player, LocalSession session, final String user, @Optional("0") @Range(min = 0) int radius, @Optional("0") String time, @Switch('r') boolean restore) throws WorldEditException {
|
||||
@ -80,74 +83,71 @@ public class HistoryCommands extends MethodCommands {
|
||||
BBC.SETTING_DISABLE.send(player, "history.use-database (Import with /frb #import )");
|
||||
return;
|
||||
}
|
||||
switch (user.charAt(0)) {
|
||||
case '#': {
|
||||
if (user.equals("#import")) {
|
||||
if (!player.hasPermission("fawe.rollback.import")) {
|
||||
BBC.NO_PERM.send(player, "fawe.rollback.import");
|
||||
return;
|
||||
if (user.charAt(0) == '#') {
|
||||
if (user.equals("#import")) {
|
||||
if (!player.hasPermission("fawe.rollback.import")) {
|
||||
BBC.NO_PERM.send(player, "fawe.rollback.import");
|
||||
return;
|
||||
}
|
||||
File folder = MainUtil.getFile(Fawe.imp().getDirectory(), Settings.IMP.PATHS.HISTORY);
|
||||
if (!folder.exists()) {
|
||||
return;
|
||||
}
|
||||
for (File worldFolder : folder.listFiles()) {
|
||||
if (!worldFolder.isDirectory()) {
|
||||
continue;
|
||||
}
|
||||
File folder = MainUtil.getFile(Fawe.imp().getDirectory(), Settings.IMP.PATHS.HISTORY);
|
||||
if (!folder.exists()) {
|
||||
return;
|
||||
}
|
||||
for (File worldFolder : folder.listFiles()) {
|
||||
if (!worldFolder.isDirectory()) {
|
||||
continue;
|
||||
}
|
||||
String worldName = worldFolder.getName();
|
||||
World world = FaweAPI.getWorld(worldName);
|
||||
if (world != null) {
|
||||
for (File userFolder : worldFolder.listFiles()) {
|
||||
if (!userFolder.isDirectory()) {
|
||||
continue;
|
||||
}
|
||||
String userUUID = userFolder.getName();
|
||||
try {
|
||||
UUID uuid = UUID.fromString(userUUID);
|
||||
for (File historyFile : userFolder.listFiles()) {
|
||||
String name = historyFile.getName();
|
||||
if (!name.endsWith(".bd")) {
|
||||
continue;
|
||||
}
|
||||
RollbackOptimizedHistory rollback = new RollbackOptimizedHistory(world, uuid, Integer.parseInt(name.substring(0, name.length() - 3)));
|
||||
DiskStorageHistory.DiskStorageSummary summary = rollback.summarize(RegionWrapper.GLOBAL(), false);
|
||||
if (summary != null) {
|
||||
rollback.setDimensions(BlockVector3.at(summary.minX, 0, summary.minZ), BlockVector3.at(summary.maxX, 255, summary.maxZ));
|
||||
rollback.setTime(historyFile.lastModified());
|
||||
RollbackDatabase db = DBHandler.IMP.getDatabase(world);
|
||||
db.logEdit(rollback);
|
||||
player.print("Logging: " + historyFile);
|
||||
}
|
||||
String worldName = worldFolder.getName();
|
||||
World world = FaweAPI.getWorld(worldName);
|
||||
if (world != null) {
|
||||
for (File userFolder : worldFolder.listFiles()) {
|
||||
if (!userFolder.isDirectory()) {
|
||||
continue;
|
||||
}
|
||||
String userUUID = userFolder.getName();
|
||||
try {
|
||||
UUID uuid = UUID.fromString(userUUID);
|
||||
for (File historyFile : userFolder.listFiles()) {
|
||||
String name = historyFile.getName();
|
||||
if (!name.endsWith(".bd")) {
|
||||
continue;
|
||||
}
|
||||
RollbackOptimizedHistory rollback = new RollbackOptimizedHistory(world, uuid, Integer.parseInt(name.substring(0, name.length() - 3)));
|
||||
DiskStorageHistory.DiskStorageSummary summary = rollback.summarize(RegionWrapper.GLOBAL(), false);
|
||||
if (summary != null) {
|
||||
rollback.setDimensions(BlockVector3.at(summary.minX, 0, summary.minZ), BlockVector3.at(summary.maxX, 255, summary.maxZ));
|
||||
rollback.setTime(historyFile.lastModified());
|
||||
RollbackDatabase db = DBHandler.IMP.getDatabase(world);
|
||||
db.logEdit(rollback);
|
||||
player.print("Logging: " + historyFile);
|
||||
}
|
||||
} catch (IllegalArgumentException e) {
|
||||
e.printStackTrace();
|
||||
continue;
|
||||
}
|
||||
} catch (IllegalArgumentException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
player.print("Done import!");
|
||||
return;
|
||||
}
|
||||
String toParse = user.substring(1);
|
||||
if (!MathMan.isInteger(toParse)) {
|
||||
BBC.COMMAND_SYNTAX.send(player, "/frb #<index>");
|
||||
return;
|
||||
}
|
||||
int index = Integer.parseInt(toParse);
|
||||
final World world = player.getWorld();
|
||||
UUID uuid = player.getUniqueId();
|
||||
DiskStorageHistory file = new DiskStorageHistory(world, uuid, index);
|
||||
if (file.getBDFile().exists()) {
|
||||
if (restore) file.redo(FawePlayer.wrap(player));
|
||||
else file.undo(FawePlayer.wrap(player));
|
||||
BBC.ROLLBACK_ELEMENT.send(player, world.getName() + "/" + user + "-" + index);
|
||||
} else {
|
||||
BBC.TOOL_INSPECT_INFO_FOOTER.send(player, 0);
|
||||
}
|
||||
player.print("Done import!");
|
||||
return;
|
||||
}
|
||||
String toParse = user.substring(1);
|
||||
if (!MathMan.isInteger(toParse)) {
|
||||
BBC.COMMAND_SYNTAX.send(player, "/frb #<index>");
|
||||
return;
|
||||
}
|
||||
int index = Integer.parseInt(toParse);
|
||||
final World world = player.getWorld();
|
||||
UUID uuid = player.getUniqueId();
|
||||
DiskStorageHistory file = new DiskStorageHistory(world, uuid, index);
|
||||
if (file.getBDFile().exists()) {
|
||||
if (restore) file.redo(FawePlayer.wrap(player));
|
||||
else file.undo(FawePlayer.wrap(player));
|
||||
BBC.ROLLBACK_ELEMENT.send(player, world.getName() + "/" + user + "-" + index);
|
||||
} else {
|
||||
BBC.TOOL_INSPECT_INFO_FOOTER.send(player, 0);
|
||||
}
|
||||
return;
|
||||
}
|
||||
UUID other = Fawe.imp().getUUID(user);
|
||||
if (other == null) {
|
||||
@ -168,15 +168,12 @@ public class HistoryCommands extends MethodCommands {
|
||||
Location origin = player.getLocation();
|
||||
BlockVector3 bot = origin.toBlockPoint().subtract(radius, radius, radius);
|
||||
bot = bot.withY(Math.max(0, bot.getY()));
|
||||
// bot.mutY(Math.max(0, bot.getY()));
|
||||
BlockVector3 top = origin.toBlockPoint().add(radius, radius, radius);
|
||||
bot = bot.withY(Math.min(255, top.getY()));
|
||||
// top.mutY(Math.min(255, top.getY()));
|
||||
RollbackDatabase database = DBHandler.IMP.getDatabase(world);
|
||||
final AtomicInteger count = new AtomicInteger();
|
||||
final FawePlayer fp = FawePlayer.wrap(player);
|
||||
|
||||
final FaweQueue finalQueue;
|
||||
Region[] allowedRegions = fp.getCurrentRegions(FaweMaskManager.MaskType.OWNER);
|
||||
if (allowedRegions == null) {
|
||||
BBC.NO_REGION.send(fp);
|
||||
@ -200,13 +197,12 @@ public class HistoryCommands extends MethodCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"/fawerestore", "/frestore"},
|
||||
name = "fawerestore",
|
||||
alias = {"/fawerestore", "/frestore"},
|
||||
usage = "<user=Empire92|*> <radius=5> <time=3d4h>",
|
||||
desc = "Redo a specific edit. " +
|
||||
" - The time uses s, m, h, d, y.\n" +
|
||||
" - Import from disk: /frb #import",
|
||||
min = 1,
|
||||
max = 3
|
||||
" - The time uses s, m, h, d, y.\n" +
|
||||
" - Import from disk: /frb #import"
|
||||
)
|
||||
@CommandPermissions("worldedit.history.rollback")
|
||||
public void restore(final Player player, LocalSession session, final String user, @Optional("0") @Range(min = 0) int radius, @Optional("0") String time) throws WorldEditException {
|
||||
@ -214,30 +210,35 @@ public class HistoryCommands extends MethodCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"/undo", "undo"},
|
||||
usage = "[times] [player]",
|
||||
desc = "Undoes the last action",
|
||||
min = 0,
|
||||
max = 2
|
||||
name = "undo",
|
||||
aliases = { "/undo" },
|
||||
desc = "Undoes the last action (from history)"
|
||||
)
|
||||
@CommandPermissions("worldedit.history.undo")
|
||||
public void undo(Player player, LocalSession session, CommandContext context) throws WorldEditException {
|
||||
@CommandPermissions({"worldedit.history.undo", "worldedit.history.undo.self"})
|
||||
public void undo(Player player, LocalSession session,
|
||||
@Arg(desc = "Number of undoes to perform", def = "1")
|
||||
int times,
|
||||
@Arg(name = "player", desc = "Undo this player's operations", def = "")
|
||||
String playerName,
|
||||
CommandContext context) throws WorldEditException {
|
||||
if (session.hasFastMode()) {
|
||||
BBC.COMMAND_UNDO_DISABLED.send(player);
|
||||
return;
|
||||
}
|
||||
int times = Math.max(1, context.getInteger(0, 1));
|
||||
times = Math.max(1, times);
|
||||
LocalSession undoSession = session;
|
||||
int finalTimes = times;
|
||||
FawePlayer.wrap(player).checkConfirmation(() -> {
|
||||
player.checkPermission("worldedit.history.undo.other");
|
||||
EditSession undone = null;
|
||||
int i = 0;
|
||||
for (; i < times; ++i) {
|
||||
for (; i < finalTimes; ++i) {
|
||||
if (context.argsLength() < 2) {
|
||||
undone = session.undo(session.getBlockBag(player), player);
|
||||
undone = undoSession.undo(undoSession.getBlockBag(player), player);
|
||||
} else {
|
||||
player.checkPermission("worldedit.history.undo.other");
|
||||
LocalSession sess = worldEdit.getSessionManager().findByName(context.getString(1));
|
||||
LocalSession sess = worldEdit.getSessionManager().findByName(playerName);
|
||||
if (sess == null) {
|
||||
BBC.COMMAND_HISTORY_OTHER_ERROR.send(player, context.getString(1));
|
||||
BBC.COMMAND_HISTORY_OTHER_ERROR.send(player, playerName);
|
||||
break;
|
||||
}
|
||||
undone = sess.undo(session.getBlockBag(player), player);
|
||||
@ -256,54 +257,52 @@ public class HistoryCommands extends MethodCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"/redo", "redo"},
|
||||
usage = "[times] [player]",
|
||||
desc = "Redoes the last action (from history)",
|
||||
min = 0,
|
||||
max = 2
|
||||
name = "redo",
|
||||
aliases = { "/redo" },
|
||||
desc = "Redoes the last action (from history)"
|
||||
)
|
||||
@CommandPermissions("worldedit.history.redo")
|
||||
public void redo(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||
int times = Math.max(1, args.getInteger(0, 1));
|
||||
|
||||
EditSession redone = null;
|
||||
int i = 0;
|
||||
for (; i < times; ++i) {
|
||||
if (args.argsLength() < 2) {
|
||||
redone = session.redo(session.getBlockBag(player), player);
|
||||
} else {
|
||||
player.checkPermission("worldedit.history.redo.other");
|
||||
LocalSession sess = worldEdit.getSessionManager().findByName(args.getString(1));
|
||||
if (sess == null) {
|
||||
BBC.COMMAND_HISTORY_OTHER_ERROR.send(player, args.getString(1));
|
||||
break;
|
||||
}
|
||||
redone = sess.redo(session.getBlockBag(player), player);
|
||||
if (redone == null) break;
|
||||
@CommandPermissions({"worldedit.history.redo", "worldedit.history.redo.self"})
|
||||
public void redo(Player player, LocalSession session,
|
||||
@Arg(desc = "Number of redoes to perform", def = "1")
|
||||
int times,
|
||||
@Arg(name = "player", desc = "Redo this player's operations", def = "")
|
||||
String playerName) throws WorldEditException {
|
||||
times = Math.max(1, times);
|
||||
LocalSession redoSession = session;
|
||||
if (playerName != null) {
|
||||
player.checkPermission("worldedit.history.redo.other");
|
||||
redoSession = worldEdit.getSessionManager().findByName(playerName);
|
||||
if (redoSession == null) {
|
||||
player.printError("Unable to find session for " + playerName);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (redone == null) i--;
|
||||
if (i > 0) {
|
||||
BBC.COMMAND_REDO_SUCCESS.send(player, i == 1 ? "" : " x" + i);
|
||||
worldEdit.flushBlockBag(player, redone);
|
||||
int timesRedone = 0;
|
||||
for (int i = 0; i < times; ++i) {
|
||||
EditSession redone = redoSession.redo(redoSession.getBlockBag(player), player);
|
||||
if (redone != null) {
|
||||
timesRedone++;
|
||||
worldEdit.flushBlockBag(player, redone);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (redone == null) {
|
||||
if (timesRedone > 0) {
|
||||
player.print("Redid " + timesRedone + " available edits.");
|
||||
} else {
|
||||
BBC.COMMAND_REDO_ERROR.send(player);
|
||||
}
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"/clearhistory", "clearhistory"},
|
||||
usage = "",
|
||||
desc = "Clear your history",
|
||||
min = 0,
|
||||
max = 0
|
||||
name = "clearhistory",
|
||||
aliases = { "/clearhistory" },
|
||||
desc = "Clear your history"
|
||||
)
|
||||
@CommandPermissions("worldedit.history.clear")
|
||||
public void clearHistory(Player player, LocalSession session) throws WorldEditException {
|
||||
public void clearHistory(Player player, LocalSession session) {
|
||||
session.clearHistory();
|
||||
BBC.COMMAND_HISTORY_CLEAR.send(player);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.sk89q.worldedit.command;
|
||||
|
||||
import com.boydti.fawe.object.mask.*;
|
||||
import com.sk89q.minecraft.util.commands.Command;
|
||||
import org.enginehub.piston.annotation.Command;
|
||||
import com.sk89q.worldedit.IncompleteRegionException;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.sk89q.worldedit.command;
|
||||
|
||||
import com.boydti.fawe.config.Commands;
|
||||
import com.sk89q.minecraft.util.commands.Command;
|
||||
import org.enginehub.piston.annotation.Command;
|
||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||
import com.sk89q.minecraft.util.commands.CommandLocals;
|
||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||
@ -97,4 +97,4 @@ public class MethodCommands {
|
||||
}
|
||||
return new String[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,28 +20,26 @@
|
||||
package com.sk89q.worldedit.command;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.sk89q.minecraft.util.commands.Logging.LogMode.POSITION;
|
||||
import static com.sk89q.worldedit.command.util.Logging.LogMode.POSITION;
|
||||
|
||||
import com.boydti.fawe.FaweAPI;
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import com.boydti.fawe.util.MathMan;
|
||||
import com.sk89q.minecraft.util.commands.Command;
|
||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||
import com.sk89q.minecraft.util.commands.Logging;
|
||||
import com.sk89q.worldedit.LocalConfiguration;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
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.util.Location;
|
||||
import com.sk89q.worldedit.util.command.parametric.Optional;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import org.enginehub.piston.annotation.Command;
|
||||
import org.enginehub.piston.annotation.CommandContainer;
|
||||
import org.enginehub.piston.annotation.param.Arg;
|
||||
import org.enginehub.piston.annotation.param.Switch;
|
||||
|
||||
/**
|
||||
* Commands for moving the player around.
|
||||
*/
|
||||
@Command(aliases = {}, desc = "Commands for moving the player around: [More Info](https://goo.gl/uQTUiT)")
|
||||
@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class)
|
||||
public class NavigationCommands {
|
||||
|
||||
private final WorldEdit worldEdit;
|
||||
@ -57,11 +55,9 @@ public class NavigationCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "unstuck", "!" },
|
||||
usage = "",
|
||||
desc = "Escape from being stuck inside a block",
|
||||
min = 0,
|
||||
max = 0
|
||||
name = "unstuck",
|
||||
aliases = { "!" },
|
||||
desc = "Escape from being stuck inside a block"
|
||||
)
|
||||
@CommandPermissions("worldedit.navigation.unstuck")
|
||||
public void unstuck(Player player) throws WorldEditException {
|
||||
@ -70,18 +66,18 @@ public class NavigationCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"ascend", "asc"},
|
||||
usage = "[# of levels]",
|
||||
desc = "Go up a floor",
|
||||
min = 0,
|
||||
max = 1
|
||||
name = "ascend",
|
||||
aliases = { "asc" },
|
||||
desc = "Go up a floor"
|
||||
)
|
||||
@CommandPermissions("worldedit.navigation.ascend")
|
||||
public void ascend(Player player, @Optional("1") int levelsToAscend) throws WorldEditException {
|
||||
public void ascend(Player player,
|
||||
@Arg(desc = "# of levels to ascend", def = "1")
|
||||
int levels) throws WorldEditException {
|
||||
int ascentLevels = 0;
|
||||
while (player.ascendLevel()) {
|
||||
++ascentLevels;
|
||||
if (levelsToAscend == ascentLevels) {
|
||||
if (levels == ascentLevels) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -97,48 +93,46 @@ public class NavigationCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"descend", "desc"},
|
||||
usage = "[# of floors]",
|
||||
desc = "Go down a floor",
|
||||
min = 0,
|
||||
max = 1
|
||||
name = "descend",
|
||||
aliases = { "desc" },
|
||||
desc = "Go down a floor"
|
||||
)
|
||||
@CommandPermissions("worldedit.navigation.descend")
|
||||
public void descend(Player player, @Optional("1") int levelsToDescend) throws WorldEditException {
|
||||
public void descend(Player player,
|
||||
@Arg(desc = "# of levels to descend", def = "1")
|
||||
int levels) throws WorldEditException {
|
||||
int descentLevels = 0;
|
||||
while (player.descendLevel()) {
|
||||
++descentLevels;
|
||||
if (levelsToDescend == descentLevels) {
|
||||
if (levels == descentLevels) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (descentLevels == 0) {
|
||||
BBC.DESCEND_FAIL.send(player);
|
||||
} else if (descentLevels == 1) {
|
||||
BBC.DESCEND_SINGULAR.send(player);
|
||||
} else {
|
||||
if (descentLevels == 1) {
|
||||
BBC.DESCEND_SINGULAR.send(player);
|
||||
} else {
|
||||
BBC.DESCEND_PLURAL.send(player, descentLevels);
|
||||
}
|
||||
BBC.DESCEND_PLURAL.send(player, descentLevels);
|
||||
}
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"ceil"},
|
||||
usage = "[clearance]",
|
||||
desc = "Go to the celing",
|
||||
flags = "fg",
|
||||
min = 0,
|
||||
max = 1
|
||||
name = "ceil",
|
||||
desc = "Go to the ceiling"
|
||||
)
|
||||
@CommandPermissions("worldedit.navigation.ceiling")
|
||||
@Logging(POSITION)
|
||||
public void ceiling(Player player, CommandContext args) throws WorldEditException {
|
||||
public void ceiling(Player player,
|
||||
@Arg(desc = "# of blocks to leave above you", def = "0")
|
||||
int clearance,
|
||||
@Switch(name = 'f', desc = "Force using flight to keep you still")
|
||||
boolean forceFlight,
|
||||
@Switch(name = 'g', desc = "Force using glass to keep you still")
|
||||
boolean forceGlass) throws WorldEditException {
|
||||
clearance = Math.max(0, clearance);
|
||||
|
||||
final int clearance = args.argsLength() > 0 ?
|
||||
Math.max(0, args.getInteger(0)) : 0;
|
||||
|
||||
final boolean alwaysGlass = getAlwaysGlass(args);
|
||||
boolean alwaysGlass = getAlwaysGlass(forceFlight, forceGlass);
|
||||
if (player.ascendToCeiling(clearance, alwaysGlass)) {
|
||||
BBC.WHOOSH.send(player);
|
||||
} else {
|
||||
@ -147,11 +141,8 @@ public class NavigationCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"thru"},
|
||||
usage = "",
|
||||
desc = "Passthrough walls",
|
||||
min = 0,
|
||||
max = 0
|
||||
name = "thru",
|
||||
desc = "Pass through walls"
|
||||
)
|
||||
@CommandPermissions("worldedit.navigation.thru.command")
|
||||
public void thru(Player player) throws WorldEditException {
|
||||
@ -163,33 +154,16 @@ public class NavigationCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"jumpto", "j"},
|
||||
usage = "[world,x,y,z]",
|
||||
desc = "Teleport to a location\n" +
|
||||
"Flags:" +
|
||||
" -f forces the specified position to be used",
|
||||
flags = "f",
|
||||
min = 0,
|
||||
max = 1
|
||||
name = "jumpto",
|
||||
aliases = { "j" },
|
||||
desc = "Teleport to a location"
|
||||
)
|
||||
@CommandPermissions("worldedit.navigation.jumpto.command")
|
||||
public void jumpTo(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||
Location pos;
|
||||
if (args.argsLength() == 1) {
|
||||
String arg = args.getString(0);
|
||||
String[] split = arg.split(",");
|
||||
World world = FaweAPI.getWorld(split[0]);
|
||||
if (world != null && split.length == 4 && MathMan.isInteger(split[1]) && MathMan.isInteger(split[2]) && MathMan.isInteger(split[3])) {
|
||||
pos = new Location(world, Integer.parseInt(split[1]), Integer.parseInt(split[2]), Integer.parseInt(split[3]));
|
||||
} else {
|
||||
BBC.SELECTOR_INVALID_COORDINATES.send(player, args.getString(0));
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
pos = player.getSolidBlockTrace(300);
|
||||
}
|
||||
public void jumpTo(Player player) throws WorldEditException {
|
||||
|
||||
Location pos = player.getSolidBlockTrace(300);
|
||||
if (pos != null) {
|
||||
if(args.hasFlag('f')) player.setPosition(pos); else player.findFreePosition(pos);
|
||||
player.findFreePosition(pos);
|
||||
BBC.POOF.send(player);
|
||||
} else {
|
||||
BBC.NO_BLOCK.send(player);
|
||||
@ -197,19 +171,19 @@ public class NavigationCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"up"},
|
||||
usage = "<number>",
|
||||
desc = "Go upwards some distance",
|
||||
flags = "fg",
|
||||
min = 1,
|
||||
max = 1
|
||||
name = "up",
|
||||
desc = "Go upwards some distance"
|
||||
)
|
||||
@CommandPermissions("worldedit.navigation.up")
|
||||
@Logging(POSITION)
|
||||
public void up(Player player, CommandContext args) throws WorldEditException {
|
||||
final int distance = args.getInteger(0);
|
||||
|
||||
final boolean alwaysGlass = getAlwaysGlass(args);
|
||||
public void up(Player player,
|
||||
@Arg(desc = "Distance to go upwards")
|
||||
int distance,
|
||||
@Switch(name = 'f', desc = "Force using flight to keep you still")
|
||||
boolean forceFlight,
|
||||
@Switch(name = 'g', desc = "Force using glass to keep you still")
|
||||
boolean forceGlass) throws WorldEditException {
|
||||
boolean alwaysGlass = getAlwaysGlass(forceFlight, forceGlass);
|
||||
if (player.ascendUpwards(distance, alwaysGlass)) {
|
||||
BBC.WHOOSH.send(player);
|
||||
} else {
|
||||
@ -220,17 +194,13 @@ public class NavigationCommands {
|
||||
/**
|
||||
* Helper function for /up and /ceil.
|
||||
*
|
||||
* @param args The {@link CommandContext} to extract the flags from.
|
||||
* @param forceFlight if flight should be used, rather than the default config option
|
||||
* @param forceGlass if glass should always be placed, rather than the default config option
|
||||
* @return true, if glass should always be put under the player
|
||||
*/
|
||||
private boolean getAlwaysGlass(CommandContext args) {
|
||||
private boolean getAlwaysGlass(boolean forceFlight, boolean forceGlass) {
|
||||
final LocalConfiguration config = worldEdit.getConfiguration();
|
||||
|
||||
final boolean forceFlight = args.hasFlag('f');
|
||||
final boolean forceGlass = args.hasFlag('g');
|
||||
|
||||
return forceGlass || (config.navigationUseGlass && !forceFlight);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ import com.boydti.fawe.util.TextureUtil;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.sk89q.minecraft.util.commands.Command;
|
||||
import org.enginehub.piston.annotation.Command;
|
||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
|
@ -0,0 +1,150 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.command;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.blocks.BaseItem;
|
||||
import com.sk89q.worldedit.command.factory.ItemUseFactory;
|
||||
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.PermissionCondition;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.function.Contextual;
|
||||
import com.sk89q.worldedit.function.RegionFunction;
|
||||
import com.sk89q.worldedit.function.factory.Paint;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.internal.annotation.Direction;
|
||||
import com.sk89q.worldedit.internal.command.CommandRegistrationHandler;
|
||||
import com.sk89q.worldedit.regions.factory.RegionFactory;
|
||||
import com.sk89q.worldedit.util.TreeGenerator;
|
||||
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 org.enginehub.piston.CommandManager;
|
||||
import org.enginehub.piston.CommandManagerService;
|
||||
import org.enginehub.piston.CommandParameters;
|
||||
import org.enginehub.piston.annotation.Command;
|
||||
import org.enginehub.piston.annotation.CommandContainer;
|
||||
import org.enginehub.piston.annotation.param.Arg;
|
||||
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 PaintBrushCommands {
|
||||
|
||||
private static final CommandArgument REGION_FACTORY = arg(TranslatableComponent.of("shape"), TextComponent.of("The shape of the region"))
|
||||
.defaultsTo(ImmutableList.of())
|
||||
.ofTypes(ImmutableList.of(Key.of(RegionFactory.class)))
|
||||
.build();
|
||||
|
||||
private static final CommandArgument RADIUS = arg(TranslatableComponent.of("radius"), TextComponent.of("The size of the brush"))
|
||||
.defaultsTo(ImmutableList.of("5"))
|
||||
.ofTypes(ImmutableList.of(Key.of(double.class)))
|
||||
.build();
|
||||
|
||||
private static final CommandArgument DENSITY = arg(TranslatableComponent.of("density"), TextComponent.of("The density of the brush"))
|
||||
.defaultsTo(ImmutableList.of("20"))
|
||||
.ofTypes(ImmutableList.of(Key.of(double.class)))
|
||||
.build();
|
||||
|
||||
public static void register(CommandManagerService service, CommandManager commandManager, CommandRegistrationHandler registration) {
|
||||
commandManager.register("paint", builder -> {
|
||||
builder.description(TextComponent.of("Paint brush, apply a function to a surface"));
|
||||
builder.action(org.enginehub.piston.Command.Action.NULL_ACTION);
|
||||
|
||||
CommandManager manager = service.newCommandManager();
|
||||
registration.register(
|
||||
manager,
|
||||
PaintBrushCommandsRegistration.builder(),
|
||||
new PaintBrushCommands()
|
||||
);
|
||||
|
||||
builder.condition(new PermissionCondition(ImmutableSet.of("worldedit.brush.paint")));
|
||||
|
||||
builder.addParts(REGION_FACTORY, RADIUS, DENSITY);
|
||||
builder.addPart(SubCommandPart.builder(TranslatableComponent.of("type"), TextComponent.of("Type of brush to use"))
|
||||
.withCommands(manager.getAllCommands().collect(Collectors.toList()))
|
||||
.required()
|
||||
.build());
|
||||
});
|
||||
}
|
||||
|
||||
private void setPaintBrush(CommandParameters parameters, Player player, LocalSession localSession,
|
||||
Contextual<? extends RegionFunction> generatorFactory) throws WorldEditException {
|
||||
double radius = requireNonNull(RADIUS.value(parameters).asSingle(double.class));
|
||||
double density = requireNonNull(DENSITY.value(parameters).asSingle(double.class)) / 100;
|
||||
RegionFactory regionFactory = REGION_FACTORY.value(parameters).asSingle(RegionFactory.class);
|
||||
BrushCommands.setOperationBasedBrush(player, localSession, radius,
|
||||
new Paint(generatorFactory, density), regionFactory, "worldedit.brush.paint");
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "forest",
|
||||
desc = "Plant trees"
|
||||
)
|
||||
public void forest(CommandParameters parameters,
|
||||
Player player, LocalSession localSession,
|
||||
@Arg(desc = "The type of tree to plant")
|
||||
TreeGenerator.TreeType type) throws WorldEditException {
|
||||
setPaintBrush(parameters, player, localSession, new TreeGeneratorFactory(type));
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "item",
|
||||
desc = "Use an item"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.item")
|
||||
public void item(CommandParameters parameters,
|
||||
Player player, LocalSession localSession,
|
||||
@Arg(desc = "The type of item to use")
|
||||
BaseItem item,
|
||||
@Arg(desc = "The direction in which the item will be applied", def = "up")
|
||||
@Direction(includeDiagonals = true)
|
||||
com.sk89q.worldedit.util.Direction direction) throws WorldEditException {
|
||||
player.print(TextComponent.builder().append("WARNING: ", TextColor.RED, TextDecoration.BOLD)
|
||||
.append("This brush simulates item usages. Its effects may not work on all platforms, may not be undo-able," +
|
||||
" and may cause strange interactions with other mods/plugins. Use at your own risk.").build());
|
||||
setPaintBrush(parameters, player, localSession, new ItemUseFactory(item, direction));
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "set",
|
||||
desc = "Place a block"
|
||||
)
|
||||
public void set(CommandParameters parameters,
|
||||
Player player, LocalSession localSession,
|
||||
@Arg(desc = "The pattern of blocks to use")
|
||||
Pattern pattern) throws WorldEditException {
|
||||
setPaintBrush(parameters, player, localSession, new ReplaceFactory(pattern));
|
||||
}
|
||||
|
||||
}
|
@ -8,7 +8,7 @@ import com.boydti.fawe.object.pattern.*;
|
||||
import com.boydti.fawe.object.random.SimplexRandom;
|
||||
import com.boydti.fawe.util.ColorUtil;
|
||||
import com.boydti.fawe.util.TextureUtil;
|
||||
import com.sk89q.minecraft.util.commands.Command;
|
||||
import org.enginehub.piston.annotation.Command;
|
||||
import com.sk89q.worldedit.*;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extension.input.InputParseException;
|
||||
@ -47,7 +47,7 @@ public class PatternCommands extends MethodCommands {
|
||||
public PatternCommands(WorldEdit worldEdit) {
|
||||
super(worldEdit);
|
||||
}
|
||||
|
||||
|
||||
@Command(
|
||||
aliases = {"#existing", "#*", "*", ".*"},
|
||||
desc = "Use the block that is already there",
|
||||
|
@ -19,6 +19,16 @@
|
||||
|
||||
package com.sk89q.worldedit.command;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.sk89q.minecraft.util.commands.Logging.LogMode.ALL;
|
||||
import static com.sk89q.minecraft.util.commands.Logging.LogMode.REGION;
|
||||
import static com.sk89q.worldedit.command.util.Logging.LogMode.ORIENTATION_REGION;
|
||||
import static com.sk89q.worldedit.command.util.Logging.LogMode.REGION;
|
||||
import static com.sk89q.worldedit.internal.command.CommandUtil.checkCommandArgument;
|
||||
import static com.sk89q.worldedit.regions.Regions.asFlatRegion;
|
||||
import static com.sk89q.worldedit.regions.Regions.maximumBlockY;
|
||||
import static com.sk89q.worldedit.regions.Regions.minimumBlockY;
|
||||
|
||||
import com.boydti.fawe.FaweAPI;
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import com.boydti.fawe.example.NMSMappedFaweQueue;
|
||||
@ -28,20 +38,14 @@ import com.boydti.fawe.object.FaweQueue;
|
||||
import com.boydti.fawe.object.exception.FaweException;
|
||||
import com.boydti.fawe.object.visitor.Fast2DIterator;
|
||||
import com.boydti.fawe.util.MathMan;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.minecraft.util.commands.Command;
|
||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||
import com.sk89q.minecraft.util.commands.Logging;
|
||||
import static com.sk89q.minecraft.util.commands.Logging.LogMode.ALL;
|
||||
import static com.sk89q.minecraft.util.commands.Logging.LogMode.ORIENTATION_REGION;
|
||||
import static com.sk89q.minecraft.util.commands.Logging.LogMode.REGION;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
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.Capability;
|
||||
import com.sk89q.worldedit.function.GroundFunction;
|
||||
@ -67,31 +71,27 @@ import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.regions.RegionOperationException;
|
||||
import com.sk89q.worldedit.regions.Regions;
|
||||
import static com.sk89q.worldedit.regions.Regions.asFlatRegion;
|
||||
import static com.sk89q.worldedit.regions.Regions.maximumBlockY;
|
||||
import static com.sk89q.worldedit.regions.Regions.minimumBlockY;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.util.TreeGenerator.TreeType;
|
||||
import com.sk89q.worldedit.util.command.binding.Range;
|
||||
import com.sk89q.worldedit.util.command.binding.Switch;
|
||||
import com.sk89q.worldedit.util.command.binding.Text;
|
||||
import com.sk89q.worldedit.util.command.parametric.Optional;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.biome.BiomeTypes;
|
||||
import com.sk89q.worldedit.world.biome.Biomes;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.registry.BiomeRegistry;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import org.enginehub.piston.annotation.Command;
|
||||
import org.enginehub.piston.annotation.CommandContainer;
|
||||
import org.enginehub.piston.annotation.param.Arg;
|
||||
import org.enginehub.piston.annotation.param.Switch;
|
||||
|
||||
/**
|
||||
* Commands that operate on regions.
|
||||
*/
|
||||
@Command(aliases = {}, desc = "Commands that operate on regions: [More Info](http://wiki.sk89q.com/wiki/WorldEdit/Region_operations)")
|
||||
public class RegionCommands extends MethodCommands {
|
||||
@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class)
|
||||
public class RegionCommands {
|
||||
|
||||
private final WorldEdit worldEdit;
|
||||
|
||||
@ -101,16 +101,13 @@ public class RegionCommands extends MethodCommands {
|
||||
* @param worldEdit reference to WorldEdit
|
||||
*/
|
||||
public RegionCommands(WorldEdit worldEdit) {
|
||||
super(worldEdit);
|
||||
checkNotNull(worldEdit);
|
||||
this.worldEdit = worldEdit;
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"/fixlighting"},
|
||||
desc = "Get the light at a position",
|
||||
min = 0,
|
||||
max = 0
|
||||
name = "/fixlighting",
|
||||
desc = "Get the light at a position"
|
||||
)
|
||||
@CommandPermissions("worldedit.light.fix")
|
||||
public void fixlighting(Player player) throws WorldEditException {
|
||||
@ -127,10 +124,8 @@ public class RegionCommands extends MethodCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"/getlighting"},
|
||||
desc = "Get the light at a position",
|
||||
min = 0,
|
||||
max = 0
|
||||
name = "/getlighting",
|
||||
desc = "Get the light at a position"
|
||||
)
|
||||
@CommandPermissions("worldedit.light.fix")
|
||||
public void getlighting(Player player) throws WorldEditException {
|
||||
@ -141,10 +136,8 @@ public class RegionCommands extends MethodCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"/removelight", "/removelighting"},
|
||||
desc = "Removing lighting in a selection",
|
||||
min = 0,
|
||||
max = 0
|
||||
name = "/removelighting",
|
||||
desc = "Removing lighting in a selection"
|
||||
)
|
||||
@CommandPermissions("worldedit.light.remove")
|
||||
public void removelighting(Player player) {
|
||||
@ -160,7 +153,7 @@ public class RegionCommands extends MethodCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"/nbtinfo", "/nbt"},
|
||||
name = "/nbtinfo",
|
||||
desc = "View nbt info for a block"
|
||||
)
|
||||
@CommandPermissions("worldedit.nbtinfo")
|
||||
@ -179,10 +172,8 @@ public class RegionCommands extends MethodCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"/setblocklight", "/setlight"},
|
||||
desc = "Set block lighting in a selection",
|
||||
min = 1,
|
||||
max = 1
|
||||
name = "/setblocklight",
|
||||
desc = "Set block lighting in a selection"
|
||||
)
|
||||
@CommandPermissions("worldedit.light.set")
|
||||
public void setlighting(Player player, @Selection Region region, @Range(min = 0, max = 15) int value) {
|
||||
@ -200,10 +191,8 @@ public class RegionCommands extends MethodCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"/setskylight"},
|
||||
desc = "Set sky lighting in a selection",
|
||||
min = 1,
|
||||
max = 1
|
||||
name = "/setskylight"
|
||||
desc = "Set sky lighting in a selection"
|
||||
)
|
||||
@CommandPermissions("worldedit.light.set")
|
||||
public void setskylighting(Player player, @Selection Region region, @Range(min = 0, max = 15) int value) {
|
||||
@ -221,30 +210,25 @@ public class RegionCommands extends MethodCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "/line" },
|
||||
usage = "<pattern> [thickness]",
|
||||
desc = "Draws a line segment between cuboid selection corners",
|
||||
help =
|
||||
"Draws a line segment between cuboid selection corners.\n" +
|
||||
"Can only be used with cuboid selections.\n" +
|
||||
"Flags:\n" +
|
||||
" -h generates only a shell",
|
||||
flags = "h",
|
||||
min = 1,
|
||||
max = 2
|
||||
name = "/line",
|
||||
desc = "Draws a line segment between cuboid selection corners",
|
||||
descFooter = "Can only be used with a cuboid selection"
|
||||
)
|
||||
@CommandPermissions("worldedit.region.line")
|
||||
@Logging(REGION)
|
||||
public void line(Player player, EditSession editSession,
|
||||
@Selection Region region,
|
||||
Pattern pattern,
|
||||
@Optional("0") @Range(min = 0) int thickness,
|
||||
@Switch('h') boolean shell) throws WorldEditException {
|
||||
|
||||
public int line(Player player, EditSession editSession,
|
||||
@Selection Region region,
|
||||
@Arg(desc = "The pattern of blocks to place")
|
||||
Pattern pattern,
|
||||
@Arg(desc = "The thickness of the line", def = "0")
|
||||
int thickness,
|
||||
@Switch(name = 'h', desc = "Generate only a shell")
|
||||
boolean shell) throws WorldEditException {
|
||||
if (!(region instanceof CuboidRegion)) {
|
||||
player.printError("//line only works with cuboid selections");
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
checkCommandArgument(thickness >= 0, "Thickness must be >= 0");
|
||||
|
||||
CuboidRegion cuboidregion = (CuboidRegion) region;
|
||||
BlockVector3 pos1 = cuboidregion.getPos1();
|
||||
@ -252,34 +236,30 @@ public class RegionCommands extends MethodCommands {
|
||||
int blocksChanged = editSession.drawLine(pattern, pos1, pos2, thickness, !shell);
|
||||
|
||||
BBC.VISITOR_BLOCK.send(player, blocksChanged);
|
||||
return blocksChanged;
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"/curve", "/spline"},
|
||||
usage = "<pattern> [thickness]",
|
||||
desc = "Draws a spline through selected points",
|
||||
help =
|
||||
"Draws a spline through selected points.\n" +
|
||||
"Can only be used with convex polyhedral selections.\n" +
|
||||
"Flags:\n" +
|
||||
" -h generates only a shell",
|
||||
flags = "h",
|
||||
min = 1,
|
||||
max = 2
|
||||
name = "/curve",
|
||||
desc = "Draws a spline through selected points",
|
||||
descFooter = "Can only be used with a convex polyhedral selection"
|
||||
)
|
||||
@CommandPermissions("worldedit.region.curve")
|
||||
@Logging(REGION)
|
||||
public void curve(FawePlayer player, EditSession editSession,
|
||||
@Selection Region region,
|
||||
Pattern pattern,
|
||||
@Optional("0") @Range(min = 0) int thickness,
|
||||
@Switch('h') boolean shell,
|
||||
@Arg(desc = "The pattern of blocks to place")
|
||||
Pattern pattern,
|
||||
@Arg(desc = "The thickness of the curve", def = "0")
|
||||
int thickness,
|
||||
@Switch(name = 'h', desc = "Generate only a shell")
|
||||
boolean shell,
|
||||
CommandContext context) throws WorldEditException {
|
||||
if (!(region instanceof ConvexPolyhedralRegion)) {
|
||||
player.sendMessage("//curve only works with convex polyhedral selections");
|
||||
player.printError("//curve only works with convex polyhedral selections");
|
||||
return;
|
||||
}
|
||||
worldEdit.checkMaxRadius(thickness);
|
||||
checkCommandArgument(thickness >= 0, "Thickness must be >= 0");
|
||||
|
||||
player.checkConfirmationRegion(() -> {
|
||||
ConvexPolyhedralRegion cpregion = (ConvexPolyhedralRegion) region;
|
||||
@ -292,12 +272,9 @@ public class RegionCommands extends MethodCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "/replace", "/re", "/rep" },
|
||||
usage = "[from-mask] <to-pattern>",
|
||||
desc = "Replace all blocks in the selection with another",
|
||||
flags = "f",
|
||||
min = 1,
|
||||
max = 2
|
||||
name = "/replace",
|
||||
aliases = { "/re", "/rep" },
|
||||
desc = "Replace all blocks in the selection with another"
|
||||
)
|
||||
@CommandPermissions("worldedit.region.replace")
|
||||
@Logging(REGION)
|
||||
@ -337,15 +314,14 @@ public class RegionCommands extends MethodCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "/overlay" },
|
||||
usage = "<pattern>",
|
||||
desc = "Set a block on top of blocks in the region",
|
||||
min = 1,
|
||||
max = 1
|
||||
name = "/overlay",
|
||||
desc = "Set a block on top of blocks in the region"
|
||||
)
|
||||
@CommandPermissions("worldedit.region.overlay")
|
||||
@Logging(REGION)
|
||||
public void overlay(FawePlayer player, EditSession editSession, @Selection Region region, Pattern pattern, CommandContext context) throws WorldEditException {
|
||||
public void overlay(FawePlayer player, EditSession editSession, @Selection Region region,
|
||||
@Arg(desc = "The pattern of blocks to overlay")
|
||||
Pattern pattern, CommandContext context) throws WorldEditException {
|
||||
player.checkConfirmationRegion(() -> {
|
||||
int affected = editSession.overlayCuboidBlocks(region, pattern);
|
||||
BBC.VISITOR_BLOCK.send(player, affected);
|
||||
@ -363,13 +339,8 @@ public class RegionCommands extends MethodCommands {
|
||||
@Logging(REGION)
|
||||
public void lay(FawePlayer player, EditSession editSession, @Selection Region region, Pattern pattern, CommandContext context) throws WorldEditException {
|
||||
player.checkConfirmationRegion(() -> {
|
||||
BlockVector3 min = region.getMinimumPoint();
|
||||
BlockVector3 max = region.getMaximumPoint();
|
||||
BlockVector3 max = region.getMaximumPoint();
|
||||
int maxY = max.getBlockY();
|
||||
int width = region.getWidth();
|
||||
int height = region.getLength();
|
||||
int bx = min.getBlockX();
|
||||
int bz = min.getBlockZ();
|
||||
Iterable<BlockVector2> flat = Regions.asFlatRegion(region).asFlatRegion();
|
||||
Iterator<BlockVector2> iter = new Fast2DIterator(flat, editSession).iterator();
|
||||
int y = 0;
|
||||
@ -386,12 +357,10 @@ public class RegionCommands extends MethodCommands {
|
||||
}, getArguments(context), region, context);
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "/center", "/middle" },
|
||||
usage = "<pattern>",
|
||||
desc = "Set the center block(s)",
|
||||
min = 1,
|
||||
max = 1
|
||||
@org.enginehub.piston.annotation.Command(
|
||||
name = "/center",
|
||||
aliases = { "/middle" },
|
||||
desc = "Set the center block(s)"
|
||||
)
|
||||
@Logging(REGION)
|
||||
@CommandPermissions("worldedit.region.center")
|
||||
@ -401,11 +370,8 @@ public class RegionCommands extends MethodCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "/naturalize" },
|
||||
usage = "",
|
||||
desc = "3 layers of dirt on top then rock below",
|
||||
min = 0,
|
||||
max = 0
|
||||
name = "/naturalize",
|
||||
desc = "3 layers of dirt on top then rock below"
|
||||
)
|
||||
@CommandPermissions("worldedit.region.naturalize")
|
||||
@Logging(REGION)
|
||||
@ -417,11 +383,8 @@ public class RegionCommands extends MethodCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "/walls" },
|
||||
usage = "<pattern>",
|
||||
desc = "Build the four sides of the selection",
|
||||
min = 1,
|
||||
max = 1
|
||||
name = "/walls",
|
||||
desc = "Build the four sides of the selection"
|
||||
)
|
||||
@CommandPermissions("worldedit.region.walls")
|
||||
@Logging(REGION)
|
||||
@ -433,11 +396,9 @@ public class RegionCommands extends MethodCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "/faces", "/outline" },
|
||||
usage = "<pattern>",
|
||||
desc = "Build the walls, ceiling, and floor of a selection",
|
||||
min = 1,
|
||||
max = 1
|
||||
name = "/faces",
|
||||
aliases = { "/outline" },
|
||||
desc = "Build the walls, ceiling, and floor of a selection"
|
||||
)
|
||||
@CommandPermissions("worldedit.region.faces")
|
||||
@Logging(REGION)
|
||||
@ -449,15 +410,9 @@ public class RegionCommands extends MethodCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "/smooth" },
|
||||
usage = "[iterations] [filter]",
|
||||
name = "/smooth",
|
||||
desc = "Smooth the elevation in the selection",
|
||||
help =
|
||||
"Smooths the elevation in the selection.\n" +
|
||||
"Optionally, restricts the height map to a set of blocks specified with mask syntax.\n" +
|
||||
"For example, '//smooth 1 grass_block,dirt,stone' would only smooth natural surface terrain.",
|
||||
min = 0,
|
||||
max = 2
|
||||
descFooter = "Example: '//smooth 1 grass_block,dirt,stone' would only smooth natural surface terrain."
|
||||
)
|
||||
@CommandPermissions("worldedit.region.smooth")
|
||||
@Logging(REGION)
|
||||
@ -524,20 +479,27 @@ public class RegionCommands extends MethodCommands {
|
||||
"The -e ignores entities\n" +
|
||||
"The -a ignores air blocks.\n" +
|
||||
"Optionally fills the old location with <leave-id>.",
|
||||
min = 0,
|
||||
max = 3
|
||||
)
|
||||
@CommandPermissions("worldedit.region.move")
|
||||
@Logging(ORIENTATION_REGION)
|
||||
public void move(FawePlayer player, LocalSession session, EditSession editSession,
|
||||
@Selection Region region,
|
||||
@Optional("1") @Range(min = 1) int count,
|
||||
@Optional(Direction.AIM) @Direction(includeDiagonals = true) BlockVector3 direction,
|
||||
@Optional("air") Pattern replace,
|
||||
@Switch('b') boolean copyBiomes,
|
||||
@Arg(desc = "# of blocks to move", def = "1")
|
||||
int count,
|
||||
@Arg(desc = "The direction to move", def = Direction.AIM)
|
||||
@Direction(includeDiagonals = true)
|
||||
BlockVector3 direction,
|
||||
@Arg(desc = "The pattern of blocks to leave", def = "air")
|
||||
Pattern replace,
|
||||
@Switch(name = 's', desc = "Shift the selection to the target location")
|
||||
boolean moveSelection,
|
||||
@Switch(name = 'a', desc = "Ignore air blocks")
|
||||
boolean ignoreAirBlocks
|
||||
@Switch('b') boolean copyBiomes,
|
||||
|
||||
@Switch('e') boolean skipEntities,
|
||||
@Switch('a') boolean skipAir,
|
||||
@Switch('s') boolean moveSelection,
|
||||
CommandContext context) throws WorldEditException {
|
||||
player.checkConfirmationRegion(() -> {
|
||||
int affected = editSession.moveRegion(region, direction, count, !skipAir, !skipEntities, copyBiomes, replace);
|
||||
@ -549,7 +511,7 @@ public class RegionCommands extends MethodCommands {
|
||||
session.getRegionSelector(player.getWorld()).learnChanges();
|
||||
session.getRegionSelector(player.getWorld()).explainRegionAdjust(player.getPlayer(), session);
|
||||
} catch (RegionOperationException e) {
|
||||
player.sendMessage(e.getMessage());
|
||||
player.printError(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@ -562,10 +524,8 @@ public class RegionCommands extends MethodCommands {
|
||||
usage = "[replace]",
|
||||
flags = "m",
|
||||
desc = "Have the blocks in the selection fall",
|
||||
help =
|
||||
"Make the blocks in the selection fall\n" +
|
||||
"The -m flag will only fall within the vertical selection.",
|
||||
min = 0,
|
||||
help = "Make the blocks in the selection fall\n" +
|
||||
"The -m flag will only fall within the vertical selection.",
|
||||
max = 2
|
||||
)
|
||||
@CommandPermissions("worldedit.region.fall")
|
||||
@ -582,28 +542,24 @@ public class RegionCommands extends MethodCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "/stack" },
|
||||
usage = "[count] [direction]",
|
||||
flags = "sam",
|
||||
desc = "Repeat the contents of the selection",
|
||||
help =
|
||||
"Repeats the contents of the selection.\n" +
|
||||
"Flags:\n" +
|
||||
" -s shifts the selection to the last stacked copy\n" +
|
||||
" -a skips air blocks",
|
||||
min = 0,
|
||||
max = 2
|
||||
name = "/stack",
|
||||
desc = "Repeat the contents of the selection"
|
||||
)
|
||||
@CommandPermissions("worldedit.region.stack")
|
||||
@Logging(ORIENTATION_REGION)
|
||||
public void stack(FawePlayer player, EditSession editSession, LocalSession session,
|
||||
@Selection Region region,
|
||||
@Optional("1") @Range(min = 1) int count,
|
||||
@Optional(Direction.AIM) @Direction(includeDiagonals = true) BlockVector3 direction,
|
||||
@Switch('s') boolean moveSelection,
|
||||
@Switch('b') boolean copyBiomes,
|
||||
@Switch('e') boolean skipEntities,
|
||||
@Switch('a') boolean ignoreAirBlocks, @Switch('m') Mask sourceMask, CommandContext context) throws WorldEditException {
|
||||
@Arg(desc = "# of copies to stack", def = "1")
|
||||
int count,
|
||||
@Arg(desc = "The direction to stack", def = Direction.AIM)
|
||||
@Direction(includeDiagonals = true)
|
||||
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 = 'a', desc = "Ignore air blocks")
|
||||
boolean ignoreAirBlocks, @Switch('m') Mask sourceMask, CommandContext context) throws WorldEditException {
|
||||
player.checkConfirmationStack(() -> {
|
||||
if (sourceMask != null) {
|
||||
editSession.addSourceMask(sourceMask);
|
||||
@ -637,17 +593,18 @@ public class RegionCommands extends MethodCommands {
|
||||
"to modify the variables x, y and z to point to a new block\n" +
|
||||
"to fetch. See also tinyurl.com/wesyntax.",
|
||||
flags = "ro",
|
||||
min = 1,
|
||||
max = -1
|
||||
min = 1
|
||||
)
|
||||
@CommandPermissions("worldedit.region.deform")
|
||||
@Logging(ALL)
|
||||
public void deform(FawePlayer fp, Player player, LocalSession session, EditSession editSession,
|
||||
@Selection Region region,
|
||||
@Text String expression,
|
||||
@Switch('r') boolean useRawCoords,
|
||||
@Switch('o') boolean offset,
|
||||
CommandContext context) throws WorldEditException {
|
||||
@Arg(desc = "The expression to use", variable = true)
|
||||
List<String> expression,
|
||||
@Switch(name = 'r', desc = "Use the game's coordinate origin")
|
||||
boolean useRawCoords,
|
||||
@Switch(name = 'o', desc = "Use the selection's center as origin")
|
||||
boolean offset) throws WorldEditException {
|
||||
final Vector3 zero;
|
||||
Vector3 unit;
|
||||
|
||||
@ -676,7 +633,7 @@ public class RegionCommands extends MethodCommands {
|
||||
player.findFreePosition();
|
||||
BBC.VISITOR_BLOCK.send(fp, affected);
|
||||
} catch (ExpressionException e) {
|
||||
fp.sendMessage(e.getMessage());
|
||||
player.printError(e.getMessage());
|
||||
}
|
||||
}, getArguments(context), region, context);
|
||||
}
|
||||
@ -689,7 +646,6 @@ public class RegionCommands extends MethodCommands {
|
||||
"Regenerates the contents of the current selection.\n" +
|
||||
"This command might affect things outside the selection,\n" +
|
||||
"if they are within the same chunk.",
|
||||
min = 0,
|
||||
max = 2
|
||||
)
|
||||
@CommandPermissions("worldedit.regen")
|
||||
@ -697,7 +653,6 @@ public class RegionCommands extends MethodCommands {
|
||||
public void regenerateChunk(FawePlayer player, LocalSession session, EditSession editSession, @Selection Region region, CommandContext context) throws WorldEditException {
|
||||
player.checkConfirmationRegion(() -> {
|
||||
Mask mask = session.getMask();
|
||||
Mask sourceMask = session.getSourceMask();
|
||||
session.setMask((Mask) null);
|
||||
session.setSourceMask((Mask) null);
|
||||
BiomeType biome = null;
|
||||
@ -730,19 +685,19 @@ public class RegionCommands extends MethodCommands {
|
||||
aliases = { "/hollow" },
|
||||
usage = "[<thickness>[ <pattern>]]",
|
||||
desc = "Hollows out the object contained in this selection",
|
||||
help =
|
||||
"Hollows out the object contained in this selection.\n" +
|
||||
help = "Hollows out the object contained in this selection.\n" +
|
||||
"Optionally fills the hollowed out part with the given block.\n" +
|
||||
"Thickness is measured in manhattan distance.",
|
||||
min = 0,
|
||||
max = 2
|
||||
)
|
||||
@CommandPermissions("worldedit.region.hollow")
|
||||
@Logging(REGION)
|
||||
public void hollow(FawePlayer player, EditSession editSession,
|
||||
@Selection Region region,
|
||||
@Optional("0") @Range(min = 0) int thickness,
|
||||
@Optional("air") Pattern pattern,
|
||||
@Arg(desc = "Thickness of the shell to leave", def = "0")
|
||||
int thickness,
|
||||
@Arg(desc = "The pattern of blocks to replace the hollowed area with", def = "air")
|
||||
Pattern pattern,
|
||||
CommandContext context) throws WorldEditException {
|
||||
player.checkConfirmationRegion(() -> {
|
||||
int affected = editSession.hollowOutRegion(region, thickness, pattern);
|
||||
@ -751,30 +706,29 @@ public class RegionCommands extends MethodCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "/forest" },
|
||||
usage = "[type] [density]",
|
||||
desc = "Make a forest within the region",
|
||||
min = 0,
|
||||
max = 2
|
||||
name = "/forest",
|
||||
desc = "Make a forest within the region"
|
||||
)
|
||||
@CommandPermissions("worldedit.region.forest")
|
||||
@Logging(REGION)
|
||||
public void forest(Player player, EditSession editSession, @Selection Region region, @Optional("tree") TreeType type,
|
||||
@Optional("5") @Range(min = 0, max = 100) double density) throws WorldEditException {
|
||||
public void forest(Player player, 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 {
|
||||
int affected = editSession.makeForest(region, density / 100, type);
|
||||
BBC.COMMAND_TREE.send(player, affected);
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "/flora" },
|
||||
usage = "[density]",
|
||||
desc = "Make flora within the region",
|
||||
min = 0,
|
||||
max = 1
|
||||
name = "/flora",
|
||||
desc = "Make flora within the region"
|
||||
)
|
||||
@CommandPermissions("worldedit.region.flora")
|
||||
@Logging(REGION)
|
||||
public void flora(FawePlayer player, EditSession editSession, @Selection Region region, @Optional("10") @Range(min = 0, max = 100) double density, CommandContext context) throws WorldEditException {
|
||||
public void flora(FawePlayer player, EditSession editSession, @Selection Region region,
|
||||
@Arg(desc = "The density of the forest", def = "5")
|
||||
double density, CommandContext context) throws WorldEditException {
|
||||
player.checkConfirmationRegion(() -> {
|
||||
FloraGenerator generator = new FloraGenerator(editSession);
|
||||
GroundFunction ground = new GroundFunction(new ExistingBlockMask(editSession), generator);
|
||||
|
@ -19,6 +19,9 @@
|
||||
|
||||
package com.sk89q.worldedit.command;
|
||||
|
||||
import static com.boydti.fawe.util.ReflectionUtils.as;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import com.boydti.fawe.config.Commands;
|
||||
import com.boydti.fawe.config.Settings;
|
||||
@ -28,79 +31,101 @@ 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.util.MainUtil;
|
||||
import com.boydti.fawe.util.chat.Message;
|
||||
import com.sk89q.minecraft.util.commands.Command;
|
||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||
import com.sk89q.minecraft.util.commands.CommandException;
|
||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||
import com.sk89q.worldedit.LocalConfiguration;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.command.util.CommandPermissions;
|
||||
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.event.extent.PlayerSaveClipboardEvent;
|
||||
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.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.formatting.component.ErrorFormat;
|
||||
import com.sk89q.worldedit.util.formatting.component.PaginationBox;
|
||||
import com.sk89q.worldedit.util.formatting.component.SchematicPaginationBox;
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
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.*;
|
||||
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.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.*;
|
||||
import java.util.concurrent.atomic.LongAdder;
|
||||
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.concurrent.Callable;
|
||||
import java.util.regex.Pattern;
|
||||
import org.enginehub.piston.annotation.Command;
|
||||
import org.enginehub.piston.annotation.CommandContainer;
|
||||
import org.enginehub.piston.annotation.param.Arg;
|
||||
import org.enginehub.piston.annotation.param.ArgFlag;
|
||||
import org.enginehub.piston.annotation.param.Switch;
|
||||
import org.enginehub.piston.exception.StopExecutionException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import static com.boydti.fawe.util.ReflectionUtils.as;
|
||||
//import com.boydti.fawe.object.schematic.visualizer.SchemVis;
|
||||
|
||||
/**
|
||||
* Commands that work with schematic files.
|
||||
*/
|
||||
@Command(aliases = {"schematic", "schem", "/schematic", "/schem", "clipboard", "/clipboard"}, desc = "Commands that work with schematic files")
|
||||
public class SchematicCommands extends MethodCommands {
|
||||
@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class)
|
||||
public class SchematicCommands {
|
||||
|
||||
/**
|
||||
* 9 schematics per page fits in the MC chat window.
|
||||
*/
|
||||
private static final int SCHEMATICS_PER_PAGE = 9;
|
||||
private static final Logger log = LoggerFactory.getLogger(SchematicCommands.class);
|
||||
private final WorldEdit worldEdit;
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
*
|
||||
* @param worldEdit reference to WorldEdit
|
||||
*/
|
||||
public SchematicCommands(final WorldEdit worldEdit) {
|
||||
super(worldEdit);
|
||||
public SchematicCommands(WorldEdit worldEdit) {
|
||||
checkNotNull(worldEdit);
|
||||
this.worldEdit = worldEdit;
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"loadall"},
|
||||
usage = "[<format>] <filename|url>",
|
||||
help = "Load multiple clipboards\n" +
|
||||
"The -r flag will apply random rotation",
|
||||
desc = "Load multiple clipboards (paste will randomly choose one)"
|
||||
name = "loadall",
|
||||
desc = "Load multiple clipboards (paste will randomly choose one)",
|
||||
descFooter = "Load multiple clipboards (paste will randomly choose one)\n" +
|
||||
"The -r flag will apply random rotation"
|
||||
)
|
||||
@Deprecated
|
||||
@CommandPermissions({"worldedit.clipboard.load", "worldedit.schematic.load", "worldedit.schematic.load.web", "worldedit.schematic.load.asset"})
|
||||
public void loadall(final Player player, final LocalSession session, @Optional("schematic") final String formatName, final String filename, @Switch('r') boolean randomRotate) throws FilenameException {
|
||||
public void loadall(final Player player, final LocalSession session,
|
||||
@Arg(desc = "Format name.", def = "schematic")
|
||||
final String formatName,
|
||||
@Arg(desc = "File name.")
|
||||
final String filename,
|
||||
@Switch(name = 'r', desc = "Apply random rotation")
|
||||
boolean randomRotate) throws FilenameException {
|
||||
final ClipboardFormat format = ClipboardFormats.findByAlias(formatName);
|
||||
if (format == null) {
|
||||
BBC.CLIPBOARD_INVALID_FORMAT.send(player, formatName);
|
||||
@ -118,9 +143,8 @@ public class SchematicCommands extends MethodCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"clear"},
|
||||
desc = "Clear your clipboard",
|
||||
max = 0
|
||||
name = "clear",
|
||||
desc = "Clear your clipboard"
|
||||
)
|
||||
@CommandPermissions({"worldedit.clipboard.clear", "worldedit.schematic.clear"})
|
||||
public void clear(Player player, LocalSession session) throws WorldEditException {
|
||||
@ -129,11 +153,8 @@ public class SchematicCommands extends MethodCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"unload"},
|
||||
usage = "[file]",
|
||||
desc = "Remove a clipboard from your multi-clipboard",
|
||||
min = 1,
|
||||
max = 1
|
||||
name = "unload",
|
||||
desc = "Remove a clipboard from your multi-clipboard"
|
||||
)
|
||||
@CommandPermissions({"worldedit.clipboard.clear", "worldedit.schematic.clear"})
|
||||
public void unload(Player player, LocalSession session, String fileName) throws WorldEditException {
|
||||
@ -166,19 +187,13 @@ public class SchematicCommands extends MethodCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"remap"},
|
||||
help = "Remap a clipboard between MCPE/PC values",
|
||||
name = "remap",
|
||||
desc = "Remap a clipboard between MCPE/PC values"
|
||||
)
|
||||
@Deprecated
|
||||
@CommandPermissions({"worldedit.schematic.remap"})
|
||||
public void remap(final Player player, final LocalSession session) throws WorldEditException {
|
||||
ClipboardRemapper remapper;
|
||||
if (false) {
|
||||
remapper = new ClipboardRemapper(ClipboardRemapper.RemapPlatform.PC, ClipboardRemapper.RemapPlatform.PE);
|
||||
} else {
|
||||
remapper = new ClipboardRemapper(ClipboardRemapper.RemapPlatform.PE, ClipboardRemapper.RemapPlatform.PC);
|
||||
}
|
||||
ClipboardRemapper remapper = new ClipboardRemapper(ClipboardRemapper.RemapPlatform.PE, ClipboardRemapper.RemapPlatform.PC);
|
||||
|
||||
for (Clipboard clip : session.getClipboard().getClipboards()) {
|
||||
remapper.apply(clip);
|
||||
@ -187,13 +202,15 @@ public class SchematicCommands extends MethodCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"load"},
|
||||
usage = "[<format>] <filename>",
|
||||
desc = "Load a schematic into your clipboard"
|
||||
name = "load",
|
||||
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(Player player, LocalSession session, @Optional() String formatName, String filename) throws FilenameException {
|
||||
public void load(Player player, LocalSession session,
|
||||
@Arg(desc = "File name.")
|
||||
String filename,
|
||||
@Arg(desc = "Format name.", def = "sponge")
|
||||
String formatName) throws FilenameException {
|
||||
LocalConfiguration config = worldEdit.getConfiguration();
|
||||
ClipboardFormat format = formatName == null ? null : ClipboardFormats.findByAlias(formatName);
|
||||
InputStream in = null;
|
||||
@ -236,7 +253,7 @@ public class SchematicCommands extends MethodCommands {
|
||||
return;
|
||||
}
|
||||
if (format == null && filename.matches(".*\\.[\\w].*")) {
|
||||
String extension = filename.substring(filename.lastIndexOf('.') + 1, filename.length());
|
||||
String extension = filename.substring(filename.lastIndexOf('.') + 1);
|
||||
format = ClipboardFormats.findByExtension(extension);
|
||||
}
|
||||
f = MainUtil.resolve(dir, filename, format, false);
|
||||
@ -248,7 +265,7 @@ public class SchematicCommands extends MethodCommands {
|
||||
}
|
||||
}
|
||||
if (f == null || !f.exists() || !MainUtil.isInSubDirectory(working, f)) {
|
||||
player.printError("Schematic " + filename + " does not exist! (" + ((f != null) && f.exists()) + "|" + f + "|" + (f != null && !MainUtil.isInSubDirectory(working, f)) + ")");
|
||||
player.printError("Schematic " + filename + " does not exist! (" + (f != null && f.exists()) + "|" + f + "|" + (f != null && !MainUtil.isInSubDirectory(working, f)) + ")");
|
||||
return;
|
||||
}
|
||||
if (format == null) {
|
||||
@ -279,33 +296,58 @@ 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"
|
||||
name = "save",
|
||||
desc = "Save a schematic into your clipboard"
|
||||
)
|
||||
@Deprecated
|
||||
@CommandPermissions({"worldedit.clipboard.save", "worldedit.schematic.save", "worldedit.schematic.save.other"})
|
||||
public void save(Player player, LocalSession session, @Optional("schem") String formatName, String filename, @Switch('g') boolean global, @Switch('f') boolean allowOverwrite) throws CommandException, WorldEditException {
|
||||
public void save(Player player, LocalSession session,
|
||||
@Arg(desc = "File name.")
|
||||
String filename,
|
||||
@Arg(desc = "Format name.", def = "sponge")
|
||||
String formatName,
|
||||
@Switch(name = 'f', desc = "Overwrite an existing file.")
|
||||
boolean allowOverwrite,
|
||||
@Switch(name = 'g', desc = "//TODO")
|
||||
boolean global
|
||||
) throws WorldEditException {
|
||||
LocalConfiguration config = worldEdit.getConfiguration();
|
||||
|
||||
File dir = worldEdit.getWorkingDirectoryFile(config.saveDir);
|
||||
|
||||
if (!global && Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS) {
|
||||
dir = new File(dir, player.getUniqueId().toString());
|
||||
}
|
||||
|
||||
ClipboardFormat format = ClipboardFormats.findByAlias(formatName);
|
||||
if (format == null) {
|
||||
player.printError("Unknown schematic format: " + formatName);
|
||||
return;
|
||||
}
|
||||
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")) {
|
||||
BBC.NO_PERM.send(player, "worldedit.schematic.save.other");
|
||||
return;
|
||||
}
|
||||
if (filename.startsWith("../")) {
|
||||
dir = working;
|
||||
dir = worldEdit.getWorkingDirectoryFile(config.saveDir);
|
||||
filename = filename.substring(3);
|
||||
}
|
||||
}
|
||||
File f = worldEdit.getSafeSaveFile(player, dir, filename, format.getPrimaryFileExtension(), format.getPrimaryFileExtension());
|
||||
|
||||
File f = worldEdit.getSafeSaveFile(player, dir, filename, format.getPrimaryFileExtension());
|
||||
|
||||
boolean overwrite = f.exists();
|
||||
if (overwrite) {
|
||||
if (!player.hasPermission("worldedit.schematic.delete")) {
|
||||
throw new StopExecutionException(TextComponent.of("That schematic already exists!"));
|
||||
}
|
||||
if (!allowOverwrite) {
|
||||
player.printError("That schematic already exists. Use the -f flag to overwrite it.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (f.getName().replaceAll("." + format.getPrimaryFileExtension(), "").isEmpty()) {
|
||||
File directory = f.getParentFile();
|
||||
if (directory.exists()) {
|
||||
@ -315,16 +357,13 @@ public class SchematicCommands extends MethodCommands {
|
||||
f = new File(directory, "1." + format.getPrimaryFileExtension());
|
||||
}
|
||||
}
|
||||
final File parent = f.getParentFile();
|
||||
if ((parent != null) && !parent.exists()) {
|
||||
|
||||
// Create parent directories
|
||||
File parent = f.getParentFile();
|
||||
if (parent != null && !parent.exists()) {
|
||||
if (!parent.mkdirs()) {
|
||||
try {
|
||||
Files.createDirectories(parent.toPath());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
log.info("Could not create folder for schematics!");
|
||||
return;
|
||||
}
|
||||
throw new StopExecutionException(TextComponent.of(
|
||||
"Could not create folder for schematics!"));
|
||||
}
|
||||
}
|
||||
try {
|
||||
@ -333,8 +372,10 @@ public class SchematicCommands extends MethodCommands {
|
||||
} else if (!allowOverwrite) {
|
||||
BBC.SCHEMATIC_MOVE_EXISTS.send(player, f.getName());
|
||||
}
|
||||
|
||||
ClipboardHolder holder = session.getClipboard();
|
||||
|
||||
try (FileOutputStream fos = new FileOutputStream(f)) {
|
||||
ClipboardHolder holder = session.getClipboard();
|
||||
Clipboard clipboard = holder.getClipboard();
|
||||
Transform transform = holder.getTransform();
|
||||
Clipboard target;
|
||||
@ -350,7 +391,9 @@ public class SchematicCommands extends MethodCommands {
|
||||
}
|
||||
|
||||
URI uri = null;
|
||||
if (holder instanceof URIClipboardHolder) uri = ((URIClipboardHolder) holder).getURI(clipboard);
|
||||
if (holder instanceof URIClipboardHolder) {
|
||||
uri = ((URIClipboardHolder) holder).getURI(clipboard);
|
||||
}
|
||||
if (new PlayerSaveClipboardEvent(player, clipboard, uri, f.toURI()).call()) {
|
||||
try (ClipboardWriter writer = format.getWriter(fos)) {
|
||||
if (writer instanceof StructureFormat) {
|
||||
@ -376,12 +419,9 @@ 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
|
||||
name = "move",
|
||||
aliases = {"m"},
|
||||
desc = "Move your loaded schematic"
|
||||
)
|
||||
@CommandPermissions({"worldedit.schematic.move", "worldedit.schematic.move.other"})
|
||||
public void move(Player player, LocalSession session, String directory) throws WorldEditException, IOException {
|
||||
@ -429,55 +469,53 @@ 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
|
||||
name = "delete",
|
||||
aliases = {"d"},
|
||||
desc = "Delete a saved schematic"
|
||||
)
|
||||
@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();
|
||||
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 delete(Actor actor, LocalSession session,
|
||||
@Arg(desc = "File name.")
|
||||
String filename) throws WorldEditException, IOException {
|
||||
LocalConfiguration config = worldEdit.getConfiguration();
|
||||
File working = worldEdit.getWorkingDirectoryFile(config.saveDir);
|
||||
File dir = Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS ? new File(working, actor.getUniqueId().toString()) : working;
|
||||
List<File> files = new ArrayList<>();
|
||||
|
||||
final String filename = args.getString(0);
|
||||
|
||||
if (filename.equalsIgnoreCase("*")) {
|
||||
files.addAll(getFiles(session.getClipboard()));
|
||||
} else {
|
||||
File f = MainUtil.resolveRelative(new File(dir, filename));
|
||||
files.add(f);
|
||||
}
|
||||
|
||||
if (files.isEmpty()) {
|
||||
BBC.SCHEMATIC_NONE.send(player);
|
||||
BBC.SCHEMATIC_NONE.send(actor);
|
||||
return;
|
||||
}
|
||||
for (File f : files) {
|
||||
if (!MainUtil.isInSubDirectory(working, f) || !f.exists()) {
|
||||
player.printError("Schematic " + filename + " does not exist! (" + f.exists() + "|" + f + "|" + (!MainUtil.isInSubDirectory(working, f)) + ")");
|
||||
actor.printError("Schematic " + filename + " does not exist! (" + f.exists() + "|" + f + "|" + (!MainUtil.isInSubDirectory(working, f)) + ")");
|
||||
continue;
|
||||
}
|
||||
if (Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS && !MainUtil.isInSubDirectory(dir, f) && !player.hasPermission("worldedit.schematic.delete.other")) {
|
||||
BBC.NO_PERM.send(player, "worldedit.schematic.delete.other");
|
||||
if (Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS && !MainUtil.isInSubDirectory(dir, f) && !actor.hasPermission("worldedit.schematic.delete.other")) {
|
||||
BBC.NO_PERM.send(actor, "worldedit.schematic.delete.other");
|
||||
continue;
|
||||
}
|
||||
if (!delete(f)) {
|
||||
player.printError("Deletion of " + filename + " failed! Maybe it is read-only.");
|
||||
if (!f.delete()) {
|
||||
actor.printError("Deletion of " + filename + " failed! Maybe it is read-only.");
|
||||
continue;
|
||||
}
|
||||
BBC.FILE_DELETED.send(player, filename);
|
||||
BBC.FILE_DELETED.send(actor, filename);
|
||||
}
|
||||
}
|
||||
|
||||
private List<File> getFiles(ClipboardHolder clipboard) {
|
||||
List<File> files = new ArrayList<>();
|
||||
Collection<URI> uris = Collections.emptyList();
|
||||
if (clipboard instanceof URIClipboardHolder) {
|
||||
uris = ((URIClipboardHolder) clipboard).getURIs();
|
||||
}
|
||||
List<File> files = new ArrayList<>();
|
||||
for (URI uri : uris) {
|
||||
File file = new File(uri);
|
||||
if (file.exists()) files.add(file);
|
||||
@ -485,40 +523,29 @@ public class SchematicCommands extends MethodCommands {
|
||||
return files;
|
||||
}
|
||||
|
||||
private boolean delete(File file) {
|
||||
if (file.delete()) {
|
||||
new File(file.getParentFile(), "." + file.getName() + ".cached").delete();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"formats", "listformats", "f"},
|
||||
desc = "List available formats",
|
||||
max = 0
|
||||
name = "formats",
|
||||
aliases = {"listformats", "f"},
|
||||
desc = "List available formats"
|
||||
)
|
||||
@CommandPermissions("worldedit.schematic.formats")
|
||||
public void formats(final Actor actor) throws WorldEditException {
|
||||
BBC.SCHEMATIC_FORMAT.send(actor);
|
||||
Message m = new Message(BBC.SCHEMATIC_FORMAT).newline();
|
||||
String baseCmd = Commands.getAlias(SchematicCommands.class, "schematic") + " " + Commands.getAlias(SchematicCommands.class, "save");
|
||||
public void formats(Actor actor) {
|
||||
actor.print("Available clipboard formats (Name: Lookup names)");
|
||||
StringBuilder builder;
|
||||
boolean first = true;
|
||||
for (final ClipboardFormat format : ClipboardFormats.getAll()) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for (ClipboardFormat format : ClipboardFormats.getAll()) {
|
||||
builder = new StringBuilder();
|
||||
builder.append(format.getName()).append(": ");
|
||||
for (final String lookupName : format.getAliases()) {
|
||||
for (String lookupName : format.getAliases()) {
|
||||
if (!first) {
|
||||
builder.append(", ");
|
||||
}
|
||||
builder.append(lookupName);
|
||||
first = false;
|
||||
}
|
||||
String cmd = baseCmd + " " + format.getName() + " <filename>";
|
||||
m.text(builder).suggestTip(cmd).newline();
|
||||
first = true;
|
||||
actor.print(builder.toString());
|
||||
}
|
||||
m.send(actor);
|
||||
}
|
||||
|
||||
|
||||
@ -587,25 +614,21 @@ public class SchematicCommands extends MethodCommands {
|
||||
*/
|
||||
|
||||
@Command(
|
||||
aliases = {"list", "ls", "all"},
|
||||
desc = "List saved schematics",
|
||||
usage = "[global|mine|<filter>] [page=1]",
|
||||
flags = "dnp",
|
||||
help = "List all schematics in the schematics directory\n" +
|
||||
" -p <page> prints the requested page\n" +
|
||||
" -f <format> restricts by format\n"
|
||||
name = "list",
|
||||
aliases = {"all", "ls"},
|
||||
desc = "List saved schematics",
|
||||
descFooter = "Note: Format is not fully verified until loading."
|
||||
)
|
||||
@CommandPermissions("worldedit.schematic.list")
|
||||
public void list(FawePlayer fp, Actor actor, CommandContext args, @Switch('p') @Optional("1") int page, @Switch('f') String formatName) throws WorldEditException {
|
||||
if (args.argsLength() == 0) {
|
||||
BBC.COMMAND_SYNTAX.send(fp, getCommand().usage());
|
||||
return;
|
||||
}
|
||||
public void list(FawePlayer fp, Actor actor, CommandContext args,
|
||||
@ArgFlag(name = 'p', desc = "Page to view.", def = "1")
|
||||
int page,
|
||||
@Switch(name = 'f', desc = "Restricts by format.")
|
||||
String formatName) throws WorldEditException {
|
||||
LocalConfiguration config = worldEdit.getConfiguration();
|
||||
String prefix = config.noDoubleSlash ? "" : "/";
|
||||
File dir = worldEdit.getWorkingDirectoryFile(config.saveDir);
|
||||
|
||||
String schemCmd = prefix + Commands.getAlias(SchematicCommands.class, "schematic");
|
||||
String schemCmd = "/" + Commands.getAlias(SchematicCommands.class, "schematic");
|
||||
String loadSingle = schemCmd + " " + Commands.getAlias(SchematicCommands.class, "load");
|
||||
String loadMulti = schemCmd + " " + Commands.getAlias(SchematicCommands.class, "loadall");
|
||||
String unload = schemCmd + " " + Commands.getAlias(SchematicCommands.class, "unload");
|
||||
@ -623,7 +646,6 @@ public class SchematicCommands extends MethodCommands {
|
||||
boolean loaded = multi != null && multi.contains(uri);
|
||||
|
||||
String name = relFilePath;
|
||||
String color;
|
||||
String uriStr = uri.toString();
|
||||
if (uriStr.startsWith("file:/")) {
|
||||
File file = new File(uri.getPath());
|
||||
@ -635,38 +657,163 @@ public class SchematicCommands extends MethodCommands {
|
||||
} catch (IOException ignore) {}
|
||||
if (file.isDirectory()) {
|
||||
isDir = true;
|
||||
color = "&6";
|
||||
} else {
|
||||
color = "&a";
|
||||
if (name.indexOf('.') != -1) name = name.substring(0, name.lastIndexOf('.'));
|
||||
} else if (name.indexOf('.') != -1) {
|
||||
name = name.substring(0, name.lastIndexOf('.'));
|
||||
}
|
||||
} else if (uriStr.startsWith("http://") || uriStr.startsWith("https://")) {
|
||||
// url
|
||||
color = "&9";
|
||||
} else {
|
||||
color = "&7";
|
||||
}
|
||||
} // url
|
||||
|
||||
msg.text("&8 - ");
|
||||
msg.text(" - ");
|
||||
|
||||
if (msg.supportsInteraction()) {
|
||||
if (loaded) {
|
||||
msg.text("&7[&c-&7]").command(unload + " " + relFilePath).tooltip("Unload");
|
||||
msg.text("[-]").command(unload + " " + relFilePath).tooltip("Unload");
|
||||
} else {
|
||||
msg.text("&7[&a+&7]").command(loadMulti + " " + relFilePath).tooltip("Add to clipboard");
|
||||
msg.text("[+]").command(loadMulti + " " + relFilePath).tooltip("Add to clipboard");
|
||||
}
|
||||
if (!isDir) msg.text("&7[&cX&7]").suggest("/" + delete + " " + relFilePath).tooltip("Delete");
|
||||
else if (hasShow) msg.text("&7[&3O&7]").command(showCmd + " " + args.getJoinedStrings(0) + " " + relFilePath).tooltip("Show");
|
||||
msg.text(color + name);
|
||||
if (!isDir) msg.text("[X]").suggest("/" + delete + " " + relFilePath).tooltip("Delete");
|
||||
else if (hasShow) msg.text("[O]").command(showCmd + " " + args.getJoinedStrings(0) + " " + relFilePath).tooltip("Show");
|
||||
msg.text(name);
|
||||
if (isDir) {
|
||||
msg.command(list + " " + relFilePath).tooltip("List");
|
||||
} else {
|
||||
msg.command(loadSingle + " " + relFilePath).tooltip("Load");
|
||||
}
|
||||
} else {
|
||||
msg.text(color).text(name);
|
||||
msg.text(name);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static class SchematicLoadTask implements Callable<ClipboardHolder> {
|
||||
private final Player player;
|
||||
private final File file;
|
||||
private final ClipboardFormat format;
|
||||
|
||||
SchematicLoadTask(Player player, File file, ClipboardFormat format) {
|
||||
this.player = player;
|
||||
this.file = file;
|
||||
this.format = format;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClipboardHolder call() throws Exception {
|
||||
try (Closer closer = Closer.create()) {
|
||||
FileInputStream fis = closer.register(new FileInputStream(file));
|
||||
BufferedInputStream bis = closer.register(new BufferedInputStream(fis));
|
||||
ClipboardReader reader = closer.register(format.getReader(bis));
|
||||
|
||||
Clipboard clipboard = reader.read();
|
||||
log.info(player.getName() + " loaded " + file.getCanonicalPath());
|
||||
return new ClipboardHolder(clipboard);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class SchematicSaveTask implements Callable<Void> {
|
||||
private final Player player;
|
||||
private final File file;
|
||||
private final ClipboardFormat format;
|
||||
private final ClipboardHolder holder;
|
||||
private final boolean overwrite;
|
||||
|
||||
SchematicSaveTask(Player player, File file, ClipboardFormat format, ClipboardHolder holder, boolean overwrite) {
|
||||
this.player = player;
|
||||
this.file = file;
|
||||
this.format = format;
|
||||
this.holder = holder;
|
||||
this.overwrite = overwrite;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void call() throws Exception {
|
||||
Clipboard clipboard = holder.getClipboard();
|
||||
Transform transform = holder.getTransform();
|
||||
Clipboard target;
|
||||
|
||||
// If we have a transform, bake it into the copy
|
||||
if (transform.isIdentity()) {
|
||||
target = clipboard;
|
||||
} else {
|
||||
FlattenedClipboardTransform result = FlattenedClipboardTransform.transform(clipboard, transform);
|
||||
target = new BlockArrayClipboard(result.getTransformedRegion());
|
||||
target.setOrigin(clipboard.getOrigin());
|
||||
Operations.completeLegacy(result.copyTo(target));
|
||||
}
|
||||
|
||||
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(target);
|
||||
|
||||
log.info(player.getName() + " saved " + file.getCanonicalPath() + (overwrite ? " (overwriting previous file)" : ""));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static class SchematicListTask implements Callable<Component> {
|
||||
private final String prefix;
|
||||
private final int sortType;
|
||||
private final int page;
|
||||
private final File rootDir;
|
||||
private final String pageCommand;
|
||||
|
||||
SchematicListTask(String prefix, int sortType, int page, String pageCommand) {
|
||||
this.prefix = prefix;
|
||||
this.sortType = sortType;
|
||||
this.page = page;
|
||||
this.rootDir = WorldEdit.getInstance().getWorkingDirectoryFile(prefix);
|
||||
this.pageCommand = pageCommand;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component call() throws Exception {
|
||||
List<File> fileList = allFiles(rootDir);
|
||||
|
||||
if (fileList == null || fileList.isEmpty()) {
|
||||
return ErrorFormat.wrap("No schematics found.");
|
||||
}
|
||||
|
||||
File[] files = new File[fileList.size()];
|
||||
fileList.toArray(files);
|
||||
// cleanup file list
|
||||
Arrays.sort(files, (f1, f2) -> {
|
||||
// http://stackoverflow.com/questions/203030/best-way-to-list-files-in-java-sorted-by-date-modified
|
||||
int res;
|
||||
if (sortType == 0) { // use name by default
|
||||
int p = f1.getParent().compareTo(f2.getParent());
|
||||
if (p == 0) { // same parent, compare names
|
||||
res = f1.getName().compareTo(f2.getName());
|
||||
} else { // different parent, sort by that
|
||||
res = p;
|
||||
}
|
||||
} else {
|
||||
res = Long.compare(f1.lastModified(), f2.lastModified()); // use date if there is a flag
|
||||
if (sortType == 1) res = -res; // flip date for newest first instead of oldest first
|
||||
}
|
||||
return res;
|
||||
});
|
||||
|
||||
PaginationBox paginationBox = new SchematicPaginationBox(prefix, files, pageCommand);
|
||||
return paginationBox.create(page);
|
||||
}
|
||||
}
|
||||
|
||||
private static List<File> allFiles(File root) {
|
||||
File[] files = root.listFiles();
|
||||
if (files == null) return null;
|
||||
List<File> fileList = new ArrayList<>();
|
||||
for (File f : files) {
|
||||
if (f.isDirectory()) {
|
||||
List<File> subFiles = allFiles(f);
|
||||
if (subFiles == null) continue; // empty subdir
|
||||
fileList.addAll(subFiles);
|
||||
} else {
|
||||
fileList.add(f);
|
||||
}
|
||||
}
|
||||
return fileList;
|
||||
}
|
||||
}
|
||||
|
@ -19,39 +19,48 @@
|
||||
|
||||
package com.sk89q.worldedit.command;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.sk89q.worldedit.command.util.Logging.LogMode.ALL;
|
||||
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import com.boydti.fawe.wrappers.LocationMaskedPlayerWrapper;
|
||||
import com.sk89q.minecraft.util.commands.Command;
|
||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||
import com.sk89q.minecraft.util.commands.Logging;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
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.extension.platform.Capability;
|
||||
import com.sk89q.worldedit.extension.platform.CommandManager;
|
||||
import com.sk89q.worldedit.extension.platform.PlatformCommandManager;
|
||||
import com.sk89q.worldedit.scripting.CraftScriptContext;
|
||||
import com.sk89q.worldedit.scripting.CraftScriptEngine;
|
||||
import com.sk89q.worldedit.scripting.RhinoCraftScriptEngine;
|
||||
import com.sk89q.worldedit.session.request.Request;
|
||||
import org.mozilla.javascript.NativeJavaObject;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.script.ScriptException;
|
||||
import java.io.*;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Stream;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.script.ScriptException;
|
||||
import org.enginehub.piston.annotation.Command;
|
||||
import org.enginehub.piston.annotation.CommandContainer;
|
||||
import org.enginehub.piston.annotation.param.Arg;
|
||||
import org.mozilla.javascript.NativeJavaObject;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.sk89q.minecraft.util.commands.Logging.LogMode.ALL;
|
||||
|
||||
/**
|
||||
* Commands related to scripting.
|
||||
*/
|
||||
@Command(aliases = {}, desc = "Run craftscripts: [More Info](https://goo.gl/dHDxLG)")
|
||||
@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class)
|
||||
public class ScriptingCommands {
|
||||
|
||||
private final WorldEdit worldEdit;
|
||||
@ -61,21 +70,18 @@ public class ScriptingCommands {
|
||||
*
|
||||
* @param worldEdit reference to WorldEdit
|
||||
*/
|
||||
public ScriptingCommands(final WorldEdit worldEdit) {
|
||||
public ScriptingCommands(WorldEdit worldEdit) {
|
||||
checkNotNull(worldEdit);
|
||||
this.worldEdit = worldEdit;
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"setupdispatcher"},
|
||||
desc = "",
|
||||
usage = "",
|
||||
min = 1,
|
||||
max = 1
|
||||
name = "setupdispatcher",
|
||||
desc = ""
|
||||
)
|
||||
@CommandPermissions("fawe.setupdispatcher")
|
||||
public void setupdispatcher(Player player, LocalSession session, final CommandContext args) throws WorldEditException {
|
||||
CommandManager.getInstance().setupDispatcher();
|
||||
PlatformCommandManager.getInstance().setupDispatcher();
|
||||
}
|
||||
|
||||
public static <T> T runScript(Player player, File f, String[] args) throws WorldEditException {
|
||||
@ -112,7 +118,7 @@ public class ScriptingCommands {
|
||||
byte[] data = new byte[in.available()];
|
||||
in.readFully(data);
|
||||
in.close();
|
||||
script = new String(data, 0, data.length, "utf-8");
|
||||
script = new String(data, 0, data.length, StandardCharsets.UTF_8);
|
||||
} catch (IOException e) {
|
||||
actor.printError("Script read error: " + e.getMessage());
|
||||
return null;
|
||||
@ -157,9 +163,7 @@ public class ScriptingCommands {
|
||||
e.printStackTrace();
|
||||
actor.printError("Failed to execute:");
|
||||
actor.printRaw(e.getMessage());
|
||||
} catch (NumberFormatException e) {
|
||||
throw e;
|
||||
} catch (WorldEditException e) {
|
||||
} catch (NumberFormatException | WorldEditException e) {
|
||||
throw e;
|
||||
} catch (Throwable e) {
|
||||
actor.printError("Failed to execute (see console):");
|
||||
@ -172,22 +176,25 @@ public class ScriptingCommands {
|
||||
return (T) result;
|
||||
}
|
||||
|
||||
@Command(aliases = {"cs"}, usage = "<filename> [args...]", desc = "Execute a CraftScript", min = 1, max = -1)
|
||||
@Command(
|
||||
name = "cs",
|
||||
desc = "Execute a CraftScript"
|
||||
)
|
||||
@CommandPermissions("worldedit.scripting.execute")
|
||||
@Logging(ALL)
|
||||
public void execute(final Player player, final LocalSession session, final CommandContext args) throws WorldEditException {
|
||||
public void execute(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||
final String[] scriptArgs = args.getSlice(1);
|
||||
final String name = args.getString(0);
|
||||
final String filename = args.getString(0);
|
||||
|
||||
if (!player.hasPermission("worldedit.scripting.execute." + name)) {
|
||||
if (!player.hasPermission("worldedit.scripting.execute." + filename)) {
|
||||
BBC.SCRIPTING_NO_PERM.send(player);
|
||||
return;
|
||||
}
|
||||
|
||||
session.setLastScript(name);
|
||||
session.setLastScript(filename);
|
||||
|
||||
final File dir = this.worldEdit.getWorkingDirectoryFile(this.worldEdit.getConfiguration().scriptsDir);
|
||||
final File f = this.worldEdit.getSafeOpenFile(player, dir, name, "js", "js");
|
||||
File dir = worldEdit.getWorkingDirectoryFile(worldEdit.getConfiguration().scriptsDir);
|
||||
File f = worldEdit.getSafeOpenFile(player, dir, filename, "js", "js");
|
||||
try {
|
||||
new RhinoCraftScriptEngine();
|
||||
} catch (NoClassDefFoundError e) {
|
||||
@ -200,10 +207,15 @@ public class ScriptingCommands {
|
||||
runScript(LocationMaskedPlayerWrapper.unwrap(player), f, scriptArgs);
|
||||
}
|
||||
|
||||
@Command(aliases = {".s"}, usage = "[args...]", desc = "Execute last CraftScript", min = 0, max = -1)
|
||||
@Command(
|
||||
name = ".s",
|
||||
desc = "Execute last CraftScript"
|
||||
)
|
||||
@CommandPermissions("worldedit.scripting.execute")
|
||||
@Logging(ALL)
|
||||
public void executeLast(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||
public void executeLast(Player player, LocalSession session,
|
||||
@Arg(desc = "Arguments to the CraftScript", def = "", variable = true)
|
||||
List<String> args) throws WorldEditException {
|
||||
|
||||
String lastScript = session.getLastScript();
|
||||
|
||||
@ -217,17 +229,10 @@ public class ScriptingCommands {
|
||||
return;
|
||||
}
|
||||
|
||||
final String[] scriptArgs = args.getSlice(0);
|
||||
File dir = worldEdit.getWorkingDirectoryFile(worldEdit.getConfiguration().scriptsDir);
|
||||
File f = worldEdit.getSafeOpenFile(player, dir, lastScript, "js", "js");
|
||||
|
||||
final File dir = this.worldEdit.getWorkingDirectoryFile(this.worldEdit.getConfiguration().scriptsDir);
|
||||
final File f = this.worldEdit.getSafeOpenFile(player, dir, lastScript, "js", "js");
|
||||
|
||||
try {
|
||||
this.worldEdit.runScript(LocationMaskedPlayerWrapper.unwrap(player), f, scriptArgs);
|
||||
} catch (final WorldEditException ex) {
|
||||
BBC.SCRIPTING_ERROR.send(player);
|
||||
}
|
||||
worldEdit.runScript(player, f, Stream.concat(Stream.of(lastScript), args.stream())
|
||||
.toArray(String[]::new));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -19,27 +19,31 @@
|
||||
|
||||
package com.sk89q.worldedit.command;
|
||||
|
||||
import static com.sk89q.worldedit.command.util.Logging.LogMode.POSITION;
|
||||
import static com.sk89q.worldedit.command.util.Logging.LogMode.REGION;
|
||||
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import com.boydti.fawe.object.clipboard.URIClipboardHolder;
|
||||
import com.boydti.fawe.object.mask.IdMask;
|
||||
import com.boydti.fawe.object.regions.selector.FuzzyRegionSelector;
|
||||
import com.boydti.fawe.object.regions.selector.PolyhedralRegionSelector;
|
||||
import com.sk89q.minecraft.util.commands.Command;
|
||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||
import com.sk89q.minecraft.util.commands.CommandException;
|
||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||
import com.sk89q.minecraft.util.commands.Logging;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||
import com.sk89q.worldedit.command.argument.SelectorChoice;
|
||||
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.input.ParserContext;
|
||||
import com.sk89q.worldedit.extension.platform.permission.ActorSelectorLimits;
|
||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.internal.annotation.Direction;
|
||||
import com.sk89q.worldedit.internal.annotation.MultiDirection;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
@ -55,28 +59,29 @@ import com.sk89q.worldedit.regions.selector.RegionSelectorType;
|
||||
import com.sk89q.worldedit.regions.selector.SphereRegionSelector;
|
||||
import com.sk89q.worldedit.session.ClipboardHolder;
|
||||
import com.sk89q.worldedit.util.Countable;
|
||||
import com.sk89q.worldedit.util.command.binding.Switch;
|
||||
import com.sk89q.worldedit.util.formatting.ColorCodeBuilder;
|
||||
import com.sk89q.worldedit.util.formatting.Style;
|
||||
import com.sk89q.worldedit.util.formatting.StyledFragment;
|
||||
import com.sk89q.worldedit.util.formatting.component.CommandListBox;
|
||||
import com.sk89q.worldedit.util.formatting.component.SubtleFormat;
|
||||
import com.sk89q.worldedit.util.formatting.component.TextComponentProducer;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.event.ClickEvent;
|
||||
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.item.ItemTypes;
|
||||
import com.sk89q.worldedit.world.storage.ChunkStore;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import static com.sk89q.minecraft.util.commands.Logging.LogMode.POSITION;
|
||||
import static com.sk89q.minecraft.util.commands.Logging.LogMode.REGION;
|
||||
import java.util.stream.Stream;
|
||||
import org.enginehub.piston.annotation.Command;
|
||||
import org.enginehub.piston.annotation.CommandContainer;
|
||||
import org.enginehub.piston.annotation.param.Arg;
|
||||
import org.enginehub.piston.annotation.param.Switch;
|
||||
|
||||
/**
|
||||
* Selection commands.
|
||||
*/
|
||||
@Command(aliases = {}, desc = "Change your selection points, mode or view info about your selection: [More Info](http://wiki.sk89q.com/wiki/WorldEdit/Selection)")
|
||||
@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class)
|
||||
public class SelectionCommands {
|
||||
|
||||
private final WorldEdit we;
|
||||
@ -86,26 +91,17 @@ public class SelectionCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"/pos1", "posa", "/1"},
|
||||
usage = "[coordinates]",
|
||||
desc = "Set position 1",
|
||||
min = 0,
|
||||
max = 1
|
||||
name = "/pos1",
|
||||
desc = "Set position 1"
|
||||
)
|
||||
@Logging(POSITION)
|
||||
@CommandPermissions("worldedit.selection.pos")
|
||||
public void pos1(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||
|
||||
public void pos1(Player player, LocalSession session,
|
||||
@Arg(desc = "Coordinates to set position 1 to", def = "")
|
||||
BlockVector3 coordinates) throws WorldEditException {
|
||||
BlockVector3 pos;
|
||||
|
||||
if (args.argsLength() == 1) {
|
||||
if (args.getString(0).matches("-?\\d+,-?\\d+,-?\\d+")) {
|
||||
String[] coords = args.getString(0).split(",");
|
||||
pos = BlockVector3.at(Integer.parseInt(coords[0]), Integer.parseInt(coords[1]), Integer.parseInt(coords[2]));
|
||||
} else {
|
||||
BBC.SELECTOR_INVALID_COORDINATES.send(player, args.getString(0));
|
||||
return;
|
||||
}
|
||||
if (coordinates != null) {
|
||||
pos = coordinates;
|
||||
} else {
|
||||
pos = player.getBlockIn().toBlockPoint();
|
||||
}
|
||||
@ -115,31 +111,22 @@ public class SelectionCommands {
|
||||
return;
|
||||
}
|
||||
|
||||
session.getRegionSelector(player.getWorld()).explainPrimarySelection(player, session, pos);
|
||||
session.getRegionSelector(player.getWorld())
|
||||
.explainPrimarySelection(player, session, pos);
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"/pos2", "posb", "/2"},
|
||||
usage = "[coordinates]",
|
||||
desc = "Set position 2",
|
||||
min = 0,
|
||||
max = 1
|
||||
name = "/pos2",
|
||||
desc = "Set position 2"
|
||||
)
|
||||
@Logging(POSITION)
|
||||
@CommandPermissions("worldedit.selection.pos")
|
||||
public void pos2(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||
|
||||
public void pos2(Player player, LocalSession session,
|
||||
@Arg(desc = "Coordinates to set position 2 to", def = "")
|
||||
BlockVector3 coordinates) throws WorldEditException {
|
||||
BlockVector3 pos;
|
||||
if (args.argsLength() == 1) {
|
||||
if (args.getString(0).matches("-?\\d+,-?\\d+,-?\\d+")) {
|
||||
String[] coords = args.getString(0).split(",");
|
||||
pos = BlockVector3.at(Integer.parseInt(coords[0]),
|
||||
Integer.parseInt(coords[1]),
|
||||
Integer.parseInt(coords[2]));
|
||||
} else {
|
||||
BBC.SELECTOR_INVALID_COORDINATES.send(player, args.getString(0));
|
||||
return;
|
||||
}
|
||||
if (coordinates != null) {
|
||||
pos = coordinates;
|
||||
} else {
|
||||
pos = player.getBlockIn().toBlockPoint();
|
||||
}
|
||||
@ -154,15 +141,13 @@ public class SelectionCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"/hpos1"},
|
||||
usage = "",
|
||||
desc = "Set position 1 to targeted block",
|
||||
min = 0,
|
||||
max = 0
|
||||
name = "/hpos1",
|
||||
desc = "Set position 1 to targeted block"
|
||||
)
|
||||
@CommandPermissions("worldedit.selection.hpos")
|
||||
public void hpos1(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||
BlockVector3 pos = player.getBlockTrace(300).toBlockPoint();
|
||||
public void hpos1(Player player, LocalSession session) throws WorldEditException {
|
||||
|
||||
BlockVector3 pos = player.getBlockTrace(300).toBlockPoint();
|
||||
|
||||
if (pos != null) {
|
||||
if (!session.getRegionSelector(player.getWorld()).selectPrimary(pos, ActorSelectorLimits.forActor(player))) {
|
||||
@ -178,15 +163,13 @@ public class SelectionCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"/hpos2"},
|
||||
usage = "",
|
||||
desc = "Set position 2 to targeted block",
|
||||
min = 0,
|
||||
max = 0
|
||||
name = "/hpos2",
|
||||
desc = "Set position 2 to targeted block"
|
||||
)
|
||||
@CommandPermissions("worldedit.selection.hpos")
|
||||
public void hpos2(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||
BlockVector3 pos = player.getBlockTrace(300).toBlockPoint();
|
||||
public void hpos2(Player player, LocalSession session) throws WorldEditException {
|
||||
|
||||
BlockVector3 pos = player.getBlockTrace(300).toBlockPoint();
|
||||
|
||||
if (pos != null) {
|
||||
if (!session.getRegionSelector(player.getWorld()).selectSecondary(pos, ActorSelectorLimits.forActor(player))) {
|
||||
@ -202,28 +185,22 @@ public class SelectionCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"/chunk"},
|
||||
usage = "[x,z coordinates]",
|
||||
flags = "sc",
|
||||
desc = "Set the selection to your current chunk.",
|
||||
help =
|
||||
"Set the selection to the chunk you are currently in.\n" +
|
||||
"With the -s flag, your current selection is expanded\n" +
|
||||
"to encompass all chunks that are part of it.\n\n" +
|
||||
"Specifying coordinates will use those instead of your\n" +
|
||||
"current position. Use -c to specify chunk coordinates,\n" +
|
||||
"otherwise full coordinates will be implied.\n" +
|
||||
"(for example, the coordinates 5,5 are the same as -c 0,0)",
|
||||
min = 0,
|
||||
max = 1
|
||||
name = "/chunk",
|
||||
desc = "Set the selection to your current chunk."
|
||||
)
|
||||
@Logging(POSITION)
|
||||
@CommandPermissions("worldedit.selection.chunk")
|
||||
public void chunk(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||
public void chunk(Player player, LocalSession session,
|
||||
@Arg(desc = "The chunk to select", def = "")
|
||||
BlockVector2 coordinates,
|
||||
@Switch(name = 's', desc = "Expand your selection to encompass all chunks that are part of it")
|
||||
boolean expandSelection,
|
||||
@Switch(name = 'c', desc = "Use chunk coordinates instead of block coordinates")
|
||||
boolean useChunkCoordinates) throws WorldEditException {
|
||||
final BlockVector3 min;
|
||||
final BlockVector3 max;
|
||||
final World world = player.getWorld();
|
||||
if (args.hasFlag('s')) {
|
||||
if (expandSelection) {
|
||||
Region region = session.getSelection(world);
|
||||
|
||||
final BlockVector2 min2D = ChunkStore.toChunk(region.getMinimumPoint());
|
||||
@ -235,16 +212,11 @@ public class SelectionCommands {
|
||||
BBC.SELECTION_CHUNKS.send(player, min2D.getBlockX() + ", " + min2D.getBlockZ(), max2D.getBlockX() + ", " + max2D.getBlockZ());
|
||||
} else {
|
||||
final BlockVector2 min2D;
|
||||
if (args.argsLength() == 1) {
|
||||
if (coordinates != null) {
|
||||
// coords specified
|
||||
String[] coords = args.getString(0).split(",");
|
||||
if (coords.length != 2) {
|
||||
BBC.SELECTOR_INVALID_COORDINATES.send(player, args.getString(0));
|
||||
}
|
||||
int x = Integer.parseInt(coords[0]);
|
||||
int z = Integer.parseInt(coords[1]);
|
||||
BlockVector2 pos = BlockVector2.at(x, z);
|
||||
min2D = (args.hasFlag('c')) ? pos : ChunkStore.toChunk(pos.toBlockVector3());
|
||||
min2D = useChunkCoordinates
|
||||
? coordinates
|
||||
: ChunkStore.toChunk(coordinates.toBlockVector3());
|
||||
} else {
|
||||
// use player loc
|
||||
min2D = ChunkStore.toChunk(player.getBlockIn().toBlockPoint());
|
||||
@ -271,14 +243,12 @@ public class SelectionCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"/wand", "/w"},
|
||||
usage = "",
|
||||
desc = "Get the wand object",
|
||||
min = 0,
|
||||
max = 0
|
||||
name = "/wand",
|
||||
desc = "Get the wand object"
|
||||
)
|
||||
@CommandPermissions("worldedit.wand")
|
||||
public void wand(Player player) throws WorldEditException {
|
||||
public void wand(Player player, LocalSession session,
|
||||
@Switch(name = 'n', desc = "Get a navigation wand") boolean navWand) throws WorldEditException {
|
||||
player.giveItem(new BaseItemStack(ItemTypes.parse(we.getConfiguration().wandItem), 1));
|
||||
BBC.SELECTION_WAND.send(player);
|
||||
if (!player.hasPermission("fawe.tips"))
|
||||
@ -286,176 +256,46 @@ public class SelectionCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"toggleeditwand"},
|
||||
usage = "",
|
||||
desc = "Toggle functionality of the edit wand",
|
||||
min = 0,
|
||||
max = 0
|
||||
name = "toggleeditwand",
|
||||
desc = "Remind the user that the wand is now a tool and can be unbound with /none."
|
||||
)
|
||||
@CommandPermissions("worldedit.wand.toggle")
|
||||
public void toggleWand(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||
|
||||
session.setToolControl(!session.isToolControlEnabled());
|
||||
|
||||
if (session.isToolControlEnabled()) {
|
||||
BBC.SELECTION_WAND_ENABLE.m().send(player);
|
||||
} else {
|
||||
BBC.SELECTION_WAND_DISABLE.send(player);
|
||||
}
|
||||
public void toggleWand(Player player) {
|
||||
player.print(TextComponent.of("The selection wand is now a normal tool. You can disable it with ")
|
||||
.append(TextComponent.of("/none", TextColor.AQUA).clickEvent(
|
||||
ClickEvent.of(ClickEvent.Action.RUN_COMMAND, "/none")))
|
||||
.append(TextComponent.of(" and rebind it to any item with "))
|
||||
.append(TextComponent.of("//selwand", TextColor.AQUA).clickEvent(
|
||||
ClickEvent.of(ClickEvent.Action.RUN_COMMAND, "//selwand")))
|
||||
.append(TextComponent.of(" or get a new wand with "))
|
||||
.append(TextComponent.of("//wand", TextColor.AQUA).clickEvent(
|
||||
ClickEvent.of(ClickEvent.Action.RUN_COMMAND, "//wand"))));
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"/expand"},
|
||||
usage = "<amount> [reverse-amount] <direction>",
|
||||
desc = "Expand the selection area",
|
||||
min = 1,
|
||||
max = 3
|
||||
)
|
||||
@Logging(REGION)
|
||||
@CommandPermissions("worldedit.selection.expand")
|
||||
public void expand(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||
|
||||
// Special syntax (//expand vert) to expand the selection between
|
||||
// sky and bedrock.
|
||||
if (args.getString(0).equalsIgnoreCase("vert") || args.getString(0).equalsIgnoreCase("vertical")) {
|
||||
Region region = session.getSelection(player.getWorld());
|
||||
try {
|
||||
int oldSize = region.getArea();
|
||||
region.expand(
|
||||
BlockVector3.at(0, (player.getWorld().getMaxY() + 1), 0),
|
||||
BlockVector3.at(0, -(player.getWorld().getMaxY() + 1), 0));
|
||||
session.getRegionSelector(player.getWorld()).learnChanges();
|
||||
int newSize = region.getArea();
|
||||
session.getRegionSelector(player.getWorld()).explainRegionAdjust(player, session);
|
||||
BBC.SELECTION_EXPAND_VERT.send(player, (newSize - oldSize));
|
||||
} catch (RegionOperationException e) {
|
||||
player.printError(e.getMessage());
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
List<BlockVector3> dirs = new ArrayList<>();
|
||||
int change = args.getInteger(0);
|
||||
int reverseChange = 0;
|
||||
|
||||
switch (args.argsLength()) {
|
||||
case 2:
|
||||
// Either a reverse amount or a direction
|
||||
try {
|
||||
reverseChange = args.getInteger(1);
|
||||
dirs.add(we.getDirection(player, "me"));
|
||||
} catch (NumberFormatException e) {
|
||||
if (args.getString(1).contains(",")) {
|
||||
String[] split = args.getString(1).split(",");
|
||||
for (String s : split) {
|
||||
dirs.add(we.getDirection(player, s.toLowerCase()));
|
||||
}
|
||||
} else {
|
||||
dirs.add(we.getDirection(player, args.getString(1).toLowerCase()));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 3:
|
||||
// Both reverse amount and direction
|
||||
reverseChange = args.getInteger(1);
|
||||
if (args.getString(2).contains(",")) {
|
||||
String[] split = args.getString(2).split(",");
|
||||
for (String s : split) {
|
||||
dirs.add(we.getDirection(player, s.toLowerCase()));
|
||||
}
|
||||
} else {
|
||||
dirs.add(we.getDirection(player, args.getString(2).toLowerCase()));
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
dirs.add(we.getDirection(player, "me"));
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
Region region = session.getSelection(player.getWorld());
|
||||
int oldSize = region.getArea();
|
||||
|
||||
if (reverseChange == 0) {
|
||||
for (BlockVector3 dir : dirs) {
|
||||
region.expand(dir.multiply(change));
|
||||
}
|
||||
} else {
|
||||
for (BlockVector3 dir : dirs) {
|
||||
region.expand(dir.multiply(change), dir.multiply(-reverseChange));
|
||||
}
|
||||
}
|
||||
|
||||
session.getRegionSelector(player.getWorld()).learnChanges();
|
||||
int newSize = region.getArea();
|
||||
|
||||
session.getRegionSelector(player.getWorld()).explainRegionAdjust(player, session);
|
||||
BBC.SELECTION_EXPAND.send(player, (newSize - oldSize));
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"/contract"},
|
||||
usage = "<amount> [reverse-amount] [direction]",
|
||||
desc = "Contract the selection area",
|
||||
min = 1,
|
||||
max = 3
|
||||
name = "/contract",
|
||||
desc = "Contract the selection area"
|
||||
)
|
||||
@Logging(REGION)
|
||||
@CommandPermissions("worldedit.selection.contract")
|
||||
public void contract(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||
|
||||
List<BlockVector3> dirs = new ArrayList<>();
|
||||
int change = args.getInteger(0);
|
||||
int reverseChange = 0;
|
||||
|
||||
switch (args.argsLength()) {
|
||||
case 2:
|
||||
// Either a reverse amount or a direction
|
||||
try {
|
||||
reverseChange = args.getInteger(1);
|
||||
dirs.add(we.getDirection(player, "me"));
|
||||
} catch (NumberFormatException e) {
|
||||
if (args.getString(1).contains(",")) {
|
||||
String[] split = args.getString(1).split(",");
|
||||
for (String s : split) {
|
||||
dirs.add(we.getDirection(player, s.toLowerCase()));
|
||||
}
|
||||
} else {
|
||||
dirs.add(we.getDirection(player, args.getString(1).toLowerCase()));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 3:
|
||||
// Both reverse amount and direction
|
||||
reverseChange = args.getInteger(1);
|
||||
if (args.getString(2).contains(",")) {
|
||||
String[] split = args.getString(2).split(",");
|
||||
for (String s : split) {
|
||||
dirs.add(we.getDirection(player, s.toLowerCase()));
|
||||
}
|
||||
} else {
|
||||
dirs.add(we.getDirection(player, args.getString(2).toLowerCase()));
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
dirs.add(we.getDirection(player, "me"));
|
||||
break;
|
||||
}
|
||||
|
||||
public void contract(Player player, LocalSession session,
|
||||
@Arg(desc = "Amount to contract the selection by")
|
||||
int amount,
|
||||
@Arg(desc = "Amount to contract the selection by in the other direction", def = "0")
|
||||
int reverseAmount,
|
||||
@Arg(desc = "Direction to contract", def = Direction.AIM)
|
||||
@MultiDirection
|
||||
List<BlockVector3> direction) throws WorldEditException {
|
||||
try {
|
||||
Region region = session.getSelection(player.getWorld());
|
||||
int oldSize = region.getArea();
|
||||
if (reverseChange == 0) {
|
||||
for (BlockVector3 dir : dirs) {
|
||||
region.contract(dir.multiply(change));
|
||||
if (reverseAmount == 0) {
|
||||
for (BlockVector3 dir : direction) {
|
||||
region.contract(dir.multiply(amount));
|
||||
}
|
||||
} else {
|
||||
for (BlockVector3 dir : dirs) {
|
||||
region.contract(dir.multiply(change), dir.multiply(-reverseChange));
|
||||
for (BlockVector3 dir : direction) {
|
||||
region.contract(dir.multiply(amount), dir.multiply(-reverseAmount));
|
||||
}
|
||||
}
|
||||
session.getRegionSelector(player.getWorld()).learnChanges();
|
||||
@ -463,6 +303,7 @@ public class SelectionCommands {
|
||||
|
||||
session.getRegionSelector(player.getWorld()).explainRegionAdjust(player, session);
|
||||
|
||||
|
||||
BBC.SELECTION_CONTRACT.send(player, (oldSize - newSize));
|
||||
} catch (RegionOperationException e) {
|
||||
player.printError(e.getMessage());
|
||||
@ -470,40 +311,28 @@ public class SelectionCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"/shift"},
|
||||
usage = "<amount> [direction]",
|
||||
desc = "Shift the selection area",
|
||||
min = 1,
|
||||
max = 2
|
||||
name = "/shift",
|
||||
desc = "Shift the selection area"
|
||||
)
|
||||
@Logging(REGION)
|
||||
@CommandPermissions("worldedit.selection.shift")
|
||||
public void shift(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||
|
||||
List<BlockVector3> dirs = new ArrayList<>();
|
||||
int change = args.getInteger(0);
|
||||
if (args.argsLength() == 2) {
|
||||
if (args.getString(1).contains(",")) {
|
||||
for (String s : args.getString(1).split(",")) {
|
||||
dirs.add(we.getDirection(player, s.toLowerCase()));
|
||||
}
|
||||
} else {
|
||||
dirs.add(we.getDirection(player, args.getString(1).toLowerCase()));
|
||||
}
|
||||
} else {
|
||||
dirs.add(we.getDirection(player, "me"));
|
||||
}
|
||||
|
||||
public void shift(Player player, LocalSession session,
|
||||
@Arg(desc = "Amount to shift the selection by")
|
||||
int amount,
|
||||
@Arg(desc = "Direction to contract", def = Direction.AIM)
|
||||
@MultiDirection
|
||||
List<BlockVector3> direction) throws WorldEditException {
|
||||
try {
|
||||
Region region = session.getSelection(player.getWorld());
|
||||
|
||||
for (BlockVector3 dir : dirs) {
|
||||
region.shift(dir.multiply(change));
|
||||
for (BlockVector3 dir : direction) {
|
||||
region.shift(dir.multiply(amount));
|
||||
}
|
||||
|
||||
session.getRegionSelector(player.getWorld()).learnChanges();
|
||||
|
||||
session.getRegionSelector(player.getWorld()).explainRegionAdjust(player, session);
|
||||
|
||||
BBC.SELECTION_SHIFT.send(player);
|
||||
} catch (RegionOperationException e) {
|
||||
player.printError(e.getMessage());
|
||||
@ -511,81 +340,73 @@ public class SelectionCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"/outset"},
|
||||
usage = "<amount>",
|
||||
desc = "Outset the selection area",
|
||||
help =
|
||||
"Expands the selection by the given amount in all directions.\n" +
|
||||
"Flags:\n" +
|
||||
" -h only expand horizontally\n" +
|
||||
" -v only expand vertically\n",
|
||||
flags = "hv",
|
||||
min = 1,
|
||||
max = 1
|
||||
name = "/outset",
|
||||
desc = "Outset the selection area"
|
||||
)
|
||||
@Logging(REGION)
|
||||
@CommandPermissions("worldedit.selection.outset")
|
||||
public void outset(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||
public void outset(Player player, LocalSession session,
|
||||
@Arg(desc = "Amount to expand the selection by in all directions")
|
||||
int amount,
|
||||
@Switch(name = 'h', desc = "Only expand horizontally")
|
||||
boolean onlyHorizontal,
|
||||
@Switch(name = 'v', desc = "Only expand vertically")
|
||||
boolean onlyVertical) throws WorldEditException {
|
||||
Region region = session.getSelection(player.getWorld());
|
||||
region.expand(getChangesForEachDir(args));
|
||||
region.expand(getChangesForEachDir(amount, onlyHorizontal, onlyVertical));
|
||||
session.getRegionSelector(player.getWorld()).learnChanges();
|
||||
session.getRegionSelector(player.getWorld()).explainRegionAdjust(player, session);
|
||||
BBC.SELECTION_OUTSET.send(player);
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"/inset"},
|
||||
usage = "<amount>",
|
||||
desc = "Inset the selection area",
|
||||
help =
|
||||
"Contracts the selection by the given amount in all directions.\n" +
|
||||
"Flags:\n" +
|
||||
" -h only contract horizontally\n" +
|
||||
" -v only contract vertically\n",
|
||||
flags = "hv",
|
||||
min = 1,
|
||||
max = 1
|
||||
name = "/inset",
|
||||
desc = "Inset the selection area"
|
||||
)
|
||||
@Logging(REGION)
|
||||
@CommandPermissions("worldedit.selection.inset")
|
||||
public void inset(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||
public void inset(Player player, LocalSession session,
|
||||
@Arg(desc = "Amount to contract the selection by in all directions")
|
||||
int amount,
|
||||
@Switch(name = 'h', desc = "Only contract horizontally")
|
||||
boolean onlyHorizontal,
|
||||
@Switch(name = 'v', desc = "Only contract vertically")
|
||||
boolean onlyVertical) throws WorldEditException {
|
||||
Region region = session.getSelection(player.getWorld());
|
||||
region.contract(getChangesForEachDir(args));
|
||||
region.contract(getChangesForEachDir(amount, onlyHorizontal, onlyVertical));
|
||||
session.getRegionSelector(player.getWorld()).learnChanges();
|
||||
session.getRegionSelector(player.getWorld()).explainRegionAdjust(player, session);
|
||||
BBC.SELECTION_INSET.send(player);
|
||||
}
|
||||
|
||||
private BlockVector3[] getChangesForEachDir(CommandContext args) {
|
||||
List<BlockVector3> changes = new ArrayList<>(6);
|
||||
int change = args.getInteger(0);
|
||||
private BlockVector3[] getChangesForEachDir(int amount, boolean onlyHorizontal, boolean onlyVertical) {
|
||||
Stream.Builder<BlockVector3> changes = Stream.builder();
|
||||
|
||||
if (!args.hasFlag('h')) {
|
||||
changes.add((BlockVector3.at(0, 1, 0)).multiply(change));
|
||||
changes.add((BlockVector3.at(0, -1, 0)).multiply(change));
|
||||
if (!onlyHorizontal) {
|
||||
changes.add(BlockVector3.UNIT_Y);
|
||||
changes.add(BlockVector3.UNIT_MINUS_Y);
|
||||
}
|
||||
|
||||
if (!args.hasFlag('v')) {
|
||||
changes.add((BlockVector3.at(1, 0, 0)).multiply(change));
|
||||
changes.add((BlockVector3.at(-1, 0, 0)).multiply(change));
|
||||
changes.add((BlockVector3.at(0, 0, 1)).multiply(change));
|
||||
changes.add((BlockVector3.at(0, 0, -1)).multiply(change));
|
||||
if (!onlyVertical) {
|
||||
changes.add(BlockVector3.UNIT_X);
|
||||
changes.add(BlockVector3.UNIT_MINUS_X);
|
||||
changes.add(BlockVector3.UNIT_Z);
|
||||
changes.add(BlockVector3.UNIT_MINUS_Z);
|
||||
}
|
||||
|
||||
return changes.toArray(new BlockVector3[0]);
|
||||
return changes.build().map(v -> v.multiply(amount)).toArray(BlockVector3[]::new);
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"/size"},
|
||||
flags = "c",
|
||||
usage = "",
|
||||
desc = "Get information about the selection",
|
||||
min = 0,
|
||||
max = 0
|
||||
name = "/size",
|
||||
desc = "Get information about the selection"
|
||||
)
|
||||
@CommandPermissions("worldedit.selection.size")
|
||||
public void size(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
if (args.hasFlag('c')) {
|
||||
public void size(Player player, LocalSession session,
|
||||
@Switch(name = 'c', desc = "Get clipboard info instead")
|
||||
boolean clipboardInfo) throws WorldEditException {
|
||||
Region region;
|
||||
if (clipboardInfo) {
|
||||
ClipboardHolder root = session.getClipboard();
|
||||
// Clipboard clipboard = holder.getClipboard();
|
||||
int index = 0;
|
||||
@ -603,8 +424,10 @@ public class SelectionCommands {
|
||||
name = Integer.toString(index);
|
||||
}
|
||||
|
||||
Region region = clipboard.getRegion();
|
||||
BlockVector3 size = region.getMaximumPoint().subtract(region.getMinimumPoint()).add(BlockVector3.ONE);
|
||||
region = clipboard.getRegion();
|
||||
BlockVector3 size = region.getMaximumPoint()
|
||||
.subtract(region.getMinimumPoint()).
|
||||
add(1, 1, 1);
|
||||
BlockVector3 origin = clipboard.getOrigin();
|
||||
|
||||
String sizeStr = size.getBlockX() + "*" + size.getBlockY() + "*" + size.getBlockZ();
|
||||
@ -617,30 +440,10 @@ public class SelectionCommands {
|
||||
|
||||
index++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// player.print("Cuboid dimensions (max - min): " + size);
|
||||
// player.print("Offset: " + origin);
|
||||
// player.print("Cuboid distance: " + size.distance(Vector.ONE));
|
||||
// player.print("# of blocks: " + (int) (size.getX() * size.getY() * size.getZ()));
|
||||
//=======
|
||||
// public void size(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
// if (args.hasFlag('c')) {
|
||||
// ClipboardHolder holder = session.getClipboard();
|
||||
// Clipboard clipboard = holder.getClipboard();
|
||||
// Region region = clipboard.getRegion();
|
||||
// BlockVector3 size = region.getMaximumPoint().subtract(region.getMinimumPoint());
|
||||
// BlockVector3 origin = clipboard.getOrigin();
|
||||
//
|
||||
// player.print("Cuboid dimensions (max - min): " + size);
|
||||
// player.print("Offset: " + origin);
|
||||
// player.print("Cuboid distance: " + size.distance(BlockVector3.ONE));
|
||||
// player.print("# of blocks: " + (int) (size.getX() * size.getY() * size.getZ()));
|
||||
return;
|
||||
}
|
||||
|
||||
Region region = session.getSelection(player.getWorld());
|
||||
region = session.getSelection(player.getWorld());
|
||||
BlockVector3 size = region.getMaximumPoint()
|
||||
.subtract(region.getMinimumPoint())
|
||||
.add(1, 1, 1);
|
||||
@ -660,57 +463,53 @@ public class SelectionCommands {
|
||||
|
||||
|
||||
@Command(
|
||||
aliases = {"/count"},
|
||||
usage = "<mask>",
|
||||
desc = "Counts the number of a certain type of block",
|
||||
flags = "d",
|
||||
min = 1,
|
||||
max = 1
|
||||
name = "/count",
|
||||
desc = "Counts the number of a certain type of block"
|
||||
)
|
||||
@CommandPermissions("worldedit.analysis.count")
|
||||
public void count(Player player, LocalSession session, EditSession editSession, Mask mask) throws WorldEditException {
|
||||
public void count(Player player, LocalSession session, EditSession editSession,
|
||||
@Arg(desc = "The mask of blocks to match")
|
||||
Mask mask) throws WorldEditException {
|
||||
int count = editSession.countBlock(session.getSelection(player.getWorld()), mask);
|
||||
BBC.SELECTION_COUNT.send(player, count);
|
||||
player.print("Counted: " + count);
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"/distr"},
|
||||
usage = "",
|
||||
desc = "Get the distribution of blocks in the selection",
|
||||
help =
|
||||
"Gets the distribution of blocks in the selection.\n" +
|
||||
"The -c flag gets the distribution of your clipboard.",
|
||||
flags = "c",
|
||||
min = 0,
|
||||
max = 0
|
||||
name = "/distr",
|
||||
desc = "Get the distribution of blocks in the selection"
|
||||
)
|
||||
@CommandPermissions("worldedit.analysis.distr")
|
||||
public void distr(Player player, LocalSession session, EditSession editSession, @Switch('c') boolean useClipboard, @Switch('d') boolean useData) throws WorldEditException, CommandException {
|
||||
int size;
|
||||
List<Countable> distributionData;
|
||||
public void distr(Player player, LocalSession session, EditSession editSession,
|
||||
@Switch(name = 'c', desc = "Get the distribution of the clipboard instead")
|
||||
boolean clipboardDistr,
|
||||
@Switch(name = 'd', desc = "Separate blocks by state")
|
||||
boolean separateStates) throws WorldEditException {
|
||||
List<Countable> distribution;
|
||||
|
||||
Region region;
|
||||
if (useClipboard) {
|
||||
if (clipboardDistr) {
|
||||
// TODO multi clipboard distribution
|
||||
Clipboard clipboard = session.getClipboard().getClipboard();
|
||||
Clipboard clipboard = session.getClipboard().getClipboard(); // throws if missing
|
||||
region = clipboard.getRegion();
|
||||
editSession.setExtent(new AbstractDelegateExtent(clipboard));
|
||||
} else {
|
||||
region = session.getSelection(player.getWorld());
|
||||
}
|
||||
if (useData)
|
||||
distributionData = (List) editSession.getBlockDistributionWithData(region);
|
||||
if (separateStates)
|
||||
distribution = (List) editSession.getBlockDistributionWithData(region);
|
||||
else
|
||||
distributionData = (List) editSession.getBlockDistribution(region);
|
||||
size = session.getSelection(player.getWorld()).getArea();
|
||||
distribution = (List) editSession.getBlockDistribution(region);
|
||||
|
||||
if (distributionData.size() <= 0) {
|
||||
if (distribution.isEmpty()) { // *Should* always be false
|
||||
player.printError("No blocks counted.");
|
||||
return;
|
||||
}
|
||||
|
||||
// note: doing things like region.getArea is inaccurate for non-cuboids.
|
||||
int size = session.getSelection(player.getWorld()).getArea();
|
||||
BBC.SELECTION_DISTR.send(player, size);
|
||||
|
||||
for (Countable c : distributionData) {
|
||||
for (Countable c : distribution) {
|
||||
String name = c.getID().toString();
|
||||
String str = String.format("%-7s (%.3f%%) %s",
|
||||
String.valueOf(c.getAmount()),
|
||||
@ -721,16 +520,17 @@ public class SelectionCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"/sel", ";", "/desel", "/deselect"},
|
||||
flags = "d",
|
||||
usage = "[cuboid|extend|poly|polyhedron|ellipsoid|sphere|cyl|convex|fuzzy]",
|
||||
desc = "Choose a region selector",
|
||||
min = 0,
|
||||
max = 1
|
||||
name = "/sel",
|
||||
aliases = { ";", "/desel", "/deselect" },
|
||||
desc = "Choose a region selector"
|
||||
)
|
||||
public void select(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
public void select(Player player, LocalSession session, EditSession editSession,
|
||||
@Arg(desc = "Selector to switch to", def = "")
|
||||
SelectorChoice selector,
|
||||
@Switch(name = 'd', desc = "Set default selector")
|
||||
boolean setDefaultSelector) throws WorldEditException {
|
||||
final World world = player.getWorld();
|
||||
if (args.argsLength() == 0) {
|
||||
if (selector == null) {
|
||||
session.getRegionSelector(world).clear();
|
||||
session.dispatchCUISelection(player);
|
||||
BBC.SELECTION_CLEARED.send(player);
|
||||
@ -740,79 +540,93 @@ public class SelectionCommands {
|
||||
final String typeName = args.getString(0);
|
||||
final RegionSelector oldSelector = session.getRegionSelector(world);
|
||||
|
||||
final RegionSelector selector;
|
||||
if (typeName.equalsIgnoreCase("cuboid")) {
|
||||
selector = new CuboidRegionSelector(oldSelector);
|
||||
player.print(BBC.SEL_CUBOID.s());
|
||||
} else if (typeName.equalsIgnoreCase("extend")) {
|
||||
selector = new ExtendingCuboidRegionSelector(oldSelector);
|
||||
player.print(BBC.SEL_CUBOID_EXTEND.s());
|
||||
} else if (typeName.equalsIgnoreCase("poly")) {
|
||||
selector = new Polygonal2DRegionSelector(oldSelector);
|
||||
player.print(BBC.SEL_2D_POLYGON.s());
|
||||
Optional<Integer> limit = ActorSelectorLimits.forActor(player).getPolygonVertexLimit();
|
||||
limit.ifPresent(integer -> player.print(BBC.SEL_MAX.f(integer)));
|
||||
player.print(BBC.SEL_LIST.s());
|
||||
} else if (typeName.equalsIgnoreCase("ellipsoid")) {
|
||||
selector = new EllipsoidRegionSelector(oldSelector);
|
||||
player.print(BBC.SEL_ELLIPSIOD.s());
|
||||
} else if (typeName.equalsIgnoreCase("sphere")) {
|
||||
selector = new SphereRegionSelector(oldSelector);
|
||||
player.print(BBC.SEL_SPHERE.s());
|
||||
} else if (typeName.equalsIgnoreCase("cyl")) {
|
||||
selector = new CylinderRegionSelector(oldSelector);
|
||||
player.print(BBC.SEL_CYLINDRICAL.s());
|
||||
} else if (typeName.equalsIgnoreCase("convex") || typeName.equalsIgnoreCase("hull")) {
|
||||
selector = new ConvexPolyhedralRegionSelector(oldSelector);
|
||||
player.print(BBC.SEL_CONVEX_POLYHEDRAL.s());
|
||||
Optional<Integer> limit = ActorSelectorLimits.forActor(player).getPolyhedronVertexLimit();
|
||||
limit.ifPresent(integer -> player.print(BBC.SEL_MAX.f(integer)));
|
||||
player.print(BBC.SEL_LIST.s());
|
||||
} else if (typeName.equalsIgnoreCase("polyhedral") || typeName.equalsIgnoreCase("polyhedron")) {
|
||||
selector = new PolyhedralRegionSelector(player.getWorld());
|
||||
player.print(BBC.SEL_CONVEX_POLYHEDRAL.s());
|
||||
Optional<Integer> limit = ActorSelectorLimits.forActor(player).getPolyhedronVertexLimit();
|
||||
limit.ifPresent(integer -> player.print(BBC.SEL_MAX.f(integer)));
|
||||
player.print(BBC.SEL_LIST.s());
|
||||
} else if (typeName.startsWith("fuzzy") || typeName.startsWith("magic")) {
|
||||
Mask mask;
|
||||
if (typeName.length() > 6) {
|
||||
ParserContext parserContext = new ParserContext();
|
||||
parserContext.setActor(player);
|
||||
parserContext.setWorld(player.getWorld());
|
||||
parserContext.setSession(session);
|
||||
parserContext.setExtent(editSession);
|
||||
mask = we.getMaskFactory().parseFromInput(typeName.substring(6), parserContext);
|
||||
} else {
|
||||
mask = new IdMask(editSession);
|
||||
final RegionSelector newSelector;
|
||||
switch (selector) {
|
||||
case CUBOID:
|
||||
newSelector = new CuboidRegionSelector(oldSelector);
|
||||
player.print(BBC.SEL_CUBOID.s());
|
||||
break;
|
||||
case EXTEND:
|
||||
newSelector = new ExtendingCuboidRegionSelector(oldSelector);
|
||||
player.print(BBC.SEL_CUBOID_EXTEND.s());
|
||||
break;
|
||||
case POLY: {
|
||||
newSelector = new Polygonal2DRegionSelector(oldSelector);
|
||||
player.print(BBC.SEL_2D_POLYGON.s());
|
||||
Optional<Integer> limit = ActorSelectorLimits.forActor(player).getPolygonVertexLimit();
|
||||
limit.ifPresent(integer -> player.print(BBC.SEL_MAX.f(integer)));
|
||||
break;
|
||||
}
|
||||
selector = new FuzzyRegionSelector(player, editSession, mask);
|
||||
player.print(BBC.SEL_FUZZY.f());
|
||||
player.print(BBC.SEL_LIST.f());
|
||||
} else {
|
||||
CommandListBox box = new CommandListBox("Selection modes");
|
||||
StyledFragment contents = box.getContents();
|
||||
StyledFragment tip = contents.createFragment(Style.RED);
|
||||
tip.append(BBC.SEL_MODES.s()).newLine();
|
||||
case ELLIPSOID:
|
||||
newSelector = new EllipsoidRegionSelector(oldSelector);
|
||||
player.print(BBC.SEL_ELLIPSIOD.s());
|
||||
break;
|
||||
case SPHERE:
|
||||
newSelector = new SphereRegionSelector(oldSelector);
|
||||
player.print(BBC.SEL_SPHERE.s());
|
||||
break;
|
||||
case CYL:
|
||||
newSelector = new CylinderRegionSelector(oldSelector);
|
||||
player.print(BBC.SEL_CYLINDRICAL.s());
|
||||
break;
|
||||
case CONVEX:
|
||||
case HULL:
|
||||
case POLYHEDRON: {
|
||||
newSelector = new ConvexPolyhedralRegionSelector(oldSelector);
|
||||
player.print(BBC.SEL_CONVEX_POLYHEDRAL.s());
|
||||
Optional<Integer> limit = ActorSelectorLimits.forActor(player).getPolyhedronVertexLimit();
|
||||
limit.ifPresent(integer -> player.print(BBC.SEL_MAX.f(integer)));
|
||||
break;
|
||||
}
|
||||
case POLYHEDRAL:
|
||||
newSelector = new PolyhedralRegionSelector(player.getWorld());
|
||||
player.print(BBC.SEL_CONVEX_POLYHEDRAL.s());
|
||||
Optional<Integer> limit = ActorSelectorLimits.forActor(player).getPolyhedronVertexLimit();
|
||||
limit.ifPresent(integer -> player.print(BBC.SEL_MAX.f(integer)));
|
||||
player.print(BBC.SEL_LIST.s());
|
||||
break;
|
||||
case FUZZY:
|
||||
case MAGIC:
|
||||
Mask mask;
|
||||
if (typeName.length() > 6) {
|
||||
ParserContext parserContext = new ParserContext();
|
||||
parserContext.setActor(player);
|
||||
parserContext.setWorld(player.getWorld());
|
||||
parserContext.setSession(session);
|
||||
parserContext.setExtent(editSession);
|
||||
mask = we.getMaskFactory().parseFromInput(typeName.substring(6), parserContext);
|
||||
} else {
|
||||
mask = new IdMask(world);
|
||||
}
|
||||
newSelector = new FuzzyRegionSelector(player, editSession, mask);
|
||||
player.print(BBC.SEL_FUZZY.f());
|
||||
player.print(BBC.SEL_LIST.f());
|
||||
break;
|
||||
case LIST:
|
||||
default:
|
||||
CommandListBox box = new CommandListBox("Selection modes", null);
|
||||
box.setHidingHelp(true);
|
||||
TextComponentProducer contents = box.getContents();
|
||||
contents.append(SubtleFormat.wrap("Select one of the modes below:")).newline();
|
||||
|
||||
box.appendCommand("//sel cuboid", "Select two corners of a cuboid");
|
||||
box.appendCommand("//sel extend", "Fast cuboid selection mode");
|
||||
box.appendCommand("//sel poly", "Select a 2D polygon with height");
|
||||
box.appendCommand("//sel ellipsoid", "Select an ellipsoid");
|
||||
box.appendCommand("//sel sphere", "Select a sphere");
|
||||
box.appendCommand("//sel cyl", "Select a cylinder");
|
||||
box.appendCommand("//sel convex", "Select a convex polyhedral");
|
||||
box.appendCommand("//sel polyhedral", "Select a hollow polyhedral");
|
||||
box.appendCommand("//sel fuzzy[=<mask>]", "Select all connected blocks (magic wand)");
|
||||
box.appendCommand("cuboid", "Select two corners of a cuboid", "//sel cuboid");
|
||||
box.appendCommand("extend", "Fast cuboid selection mode", "//sel extend");
|
||||
box.appendCommand("poly", "Select a 2D polygon with height", "//sel poly");
|
||||
box.appendCommand("ellipsoid", "Select an ellipsoid", "//sel ellipsoid");
|
||||
box.appendCommand("sphere", "Select a sphere", "//sel sphere");
|
||||
box.appendCommand("cyl", "Select a cylinder", "//sel cyl");
|
||||
box.appendCommand("convex", "Select a convex polyhedral", "//sel convex");
|
||||
box.appendCommand("polyhedral", "Select a hollow polyhedral", "//sel polyhedral");
|
||||
box.appendCommand("fuzzy[=<mask>]", "Select all connected blocks (magic wand)", "//sel fuzzy[=<mask>]");
|
||||
|
||||
player.printRaw(ColorCodeBuilder.asColorCodes(box));
|
||||
return;
|
||||
player.print(box.create(1));
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.hasFlag('d')) {
|
||||
if (setDefaultSelector) {
|
||||
RegionSelectorType found = null;
|
||||
for (RegionSelectorType type : RegionSelectorType.values()) {
|
||||
if (type.getSelectorClass() == selector.getClass()) {
|
||||
if (type.getSelectorClass() == newSelector.getClass()) {
|
||||
found = type;
|
||||
break;
|
||||
}
|
||||
@ -826,9 +640,8 @@ public class SelectionCommands {
|
||||
}
|
||||
}
|
||||
|
||||
session.setRegionSelector(world, selector);
|
||||
session.setRegionSelector(world, newSelector);
|
||||
session.dispatchCUISelection(player);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,5 +0,0 @@
|
||||
package com.sk89q.worldedit.command;
|
||||
|
||||
public class SelectionTypeCommands {
|
||||
|
||||
}
|
@ -22,32 +22,33 @@
|
||||
package com.sk89q.worldedit.command;
|
||||
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import com.sk89q.minecraft.util.commands.Command;
|
||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||
import com.sk89q.worldedit.LocalConfiguration;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.command.util.CommandPermissions;
|
||||
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.world.snapshot.InvalidSnapshotException;
|
||||
import com.sk89q.worldedit.world.snapshot.Snapshot;
|
||||
import com.sk89q.worldedit.world.storage.MissingWorldException;
|
||||
import org.enginehub.piston.annotation.Command;
|
||||
import org.enginehub.piston.annotation.CommandContainer;
|
||||
import org.enginehub.piston.annotation.param.Arg;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Snapshot commands.
|
||||
*/
|
||||
@Command(aliases = {"snapshot", "snap"}, desc = "List, load and view information related to snapshots")
|
||||
@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class)
|
||||
public class SnapshotCommands {
|
||||
|
||||
private static final DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z");
|
||||
private static final DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss z");
|
||||
|
||||
private final WorldEdit we;
|
||||
|
||||
@ -56,14 +57,13 @@ public class SnapshotCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"list"},
|
||||
usage = "[num]",
|
||||
desc = "List snapshots",
|
||||
min = 0,
|
||||
max = 1
|
||||
name = "list",
|
||||
desc = "List snapshots"
|
||||
)
|
||||
@CommandPermissions("worldedit.snapshots.list")
|
||||
public void list(Player player, CommandContext args) throws WorldEditException {
|
||||
public void list(Player player,
|
||||
@Arg(desc = "# of snapshots to list", def = "5")
|
||||
int num) throws WorldEditException {
|
||||
|
||||
LocalConfiguration config = we.getConfiguration();
|
||||
|
||||
@ -77,7 +77,7 @@ public class SnapshotCommands {
|
||||
|
||||
if (!snapshots.isEmpty()) {
|
||||
|
||||
int num = args.argsLength() > 0 ? Math.min(40, Math.max(5, args.getInteger(0))) : 5;
|
||||
num = Math.min(40, Math.max(5, num));
|
||||
|
||||
BBC.SNAPSHOT_LIST_HEADER.send(player, player.getWorld().getName());
|
||||
for (byte i = 0; i < Math.min(num, snapshots.size()); i++) {
|
||||
@ -92,7 +92,8 @@ public class SnapshotCommands {
|
||||
File dir = config.snapshotRepo.getDirectory();
|
||||
|
||||
try {
|
||||
WorldEdit.logger.info("WorldEdit found no snapshots: looked in: " + dir.getCanonicalPath());
|
||||
WorldEdit.logger.info("WorldEdit found no snapshots: looked in: "
|
||||
+ dir.getCanonicalPath());
|
||||
} catch (IOException e) {
|
||||
WorldEdit.logger.info("WorldEdit found no snapshots: looked in "
|
||||
+ "(NON-RESOLVABLE PATH - does it exist?): "
|
||||
@ -105,14 +106,13 @@ public class SnapshotCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "use" },
|
||||
usage = "<snapshot>",
|
||||
desc = "Choose a snapshot to use",
|
||||
min = 1,
|
||||
max = 1
|
||||
name = "use",
|
||||
desc = "Choose a snapshot to use"
|
||||
)
|
||||
@CommandPermissions("worldedit.snapshots.restore")
|
||||
public void use(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||
public void use(Player player, LocalSession session,
|
||||
@Arg(desc = "Snapeshot to use")
|
||||
String name) throws WorldEditException {
|
||||
|
||||
LocalConfiguration config = we.getConfiguration();
|
||||
|
||||
@ -121,8 +121,6 @@ public class SnapshotCommands {
|
||||
return;
|
||||
}
|
||||
|
||||
String name = args.getString(0);
|
||||
|
||||
// Want the latest snapshot?
|
||||
if (name.equalsIgnoreCase("latest")) {
|
||||
try {
|
||||
@ -148,14 +146,13 @@ public class SnapshotCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "sel" },
|
||||
usage = "<index>",
|
||||
desc = "Choose the snapshot based on the list id",
|
||||
min = 1,
|
||||
max = 1
|
||||
name = "sel",
|
||||
desc = "Choose the snapshot based on the list id"
|
||||
)
|
||||
@CommandPermissions("worldedit.snapshots.restore")
|
||||
public void sel(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||
public void sel(Player player, LocalSession session,
|
||||
@Arg(desc = "The list ID to select")
|
||||
int index) throws WorldEditException {
|
||||
LocalConfiguration config = we.getConfiguration();
|
||||
|
||||
if (config.snapshotRepo == null) {
|
||||
@ -163,14 +160,6 @@ public class SnapshotCommands {
|
||||
return;
|
||||
}
|
||||
|
||||
int index = -1;
|
||||
try {
|
||||
index = Integer.parseInt(args.getString(0));
|
||||
} catch (NumberFormatException e) {
|
||||
player.printError("Invalid index, " + args.getString(0) + " is not a valid integer.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (index < 1) {
|
||||
BBC.SNAPSHOT_INVALID_INDEX.send(player);
|
||||
return;
|
||||
@ -195,14 +184,13 @@ public class SnapshotCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "before" },
|
||||
usage = "<date>",
|
||||
desc = "Choose the nearest snapshot before a date",
|
||||
min = 1,
|
||||
max = -1
|
||||
name = "before",
|
||||
desc = "Choose the nearest snapshot before a date"
|
||||
)
|
||||
@CommandPermissions("worldedit.snapshots.restore")
|
||||
public void before(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||
public void before(Player player, LocalSession session,
|
||||
@Arg(desc = "The soonest date that may be used")
|
||||
ZonedDateTime date) throws WorldEditException {
|
||||
|
||||
LocalConfiguration config = we.getConfiguration();
|
||||
|
||||
@ -211,18 +199,12 @@ public class SnapshotCommands {
|
||||
return;
|
||||
}
|
||||
|
||||
Calendar date = session.detectDate(args.getJoinedStrings(0));
|
||||
|
||||
if (date == null) {
|
||||
BBC.SNAPSHOT_ERROR_DATE.send(player);
|
||||
} else {
|
||||
try {
|
||||
Snapshot snapshot = config.snapshotRepo.getSnapshotBefore(date, player.getWorld().getName());
|
||||
|
||||
if (snapshot == null) {
|
||||
dateFormat.setTimeZone(session.getTimeZone());
|
||||
player.printError("Couldn't find a snapshot before "
|
||||
+ dateFormat.format(date.getTime()) + ".");
|
||||
+ dateFormat.withZone(session.getTimeZone().toZoneId()).format(date) + ".");
|
||||
} else {
|
||||
session.setSnapshot(snapshot);
|
||||
BBC.SNAPSHOT_SET.send(player, snapshot.getName());
|
||||
@ -230,18 +212,16 @@ public class SnapshotCommands {
|
||||
} catch (MissingWorldException ex) {
|
||||
BBC.SNAPSHOT_NOT_FOUND_WORLD.send(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "after" },
|
||||
usage = "<date>",
|
||||
desc = "Choose the nearest snapshot after a date",
|
||||
min = 1,
|
||||
max = -1
|
||||
name = "after",
|
||||
desc = "Choose the nearest snapshot after a date"
|
||||
)
|
||||
@CommandPermissions("worldedit.snapshots.restore")
|
||||
public void after(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||
public void after(Player player, LocalSession session,
|
||||
@Arg(desc = "The soonest date that may be used")
|
||||
ZonedDateTime date) throws WorldEditException {
|
||||
|
||||
LocalConfiguration config = we.getConfiguration();
|
||||
|
||||
@ -250,24 +230,17 @@ public class SnapshotCommands {
|
||||
return;
|
||||
}
|
||||
|
||||
Calendar date = session.detectDate(args.getJoinedStrings(0));
|
||||
|
||||
if (date == null) {
|
||||
BBC.SNAPSHOT_ERROR_DATE.send(player);
|
||||
} else {
|
||||
try {
|
||||
Snapshot snapshot = config.snapshotRepo.getSnapshotAfter(date, player.getWorld().getName());
|
||||
if (snapshot == null) {
|
||||
dateFormat.setTimeZone(session.getTimeZone());
|
||||
player.printError("Couldn't find a snapshot after "
|
||||
+ dateFormat.format(date.getTime()) + ".");
|
||||
+ dateFormat.withZone(session.getTimeZone().toZoneId()).format(date) + ".");
|
||||
} else {
|
||||
session.setSnapshot(snapshot);
|
||||
BBC.SNAPSHOT_SET.send(player, snapshot.getName());
|
||||
}
|
||||
} catch (MissingWorldException ex) {
|
||||
BBC.SNAPSHOT_NOT_FOUND_WORLD.send(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,16 +19,17 @@
|
||||
|
||||
package com.sk89q.worldedit.command;
|
||||
|
||||
import static com.sk89q.worldedit.command.util.Logging.LogMode.REGION;
|
||||
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import com.sk89q.minecraft.util.commands.Command;
|
||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||
import com.sk89q.minecraft.util.commands.Logging;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.LocalConfiguration;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
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.regions.Region;
|
||||
import com.sk89q.worldedit.world.DataException;
|
||||
@ -37,13 +38,13 @@ import com.sk89q.worldedit.world.snapshot.Snapshot;
|
||||
import com.sk89q.worldedit.world.snapshot.SnapshotRestore;
|
||||
import com.sk89q.worldedit.world.storage.ChunkStore;
|
||||
import com.sk89q.worldedit.world.storage.MissingWorldException;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import org.enginehub.piston.annotation.Command;
|
||||
import org.enginehub.piston.annotation.CommandContainer;
|
||||
import org.enginehub.piston.annotation.param.Arg;
|
||||
|
||||
import static com.sk89q.minecraft.util.commands.Logging.LogMode.REGION;
|
||||
|
||||
@Command(aliases = {}, desc = "[More Info](http://wiki.sk89q.com/wiki/WorldEdit/Snapshots)")
|
||||
@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class)
|
||||
public class SnapshotUtilCommands {
|
||||
|
||||
private final WorldEdit we;
|
||||
@ -53,14 +54,15 @@ public class SnapshotUtilCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "restore", "/restore" },
|
||||
usage = "[snapshot]",
|
||||
desc = "Restore the selection from a snapshot",
|
||||
max = 1
|
||||
name = "restore",
|
||||
aliases = { "/restore" },
|
||||
desc = "Restore the selection from a snapshot"
|
||||
)
|
||||
@Logging(REGION)
|
||||
@CommandPermissions("worldedit.snapshots.restore")
|
||||
public void restore(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
public void restore(Player player, LocalSession session, EditSession editSession,
|
||||
@Arg(name = "snapshot", desc = "The snapshot to restore", def = "")
|
||||
String snapshotName) throws WorldEditException {
|
||||
|
||||
LocalConfiguration config = we.getConfiguration();
|
||||
|
||||
@ -72,9 +74,9 @@ public class SnapshotUtilCommands {
|
||||
Region region = session.getSelection(player.getWorld());
|
||||
Snapshot snapshot;
|
||||
|
||||
if (args.argsLength() > 0) {
|
||||
if (snapshotName != null) {
|
||||
try {
|
||||
snapshot = config.snapshotRepo.getSnapshot(args.getString(0));
|
||||
snapshot = config.snapshotRepo.getSnapshot(snapshotName);
|
||||
} catch (InvalidSnapshotException e) {
|
||||
BBC.SNAPSHOT_NOT_AVAILABLE.send(player);
|
||||
return;
|
||||
@ -113,27 +115,28 @@ public class SnapshotUtilCommands {
|
||||
|
||||
|
||||
// Load chunk store
|
||||
SnapshotRestore restore;
|
||||
try (ChunkStore chunkStore = snapshot.getChunkStore()) {
|
||||
BBC.SNAPSHOT_LOADED.send(player, snapshot.getName());
|
||||
|
||||
// Restore snapshot
|
||||
restore = new SnapshotRestore(chunkStore, editSession, region);
|
||||
SnapshotRestore restore = new SnapshotRestore(chunkStore, editSession, region);
|
||||
//player.print(restore.getChunksAffected() + " chunk(s) will be loaded.");
|
||||
|
||||
restore.restore();
|
||||
|
||||
if (restore.hadTotalFailure()) {
|
||||
String error = restore.getLastErrorMessage();
|
||||
if (error != null) {
|
||||
BBC.SNAPSHOT_ERROR_RESTORE.send(player);
|
||||
if (!restore.getMissingChunks().isEmpty()) {
|
||||
player.printError("Chunks were not present in snapshot.");
|
||||
} else if (error != null) {
|
||||
player.printError("Errors prevented any blocks from being restored.");
|
||||
player.printError("Last error: " + error);
|
||||
} else {
|
||||
BBC.SNAPSHOT_ERROR_RESTORE_CHUNKS.send(player);
|
||||
player.printError("No chunks could be loaded. (Bad archive?)");
|
||||
}
|
||||
} else {
|
||||
player.print(String.format("Restored; %d "
|
||||
+ "missing chunks and %d other errors.",
|
||||
+ "missing chunks and %d other errors.",
|
||||
restore.getMissingChunks().size(),
|
||||
restore.getErrorChunks().size()));
|
||||
}
|
||||
|
@ -20,7 +20,7 @@
|
||||
package com.sk89q.worldedit.command;
|
||||
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import com.sk89q.minecraft.util.commands.Command;
|
||||
import org.enginehub.piston.annotation.Command;
|
||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||
import com.sk89q.worldedit.LocalConfiguration;
|
||||
@ -42,14 +42,11 @@ public class SuperPickaxeCommands {
|
||||
|
||||
@Command(
|
||||
aliases = {"single"},
|
||||
usage = "",
|
||||
desc = "Enable the single block super pickaxe mode",
|
||||
min = 0,
|
||||
max = 0
|
||||
)
|
||||
@CommandPermissions("worldedit.superpickaxe")
|
||||
public void single(Player player, LocalSession session) throws WorldEditException {
|
||||
|
||||
session.setSuperPickaxe(new SinglePickaxe());
|
||||
session.enableSuperPickAxe();
|
||||
BBC.SUPERPICKAXE_AREA_ENABLED.send(player);
|
||||
|
@ -21,16 +21,10 @@ package com.sk89q.worldedit.command;
|
||||
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import com.boydti.fawe.object.brush.InspectBrush;
|
||||
import com.sk89q.minecraft.util.commands.Command;
|
||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.LocalConfiguration;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||
import com.sk89q.worldedit.command.tool.BlockDataCyler;
|
||||
import com.sk89q.worldedit.command.tool.BlockReplacer;
|
||||
@ -38,20 +32,22 @@ import com.sk89q.worldedit.command.tool.DistanceWand;
|
||||
import com.sk89q.worldedit.command.tool.FloatingTreeRemover;
|
||||
import com.sk89q.worldedit.command.tool.FloodFillTool;
|
||||
import com.sk89q.worldedit.command.tool.LongRangeBuildTool;
|
||||
import com.sk89q.worldedit.command.tool.NavigationWand;
|
||||
import com.sk89q.worldedit.command.tool.QueryTool;
|
||||
import com.sk89q.worldedit.command.tool.SelectionWand;
|
||||
import com.sk89q.worldedit.command.tool.TreePlanter;
|
||||
import com.sk89q.worldedit.command.util.CommandPermissions;
|
||||
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.util.HandSide;
|
||||
import com.sk89q.worldedit.util.TreeGenerator;
|
||||
import com.sk89q.worldedit.util.command.parametric.Optional;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.function.pattern.BlockPattern;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.util.HandSide;
|
||||
import com.sk89q.worldedit.util.TreeGenerator;
|
||||
import com.sk89q.worldedit.world.item.ItemType;
|
||||
import org.enginehub.piston.annotation.Command;
|
||||
import org.enginehub.piston.annotation.CommandContainer;
|
||||
import org.enginehub.piston.annotation.param.Arg;
|
||||
|
||||
@Command(aliases = {"brush", "br", "tool"}, desc = "Bind functions to held items: [More Info](https://goo.gl/xPnPxj)")
|
||||
@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class)
|
||||
public class ToolCommands {
|
||||
private final WorldEdit we;
|
||||
|
||||
@ -60,132 +56,169 @@ public class ToolCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"info", "/info"},
|
||||
usage = "",
|
||||
desc = "Block information tool",
|
||||
min = 0,
|
||||
max = 0
|
||||
name = "none",
|
||||
desc = "Unbind a bound tool from your current item"
|
||||
)
|
||||
public void none(Player player, LocalSession session) throws WorldEditException {
|
||||
|
||||
session.setTool(player.getItemInHand(HandSide.MAIN_HAND).getType(), null);
|
||||
player.print("Tool unbound from your current item.");
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "/selwand",
|
||||
aliases = "selwand",
|
||||
desc = "Selection wand tool"
|
||||
)
|
||||
@CommandPermissions("worldedit.setwand")
|
||||
public void selwand(Player player, LocalSession session) throws WorldEditException {
|
||||
|
||||
final ItemType itemType = player.getItemInHand(HandSide.MAIN_HAND).getType();
|
||||
session.setTool(itemType, new SelectionWand());
|
||||
player.print("Selection wand bound to " + itemType.getName() + ".");
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "/navwand",
|
||||
aliases = "navwand",
|
||||
desc = "Navigation wand tool"
|
||||
)
|
||||
@CommandPermissions("worldedit.setwand")
|
||||
public void navwand(Player player, LocalSession session) throws WorldEditException {
|
||||
|
||||
BaseItemStack itemStack = player.getItemInHand(HandSide.MAIN_HAND);
|
||||
session.setTool(itemStack.getType(), new NavigationWand());
|
||||
player.print("Navigation wand bound to " + itemStack.getType().getName() + ".");
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "info",
|
||||
desc = "Block information tool"
|
||||
)
|
||||
@CommandPermissions("worldedit.tool.info")
|
||||
public void info(Player player, LocalSession session) throws WorldEditException {
|
||||
session.setTool(new QueryTool(), player);
|
||||
|
||||
BaseItemStack itemStack = player.getItemInHand(HandSide.MAIN_HAND);
|
||||
session.setTool(itemStack.getType(), new QueryTool());
|
||||
BBC.TOOL_INFO.send(player, itemStack.getType().getName());
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"inspect"},
|
||||
usage = "",
|
||||
desc = "Inspect edits within a radius",
|
||||
help =
|
||||
"Chooses the inspect brush",
|
||||
min = 0,
|
||||
max = 0
|
||||
name = "inspect",
|
||||
desc = "Inspect edits within a radius"
|
||||
)
|
||||
@CommandPermissions("worldedit.tool.inspect")
|
||||
public void inspectBrush(Player player, LocalSession session, @Optional("1") double radius) throws WorldEditException {
|
||||
session.setTool(new InspectBrush(), player);
|
||||
BBC.TOOL_INSPECT.send(player, player.getItemInHand(HandSide.MAIN_HAND).getType().getName());
|
||||
public void inspectBrush(Player player, LocalSession session,
|
||||
@Arg(desc = "The radius of the brush", def = "1")
|
||||
double radius) throws WorldEditException {
|
||||
BaseItemStack itemStack = player.getItemInHand(HandSide.MAIN_HAND);
|
||||
session.setTool(itemStack.getType(), new InspectBrush());
|
||||
BBC.TOOL_INSPECT.send(player, itemStack.getType().getName());
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"tree"},
|
||||
usage = "[type]",
|
||||
desc = "Tree generator tool",
|
||||
min = 0,
|
||||
max = 1
|
||||
name = "tree",
|
||||
desc = "Tree generator tool"
|
||||
)
|
||||
@CommandPermissions("worldedit.tool.tree")
|
||||
@SuppressWarnings("deprecation")
|
||||
public void tree(Player player, LocalSession session, @Optional("tree") TreeGenerator.TreeType type, CommandContext args) throws WorldEditException {
|
||||
session.setTool(new TreePlanter(type), player);
|
||||
BBC.TOOL_TREE.send(player, player.getItemInHand(HandSide.MAIN_HAND).getType().getName());
|
||||
public void tree(Player player, LocalSession session,
|
||||
@Arg(desc = "Type of tree to generate", def = "tree")
|
||||
TreeGenerator.TreeType type) throws WorldEditException {
|
||||
|
||||
BaseItemStack itemStack = player.getItemInHand(HandSide.MAIN_HAND);
|
||||
session.setTool(itemStack.getType(), new TreePlanter(type));
|
||||
BBC.TOOL_TREE.send(player, itemStack.getType().getName());
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"repl"},
|
||||
usage = "<pattern>",
|
||||
desc = "Block replacer tool",
|
||||
min = 1,
|
||||
max = 1
|
||||
name = "repl",
|
||||
desc = "Block replacer tool"
|
||||
)
|
||||
@CommandPermissions("worldedit.tool.replacer")
|
||||
public void repl(Player player, LocalSession session, Pattern pattern) throws WorldEditException {
|
||||
session.setTool(new BlockReplacer(pattern), player);
|
||||
BBC.TOOL_REPL.send(player, player.getItemInHand(HandSide.MAIN_HAND).getType().getName());
|
||||
public void repl(Player player, LocalSession session,
|
||||
@Arg(desc = "The pattern of blocks to place")
|
||||
Pattern pattern) throws WorldEditException {
|
||||
|
||||
BaseItemStack itemStack = player.getItemInHand(HandSide.MAIN_HAND);
|
||||
session.setTool(itemStack.getType(), new BlockReplacer(pattern));
|
||||
BBC.TOOL_REPL.send(player, itemStack.getType().getName());
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"cycler"},
|
||||
usage = "",
|
||||
desc = "Block data cycler tool",
|
||||
min = 0,
|
||||
max = 0
|
||||
name = "cycler",
|
||||
desc = "Block data cycler tool"
|
||||
)
|
||||
@CommandPermissions("worldedit.tool.data-cycler")
|
||||
public void cycler(Player player, LocalSession session) throws WorldEditException {
|
||||
|
||||
session.setTool(new BlockDataCyler(), player);
|
||||
BBC.TOOL_CYCLER.send(player, player.getItemInHand(HandSide.MAIN_HAND).getType().getName());
|
||||
BaseItemStack itemStack = player.getItemInHand(HandSide.MAIN_HAND);
|
||||
session.setTool(itemStack.getType(), new BlockDataCyler());
|
||||
BBC.TOOL_CYCLER.send(player, itemStack.getType().getName());
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"floodfill", "flood"},
|
||||
usage = "<pattern> <range>",
|
||||
desc = "Flood fill tool",
|
||||
min = 2,
|
||||
max = 2
|
||||
name = "floodfill",
|
||||
aliases = { "flood" },
|
||||
desc = "Flood fill tool"
|
||||
)
|
||||
@CommandPermissions("worldedit.tool.flood-fill")
|
||||
public void floodFill(Player player, EditSession editSession, LocalSession session, Pattern pattern, int range) throws WorldEditException {
|
||||
public void floodFill(Player player, LocalSession session,
|
||||
@Arg(desc = "The pattern to flood fill")
|
||||
Pattern pattern,
|
||||
@Arg(desc = "The range to perform the fill")
|
||||
int range) throws WorldEditException {
|
||||
|
||||
LocalConfiguration config = we.getConfiguration();
|
||||
|
||||
if (range > config.maxSuperPickaxeSize) {
|
||||
BBC.TOOL_RANGE_ERROR.send(player, config.maxSuperPickaxeSize);
|
||||
return;
|
||||
}
|
||||
session.setTool(new FloodFillTool(range, pattern), player);
|
||||
BBC.TOOL_FLOOD_FILL.send(player, player.getItemInHand(HandSide.MAIN_HAND).getType().getName());
|
||||
|
||||
BaseItemStack itemStack = player.getItemInHand(HandSide.MAIN_HAND);
|
||||
session.setTool(itemStack.getType(), new FloodFillTool(range, pattern));
|
||||
BBC.TOOL_FLOOD_FILL.send(player, itemStack.getType().getName());
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"deltree"},
|
||||
usage = "",
|
||||
desc = "Floating tree remover tool",
|
||||
min = 0,
|
||||
max = 0
|
||||
name = "deltree",
|
||||
desc = "Floating tree remover tool"
|
||||
)
|
||||
@CommandPermissions("worldedit.tool.deltree")
|
||||
public void deltree(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||
session.setTool(new FloatingTreeRemover(), player);
|
||||
BBC.TOOL_DELTREE.send(player, player.getItemInHand(HandSide.MAIN_HAND).getType().getName());
|
||||
public void deltree(Player player, LocalSession session) throws WorldEditException {
|
||||
|
||||
BaseItemStack itemStack = player.getItemInHand(HandSide.MAIN_HAND);
|
||||
session.setTool(itemStack.getType(), new FloatingTreeRemover());
|
||||
BBC.TOOL_DELTREE.send(player, itemStack.getType().getName());
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"farwand"},
|
||||
usage = "",
|
||||
desc = "Wand at a distance tool",
|
||||
min = 0,
|
||||
max = 0
|
||||
name = "farwand",
|
||||
desc = "Wand at a distance tool"
|
||||
)
|
||||
@CommandPermissions("worldedit.tool.farwand")
|
||||
public void farwand(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||
session.setTool(new DistanceWand(), player);
|
||||
BBC.TOOL_FARWAND.send(player, player.getItemInHand(HandSide.MAIN_HAND).getType().getName());
|
||||
public void farwand(Player player, LocalSession session) throws WorldEditException {
|
||||
|
||||
BaseItemStack itemStack = player.getItemInHand(HandSide.MAIN_HAND);
|
||||
session.setTool(itemStack.getType(), new DistanceWand());
|
||||
BBC.TOOL_FARWAND.send(player, itemStack.getType().getName());
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"lrbuild", "/lrbuild"},
|
||||
usage = "<leftclick block> <rightclick block>",
|
||||
desc = "Long-range building tool",
|
||||
min = 2,
|
||||
max = 2
|
||||
name = "lrbuild",
|
||||
aliases = { "/lrbuild" },
|
||||
desc = "Long-range building tool"
|
||||
)
|
||||
@CommandPermissions("worldedit.tool.lrbuild")
|
||||
public void longrangebuildtool(Player player, LocalSession session, Pattern secondary, Pattern primary) throws WorldEditException {
|
||||
session.setTool(new LongRangeBuildTool(primary, secondary), player);
|
||||
BBC.TOOL_LRBUILD_BOUND.send(player, player.getItemInHand(HandSide.MAIN_HAND).getType().getName());
|
||||
public void longrangebuildtool(Player player, LocalSession session,
|
||||
@Arg(desc = "Pattern to set on left-click")
|
||||
Pattern primary,
|
||||
@Arg(desc = "Pattern to set on right-click")
|
||||
Pattern secondary) throws WorldEditException {
|
||||
BaseItemStack itemStack = player.getItemInHand(HandSide.MAIN_HAND);
|
||||
|
||||
session.setTool(itemStack.getType(), new LongRangeBuildTool(primary, secondary));
|
||||
BBC.TOOL_LRBUILD_BOUND.send(player, itemStack.getType().getName());
|
||||
BBC.TOOL_LRBUILD_INFO.send(player, secondary, primary);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -19,23 +19,23 @@
|
||||
|
||||
package com.sk89q.worldedit.command;
|
||||
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import com.sk89q.minecraft.util.commands.Command;
|
||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.command.util.CommandPermissions;
|
||||
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.internal.expression.Expression;
|
||||
import com.sk89q.worldedit.util.HandSide;
|
||||
import com.sk89q.worldedit.util.command.parametric.Optional;
|
||||
import org.enginehub.piston.annotation.Command;
|
||||
import org.enginehub.piston.annotation.CommandContainer;
|
||||
import org.enginehub.piston.annotation.param.Arg;
|
||||
|
||||
/**
|
||||
* Tool commands.
|
||||
*/
|
||||
@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class)
|
||||
public class ToolUtilCommands {
|
||||
private final WorldEdit we;
|
||||
|
||||
@ -44,93 +44,98 @@ public class ToolUtilCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "/", "," },
|
||||
usage = "[on|off]",
|
||||
desc = "Toggle the super pickaxe function",
|
||||
min = 0,
|
||||
max = 1
|
||||
name = "/",
|
||||
aliases = { "," },
|
||||
desc = "Toggle the super pickaxe function"
|
||||
)
|
||||
@CommandPermissions("worldedit.superpickaxe")
|
||||
public void togglePickaxe(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||
|
||||
String newState = args.getString(0, null);
|
||||
if (session.hasSuperPickAxe()) {
|
||||
if ("on".equals(newState)) {
|
||||
player.printError("Super pick axe already enabled.");
|
||||
return;
|
||||
}
|
||||
|
||||
public void togglePickaxe(Player player, LocalSession session,
|
||||
@Arg(desc = "The new super pickaxe state", def = "")
|
||||
Boolean superPickaxe) {
|
||||
boolean hasSuperPickAxe = session.hasSuperPickAxe();
|
||||
if (superPickaxe != null && superPickaxe == hasSuperPickAxe) {
|
||||
player.printError("Super pickaxe already " + (superPickaxe ? "enabled" : "disabled") + ".");
|
||||
return;
|
||||
}
|
||||
if (hasSuperPickAxe) {
|
||||
session.disableSuperPickAxe();
|
||||
player.print("Super pick axe disabled.");
|
||||
player.print("Super pickaxe disabled.");
|
||||
} else {
|
||||
if ("off".equals(newState)) {
|
||||
player.printError("Super pick axe already disabled.");
|
||||
return;
|
||||
}
|
||||
session.enableSuperPickAxe();
|
||||
player.print("Super pick axe enabled.");
|
||||
player.print("Super pickaxe enabled.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "mask" },
|
||||
usage = "[mask]",
|
||||
desc = "Set the brush mask",
|
||||
min = 0,
|
||||
max = -1
|
||||
name = "mask",
|
||||
desc = "Set the brush mask"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.options.mask")
|
||||
public void mask(Player player, LocalSession session, @Optional Mask mask) throws WorldEditException {
|
||||
public void mask(Player player, LocalSession session,
|
||||
@Arg(desc = "The mask to set", def = "")
|
||||
Mask mask) throws WorldEditException {
|
||||
session.getBrushTool(player.getItemInHand(HandSide.MAIN_HAND).getType()).setMask(mask);
|
||||
if (mask == null) {
|
||||
session.getBrushTool(player).setMask(null);
|
||||
player.print("Brush mask disabled.");
|
||||
} else {
|
||||
session.getBrushTool(player).setMask(mask);
|
||||
player.print("Brush mask set.");
|
||||
}
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "mat", "material" },
|
||||
usage = "[pattern]",
|
||||
desc = "Set the brush material",
|
||||
min = 1,
|
||||
max = 1
|
||||
name = "material",
|
||||
aliases = { "/material" },
|
||||
desc = "Set the brush material"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.options.material")
|
||||
public void material(Player player, LocalSession session, Pattern pattern) throws WorldEditException {
|
||||
session.getBrushTool(player).setFill(pattern);
|
||||
public void material(Player player, LocalSession session,
|
||||
@Arg(desc = "The pattern of blocks to use")
|
||||
Pattern pattern) throws WorldEditException {
|
||||
session.getBrushTool(player.getItemInHand(HandSide.MAIN_HAND).getType()).setFill(pattern);
|
||||
player.print("Brush material set.");
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "range" },
|
||||
usage = "[pattern]",
|
||||
desc = "Set the brush range",
|
||||
min = 1,
|
||||
max = 1
|
||||
)
|
||||
name = "range",
|
||||
desc = "Set the brush range"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.options.range")
|
||||
public void range(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||
int range = args.getInteger(0);
|
||||
session.getBrushTool(player).setRange(range);
|
||||
public void range(Player player, LocalSession session,
|
||||
@Arg(desc = "The range of the brush")
|
||||
int range) throws WorldEditException {
|
||||
session.getBrushTool(player.getItemInHand(HandSide.MAIN_HAND).getType()).setRange(range);
|
||||
player.print("Brush range set.");
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "size" },
|
||||
usage = "[size]",
|
||||
desc = "Set the brush size",
|
||||
min = 1,
|
||||
max = 1
|
||||
name = "size",
|
||||
desc = "Set the brush size"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.options.size")
|
||||
public void size(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||
public void size(Player player, LocalSession session,
|
||||
@Arg(desc = "The size of the brush")
|
||||
int size) throws WorldEditException {
|
||||
we.checkMaxBrushRadius(size);
|
||||
|
||||
int radius = args.getInteger(0);
|
||||
we.checkMaxBrushRadius(radius);
|
||||
session.getBrushTool(player).setSize(radius);
|
||||
session.getBrushTool(player.getItemInHand(HandSide.MAIN_HAND).getType()).setSize(size);
|
||||
player.print("Brush size set.");
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "tracemask",
|
||||
desc = "Set the mask used to stop tool traces"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.options.tracemask")
|
||||
public void traceMask(Player player, LocalSession session,
|
||||
@Arg(desc = "The trace mask to set", def = "")
|
||||
Mask mask) throws WorldEditException {
|
||||
//TODO TraceMask
|
||||
//session.getBrushTool(player.getItemInHand(HandSide.MAIN_HAND).getType()).setTraceMask(mask);
|
||||
if (mask == null) {
|
||||
player.print("Trace mask disabled.");
|
||||
} else {
|
||||
player.print("Trace mask set.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ import com.boydti.fawe.object.extent.ResettableExtent;
|
||||
import com.boydti.fawe.object.extent.ScaleTransform;
|
||||
import com.boydti.fawe.object.extent.TransformExtent;
|
||||
import com.boydti.fawe.util.ExtentTraverser;
|
||||
import com.sk89q.minecraft.util.commands.Command;
|
||||
import org.enginehub.piston.annotation.Command;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -24,36 +24,40 @@ import com.boydti.fawe.FaweVersion;
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import com.boydti.fawe.config.Settings;
|
||||
import com.boydti.fawe.util.IncendoPaster;
|
||||
import com.sk89q.minecraft.util.commands.Command;
|
||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.command.util.CommandPermissions;
|
||||
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
|
||||
import com.sk89q.worldedit.command.util.PrintCommandHelp;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.event.platform.ConfigurationLoadEvent;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extension.platform.Capability;
|
||||
import com.sk89q.worldedit.extension.platform.Capability;
|
||||
import com.sk89q.worldedit.extension.platform.CommandManager;
|
||||
import com.sk89q.worldedit.extension.platform.Platform;
|
||||
import com.sk89q.worldedit.extension.platform.Platform;
|
||||
import com.sk89q.worldedit.extension.platform.PlatformManager;
|
||||
import com.sk89q.worldedit.extension.platform.PlatformManager;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.format.TextStyle;
|
||||
import java.time.zone.ZoneRulesException;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.TimeZone;
|
||||
import org.enginehub.piston.annotation.Command;
|
||||
import org.enginehub.piston.annotation.CommandContainer;
|
||||
import org.enginehub.piston.annotation.param.Arg;
|
||||
import org.enginehub.piston.annotation.param.ArgFlag;
|
||||
import org.enginehub.piston.annotation.param.Switch;
|
||||
|
||||
@Command(aliases = {"worldedit", "we", "fawe"}, desc = "Updating, informational, debug and help commands")
|
||||
@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class)
|
||||
public class WorldEditCommands {
|
||||
private static final DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z");
|
||||
|
||||
private static final DateTimeFormatter dateFormat = DateTimeFormatter
|
||||
.ofPattern("yyyy-MM-dd HH:mm:ss z");
|
||||
|
||||
private final WorldEdit we;
|
||||
|
||||
@ -62,21 +66,20 @@ public class WorldEditCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "version", "ver" },
|
||||
usage = "",
|
||||
desc = "Get WorldEdit/FAWE version",
|
||||
min = 0,
|
||||
max = 0,
|
||||
queued = false
|
||||
name = "version",
|
||||
aliases = { "ver" },
|
||||
desc = "Get WorldEdit/FAWE version"
|
||||
//queued = false
|
||||
)
|
||||
public void version(Actor actor) throws WorldEditException {
|
||||
public void version(Actor actor) {
|
||||
FaweVersion fVer = Fawe.get().getVersion();
|
||||
String fVerStr = fVer == null ? "unknown" : "-" + fVer.build;
|
||||
actor.print("FastAsyncWorldEdit-1.13" + fVerStr + " by Empire92");
|
||||
actor.print("FastAsyncWorldEdit" + fVerStr + " created by Empire92");
|
||||
if (fVer != null) {
|
||||
actor.printDebug("----------- Platforms -----------");
|
||||
FaweVersion version = Fawe.get().getVersion();
|
||||
Date date = new GregorianCalendar(2000 + version.year, version.month - 1, version.day).getTime();
|
||||
Date date = new GregorianCalendar(2000 + version.year, version.month - 1, version.day)
|
||||
.getTime();
|
||||
actor.printDebug(" - DATE: " + date.toLocaleString());
|
||||
actor.printDebug(" - COMMIT: " + Integer.toHexString(version.hash));
|
||||
actor.printDebug(" - BUILD: " + version.build);
|
||||
@ -87,61 +90,55 @@ public class WorldEditCommands {
|
||||
|
||||
actor.printDebug("----------- Platforms -----------");
|
||||
for (Platform platform : pm.getPlatforms()) {
|
||||
actor.printDebug(String.format("* %s", platform.getPlatformName()));
|
||||
actor.printDebug(String.format("* %s (%s)", platform.getPlatformName(), platform.getPlatformVersion()));
|
||||
}
|
||||
|
||||
actor.printDebug("----------- Capabilities -----------");
|
||||
for (Capability capability : Capability.values()) {
|
||||
Platform platform = pm.queryCapability(capability);
|
||||
actor.printDebug(String.format(" - %s: %s", capability.name(), platform != null ? platform.getPlatformName() : "NONE"));
|
||||
actor.printDebug(String.format("%s: %s", capability.name(), platform != null ? platform.getPlatformName() : "NONE"));
|
||||
}
|
||||
actor.printDebug("------------------------------------");
|
||||
actor.printDebug("Wiki: " + "https://github.com/boy0001/FastAsyncWorldedit/wiki");
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "reload" },
|
||||
usage = "",
|
||||
desc = "Reload configuration and translations",
|
||||
min = 0,
|
||||
max = 0
|
||||
name = "reload",
|
||||
desc = "Reload configuration and translations"
|
||||
)
|
||||
@CommandPermissions("worldedit.reload")
|
||||
public void reload(Actor actor) throws WorldEditException {
|
||||
public void reload(Actor actor) {
|
||||
we.getPlatformManager().queryCapability(Capability.CONFIGURATION).reload();
|
||||
we.getEventBus().post(new ConfigurationLoadEvent(we.getPlatformManager().queryCapability(Capability.CONFIGURATION).getConfiguration()));
|
||||
Fawe.get().setupConfigs();
|
||||
CommandManager.getInstance().register(we.getPlatformManager().queryCapability(Capability.USER_COMMANDS));
|
||||
actor.print("Configuration and translations reloaded!");
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"debugpaste"},
|
||||
usage = "",
|
||||
desc = "Upload latest.log, config.yml, message.yml and your commands.yml to https://athion.net/ISPaster/paste",
|
||||
min = 0,
|
||||
max = 0
|
||||
name = "report",
|
||||
aliases = { "debugpaste" },
|
||||
desc = "Writes a report of latest.log, config.yml, message.yml and your commands.yml to https://athion.net/ISPaster/paste"
|
||||
)
|
||||
@CommandPermissions("worldedit.debugpaste")
|
||||
public void debugpaste(Actor actor) throws WorldEditException, IOException {
|
||||
@CommandPermissions({"worldedit.report", "worldedit.debugpaste"})
|
||||
public void report(Actor actor) throws WorldEditException, IOException {
|
||||
BBC.DOWNLOAD_LINK.send(actor, IncendoPaster.debugPaste());
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"threads"},
|
||||
usage = "",
|
||||
desc = "Print all thread stacks",
|
||||
min = 0,
|
||||
max = 0,
|
||||
queued = false
|
||||
name = "threads",
|
||||
desc = "Print all thread stacks"
|
||||
//queued = false
|
||||
)
|
||||
@CommandPermissions("worldedit.threads")
|
||||
public void threads(Actor actor) throws WorldEditException {
|
||||
Map<Thread, StackTraceElement[]> stacks = Thread.getAllStackTraces();
|
||||
for (Map.Entry<Thread, StackTraceElement[]> entry : stacks.entrySet()) {
|
||||
Thread thread = entry.getKey();
|
||||
actor.printDebug("--------------------------------------------------------------------------------------------");
|
||||
actor.printDebug("Thread: " + thread.getName() + " | Id: " + thread.getId() + " | Alive: " + thread.isAlive());
|
||||
actor.printDebug(
|
||||
"--------------------------------------------------------------------------------------------");
|
||||
actor.printDebug(
|
||||
"Thread: " + thread.getName() + " | Id: " + thread.getId() + " | Alive: " + thread
|
||||
.isAlive());
|
||||
for (StackTraceElement elem : entry.getValue()) {
|
||||
actor.printDebug(elem.toString());
|
||||
}
|
||||
@ -149,41 +146,47 @@ public class WorldEditCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "cui" },
|
||||
usage = "",
|
||||
desc = "Complete CUI handshake (internal usage)",
|
||||
min = 0,
|
||||
max = 0
|
||||
name = "cui",
|
||||
desc = "Complete CUI handshake (internal usage)"
|
||||
)
|
||||
public void cui(Player player, LocalSession session) throws WorldEditException {
|
||||
public void cui(Player player, LocalSession session) {
|
||||
session.setCUISupport(true);
|
||||
session.dispatchCUISetup(player);
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "tz" },
|
||||
usage = "[timezone]",
|
||||
desc = "Set your timezone for snapshots",
|
||||
min = 1,
|
||||
max = 1
|
||||
name = "tz",
|
||||
desc = "Set your timezone for snapshots"
|
||||
)
|
||||
public void tz(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||
TimeZone tz = TimeZone.getTimeZone(args.getString(0));
|
||||
session.setTimezone(tz);
|
||||
BBC.TIMEZONE_SET.send(player, tz.getDisplayName());
|
||||
BBC.TIMEZONE_DISPLAY.send(player, dateFormat.format(Calendar.getInstance(tz).getTime()));
|
||||
public void tz(Player player, LocalSession session,
|
||||
@Arg(desc = "The timezone to set")
|
||||
String timezone) {
|
||||
try {
|
||||
ZoneId tz = ZoneId.of(timezone);
|
||||
session.setTimezone(tz);
|
||||
BBC.TIMEZONE_SET.send(player, tz.getDisplayName(
|
||||
TextStyle.FULL, Locale.ENGLISH
|
||||
));
|
||||
BBC.TIMEZONE_DISPLAY
|
||||
.send(player, dateFormat.format(ZonedDateTime.now(tz)));
|
||||
} catch (ZoneRulesException e) {
|
||||
player.printError("Invalid timezone");
|
||||
}
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "help" },
|
||||
usage = "[<command>]",
|
||||
desc = "Displays help for FAWE commands",
|
||||
min = 0,
|
||||
max = -1,
|
||||
queued = false
|
||||
name = "help",
|
||||
desc = "Displays help for FAWE commands"
|
||||
//queued = false
|
||||
)
|
||||
@CommandPermissions("worldedit.help")
|
||||
public void help(Actor actor, CommandContext args) throws WorldEditException {
|
||||
UtilityCommands.help(args, we, actor);
|
||||
public void help(Actor actor,
|
||||
@Switch(name = 's', desc = "List sub-commands of the given command, if applicable")
|
||||
boolean listSubCommands,
|
||||
@ArgFlag(name = 'p', desc = "The page to retrieve", def = "1")
|
||||
int page,
|
||||
@Arg(desc = "The command to retrieve help for", def = "", variable = true)
|
||||
List<String> command) throws WorldEditException {
|
||||
PrintCommandHelp.help(command, page, listSubCommands, we, actor);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,119 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.command.argument;
|
||||
|
||||
import com.google.auto.value.AutoAnnotation;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.sk89q.worldedit.UnknownDirectionException;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.internal.annotation.Direction;
|
||||
import com.sk89q.worldedit.internal.annotation.MultiDirection;
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import org.enginehub.piston.CommandManager;
|
||||
import org.enginehub.piston.converter.ArgumentConverter;
|
||||
import org.enginehub.piston.converter.ConversionResult;
|
||||
import org.enginehub.piston.converter.FailedConversion;
|
||||
import org.enginehub.piston.converter.SuccessfulConversion;
|
||||
import org.enginehub.piston.inject.InjectedValueAccess;
|
||||
import org.enginehub.piston.inject.Key;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
import static org.enginehub.piston.converter.SuggestionHelper.limitByPrefix;
|
||||
|
||||
public abstract class AbstractDirectionConverter<D> implements ArgumentConverter<D> {
|
||||
|
||||
@AutoAnnotation
|
||||
private static Direction direction(boolean includeDiagonals) {
|
||||
return new AutoAnnotation_AbstractDirectionConverter_direction(includeDiagonals);
|
||||
}
|
||||
|
||||
@AutoAnnotation
|
||||
private static MultiDirection multiDirection(boolean includeDiagonals) {
|
||||
return new AutoAnnotation_AbstractDirectionConverter_multiDirection(includeDiagonals);
|
||||
}
|
||||
|
||||
protected static <D> void register(CommandManager commandManager, AbstractDirectionConverter<D> converter,
|
||||
Class<D> keyClass, boolean includeDiagonals) {
|
||||
commandManager.registerConverter(
|
||||
Key.of(keyClass, direction(includeDiagonals)),
|
||||
converter
|
||||
);
|
||||
commandManager.registerConverter(
|
||||
Key.of(keyClass, multiDirection(includeDiagonals)),
|
||||
CommaSeparatedValuesConverter.wrap(converter)
|
||||
);
|
||||
}
|
||||
|
||||
private static final ImmutableSet<String> ORTHOGONAL = ImmutableSet.of(
|
||||
"north", "south", "east", "west", "up", "down"
|
||||
);
|
||||
private static final ImmutableSet<String> RELATIVE = ImmutableSet.of(
|
||||
"me", "forward", "back", "left", "right"
|
||||
);
|
||||
private static final ImmutableSet<String> DIAGONAL = ImmutableSet.of(
|
||||
"northeast", "northwest", "southeast", "southwest"
|
||||
);
|
||||
|
||||
private final WorldEdit worldEdit;
|
||||
private final boolean includeDiagonals;
|
||||
private final ImmutableList<String> suggestions;
|
||||
|
||||
protected AbstractDirectionConverter(WorldEdit worldEdit, boolean includeDiagonals) {
|
||||
this.worldEdit = worldEdit;
|
||||
this.includeDiagonals = includeDiagonals;
|
||||
suggestions = ImmutableList.<String>builder()
|
||||
.addAll(ORTHOGONAL)
|
||||
.addAll(RELATIVE)
|
||||
.addAll(includeDiagonals ? DIAGONAL : ImmutableList.of())
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConversionResult<D> convert(String argument, InjectedValueAccess context) {
|
||||
Player player = context.injectedValue(Key.of(Player.class)).orElse(null);
|
||||
try {
|
||||
return SuccessfulConversion.fromSingle(convertDirection(argument, player, includeDiagonals));
|
||||
} catch (Exception e) {
|
||||
return FailedConversion.from(e);
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract D convertDirection(String argument, @Nullable Player player, boolean includeDiagonals) throws UnknownDirectionException;
|
||||
|
||||
@Override
|
||||
public Component describeAcceptableArguments() {
|
||||
return TextComponent.of("`me` to use facing direction, or any "
|
||||
+ (includeDiagonals ? "direction" : "non-diagonal direction"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getSuggestions(String input) {
|
||||
return limitByPrefix(suggestions.stream(), input);
|
||||
}
|
||||
|
||||
protected WorldEdit getWorldEdit() {
|
||||
return worldEdit;
|
||||
}
|
||||
}
|
@ -17,21 +17,16 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.util.formatting.component;
|
||||
package com.sk89q.worldedit.command.argument;
|
||||
|
||||
import com.sk89q.worldedit.util.formatting.Style;
|
||||
import com.sk89q.worldedit.util.formatting.StyledFragment;
|
||||
|
||||
import org.enginehub.piston.inject.InjectedValueAccess;
|
||||
|
||||
/**
|
||||
* Represents a fragment representing a label.
|
||||
* Key-interface for {@link InjectedValueAccess} for the String arguments.
|
||||
*/
|
||||
public class Label extends StyledFragment {
|
||||
public interface Arguments {
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
*/
|
||||
public Label() {
|
||||
super(Style.YELLOW);
|
||||
}
|
||||
String get();
|
||||
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.command.argument;
|
||||
|
||||
import com.google.common.collect.ImmutableSetMultimap;
|
||||
import org.enginehub.piston.CommandManager;
|
||||
import org.enginehub.piston.converter.MultiKeyConverter;
|
||||
import org.enginehub.piston.inject.Key;
|
||||
|
||||
public class BooleanConverter {
|
||||
|
||||
public static void register(CommandManager commandManager) {
|
||||
commandManager.registerConverter(Key.of(Boolean.class),
|
||||
MultiKeyConverter.builder(
|
||||
ImmutableSetMultimap.<Boolean, String>builder()
|
||||
.putAll(false, "off", "f", "false", "n", "no")
|
||||
.putAll(true, "on", "t", "true", "y", "yes")
|
||||
.build()
|
||||
)
|
||||
.errorMessage(arg -> "Not a boolean value: " + arg)
|
||||
.build()
|
||||
);
|
||||
}
|
||||
|
||||
private BooleanConverter() {
|
||||
}
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user