From 8dbd9645f9f0baa8b4404112bd9bd6c5f57177b7 Mon Sep 17 00:00:00 2001 From: sk89q Date: Sat, 29 Jan 2011 12:40:42 -0800 Subject: [PATCH] Updated documentation printer program, updated plugin.yml. --- plugin.yml | 457 +++++++++--------- .../worldedit/dev/DocumentationPrinter.java | 107 +++- 2 files changed, 319 insertions(+), 245 deletions(-) diff --git a/plugin.yml b/plugin.yml index 902574540..f67455476 100644 --- a/plugin.yml +++ b/plugin.yml @@ -2,258 +2,249 @@ name: WorldEdit main: com.sk89q.worldedit.bukkit.WorldEditPlugin version: "WEVERSIONMACRO" commands: - /limit: - description: See documentation - usage: / - toggleplace: - description: Toggle placing at pos #1 - usage: / - - /undo: - description: Undo - usage: / - /redo: - description: Redo - usage: / - clearhistory: - description: Clear history - usage: / - - /pos1: - description: Set editing position #1 - usage: / - /pos2: - description: Set editing position #2 - usage: / - /hpos1: - description: Trace editing position #1 - usage: / - /hpos2: - description: Trace editing position #2 - usage: / - /chunk: - description: Select the chunk that you are in - usage: / - /wand: - description: Gives you the edit wand - usage: / - toggleeditwand: - description: Toggles edit wand selection - usage: / - /expand: - description: Expands the selection - usage: / [direction] - /contract: - description: Contracts the selection - usage: / [direction] - /shift: - description: Shift the selection - usage: / [direction] - /size: - description: Get size of selected region + chunkinfo: + description: Get information about the chunk that you are inside usage: / - /count: - description: Count the number of blocks in the region - usage: / - /distr: - description: Get the top block distribution + listchunks: + description: List chunks that your selection includes + usage: / + delchunks: + description: Delete chunks that your selection includes + usage: / + clearclipboard: + description: Clear your clipboard usage: / - - /set: - description: Set all blocks inside region - usage: / - /replace: - description: Replace all existing blocks inside region - usage: / [from-id] [to-id] - /overlay: - description: Overlay the area one layer - usage: / - /walls: - description: Build walls - usage: / - /outline: - description: Outline the region with blocks - usage: / - /move: - description: Move the selection - usage: / [count] [dir] [leave-id] - /stack: - description: Stacks the selection - usage: / [count] [dir] - /smooth: - description: Smooth an area's heightmap - usage: / [iterations] - - /copy: - description: Copies the currently selected region - usage: / - /cut: - description: Cuts the currently selected region - usage: / - /paste: - description: Pastes the clipboard - usage: / - /rotate: - description: Rotate the clipboard - usage: / - /flip: - description: Flip the clipboard - usage: / [dir] /load: - description: Load .schematic into clipboard + description: Load a schematic into your clipboard usage: / /save: - description: Save clipboard to .schematic + description: Save a schematic into your clipboard usage: / - clearclipboard: - description: Clear clipboard - usage: / - + /copy: + description: Copy the selection to the clipboard + usage: / + /flip: + description: Flip the contents of the clipboard + usage: / [dir] + /rotate: + description: Rotate the contents of the clipboard + usage: / + /cut: + description: Cut the selection to the clipboard + usage: / [leave-id] + /paste: + description: Paste the clipboard's contents + usage: / [-ao] + toggleplace: + description: + usage: / + /limit: + description: Modify block change limit + usage: / /hcyl: - description: Create a vertical hollow cylinder - usage: / [height] + description: Generate a hollow cylinder + usage: / [height] /cyl: - description: Create a vertical cylinder - usage: / [height] - /sphere: - description: Create a sphere - usage: / [raised?] + description: Generate a cylinder + usage: / [height] /hsphere: - description: Create a hollow sphere - usage: / [raised?] + description: Generate a hollow sphere + usage: / [raised?] + /sphere: + description: Generate a filled sphere + usage: / [raised?] forestgen: - description: Make Notch tree forest - usage: / [size] [density] + description: Generate a forest + usage: / [size] [density] pinegen: - description: Make an ugly pine tree forest + description: Generate a pine forest usage: / [size] [density] pumpkins: - description: Make a pumpkin forest + description: Generate pumpkin patches usage: / [size] - - /fill: - description: Fill a hole - usage: / [depth] - /fillr: - description: Fill a hole fully recursively - usage: / - fixwater: - description: Level nearby pools of water - usage: / - fixlava: - description: Level nearby pools of lava - usage: / - /drain: - description: Drain nearby water/lava pools - usage: / - removeabove: - description: Remove blocks above head - usage: / [size] [height] - removebelow: - description: Remove blocks below position - usage: / [size] [height] - removenear: - description: Remove blocks near you - usage: / [id] [size] - replacenear: - description: Replace all existing blocks nearby - usage: / - snow: - description: Simulate snow cover - usage: / - thaw: - description: Unthaw/remove snow - usage: / - butcher: - description: Kill nearby mobs - usage: / [radius] - ex: - description: Extinguish fires - usage: / [size] - - chunkinfo: - description: Get the filename of the chunk that you are in - usage: / - listchunks: - description: Print a list of used chunks - usage: / - delchunks: - description: Generate a shell script to delete chunks - usage: / - + clearhistory: + description: Clear your history + usage: / + /redo: + description: Redoes the last action (from history) + usage: / + /undo: + description: Undoes the last action + usage: / unstuck: - description: Go up to the first free spot - usage: / + description: Escape from being stuck inside a block + usage: / ascend: - description: Go up one level - usage: / + description: Go up a floor + usage: / descend: - description: Go down one level - usage: / - jumpto: - description: Jump to the block that you are looking at - usage: / + description: Go down a floor + usage: / thru: - description: Go through the wall that you are looking at - usage: / + description: Passthrough walls + usage: / + jumpto: + description: Teleport to a location + usage: / ceil: - description: Get to the ceiling - usage: / [clearence] + description: Go to the celing + usage: / [clearance] up: - description: Go up some distance - usage: / - - listsnapshots: - description: List the 5 newest snapshots - usage: / [num] - /use: - description: Use a particular snapshot - usage: / - /restore: - description: Restore a particular snapshot - usage: / [snapshot-id] - - /: - description: Toggles super pick axe. - usage: / - single: - description: Switch to single block super pickaxe mode - usage: / - area: - description: Switch to area super pickaxe mode - usage: / - recur: - description: Switch to recursive super pickaxe mode - usage: / - none: - description: Switch to no tool - usage: / - info: - description: Switch to the info tool - usage: / - tree: - description: Switch to the tree tool - usage: / - pinetree: - description: Switch to the pine tree tool - usage: / - bigtree: - description: Switch to the big tree tool - usage: / - repl: - description: Switch to the block replacer tool - usage: / - brush: - description: Switch to the sphere brush tool - usage: / [radius] [no-replace?] - + description: Go upwards some distance + usage: / + /overlay: + description: Set a block on top of blocks in the region + usage: / + /walls: + description: Build the four sides of the selection + usage: / + /faces: + description: Build the walls, ceiling, and roof of a selection + usage: / + aliases: /outline + /smooth: + description: Smooth the elevation in the selection + usage: / [iterations] + /replace: + description: Replace all blocks in the selection with another + usage: / [from-block] + /stack: + description: Repeat the contents of the selection + usage: / [-a] [count] [direction] + /set: + description: Set all the blocks inside the selection to a block + usage: / + /move: + description: Move the contents of the selection + usage: / [count] [direction] [leave-id] + .s: + description: Execute last CraftScript + usage: / [args...] cs: description: Execute a CraftScript - usage: / [arg1 [args2 [arg3 [...]]]] - .s: - description: Re-execute last CraftScript - usage: / [arg1 [args2 [arg3 [...]]]] - - reloadwe: - description: Reload WorldEdit's configuration - usage: / \ No newline at end of file + usage: / [args...] + /chunk: + description: Set the selection to your current chunk + usage: / + /pos1: + description: Set position 1 + usage: / + /pos2: + description: Set position 2 + usage: / + /hpos1: + description: Set position 1 to targeted block + usage: / + /hpos2: + description: Set position 2 to targeted block + usage: / + /wand: + description: Get the wand object + usage: / + toggleeditwand: + description: Toggle functionality of the edit wand + usage: / + /contract: + description: Contract the selection area + usage: / [reverse-amount] [direction] + /distr: + description: Get the distribution of blocks in the selection + usage: / + //count: + description: Counts the number of a certain type of block + usage: / + /size: + description: Get information about the selection + usage: / + /shift: + description: Shift the selection area + usage: / [direction] + /expand: + description: Expand the selection area + usage: / [reverse-amount] + /use: + description: Choose a snapshot to use + usage: / + listsnapshots: + description: List snapshots + usage: / [num] + /restore: + description: Restore the selection from a snapshot + usage: / [snapshot] + /: + description: Toggle the super pickaxe pickaxe function + usage: / + aliases: , + area: + description: Enable the area super pickaxe pickaxe mode + usage: / + none: + description: Turn off all superpickaxe alternate modes + usage: / + bigtree: + description: Big tree generator tool + usage: / + pinetree: + description: Pine tree generator tool + usage: / + repl: + description: Block replacer tool + usage: / + brush: + description: Build spheres from far away + usage: / [radius] [no-replace?] + rbrush: + description: Brush tool that will only replace blocks + usage: / [radius] + recur: + description: Enable the recursive super pickaxe pickaxe mode + usage: / + info: + description: Block information tool + usage: / + single: + description: Enable the single block super pickaxe mode + usage: / + tree: + description: Tree generator tool + usage: / + /fillr: + description: Fill a hole recursively + usage: / [depth] + fixlava: + description: Fix lava to be stationary + usage: / + fixwater: + description: Fix water to be stationary + usage: / + removeabove: + description: Remove blocks above your head. + usage: / [size] [height] + removebelow: + description: Remove blocks below your head. + usage: / [size] [height] + removenear: + description: Remove blocks near you. + usage: / [size] + replacenear: + description: Replace nearby blocks + usage: / + snow: + description: Simulates snow + usage: / [radius] + thaw: + description: Thaws the area + usage: / [radius] + ex: + description: Extinguish nearby fire + usage: / [radius] + aliases: ext, extinguish + butcher: + description: Kill all or nearby mobs + usage: / [radius] + /fill: + description: Fill a hole + usage: / [depth] + /drain: + description: Drain a pool + usage: / diff --git a/src/com/sk89q/worldedit/dev/DocumentationPrinter.java b/src/com/sk89q/worldedit/dev/DocumentationPrinter.java index 00f6768de..087654961 100644 --- a/src/com/sk89q/worldedit/dev/DocumentationPrinter.java +++ b/src/com/sk89q/worldedit/dev/DocumentationPrinter.java @@ -21,14 +21,30 @@ package com.sk89q.worldedit.dev; import java.io.*; import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.List; +import com.sk89q.util.StringUtil; import com.sk89q.util.commands.Command; import com.sk89q.worldedit.commands.CommandPermissions; public class DocumentationPrinter { - public static void main(String[] args) { + public static void main(String[] args) throws IOException { File commandsDir = new File(args[0]); - for (File f : commandsDir.listFiles()) { + List> commandClasses = getCommandClasses(commandsDir); + + System.out.println("Writing permissions wiki table..."); + writePermissionsWikiTable(commandClasses); + System.out.println("Writing Bukkit plugin.yml..."); + writeBukkitYAML(commandClasses); + + System.out.println("Done!"); + } + + private static List> getCommandClasses(File dir) { + List> classes = new ArrayList>(); + + for (File f : dir.listFiles()) { if (!f.getName().matches("^.*\\.java$")) { continue; } @@ -43,18 +59,42 @@ public class DocumentationPrinter { } catch (ClassNotFoundException e) { continue; } - + + classes.add(cls); + } + + return classes; + } + + private static void writePermissionsWikiTable(List> commandClasses) + throws IOException { + FileOutputStream stream = null; + try { + stream = new FileOutputStream("wiki_permissions.txt"); + PrintStream print = new PrintStream(stream); + _writePermissionsWikiTable(print, commandClasses); + } finally { + if (stream != null) { + stream.close(); + } + } + } + + private static void _writePermissionsWikiTable(PrintStream stream, + List> commandClasses) { + + for (Class cls : commandClasses) { for (Method method : cls.getMethods()) { if (!method.isAnnotationPresent(Command.class)) { continue; } - + Command cmd = method.getAnnotation(Command.class); - - System.out.println("|-"); - System.out.print("| " + cmd.aliases()[0]); - System.out.print(" || "); - + + stream.println("|-"); + stream.print("| " + cmd.aliases()[0]); + stream.print(" || "); + if (method.isAnnotationPresent(CommandPermissions.class)) { CommandPermissions perms = method.getAnnotation(CommandPermissions.class); @@ -62,13 +102,56 @@ public class DocumentationPrinter { String[] permKeys = perms.value(); for (int i = 0; i < permKeys.length; i++) { if (i > 0) { - System.out.print(", "); + stream.print(", "); } - System.out.print(permKeys[i]); + stream.print(permKeys[i]); } } + + stream.println(); + } + } + } + + private static void writeBukkitYAML(List> commandClasses) + throws IOException { + FileOutputStream stream = null; + try { + stream = new FileOutputStream("plugin.yml"); + PrintStream print = new PrintStream(stream); + _writeBukkitYAML(print, commandClasses); + } finally { + if (stream != null) { + stream.close(); + } + } + } + + private static void _writeBukkitYAML(PrintStream stream, + List> commandClasses) { - System.out.println(); + stream.println("name: WorldEdit"); + stream.println("main: com.sk89q.worldedit.bukkit.WorldEditPlugin"); + stream.println("version: \"WEVERSIONMACRO\""); + stream.println("commands:"); + + for (Class cls : commandClasses) { + for (Method method : cls.getMethods()) { + if (!method.isAnnotationPresent(Command.class)) { + continue; + } + + Command cmd = method.getAnnotation(Command.class); + + stream.println(" " + cmd.aliases()[0] + ":"); + stream.println(" description: " + cmd.desc()); + stream.println(" usage: / " + + (cmd.flags().length() > 0 ? "[-" + cmd.flags() + "] " : "") + + cmd.usage()); + if (cmd.aliases().length > 1) { + stream.println(" aliases: " + + StringUtil.joinString(cmd.aliases(), ", ", 1)); + } } } }