Fixes #1099
This commit is contained in:
parent
e57ac75a50
commit
9a67e7deb0
@ -29,6 +29,8 @@ import com.sk89q.worldedit.regions.selector.CylinderRegionSelector;
|
|||||||
import com.sk89q.worldedit.session.ClipboardHolder;
|
import com.sk89q.worldedit.session.ClipboardHolder;
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
import com.sk89q.worldedit.world.registry.WorldData;
|
import com.sk89q.worldedit.world.registry.WorldData;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
@ -158,60 +160,84 @@ public abstract class FawePlayer<T> extends Metadatable {
|
|||||||
return cancelled;
|
return cancelled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checkConfirmation(String command, int times, int limit) throws RegionOperationException {
|
private void setConfirmTask(@Nullable WorldEditRunnable task, String command) {
|
||||||
if (command == null || getMeta("cmdConfirmRunning", false)) {
|
setMeta("cmdConfirm", task == null ? (WorldEditRunnable) () ->
|
||||||
return;
|
CommandManager.getInstance().handleCommandOnCurrentThread(new CommandEvent(getPlayer(), command))
|
||||||
}
|
: task);
|
||||||
if (times > limit) {
|
|
||||||
setMeta("cmdConfirm", command);
|
|
||||||
String volume = "<unspecified>";
|
|
||||||
throw new RegionOperationException(BBC.WORLDEDIT_CANCEL_REASON_CONFIRM.f(0, times, command, volume));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checkConfirmationRadius(String command, int radius) throws RegionOperationException {
|
public void checkConfirmation(@Nullable WorldEditRunnable task, String command, int times, int limit) throws WorldEditException {
|
||||||
if (command == null || getMeta("cmdConfirmRunning", false)) {
|
if (command != null && !getMeta("cmdConfirmRunning", false)) {
|
||||||
return;
|
if (times > limit) {
|
||||||
}
|
setConfirmTask(task, command);
|
||||||
if (radius > 0) {
|
String volume = "<unspecified>";
|
||||||
if (radius > 448) {
|
throw new RegionOperationException(BBC.WORLDEDIT_CANCEL_REASON_CONFIRM.f(0, times, command, volume));
|
||||||
setMeta("cmdConfirm", command);
|
|
||||||
long volume = (long) (Math.PI * ((double) radius * radius));
|
|
||||||
throw new RegionOperationException(BBC.WORLDEDIT_CANCEL_REASON_CONFIRM.f(0, radius, command, NumberFormat.getNumberInstance().format(volume)));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (task != null) task.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checkConfirmationStack(String command, Region region, int times) throws RegionOperationException {
|
public void checkConfirmationRadius(@Nullable WorldEditRunnable task, String command, int radius) throws WorldEditException {
|
||||||
if (command == null || getMeta("cmdConfirmRunning", false)) {
|
if (command != null && !getMeta("cmdConfirmRunning", false)) {
|
||||||
return;
|
if (radius > 0) {
|
||||||
}
|
if (radius > 448) {
|
||||||
if (region != null) {
|
setConfirmTask(task, command);
|
||||||
Vector min = region.getMinimumPoint().toBlockVector();
|
long volume = (long) (Math.PI * ((double) radius * radius));
|
||||||
Vector max = region.getMaximumPoint().toBlockVector();
|
throw new RegionOperationException(BBC.WORLDEDIT_CANCEL_REASON_CONFIRM.f(0, radius, command, NumberFormat.getNumberInstance().format(volume)));
|
||||||
long area = (long) ((max.getX() - min.getX()) * (max.getZ() - min.getZ() + 1)) * times;
|
}
|
||||||
if (area > 2 << 18) {
|
|
||||||
setMeta("cmdConfirm", command);
|
|
||||||
long volume = (long) max.subtract(min).add(Vector.ONE).volume() * times;
|
|
||||||
throw new RegionOperationException(BBC.WORLDEDIT_CANCEL_REASON_CONFIRM.f(min, max, command, NumberFormat.getNumberInstance().format(volume)));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (task != null) task.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checkConfirmationRegion(String command, Region region) throws RegionOperationException {
|
public void checkConfirmationStack(@Nullable WorldEditRunnable task, String command, Region region, int times) throws WorldEditException {
|
||||||
if (command == null || getMeta("cmdConfirmRunning", false)) {
|
if (command != null && !getMeta("cmdConfirmRunning", false)) {
|
||||||
return;
|
if (region != null) {
|
||||||
}
|
Vector min = region.getMinimumPoint().toBlockVector();
|
||||||
if (region != null) {
|
Vector max = region.getMaximumPoint().toBlockVector();
|
||||||
Vector min = region.getMinimumPoint().toBlockVector();
|
long area = (long) ((max.getX() - min.getX()) * (max.getZ() - min.getZ() + 1)) * times;
|
||||||
Vector max = region.getMaximumPoint().toBlockVector();
|
if (area > 2 << 18) {
|
||||||
long area = (long) ((max.getX() - min.getX()) * (max.getZ() - min.getZ() + 1));
|
setConfirmTask(task, command);
|
||||||
if (area > 2 << 18) {
|
long volume = (long) max.subtract(min).add(Vector.ONE).volume() * times;
|
||||||
setMeta("cmdConfirm", command);
|
throw new RegionOperationException(BBC.WORLDEDIT_CANCEL_REASON_CONFIRM.f(min, max, command, NumberFormat.getNumberInstance().format(volume)));
|
||||||
long volume = (long) max.subtract(min).add(Vector.ONE).volume();
|
}
|
||||||
throw new RegionOperationException(BBC.WORLDEDIT_CANCEL_REASON_CONFIRM.f(min, max, command, NumberFormat.getNumberInstance().format(volume)));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (task != null) task.run();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void checkConfirmationRegion(@Nullable WorldEditRunnable task, String command, Region region) throws WorldEditException {
|
||||||
|
if (command != null && !getMeta("cmdConfirmRunning", false)) {
|
||||||
|
if (region != null) {
|
||||||
|
Vector min = region.getMinimumPoint().toBlockVector();
|
||||||
|
Vector max = region.getMaximumPoint().toBlockVector();
|
||||||
|
long area = (long) ((max.getX() - min.getX()) * (max.getZ() - min.getZ() + 1));
|
||||||
|
if (area > 2 << 18) {
|
||||||
|
setConfirmTask(task, command);
|
||||||
|
long volume = (long) max.subtract(min).add(Vector.ONE).volume();
|
||||||
|
throw new RegionOperationException(BBC.WORLDEDIT_CANCEL_REASON_CONFIRM.f(min, max, command, NumberFormat.getNumberInstance().format(volume)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (task != null) task.run();
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized boolean confirm() {
|
||||||
|
WorldEditRunnable confirm = deleteMeta("cmdConfirm");
|
||||||
|
if (!(confirm instanceof Runnable)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
queueAction(() -> {
|
||||||
|
setMeta("cmdConfirmRunning", true);
|
||||||
|
try {
|
||||||
|
confirm.run();
|
||||||
|
} catch (WorldEditException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
} finally {
|
||||||
|
setMeta("cmdConfirmRunning", false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checkAllowedRegion(Region wrappedSelection) {
|
public void checkAllowedRegion(Region wrappedSelection) {
|
||||||
@ -224,20 +250,6 @@ public abstract class FawePlayer<T> extends Metadatable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean confirm() {
|
|
||||||
String confirm = deleteMeta("cmdConfirm");
|
|
||||||
if (confirm == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
queueAction(() -> {
|
|
||||||
setMeta("cmdConfirmRunning", true);
|
|
||||||
CommandEvent event = new CommandEvent(getPlayer(), confirm);
|
|
||||||
CommandManager.getInstance().handleCommandOnCurrentThread(event);
|
|
||||||
setMeta("cmdConfirmRunning", false);
|
|
||||||
});
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean toggle(String perm) {
|
public boolean toggle(String perm) {
|
||||||
if (this.hasPermission(perm)) {
|
if (this.hasPermission(perm)) {
|
||||||
this.setPermission(perm, false);
|
this.setPermission(perm, false);
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
package com.boydti.fawe.object;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
|
|
||||||
|
public interface WorldEditRunnable {
|
||||||
|
void run() throws WorldEditException;
|
||||||
|
}
|
@ -152,35 +152,37 @@ public class ClipboardCommands extends MethodCommands {
|
|||||||
public void copy(FawePlayer fp, Player player, LocalSession session, EditSession editSession,
|
public void copy(FawePlayer fp, Player player, LocalSession session, EditSession editSession,
|
||||||
@Selection Region region, @Switch('e') boolean skipEntities,
|
@Selection Region region, @Switch('e') boolean skipEntities,
|
||||||
@Switch('m') Mask mask, CommandContext context, @Switch('b') boolean copyBiomes) throws WorldEditException {
|
@Switch('m') Mask mask, CommandContext context, @Switch('b') boolean copyBiomes) throws WorldEditException {
|
||||||
fp.checkConfirmationRegion(getArguments(context), region);
|
Vector pos = session.getPlacementPosition(player);
|
||||||
Vector min = region.getMinimumPoint();
|
fp.checkConfirmationRegion(() -> {
|
||||||
Vector max = region.getMaximumPoint();
|
Vector min = region.getMinimumPoint();
|
||||||
long volume = (((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1));
|
Vector max = region.getMaximumPoint();
|
||||||
FaweLimit limit = FawePlayer.wrap(player).getLimit();
|
long volume = (((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1));
|
||||||
if (volume >= limit.MAX_CHECKS) {
|
FaweLimit limit = FawePlayer.wrap(player).getLimit();
|
||||||
throw new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_CHECKS);
|
if (volume >= limit.MAX_CHECKS) {
|
||||||
}
|
throw new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_CHECKS);
|
||||||
session.setClipboard(null);
|
}
|
||||||
BlockArrayClipboard clipboard = new BlockArrayClipboard(region, player.getUniqueId());
|
session.setClipboard(null);
|
||||||
session.setClipboard(new ClipboardHolder(clipboard, editSession.getWorldData()));
|
BlockArrayClipboard clipboard = new BlockArrayClipboard(region, player.getUniqueId());
|
||||||
|
session.setClipboard(new ClipboardHolder(clipboard, editSession.getWorldData()));
|
||||||
|
|
||||||
clipboard.setOrigin(session.getPlacementPosition(player));
|
clipboard.setOrigin(pos);
|
||||||
ForwardExtentCopy copy = new ForwardExtentCopy(editSession, region, clipboard, region.getMinimumPoint());
|
ForwardExtentCopy copy = new ForwardExtentCopy(editSession, region, clipboard, region.getMinimumPoint());
|
||||||
copy.setCopyEntities(!skipEntities);
|
copy.setCopyEntities(!skipEntities);
|
||||||
copy.setCopyBiomes(copyBiomes);
|
copy.setCopyBiomes(copyBiomes);
|
||||||
Mask sourceMask = editSession.getSourceMask();
|
Mask sourceMask = editSession.getSourceMask();
|
||||||
if (sourceMask != null) {
|
if (sourceMask != null) {
|
||||||
new MaskTraverser(sourceMask).reset(editSession);
|
new MaskTraverser(sourceMask).reset(editSession);
|
||||||
copy.setSourceMask(sourceMask);
|
copy.setSourceMask(sourceMask);
|
||||||
editSession.setSourceMask(null);
|
editSession.setSourceMask(null);
|
||||||
}
|
}
|
||||||
if (mask != null && mask != Masks.alwaysTrue()) {
|
if (mask != null && mask != Masks.alwaysTrue()) {
|
||||||
copy.setSourceMask(mask);
|
copy.setSourceMask(mask);
|
||||||
}
|
}
|
||||||
Operations.completeLegacy(copy);
|
Operations.completeBlindly(copy);
|
||||||
BBC.COMMAND_COPY.send(player, region.getArea());
|
BBC.COMMAND_COPY.send(player, region.getArea());
|
||||||
if (!FawePlayer.wrap(player).hasPermission("fawe.tips"))
|
if (!FawePlayer.wrap(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);
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -240,7 +242,6 @@ public class ClipboardCommands extends MethodCommands {
|
|||||||
public void cut(FawePlayer fp, Player player, LocalSession session, EditSession editSession,
|
public void cut(FawePlayer fp, Player player, LocalSession session, EditSession editSession,
|
||||||
@Selection Region region, @Optional("air") Pattern leavePattern, @Switch('e') boolean skipEntities,
|
@Selection Region region, @Optional("air") Pattern leavePattern, @Switch('e') boolean skipEntities,
|
||||||
@Switch('m') Mask mask, @Switch('b') boolean copyBiomes, CommandContext context) throws WorldEditException {
|
@Switch('m') Mask mask, @Switch('b') boolean copyBiomes, CommandContext context) throws WorldEditException {
|
||||||
fp.checkConfirmationRegion(getArguments(context), region);
|
|
||||||
Vector min = region.getMinimumPoint();
|
Vector min = region.getMinimumPoint();
|
||||||
Vector max = region.getMaximumPoint();
|
Vector 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));
|
||||||
@ -251,27 +252,30 @@ public class ClipboardCommands extends MethodCommands {
|
|||||||
if (volume >= limit.MAX_CHANGES) {
|
if (volume >= limit.MAX_CHANGES) {
|
||||||
throw new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_CHANGES);
|
throw new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_CHANGES);
|
||||||
}
|
}
|
||||||
session.setClipboard(null);
|
Vector pos = session.getPlacementPosition(player);
|
||||||
BlockArrayClipboard clipboard = new BlockArrayClipboard(region, player.getUniqueId());
|
fp.checkConfirmationRegion(() -> {
|
||||||
clipboard.setOrigin(session.getPlacementPosition(player));
|
session.setClipboard(null);
|
||||||
ForwardExtentCopy copy = new ForwardExtentCopy(editSession, region, clipboard, region.getMinimumPoint());
|
BlockArrayClipboard clipboard = new BlockArrayClipboard(region, player.getUniqueId());
|
||||||
copy.setSourceFunction(new BlockReplace(editSession, leavePattern));
|
clipboard.setOrigin(pos);
|
||||||
copy.setCopyEntities(!skipEntities);
|
ForwardExtentCopy copy = new ForwardExtentCopy(editSession, region, clipboard, region.getMinimumPoint());
|
||||||
copy.setCopyBiomes(copyBiomes);
|
copy.setSourceFunction(new BlockReplace(editSession, leavePattern));
|
||||||
Mask sourceMask = editSession.getSourceMask();
|
copy.setCopyEntities(!skipEntities);
|
||||||
if (sourceMask != null) {
|
copy.setCopyBiomes(copyBiomes);
|
||||||
new MaskTraverser(sourceMask).reset(editSession);
|
Mask sourceMask = editSession.getSourceMask();
|
||||||
copy.setSourceMask(sourceMask);
|
if (sourceMask != null) {
|
||||||
editSession.setSourceMask(null);
|
new MaskTraverser(sourceMask).reset(editSession);
|
||||||
}
|
copy.setSourceMask(sourceMask);
|
||||||
if (mask != null) {
|
editSession.setSourceMask(null);
|
||||||
copy.setSourceMask(mask);
|
}
|
||||||
}
|
if (mask != null) {
|
||||||
Operations.completeLegacy(copy);
|
copy.setSourceMask(mask);
|
||||||
session.setClipboard(new ClipboardHolder(clipboard, editSession.getWorldData()));
|
}
|
||||||
|
Operations.completeBlindly(copy);
|
||||||
|
session.setClipboard(new ClipboardHolder(clipboard, editSession.getWorldData()));
|
||||||
|
|
||||||
BBC.COMMAND_CUT_SLOW.send(player, region.getArea());
|
BBC.COMMAND_CUT_SLOW.send(player, region.getArea());
|
||||||
if (!FawePlayer.wrap(player).hasPermission("fawe.tips")) BBC.TIP_LAZYCUT.send(player);
|
if (!FawePlayer.wrap(player).hasPermission("fawe.tips")) BBC.TIP_LAZYCUT.send(player);
|
||||||
|
}, getArguments(context), region);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(aliases = {"download"}, desc = "Downloads your clipboard through the configured web interface")
|
@Command(aliases = {"download"}, desc = "Downloads your clipboard through the configured web interface")
|
||||||
|
@ -85,10 +85,11 @@ public class GenerationCommands extends MethodCommands {
|
|||||||
@CommandPermissions("worldedit.generation.caves")
|
@CommandPermissions("worldedit.generation.caves")
|
||||||
@Logging(PLACEMENT)
|
@Logging(PLACEMENT)
|
||||||
public void caves(FawePlayer fp, LocalSession session, EditSession editSession, @Selection Region region, @Optional("8") int size, @Optional("40") int frequency, @Optional("7") int rarity, @Optional("8") int minY, @Optional("127") int maxY, @Optional("1") int systemFrequency, @Optional("25") int individualRarity, @Optional("0") int pocketChance, @Optional("0") int pocketMin, @Optional("3") int pocketMax, CommandContext context) throws WorldEditException, ParameterException {
|
public void caves(FawePlayer fp, LocalSession session, EditSession editSession, @Selection Region region, @Optional("8") int size, @Optional("40") int frequency, @Optional("7") int rarity, @Optional("8") int minY, @Optional("127") int maxY, @Optional("1") int systemFrequency, @Optional("25") int individualRarity, @Optional("0") int pocketChance, @Optional("0") int pocketMin, @Optional("3") int pocketMax, CommandContext context) throws WorldEditException, ParameterException {
|
||||||
fp.checkConfirmationRegion(getArguments(context), region);
|
fp.checkConfirmationRegion(() -> {
|
||||||
CavesGen gen = new CavesGen(size, frequency, rarity, minY, maxY, systemFrequency, individualRarity, pocketChance, pocketMin, pocketMax);
|
CavesGen gen = new CavesGen(size, frequency, rarity, minY, maxY, systemFrequency, individualRarity, pocketChance, pocketMin, pocketMax);
|
||||||
editSession.generate(region, gen);
|
editSession.generate(region, gen);
|
||||||
BBC.VISITOR_BLOCK.send(fp, editSession.getBlockChangeCount());
|
BBC.VISITOR_BLOCK.send(fp, editSession.getBlockChangeCount());
|
||||||
|
}, getArguments(context), region);
|
||||||
}
|
}
|
||||||
|
|
||||||
// public void addOre(Mask mask, Pattern material, int size, int frequency, int rarity, int minY, int maxY) throws WorldEditException {
|
// public void addOre(Mask mask, Pattern material, int size, int frequency, int rarity, int minY, int maxY) throws WorldEditException {
|
||||||
@ -103,9 +104,10 @@ public class GenerationCommands extends MethodCommands {
|
|||||||
@CommandPermissions("worldedit.generation.ore")
|
@CommandPermissions("worldedit.generation.ore")
|
||||||
@Logging(PLACEMENT)
|
@Logging(PLACEMENT)
|
||||||
public void ores(FawePlayer player, LocalSession session, EditSession editSession, @Selection Region region, Mask mask, CommandContext context) throws WorldEditException, ParameterException {
|
public void ores(FawePlayer player, LocalSession session, EditSession editSession, @Selection Region region, Mask mask, CommandContext context) throws WorldEditException, ParameterException {
|
||||||
player.checkConfirmationRegion(getArguments(context), region);
|
player.checkConfirmationRegion(() -> {
|
||||||
editSession.addOres(region, mask);
|
editSession.addOres(region, mask);
|
||||||
BBC.VISITOR_BLOCK.send(player, editSession.getBlockChangeCount());
|
BBC.VISITOR_BLOCK.send(player, editSession.getBlockChangeCount());
|
||||||
|
}, getArguments(context), region);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -166,9 +168,10 @@ public class GenerationCommands extends MethodCommands {
|
|||||||
@CommandPermissions("worldedit.generation.ore")
|
@CommandPermissions("worldedit.generation.ore")
|
||||||
@Logging(PLACEMENT)
|
@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, CommandContext context) throws WorldEditException, ParameterException {
|
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, CommandContext context) throws WorldEditException, ParameterException {
|
||||||
player.checkConfirmationRegion(getArguments(context), region);
|
player.checkConfirmationRegion(() -> {
|
||||||
editSession.addOre(region, mask, material, size, freq, rarity, minY, maxY);
|
editSession.addOre(region, mask, material, size, freq, rarity, minY, maxY);
|
||||||
BBC.VISITOR_BLOCK.send(player, editSession.getBlockChangeCount());
|
BBC.VISITOR_BLOCK.send(player, editSession.getBlockChangeCount());
|
||||||
|
}, getArguments(context), region);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -188,11 +191,11 @@ public class GenerationCommands extends MethodCommands {
|
|||||||
public void hcyl(FawePlayer fp, Player player, LocalSession session, EditSession editSession, Pattern pattern, Vector2D radius, @Optional("1") int height, @Range(min = 1) @Optional("1") double thickness, CommandContext context) throws WorldEditException, ParameterException {
|
public void hcyl(FawePlayer fp, Player player, LocalSession session, EditSession editSession, Pattern pattern, Vector2D radius, @Optional("1") int height, @Range(min = 1) @Optional("1") double thickness, CommandContext context) throws WorldEditException, ParameterException {
|
||||||
double max = MathMan.max(radius.getBlockX(), radius.getBlockZ());
|
double max = MathMan.max(radius.getBlockX(), radius.getBlockZ());
|
||||||
worldEdit.checkMaxRadius(max);
|
worldEdit.checkMaxRadius(max);
|
||||||
fp.checkConfirmationRadius(getArguments(context), (int) max);
|
|
||||||
height = Math.min(256, height);
|
|
||||||
Vector pos = session.getPlacementPosition(player);
|
Vector pos = session.getPlacementPosition(player);
|
||||||
int affected = editSession.makeHollowCylinder(pos, pattern, radius.getX(), radius.getZ(), height, thickness - 1);
|
fp.checkConfirmationRadius(() -> {
|
||||||
BBC.VISITOR_BLOCK.send(fp, affected);
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -213,11 +216,11 @@ public class GenerationCommands extends MethodCommands {
|
|||||||
public void cyl(FawePlayer fp, Player player, LocalSession session, EditSession editSession, Pattern pattern, Vector2D radius, @Optional("1") int height, @Switch('h') boolean hollow, CommandContext context) throws WorldEditException, ParameterException {
|
public void cyl(FawePlayer fp, Player player, LocalSession session, EditSession editSession, Pattern pattern, Vector2D radius, @Optional("1") int height, @Switch('h') boolean hollow, CommandContext context) throws WorldEditException, ParameterException {
|
||||||
double max = MathMan.max(radius.getBlockX(), radius.getBlockZ());
|
double max = MathMan.max(radius.getBlockX(), radius.getBlockZ());
|
||||||
worldEdit.checkMaxRadius(max);
|
worldEdit.checkMaxRadius(max);
|
||||||
fp.checkConfirmationRadius(getArguments(context), (int) max);
|
|
||||||
height = Math.min(256, height);
|
|
||||||
Vector pos = session.getPlacementPosition(player);
|
Vector pos = session.getPlacementPosition(player);
|
||||||
int affected = editSession.makeCylinder(pos, pattern, radius.getX(), radius.getZ(), height, !hollow);
|
fp.checkConfirmationRadius(() -> {
|
||||||
BBC.VISITOR_BLOCK.send(fp, affected);
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -256,16 +259,13 @@ public class GenerationCommands extends MethodCommands {
|
|||||||
public void sphere(FawePlayer fp, Player player, LocalSession session, EditSession editSession, Pattern pattern, Vector radius, @Optional("false") boolean raised, @Switch('h') boolean hollow, CommandContext context) throws WorldEditException, ParameterException {
|
public void sphere(FawePlayer fp, Player player, LocalSession session, EditSession editSession, Pattern pattern, Vector radius, @Optional("false") boolean raised, @Switch('h') boolean hollow, CommandContext context) throws WorldEditException, ParameterException {
|
||||||
double max = MathMan.max(radius.getBlockX(), radius.getBlockY(), radius.getBlockZ());
|
double max = MathMan.max(radius.getBlockX(), radius.getBlockY(), radius.getBlockZ());
|
||||||
worldEdit.checkMaxRadius(max);
|
worldEdit.checkMaxRadius(max);
|
||||||
fp.checkConfirmationRadius(getArguments(context), (int) max);
|
|
||||||
|
|
||||||
Vector pos = session.getPlacementPosition(player);
|
Vector pos = session.getPlacementPosition(player);
|
||||||
if (raised) {
|
Vector finalPos = raised ? pos.add(0, radius.getY(), 0) : pos;
|
||||||
pos = pos.add(0, radius.getY(), 0);
|
fp.checkConfirmationRadius(() -> {
|
||||||
}
|
int affected = editSession.makeSphere(finalPos, pattern, radius.getX(), radius.getY(), radius.getZ(), !hollow);
|
||||||
|
player.findFreePosition();
|
||||||
int affected = editSession.makeSphere(pos, pattern, radius.getX(), radius.getY(), radius.getZ(), !hollow);
|
BBC.VISITOR_BLOCK.send(fp, affected);
|
||||||
player.findFreePosition();
|
}, getArguments(context), (int) max);
|
||||||
BBC.VISITOR_BLOCK.send(fp, affected);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -322,12 +322,13 @@ public class GenerationCommands extends MethodCommands {
|
|||||||
@CommandPermissions("worldedit.generation.pyramid")
|
@CommandPermissions("worldedit.generation.pyramid")
|
||||||
@Logging(PLACEMENT)
|
@Logging(PLACEMENT)
|
||||||
public void pyramid(FawePlayer fp, Player player, LocalSession session, EditSession editSession, Pattern pattern, @Range(min = 1) int size, @Switch('h') boolean hollow, CommandContext context) throws WorldEditException, ParameterException {
|
public void pyramid(FawePlayer fp, Player player, LocalSession session, EditSession editSession, Pattern pattern, @Range(min = 1) int size, @Switch('h') boolean hollow, CommandContext context) throws WorldEditException, ParameterException {
|
||||||
fp.checkConfirmationRadius(getArguments(context), size);
|
|
||||||
Vector pos = session.getPlacementPosition(player);
|
|
||||||
worldEdit.checkMaxRadius(size);
|
worldEdit.checkMaxRadius(size);
|
||||||
int affected = editSession.makePyramid(pos, pattern, size, !hollow);
|
Vector pos = session.getPlacementPosition(player);
|
||||||
player.findFreePosition();
|
fp.checkConfirmationRadius(() -> {
|
||||||
BBC.VISITOR_BLOCK.send(fp, affected);
|
int affected = editSession.makePyramid(pos, pattern, size, !hollow);
|
||||||
|
player.findFreePosition();
|
||||||
|
BBC.VISITOR_BLOCK.send(fp, affected);
|
||||||
|
}, getArguments(context), size);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -360,7 +361,6 @@ public class GenerationCommands extends MethodCommands {
|
|||||||
@Switch('o') boolean offset,
|
@Switch('o') boolean offset,
|
||||||
@Switch('c') boolean offsetCenter,
|
@Switch('c') boolean offsetCenter,
|
||||||
CommandContext context) throws WorldEditException, ParameterException {
|
CommandContext context) throws WorldEditException, ParameterException {
|
||||||
fp.checkConfirmationRegion(getArguments(context), region);
|
|
||||||
final Vector zero;
|
final Vector zero;
|
||||||
Vector unit;
|
Vector unit;
|
||||||
|
|
||||||
@ -388,13 +388,15 @@ public class GenerationCommands extends MethodCommands {
|
|||||||
if (unit.getZ() == 0) unit.mutZ(1);
|
if (unit.getZ() == 0) unit.mutZ(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
fp.checkConfirmationRegion(() -> {
|
||||||
final int affected = editSession.makeShape(region, zero, unit, pattern, expression, hollow);
|
try {
|
||||||
player.findFreePosition();
|
final int affected = editSession.makeShape(region, zero, unit, pattern, expression, hollow);
|
||||||
BBC.VISITOR_BLOCK.send(fp, affected);
|
player.findFreePosition();
|
||||||
} catch (ExpressionException e) {
|
BBC.VISITOR_BLOCK.send(fp, affected);
|
||||||
fp.sendMessage(BBC.getPrefix() + e.getMessage());
|
} catch (ExpressionException e) {
|
||||||
}
|
fp.sendMessage(BBC.getPrefix() + e.getMessage());
|
||||||
|
}
|
||||||
|
}, getArguments(context), region);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -427,7 +429,6 @@ public class GenerationCommands extends MethodCommands {
|
|||||||
@Switch('o') boolean offset,
|
@Switch('o') boolean offset,
|
||||||
@Switch('c') boolean offsetCenter,
|
@Switch('c') boolean offsetCenter,
|
||||||
CommandContext context) throws WorldEditException, ParameterException {
|
CommandContext context) throws WorldEditException, ParameterException {
|
||||||
fp.checkConfirmationRegion(getArguments(context), region);
|
|
||||||
final Vector zero;
|
final Vector zero;
|
||||||
Vector unit;
|
Vector unit;
|
||||||
|
|
||||||
@ -454,14 +455,15 @@ public class GenerationCommands extends MethodCommands {
|
|||||||
if (unit.getY() == 0) unit.mutY(1);
|
if (unit.getY() == 0) unit.mutY(1);
|
||||||
if (unit.getZ() == 0) unit.mutZ(1);
|
if (unit.getZ() == 0) unit.mutZ(1);
|
||||||
}
|
}
|
||||||
|
fp.checkConfirmationRegion(() -> {
|
||||||
try {
|
try {
|
||||||
final int affected = editSession.makeBiomeShape(region, zero, unit, target, expression, hollow);
|
final int affected = editSession.makeBiomeShape(region, zero, unit, target, expression, hollow);
|
||||||
player.findFreePosition();
|
player.findFreePosition();
|
||||||
BBC.VISITOR_FLAT.send(fp, affected);
|
BBC.VISITOR_FLAT.send(fp, affected);
|
||||||
} catch (ExpressionException e) {
|
} catch (ExpressionException e) {
|
||||||
fp.sendMessage(BBC.getPrefix() + e.getMessage());
|
fp.sendMessage(BBC.getPrefix() + e.getMessage());
|
||||||
}
|
}
|
||||||
|
}, getArguments(context), region);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Class<GenerationCommands> inject() {
|
public static Class<GenerationCommands> inject() {
|
||||||
|
@ -37,6 +37,7 @@ import com.sk89q.minecraft.util.commands.Logging;
|
|||||||
import com.sk89q.worldedit.*;
|
import com.sk89q.worldedit.*;
|
||||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||||
import com.sk89q.worldedit.entity.Player;
|
import com.sk89q.worldedit.entity.Player;
|
||||||
|
import com.sk89q.worldedit.extension.platform.Capability;
|
||||||
import com.sk89q.worldedit.function.GroundFunction;
|
import com.sk89q.worldedit.function.GroundFunction;
|
||||||
import com.sk89q.worldedit.function.generator.FloraGenerator;
|
import com.sk89q.worldedit.function.generator.FloraGenerator;
|
||||||
import com.sk89q.worldedit.function.generator.ForestGenerator;
|
import com.sk89q.worldedit.function.generator.ForestGenerator;
|
||||||
@ -277,15 +278,14 @@ public class RegionCommands extends MethodCommands {
|
|||||||
}
|
}
|
||||||
worldEdit.checkMaxRadius(thickness);
|
worldEdit.checkMaxRadius(thickness);
|
||||||
|
|
||||||
player.checkConfirmationRegion(getArguments(context), region);
|
player.checkConfirmationRegion(() -> {
|
||||||
player.checkConfirmationRadius(getArguments(context), thickness);
|
ConvexPolyhedralRegion cpregion = (ConvexPolyhedralRegion) region;
|
||||||
|
List<Vector> vectors = new ArrayList<Vector>(cpregion.getVertices());
|
||||||
|
|
||||||
ConvexPolyhedralRegion cpregion = (ConvexPolyhedralRegion) region;
|
int blocksChanged = editSession.drawSpline(pattern, vectors, 0, 0, 0, 10, thickness, !shell);
|
||||||
List<Vector> vectors = new ArrayList<Vector>(cpregion.getVertices());
|
|
||||||
|
|
||||||
int blocksChanged = editSession.drawSpline(pattern, vectors, 0, 0, 0, 10, thickness, !shell);
|
BBC.VISITOR_BLOCK.send(player, blocksChanged);
|
||||||
|
}, getArguments(context), region);
|
||||||
BBC.VISITOR_BLOCK.send(player, blocksChanged);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -299,14 +299,12 @@ public class RegionCommands extends MethodCommands {
|
|||||||
@CommandPermissions("worldedit.region.replace")
|
@CommandPermissions("worldedit.region.replace")
|
||||||
@Logging(REGION)
|
@Logging(REGION)
|
||||||
public void replace(FawePlayer player, EditSession editSession, @Selection Region region, @Optional Mask from, Pattern to, CommandContext context) throws WorldEditException {
|
public void replace(FawePlayer player, EditSession editSession, @Selection Region region, @Optional Mask from, Pattern to, CommandContext context) throws WorldEditException {
|
||||||
player.checkConfirmationRegion(getArguments(context), region);
|
player.checkConfirmationRegion(() -> {
|
||||||
if (from == null) {
|
int affected = editSession.replaceBlocks(region, from == null ? new ExistingBlockMask(editSession) : from, to);
|
||||||
from = new ExistingBlockMask(editSession);
|
BBC.VISITOR_BLOCK.send(player, affected);
|
||||||
}
|
if (!player.hasPermission("fawe.tips"))
|
||||||
int affected = editSession.replaceBlocks(region, from, to);
|
BBC.TIP_REPLACE_ID.or(BBC.TIP_REPLACE_LIGHT, BBC.TIP_REPLACE_MARKER, BBC.TIP_TAB_COMPLETE).send(player);
|
||||||
BBC.VISITOR_BLOCK.send(player, affected);
|
}, getArguments(context), region);
|
||||||
if (!player.hasPermission("fawe.tips"))
|
|
||||||
BBC.TIP_REPLACE_ID.or(BBC.TIP_REPLACE_LIGHT, BBC.TIP_REPLACE_MARKER, BBC.TIP_TAB_COMPLETE).send(player);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compatibility for SKCompat
|
// Compatibility for SKCompat
|
||||||
@ -325,14 +323,15 @@ public class RegionCommands extends MethodCommands {
|
|||||||
@CommandPermissions("worldedit.region.set")
|
@CommandPermissions("worldedit.region.set")
|
||||||
@Logging(REGION)
|
@Logging(REGION)
|
||||||
public void set(FawePlayer player, LocalSession session, EditSession editSession, @Selection Region selection, Pattern to, CommandContext context) throws WorldEditException {
|
public void set(FawePlayer player, LocalSession session, EditSession editSession, @Selection Region selection, Pattern to, CommandContext context) throws WorldEditException {
|
||||||
player.checkConfirmationRegion(getArguments(context), selection);
|
player.checkConfirmationRegion(() -> {
|
||||||
int affected;
|
int affected;
|
||||||
affected = editSession.setBlocks(selection, to);
|
affected = editSession.setBlocks(selection, to);
|
||||||
if (affected != 0) {
|
if (affected != 0) {
|
||||||
BBC.OPERATION.send(player, affected);
|
BBC.OPERATION.send(player, affected);
|
||||||
if (!player.hasPermission("fawe.tips"))
|
if (!player.hasPermission("fawe.tips"))
|
||||||
BBC.TIP_FAST.or(BBC.TIP_CANCEL, BBC.TIP_MASK, BBC.TIP_MASK_ANGLE, BBC.TIP_SET_LINEAR, BBC.TIP_SURFACE_SPREAD, BBC.TIP_SET_HAND).send(player);
|
BBC.TIP_FAST.or(BBC.TIP_CANCEL, BBC.TIP_MASK, BBC.TIP_MASK_ANGLE, BBC.TIP_SET_LINEAR, BBC.TIP_SURFACE_SPREAD, BBC.TIP_SET_HAND).send(player);
|
||||||
}
|
}
|
||||||
|
}, getArguments(context), selection);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -345,9 +344,10 @@ public class RegionCommands extends MethodCommands {
|
|||||||
@CommandPermissions("worldedit.region.overlay")
|
@CommandPermissions("worldedit.region.overlay")
|
||||||
@Logging(REGION)
|
@Logging(REGION)
|
||||||
public void overlay(FawePlayer player, EditSession editSession, @Selection Region region, Pattern pattern, CommandContext context) throws WorldEditException {
|
public void overlay(FawePlayer player, EditSession editSession, @Selection Region region, Pattern pattern, CommandContext context) throws WorldEditException {
|
||||||
player.checkConfirmationRegion(getArguments(context), region);
|
player.checkConfirmationRegion(() -> {
|
||||||
int affected = editSession.overlayCuboidBlocks(region, pattern);
|
int affected = editSession.overlayCuboidBlocks(region, pattern);
|
||||||
BBC.VISITOR_BLOCK.send(player, affected);
|
BBC.VISITOR_BLOCK.send(player, affected);
|
||||||
|
}, getArguments(context), region);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -360,28 +360,29 @@ public class RegionCommands extends MethodCommands {
|
|||||||
@CommandPermissions("worldedit.region.overlay")
|
@CommandPermissions("worldedit.region.overlay")
|
||||||
@Logging(REGION)
|
@Logging(REGION)
|
||||||
public void lay(FawePlayer player, EditSession editSession, @Selection Region region, Pattern pattern, CommandContext context) throws WorldEditException {
|
public void lay(FawePlayer player, EditSession editSession, @Selection Region region, Pattern pattern, CommandContext context) throws WorldEditException {
|
||||||
player.checkConfirmationRegion(getArguments(context), region);
|
player.checkConfirmationRegion(() -> {
|
||||||
Vector min = region.getMinimumPoint();
|
Vector min = region.getMinimumPoint();
|
||||||
Vector max = region.getMaximumPoint();
|
Vector max = region.getMaximumPoint();
|
||||||
int maxY = max.getBlockY();
|
int maxY = max.getBlockY();
|
||||||
int width = region.getWidth();
|
int width = region.getWidth();
|
||||||
int height = region.getLength();
|
int height = region.getLength();
|
||||||
int bx = min.getBlockX();
|
int bx = min.getBlockX();
|
||||||
int bz = min.getBlockZ();
|
int bz = min.getBlockZ();
|
||||||
Iterable<Vector2D> flat = Regions.asFlatRegion(region).asFlatRegion();
|
Iterable<Vector2D> flat = Regions.asFlatRegion(region).asFlatRegion();
|
||||||
Iterator<Vector2D> iter = new Fast2DIterator(flat, editSession).iterator();
|
Iterator<Vector2D> iter = new Fast2DIterator(flat, editSession).iterator();
|
||||||
int y = 0;
|
int y = 0;
|
||||||
int affected = 0;
|
int affected = 0;
|
||||||
MutableBlockVector mutable = new MutableBlockVector();
|
MutableBlockVector mutable = new MutableBlockVector();
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
Vector2D pos = iter.next();
|
Vector2D pos = iter.next();
|
||||||
int x = pos.getBlockX();
|
int x = pos.getBlockX();
|
||||||
int z = pos.getBlockZ();
|
int z = pos.getBlockZ();
|
||||||
y = editSession.getNearestSurfaceTerrainBlock(x, z, y, 0, maxY);
|
y = editSession.getNearestSurfaceTerrainBlock(x, z, y, 0, maxY);
|
||||||
editSession.setBlock(x, y, z, pattern);
|
editSession.setBlock(x, y, z, pattern);
|
||||||
affected++;
|
affected++;
|
||||||
}
|
}
|
||||||
BBC.VISITOR_BLOCK.send(player, affected);
|
BBC.VISITOR_BLOCK.send(player, affected);
|
||||||
|
}, getArguments(context), region);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -408,9 +409,10 @@ public class RegionCommands extends MethodCommands {
|
|||||||
@CommandPermissions("worldedit.region.naturalize")
|
@CommandPermissions("worldedit.region.naturalize")
|
||||||
@Logging(REGION)
|
@Logging(REGION)
|
||||||
public void naturalize(FawePlayer player, EditSession editSession, @Selection Region region, CommandContext context) throws WorldEditException {
|
public void naturalize(FawePlayer player, EditSession editSession, @Selection Region region, CommandContext context) throws WorldEditException {
|
||||||
player.checkConfirmationRegion(getArguments(context), region);
|
player.checkConfirmationRegion(() -> {
|
||||||
int affected = editSession.naturalizeCuboidBlocks(region);
|
int affected = editSession.naturalizeCuboidBlocks(region);
|
||||||
BBC.VISITOR_BLOCK.send(player, affected);
|
BBC.VISITOR_BLOCK.send(player, affected);
|
||||||
|
}, getArguments(context), region);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -423,9 +425,10 @@ public class RegionCommands extends MethodCommands {
|
|||||||
@CommandPermissions("worldedit.region.walls")
|
@CommandPermissions("worldedit.region.walls")
|
||||||
@Logging(REGION)
|
@Logging(REGION)
|
||||||
public void walls(FawePlayer player, EditSession editSession, @Selection Region region, Pattern pattern, CommandContext context) throws WorldEditException {
|
public void walls(FawePlayer player, EditSession editSession, @Selection Region region, Pattern pattern, CommandContext context) throws WorldEditException {
|
||||||
player.checkConfirmationRegion(getArguments(context), region);
|
player.checkConfirmationRegion(() -> {
|
||||||
int affected = editSession.makeCuboidWalls(region, pattern);
|
int affected = editSession.makeWalls(region, pattern);
|
||||||
BBC.VISITOR_BLOCK.send(player, affected);
|
BBC.VISITOR_BLOCK.send(player, affected);
|
||||||
|
}, getArguments(context), region);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -438,9 +441,10 @@ public class RegionCommands extends MethodCommands {
|
|||||||
@CommandPermissions("worldedit.region.faces")
|
@CommandPermissions("worldedit.region.faces")
|
||||||
@Logging(REGION)
|
@Logging(REGION)
|
||||||
public void faces(FawePlayer player, EditSession editSession, @Selection Region region, Pattern pattern, CommandContext context) throws WorldEditException {
|
public void faces(FawePlayer player, EditSession editSession, @Selection Region region, Pattern pattern, CommandContext context) throws WorldEditException {
|
||||||
player.checkConfirmationRegion(getArguments(context), region);
|
player.checkConfirmationRegion(() -> {
|
||||||
int affected = editSession.makeCuboidFaces(region, pattern);
|
int affected = editSession.makeCuboidFaces(region, pattern);
|
||||||
BBC.VISITOR_BLOCK.send(player, affected);
|
BBC.VISITOR_BLOCK.send(player, affected);
|
||||||
|
}, getArguments(context), region);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -458,22 +462,23 @@ public class RegionCommands extends MethodCommands {
|
|||||||
@CommandPermissions("worldedit.region.smoothsnow")
|
@CommandPermissions("worldedit.region.smoothsnow")
|
||||||
@Logging(REGION)
|
@Logging(REGION)
|
||||||
public void smooth(FawePlayer player, EditSession editSession, @Selection Region region, @Optional("1") int iterations, @Switch('n') boolean affectNatural, @Switch('s') boolean snow, CommandContext context) throws WorldEditException {
|
public void smooth(FawePlayer player, EditSession editSession, @Selection Region region, @Optional("1") int iterations, @Switch('n') boolean affectNatural, @Switch('s') boolean snow, CommandContext context) throws WorldEditException {
|
||||||
try {
|
Vector min = region.getMinimumPoint();
|
||||||
Vector min = region.getMinimumPoint();
|
Vector max = region.getMaximumPoint();
|
||||||
Vector 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();
|
||||||
FaweLimit limit = FawePlayer.wrap(player).getLimit();
|
if (volume >= limit.MAX_CHECKS) {
|
||||||
if (volume >= limit.MAX_CHECKS) {
|
throw new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_CHECKS);
|
||||||
throw new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_CHECKS);
|
|
||||||
}
|
|
||||||
player.checkConfirmationRegion(getArguments(context), region);
|
|
||||||
HeightMap heightMap = new HeightMap(editSession, region, affectNatural, snow);
|
|
||||||
HeightMapFilter filter = (HeightMapFilter) HeightMapFilter.class.getConstructors()[0].newInstance(GaussianKernel.class.getConstructors()[0].newInstance(5, 1));
|
|
||||||
int affected = heightMap.applyFilter(filter, iterations);
|
|
||||||
BBC.VISITOR_BLOCK.send(player, affected);
|
|
||||||
} catch (Throwable e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
}
|
||||||
|
player.checkConfirmationRegion(() -> {
|
||||||
|
try {
|
||||||
|
HeightMap heightMap = new HeightMap(editSession, region, affectNatural, snow);
|
||||||
|
HeightMapFilter filter = (HeightMapFilter) HeightMapFilter.class.getConstructors()[0].newInstance(GaussianKernel.class.getConstructors()[0].newInstance(5, 1));
|
||||||
|
int affected = heightMap.applyFilter(filter, iterations);
|
||||||
|
BBC.VISITOR_BLOCK.send(player, affected);
|
||||||
|
} catch (Throwable e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}, getArguments(context), region);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -536,22 +541,22 @@ public class RegionCommands extends MethodCommands {
|
|||||||
@Switch('a') boolean skipAir,
|
@Switch('a') boolean skipAir,
|
||||||
@Switch('s') boolean moveSelection,
|
@Switch('s') boolean moveSelection,
|
||||||
CommandContext context) throws WorldEditException {
|
CommandContext context) throws WorldEditException {
|
||||||
player.checkConfirmationRegion(getArguments(context), region);
|
player.checkConfirmationRegion(() -> {
|
||||||
|
int affected = editSession.moveRegion(region, direction, count, !skipAir, !skipEntities, copyBiomes, replace);
|
||||||
|
|
||||||
int affected = editSession.moveRegion(region, direction, count, !skipAir, !skipEntities, copyBiomes, replace);
|
if (moveSelection) {
|
||||||
|
try {
|
||||||
|
region.shift(direction.multiply(count));
|
||||||
|
|
||||||
if (moveSelection) {
|
session.getRegionSelector(player.getWorld()).learnChanges();
|
||||||
try {
|
session.getRegionSelector(player.getWorld()).explainRegionAdjust(player.getPlayer(), session);
|
||||||
region.shift(direction.multiply(count));
|
} catch (RegionOperationException e) {
|
||||||
|
player.sendMessage(BBC.getPrefix() + e.getMessage());
|
||||||
session.getRegionSelector(player.getWorld()).learnChanges();
|
}
|
||||||
session.getRegionSelector(player.getWorld()).explainRegionAdjust(player.getPlayer(), session);
|
|
||||||
} catch (RegionOperationException e) {
|
|
||||||
player.sendMessage(BBC.getPrefix() + e.getMessage());
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
BBC.VISITOR_BLOCK.send(player, affected);
|
BBC.VISITOR_BLOCK.send(player, affected);
|
||||||
|
}, getArguments(context), region);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -572,9 +577,10 @@ public class RegionCommands extends MethodCommands {
|
|||||||
@Optional("air") BaseBlock replace,
|
@Optional("air") BaseBlock replace,
|
||||||
@Switch('m') boolean notFullHeight,
|
@Switch('m') boolean notFullHeight,
|
||||||
CommandContext context) throws WorldEditException {
|
CommandContext context) throws WorldEditException {
|
||||||
player.checkConfirmationRegion(getArguments(context), region);
|
player.checkConfirmationRegion(() -> {
|
||||||
int affected = editSession.fall(region, !notFullHeight, replace);
|
int affected = editSession.fall(region, !notFullHeight, replace);
|
||||||
BBC.VISITOR_BLOCK.send(player, affected);
|
BBC.VISITOR_BLOCK.send(player, affected);
|
||||||
|
}, getArguments(context), region);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -600,26 +606,27 @@ public class RegionCommands extends MethodCommands {
|
|||||||
@Switch('b') boolean copyBiomes,
|
@Switch('b') boolean copyBiomes,
|
||||||
@Switch('e') boolean skipEntities,
|
@Switch('e') boolean skipEntities,
|
||||||
@Switch('a') boolean ignoreAirBlocks, @Switch('m') Mask sourceMask, CommandContext context) throws WorldEditException {
|
@Switch('a') boolean ignoreAirBlocks, @Switch('m') Mask sourceMask, CommandContext context) throws WorldEditException {
|
||||||
player.checkConfirmationStack(getArguments(context), region, count);
|
player.checkConfirmationStack(() -> {
|
||||||
if (sourceMask != null) {
|
if (sourceMask != null) {
|
||||||
editSession.addSourceMask(sourceMask);
|
editSession.addSourceMask(sourceMask);
|
||||||
}
|
|
||||||
int affected = editSession.stackCuboidRegion(region, direction, count, !ignoreAirBlocks, !skipEntities, copyBiomes);
|
|
||||||
|
|
||||||
if (moveSelection) {
|
|
||||||
try {
|
|
||||||
final Vector size = region.getMaximumPoint().subtract(region.getMinimumPoint()).add(1, 1, 1);
|
|
||||||
Vector shiftVector = new Vector(direction.getX() * size.getX() * count, direction.getY() * size.getY() * count, direction.getZ() * size.getZ() * count);
|
|
||||||
region.shift(shiftVector);
|
|
||||||
|
|
||||||
session.getRegionSelector(player.getWorld()).learnChanges();
|
|
||||||
session.getRegionSelector(player.getWorld()).explainRegionAdjust(player.getPlayer(), session);
|
|
||||||
} catch (RegionOperationException e) {
|
|
||||||
player.sendMessage(BBC.getPrefix() + e.getMessage());
|
|
||||||
}
|
}
|
||||||
}
|
int affected = editSession.stackCuboidRegion(region, direction, count, !ignoreAirBlocks, !skipEntities, copyBiomes);
|
||||||
|
|
||||||
BBC.VISITOR_BLOCK.send(player, affected);
|
if (moveSelection) {
|
||||||
|
try {
|
||||||
|
final Vector size = region.getMaximumPoint().subtract(region.getMinimumPoint()).add(1, 1, 1);
|
||||||
|
Vector shiftVector = new Vector(direction.getX() * size.getX() * count, direction.getY() * size.getY() * count, direction.getZ() * size.getZ() * count);
|
||||||
|
region.shift(shiftVector);
|
||||||
|
|
||||||
|
session.getRegionSelector(player.getWorld()).learnChanges();
|
||||||
|
session.getRegionSelector(player.getWorld()).explainRegionAdjust(player.getPlayer(), session);
|
||||||
|
} catch (RegionOperationException e) {
|
||||||
|
player.sendMessage(BBC.getPrefix() + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BBC.VISITOR_BLOCK.send(player, affected);
|
||||||
|
}, getArguments(context), region, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -643,7 +650,6 @@ public class RegionCommands extends MethodCommands {
|
|||||||
@Switch('r') boolean useRawCoords,
|
@Switch('r') boolean useRawCoords,
|
||||||
@Switch('o') boolean offset,
|
@Switch('o') boolean offset,
|
||||||
CommandContext context) throws WorldEditException {
|
CommandContext context) throws WorldEditException {
|
||||||
fp.checkConfirmationRegion(getArguments(context), region);
|
|
||||||
final Vector zero;
|
final Vector zero;
|
||||||
Vector unit;
|
Vector unit;
|
||||||
|
|
||||||
@ -664,14 +670,15 @@ public class RegionCommands extends MethodCommands {
|
|||||||
if (unit.getY() == 0) unit.mutY(1);
|
if (unit.getY() == 0) unit.mutY(1);
|
||||||
if (unit.getZ() == 0) unit.mutZ(1);
|
if (unit.getZ() == 0) unit.mutZ(1);
|
||||||
}
|
}
|
||||||
|
fp.checkConfirmationRegion(() -> {
|
||||||
try {
|
try {
|
||||||
final int affected = editSession.deformRegion(region, zero, unit, expression);
|
final int affected = editSession.deformRegion(region, zero, unit, expression);
|
||||||
player.findFreePosition();
|
player.findFreePosition();
|
||||||
BBC.VISITOR_BLOCK.send(fp, affected);
|
BBC.VISITOR_BLOCK.send(fp, affected);
|
||||||
} catch (ExpressionException e) {
|
} catch (ExpressionException e) {
|
||||||
fp.sendMessage(BBC.getPrefix() + e.getMessage());
|
fp.sendMessage(BBC.getPrefix() + e.getMessage());
|
||||||
}
|
}
|
||||||
|
}, getArguments(context), region);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -688,33 +695,33 @@ public class RegionCommands extends MethodCommands {
|
|||||||
@CommandPermissions("worldedit.regen")
|
@CommandPermissions("worldedit.regen")
|
||||||
@Logging(REGION)
|
@Logging(REGION)
|
||||||
public void regenerateChunk(FawePlayer player, LocalSession session, EditSession editSession, @Selection Region region, CommandContext args) throws WorldEditException {
|
public void regenerateChunk(FawePlayer player, LocalSession session, EditSession editSession, @Selection Region region, CommandContext args) throws WorldEditException {
|
||||||
player.checkConfirmationRegion(getArguments(args), region);
|
player.checkConfirmationRegion(() -> {
|
||||||
|
Mask mask = session.getMask();
|
||||||
Mask mask = session.getMask();
|
Mask sourceMask = session.getSourceMask();
|
||||||
Mask sourceMask = session.getSourceMask();
|
session.setMask((Mask) null);
|
||||||
session.setMask((Mask) null);
|
session.setSourceMask((Mask) null);
|
||||||
session.setSourceMask((Mask) null);
|
BaseBiome biome = null;
|
||||||
BaseBiome biome = null;
|
if (args.argsLength() >= 1) {
|
||||||
if (args.argsLength() >= 1) {
|
BiomeRegistry biomeRegistry = player.getWorld().getWorldData().getBiomeRegistry();
|
||||||
BiomeRegistry biomeRegistry = player.getWorld().getWorldData().getBiomeRegistry();
|
List<BaseBiome> knownBiomes = biomeRegistry.getBiomes();
|
||||||
List<BaseBiome> knownBiomes = biomeRegistry.getBiomes();
|
biome = Biomes.findBiomeByName(knownBiomes, args.getString(0), biomeRegistry);
|
||||||
biome = Biomes.findBiomeByName(knownBiomes, args.getString(0), biomeRegistry);
|
}
|
||||||
}
|
Long seed = args.argsLength() != 2 || !MathMan.isInteger(args.getString(1)) ? null : Long.parseLong(args.getString(1));
|
||||||
Long seed = args.argsLength() != 2 || !MathMan.isInteger(args.getString(1)) ? null : Long.parseLong(args.getString(1));
|
editSession.regenerate(region, biome, seed);
|
||||||
editSession.regenerate(region, biome, seed);
|
session.setMask(mask);
|
||||||
session.setMask(mask);
|
session.setSourceMask(mask);
|
||||||
session.setSourceMask(mask);
|
if (!player.hasPermission("fawe.tips")) {
|
||||||
if (!player.hasPermission("fawe.tips")) {
|
BBC.COMMAND_REGEN_2.send(player);
|
||||||
BBC.COMMAND_REGEN_2.send(player);
|
} else if (biome == null) {
|
||||||
} else if (biome == null) {
|
BBC.COMMAND_REGEN_0.send(player);
|
||||||
BBC.COMMAND_REGEN_0.send(player);
|
if (!FawePlayer.wrap(player).hasPermission("fawe.tips")) BBC.TIP_REGEN_0.send(player);
|
||||||
if (!FawePlayer.wrap(player).hasPermission("fawe.tips")) BBC.TIP_REGEN_0.send(player);
|
} else if (seed == null) {
|
||||||
} else if (seed == null) {
|
BBC.COMMAND_REGEN_1.send(player);
|
||||||
BBC.COMMAND_REGEN_1.send(player);
|
if (!FawePlayer.wrap(player).hasPermission("fawe.tips")) BBC.TIP_REGEN_1.send(player);
|
||||||
if (!FawePlayer.wrap(player).hasPermission("fawe.tips")) BBC.TIP_REGEN_1.send(player);
|
} else {
|
||||||
} else {
|
BBC.COMMAND_REGEN_2.send(player);
|
||||||
BBC.COMMAND_REGEN_2.send(player);
|
}
|
||||||
}
|
}, getArguments(args), region);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -735,9 +742,10 @@ public class RegionCommands extends MethodCommands {
|
|||||||
@Optional("0") @Range(min = 0) int thickness,
|
@Optional("0") @Range(min = 0) int thickness,
|
||||||
@Optional("air") Pattern pattern,
|
@Optional("air") Pattern pattern,
|
||||||
CommandContext context) throws WorldEditException {
|
CommandContext context) throws WorldEditException {
|
||||||
player.checkConfirmationRegion(getArguments(context), region);
|
player.checkConfirmationRegion(() -> {
|
||||||
int affected = editSession.hollowOutRegion(region, thickness, pattern);
|
int affected = editSession.hollowOutRegion(region, thickness, pattern);
|
||||||
BBC.VISITOR_BLOCK.send(player, affected);
|
BBC.VISITOR_BLOCK.send(player, affected);
|
||||||
|
}, getArguments(context), region);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -752,16 +760,15 @@ public class RegionCommands extends MethodCommands {
|
|||||||
public void forest(FawePlayer player, EditSession editSession, @Selection Region region, @Optional("tree") TreeType type,
|
public void forest(FawePlayer player, EditSession editSession, @Selection Region region, @Optional("tree") TreeType type,
|
||||||
@Optional("5") @Range(min = 0, max = 100) double density,
|
@Optional("5") @Range(min = 0, max = 100) double density,
|
||||||
CommandContext context) throws WorldEditException {
|
CommandContext context) throws WorldEditException {
|
||||||
player.checkConfirmationRegion(getArguments(context), region);
|
player.checkConfirmationRegion(() -> {
|
||||||
|
ForestGenerator generator = new ForestGenerator(editSession, new TreeGenerator(type));
|
||||||
|
GroundFunction ground = new GroundFunction(new ExistingBlockMask(editSession), generator);
|
||||||
|
LayerVisitor visitor = new LayerVisitor(asFlatRegion(region), minimumBlockY(region), maximumBlockY(region), ground);
|
||||||
|
visitor.setMask(new NoiseFilter2D(new RandomNoise(), density / 100));
|
||||||
|
Operations.completeLegacy(visitor);
|
||||||
|
|
||||||
density = density / 100;
|
BBC.COMMAND_TREE.send(player, ground.getAffected());
|
||||||
ForestGenerator generator = new ForestGenerator(editSession, new TreeGenerator(type));
|
}, getArguments(context), region);
|
||||||
GroundFunction ground = new GroundFunction(new ExistingBlockMask(editSession), generator);
|
|
||||||
LayerVisitor visitor = new LayerVisitor(asFlatRegion(region), minimumBlockY(region), maximumBlockY(region), ground);
|
|
||||||
visitor.setMask(new NoiseFilter2D(new RandomNoise(), density));
|
|
||||||
Operations.completeLegacy(visitor);
|
|
||||||
|
|
||||||
BBC.COMMAND_TREE.send(player, ground.getAffected());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -774,15 +781,15 @@ public class RegionCommands extends MethodCommands {
|
|||||||
@CommandPermissions("worldedit.region.flora")
|
@CommandPermissions("worldedit.region.flora")
|
||||||
@Logging(REGION)
|
@Logging(REGION)
|
||||||
public void flora(FawePlayer player, EditSession editSession, @Selection Region region, @Optional("10") @Range(min = 0, max = 100) double density, CommandContext context) throws WorldEditException {
|
public void flora(FawePlayer player, EditSession editSession, @Selection Region region, @Optional("10") @Range(min = 0, max = 100) double density, CommandContext context) throws WorldEditException {
|
||||||
player.checkConfirmationRegion(getArguments(context), region);
|
player.checkConfirmationRegion(() -> {
|
||||||
density = density / 100;
|
FloraGenerator generator = new FloraGenerator(editSession);
|
||||||
FloraGenerator generator = new FloraGenerator(editSession);
|
GroundFunction ground = new GroundFunction(new ExistingBlockMask(editSession), generator);
|
||||||
GroundFunction ground = new GroundFunction(new ExistingBlockMask(editSession), generator);
|
LayerVisitor visitor = new LayerVisitor(asFlatRegion(region), minimumBlockY(region), maximumBlockY(region), ground);
|
||||||
LayerVisitor visitor = new LayerVisitor(asFlatRegion(region), minimumBlockY(region), maximumBlockY(region), ground);
|
visitor.setMask(new NoiseFilter2D(new RandomNoise(), density / 100));
|
||||||
visitor.setMask(new NoiseFilter2D(new RandomNoise(), density));
|
Operations.completeLegacy(visitor);
|
||||||
Operations.completeLegacy(visitor);
|
|
||||||
|
|
||||||
BBC.COMMAND_FLORA.send(player, ground.getAffected());
|
BBC.COMMAND_FLORA.send(player, ground.getAffected());
|
||||||
|
}, getArguments(context), region);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Class<?> inject() {
|
public static Class<?> inject() {
|
||||||
|
@ -28,7 +28,9 @@
|
|||||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.thoughtworks.paranamer;
|
package com.sk89q.worldedit.util.command.parametric;
|
||||||
|
|
||||||
|
import com.thoughtworks.paranamer.CachingParanamer;
|
||||||
|
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
@ -45,7 +45,6 @@ import com.sk89q.worldedit.util.command.ProcessedCallable;
|
|||||||
import com.sk89q.worldedit.util.command.binding.PrimitiveBindings;
|
import com.sk89q.worldedit.util.command.binding.PrimitiveBindings;
|
||||||
import com.sk89q.worldedit.util.command.binding.StandardBindings;
|
import com.sk89q.worldedit.util.command.binding.StandardBindings;
|
||||||
import com.sk89q.worldedit.util.command.binding.Switch;
|
import com.sk89q.worldedit.util.command.binding.Switch;
|
||||||
import com.thoughtworks.paranamer.FaweParanamer;
|
|
||||||
import com.thoughtworks.paranamer.Paranamer;
|
import com.thoughtworks.paranamer.Paranamer;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
|
Loading…
Reference in New Issue
Block a user