Added nested command support.

This commit is contained in:
sk89q
2011-02-01 02:03:18 -08:00
parent 78c78fee1f
commit 01f7be3ba3
5 changed files with 262 additions and 51 deletions

View File

@ -18,6 +18,8 @@
package com.sk89q.util;
import java.util.List;
/**
* String utilities.
*
@ -133,4 +135,24 @@ public class StringUtil {
}
return buffer.toString();
}
/**
* Join an list of strings into a string.
*
* @param str
* @param delimiter
* @param initialIndex
* @return
*/
public static String joinString(List<String> str, String delimiter,
int initialIndex) {
if (str.size() == 0) {
return "";
}
StringBuilder buffer = new StringBuilder(str.get(initialIndex).toString());
for (int i = initialIndex + 1; i < str.size(); i++) {
buffer.append(delimiter).append(str.get(i).toString());
}
return buffer.toString();
}
}

View File

@ -24,9 +24,9 @@ import java.lang.annotation.RetentionPolicy;
@Retention(RetentionPolicy.RUNTIME)
public @interface Command {
String[] aliases();
String usage();
String usage() default "";
String desc();
int min();
int max();
int min() default 0;
int max() default -1;
String flags() default "";
}

View File

@ -0,0 +1,28 @@
// $Id$
/*
* WorldEdit
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.util.commands;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@Retention(RetentionPolicy.RUNTIME)
public @interface NestedCommand {
Class<?>[] value();
}