mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-01 02:46:41 +00:00
merge
This commit is contained in:
@ -19,6 +19,10 @@
|
||||
|
||||
package com.sk89q.worldedit.command;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.sk89q.worldedit.command.util.Logging.LogMode.PLACEMENT;
|
||||
import static com.sk89q.worldedit.command.util.Logging.LogMode.REGION;
|
||||
|
||||
import com.boydti.fawe.FaweAPI;
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import com.boydti.fawe.config.Settings;
|
||||
@ -35,10 +39,6 @@ import com.boydti.fawe.object.schematic.Schematic;
|
||||
import com.boydti.fawe.util.ImgurUtility;
|
||||
import com.boydti.fawe.util.MainUtil;
|
||||
import com.boydti.fawe.util.MaskTraverser;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import org.enginehub.piston.inject.InjectedValueAccess;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.LocalConfiguration;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
@ -47,8 +47,6 @@ 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;
|
||||
@ -74,12 +72,6 @@ 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 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;
|
||||
import java.io.OutputStream;
|
||||
@ -91,6 +83,12 @@ import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
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.inject.InjectedValueAccess;
|
||||
|
||||
|
||||
/**
|
||||
@ -128,7 +126,8 @@ public class ClipboardCommands {
|
||||
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));
|
||||
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 FaweException.MAX_CHECKS;
|
||||
@ -159,7 +158,7 @@ public class ClipboardCommands {
|
||||
if (!player.hasPermission("fawe.tips")) {
|
||||
BBC.TIP_PASTE.or(BBC.TIP_DOWNLOAD, BBC.TIP_ROTATE, BBC.TIP_COPYPASTE, BBC.TIP_REPLACE_MARKER, BBC.TIP_COPY_PATTERN).send(player);
|
||||
}
|
||||
}, getArguments(context), region, context);
|
||||
}, "/copy", region, context);
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -283,7 +282,7 @@ public class ClipboardCommands {
|
||||
if (!player.hasPermission("fawe.tips")) {
|
||||
BBC.TIP_LAZYCUT.send(player);
|
||||
}
|
||||
}, getArguments(context), region, context);
|
||||
}, "cut", region, context);
|
||||
|
||||
}
|
||||
|
||||
|
@ -93,7 +93,7 @@ public class GenerationCommands {
|
||||
@CommandPermissions("worldedit.generation.caves")
|
||||
@Logging(PLACEMENT)
|
||||
public void caves(FawePlayer fp, LocalSession session, EditSession editSession, @Selection Region region,
|
||||
@Arg(desc = "TODO", def = "8") int size,
|
||||
@Arg(name = "size", desc = "TODO", def = "8") int sizeOpt,
|
||||
@Arg(desc = "TODO", def = "40") int frequency,
|
||||
@Arg(desc = "TODO", def = "7") int rarity,
|
||||
@Arg(desc = "TODO", def = "8") int minY,
|
||||
@ -104,10 +104,10 @@ public class GenerationCommands {
|
||||
@Arg(desc = "TODO", def = "0") int pocketMin,
|
||||
@Arg(desc = "TODO", def = "3") int pocketMax, InjectedValueAccess context) throws WorldEditException {
|
||||
fp.checkConfirmationRegion(() -> {
|
||||
CavesGen gen = new CavesGen(size, frequency, rarity, minY, maxY, systemFrequency, individualRarity, pocketChance, pocketMin, pocketMax);
|
||||
CavesGen gen = new CavesGen(sizeOpt, frequency, rarity, minY, maxY, systemFrequency, individualRarity, pocketChance, pocketMin, pocketMax);
|
||||
editSession.generate(region, gen);
|
||||
BBC.VISITOR_BLOCK.send(fp, editSession.getBlockChangeCount());
|
||||
}, getArguments(context), region, context);
|
||||
}, "/caves", region, context);
|
||||
}
|
||||
|
||||
|
||||
@ -117,11 +117,11 @@ public class GenerationCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.generation.ore")
|
||||
@Logging(PLACEMENT)
|
||||
public void ores(FawePlayer player, LocalSession session, EditSession editSession, @Selection Region region, Mask mask, InjectedValueAccess context) throws WorldEditException {
|
||||
player.checkConfirmationRegion(() -> {
|
||||
public void ores(FawePlayer fp, LocalSession session, EditSession editSession, @Selection Region region, Mask mask, InjectedValueAccess context) throws WorldEditException {
|
||||
fp.checkConfirmationRegion(() -> {
|
||||
editSession.addOres(region, mask);
|
||||
BBC.VISITOR_BLOCK.send(player, editSession.getBlockChangeCount());
|
||||
}, getArguments(context), region, context);
|
||||
BBC.VISITOR_BLOCK.send(fp, editSession.getBlockChangeCount());
|
||||
}, "/ores", region, context);
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -171,11 +171,11 @@ public class GenerationCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.generation.ore")
|
||||
@Logging(PLACEMENT)
|
||||
public void ore(FawePlayer player, LocalSession session, EditSession editSession, @Selection Region region, Mask mask, Pattern material, @Range(min = 0) int size, int freq, @Range(min = 0, max = 100) int rarity, @Range(min = 0, max = 255) int minY, @Range(min = 0, max = 255) int maxY, InjectedValueAccess context) throws WorldEditException {
|
||||
player.checkConfirmationRegion(() -> {
|
||||
public void ore(FawePlayer fp, LocalSession session, EditSession editSession, @Selection Region region, Mask mask, Pattern material, @Range(min = 0) int size, int freq, @Range(min = 0, max = 100) int rarity, @Range(min = 0, max = 255) int minY, @Range(min = 0, max = 255) int maxY, InjectedValueAccess context) throws WorldEditException {
|
||||
fp.checkConfirmationRegion(() -> {
|
||||
editSession.addOre(region, mask, material, size, freq, rarity, minY, maxY);
|
||||
BBC.VISITOR_BLOCK.send(player, editSession.getBlockChangeCount());
|
||||
}, getArguments(context), region, context);
|
||||
BBC.VISITOR_BLOCK.send(fp, editSession.getBlockChangeCount());
|
||||
}, "/ore", region, context);
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -197,7 +197,7 @@ public class GenerationCommands {
|
||||
fp.checkConfirmationRadius(() -> {
|
||||
int affected = editSession.makeHollowCylinder(pos, pattern, radius.getX(), radius.getZ(), Math.min(256, height), thickness - 1);
|
||||
BBC.VISITOR_BLOCK.send(fp, affected);
|
||||
}, getArguments(context), (int) max, context);
|
||||
}, "/hcyl", (int) max, context);
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -220,7 +220,7 @@ public class GenerationCommands {
|
||||
fp.checkConfirmationRadius(() -> {
|
||||
int affected = editSession.makeCylinder(pos, pattern, radius.getX(), radius.getZ(), Math.min(256, height), !hollow);
|
||||
BBC.VISITOR_BLOCK.send(fp, affected);
|
||||
}, getArguments(context), (int) max, context);
|
||||
}, "/cyl", (int) max, context);
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -262,7 +262,7 @@ public class GenerationCommands {
|
||||
int affected = editSession.makeSphere(finalPos, pattern, radii.getX(), radii.getY(), radii.getZ(), !hollow);
|
||||
player.findFreePosition();
|
||||
BBC.VISITOR_BLOCK.send(fp, affected);
|
||||
}, getArguments(context), (int) max, context);
|
||||
}, "sphere", (int) max, context);
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -272,15 +272,15 @@ public class GenerationCommands {
|
||||
@CommandPermissions("worldedit.generation.forest")
|
||||
@Logging(POSITION)
|
||||
public int forestGen(Player player, LocalSession session, EditSession editSession,
|
||||
@Arg(desc = "The size of the forest, in blocks", def = "10")
|
||||
int size,
|
||||
@Arg(name = "size", desc = "The size of the forest, in blocks", def = "10")
|
||||
int sizeOpt,
|
||||
@Arg(desc = "The type of forest", def = "tree")
|
||||
TreeType type,
|
||||
@Range(min = 0, max = 100) @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 /= 100;
|
||||
int affected = editSession.makeForest(session.getPlacementPosition(player), size, density, type);
|
||||
int affected = editSession.makeForest(session.getPlacementPosition(player), sizeOpt, density, type);
|
||||
player.print(affected + " trees created.");
|
||||
return affected;
|
||||
}
|
||||
@ -292,12 +292,13 @@ public class GenerationCommands {
|
||||
@CommandPermissions("worldedit.generation.pumpkins")
|
||||
@Logging(POSITION)
|
||||
public int pumpkins(Player player, LocalSession session, EditSession editSession,
|
||||
@Arg(desc = "The size of the patch", def = "10")
|
||||
int size,
|
||||
@Arg(name = "size", desc = "The size of the patch", def = "10")
|
||||
int sizeOpt,
|
||||
@Arg(desc = "//TODO", def = "10")
|
||||
int apothem,
|
||||
@Range(min = 0, max = 100) @Arg(desc = "//TODO ", def = "0.02")
|
||||
@Arg(desc = "//TODO ", def = "0.02")
|
||||
double density) throws WorldEditException {
|
||||
checkCommandArgument(0 <= density && density <= 100, "Density must be between 0 and 100");
|
||||
int affected = editSession.makePumpkinPatches(session.getPlacementPosition(player), apothem, density);
|
||||
BBC.COMMAND_PUMPKIN.send(player, affected);
|
||||
return affected;
|
||||
@ -401,7 +402,7 @@ public class GenerationCommands {
|
||||
} catch (ExpressionException e) {
|
||||
player.printError(e.getMessage());
|
||||
}
|
||||
}, getArguments(context), region, context);
|
||||
}, "/generate", region, context);
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -464,7 +465,7 @@ public class GenerationCommands {
|
||||
} catch (ExpressionException e) {
|
||||
fp.printError(e.getMessage());
|
||||
}
|
||||
}, getArguments(context), region, context);
|
||||
}, "/generatebiome", region, context);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -257,7 +257,7 @@ public class HistoryCommands {
|
||||
if (undone == null) {
|
||||
BBC.COMMAND_UNDO_ERROR.send(player);
|
||||
}
|
||||
}, getArguments(context), times, 50, context);
|
||||
}, "undo", times, 50, context);
|
||||
}
|
||||
|
||||
@Command(
|
||||
|
@ -10,11 +10,10 @@ import java.util.UUID;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.regex.PatternSyntaxException;
|
||||
import org.enginehub.piston.annotation.Command;
|
||||
import org.enginehub.piston.annotation.CommandContainer;
|
||||
import org.enginehub.piston.exception.StopExecutionException;
|
||||
|
||||
//TODO This class breaks compilation
|
||||
@CommandContainer
|
||||
//@CommandContainer
|
||||
public class ListFilters {
|
||||
public class Filter {
|
||||
public boolean listPrivate() {
|
||||
|
@ -72,7 +72,7 @@ public class MaskCommands {
|
||||
name = "#simplex",
|
||||
desc = "Use simplex noise as the mask"
|
||||
)
|
||||
public Mask simplex(double scale, double min, double max) {
|
||||
public Mask simplex(double scale, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) {
|
||||
scale = 1d / Math.max(1, scale);
|
||||
min = (min - 50) / 50;
|
||||
max = (max - 50) / 50;
|
||||
@ -83,13 +83,12 @@ public class MaskCommands {
|
||||
name = "#light",
|
||||
desc = "Restrict to specific light levels"
|
||||
)
|
||||
public Mask light(Extent extent, double min, double max) {
|
||||
public Mask light(Extent extent, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) {
|
||||
return new LightMask(extent, (int) min, (int) max);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#false",
|
||||
aliases = {"false"},
|
||||
desc = "Always false"
|
||||
)
|
||||
public Mask falseMask(Extent extent) {
|
||||
@ -98,7 +97,6 @@ public class MaskCommands {
|
||||
|
||||
@Command(
|
||||
name = "#true",
|
||||
aliases = {"true"},
|
||||
desc = "Always true"
|
||||
)
|
||||
public Mask trueMask(Extent extent) {
|
||||
@ -109,8 +107,8 @@ public class MaskCommands {
|
||||
name = "#skylight",
|
||||
desc = "Restrict to specific sky light levels"
|
||||
)
|
||||
public Mask skylight(Extent extent, double min, double max) {
|
||||
return new SkyLightMask(extent, (int) min, (int) max);
|
||||
public Mask skylight(Extent extent, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) {
|
||||
return new SkyLightMask(extent, (int) minInt, (int) maxInt);
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -118,24 +116,24 @@ public class MaskCommands {
|
||||
aliases = {"#emittedlight"},
|
||||
desc = "Restrict to specific block light levels"
|
||||
)
|
||||
public Mask blocklight(Extent extent, double min, double max) {
|
||||
return new BlockLightMask(extent, (int) min, (int) max);
|
||||
public Mask blocklight(Extent extent, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) {
|
||||
return new BlockLightMask(extent, (int) minInt, (int) maxInt);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#opacity",
|
||||
desc = "Restrict to specific opacity levels"
|
||||
)
|
||||
public Mask opacity(Extent extent, double min, double max) {
|
||||
return new OpacityMask(extent, (int) min, (int) max);
|
||||
public Mask opacity(Extent extent, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) {
|
||||
return new OpacityMask(extent, (int) minInt, (int) maxInt);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "#brightness",
|
||||
desc = "Restrict to specific block brightness"
|
||||
)
|
||||
public Mask brightness(Extent extent, double min, double max) {
|
||||
return new BrightnessMask(extent, (int) min, (int) max);
|
||||
public Mask brightness(Extent extent, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) {
|
||||
return new BrightnessMask(extent, (int) minInt, (int) maxInt);
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -288,17 +286,17 @@ public class MaskCommands {
|
||||
"Example: /[3][20]\n" +
|
||||
"Explanation: Allows any block where the adjacent block is between 3 and 20 blocks below"
|
||||
)
|
||||
public Mask angle(Extent extent, String min, String max, @Switch(name = 'o', desc = "TODO") boolean overlay, @Arg(name = "distance", desc = "int", def = "1") int distance) throws ExpressionException {
|
||||
public Mask angle(Extent extent, String minStr, String maxStr, @Switch(name = 'o', desc = "TODO") boolean overlay, @Arg(name = "distance", desc = "int", def = "1") int distance) throws ExpressionException {
|
||||
double y1, y2;
|
||||
boolean override;
|
||||
if (max.endsWith("d")) {
|
||||
double y1d = Expression.compile(min.substring(0, min.length() - 1)).evaluate();
|
||||
double y2d = Expression.compile(max.substring(0, max.length() - 1)).evaluate();
|
||||
if (maxStr.endsWith("d")) {
|
||||
double y1d = Expression.compile(minStr.substring(0, minStr.length() - 1)).evaluate();
|
||||
double y2d = Expression.compile(maxStr.substring(0, maxStr.length() - 1)).evaluate();
|
||||
y1 = Math.tan(y1d * (Math.PI / 180));
|
||||
y2 = Math.tan(y2d * (Math.PI / 180));
|
||||
} else {
|
||||
y1 = Expression.compile(min).evaluate();
|
||||
y2 = Expression.compile(max).evaluate();
|
||||
y1 = Expression.compile(minStr).evaluate();
|
||||
y2 = Expression.compile(maxStr).evaluate();
|
||||
}
|
||||
return new AngleMask(extent, y1, y2, overlay, distance);
|
||||
}
|
||||
@ -313,17 +311,17 @@ public class MaskCommands {
|
||||
"Explanation: Restrict near where the angle changes between 0-45 degrees within 5 blocks\n" +
|
||||
"Note: Use negatives for decreasing slope"
|
||||
)
|
||||
public Mask roc(Extent extent, String min, String max, @Switch(name = 'o', desc = "TODO") boolean overlay, @Arg(name = "distance", desc = "int", def = "4") int distance) throws ExpressionException {
|
||||
public Mask roc(Extent extent, String minStr, String maxStr, @Switch(name = 'o', desc = "TODO") boolean overlay, @Arg(name = "distance", desc = "int", def = "4") int distance) throws ExpressionException {
|
||||
double y1, y2;
|
||||
boolean override;
|
||||
if (max.endsWith("d")) {
|
||||
double y1d = Expression.compile(min.substring(0, min.length() - 1)).evaluate();
|
||||
double y2d = Expression.compile(max.substring(0, max.length() - 1)).evaluate();
|
||||
if (maxStr.endsWith("d")) {
|
||||
double y1d = Expression.compile(minStr.substring(0, minStr.length() - 1)).evaluate();
|
||||
double y2d = Expression.compile(maxStr.substring(0, maxStr.length() - 1)).evaluate();
|
||||
y1 = Math.tan(y1d * (Math.PI / 180));
|
||||
y2 = Math.tan(y2d * (Math.PI / 180));
|
||||
} else {
|
||||
y1 = Expression.compile(min).evaluate();
|
||||
y2 = Expression.compile(max).evaluate();
|
||||
y1 = Expression.compile(minStr).evaluate();
|
||||
y2 = Expression.compile(maxStr).evaluate();
|
||||
}
|
||||
return new ROCAngleMask(extent, y1, y2, overlay, distance);
|
||||
}
|
||||
@ -358,8 +356,8 @@ public class MaskCommands {
|
||||
aliases = {"#{"},
|
||||
desc = "Restricts blocks to within a specific radius range of the initial block"
|
||||
)
|
||||
public Mask radius(double min, double max) throws ExpressionException {
|
||||
return new RadiusMask((int) min, (int) max);
|
||||
public Mask radius(@Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) throws ExpressionException {
|
||||
return new RadiusMask((int) minInt, (int) maxInt);
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -367,8 +365,8 @@ public class MaskCommands {
|
||||
aliases = {"#|", "#side"},
|
||||
desc = "sides with a specific number of other blocks"
|
||||
)
|
||||
public Mask wall(Mask mask, double min, double max) throws ExpressionException {
|
||||
return new WallMask(mask, (int) min, (int) max);
|
||||
public Mask wall(Mask mask, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) throws ExpressionException {
|
||||
return new WallMask(mask, (int) minInt, (int) maxInt);
|
||||
}
|
||||
|
||||
@Command(
|
||||
|
@ -292,7 +292,7 @@ public class SchematicCommands {
|
||||
desc = "Save a schematic into your clipboard"
|
||||
)
|
||||
@CommandPermissions({"worldedit.clipboard.save", "worldedit.schematic.save", "worldedit.schematic.save.other"})
|
||||
public void save(Player player, LocalSession session,
|
||||
public void save(Actor actor, LocalSession session,
|
||||
@Arg(desc = "File name.")
|
||||
String filename,
|
||||
@Arg(desc = "Format name.", def = "sponge")
|
||||
@ -307,20 +307,20 @@ public class SchematicCommands {
|
||||
File dir = worldEdit.getWorkingDirectoryFile(config.saveDir);
|
||||
|
||||
if (!global && Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS) {
|
||||
dir = new File(dir, player.getUniqueId().toString());
|
||||
dir = new File(dir, actor.getUniqueId().toString());
|
||||
}
|
||||
|
||||
ClipboardFormat format = ClipboardFormats.findByAlias(formatName);
|
||||
if (format == null) {
|
||||
player.printError("Unknown schematic format: " + formatName);
|
||||
actor.printError("Unknown schematic format: " + formatName);
|
||||
return;
|
||||
}
|
||||
|
||||
boolean other = false;
|
||||
if (filename.contains("../")) {
|
||||
other = true;
|
||||
if (!player.hasPermission("worldedit.schematic.save.other")) {
|
||||
BBC.NO_PERM.send(player, "worldedit.schematic.save.other");
|
||||
if (!actor.hasPermission("worldedit.schematic.save.other")) {
|
||||
BBC.NO_PERM.send(actor, "worldedit.schematic.save.other");
|
||||
return;
|
||||
}
|
||||
if (filename.startsWith("../")) {
|
||||
@ -329,21 +329,21 @@ public class SchematicCommands {
|
||||
}
|
||||
}
|
||||
|
||||
File f = worldEdit.getSafeSaveFile(player, dir, filename, format.getPrimaryFileExtension());
|
||||
File f = worldEdit.getSafeSaveFile(actor, dir, filename, format.getPrimaryFileExtension());
|
||||
|
||||
boolean overwrite = f.exists();
|
||||
if (overwrite) {
|
||||
if (!player.hasPermission("worldedit.schematic.delete")) {
|
||||
if (!actor.hasPermission("worldedit.schematic.delete")) {
|
||||
throw new StopExecutionException(TextComponent.of("That schematic already exists!"));
|
||||
}
|
||||
if (other) {
|
||||
if (!player.hasPermission("worldedit.schematic.delete.other")) {
|
||||
if (!actor.hasPermission("worldedit.schematic.delete.other")) {
|
||||
BBC.NO_PERM.send(player, "worldedit.schematic.delete.other");
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!allowOverwrite) {
|
||||
player.printError("That schematic already exists. Use the -f flag to overwrite it.");
|
||||
actor.printError("That schematic already exists. Use the -f flag to overwrite it.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -359,8 +359,8 @@ public class SchematicCommands {
|
||||
|
||||
ClipboardHolder holder = session.getClipboard();
|
||||
|
||||
SchematicSaveTask task = new SchematicSaveTask(player, f, format, holder, overwrite);
|
||||
AsyncCommandBuilder.wrap(task, player)
|
||||
SchematicSaveTask task = new SchematicSaveTask(actor, f, format, holder, overwrite);
|
||||
AsyncCommandBuilder.wrap(task, actor)
|
||||
.registerWithSupervisor(worldEdit.getSupervisor(), "Saving schematic " + filename)
|
||||
.sendMessageAfterDelay("(Please wait... saving schematic.)")
|
||||
.onSuccess(filename + " saved" + (overwrite ? " (overwriting previous file)." : "."), null)
|
||||
@ -577,7 +577,7 @@ public class SchematicCommands {
|
||||
boolean oldFirst,
|
||||
@Switch(name = 'n', desc = "Sort by date, newest first")
|
||||
boolean newFirst,
|
||||
@Switch(name = 'f', desc = "Restricts by format.")
|
||||
@ArgFlag(name = 'f', desc = "Restricts by format.")
|
||||
String formatName,
|
||||
@Arg(name = "filter", desc = "Filter for schematics", def = "all")
|
||||
String filter) throws WorldEditException {
|
||||
@ -635,12 +635,12 @@ public class SchematicCommands {
|
||||
}
|
||||
|
||||
private static class SchematicLoadTask implements Callable<ClipboardHolder> {
|
||||
private final Player player;
|
||||
private final Actor actor;
|
||||
private final File file;
|
||||
private final ClipboardFormat format;
|
||||
|
||||
SchematicLoadTask(Player player, File file, ClipboardFormat format) {
|
||||
this.player = player;
|
||||
SchematicLoadTask(Actor actor, File file, ClipboardFormat format) {
|
||||
this.actor = actor;
|
||||
this.file = file;
|
||||
this.format = format;
|
||||
}
|
||||
@ -653,21 +653,21 @@ public class SchematicCommands {
|
||||
ClipboardReader reader = closer.register(format.getReader(bis));
|
||||
|
||||
Clipboard clipboard = reader.read();
|
||||
log.info(player.getName() + " loaded " + file.getCanonicalPath());
|
||||
log.info(actor.getName() + " loaded " + file.getCanonicalPath());
|
||||
return new ClipboardHolder(clipboard);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class SchematicSaveTask implements Callable<Void> {
|
||||
private final Player player;
|
||||
private final Actor actor;
|
||||
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;
|
||||
SchematicSaveTask(Actor actor, File file, ClipboardFormat format, ClipboardHolder holder, boolean overwrite) {
|
||||
this.actor = actor;
|
||||
this.file = file;
|
||||
this.format = format;
|
||||
this.holder = holder;
|
||||
@ -700,14 +700,14 @@ public class SchematicCommands {
|
||||
}
|
||||
if (new PlayerSaveClipboardEvent(player, clipboard, uri, file.toURI()).call()) {
|
||||
if (writer instanceof MinecraftStructure) {
|
||||
((MinecraftStructure) writer).write(target, player.getName());
|
||||
((MinecraftStructure) writer).write(target, actor.getName());
|
||||
} else {
|
||||
writer.write(target);
|
||||
}
|
||||
log.info(player.getName() + " saved " + file.getCanonicalPath());
|
||||
BBC.SCHEMATIC_SAVED.send(player, file.getName());
|
||||
log.info(actor.getName() + " saved " + file.getCanonicalPath());
|
||||
BBC.SCHEMATIC_SAVED.send(actor, file.getName());
|
||||
} else {
|
||||
BBC.WORLDEDIT_CANCEL_REASON_MANUAL.send(player);
|
||||
BBC.WORLDEDIT_CANCEL_REASON_MANUAL.send(actor);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
@ -40,6 +40,8 @@ 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.Locatable;
|
||||
import com.sk89q.worldedit.extension.platform.permission.ActorSelectorLimits;
|
||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
@ -61,6 +63,7 @@ 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.Location;
|
||||
import com.sk89q.worldedit.util.formatting.component.CommandListBox;
|
||||
import com.sk89q.worldedit.util.formatting.component.SubtleFormat;
|
||||
import com.sk89q.worldedit.util.formatting.component.TextComponentProducer;
|
||||
@ -99,23 +102,26 @@ public class SelectionCommands {
|
||||
)
|
||||
@Logging(POSITION)
|
||||
@CommandPermissions("worldedit.selection.pos")
|
||||
public void pos1(Player player, LocalSession session,
|
||||
public void pos1(Actor actor, World world, LocalSession session,
|
||||
@Arg(desc = "Coordinates to set position 1 to", def = "")
|
||||
BlockVector3 coordinates) throws WorldEditException {
|
||||
BlockVector3 pos;
|
||||
Location pos;
|
||||
if (coordinates != null) {
|
||||
pos = coordinates;
|
||||
pos = new Location(world, coordinates.toVector3());
|
||||
} else if (actor instanceof Locatable) {
|
||||
pos = ((Locatable) actor).getBlockLocation();
|
||||
} else {
|
||||
pos = player.getBlockIn().toBlockPoint();
|
||||
}
|
||||
pos = pos.clampY(0, player.getWorld().getMaximumPoint().getBlockY());
|
||||
if (!session.getRegionSelector(player.getWorld()).selectPrimary(pos, ActorSelectorLimits.forActor(player))) {
|
||||
BBC.SELECTOR_ALREADY_SET.send(player);
|
||||
actor.printError("You must provide coordinates as console.");
|
||||
return;
|
||||
}
|
||||
|
||||
session.getRegionSelector(player.getWorld())
|
||||
.explainPrimarySelection(player, session, pos);
|
||||
if (!session.getRegionSelector(world).selectPrimary(pos.toBlockPoint(), ActorSelectorLimits.forActor(actor))) {
|
||||
BBC.SELECTOR_ALREADY_SET.send(actor);
|
||||
return;
|
||||
}
|
||||
|
||||
session.getRegionSelector(world)
|
||||
.explainPrimarySelection(actor, session, pos.toBlockPoint());
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -124,23 +130,25 @@ public class SelectionCommands {
|
||||
)
|
||||
@Logging(POSITION)
|
||||
@CommandPermissions("worldedit.selection.pos")
|
||||
public void pos2(Player player, LocalSession session,
|
||||
public void pos2(Actor actor, World world, LocalSession session,
|
||||
@Arg(desc = "Coordinates to set position 2 to", def = "")
|
||||
BlockVector3 coordinates) throws WorldEditException {
|
||||
BlockVector3 pos;
|
||||
Location pos;
|
||||
if (coordinates != null) {
|
||||
pos = coordinates;
|
||||
pos = new Location(world, coordinates.toVector3());
|
||||
} else if (actor instanceof Locatable) {
|
||||
pos = ((Locatable) actor).getBlockLocation();
|
||||
} else {
|
||||
pos = player.getBlockIn().toBlockPoint();
|
||||
actor.printError("You must provide coordinates as console.");
|
||||
return;
|
||||
}
|
||||
pos = pos.clampY(0, player.getWorld().getMaximumPoint().getBlockY());
|
||||
if (!session.getRegionSelector(player.getWorld()).selectSecondary(pos, ActorSelectorLimits.forActor(player))) {
|
||||
BBC.SELECTOR_ALREADY_SET.send(player);
|
||||
if (!session.getRegionSelector(world).selectSecondary(pos.toBlockPoint(), ActorSelectorLimits.forActor(actor))) {
|
||||
BBC.SELECTOR_ALREADY_SET.send(actor);
|
||||
return;
|
||||
}
|
||||
|
||||
session.getRegionSelector(player.getWorld())
|
||||
.explainSecondarySelection(player, session, pos);
|
||||
session.getRegionSelector(world)
|
||||
.explainSecondarySelection(actor, session, pos.toBlockPoint());
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -222,7 +230,7 @@ public class SelectionCommands {
|
||||
: ChunkStore.toChunk(coordinates.toBlockVector3());
|
||||
} else {
|
||||
// use player loc
|
||||
min2D = ChunkStore.toChunk(player.getBlockIn().toBlockPoint());
|
||||
min2D = ChunkStore.toChunk(player.getBlockLocation().toBlockPoint());
|
||||
}
|
||||
|
||||
min = BlockVector3.at(min2D.getBlockX() * 16, 0, min2D.getBlockZ() * 16);
|
||||
@ -296,7 +304,7 @@ public class SelectionCommands {
|
||||
)
|
||||
@Logging(REGION)
|
||||
@CommandPermissions("worldedit.selection.contract")
|
||||
public void contract(Player player, LocalSession session,
|
||||
public void contract(Actor actor, World world, 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")
|
||||
@ -305,7 +313,7 @@ public class SelectionCommands {
|
||||
@MultiDirection
|
||||
List<BlockVector3> direction) throws WorldEditException {
|
||||
try {
|
||||
Region region = session.getSelection(player.getWorld());
|
||||
Region region = session.getSelection(world);
|
||||
int oldSize = region.getArea();
|
||||
if (reverseAmount == 0) {
|
||||
for (BlockVector3 dir : direction) {
|
||||
@ -316,15 +324,15 @@ public class SelectionCommands {
|
||||
region.contract(dir.multiply(amount), dir.multiply(-reverseAmount));
|
||||
}
|
||||
}
|
||||
session.getRegionSelector(player.getWorld()).learnChanges();
|
||||
session.getRegionSelector(world).learnChanges();
|
||||
int newSize = region.getArea();
|
||||
|
||||
session.getRegionSelector(player.getWorld()).explainRegionAdjust(player, session);
|
||||
session.getRegionSelector(world).explainRegionAdjust(actor, session);
|
||||
|
||||
|
||||
BBC.SELECTION_CONTRACT.send(player, (oldSize - newSize));
|
||||
BBC.SELECTION_CONTRACT.send(actor, (oldSize - newSize));
|
||||
} catch (RegionOperationException e) {
|
||||
player.printError(e.getMessage());
|
||||
actor.printError(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@ -334,26 +342,26 @@ public class SelectionCommands {
|
||||
)
|
||||
@Logging(REGION)
|
||||
@CommandPermissions("worldedit.selection.shift")
|
||||
public void shift(Player player, LocalSession session,
|
||||
public void shift(Actor actor, World world, 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());
|
||||
Region region = session.getSelection(world);
|
||||
|
||||
for (BlockVector3 dir : direction) {
|
||||
region.shift(dir.multiply(amount));
|
||||
}
|
||||
|
||||
session.getRegionSelector(player.getWorld()).learnChanges();
|
||||
session.getRegionSelector(world).learnChanges();
|
||||
|
||||
session.getRegionSelector(player.getWorld()).explainRegionAdjust(player, session);
|
||||
session.getRegionSelector(world).explainRegionAdjust(actor, session);
|
||||
|
||||
BBC.SELECTION_SHIFT.send(player);
|
||||
BBC.SELECTION_SHIFT.send(actor);
|
||||
} catch (RegionOperationException e) {
|
||||
player.printError(e.getMessage());
|
||||
actor.printError(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@ -363,18 +371,18 @@ public class SelectionCommands {
|
||||
)
|
||||
@Logging(REGION)
|
||||
@CommandPermissions("worldedit.selection.outset")
|
||||
public void outset(Player player, LocalSession session,
|
||||
public void outset(Actor actor, World world, 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 region = session.getSelection(world);
|
||||
region.expand(getChangesForEachDir(amount, onlyHorizontal, onlyVertical));
|
||||
session.getRegionSelector(player.getWorld()).learnChanges();
|
||||
session.getRegionSelector(player.getWorld()).explainRegionAdjust(player, session);
|
||||
BBC.SELECTION_OUTSET.send(player);
|
||||
session.getRegionSelector(world).learnChanges();
|
||||
session.getRegionSelector(world).explainRegionAdjust(actor, session);
|
||||
BBC.SELECTION_OUTSET.send(actor);
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -383,18 +391,18 @@ public class SelectionCommands {
|
||||
)
|
||||
@Logging(REGION)
|
||||
@CommandPermissions("worldedit.selection.inset")
|
||||
public void inset(Player player, LocalSession session,
|
||||
public void inset(Actor actor, World world, 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 region = session.getSelection(world);
|
||||
region.contract(getChangesForEachDir(amount, onlyHorizontal, onlyVertical));
|
||||
session.getRegionSelector(player.getWorld()).learnChanges();
|
||||
session.getRegionSelector(player.getWorld()).explainRegionAdjust(player, session);
|
||||
BBC.SELECTION_INSET.send(player);
|
||||
session.getRegionSelector(world).learnChanges();
|
||||
session.getRegionSelector(world).explainRegionAdjust(actor, session);
|
||||
actor.print("Region inset.");
|
||||
}
|
||||
|
||||
private BlockVector3[] getChangesForEachDir(int amount, boolean onlyHorizontal, boolean onlyVertical) {
|
||||
@ -544,17 +552,16 @@ public class SelectionCommands {
|
||||
aliases = { ";", "/desel", "/deselect" },
|
||||
desc = "Choose a region selector"
|
||||
)
|
||||
public void select(Player player, LocalSession session, EditSession editSession,
|
||||
public void select(Actor actor, World world, LocalSession session, EditSession editSession,
|
||||
@Arg(desc = "Selector to switch to", def = "")
|
||||
SelectorChoice selector,
|
||||
@Arg(desc = "Selector mask", def = "") Mask mask,
|
||||
@Switch(name = 'd', desc = "Set default selector")
|
||||
boolean setDefaultSelector) throws WorldEditException {
|
||||
final World world = player.getWorld();
|
||||
if (selector == null) {
|
||||
session.getRegionSelector(world).clear();
|
||||
session.dispatchCUISelection(player);
|
||||
BBC.SELECTION_CLEARED.send(player);
|
||||
session.dispatchCUISelection(actor);
|
||||
BBC.SELECTION_CLEARED.send(actor);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -564,55 +571,56 @@ public class SelectionCommands {
|
||||
switch (selector) {
|
||||
case CUBOID:
|
||||
newSelector = new CuboidRegionSelector(oldSelector);
|
||||
player.print(BBC.SEL_CUBOID.s());
|
||||
actor.print(BBC.SEL_CUBOID.s());
|
||||
break;
|
||||
case EXTEND:
|
||||
newSelector = new ExtendingCuboidRegionSelector(oldSelector);
|
||||
player.print(BBC.SEL_CUBOID_EXTEND.s());
|
||||
actor.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.format(integer)));
|
||||
actor.print(BBC.SEL_2D_POLYGON.s());
|
||||
Optional<Integer> limit = ActorSelectorLimits.forActor(actor).getPolygonVertexLimit();
|
||||
limit.ifPresent(integer -> actor.print(BBC.SEL_MAX.format(integer)));
|
||||
break;
|
||||
}
|
||||
case ELLIPSOID:
|
||||
newSelector = new EllipsoidRegionSelector(oldSelector);
|
||||
player.print(BBC.SEL_ELLIPSIOD.s());
|
||||
actor.print(BBC.SAL_ELLIPSOID.s());
|
||||
break;
|
||||
case SPHERE:
|
||||
newSelector = new SphereRegionSelector(oldSelector);
|
||||
player.print(BBC.SEL_SPHERE.s());
|
||||
actor.print(BBC.SEL_SPHERE.s());
|
||||
break;
|
||||
case CYL:
|
||||
newSelector = new CylinderRegionSelector(oldSelector);
|
||||
player.print(BBC.SEL_CYLINDRICAL.s());
|
||||
actor.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.format(integer)));
|
||||
actor.print(BBC.SEL_CONVEX_POLYHEDRAL.s());
|
||||
Optional<Integer> limit = ActorSelectorLimits.forActor(actor).getPolyhedronVertexLimit();
|
||||
limit.ifPresent(integer -> actor.print(BBC.SEL_MAX.format(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.format(integer)));
|
||||
player.print(BBC.SEL_LIST.s());
|
||||
newSelector = new PolyhedralRegionSelector(world);
|
||||
actor.print(BBC.SEL_CONVEX_POLYHEDRAL.s());
|
||||
Optional<Integer> limit = ActorSelectorLimits.forActor(actor).getPolyhedronVertexLimit();
|
||||
limit.ifPresent(integer -> actor.print(BBC.SEL_MAX.format(integer)));
|
||||
actor.print(BBC.SEL_LIST.s());
|
||||
break;
|
||||
case FUZZY:
|
||||
case MAGIC:
|
||||
if (mask == null) {
|
||||
mask = new IdMask(world);
|
||||
}
|
||||
newSelector = new FuzzyRegionSelector(player, editSession, mask);
|
||||
player.print(BBC.SEL_FUZZY.s());
|
||||
player.print(BBC.SEL_LIST.s());
|
||||
//TODO Make FuzzyRegionSelector accept actors
|
||||
newSelector = new FuzzyRegionSelector((Player) actor, editSession, mask);
|
||||
actor.print(BBC.SEL_FUZZY.s());
|
||||
actor.print(BBC.SEL_LIST.s());
|
||||
break;
|
||||
case LIST:
|
||||
default:
|
||||
@ -631,7 +639,7 @@ public class SelectionCommands {
|
||||
box.appendCommand("polyhedral", "Select a hollow polyhedral", "//sel polyhedral");
|
||||
box.appendCommand("fuzzy[=<mask>]", "Select all connected blocks (magic wand)", "//sel fuzzy[=<mask>]");
|
||||
|
||||
player.print(box.create(1));
|
||||
actor.print(box.create(1));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -646,14 +654,14 @@ public class SelectionCommands {
|
||||
|
||||
if (found != null) {
|
||||
session.setDefaultRegionSelector(found);
|
||||
BBC.SELECTOR_SET_DEFAULT.send(player, found.name());
|
||||
BBC.SELECTOR_SET_DEFAULT.send(actor, found.name());
|
||||
} else {
|
||||
throw new RuntimeException("Something unexpected happened. Please report this.");
|
||||
}
|
||||
}
|
||||
|
||||
session.setRegionSelector(world, newSelector);
|
||||
session.dispatchCUISelection(player);
|
||||
session.dispatchCUISelection(actor);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -29,12 +29,14 @@ 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.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.util.formatting.component.PaginationBox;
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.event.ClickEvent;
|
||||
import com.sk89q.worldedit.util.formatting.text.event.HoverEvent;
|
||||
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.snapshot.InvalidSnapshotException;
|
||||
import com.sk89q.worldedit.world.snapshot.Snapshot;
|
||||
import com.sk89q.worldedit.world.storage.MissingWorldException;
|
||||
@ -67,24 +69,24 @@ public class SnapshotCommands {
|
||||
desc = "List snapshots"
|
||||
)
|
||||
@CommandPermissions("worldedit.snapshots.list")
|
||||
public void list(Player player,
|
||||
public void list(Actor actor, World world,
|
||||
@ArgFlag(name = 'p', desc = "Page of results to return", def = "1")
|
||||
int page) throws WorldEditException {
|
||||
|
||||
LocalConfiguration config = we.getConfiguration();
|
||||
|
||||
if (config.snapshotRepo == null) {
|
||||
BBC.SNAPSHOT_NOT_CONFIGURED.send(player);
|
||||
BBC.SNAPSHOT_NOT_CONFIGURED.send(actor);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
List<Snapshot> snapshots = config.snapshotRepo.getSnapshots(true, player.getWorld().getName());
|
||||
List<Snapshot> snapshots = config.snapshotRepo.getSnapshots(true, world.getName());
|
||||
|
||||
if (!snapshots.isEmpty()) {
|
||||
player.print(new SnapshotListBox(player.getWorld().getName(), snapshots).create(page));
|
||||
actor.print(new SnapshotListBox(world.getName(), snapshots).create(page));
|
||||
} else {
|
||||
BBC.SNAPSHOT_NOT_AVAILABLE.send(player);
|
||||
BBC.SNAPSHOT_NOT_AVAILABLE.send(actor);
|
||||
|
||||
// Okay, let's toss some debugging information!
|
||||
File dir = config.snapshotRepo.getDirectory();
|
||||
@ -99,7 +101,7 @@ public class SnapshotCommands {
|
||||
}
|
||||
}
|
||||
} catch (MissingWorldException ex) {
|
||||
BBC.SNAPSHOT_NOT_FOUND_WORLD.send(player);
|
||||
BBC.SNAPSHOT_NOT_FOUND_WORLD.send(actor);
|
||||
}
|
||||
}
|
||||
|
||||
@ -108,37 +110,37 @@ public class SnapshotCommands {
|
||||
desc = "Choose a snapshot to use"
|
||||
)
|
||||
@CommandPermissions("worldedit.snapshots.restore")
|
||||
public void use(Player player, LocalSession session,
|
||||
@Arg(desc = "Snapeshot to use")
|
||||
public void use(Actor actor, World world, LocalSession session,
|
||||
@Arg(desc = "Snapshot to use")
|
||||
String name) throws WorldEditException {
|
||||
|
||||
LocalConfiguration config = we.getConfiguration();
|
||||
|
||||
if (config.snapshotRepo == null) {
|
||||
BBC.SNAPSHOT_NOT_CONFIGURED.send(player);
|
||||
BBC.SNAPSHOT_NOT_CONFIGURED.send(actor);
|
||||
return;
|
||||
}
|
||||
|
||||
// Want the latest snapshot?
|
||||
if (name.equalsIgnoreCase("latest")) {
|
||||
try {
|
||||
Snapshot snapshot = config.snapshotRepo.getDefaultSnapshot(player.getWorld().getName());
|
||||
Snapshot snapshot = config.snapshotRepo.getDefaultSnapshot(world.getName());
|
||||
|
||||
if (snapshot != null) {
|
||||
session.setSnapshot(null);
|
||||
BBC.SNAPSHOT_NEWEST.send(player);
|
||||
BBC.SNAPSHOT_NEWEST.send(actor);
|
||||
} else {
|
||||
BBC.SNAPSHOT_NOT_FOUND.send(player);
|
||||
BBC.SNAPSHOT_NOT_FOUND.send(actor);
|
||||
}
|
||||
} catch (MissingWorldException ex) {
|
||||
BBC.SNAPSHOT_NOT_FOUND_WORLD.send(player);
|
||||
BBC.SNAPSHOT_NOT_FOUND_WORLD.send(actor);
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
session.setSnapshot(config.snapshotRepo.getSnapshot(name));
|
||||
BBC.SNAPSHOT_SET.send(player, name);
|
||||
BBC.SNAPSHOT_SET.send(actor, name);
|
||||
} catch (InvalidSnapshotException e) {
|
||||
BBC.SNAPSHOT_NOT_AVAILABLE.send(player);
|
||||
BBC.SNAPSHOT_NOT_AVAILABLE.send(actor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -30,9 +30,10 @@ 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.regions.Region;
|
||||
import com.sk89q.worldedit.world.DataException;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.snapshot.InvalidSnapshotException;
|
||||
import com.sk89q.worldedit.world.snapshot.Snapshot;
|
||||
import com.sk89q.worldedit.world.snapshot.SnapshotRestore;
|
||||
@ -60,25 +61,25 @@ public class SnapshotUtilCommands {
|
||||
)
|
||||
@Logging(REGION)
|
||||
@CommandPermissions("worldedit.snapshots.restore")
|
||||
public void restore(Player player, LocalSession session, EditSession editSession,
|
||||
public void restore(Actor actor, World world, LocalSession session, EditSession editSession,
|
||||
@Arg(name = "snapshot", desc = "The snapshot to restore", def = "")
|
||||
String snapshotName) throws WorldEditException {
|
||||
|
||||
LocalConfiguration config = we.getConfiguration();
|
||||
|
||||
if (config.snapshotRepo == null) {
|
||||
BBC.SNAPSHOT_NOT_CONFIGURED.send(player);
|
||||
BBC.SNAPSHOT_NOT_CONFIGURED.send(actor);
|
||||
return;
|
||||
}
|
||||
|
||||
Region region = session.getSelection(player.getWorld());
|
||||
Region region = session.getSelection(world);
|
||||
Snapshot snapshot;
|
||||
|
||||
if (snapshotName != null) {
|
||||
try {
|
||||
snapshot = config.snapshotRepo.getSnapshot(snapshotName);
|
||||
} catch (InvalidSnapshotException e) {
|
||||
BBC.SNAPSHOT_NOT_AVAILABLE.send(player);
|
||||
BBC.SNAPSHOT_NOT_AVAILABLE.send(actor);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
@ -88,10 +89,10 @@ public class SnapshotUtilCommands {
|
||||
// No snapshot set?
|
||||
if (snapshot == null) {
|
||||
try {
|
||||
snapshot = config.snapshotRepo.getDefaultSnapshot(player.getWorld().getName());
|
||||
snapshot = config.snapshotRepo.getDefaultSnapshot(world.getName());
|
||||
|
||||
if (snapshot == null) {
|
||||
BBC.SNAPSHOT_NOT_AVAILABLE.send(player);
|
||||
BBC.SNAPSHOT_NOT_AVAILABLE.send(actor);
|
||||
|
||||
// Okay, let's toss some debugging information!
|
||||
File dir = config.snapshotRepo.getDirectory();
|
||||
@ -108,7 +109,7 @@ public class SnapshotUtilCommands {
|
||||
return;
|
||||
}
|
||||
} catch (MissingWorldException ex) {
|
||||
BBC.SNAPSHOT_NOT_FOUND_WORLD.send(player);
|
||||
BBC.SNAPSHOT_NOT_FOUND_WORLD.send(actor);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -116,7 +117,7 @@ public class SnapshotUtilCommands {
|
||||
|
||||
// Load chunk store
|
||||
try (ChunkStore chunkStore = snapshot.getChunkStore()) {
|
||||
BBC.SNAPSHOT_LOADED.send(player, snapshot.getName());
|
||||
BBC.SNAPSHOT_LOADED.send(actor, snapshot.getName());
|
||||
|
||||
// Restore snapshot
|
||||
SnapshotRestore restore = new SnapshotRestore(chunkStore, editSession, region);
|
||||
@ -127,21 +128,20 @@ public class SnapshotUtilCommands {
|
||||
if (restore.hadTotalFailure()) {
|
||||
String error = restore.getLastErrorMessage();
|
||||
if (!restore.getMissingChunks().isEmpty()) {
|
||||
BBC.SNAPSHOT_ERROR_RESTORE.send(player);
|
||||
BBC.SNAPSHOT_ERROR_RESTORE.send(actor);
|
||||
} else if (error != null) {
|
||||
player.printError("Errors prevented any blocks from being restored.");
|
||||
player.printError("Last error: " + error);
|
||||
actor.printError("Errors prevented any blocks from being restored.");
|
||||
actor.printError("Last error: " + error);
|
||||
} else {
|
||||
BBC.SNAPSHOT_ERROR_RESTORE_CHUNKS.send(player);
|
||||
BBC.SNAPSHOT_ERROR_RESTORE_CHUNKS.send(actor);
|
||||
}
|
||||
} else {
|
||||
player.print(String.format("Restored; %d "
|
||||
+ "missing chunks and %d other errors.",
|
||||
actor.print(String.format("Restored; %d missing chunks and %d other errors.",
|
||||
restore.getMissingChunks().size(),
|
||||
restore.getErrorChunks().size()));
|
||||
}
|
||||
} catch (DataException | IOException e) {
|
||||
player.printError("Failed to load snapshot: " + e.getMessage());
|
||||
actor.printError("Failed to load snapshot: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -36,6 +36,7 @@ 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.Capability;
|
||||
import com.sk89q.worldedit.extension.platform.NoCapablePlatformException;
|
||||
import com.sk89q.worldedit.extension.platform.Platform;
|
||||
import com.sk89q.worldedit.extension.platform.PlatformManager;
|
||||
import java.io.IOException;
|
||||
@ -98,8 +99,13 @@ public class WorldEditCommands {
|
||||
|
||||
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"));
|
||||
try {
|
||||
Platform platform = pm.queryCapability(capability);
|
||||
actor.printDebug(String.format("%s: %s", capability.name(),
|
||||
platform != null ? platform.getPlatformName() : "NONE"));
|
||||
} catch (NoCapablePlatformException e) {
|
||||
actor.printDebug(String.format("%s: %s", capability.name(), "NONE"));
|
||||
}
|
||||
}
|
||||
actor.printDebug("");
|
||||
actor.printDebug("Wiki: " + "https://github.com/boy0001/FastAsyncWorldedit/wiki");
|
||||
@ -120,7 +126,7 @@ public class WorldEditCommands {
|
||||
@Command(
|
||||
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"
|
||||
desc = "Writes a report of latest.log, config.yml, message.yml https://athion.net/ISPaster/paste"
|
||||
)
|
||||
@CommandQueued(false)
|
||||
@CommandPermissions({"worldedit.report", "worldedit.debugpaste"})
|
||||
@ -162,19 +168,19 @@ public class WorldEditCommands {
|
||||
name = "tz",
|
||||
desc = "Set your timezone for snapshots"
|
||||
)
|
||||
public void tz(Player player, LocalSession session,
|
||||
public void tz(Actor actor, 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(
|
||||
BBC.TIMEZONE_SET.send(actor, tz.getDisplayName(
|
||||
TextStyle.FULL, Locale.ENGLISH
|
||||
));
|
||||
BBC.TIMEZONE_DISPLAY
|
||||
.send(player, dateFormat.format(ZonedDateTime.now(tz)));
|
||||
.send(actor, dateFormat.format(ZonedDateTime.now(tz)));
|
||||
} catch (ZoneRulesException e) {
|
||||
player.printError("Invalid timezone");
|
||||
actor.printError("Invalid timezone");
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user