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

Datei anzeigen

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

Datei anzeigen

@ -160,35 +160,7 @@ public class ClipboardCommands {
session.getPlacementPosition(actor)); session.getPlacementPosition(actor));
ForwardExtentCopy copy = new ForwardExtentCopy(editSession, region, clipboard, region.getMinimumPoint()); ForwardExtentCopy copy = new ForwardExtentCopy(editSession, region, clipboard, region.getMinimumPoint());
copy.setCopyingEntities(copyEntities); copy.setCopyingEntities(copyEntities);
copy.setCopyingBiomes(copyBiomes); createCopy(session, editSession, copyBiomes, mask, clipboard, copy);
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));
copy.getStatusMessages().forEach(actor::print); copy.getStatusMessages().forEach(actor::print);
//FAWE end //FAWE end
@ -299,7 +271,25 @@ public class ClipboardCommands {
copy.setSourceFunction(new BlockReplace(editSession, leavePattern)); copy.setSourceFunction(new BlockReplace(editSession, leavePattern));
copy.setCopyingEntities(copyEntities); copy.setCopyingEntities(copyEntities);
copy.setRemovingEntities(true); 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); copy.setCopyingBiomes(copyBiomes);
Mask sourceMask = editSession.getSourceMask(); Mask sourceMask = editSession.getSourceMask();
Region[] regions = editSession.getAllowedRegions(); Region[] regions = editSession.getAllowedRegions();
Region allowedRegion; Region allowedRegion;
@ -318,20 +308,13 @@ public class ClipboardCommands {
new MaskTraverser(sourceMask).reset(editSession); new MaskTraverser(sourceMask).reset(editSession);
editSession.setSourceMask(null); editSession.setSourceMask(null);
} }
try { try {
Operations.completeLegacy(copy); Operations.completeLegacy(copy);
} catch (Throwable e) {
throw e;
} finally { } finally {
clipboard.flush(); clipboard.flush();
} }
session.setClipboard(new ClipboardHolder(clipboard)); 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 //FAWE start
@ -583,9 +566,10 @@ public class ClipboardCommands {
@Command( @Command(
name = "/rotate", name = "/rotate",
desc = "Rotate the contents of the clipboard", desc = "Rotate the contents of the clipboard",
descFooter = "Non-destructively rotate the contents of the clipboard.\n" descFooter = """
+ "Angles are provided in degrees and a positive angle will result in a clockwise rotation. " Non-destructively rotate the contents of the clipboard.
+ "Multiple rotations can be stacked. Interpolation is not performed so angles should be a multiple of 90 degrees.\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.
"""
) )
@CommandPermissions("worldedit.clipboard.rotate") @CommandPermissions("worldedit.clipboard.rotate")
public void rotate( public void rotate(

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

@ -140,7 +140,10 @@ public class RegionCommands {
name = "/test", name = "/test",
desc = "test region" desc = "test region"
) )
@CommandPermissions("worldedit.region.test") @CommandPermissions(
value = "worldedit.region.test",
queued = false
)
@Logging(REGION) @Logging(REGION)
public void test( public void test(
Actor actor, EditSession editSession, Actor actor, EditSession editSession,
@ -175,7 +178,10 @@ public class RegionCommands {
aliases = "/nbt", aliases = "/nbt",
desc = "View nbt info for a block" desc = "View nbt info for a block"
) )
@CommandPermissions("worldedit.nbtinfo") @CommandPermissions(
value = "worldedit.nbtinfo",
queued = false
)
public void nbtinfo(Player player, EditSession editSession) { public void nbtinfo(Player player, EditSession editSession) {
Location pos = player.getBlockTrace(128); Location pos = player.getBlockTrace(128);
if (pos == null) { if (pos == null) {
@ -228,13 +234,12 @@ public class RegionCommands {
@Switch(name = 'h', desc = "Generate only a shell") @Switch(name = 'h', desc = "Generate only a shell")
boolean shell boolean shell
) throws WorldEditException { ) throws WorldEditException {
if (!(region instanceof CuboidRegion)) { if (!(region instanceof CuboidRegion cuboidregion)) {
actor.print(Caption.of("worldedit.line.cuboid-only")); actor.print(Caption.of("worldedit.line.cuboid-only"));
return 0; return 0;
} }
checkCommandArgument(thickness >= 0, "Thickness must be >= 0"); checkCommandArgument(thickness >= 0, "Thickness must be >= 0");
CuboidRegion cuboidregion = (CuboidRegion) region;
BlockVector3 pos1 = cuboidregion.getPos1(); BlockVector3 pos1 = cuboidregion.getPos1();
BlockVector3 pos2 = cuboidregion.getPos2(); BlockVector3 pos2 = cuboidregion.getPos2();
int blocksChanged = editSession.drawLine(pattern, pos1, pos2, thickness, !shell); int blocksChanged = editSession.drawLine(pattern, pos1, pos2, thickness, !shell);
@ -261,13 +266,12 @@ public class RegionCommands {
@Switch(name = 'h', desc = "Generate only a shell") @Switch(name = 'h', desc = "Generate only a shell")
boolean shell boolean shell
) throws WorldEditException { ) throws WorldEditException {
if (!(region instanceof ConvexPolyhedralRegion)) { if (!(region instanceof ConvexPolyhedralRegion cpregion)) {
actor.print(Caption.of("worldedit.curve.invalid-type")); actor.print(Caption.of("worldedit.curve.invalid-type"));
return 0; return 0;
} }
checkCommandArgument(thickness >= 0, "Thickness must be >= 0"); checkCommandArgument(thickness >= 0, "Thickness must be >= 0");
ConvexPolyhedralRegion cpregion = (ConvexPolyhedralRegion) region;
List<BlockVector3> vectors = new ArrayList<>(cpregion.getVertices()); List<BlockVector3> vectors = new ArrayList<>(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);
@ -468,7 +472,10 @@ public class RegionCommands {
desc = "Bypass region restrictions", desc = "Bypass region restrictions",
descFooter = "Bypass region restrictions" descFooter = "Bypass region restrictions"
) )
@CommandPermissions("fawe.admin") @CommandPermissions(
value = "fawe.admin",
queued = false
)
public void wea(Actor actor) throws WorldEditException { public void wea(Actor actor) throws WorldEditException {
if (actor.togglePermission("fawe.bypass")) { if (actor.togglePermission("fawe.bypass")) {
actor.print(Caption.of("fawe.info.worldedit.bypassed")); actor.print(Caption.of("fawe.info.worldedit.bypassed"));
@ -697,7 +704,7 @@ public class RegionCommands {
actor.print(Caption.of("fawe.regen.time")); actor.print(Caption.of("fawe.regen.time"));
//FAWE end //FAWE end
RegenOptions options = RegenOptions.builder() RegenOptions options = RegenOptions.builder()
.seed(!randomSeed ? seed : new Long(ThreadLocalRandom.current().nextLong())) .seed(!randomSeed ? seed : Long.valueOf(ThreadLocalRandom.current().nextLong()))
.regenBiomes(regenBiomes) .regenBiomes(regenBiomes)
.biomeType(biomeType) .biomeType(biomeType)
.build(); .build();
@ -718,9 +725,10 @@ public class RegionCommands {
@Command( @Command(
name = "/deform", name = "/deform",
desc = "Deforms a selected region with an expression", desc = "Deforms a selected region with an expression",
descFooter = "The expression is executed for each block and is expected\n" descFooter = """
+ "to modify the variables x, y and z to point to a new block\n" The expression is executed for each block and is expected
+ "to fetch. For details, see https://ehub.to/we/expr" 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") @CommandPermissions("worldedit.region.deform")
@Logging(ALL) @Logging(ALL)
@ -794,9 +802,10 @@ public class RegionCommands {
@Command( @Command(
name = "/hollow", name = "/hollow",
desc = "Hollows out the object contained in this selection", desc = "Hollows out the object contained in this selection",
descFooter = "Hollows out the object contained in this selection.\n" descFooter = """
+ "Optionally fills the hollowed out part with the given block.\n" Hollows out the object contained in this selection.
+ "Thickness is measured in manhattan distance." Optionally fills the hollowed out part with the given block.
Thickness is measured in manhattan distance."""
) )
@CommandPermissions("worldedit.region.hollow") @CommandPermissions("worldedit.region.hollow")
@Logging(REGION) @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.URIClipboardHolder;
import com.fastasyncworldedit.core.extent.clipboard.io.schematic.MinecraftStructure; import com.fastasyncworldedit.core.extent.clipboard.io.schematic.MinecraftStructure;
import com.fastasyncworldedit.core.util.MainUtil; import com.fastasyncworldedit.core.util.MainUtil;
import com.google.common.base.Function;
import com.google.common.collect.Multimap; import com.google.common.collect.Multimap;
import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.LocalConfiguration;
import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.LocalSession;
@ -90,6 +89,7 @@ import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
import java.util.function.Function;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import static com.fastasyncworldedit.core.util.ReflectionUtils.as; import static com.fastasyncworldedit.core.util.ReflectionUtils.as;
@ -209,11 +209,9 @@ public class SchematicCommands {
} }
ClipboardHolder clipboard = session.getClipboard(); ClipboardHolder clipboard = session.getClipboard();
if (clipboard instanceof URIClipboardHolder) { if (clipboard instanceof URIClipboardHolder identifiable) {
URIClipboardHolder identifiable = (URIClipboardHolder) clipboard;
if (identifiable.contains(uri)) { if (identifiable.contains(uri)) {
if (identifiable instanceof MultiClipboardHolder) { if (identifiable instanceof MultiClipboardHolder multi) {
MultiClipboardHolder multi = (MultiClipboardHolder) identifiable;
multi.remove(uri); multi.remove(uri);
if (multi.getHolders().isEmpty()) { if (multi.getHolders().isEmpty()) {
session.setClipboard(null); session.setClipboard(null);
@ -319,7 +317,7 @@ public class SchematicCommands {
LocalConfiguration config = worldEdit.getConfiguration(); LocalConfiguration config = worldEdit.getConfiguration();
//FAWE start //FAWE start
ClipboardFormat format = null; ClipboardFormat format;
InputStream in = null; InputStream in = null;
try { try {
URI uri; URI uri;
@ -526,7 +524,10 @@ public class SchematicCommands {
aliases = {"listformats", "f"}, aliases = {"listformats", "f"},
desc = "List available formats" desc = "List available formats"
) )
@CommandPermissions("worldedit.schematic.formats") @CommandPermissions(
value = "worldedit.schematic.formats",
queued = false
)
public void formats(Actor actor) { public void formats(Actor actor) {
actor.print(Caption.of("worldedit.schematic.formats.title")); actor.print(Caption.of("worldedit.schematic.formats.title"));
StringBuilder builder; StringBuilder builder;
@ -552,7 +553,10 @@ public class SchematicCommands {
desc = "List saved schematics", desc = "List saved schematics",
descFooter = "Note: Format is not fully verified until loading." descFooter = "Note: Format is not fully verified until loading."
) )
@CommandPermissions("worldedit.schematic.list") @CommandPermissions(
value = "worldedit.schematic.list",
queued = false
)
public void list( public void list(
Actor actor, LocalSession session, Actor actor, LocalSession session,
@ArgFlag(name = 'p', desc = "Page to view.", def = "1") @ArgFlag(name = 'p', desc = "Page to view.", def = "1")
@ -823,7 +827,6 @@ public class SchematicCommands {
final String SCHEMATIC_NAME = file.getName(); final String SCHEMATIC_NAME = file.getName();
double oldKbOverwritten = 0; double oldKbOverwritten = 0;
String overwrittenPath = curFilepath;
int numFiles = -1; int numFiles = -1;
if (checkFilesize) { if (checkFilesize) {
@ -839,10 +842,10 @@ public class SchematicCommands {
if (overwrite) { if (overwrite) {
oldKbOverwritten = Files.size(Paths.get(file.getAbsolutePath())) / 1000.0; oldKbOverwritten = Files.size(Paths.get(file.getAbsolutePath())) / 1000.0;
int iter = 1; int iter = 1;
while (new File(overwrittenPath + "." + iter + "." + format.getPrimaryFileExtension()).exists()) { while (new File(curFilepath + "." + iter + "." + format.getPrimaryFileExtension()).exists()) {
iter++; 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", name = "/wand",
desc = "Get the wand object" desc = "Get the wand object"
) )
@CommandPermissions("worldedit.wand") @CommandPermissions(
value = "worldedit.wand",
queued = false
)
public void wand( public void wand(
Player player, LocalSession session, Player player, LocalSession session,
@Switch(name = 'n', desc = "Get a navigation wand") boolean navWand @Switch(name = 'n', desc = "Get a navigation wand") boolean navWand
@ -348,7 +351,10 @@ public class SelectionCommands {
aliases = {"/toggleeditwand"}, aliases = {"/toggleeditwand"},
desc = "Remind the user that the wand is now a tool and can be unbound with /tool none." 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) { public void toggleWand(Player player) {
player.print( player.print(
Caption.of( Caption.of(
@ -499,7 +505,10 @@ public class SelectionCommands {
name = "/size", name = "/size",
desc = "Get information about the selection" desc = "Get information about the selection"
) )
@CommandPermissions("worldedit.selection.size") @CommandPermissions(
value = "worldedit.selection.size",
queued = false
)
public void size( public void size(
Actor actor, World world, LocalSession session, Actor actor, World world, LocalSession session,
@Switch(name = 'c', desc = "Get clipboard info instead") @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("sphere", Caption.of("worldedit.select.sphere.description"), "//sel sphere");
box.appendCommand("cyl", Caption.of("worldedit.select.cyl.description"), "//sel cyl"); box.appendCommand("cyl", Caption.of("worldedit.select.cyl.description"), "//sel cyl");
box.appendCommand("convex", Caption.of("worldedit.select.convex.description"), "//sel convex"); box.appendCommand("convex", Caption.of("worldedit.select.convex.description"), "//sel convex");
//FAWE start //FAWE start
box.appendCommand("polyhedral", Caption.of("fawe.selection.sel.polyhedral"), "//sel polyhedral"); 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>]"); 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", name = "list",
desc = "List snapshots" desc = "List snapshots"
) )
@CommandPermissions("worldedit.snapshots.list") @CommandPermissions(
value = "worldedit.snapshots.list",
queued = false
)
void list( void list(
Actor actor, World world, Actor actor, World world,
@ArgFlag(name = 'p', desc = "Page of results to return", def = "1") @ArgFlag(name = 'p', desc = "Page of results to return", def = "1")
@ -127,8 +130,7 @@ public class SnapshotCommands {
TextComponent.of(world.getName()) TextComponent.of(world.getName())
)); ));
if (config.snapshotDatabase instanceof FileSystemSnapshotDatabase) { if (config.snapshotDatabase instanceof FileSystemSnapshotDatabase db) {
FileSystemSnapshotDatabase db = (FileSystemSnapshotDatabase) config.snapshotDatabase;
Path root = db.getRoot(); Path root = db.getRoot();
if (Files.isDirectory(root)) { if (Files.isDirectory(root)) {
WorldEdit.logger.info("No snapshots were found for world '" WorldEdit.logger.info("No snapshots were found for world '"

Datei anzeigen

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

Datei anzeigen

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