mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-11-18 01:46:11 +00:00
This commit is contained in:
parent
d99765f13f
commit
6ae0d3f64e
@ -28,6 +28,8 @@ import com.sk89q.worldedit.regions.selector.CuboidRegionSelector;
|
|||||||
import com.sk89q.worldedit.regions.selector.CylinderRegionSelector;
|
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 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;
|
||||||
@ -36,6 +38,7 @@ import java.text.NumberFormat;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
public abstract class FawePlayer<T> extends Metadatable {
|
public abstract class FawePlayer<T> extends Metadatable {
|
||||||
|
|
||||||
@ -156,61 +159,65 @@ 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 Runnable task, String command) {
|
||||||
if (command == null || getMeta("cmdConfirmRunning", false)) {
|
setMeta("cmdConfirm", task == null ? new CommandEvent(getPlayer(), command) : task);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void checkConfirmation(@Nullable Runnable task, String command, int times, int limit) throws RegionOperationException {
|
||||||
|
if (command != null && !getMeta("cmdConfirmRunning", false)) {
|
||||||
if (times > limit) {
|
if (times > limit) {
|
||||||
setMeta("cmdConfirm", command);
|
setConfirmTask(task, command);
|
||||||
String volume = "<unspecified>";
|
String volume = "<unspecified>";
|
||||||
throw new RegionOperationException(BBC.WORLDEDIT_CANCEL_REASON_CONFIRM.f(0, times, command, volume));
|
throw new RegionOperationException(BBC.WORLDEDIT_CANCEL_REASON_CONFIRM.f(0, times, command, volume));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (task != null) task.run();
|
||||||
public void checkConfirmationRadius(String command, int radius) throws RegionOperationException {
|
|
||||||
if (command == null || getMeta("cmdConfirmRunning", false)) {
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void checkConfirmationRadius(@Nullable Runnable task, String command, int radius) throws RegionOperationException {
|
||||||
|
if (command != null && !getMeta("cmdConfirmRunning", false)) {
|
||||||
if (radius > 0) {
|
if (radius > 0) {
|
||||||
if (radius > 448) {
|
if (radius > 448) {
|
||||||
setMeta("cmdConfirm", command);
|
setConfirmTask(task, command);
|
||||||
long volume = (long) (Math.PI * ((double) radius * radius));
|
long volume = (long) (Math.PI * ((double) radius * radius));
|
||||||
throw new RegionOperationException(BBC.WORLDEDIT_CANCEL_REASON_CONFIRM.f(0, radius, command, NumberFormat.getNumberInstance().format(volume)));
|
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 {
|
|
||||||
if (command == null || getMeta("cmdConfirmRunning", false)) {
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void checkConfirmationStack(@Nullable Runnable task, String command, Region region, int times) throws RegionOperationException {
|
||||||
|
if (command != null && !getMeta("cmdConfirmRunning", false)) {
|
||||||
if (region != null) {
|
if (region != null) {
|
||||||
Vector min = region.getMinimumPoint().toBlockVector();
|
Vector min = region.getMinimumPoint().toBlockVector();
|
||||||
Vector max = region.getMaximumPoint().toBlockVector();
|
Vector max = region.getMaximumPoint().toBlockVector();
|
||||||
long area = (long) ((max.getX() - min.getX()) * (max.getZ() - min.getZ() + 1)) * times;
|
long area = (long) ((max.getX() - min.getX()) * (max.getZ() - min.getZ() + 1)) * times;
|
||||||
if (area > 2 << 18) {
|
if (area > 2 << 18) {
|
||||||
setMeta("cmdConfirm", command);
|
setConfirmTask(task, command);
|
||||||
long volume = (long) max.subtract(min).add(Vector.ONE).volume() * times;
|
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)));
|
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 {
|
|
||||||
if (command == null || getMeta("cmdConfirmRunning", false)) {
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void checkConfirmationRegion(@Nullable Runnable task, String command, Region region) throws RegionOperationException {
|
||||||
|
if (command != null && !getMeta("cmdConfirmRunning", false)) {
|
||||||
if (region != null) {
|
if (region != null) {
|
||||||
Vector min = region.getMinimumPoint().toBlockVector();
|
Vector min = region.getMinimumPoint().toBlockVector();
|
||||||
Vector max = region.getMaximumPoint().toBlockVector();
|
Vector max = region.getMaximumPoint().toBlockVector();
|
||||||
long area = (long) ((max.getX() - min.getX()) * (max.getZ() - min.getZ() + 1));
|
long area = (long) ((max.getX() - min.getX()) * (max.getZ() - min.getZ() + 1));
|
||||||
if (area > 2 << 18) {
|
if (area > 2 << 18) {
|
||||||
setMeta("cmdConfirm", command);
|
setConfirmTask(task, command);
|
||||||
long volume = (long) max.subtract(min).add(Vector.ONE).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)));
|
throw new RegionOperationException(BBC.WORLDEDIT_CANCEL_REASON_CONFIRM.f(min, max, command, NumberFormat.getNumberInstance().format(volume)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (task != null) task.run();
|
||||||
|
}
|
||||||
|
|
||||||
public void checkAllowedRegion(Region wrappedSelection) {
|
public void checkAllowedRegion(Region wrappedSelection) {
|
||||||
Region[] allowed = WEManager.IMP.getMask(this, FaweMaskManager.MaskType.OWNER);
|
Region[] allowed = WEManager.IMP.getMask(this, FaweMaskManager.MaskType.OWNER);
|
||||||
@ -222,16 +229,25 @@ public abstract class FawePlayer<T> extends Metadatable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean confirm() {
|
public synchronized boolean confirm() {
|
||||||
String confirm = deleteMeta("cmdConfirm");
|
Object confirm = deleteMeta("cmdConfirm");
|
||||||
if (confirm == null) {
|
if (confirm == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
queueAction(() -> {
|
queueAction(() -> {
|
||||||
setMeta("cmdConfirmRunning", true);
|
setMeta("cmdConfirmRunning", true);
|
||||||
CommandEvent event = new CommandEvent(getPlayer(), confirm);
|
try {
|
||||||
|
if (confirm instanceof String) {
|
||||||
|
CommandEvent event = new CommandEvent(getPlayer(), (String) confirm);
|
||||||
CommandManager.getInstance().handleCommandOnCurrentThread(event);
|
CommandManager.getInstance().handleCommandOnCurrentThread(event);
|
||||||
|
} else if (confirm instanceof Runnable) {
|
||||||
|
((Runnable) confirm).run();
|
||||||
|
} else {
|
||||||
|
throw new RuntimeException("Invalid confirm action: " + confirm);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
setMeta("cmdConfirmRunning", false);
|
setMeta("cmdConfirmRunning", false);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -151,7 +151,7 @@ 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);
|
fp.checkConfirmationRegion(() -> {
|
||||||
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));
|
||||||
@ -178,9 +178,11 @@ public class ClipboardCommands extends MethodCommands {
|
|||||||
}
|
}
|
||||||
Operations.completeLegacy(copy);
|
Operations.completeLegacy(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(
|
||||||
aliases = {"/lazycut"},
|
aliases = {"/lazycut"},
|
||||||
@ -239,7 +241,7 @@ 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);
|
fp.checkConfirmationRegion(() -> {
|
||||||
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));
|
||||||
@ -271,6 +273,8 @@ public class ClipboardCommands extends MethodCommands {
|
|||||||
|
|
||||||
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")
|
||||||
|
@ -88,10 +88,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 {
|
||||||
@ -106,9 +107,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(
|
||||||
@ -169,9 +171,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(
|
||||||
@ -191,11 +194,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(() -> {
|
||||||
|
int affected = editSession.makeHollowCylinder(pos, pattern, radius.getX(), radius.getZ(), Math.min(256, height), thickness - 1);
|
||||||
BBC.VISITOR_BLOCK.send(fp, affected);
|
BBC.VISITOR_BLOCK.send(fp, affected);
|
||||||
|
}, getArguments(context), (int) max);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -216,11 +219,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(() -> {
|
||||||
|
int affected = editSession.makeCylinder(pos, pattern, radius.getX(), radius.getZ(), Math.min(256, height), !hollow);
|
||||||
BBC.VISITOR_BLOCK.send(fp, affected);
|
BBC.VISITOR_BLOCK.send(fp, affected);
|
||||||
|
}, getArguments(context), (int) max);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -259,16 +262,15 @@ 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);
|
||||||
|
|
||||||
int affected = editSession.makeSphere(pos, pattern, radius.getX(), radius.getY(), radius.getZ(), !hollow);
|
|
||||||
player.findFreePosition();
|
player.findFreePosition();
|
||||||
BBC.VISITOR_BLOCK.send(fp, affected);
|
BBC.VISITOR_BLOCK.send(fp, affected);
|
||||||
|
}, getArguments(context), (int) max);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -325,12 +327,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);
|
||||||
|
Vector pos = session.getPlacementPosition(player);
|
||||||
|
fp.checkConfirmationRadius(() -> {
|
||||||
int affected = editSession.makePyramid(pos, pattern, size, !hollow);
|
int affected = editSession.makePyramid(pos, pattern, size, !hollow);
|
||||||
player.findFreePosition();
|
player.findFreePosition();
|
||||||
BBC.VISITOR_BLOCK.send(fp, affected);
|
BBC.VISITOR_BLOCK.send(fp, affected);
|
||||||
|
}, getArguments(context), size);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -363,7 +366,7 @@ 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);
|
fp.checkConfirmationRegion(() -> {
|
||||||
final Vector zero;
|
final Vector zero;
|
||||||
Vector unit;
|
Vector unit;
|
||||||
|
|
||||||
@ -398,6 +401,7 @@ public class GenerationCommands extends MethodCommands {
|
|||||||
} catch (ExpressionException e) {
|
} catch (ExpressionException e) {
|
||||||
fp.sendMessage(BBC.getPrefix() + e.getMessage());
|
fp.sendMessage(BBC.getPrefix() + e.getMessage());
|
||||||
}
|
}
|
||||||
|
}, getArguments(context), region);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -430,7 +434,7 @@ 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);
|
fp.checkConfirmationRegion(() -> {
|
||||||
final Vector zero;
|
final Vector zero;
|
||||||
Vector unit;
|
Vector unit;
|
||||||
|
|
||||||
@ -465,5 +469,6 @@ public class GenerationCommands extends MethodCommands {
|
|||||||
} catch (ExpressionException e) {
|
} catch (ExpressionException e) {
|
||||||
fp.sendMessage(BBC.getPrefix() + e.getMessage());
|
fp.sendMessage(BBC.getPrefix() + e.getMessage());
|
||||||
}
|
}
|
||||||
|
}, getArguments(context), region);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -225,9 +225,7 @@ public class HistoryCommands extends MethodCommands {
|
|||||||
@CommandPermissions("worldedit.history.undo")
|
@CommandPermissions("worldedit.history.undo")
|
||||||
public void undo(Player player, LocalSession session, CommandContext context) throws WorldEditException {
|
public void undo(Player player, LocalSession session, CommandContext context) throws WorldEditException {
|
||||||
int times = Math.max(1, context.getInteger(0, 1));
|
int times = Math.max(1, context.getInteger(0, 1));
|
||||||
if (times > 50) {
|
FawePlayer.wrap(player).checkConfirmation(() -> {
|
||||||
FawePlayer.wrap(player).checkConfirmation(getArguments(context), times, 50);
|
|
||||||
}
|
|
||||||
for (int i = 0; i < times; ++i) {
|
for (int i = 0; i < times; ++i) {
|
||||||
EditSession undone;
|
EditSession undone;
|
||||||
if (context.argsLength() < 2) {
|
if (context.argsLength() < 2) {
|
||||||
@ -249,6 +247,7 @@ public class HistoryCommands extends MethodCommands {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}, getArguments(context), times, 50);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
|
@ -281,15 +281,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;
|
ConvexPolyhedralRegion cpregion = (ConvexPolyhedralRegion) region;
|
||||||
List<Vector> vectors = new ArrayList<Vector>(cpregion.getVertices());
|
List<Vector> vectors = new ArrayList<Vector>(cpregion.getVertices());
|
||||||
|
|
||||||
int blocksChanged = editSession.drawSpline(pattern, vectors, 0, 0, 0, 10, thickness, !shell);
|
int blocksChanged = editSession.drawSpline(pattern, vectors, 0, 0, 0, 10, thickness, !shell);
|
||||||
|
|
||||||
BBC.VISITOR_BLOCK.send(player, blocksChanged);
|
BBC.VISITOR_BLOCK.send(player, blocksChanged);
|
||||||
|
}, getArguments(context), region);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -303,14 +302,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);
|
|
||||||
}
|
|
||||||
int affected = editSession.replaceBlocks(region, from, to);
|
|
||||||
BBC.VISITOR_BLOCK.send(player, affected);
|
BBC.VISITOR_BLOCK.send(player, affected);
|
||||||
if (!player.hasPermission("fawe.tips"))
|
if (!player.hasPermission("fawe.tips"))
|
||||||
BBC.TIP_REPLACE_ID.or(BBC.TIP_REPLACE_LIGHT, BBC.TIP_REPLACE_MARKER, BBC.TIP_TAB_COMPLETE, BBC.TIP_REPLACE_REGEX, BBC.TIP_REPLACE_REGEX_2, BBC.TIP_REPLACE_REGEX_3, BBC.TIP_REPLACE_REGEX_4, BBC.TIP_REPLACE_REGEX_5).send(player);
|
BBC.TIP_REPLACE_ID.or(BBC.TIP_REPLACE_LIGHT, BBC.TIP_REPLACE_MARKER, BBC.TIP_TAB_COMPLETE, BBC.TIP_REPLACE_REGEX, BBC.TIP_REPLACE_REGEX_2, BBC.TIP_REPLACE_REGEX_3, BBC.TIP_REPLACE_REGEX_4, BBC.TIP_REPLACE_REGEX_5).send(player);
|
||||||
|
}, getArguments(context), region);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compatibility for SKCompat
|
// Compatibility for SKCompat
|
||||||
@ -329,7 +326,7 @@ 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) {
|
||||||
@ -337,6 +334,7 @@ public class RegionCommands extends MethodCommands {
|
|||||||
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(
|
||||||
@ -349,9 +347,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(
|
||||||
@ -364,7 +363,7 @@ 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();
|
||||||
@ -386,6 +385,7 @@ public class RegionCommands extends MethodCommands {
|
|||||||
affected++;
|
affected++;
|
||||||
}
|
}
|
||||||
BBC.VISITOR_BLOCK.send(player, affected);
|
BBC.VISITOR_BLOCK.send(player, affected);
|
||||||
|
}, getArguments(context), region);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -412,9 +412,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(
|
||||||
@ -427,9 +428,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.makeWalls(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(
|
||||||
@ -442,9 +444,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(
|
||||||
@ -470,11 +473,12 @@ public class RegionCommands extends MethodCommands {
|
|||||||
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);
|
player.checkConfirmationRegion(() -> {
|
||||||
HeightMap heightMap = new HeightMap(editSession, region, affectNatural, snow);
|
HeightMap heightMap = new HeightMap(editSession, region, affectNatural, snow);
|
||||||
HeightMapFilter filter = (HeightMapFilter) HeightMapFilter.class.getConstructors()[0].newInstance(GaussianKernel.class.getConstructors()[0].newInstance(5, 1));
|
HeightMapFilter filter = (HeightMapFilter) HeightMapFilter.class.getConstructors()[0].newInstance(GaussianKernel.class.getConstructors()[0].newInstance(5, 1));
|
||||||
int affected = heightMap.applyFilter(filter, iterations);
|
int affected = heightMap.applyFilter(filter, iterations);
|
||||||
BBC.VISITOR_BLOCK.send(player, affected);
|
BBC.VISITOR_BLOCK.send(player, affected);
|
||||||
|
}, getArguments(context), region);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
@ -540,8 +544,7 @@ 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) {
|
if (moveSelection) {
|
||||||
@ -556,6 +559,7 @@ public class RegionCommands extends MethodCommands {
|
|||||||
}
|
}
|
||||||
|
|
||||||
BBC.VISITOR_BLOCK.send(player, affected);
|
BBC.VISITOR_BLOCK.send(player, affected);
|
||||||
|
}, getArguments(context), region);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -576,9 +580,10 @@ public class RegionCommands extends MethodCommands {
|
|||||||
@Optional("air") BlockStateHolder replace,
|
@Optional("air") BlockStateHolder 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(
|
||||||
@ -604,7 +609,7 @@ 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);
|
||||||
}
|
}
|
||||||
@ -624,6 +629,7 @@ public class RegionCommands extends MethodCommands {
|
|||||||
}
|
}
|
||||||
|
|
||||||
BBC.VISITOR_BLOCK.send(player, affected);
|
BBC.VISITOR_BLOCK.send(player, affected);
|
||||||
|
}, getArguments(context), region, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -647,7 +653,7 @@ 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);
|
fp.checkConfirmationRegion(() -> {
|
||||||
final Vector zero;
|
final Vector zero;
|
||||||
Vector unit;
|
Vector unit;
|
||||||
|
|
||||||
@ -676,6 +682,7 @@ public class RegionCommands extends MethodCommands {
|
|||||||
} catch (ExpressionException e) {
|
} catch (ExpressionException e) {
|
||||||
fp.sendMessage(BBC.getPrefix() + e.getMessage());
|
fp.sendMessage(BBC.getPrefix() + e.getMessage());
|
||||||
}
|
}
|
||||||
|
}, getArguments(context), region);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -692,8 +699,7 @@ 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);
|
||||||
@ -719,6 +725,9 @@ public class RegionCommands extends MethodCommands {
|
|||||||
} else {
|
} else {
|
||||||
BBC.COMMAND_REGEN_2.send(player);
|
BBC.COMMAND_REGEN_2.send(player);
|
||||||
}
|
}
|
||||||
|
}, getArguments(args), region);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -739,9 +748,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(
|
||||||
@ -756,16 +766,16 @@ 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(() -> {
|
||||||
|
|
||||||
density = density / 100;
|
|
||||||
ForestGenerator generator = new ForestGenerator(editSession, type);
|
ForestGenerator generator = new ForestGenerator(editSession, type);
|
||||||
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));
|
visitor.setMask(new NoiseFilter2D(new RandomNoise(), density / 100));
|
||||||
Operations.completeLegacy(visitor);
|
Operations.completeLegacy(visitor);
|
||||||
|
|
||||||
BBC.COMMAND_TREE.send(player, ground.getAffected());
|
BBC.COMMAND_TREE.send(player, ground.getAffected());
|
||||||
|
}, getArguments(context), region);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -778,15 +788,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));
|
visitor.setMask(new NoiseFilter2D(new RandomNoise(), density / 100));
|
||||||
Operations.completeLegacy(visitor);
|
Operations.completeLegacy(visitor);
|
||||||
|
|
||||||
BBC.COMMAND_FLORA.send(player, ground.getAffected());
|
BBC.COMMAND_FLORA.send(player, ground.getAffected());
|
||||||
|
}, getArguments(context), region);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -173,8 +173,7 @@ public class UtilityCommands extends MethodCommands {
|
|||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = {"/heightmapinterface"},
|
aliases = {"/heightmapinterface"},
|
||||||
desc = "Generate the heightmap interface: https://github.com/boy0001/HeightMap",
|
desc = "Generate the heightmap interface: https://github.com/boy0001/HeightMap"
|
||||||
max = 0
|
|
||||||
)
|
)
|
||||||
public void heightmapInterface(FawePlayer player, @Optional("100") int min, @Optional("200") int max) throws IOException {
|
public void heightmapInterface(FawePlayer player, @Optional("100") int min, @Optional("200") int max) throws IOException {
|
||||||
player.sendMessage("Please wait while we generate the minified heightmaps.");
|
player.sendMessage("Please wait while we generate the minified heightmaps.");
|
||||||
@ -200,7 +199,7 @@ public class UtilityCommands extends MethodCommands {
|
|||||||
if (name.startsWith(File.separator)) name = name.replaceFirst(java.util.regex.Pattern.quote(File.separator), "");
|
if (name.startsWith(File.separator)) name = name.replaceFirst(java.util.regex.Pattern.quote(File.separator), "");
|
||||||
BufferedImage img = MainUtil.readImage(file);
|
BufferedImage img = MainUtil.readImage(file);
|
||||||
BufferedImage minImg = ImageUtil.getScaledInstance(img, min, min, RenderingHints.VALUE_INTERPOLATION_BILINEAR, true);
|
BufferedImage minImg = ImageUtil.getScaledInstance(img, min, min, RenderingHints.VALUE_INTERPOLATION_BILINEAR, true);
|
||||||
BufferedImage maxImg = ImageUtil.getScaledInstance(img, max, max, RenderingHints.VALUE_INTERPOLATION_BILINEAR, true);
|
BufferedImage maxImg = max == -1 ? img : ImageUtil.getScaledInstance(img, max, max, RenderingHints.VALUE_INTERPOLATION_BILINEAR, true);
|
||||||
player.sendMessage("Writing " + name);
|
player.sendMessage("Writing " + name);
|
||||||
File minFile = new File(minImages, name);
|
File minFile = new File(minImages, name);
|
||||||
File maxFile = new File(maxImages, name);
|
File maxFile = new File(maxImages, name);
|
||||||
|
@ -21,13 +21,14 @@ package com.sk89q.worldedit.event.platform;
|
|||||||
|
|
||||||
import com.sk89q.worldedit.event.AbstractCancellable;
|
import com.sk89q.worldedit.event.AbstractCancellable;
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
|
import com.sk89q.worldedit.extension.platform.CommandManager;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class is currently only for internal use. Do not post or catch this event.
|
* This class is currently only for internal use. Do not post or catch this event.
|
||||||
*/
|
*/
|
||||||
public class CommandEvent extends AbstractCancellable {
|
public class CommandEvent extends AbstractCancellable implements Runnable {
|
||||||
|
|
||||||
private final Actor actor;
|
private final Actor actor;
|
||||||
private final String arguments;
|
private final String arguments;
|
||||||
@ -64,4 +65,8 @@ public class CommandEvent extends AbstractCancellable {
|
|||||||
return arguments;
|
return arguments;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
CommandManager.getInstance().handleCommandOnCurrentThread(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user