3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-11-05 02:50:05 +01:00
Dieser Commit ist enthalten in:
Jesse Boyd 2019-08-07 01:29:49 +10:00
Ursprung a3c58a187e
Commit a476ab1ea0
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 59F1DE6293AF6E1F
27 geänderte Dateien mit 461 neuen und 485 gelöschten Zeilen

Datei anzeigen

@ -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);
}

Datei anzeigen

@ -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);
}
}

Datei anzeigen

@ -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(

Datei anzeigen

@ -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() {

Datei anzeigen

@ -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(

Datei anzeigen

@ -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;

Datei anzeigen

@ -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);
}
}

Datei anzeigen

@ -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);
}
}
}

Datei anzeigen

@ -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());
}
}
}

Datei anzeigen

@ -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");
}
}

Datei anzeigen

@ -19,11 +19,10 @@
package com.sk89q.worldedit.entity;
import com.sk89q.worldedit.extension.platform.Locatable;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.util.Faceted;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.entity.EntityType;
import javax.annotation.Nullable;
/**
@ -34,7 +33,7 @@ import javax.annotation.Nullable;
* instance of an entity, but a {@link BaseEntity} can be created from
* this entity by calling {@link #getState()}.</p>
*/
public interface Entity extends Faceted {
public interface Entity extends Faceted, Locatable {
/**
* Get a copy of the entity's state.
@ -48,33 +47,11 @@ public interface Entity extends Faceted {
@Nullable
BaseEntity getState();
/**
* Get the location of this entity.
*
* @return the location of the entity
*/
Location getLocation();
/**
* Sets the location of this entity.
*
* @param location the new location of the entity
* @return if the teleport worked
*/
boolean setLocation(Location location);
default EntityType getType() {
BaseEntity state = getState();
return state != null ? state.getType() : null;
}
/**
* Get the extent that this entity is on.
*
* @return the extent
*/
Extent getExtent();
/**
* Remove this entity from it container.
*

Datei anzeigen

@ -191,8 +191,12 @@ public interface Player extends Entity, Actor {
* Get the point of the block that is being stood in.
*
* @return point
* @deprecated Use Locatable#getBlockLocation
*/
Location getBlockIn();
@Deprecated
default Location getBlockIn() {
return getBlockLocation();
}
/**
* Get the point of the block that is being stood upon.

Datei anzeigen

@ -23,71 +23,33 @@ import com.boydti.fawe.command.FaweParser;
import com.boydti.fawe.command.SuggestInputParseException;
import com.boydti.fawe.config.BBC;
import com.boydti.fawe.util.StringMan;
import com.google.common.collect.Iterables;
import com.sk89q.minecraft.util.commands.CommandException;
import com.sk89q.minecraft.util.commands.CommandLocals;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.command.MaskCommands;
import com.sk89q.worldedit.extension.input.InputParseException;
import com.sk89q.worldedit.extension.input.NoMatchException;
import com.sk89q.worldedit.extension.input.ParserContext;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extension.platform.PlatformCommandManager;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.mask.BlockMaskBuilder;
import com.sk89q.worldedit.function.mask.BiomeMask2D;
import com.sk89q.worldedit.function.mask.BlockMask;
import com.sk89q.worldedit.function.mask.ExistingBlockMask;
import com.sk89q.worldedit.function.mask.ExpressionMask;
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.internal.command.ActorAuthorizer;
import com.sk89q.worldedit.internal.command.WorldEditBinding;
import com.sk89q.worldedit.function.mask.Masks;
import com.sk89q.worldedit.function.mask.OffsetMask;
import com.sk89q.worldedit.internal.expression.Expression;
import com.sk89q.worldedit.internal.expression.ExpressionException;
import com.sk89q.worldedit.internal.registry.InputParser;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.regions.shape.WorldEditExpressionEnvironment;
import com.sk89q.worldedit.session.request.Request;
import com.sk89q.worldedit.util.command.Dispatcher;
import com.sk89q.worldedit.util.command.SimpleDispatcher;
import com.sk89q.worldedit.util.command.parametric.ParametricBuilder;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockTypes;
import java.util.ArrayList;
import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.biome.Biomes;
import com.sk89q.worldedit.world.registry.BiomeRegistry;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public class DefaultMaskParser extends FaweParser<Mask> {
private final Dispatcher dispatcher;
private final Pattern INTERSECTION_PATTERN = Pattern.compile("[&|;]+(?![^\\[]*\\])");
public DefaultMaskParser(WorldEdit worldEdit) {
super(worldEdit);
this.dispatcher = new SimpleDispatcher();
this.register(new MaskCommands(worldEdit));
}
@Override
public Dispatcher getDispatcher() {
return dispatcher;
}
public void register(Object clazz) {
ParametricBuilder builder = new ParametricBuilder();
builder.setAuthorizer(new ActorAuthorizer());
builder.addBinding(new WorldEditBinding(worldEdit));
builder.registerMethodsAsCommands(dispatcher, clazz);
public DefaultMaskParser(WorldEdit worldEdit, PlatformCommandManager manager) {
super(worldEdit, manager, Mask.class);
}
@Override
@ -111,53 +73,58 @@ public class DefaultMaskParser extends FaweParser<Mask> {
ParseEntry pe = entry.getKey();
final String command = pe.input;
String full = pe.full;
Mask mask = null;
Mask mask;
if (command.isEmpty()) {
mask = parseFromInput(StringMan.join(entry.getValue(), ','), context);
} else if (dispatcher.get(command) == null) {
// Legacy patterns
char char0 = command.charAt(0);
boolean charMask = input.length() > 1 && input.charAt(1) != '[';
if (charMask && input.charAt(0) == '=') {
return parseFromInput(char0 + "[" + input.substring(1) + "]", context);
}
if (char0 == '#' || char0 == '?') {
throw new SuggestInputParseException(new NoMatchException("Unknown mask: " + full + ", See: //masks"), full,
() -> {
if (full.length() == 1) return new ArrayList<>(dispatcher.getPrimaryAliases());
return dispatcher.getAliases().stream().filter(
s -> s.startsWith(command.toLowerCase())
).collect(Collectors.toList());
} else {
mask = Iterables.getFirst(parse(input, actor), null);
SuggestInputParseException suggestion = null; // TODO NOT IMPLEMENTED suggestion
if (mask == null) {
// Legacy patterns
char char0 = command.charAt(0);
boolean charMask = input.length() > 1 && input.charAt(1) != '[';
if (charMask && input.charAt(0) == '=') {
return parseFromInput(char0 + "[" + input.substring(1) + "]", context);
}
if (char0 == '#' || char0 == '?') {
throw suggestion;
// throw new SuggestInputParseException(new NoMatchException("Unknown mask: " + full + ", See: //masks"), full,
// () -> {
// if (full.length() == 1) return new ArrayList<>(dispatcher.getPrimaryAliases());
// return dispatcher.getAliases().stream().filter(
// s -> s.startsWith(command.toLowerCase())
// ).collect(Collectors.toList());
// }
// );
}
// Legacy syntax
if (charMask) {
switch (char0) {
case '\\': //
case '/': //
case '{': //
case '$': //
case '%': {
String value = command.substring(1) + ((entry.getValue().isEmpty()) ? "" : "[" + StringMan.join(entry.getValue(), "][") + "]");
if (value.contains(":")) {
if (value.charAt(0) == ':') value.replaceFirst(":", "");
value = value.replaceAll(":", "][");
}
mask = parseFromInput("#" + char0 + "[" + value + "]", context);
break;
}
);
}
// Legacy syntax
if (charMask) {
switch (char0) {
case '\\': //
case '/': //
case '{': //
case '$': //
case '%': {
String value = command.substring(1) + ((entry.getValue().isEmpty()) ? "" : "[" + StringMan.join(entry.getValue(), "][") + "]");
if (value.contains(":")) {
if (value.charAt(0) == ':') value.replaceFirst(":", "");
value = value.replaceAll(":", "][");
}
mask = parseFromInput("#" + char0 + "[" + value + "]", context);
break;
case '|':
case '~':
case '<':
case '>':
case '!':
input = input.substring(input.indexOf(char0) + 1);
mask = parseFromInput(char0 + "[" + input + "]", context);
if (actor != null) {
BBC.COMMAND_CLARIFYING_BRACKET.send(actor, char0 + "[" + input + "]");
}
return mask;
}
case '|':
case '~':
case '<':
case '>':
case '!':
input = input.substring(input.indexOf(char0) + 1);
mask = parseFromInput(char0 + "[" + input + "]", context);
if (actor != null) {
BBC.COMMAND_CLARIFYING_BRACKET.send(actor, char0 + "[" + input + "]");
}
return mask;
}
}
if (mask == null) {
@ -182,37 +149,38 @@ public class DefaultMaskParser extends FaweParser<Mask> {
}
}
}
} else {
List<String> args = entry.getValue();
String cmdArgs = ((args.isEmpty()) ? "" : " " + StringMan.join(args, " "));
try {
mask = (Mask) dispatcher.call(command + cmdArgs, locals, new String[0]);
} catch (SuggestInputParseException rethrow) {
throw rethrow;
} catch (Throwable e) {
throw SuggestInputParseException.of(e, full, () -> {
try {
List<String> suggestions = dispatcher.get(command).getCallable().getSuggestions(cmdArgs, locals);
if (suggestions.size() <= 2) {
for (int i = 0; i < suggestions.size(); i++) {
String suggestion = suggestions.get(i);
if (suggestion.indexOf(' ') != 0) {
String[] split = suggestion.split(" ");
suggestion = BBC.color("[" + StringMan.join(split, "][") + "]");
suggestions.set(i, suggestion);
}
}
}
return suggestions;
} catch (CommandException e1) {
throw new InputParseException(e1.getMessage());
} catch (Throwable e2) {
e2.printStackTrace();
throw new InputParseException(e2.getMessage());
}
});
}
}
// else {
// List<String> args = entry.getValue();
// String cmdArgs = ((args.isEmpty()) ? "" : " " + StringMan.join(args, " "));
// try {
// mask = (Mask) dispatcher.call(command + cmdArgs, locals, new String[0]);
// } catch (SuggestInputParseException rethrow) {
// throw rethrow;
// } catch (Throwable e) {
// throw SuggestInputParseException.of(e, full, () -> {
// try {
// List<String> suggestions = dispatcher.get(command).getCallable().getSuggestions(cmdArgs, locals);
// if (suggestions.size() <= 2) {
// for (int i = 0; i < suggestions.size(); i++) {
// String suggestion = suggestions.get(i);
// if (suggestion.indexOf(' ') != 0) {
// String[] split = suggestion.split(" ");
// suggestion = "[" + StringMan.join(split, "][") + "]";
// suggestions.set(i, suggestion);
// }
// }
// }
// return suggestions;
// } catch (CommandException e1) {
// throw new InputParseException(e1.getMessage());
// } catch (Throwable e2) {
// e2.printStackTrace();
// throw new InputParseException(e2.getMessage());
// }
// });
// }
// }
if (pe.and) {
masks.add(new ArrayList<>());
}

Datei anzeigen

@ -32,14 +32,11 @@ import com.sk89q.worldedit.extension.input.InputParseException;
import com.sk89q.worldedit.extension.input.NoMatchException;
import com.sk89q.worldedit.extension.input.ParserContext;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extension.platform.PlatformCommandManager;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.function.pattern.RandomPattern;
import com.sk89q.worldedit.internal.command.ActorAuthorizer;
import com.sk89q.worldedit.internal.command.WorldEditBinding;
import com.sk89q.worldedit.internal.expression.Expression;
import com.sk89q.worldedit.util.command.Dispatcher;
import com.sk89q.worldedit.util.command.SimpleDispatcher;
import com.sk89q.worldedit.util.command.parametric.ParametricBuilder;
import com.sk89q.worldedit.world.block.BlockTypes;
import java.util.ArrayList;
import java.util.List;
@ -49,24 +46,9 @@ import java.util.stream.Collectors;
import java.util.stream.Stream;
public class DefaultPatternParser extends FaweParser<Pattern> {
private final Dispatcher dispatcher;
public DefaultPatternParser(WorldEdit worldEdit) {
super(worldEdit);
this.dispatcher = new SimpleDispatcher();
this.register(new PatternCommands());
}
@Override
public Dispatcher getDispatcher() {
return dispatcher;
}
public void register(Object clazz) {
ParametricBuilder builder = new ParametricBuilder();
builder.setAuthorizer(new ActorAuthorizer());
builder.addBinding(new WorldEditBinding(worldEdit));
builder.registerMethodsAsCommands(dispatcher, clazz);
public DefaultPatternParser(WorldEdit worldEdit, PlatformCommandManager commandManager) {
super(worldEdit, commandManager, Pattern.class);
}
@Override
@ -161,7 +143,7 @@ public class DefaultPatternParser extends FaweParser<Pattern> {
String suggestion = suggestions.get(i);
if (suggestion.indexOf(' ') != 0) {
String[] split = suggestion.split(" ");
suggestion = BBC.color("[" + StringMan.join(split, "][") + "]");
suggestion = "[" + StringMan.join(split, "][") + "]";
suggestions.set(i, suggestion);
}
}

Datei anzeigen

@ -19,7 +19,10 @@
package com.sk89q.worldedit.extension.platform;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.NotABlockException;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extent.Extent;
@ -33,6 +36,7 @@ import com.sk89q.worldedit.util.HandSide;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.util.TargetBlock;
import com.sk89q.worldedit.util.auth.AuthorizationException;
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.block.BlockStateHolder;
@ -44,13 +48,13 @@ import com.sk89q.worldedit.world.gamemode.GameModes;
import com.sk89q.worldedit.world.item.ItemType;
import com.sk89q.worldedit.world.item.ItemTypes;
import com.sk89q.worldedit.world.registry.BlockMaterial;
import java.io.File;
import javax.annotation.Nullable;
/**
* An abstract implementation of both a {@link Actor} and a {@link Player} that is intended for
* implementations of WorldEdit to use to wrap players that make use of WorldEdit.
* An abstract implementation of both a {@link Actor} and a {@link Player}
* that is intended for implementations of WorldEdit to use to wrap
* players that make use of WorldEdit.
*/
public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
@ -151,12 +155,12 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
@Override
public void findFreePosition() {
findFreePosition(getBlockIn());
findFreePosition(getBlockLocation());
}
@Override
public boolean ascendLevel() {
final Location pos = getBlockIn();
final Location pos = getBlockLocation();
final int x = pos.getBlockX();
int y = Math.max(0, pos.getBlockY());
final int z = pos.getBlockZ();
@ -214,7 +218,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
@Override
public boolean descendLevel() {
final Location pos = getBlockIn();
final Location pos = getBlockLocation();
final int x = pos.getBlockX();
int y = Math.max(0, pos.getBlockY());
final int z = pos.getBlockZ();
@ -277,7 +281,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
@Override
public boolean ascendToCeiling(int clearance, boolean alwaysGlass) {
Location pos = getBlockIn();
Location pos = getBlockLocation();
int x = pos.getBlockX();
int initialY = Math.max(0, pos.getBlockY());
int y = Math.max(0, pos.getBlockY() + 2);
@ -294,6 +298,13 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
if (world.getBlock(BlockVector3.at(x, y, z)).getBlockType().getMaterial()
.isMovementBlocker()) {
int platformY = Math.max(initialY, y - 3 - clearance);
if (platformY < initialY) { // if ==, they already have the given clearance, if <, clearance is too large
printError("Not enough space above you!");
return false;
} else if (platformY == initialY) {
printError("You're already at the ceiling.");
return false;
}
floatAt(x, platformY + 1, z, alwaysGlass);
return true;
}
@ -311,7 +322,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
@Override
public boolean ascendUpwards(int distance, boolean alwaysGlass) {
final Location pos = getBlockIn();
final Location pos = getBlockLocation();
final int x = pos.getBlockX();
final int initialY = Math.max(0, pos.getBlockY());
int y = Math.max(0, pos.getBlockY() + 1);
@ -338,27 +349,41 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
@Override
public void floatAt(int x, int y, int z, boolean alwaysGlass) {
try {
if (alwaysGlass || !isAllowedToFly()) {
BlockVector3 spot = BlockVector3.at(x, y - 1, z);
if (!getLocation().getExtent().getBlock(spot).getBlockType().getMaterial()
.isMovementBlocker()) {
getLocation().getExtent().setBlock(spot, BlockTypes.GLASS.getDefaultState());
final World world = getWorld();
if (!world.getBlock(spot).getBlockType().getMaterial().isMovementBlocker()) {
try (EditSession session = WorldEdit.getInstance().getEditSessionFactory().getEditSession(world, 1, this)) {
session.setBlock(spot, BlockTypes.GLASS.getDefaultState());
} catch (MaxChangedBlocksException ignored) {
}
} catch (WorldEditException e) {
e.printStackTrace();
}
} else {
setFlying(true);
}
setPosition(Vector3.at(x + 0.5, y, z + 0.5));
}
@Override
public Location getBlockIn() {
return getLocation().setPosition(getLocation().toVector().floor());
/**
* Check whether the player is allowed to fly.
*
* @return true if allowed flight
*/
protected boolean isAllowedToFly() {
return false;
}
/**
* Set whether the player is currently flying.
*
* @param flying true to fly
*/
protected void setFlying(boolean flying) {
}
@Override
public Location getBlockOn() {
return getLocation()
.setPosition(getLocation().setY(getLocation().getY() - 1).toVector().floor());
return getLocation().setPosition(getLocation().setY(getLocation().getY() - 1).toVector().floor());
}
@Override
@ -407,15 +432,16 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
@Override
public Direction getCardinalDirection(int yawOffset) {
if (getLocation().getPitch() > 67.5) {
final Location location = getLocation();
if (location.getPitch() > 67.5) {
return Direction.DOWN;
}
if (getLocation().getPitch() < -67.5) {
if (location.getPitch() < -67.5) {
return Direction.UP;
}
// From hey0's code
double rot = (getLocation().getYaw() + yawOffset) % 360; //let's use real yaw now
double rot = (location.getYaw() + yawOffset) % 360; //let's use real yaw now
if (rot < 0) {
rot += 360.0;
}
@ -435,56 +461,66 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
}
}
private boolean canPassThroughBlock(Location curBlock) {
BlockVector3 blockPos = curBlock.toVector().toBlockPoint();
BlockState block = curBlock.getExtent().getBlock(blockPos);
return !block.getBlockType().getMaterial().isMovementBlocker();
}
/**
* Get the player's view yaw.
*
* @return yaw
* Advances the block target block until the current block is a wall
* @return true if a wall is found
*/
@Override
public boolean passThroughForwardWall(int range) {
int searchDist = 0;
TargetBlock hitBlox = new TargetBlock(this, range, 0.2);
Extent world = getLocation().getExtent();
Location block;
boolean firstBlock = true;
int freeToFind = 2;
boolean inFree = false;
while ((block = hitBlox.getNextBlock()) != null) {
boolean free = !world.getBlock(block.toVector().toBlockPoint()).getBlockType()
.getMaterial().isMovementBlocker();
if (firstBlock) {
firstBlock = false;
if (!free) {
--freeToFind;
continue;
}
}
++searchDist;
if (searchDist > 20) {
return false;
}
if (inFree != free) {
if (free) {
--freeToFind;
}
}
if (freeToFind == 0) {
setOnGround(block);
private boolean advanceToWall(TargetBlock hitBlox) {
Location curBlock;
while ((curBlock = hitBlox.getCurrentBlock()) != null) {
if (!canPassThroughBlock(curBlock)) {
return true;
}
inFree = free;
hitBlox.getNextBlock();
}
return false;
}
/**
* Advances the block target block until the current block is a free
* @return true if a free spot is found
*/
private boolean advanceToFree(TargetBlock hitBlox) {
Location curBlock;
while ((curBlock = hitBlox.getCurrentBlock()) != null) {
if (canPassThroughBlock(curBlock)) {
return true;
}
hitBlox.getNextBlock();
}
return false;
}
@Override
public boolean passThroughForwardWall(int range) {
TargetBlock hitBlox = new TargetBlock(this, range, 0.2);
if (!advanceToWall(hitBlox)) {
return false;
}
if (!advanceToFree(hitBlox)) {
return false;
}
Location foundBlock = hitBlox.getCurrentBlock();
if (foundBlock != null) {
setOnGround(foundBlock);
return true;
}
return false;
}
@Override
public void setPosition(Vector3 pos) {

Datei anzeigen

@ -83,7 +83,7 @@ public interface Actor extends Identifiable, SessionOwner, Subject {
*/
void print(Component component);
/**
/**F
* Returns true if the actor can destroy bedrock.
*
* @return true if bedrock can be broken by the actor

Datei anzeigen

@ -232,7 +232,7 @@ public class BlockMaskBuilder {
private void suggest(String input, String property, Collection<BlockType> finalTypes) throws InputParseException {
throw new SuggestInputParseException(input + " does not have: " + property, input, () -> {
Set<PropertyKey> keys = new HashSet<>();
finalTypes.forEach(t -> t.getProperties().stream().forEach(p -> keys.add(p.getKey())));
finalTypes.forEach(t -> t.getProperties().forEach(p -> keys.add(p.getKey())));
return keys.stream().map(PropertyKey::getId)
.filter(p -> StringMan.blockStateMatches(property, p))
.sorted(StringMan.blockStateComparator(property))

Datei anzeigen

@ -22,20 +22,20 @@ package com.sk89q.worldedit.function.mask;
import static com.google.common.base.Preconditions.checkNotNull;
import com.boydti.fawe.Fawe;
import com.google.common.base.Function;
import com.sk89q.worldedit.math.BlockVector3;
import javax.annotation.Nullable;
import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.function.Function;
import javax.annotation.Nullable;
/**
@ -100,7 +100,7 @@ public class MaskIntersection extends AbstractMask {
}
}
public Function<Map.Entry<Mask, Mask>, Mask> pairingFunction() {
public Function<Entry<Mask, Mask>, Mask> pairingFunction() {
return input -> input.getKey().tryCombine(input.getValue());
}
@ -120,12 +120,11 @@ public class MaskIntersection extends AbstractMask {
}
if (changed) {
masks.clear();
for (Mask mask : masksArray) masks.add(mask);
Collections.addAll(masks, masksArray);
}
// Optimize this
boolean formArray = false;
for (int i = 0; i < masksArray.length; i++) {
Mask mask = masksArray[i];
for (Mask mask : masksArray) {
if (mask.getClass() == this.getClass()) {
this.masks.remove(mask);
this.masks.addAll(((MaskIntersection) mask).getMasks());
@ -162,7 +161,7 @@ public class MaskIntersection extends AbstractMask {
return changed ? this : null;
}
private boolean combineMasks(Function<Map.Entry<Mask, Mask>, Mask> pairing, Set<Map.Entry<Mask, Mask>> failedCombines) {
private boolean combineMasks(Function<Entry<Mask, Mask>, Mask> pairing, Set<Map.Entry<Mask, Mask>> failedCombines) {
boolean hasOptimized = false;
while (true) {
Mask[] result = null;

Datei anzeigen

@ -19,16 +19,14 @@
package com.sk89q.worldedit.function.mask;
import com.google.common.base.Function;
import com.sk89q.worldedit.math.BlockVector3;
import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.function.Function;
import javax.annotation.Nullable;
/**
@ -81,7 +79,7 @@ public class MaskUnion extends MaskIntersection {
}
@Override
public Function<Map.Entry<Mask, Mask>, Mask> pairingFunction() {
public Function<Entry<Mask, Mask>, Mask> pairingFunction() {
return input -> input.getKey().tryOr(input.getValue());
}

Datei anzeigen

@ -21,13 +21,14 @@ package com.sk89q.worldedit.function.pattern;
import static com.google.common.base.Preconditions.checkNotNull;
import com.boydti.fawe.beta.FilterBlock;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockStateHolder;
/**
* A pattern that returns the same {@link BaseBlock} each time.
*
* @deprecated all BlockStateHolders can be used directly as a pattern
*/
@Deprecated
public class BlockPattern extends AbstractPattern {
@ -39,7 +40,6 @@ public class BlockPattern extends AbstractPattern {
*
* @param block the block
*/
@Deprecated
public BlockPattern(BlockStateHolder<?> block) {
setBlock(block);
}

Datei anzeigen

@ -20,6 +20,7 @@
package com.sk89q.worldedit.function.visitor;
import com.boydti.fawe.config.BBC;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.function.RegionFunction;
import com.sk89q.worldedit.function.operation.Operation;
@ -58,6 +59,9 @@ public class RegionVisitor implements Operation {
this.iterable = iterable;
}
public RegionVisitor(Region region, RegionFunction regionFunction, EditSession editSession) {
}
/**
* Get the number of affected objects.
*

Datei anzeigen

@ -1,17 +1,10 @@
package com.sk89q.worldedit.function.visitor;
import com.boydti.fawe.beta.IChunk;
import com.boydti.fawe.util.MathMan;
import com.sk89q.worldedit.function.RegionFunction;
import com.sk89q.worldedit.math.BlockVector3;
import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
import it.unimi.dsi.fastutil.longs.LongArraySet;
import it.unimi.dsi.fastutil.objects.ObjectIterator;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.concurrent.ConcurrentLinkedQueue;
@ -24,12 +17,12 @@ public class ScanChunk {
public static final BlockVector3[] DIAGONAL_DIRECTIONS;
static {
DEFAULT_DIRECTIONS[0] = (BlockVector3.at(0, -1, 0));
DEFAULT_DIRECTIONS[1] = (BlockVector3.at(0, 1, 0));
DEFAULT_DIRECTIONS[2] = (BlockVector3.at(-1, 0, 0));
DEFAULT_DIRECTIONS[3] = (BlockVector3.at(1, 0, 0));
DEFAULT_DIRECTIONS[4] = (BlockVector3.at(0, 0, -1));
DEFAULT_DIRECTIONS[5] = (BlockVector3.at(0, 0, 1));
DEFAULT_DIRECTIONS[0] = BlockVector3.at(0, -1, 0);
DEFAULT_DIRECTIONS[1] = BlockVector3.at(0, 1, 0);
DEFAULT_DIRECTIONS[2] = BlockVector3.at(-1, 0, 0);
DEFAULT_DIRECTIONS[3] = BlockVector3.at(1, 0, 0);
DEFAULT_DIRECTIONS[4] = BlockVector3.at(0, 0, -1);
DEFAULT_DIRECTIONS[5] = BlockVector3.at(0, 0, 1);
List<BlockVector3> list = new ArrayList<>();
for (int x = -1; x <= 1; x++) {
for (int y = -1; y <= 1; y++) {
@ -43,13 +36,8 @@ public class ScanChunk {
}
}
}
Collections.sort(list, new Comparator<BlockVector3>() {
@Override
public int compare(BlockVector3 o1, BlockVector3 o2) {
return (int) Math.signum(o1.lengthSq() - o2.lengthSq());
}
});
DIAGONAL_DIRECTIONS = list.toArray(new BlockVector3[list.size()]);
list.sort((o1, o2) -> (int) Math.signum(o1.lengthSq() - o2.lengthSq()));
DIAGONAL_DIRECTIONS = list.toArray(new BlockVector3[0]);
}
private final RegionFunction function;
@ -57,7 +45,7 @@ public class ScanChunk {
private final Long2ObjectOpenHashMap<long[][]> visits;
private final Long2ObjectOpenHashMap<char[][]> queues;
public ScanChunk(final RegionFunction function) {
public ScanChunk(RegionFunction function) {
this.function = function;
this.directions = DEFAULT_DIRECTIONS;
@ -65,8 +53,8 @@ public class ScanChunk {
this.visits = new Long2ObjectOpenHashMap<>();
}
public static final long pairInt(int x, int y) {
return (((long) x) << 32) | (y & 0xffffffffL);
public static long pairInt(int x, int y) {
return (long) x << 32 | y & 0xffffffffL;
}
public boolean isVisited(int x, int y, int z) {
@ -180,7 +168,7 @@ public class ScanChunk {
char triple = queue[index];
int x = index & 15;
int z = (index >> 4) & 15;
int z = index >> 4 & 15;
int y = index >> 8;
int absX = xx + x;
@ -249,7 +237,7 @@ public class ScanChunk {
char triple = queue[index];
int x = index & 15;
int z = (index >> 4) & 15;
int z = index >> 4 & 15;
int y = index >> 8;
}
queuePool.add(queue);
@ -327,11 +315,11 @@ public class ScanChunk {
}
public void set(long[] bits, int i) {
bits[i >> 6] |= (1L << (i & 0x3F));
bits[i >> 6] |= 1L << (i & 0x3F);
}
public boolean get(long[] bits, final int i) {
return (bits[i >> 6] & (1L << (i & 0x3F))) != 0;
public boolean get(long[] bits, int i) {
return (bits[i >> 6] & 1L << (i & 0x3F)) != 0;
}
public char getLocalIndex(int x, int y, int z) {

Datei anzeigen

@ -20,6 +20,7 @@
package com.sk89q.worldedit.internal.command.exception;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.collect.ImmutableList;
import com.sk89q.worldedit.DisallowedItemException;
import com.sk89q.worldedit.EmptyClipboardException;
@ -40,11 +41,11 @@ import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.util.io.file.FileSelectionAbortedException;
import com.sk89q.worldedit.util.io.file.FilenameResolutionException;
import com.sk89q.worldedit.util.io.file.InvalidFilenameException;
import org.enginehub.piston.exception.CommandException;
import org.enginehub.piston.exception.UsageException;
import com.sk89q.worldedit.world.storage.MissingWorldException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.enginehub.piston.exception.CommandException;
import org.enginehub.piston.exception.UsageException;
/**
* converts WorldEdit exceptions and converts them into {@link CommandException}s.
@ -80,6 +81,10 @@ public class WorldEditExceptionConverter extends ExceptionConverterHelper {
throw newCommandException("Make a region selection first.", e);
}
@ExceptionMatch
public void convert(MissingWorldException e) throws CommandException {
throw newCommandException("You need to provide a world (Try //world)", e);
}
@ExceptionMatch
public void convert(UnknownItemException e) throws CommandException {
throw newCommandException("Block name '" + e.getID() + "' was not recognized.", e);

Datei anzeigen

@ -19,8 +19,6 @@
package com.sk89q.worldedit.math.convolution;
import com.boydti.fawe.object.visitor.Fast2DIterator;
import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.EditSession;
@ -34,7 +32,6 @@ import com.sk89q.worldedit.registry.state.PropertyGroup;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockTypes;
import java.util.Iterator;
import javax.annotation.Nullable;
@ -93,11 +90,10 @@ public class HeightMap {
BlockVector3 min = region.getMinimumPoint();
int bx = min.getBlockX();
int bz = min.getBlockZ();
Iterable<BlockVector2> flat = Regions.asFlatRegion(region).asFlatRegion();
Iterator<BlockVector2> iter = new Fast2DIterator(flat, session).iterator();
Iterator<BlockVector2> flat = Regions.asFlatRegion(region).asFlatRegion().iterator();
int layer = 0;
while (iter.hasNext()) {
BlockVector2 pos = iter.next();
while (flat.hasNext()) {
BlockVector2 pos = flat.next();
int x = pos.getBlockX();
int z = pos.getBlockZ();
layer = session.getNearestSurfaceLayer(x, z, (layer + 7) >> 3, 0, maxY);

Datei anzeigen

@ -32,6 +32,7 @@ import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.registry.Keyed;
import com.sk89q.worldedit.util.Direction;
import com.sk89q.worldedit.util.TreeGenerator;
import com.sk89q.worldedit.world.block.BlockState;
@ -41,11 +42,12 @@ import com.sk89q.worldedit.world.weather.WeatherType;
import javax.annotation.Nullable;
import java.nio.file.Path;
import java.util.Locale;
/**
* Represents a world (dimension).
*/
public interface World extends Extent {
public interface World extends Extent, Keyed {
/**
* Get the name of the world.
@ -284,4 +286,8 @@ public interface World extends Extent {
return true;
}
@Override
default String getId() {
return getName().replace(" ", "_").toLowerCase(Locale.ROOT);
}
}

Datei anzeigen

@ -182,7 +182,7 @@ public class BaseBlock implements BlockStateHolder<BaseBlock>, TileEntityBlock {
@Override
public void setNbtData(@Nullable CompoundTag nbtData) {
throw new UnsupportedOperationException("Immutable");
throw new UnsupportedOperationException("This class is immutable.");
}
/**
@ -239,7 +239,7 @@ public class BaseBlock implements BlockStateHolder<BaseBlock>, TileEntityBlock {
}
@Override
public final BaseBlock toBaseBlock() {
public BaseBlock toBaseBlock() {
return this;
}

Datei anzeigen

@ -301,6 +301,9 @@ public class BlockState implements BlockStateHolder<BlockState>, FawePattern {
@Override
public boolean equalsFuzzy(BlockStateHolder<?> o) {
if (null == o) {
return false;
}
if (this == o) {
// Added a reference equality check for speediness
return true;
@ -308,9 +311,6 @@ public class BlockState implements BlockStateHolder<BlockState>, FawePattern {
if (o.getClass() == BlockState.class) {
return o.getOrdinal() == this.getOrdinal();
}
if (null == o) {
return false;
}
return o.equalsFuzzy(this);
}