diff --git a/gradle.properties b/gradle.properties index d210d4f53..bca9aaf56 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ # Sets default memory used for gradle commands. Can be overridden by user or command line properties. # This is required to provide enough memory for the Minecraft decompilation process. #org.gradle.jvmargs=-Xmx3G -#org.gradle.daemon=false \ No newline at end of file +org.gradle.daemon=false \ No newline at end of file diff --git a/worldedit-core/doctools/src/main/kotlin/com/sk89q/worldedit/internal/util/DocumentationPrinter.kt b/worldedit-core/doctools/src/main/kotlin/com/sk89q/worldedit/internal/util/DocumentationPrinter.kt index d01020439..768830857 100644 --- a/worldedit-core/doctools/src/main/kotlin/com/sk89q/worldedit/internal/util/DocumentationPrinter.kt +++ b/worldedit-core/doctools/src/main/kotlin/com/sk89q/worldedit/internal/util/DocumentationPrinter.kt @@ -194,6 +194,7 @@ Other Permissions ``worldedit.override.data-cycler``,"Allows cycling non-whitelisted blocks with the data cycler tool." ``worldedit.setnbt``,"Allows setting `extra data `_ on blocks (such as signs, chests, etc)." ``worldedit.report.pastebin``,"Allows uploading report files to pastebin automatically for the ``/worldedit report`` :doc:`command `." + ``worldedit.scripting.execute.``,"Allows using the CraftScript with the given filename." """.trim()) } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/WorldEdit.java b/worldedit-core/src/main/java/com/sk89q/worldedit/WorldEdit.java index fa60eb72f..7aec0298a 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/WorldEdit.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/WorldEdit.java @@ -666,9 +666,9 @@ public final class WorldEdit { try { engine = new RhinoCraftScriptEngine(); - } catch (NoClassDefFoundError e) { + } catch (NoClassDefFoundError ignored) { player.printError("Failed to find an installed script engine."); - player.printError("Please see http://wiki.sk89q.com/wiki/WorldEdit/Installation"); + player.printError("Please see https://worldedit.readthedocs.io/en/latest/usage/other/craftscripts/"); return; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java index ae27b9505..a5b6290d6 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java @@ -150,7 +150,7 @@ public class BrushCommands { public void clipboardBrush(Player player, LocalSession session, @Switch(name = 'a', desc = "Don't paste air from the clipboard") boolean ignoreAir, - @Switch(name = 'o', desc = "Paste using clipboard origin, instead of being centered at the target location") + @Switch(name = 'o', desc = "Paste starting at the target location, instead of centering on it") boolean usingOrigin, @Switch(name = 'e', desc = "Paste entities if available") boolean pasteEntities, diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java index 8b0e20a1f..d2b9f7747 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java @@ -92,8 +92,7 @@ public class ClipboardCommands { @Command( name = "/cut", - desc = "Cut the selection to the clipboard", - descFooter = "WARNING: Cutting and pasting entities cannot be undone!" + desc = "Cut the selection to the clipboard" ) @CommandPermissions("worldedit.clipboard.cut") @Logging(REGION) @@ -105,7 +104,7 @@ public class ClipboardCommands { boolean copyEntities, @Switch(name = 'b', desc = "Also copy biomes, source biomes are unaffected") boolean copyBiomes, - @ArgFlag(name = 'm', desc = "Set the exclude mask, matching blocks become air", def = "") + @ArgFlag(name = 'm', desc = "Set the exclude mask, non-matching blocks become air", def = "") Mask mask) throws WorldEditException { BlockArrayClipboard clipboard = new BlockArrayClipboard(region); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SnapshotCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SnapshotCommands.java index 643b064b1..30728ed53 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SnapshotCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SnapshotCommands.java @@ -28,12 +28,19 @@ import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.command.util.CommandPermissions; import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator; import com.sk89q.worldedit.entity.Player; +import com.sk89q.worldedit.util.formatting.component.PaginationBox; +import com.sk89q.worldedit.util.formatting.text.Component; +import com.sk89q.worldedit.util.formatting.text.TextComponent; +import com.sk89q.worldedit.util.formatting.text.event.ClickEvent; +import com.sk89q.worldedit.util.formatting.text.event.HoverEvent; +import com.sk89q.worldedit.util.formatting.text.format.TextColor; import com.sk89q.worldedit.world.snapshot.InvalidSnapshotException; import com.sk89q.worldedit.world.snapshot.Snapshot; import com.sk89q.worldedit.world.storage.MissingWorldException; import org.enginehub.piston.annotation.Command; import org.enginehub.piston.annotation.CommandContainer; import org.enginehub.piston.annotation.param.Arg; +import org.enginehub.piston.annotation.param.ArgFlag; import java.io.File; import java.io.IOException; @@ -61,8 +68,8 @@ public class SnapshotCommands { ) @CommandPermissions("worldedit.snapshots.list") public void list(Player player, - @Arg(desc = "# of snapshots to list", def = "5") - int num) throws WorldEditException { + @ArgFlag(name = 'p', desc = "Page of results to return", def = "1") + int page) throws WorldEditException { LocalConfiguration config = we.getConfiguration(); @@ -75,15 +82,7 @@ public class SnapshotCommands { List snapshots = config.snapshotRepo.getSnapshots(true, player.getWorld().getName()); if (!snapshots.isEmpty()) { - - num = Math.min(40, Math.max(5, num)); - - player.print("Snapshots for world: '" + player.getWorld().getName() + "'"); - for (byte i = 0; i < Math.min(num, snapshots.size()); i++) { - player.print((i + 1) + ". " + snapshots.get(i).getName()); - } - - player.print("Use /snap use [snapshot] or /snap use latest."); + player.print(new SnapshotListBox(player.getWorld().getName(), snapshots).create(page)); } else { player.printError("No snapshots are available. See console for details."); @@ -243,4 +242,26 @@ public class SnapshotCommands { } } + private static class SnapshotListBox extends PaginationBox { + private final List snapshots; + + SnapshotListBox(String world, List snapshots) { + super("Snapshots for: " + world, "/snap list -p %page%"); + this.snapshots = snapshots; + } + + @Override + public Component getComponent(int number) { + final Snapshot snapshot = snapshots.get(number); + return TextComponent.of(number + 1 + ". ", TextColor.GOLD) + .append(TextComponent.of(snapshot.getName(), TextColor.LIGHT_PURPLE) + .hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click to use"))) + .clickEvent(ClickEvent.of(ClickEvent.Action.RUN_COMMAND, "/snap use " + snapshot.getName()))); + } + + @Override + public int getComponentsSize() { + return snapshots.size(); + } + } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ToolCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ToolCommands.java index 08fbcde6c..6bbd2d853 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ToolCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ToolCommands.java @@ -199,9 +199,9 @@ public class ToolCommands { ) @CommandPermissions("worldedit.tool.lrbuild") public void longrangebuildtool(Player player, LocalSession session, - @Arg(desc = "Block to set on left-click") + @Arg(desc = "Pattern to set on left-click") Pattern primary, - @Arg(desc = "Block to set on right-click") + @Arg(desc = "Pattern to set on right-click") Pattern secondary) throws WorldEditException { BaseItemStack itemStack = player.getItemInHand(HandSide.MAIN_HAND); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/pattern/ClipboardPatternParser.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/pattern/ClipboardPatternParser.java index 532a981e6..bb131484f 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/pattern/ClipboardPatternParser.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/pattern/ClipboardPatternParser.java @@ -43,7 +43,7 @@ public class ClipboardPatternParser extends InputParser { @Override public Stream getSuggestions(String input) { if (input.isEmpty()) { - return Stream.of("#clipoard"); + return Stream.of("#clipboard"); } String[] offsetParts = input.split("@", 2); String firstLower = offsetParts[0].toLowerCase(Locale.ROOT); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/snapshot/YYMMDDHHIISSParser.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/snapshot/YYMMDDHHIISSParser.java index 3356f71f6..51a8fa393 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/snapshot/YYMMDDHHIISSParser.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/snapshot/YYMMDDHHIISSParser.java @@ -27,13 +27,13 @@ import java.util.regex.Pattern; public class YYMMDDHHIISSParser implements SnapshotDateParser { - protected Pattern patt = + private Pattern datePattern = Pattern.compile("([0-9]+)[^0-9]?([0-9]+)[^0-9]?([0-9]+)[^0-9]?" - + "([0-9]+)[^0-9]?([0-9]+)[^0-9]?([0-9]+)"); + + "([0-9]+)[^0-9]?([0-9]+)[^0-9]?([0-9]+)(\\..*)?"); @Override public Calendar detectDate(File file) { - Matcher matcher = patt.matcher(file.getName()); + Matcher matcher = datePattern.matcher(file.getName()); if (matcher.matches()) { int year = Integer.parseInt(matcher.group(1)); int month = Integer.parseInt(matcher.group(2));