feat: make more commands unqueued (#2235)

* feat: make more commands unqueued
 - Effectively fixes the very specific "issue" in #2223 I guess
 - Use this opportunity to clean up the command classes a bit

* Address comments
Dieser Commit ist enthalten in:
Jordan 2023-05-22 19:33:59 +01:00 committet von GitHub
Ursprung 435161d566
Commit 5dca925bc3
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23
15 geänderte Dateien mit 233 neuen und 201 gelöschten Zeilen

Datei anzeigen

@ -82,7 +82,10 @@ public class BiomeCommands {
aliases = {"biomels", "/biomelist", "/listbiomes"},
desc = "Gets all biomes available."
)
@CommandPermissions("worldedit.biome.list")
@CommandPermissions(
value = "worldedit.biome.list",
queued = false
)
public void biomeList(
Actor actor,
@ArgFlag(name = 'p', desc = "Page number.", def = "1")

Datei anzeigen

@ -310,11 +310,11 @@ public class BrushCommands {
},
desc = "Join multiple objects together in a curve",
descFooter =
"Click to select some objects,click the same block twice to connect the objects.\n"
+ "Insufficient brush radius, or clicking the the wrong spot will result in undesired shapes. The shapes must be simple lines or loops.\n"
+ "Pic1: http://i.imgur.com/CeRYAoV.jpg -> http://i.imgur.com/jtM0jA4.png\n"
+ "Pic2: http://i.imgur.com/bUeyc72.png -> http://i.imgur.com/tg6MkcF.png"
+ "Tutorial: https://www.planetminecraft.com/blog/fawe-tutorial/"
"""
Click to select some objects,click the same block twice to connect the objects.
Insufficient brush radius, or clicking the the wrong spot will result in undesired shapes. The shapes must be simple lines or loops.
Pic1: http://i.imgur.com/CeRYAoV.jpg -> http://i.imgur.com/jtM0jA4.png
Pic2: http://i.imgur.com/bUeyc72.png -> http://i.imgur.com/tg6MkcF.pngTutorial: https://www.planetminecraft.com/blog/fawe-tutorial/"""
)
@CommandPermissions("worldedit.brush.spline")
public void splineBrush(
@ -337,9 +337,10 @@ public class BrushCommands {
"vaesweep"
},
desc = "Sweep your clipboard content along a curve",
descFooter = "Sweeps your clipboard content along a curve.\n"
+ "Define a curve by selecting the individual points with a brush\n"
+ "Set [copies] to a value > 0 if you want to have your selection pasted a limited amount of times equally spaced on the curve"
descFooter = """
Sweeps your clipboard content along a curve.
Define a curve by selecting the individual points with a brush
Set [copies] to a value > 0 if you want to have your selection pasted a limited amount of times equally spaced on the curve"""
)
@CommandPermissions("worldedit.brush.sweep")
public void sweepBrush(
@ -636,10 +637,10 @@ public class BrushCommands {
@Command(
name = "layer",
desc = "Replaces terrain with a layer.",
descFooter = "Replaces terrain with a layer.\n"
+ "Example: /br layer 5 oak_planks,orange_stained_glass,magenta_stained_glass,black_wool - Places several " +
"layers on a surface\n"
+ "Pic: https://i.imgur.com/XV0vYoX.png"
descFooter = """
Replaces terrain with a layer.
Example: /br layer 5 oak_planks,orange_stained_glass,magenta_stained_glass,black_wool - Places several layers on a surface
Pic: https://i.imgur.com/XV0vYoX.png"""
)
@CommandPermissions("worldedit.brush.layer")
public void surfaceLayer(
@ -658,11 +659,11 @@ public class BrushCommands {
@Command(
name = "splatter",
desc = "Splatter a pattern on a surface",
descFooter = "Sets a bunch of blocks randomly on a surface.\n"
+ "Pic: https://i.imgur.com/hMD29oO.png\n"
+ "Example: /br splatter stone,dirt 30 15\n"
+ "Note: The seeds define how many splotches there are, recursion defines how large, "
+ "solid defines whether the pattern is applied per seed, else per block."
descFooter = """
Sets a bunch of blocks randomly on a surface.
Pic: https://i.imgur.com/hMD29oO.png
Example: /br splatter stone,dirt 30 15
Note: The seeds define how many splotches there are, recursion defines how large, solid defines whether the pattern is applied per seed, else per block."""
)
@CommandPermissions("worldedit.brush.splatter")
public void splatterBrush(
@ -691,9 +692,10 @@ public class BrushCommands {
"scommand"
},
desc = "Run commands at random points on a surface",
descFooter = "Run commands at random points on a surface\n"
+ " - Your selection will be expanded to the specified size around each point\n"
+ " - Placeholders: {x}, {y}, {z}, {world}, {size}"
descFooter = """
Run commands at random points on a surface
- Your selection will be expanded to the specified size around each point
- Placeholders: {x}, {y}, {z}, {world}, {size}"""
)
@CommandPermissions("worldedit.brush.scattercommand")
public void scatterCommandBrush(
@ -723,9 +725,10 @@ public class BrushCommands {
name = "height",
aliases = {"heightmap"},
desc = "Raise or lower terrain using a heightmap",
descFooter = "This brush raises and lowers land.\n"
+ "Note: Use a negative yscale to reduce height\n"
+ "Snow Pic: https://i.imgur.com/Hrzn0I4.png"
descFooter = """
This brush raises and lowers land.
Note: Use a negative yscale to reduce height
Snow Pic: https://i.imgur.com/Hrzn0I4.png"""
)
@CommandPermissions("worldedit.brush.height")
public void heightBrush(
@ -890,9 +893,11 @@ public class BrushCommands {
"copypasta"
},
desc = "Copy Paste brush",
descFooter = "Left click the base of an object to copy.\n" + "Right click to paste\n"
+ "Note: Works well with the clipboard scroll action\n"
+ "Video: https://www.youtube.com/watch?v=RPZIaTbqoZw"
descFooter = """
Left click the base of an object to copy.
Right click to paste
Note: Works well with the clipboard scroll action
Video: https://www.youtube.com/watch?v=RPZIaTbqoZw"""
)
@CommandPermissions("worldedit.brush.copy")
public void copy(
@ -914,9 +919,10 @@ public class BrushCommands {
name = "command",
aliases = {"cmd"},
desc = "Command brush",
descFooter = "Run the commands at the clicked position.\n"
+ " - Your selection will be expanded to the specified size around each point\n"
+ " - Placeholders: {x}, {y}, {z}, {world}, {size}"
descFooter = """
Run the commands at the clicked position.
- Your selection will be expanded to the specified size around each point
- Placeholders: {x}, {y}, {z}, {world}, {size}"""
)
@CommandPermissions("worldedit.brush.command")
public void command(
@ -1036,7 +1042,7 @@ public class BrushCommands {
)
throws WorldEditException {
WorldEdit.getInstance().checkMaxBrushRadius(radius);
BrushTool tool = session.getBrushTool(player.getItemInHand(HandSide.MAIN_HAND).getType());
BrushTool tool = session.getBrushTool(player);
tool.setSize(radius);
tool.setFill(null);
tool.setBrush(new OperationFactoryBrush(factory, shape, session), permission);
@ -1196,17 +1202,12 @@ public class BrushCommands {
brush = new HollowSphereBrush();
} else {
//FAWE start - Suggest different brush material if sand or gravel is used
if (pattern instanceof BlockStateHolder) {
BlockType type = ((BlockStateHolder) pattern).getBlockType();
switch (type.getId()) {
case "minecraft:sand":
case "minecraft:gravel":
if (pattern instanceof BlockStateHolder<?> holder) {
BlockType type = holder.getBlockType();
if (type == BlockTypes.SAND || type == BlockTypes.GRAVEL) {
player.print(
Caption.of("fawe.worldedit.brush.brush.try.other"));
falling = true;
break;
default:
break;
}
}
if (falling) {
@ -1361,7 +1362,7 @@ public class BrushCommands {
iterations = Math.min(limit.MAX_ITERATIONS, iterations);
//FAWE end
set(context, new SnowSmoothBrush(iterations, mask), "worldedit.brush.snowsmooth").setSize(radius);
set(context, new SnowSmoothBrush(iterations, snowBlockCount, mask), "worldedit.brush.snowsmooth").setSize(radius);
player.print(Caption.of(
"worldedit.brush.smooth.equip",
radius,

Datei anzeigen

@ -79,7 +79,10 @@ public class ChunkCommands {
aliases = {"/chunkinfo"},
desc = "Get information about the chunk you're inside"
)
@CommandPermissions("worldedit.chunkinfo")
@CommandPermissions(
value = "worldedit.chunkinfo",
queued = false
)
public void chunkInfo(Player player) {
Location pos = player.getBlockLocation();
int chunkX = (int) Math.floor(pos.getBlockX() / 16.0);
@ -99,7 +102,10 @@ public class ChunkCommands {
aliases = {"/listchunks"},
desc = "List chunks that your selection includes"
)
@CommandPermissions("worldedit.listchunks")
@CommandPermissions(
value = "worldedit.listchunks",
queued = false
)
public void listChunks(
Actor actor, World world, LocalSession session,
@ArgFlag(name = 'p', desc = "Page number.", def = "1") int page

Datei anzeigen

@ -160,35 +160,7 @@ public class ClipboardCommands {
session.getPlacementPosition(actor));
ForwardExtentCopy copy = new ForwardExtentCopy(editSession, region, clipboard, region.getMinimumPoint());
copy.setCopyingEntities(copyEntities);
copy.setCopyingBiomes(copyBiomes);
Mask sourceMask = editSession.getSourceMask();
Region[] regions = editSession.getAllowedRegions();
Region allowedRegion;
if (regions == null || regions.length == 0) {
allowedRegion = new NullRegion();
} else {
allowedRegion = new RegionIntersection(regions);
}
final Mask firstSourceMask = mask != null ? mask : sourceMask;
final Mask finalMask = MaskIntersection.of(firstSourceMask, new RegionMask(allowedRegion)).optimize();
if (finalMask != Masks.alwaysTrue()) {
copy.setSourceMask(finalMask);
}
if (sourceMask != null) {
editSession.setSourceMask(null);
new MaskTraverser(sourceMask).reset(editSession);
editSession.setSourceMask(null);
}
try {
Operations.completeLegacy(copy);
} catch (Throwable e) {
throw e;
} finally {
clipboard.flush();
}
session.setClipboard(new ClipboardHolder(clipboard));
createCopy(session, editSession, copyBiomes, mask, clipboard, copy);
copy.getStatusMessages().forEach(actor::print);
//FAWE end
@ -299,7 +271,25 @@ public class ClipboardCommands {
copy.setSourceFunction(new BlockReplace(editSession, leavePattern));
copy.setCopyingEntities(copyEntities);
copy.setRemovingEntities(true);
createCopy(session, editSession, copyBiomes, mask, clipboard, copy);
if (!actor.hasPermission("fawe.tips")) {
actor.print(Caption.of("fawe.tips.tip.lazycut"));
}
copy.getStatusMessages().forEach(actor::print);
//FAWE end
}
private void createCopy(
final LocalSession session,
final EditSession editSession,
final boolean copyBiomes,
final Mask mask,
final Clipboard clipboard,
final ForwardExtentCopy copy
) {
copy.setCopyingBiomes(copyBiomes);
Mask sourceMask = editSession.getSourceMask();
Region[] regions = editSession.getAllowedRegions();
Region allowedRegion;
@ -318,20 +308,13 @@ public class ClipboardCommands {
new MaskTraverser(sourceMask).reset(editSession);
editSession.setSourceMask(null);
}
try {
Operations.completeLegacy(copy);
} catch (Throwable e) {
throw e;
} finally {
clipboard.flush();
}
session.setClipboard(new ClipboardHolder(clipboard));
if (!actor.hasPermission("fawe.tips")) {
actor.print(Caption.of("fawe.tips.tip.lazycut"));
}
copy.getStatusMessages().forEach(actor::print);
//FAWE end
}
//FAWE start
@ -583,9 +566,10 @@ public class ClipboardCommands {
@Command(
name = "/rotate",
desc = "Rotate the contents of the clipboard",
descFooter = "Non-destructively rotate the contents of the clipboard.\n"
+ "Angles are provided in degrees and a positive angle will result in a clockwise rotation. "
+ "Multiple rotations can be stacked. Interpolation is not performed so angles should be a multiple of 90 degrees.\n"
descFooter = """
Non-destructively rotate the contents of the clipboard.
Angles are provided in degrees and a positive angle will result in a clockwise rotation. Multiple rotations can be stacked. Interpolation is not performed so angles should be a multiple of 90 degrees.
"""
)
@CommandPermissions("worldedit.clipboard.rotate")
public void rotate(

Datei anzeigen

@ -149,15 +149,12 @@ public class GeneralCommands {
String arg0 = args.get(0).toLowerCase(Locale.ENGLISH);
String flipped;
switch (arg0) {
case "on":
flipped = "off";
break;
case "off":
flipped = "on";
break;
default:
case "on" -> flipped = "off";
case "off" -> flipped = "on";
default -> {
return TextComponent.of("There is no replacement for //fast " + arg0);
}
}
return CommandUtil.createNewCommandReplacementText("//perf " + flipped);
}
@ -362,7 +359,10 @@ public class GeneralCommands {
descFooter = "This is dependent on platform implementation. " +
"Not all platforms support watchdog hooks, or contain a watchdog."
)
@CommandPermissions("worldedit.watchdog")
@CommandPermissions(
value = "worldedit.watchdog",
queued = false
)
public void watchdog(
Actor actor, LocalSession session,
@Arg(desc = "The mode to set the watchdog hook to", def = "")
@ -424,7 +424,10 @@ public class GeneralCommands {
aliases = {"/searchitem", "/l", "/search"},
desc = "Search for an item"
)
@CommandPermissions("worldedit.searchitem")
@CommandPermissions(
value = "worldedit.searchitem",
queued = false
)
public void searchItem(
Actor actor,
@Switch(name = 'b', desc = "Only search for blocks")
@ -573,7 +576,10 @@ public class GeneralCommands {
aliases = {"tips"},
desc = "Toggle FAWE tips"
)
@CommandPermissions("fawe.tips")
@CommandPermissions(
value = "fawe.tips",
queued = false
)
public void tips(Actor actor, LocalSession session) throws WorldEditException {
if (actor.togglePermission("fawe.tips")) {
actor.print(Caption.of("fawe.info.worldedit.toggle.tips.on"));
@ -627,7 +633,6 @@ public class GeneralCommands {
String command = "/searchitem " + (blocksOnly ? "-b " : "") + (itemsOnly ? "-i " : "") + "-p %page% " + search;
Map<String, Component> results = new TreeMap<>();
String idMatch = search.replace(' ', '_');
String nameMatch = search.toLowerCase(Locale.ROOT);
for (ItemType searchType : ItemType.REGISTRY) {
if (blocksOnly && !searchType.hasBlockType()) {
continue;

Datei anzeigen

@ -119,19 +119,16 @@ public class GenerationCommands {
final double radiusX;
final double radiusZ;
switch (radii.size()) {
case 1:
radiusX = radiusZ = Math.max(1, radii.get(0));
break;
case 2:
case 1 -> radiusX = radiusZ = Math.max(1, radii.get(0));
case 2 -> {
radiusX = Math.max(1, radii.get(0));
radiusZ = Math.max(1, radii.get(1));
break;
default:
}
default -> {
actor.print(Caption.of("worldedit.cyl.invalid-radius"));
return 0;
}
}
worldEdit.checkMaxRadius(radiusX);
worldEdit.checkMaxRadius(radiusZ);
worldEdit.checkMaxRadius(height);
@ -169,19 +166,16 @@ public class GenerationCommands {
final double radiusX;
final double radiusZ;
switch (radii.size()) {
case 1:
radiusX = radiusZ = Math.max(1, radii.get(0));
break;
case 2:
case 1 -> radiusX = radiusZ = Math.max(1, radii.get(0));
case 2 -> {
radiusX = Math.max(1, radii.get(0));
radiusZ = Math.max(1, radii.get(1));
break;
default:
}
default -> {
actor.print(Caption.of("worldedit.cyl.invalid-radius"));
return 0;
}
}
worldEdit.checkMaxRadius(radiusX);
worldEdit.checkMaxRadius(radiusZ);
@ -234,20 +228,17 @@ public class GenerationCommands {
final double radiusY;
final double radiusZ;
switch (radii.size()) {
case 1:
radiusX = radiusY = radiusZ = Math.max(0, radii.get(0));
break;
case 3:
case 1 -> radiusX = radiusY = radiusZ = Math.max(0, radii.get(0));
case 3 -> {
radiusX = Math.max(0, radii.get(0));
radiusY = Math.max(0, radii.get(1));
radiusZ = Math.max(0, radii.get(2));
break;
default:
}
default -> {
actor.print(Caption.of("worldedit.sphere.invalid-radius"));
return 0;
}
}
worldEdit.checkMaxRadius(radiusX);
worldEdit.checkMaxRadius(radiusY);
@ -437,9 +428,10 @@ public class GenerationCommands {
name = "/generatebiome",
aliases = {"/genbiome", "/gb"},
desc = "Sets biome according to a formula.",
descFooter = "Formula must return positive numbers (true) if the point is inside the shape\n"
+ "Sets the biome of blocks in that shape.\n"
+ "For details, see https://ehub.to/we/expr"
descFooter = """
Formula must return positive numbers (true) if the point is inside the shape
Sets the biome of blocks in that shape.
For details, see https://ehub.to/we/expr"""
)
@CommandPermissions("worldedit.generation.shape.biome")
@Logging(ALL)
@ -626,14 +618,12 @@ public class GenerationCommands {
BlockVector3 pos1 = session.getPlacementPosition(actor);
BlockVector3 pos2 = pos1.add(image.getWidth() - 1, 0, image.getHeight() - 1);
CuboidRegion region = new CuboidRegion(pos1, pos2);
int[] count = new int[1];
final BufferedImage finalImage = image;
RegionVisitor visitor = new RegionVisitor(region, pos -> {
int x = pos.getBlockX() - pos1.getBlockX();
int z = pos.getBlockZ() - pos1.getBlockZ();
int color = finalImage.getRGB(x, z);
BlockType block = tu.getNearestBlock(color);
count[0]++;
if (block != null) {
return editSession.setBlock(pos, block.getDefaultState());
}

Datei anzeigen

@ -223,7 +223,10 @@ public class HistorySubCommands {
aliases = {"summary", "summarize"},
desc = "Summarize an edit"
)
@CommandPermissions("worldedit.history.info")
@CommandPermissions(
value = "worldedit.history.info",
queued = false
)
public synchronized void summary(
Player player, RollbackDatabase database, Arguments arguments,
@Arg(desc = "Player uuid/name")
@ -314,8 +317,7 @@ public class HistorySubCommands {
public Component apply(@Nullable Supplier<? extends ChangeSet> input) {
ChangeSet edit = input.get();
if (edit instanceof RollbackOptimizedHistory) {
RollbackOptimizedHistory rollback = (RollbackOptimizedHistory) edit;
if (edit instanceof RollbackOptimizedHistory rollback) {
UUID uuid = rollback.getUUID();
int index = rollback.getIndex();
@ -368,7 +370,10 @@ public class HistorySubCommands {
aliases = {"inspect", "search", "near"},
desc = "Find nearby edits"
)
@CommandPermissions("worldedit.history.find")
@CommandPermissions(
value = "worldedit.history.find",
queued = false
)
public synchronized void find(
Player player, World world, RollbackDatabase database, Arguments arguments,
@ArgFlag(name = 'u', def = "", desc = "String user")
@ -429,7 +434,10 @@ public class HistorySubCommands {
aliases = {"distribution"},
desc = "View block distribution for an edit"
)
@CommandPermissions("worldedit.history.distr")
@CommandPermissions(
value = "worldedit.history.distr",
queued = false
)
public void distr(
Player player, LocalSession session, RollbackDatabase database, Arguments arguments,
@Arg(desc = "Player uuid/name")
@ -468,7 +476,10 @@ public class HistorySubCommands {
name = "list",
desc = "List your history"
)
@CommandPermissions("worldedit.history.list")
@CommandPermissions(
value = "worldedit.history.list",
queued = false
)
public void list(
Player player, LocalSession session, RollbackDatabase database, Arguments arguments,
@Arg(desc = "Player uuid/name")
@ -476,7 +487,6 @@ public class HistorySubCommands {
@ArgFlag(name = 'p', desc = "Page to view.", def = "")
Integer page
) {
int index = session.getHistoryIndex();
List<Supplier<? extends ChangeSet>> history = Lists.transform(
session.getHistory(),
(Function<ChangeSet, Supplier<ChangeSet>>) input -> () -> input

Datei anzeigen

@ -60,7 +60,10 @@ public class NavigationCommands {
aliases = {"!", "/unstuck"},
desc = "Escape from being stuck inside a block"
)
@CommandPermissions("worldedit.navigation.unstuck")
@CommandPermissions(
value = "worldedit.navigation.unstuck",
queued = false
)
public void unstuck(Player player) throws WorldEditException {
player.findFreePosition();
player.print(Caption.of("worldedit.unstuck.moved"));
@ -71,7 +74,10 @@ public class NavigationCommands {
aliases = {"asc", "/asc", "/ascend"},
desc = "Go up a floor"
)
@CommandPermissions("worldedit.navigation.ascend")
@CommandPermissions(
value = "worldedit.navigation.ascend",
queued = false
)
public void ascend(
Player player,
@Arg(desc = "# of levels to ascend", def = "1")
@ -96,7 +102,10 @@ public class NavigationCommands {
aliases = {"desc", "/desc", "/descend"},
desc = "Go down a floor"
)
@CommandPermissions("worldedit.navigation.descend")
@CommandPermissions(
value = "worldedit.navigation.descend",
queued = false
)
public void descend(
Player player,
@Arg(desc = "# of levels to descend", def = "1")
@ -147,7 +156,10 @@ public class NavigationCommands {
aliases = {"/thru"},
desc = "Pass through walls"
)
@CommandPermissions("worldedit.navigation.thru.command")
@CommandPermissions(
value = "worldedit.navigation.thru.command",
queued = false
)
public void thru(Player player) throws WorldEditException {
if (player.passThroughForwardWall(6)) {
player.print(Caption.of("worldedit.thru.moved"));
@ -161,7 +173,10 @@ public class NavigationCommands {
aliases = {"j", "/jumpto", "/j"},
desc = "Teleport to a location"
)
@CommandPermissions("worldedit.navigation.jumpto.command")
@CommandPermissions(
value = "worldedit.navigation.jumpto.command",
queued = false
)
public void jumpTo(
Player player,
@Arg(desc = "Location to jump to", def = "")

Datei anzeigen

@ -140,7 +140,10 @@ public class RegionCommands {
name = "/test",
desc = "test region"
)
@CommandPermissions("worldedit.region.test")
@CommandPermissions(
value = "worldedit.region.test",
queued = false
)
@Logging(REGION)
public void test(
Actor actor, EditSession editSession,
@ -175,7 +178,10 @@ public class RegionCommands {
aliases = "/nbt",
desc = "View nbt info for a block"
)
@CommandPermissions("worldedit.nbtinfo")
@CommandPermissions(
value = "worldedit.nbtinfo",
queued = false
)
public void nbtinfo(Player player, EditSession editSession) {
Location pos = player.getBlockTrace(128);
if (pos == null) {
@ -228,13 +234,12 @@ public class RegionCommands {
@Switch(name = 'h', desc = "Generate only a shell")
boolean shell
) throws WorldEditException {
if (!(region instanceof CuboidRegion)) {
if (!(region instanceof CuboidRegion cuboidregion)) {
actor.print(Caption.of("worldedit.line.cuboid-only"));
return 0;
}
checkCommandArgument(thickness >= 0, "Thickness must be >= 0");
CuboidRegion cuboidregion = (CuboidRegion) region;
BlockVector3 pos1 = cuboidregion.getPos1();
BlockVector3 pos2 = cuboidregion.getPos2();
int blocksChanged = editSession.drawLine(pattern, pos1, pos2, thickness, !shell);
@ -261,13 +266,12 @@ public class RegionCommands {
@Switch(name = 'h', desc = "Generate only a shell")
boolean shell
) throws WorldEditException {
if (!(region instanceof ConvexPolyhedralRegion)) {
if (!(region instanceof ConvexPolyhedralRegion cpregion)) {
actor.print(Caption.of("worldedit.curve.invalid-type"));
return 0;
}
checkCommandArgument(thickness >= 0, "Thickness must be >= 0");
ConvexPolyhedralRegion cpregion = (ConvexPolyhedralRegion) region;
List<BlockVector3> vectors = new ArrayList<>(cpregion.getVertices());
int blocksChanged = editSession.drawSpline(pattern, vectors, 0, 0, 0, 10, thickness, !shell);
@ -468,7 +472,10 @@ public class RegionCommands {
desc = "Bypass region restrictions",
descFooter = "Bypass region restrictions"
)
@CommandPermissions("fawe.admin")
@CommandPermissions(
value = "fawe.admin",
queued = false
)
public void wea(Actor actor) throws WorldEditException {
if (actor.togglePermission("fawe.bypass")) {
actor.print(Caption.of("fawe.info.worldedit.bypassed"));
@ -697,7 +704,7 @@ public class RegionCommands {
actor.print(Caption.of("fawe.regen.time"));
//FAWE end
RegenOptions options = RegenOptions.builder()
.seed(!randomSeed ? seed : new Long(ThreadLocalRandom.current().nextLong()))
.seed(!randomSeed ? seed : Long.valueOf(ThreadLocalRandom.current().nextLong()))
.regenBiomes(regenBiomes)
.biomeType(biomeType)
.build();
@ -718,9 +725,10 @@ public class RegionCommands {
@Command(
name = "/deform",
desc = "Deforms a selected region with an expression",
descFooter = "The expression is executed for each block and is expected\n"
+ "to modify the variables x, y and z to point to a new block\n"
+ "to fetch. For details, see https://ehub.to/we/expr"
descFooter = """
The expression is executed for each block and is expected
to modify the variables x, y and z to point to a new block
to fetch. For details, see https://ehub.to/we/expr"""
)
@CommandPermissions("worldedit.region.deform")
@Logging(ALL)
@ -794,9 +802,10 @@ public class RegionCommands {
@Command(
name = "/hollow",
desc = "Hollows out the object contained in this selection",
descFooter = "Hollows out the object contained in this selection.\n"
+ "Optionally fills the hollowed out part with the given block.\n"
+ "Thickness is measured in manhattan distance."
descFooter = """
Hollows out the object contained in this selection.
Optionally fills the hollowed out part with the given block.
Thickness is measured in manhattan distance."""
)
@CommandPermissions("worldedit.region.hollow")
@Logging(REGION)

Datei anzeigen

@ -26,7 +26,6 @@ import com.fastasyncworldedit.core.extent.clipboard.MultiClipboardHolder;
import com.fastasyncworldedit.core.extent.clipboard.URIClipboardHolder;
import com.fastasyncworldedit.core.extent.clipboard.io.schematic.MinecraftStructure;
import com.fastasyncworldedit.core.util.MainUtil;
import com.google.common.base.Function;
import com.google.common.collect.Multimap;
import com.sk89q.worldedit.LocalConfiguration;
import com.sk89q.worldedit.LocalSession;
@ -90,6 +89,7 @@ import java.util.Map;
import java.util.Objects;
import java.util.UUID;
import java.util.concurrent.Callable;
import java.util.function.Function;
import java.util.regex.Pattern;
import static com.fastasyncworldedit.core.util.ReflectionUtils.as;
@ -209,11 +209,9 @@ public class SchematicCommands {
}
ClipboardHolder clipboard = session.getClipboard();
if (clipboard instanceof URIClipboardHolder) {
URIClipboardHolder identifiable = (URIClipboardHolder) clipboard;
if (clipboard instanceof URIClipboardHolder identifiable) {
if (identifiable.contains(uri)) {
if (identifiable instanceof MultiClipboardHolder) {
MultiClipboardHolder multi = (MultiClipboardHolder) identifiable;
if (identifiable instanceof MultiClipboardHolder multi) {
multi.remove(uri);
if (multi.getHolders().isEmpty()) {
session.setClipboard(null);
@ -319,7 +317,7 @@ public class SchematicCommands {
LocalConfiguration config = worldEdit.getConfiguration();
//FAWE start
ClipboardFormat format = null;
ClipboardFormat format;
InputStream in = null;
try {
URI uri;
@ -526,7 +524,10 @@ public class SchematicCommands {
aliases = {"listformats", "f"},
desc = "List available formats"
)
@CommandPermissions("worldedit.schematic.formats")
@CommandPermissions(
value = "worldedit.schematic.formats",
queued = false
)
public void formats(Actor actor) {
actor.print(Caption.of("worldedit.schematic.formats.title"));
StringBuilder builder;
@ -552,7 +553,10 @@ public class SchematicCommands {
desc = "List saved schematics",
descFooter = "Note: Format is not fully verified until loading."
)
@CommandPermissions("worldedit.schematic.list")
@CommandPermissions(
value = "worldedit.schematic.list",
queued = false
)
public void list(
Actor actor, LocalSession session,
@ArgFlag(name = 'p', desc = "Page to view.", def = "1")
@ -823,7 +827,6 @@ public class SchematicCommands {
final String SCHEMATIC_NAME = file.getName();
double oldKbOverwritten = 0;
String overwrittenPath = curFilepath;
int numFiles = -1;
if (checkFilesize) {
@ -839,10 +842,10 @@ public class SchematicCommands {
if (overwrite) {
oldKbOverwritten = Files.size(Paths.get(file.getAbsolutePath())) / 1000.0;
int iter = 1;
while (new File(overwrittenPath + "." + iter + "." + format.getPrimaryFileExtension()).exists()) {
while (new File(curFilepath + "." + iter + "." + format.getPrimaryFileExtension()).exists()) {
iter++;
}
file = new File(overwrittenPath + "." + iter + "." + format.getPrimaryFileExtension());
file = new File(curFilepath + "." + iter + "." + format.getPrimaryFileExtension());
}
}

Datei anzeigen

@ -314,7 +314,10 @@ public class SelectionCommands {
name = "/wand",
desc = "Get the wand object"
)
@CommandPermissions("worldedit.wand")
@CommandPermissions(
value = "worldedit.wand",
queued = false
)
public void wand(
Player player, LocalSession session,
@Switch(name = 'n', desc = "Get a navigation wand") boolean navWand
@ -348,7 +351,10 @@ public class SelectionCommands {
aliases = {"/toggleeditwand"},
desc = "Remind the user that the wand is now a tool and can be unbound with /tool none."
)
@CommandPermissions("worldedit.wand.toggle")
@CommandPermissions(
value = "worldedit.wand.toggle",
queued = false
)
public void toggleWand(Player player) {
player.print(
Caption.of(
@ -499,7 +505,10 @@ public class SelectionCommands {
name = "/size",
desc = "Get information about the selection"
)
@CommandPermissions("worldedit.selection.size")
@CommandPermissions(
value = "worldedit.selection.size",
queued = false
)
public void size(
Actor actor, World world, LocalSession session,
@Switch(name = 'c', desc = "Get clipboard info instead")
@ -734,6 +743,7 @@ public class SelectionCommands {
box.appendCommand("sphere", Caption.of("worldedit.select.sphere.description"), "//sel sphere");
box.appendCommand("cyl", Caption.of("worldedit.select.cyl.description"), "//sel cyl");
box.appendCommand("convex", Caption.of("worldedit.select.convex.description"), "//sel convex");
//FAWE start
box.appendCommand("polyhedral", Caption.of("fawe.selection.sel.polyhedral"), "//sel polyhedral");
box.appendCommand("fuzzy[=<mask>]", Caption.of("fawe.selection.sel.fuzzy-instruction"), "//sel fuzzy[=<mask>]");

Datei anzeigen

@ -98,7 +98,10 @@ public class SnapshotCommands {
name = "list",
desc = "List snapshots"
)
@CommandPermissions("worldedit.snapshots.list")
@CommandPermissions(
value = "worldedit.snapshots.list",
queued = false
)
void list(
Actor actor, World world,
@ArgFlag(name = 'p', desc = "Page of results to return", def = "1")
@ -127,8 +130,7 @@ public class SnapshotCommands {
TextComponent.of(world.getName())
));
if (config.snapshotDatabase instanceof FileSystemSnapshotDatabase) {
FileSystemSnapshotDatabase db = (FileSystemSnapshotDatabase) config.snapshotDatabase;
if (config.snapshotDatabase instanceof FileSystemSnapshotDatabase db) {
Path root = db.getRoot();
if (Files.isDirectory(root)) {
WorldEdit.logger.info("No snapshots were found for world '"

Datei anzeigen

@ -95,7 +95,7 @@ public class SnapshotUtilCommands {
if (snapshotName != null) {
URI uri = resolveSnapshotName(config, snapshotName);
Optional<Snapshot> snapOpt = config.snapshotDatabase.getSnapshot(uri);
if (!snapOpt.isPresent()) {
if (snapOpt.isEmpty()) {
actor.print(Caption.of("worldedit.restore.not-available"));
return;
}

Datei anzeigen

@ -140,7 +140,7 @@ public class ToolUtilCommands {
@Arg(desc = "The range of the brush")
int range
) throws WorldEditException {
session.getBrushTool(player.getItemInHand(HandSide.MAIN_HAND).getType()).setRange(range);
session.getBrushTool(player).setRange(range);
player.print(Caption.of("worldedit.tool.range.set"));
}
@ -156,7 +156,7 @@ public class ToolUtilCommands {
) throws WorldEditException {
we.checkMaxBrushRadius(size);
session.getBrushTool(player.getItemInHand(HandSide.MAIN_HAND).getType()).setSize(size);
session.getBrushTool(player).setSize(size);
player.print(Caption.of("worldedit.tool.size.set"));
}

Datei anzeigen

@ -29,7 +29,6 @@ import com.fastasyncworldedit.core.util.StringMan;
import com.fastasyncworldedit.core.util.TaskManager;
import com.fastasyncworldedit.core.util.image.ImageUtil;
import com.fastasyncworldedit.core.util.task.DelegateConsumer;
import com.google.common.base.Function;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.IncompleteRegionException;
import com.sk89q.worldedit.LocalConfiguration;
@ -98,6 +97,7 @@ import java.util.Locale;
import java.util.Map;
import java.util.UUID;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;
import java.util.stream.Collectors;
@ -130,7 +130,10 @@ public class UtilityCommands {
aliases = {"/hmi", "hmi"},
desc = "Generate the heightmap interface: https://github.com/IntellectualSites/HeightMap"
)
@CommandPermissions("fawe.admin")
@CommandPermissions(
value = "fawe.admin",
queued = false
)
public void heightmapInterface(
Actor actor,
@Arg(name = "min", desc = "int", def = "100") int min,
@ -145,11 +148,8 @@ public class UtilityCommands {
final int sub = srcFolder.getAbsolutePath().length();
List<String> images = new ArrayList<>();
MainUtil.iterateFiles(srcFolder, file -> {
switch (file.getName().substring(file.getName().lastIndexOf('.')).toLowerCase(Locale.ROOT)) {
case ".png":
case ".jpeg":
break;
default:
String s = file.getName().substring(file.getName().lastIndexOf('.')).toLowerCase(Locale.ROOT);
if (!s.equals(".png") && !s.equals(".jpeg")) {
return;
}
try {
@ -187,7 +187,7 @@ public class UtilityCommands {
StringBuilder config = new StringBuilder();
config.append("var images = [\n");
for (String image : images) {
config.append('"' + image.replace(File.separator, "/") + "\",\n");
config.append('"').append(image.replace(File.separator, "/")).append("\",\n");
}
config.append("];\n");
config.append("// The low res images (they should all be the same size)\n");
@ -805,7 +805,10 @@ public class UtilityCommands {
name = "/help",
desc = "Displays help for WorldEdit commands"
)
@CommandPermissions("worldedit.help")
@CommandPermissions(
value = "worldedit.help",
queued = false
)
public void help(
Actor actor,
@Switch(name = 's', desc = "List sub-commands of the given command, if applicable")
@ -859,7 +862,6 @@ public class UtilityCommands {
URI uri = input.getKey();
String path = input.getValue();
boolean url = false;
boolean loaded = isLoaded.apply(uri);
URIType type = URIType.FILE;
@ -959,21 +961,13 @@ public class UtilityCommands {
if (len > 0) {
for (String arg : args) {
switch (arg.toLowerCase(Locale.ROOT)) {
case "me":
case "mine":
case "local":
case "private":
listMine = true;
break;
case "public":
case "global":
listGlobal = true;
break;
case "all":
case "me", "mine", "local", "private" -> listMine = true;
case "public", "global" -> listGlobal = true;
case "all" -> {
listMine = true;
listGlobal = true;
break;
default:
}
default -> {
if (arg.endsWith("/") || arg.endsWith(File.separator)) {
arg = arg.replace("/", File.separator);
String newDirFilter = dirFilter + arg;
@ -995,7 +989,7 @@ public class UtilityCommands {
} else {
filters.add(arg);
}
break;
}
}
}
}
@ -1005,7 +999,7 @@ public class UtilityCommands {
List<File> toFilter = new ArrayList<>();
if (!filters.isEmpty()) {
forEachFile = new DelegateConsumer<File>(forEachFile) {
forEachFile = new DelegateConsumer<>(forEachFile) {
@Override
public void accept(File file) {
toFilter.add(file);
@ -1015,7 +1009,7 @@ public class UtilityCommands {
if (formatName != null) {
final ClipboardFormat cf = ClipboardFormats.findByAlias(formatName);
forEachFile = new DelegateConsumer<File>(forEachFile) {
forEachFile = new DelegateConsumer<>(forEachFile) {
@Override
public void accept(File file) {
if (cf.isFormat(file)) {
@ -1024,7 +1018,7 @@ public class UtilityCommands {
}
};
} else {
forEachFile = new DelegateConsumer<File>(forEachFile) {
forEachFile = new DelegateConsumer<>(forEachFile) {
@Override
public void accept(File file) {
if (!file.toString().endsWith(".cached")) {
@ -1062,7 +1056,7 @@ public class UtilityCommands {
}
if (listGlobal) {
File rel = MainUtil.resolveRelative(new File(dir, dirFilter));
forEachFile = new DelegateConsumer<File>(forEachFile) {
forEachFile = new DelegateConsumer<>(forEachFile) {
@Override
public void accept(File f) {
try {
@ -1172,7 +1166,7 @@ public class UtilityCommands {
StringBuilder name = new StringBuilder();
if (relative.isAbsolute()) {
relative = root.toURI().relativize(file.toURI());
name.append(".." + File.separator);
name.append("..").append(File.separator);
}
name.append(relative.getPath());
return name.toString();