mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-24 10:17:39 +00:00
Improved the permissions list printer to handle nested commands.
This commit is contained in:
parent
b2547b2156
commit
35ae72e8b7
@ -22,9 +22,11 @@ package com.sk89q.worldedit.dev;
|
|||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import com.sk89q.minecraft.util.commands.Command;
|
import com.sk89q.minecraft.util.commands.Command;
|
||||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||||
|
import com.sk89q.minecraft.util.commands.NestedCommand;
|
||||||
import com.sk89q.util.StringUtil;
|
import com.sk89q.util.StringUtil;
|
||||||
import com.sk89q.worldedit.commands.ChunkCommands;
|
import com.sk89q.worldedit.commands.ChunkCommands;
|
||||||
import com.sk89q.worldedit.commands.ClipboardCommands;
|
import com.sk89q.worldedit.commands.ClipboardCommands;
|
||||||
@ -99,7 +101,7 @@ public class DocumentationPrinter {
|
|||||||
try {
|
try {
|
||||||
stream = new FileOutputStream("wiki_permissions.txt");
|
stream = new FileOutputStream("wiki_permissions.txt");
|
||||||
PrintStream print = new PrintStream(stream);
|
PrintStream print = new PrintStream(stream);
|
||||||
_writePermissionsWikiTable(print, commandClasses);
|
_writePermissionsWikiTable(print, commandClasses, "/");
|
||||||
} finally {
|
} finally {
|
||||||
if (stream != null) {
|
if (stream != null) {
|
||||||
stream.close();
|
stream.close();
|
||||||
@ -108,7 +110,7 @@ public class DocumentationPrinter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void _writePermissionsWikiTable(PrintStream stream,
|
private static void _writePermissionsWikiTable(PrintStream stream,
|
||||||
List<Class<?>> commandClasses) {
|
List<Class<?>> commandClasses, String prefix) {
|
||||||
|
|
||||||
for (Class<?> cls : commandClasses) {
|
for (Class<?> cls : commandClasses) {
|
||||||
for (Method method : cls.getMethods()) {
|
for (Method method : cls.getMethods()) {
|
||||||
@ -119,7 +121,7 @@ public class DocumentationPrinter {
|
|||||||
Command cmd = method.getAnnotation(Command.class);
|
Command cmd = method.getAnnotation(Command.class);
|
||||||
|
|
||||||
stream.println("|-");
|
stream.println("|-");
|
||||||
stream.print("| /" + cmd.aliases()[0]);
|
stream.print("| " + prefix + cmd.aliases()[0]);
|
||||||
stream.print(" || ");
|
stream.print(" || ");
|
||||||
|
|
||||||
if (method.isAnnotationPresent(CommandPermissions.class)) {
|
if (method.isAnnotationPresent(CommandPermissions.class)) {
|
||||||
@ -136,6 +138,16 @@ public class DocumentationPrinter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
stream.println();
|
stream.println();
|
||||||
|
|
||||||
|
if (method.isAnnotationPresent(NestedCommand.class)) {
|
||||||
|
NestedCommand nested =
|
||||||
|
method.getAnnotation(NestedCommand.class);
|
||||||
|
|
||||||
|
Class<?>[] nestedClasses = nested.value();
|
||||||
|
_writePermissionsWikiTable(stream,
|
||||||
|
Arrays.asList(nestedClasses),
|
||||||
|
prefix + cmd.aliases()[0] + " ");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user