Framework adjustment
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package io.izzel.taboolib.module.command;
|
||||
|
||||
import io.izzel.taboolib.TabooLibAPI;
|
||||
import io.izzel.taboolib.module.command.base.BaseCommand;
|
||||
import io.izzel.taboolib.module.locale.TLocale;
|
||||
import io.izzel.taboolib.module.command.base.BaseMainCommand;
|
||||
import io.izzel.taboolib.module.inject.TFunction;
|
||||
@@ -107,7 +108,7 @@ public class TCommandHandler {
|
||||
* @param baseMainCommand 命令对象
|
||||
* @return {@link BaseMainCommand}
|
||||
*/
|
||||
public static BaseMainCommand registerCommand(TCommand tCommand, String command, BaseMainCommand baseMainCommand, Plugin plugin) {
|
||||
public static BaseMainCommand registerCommand(BaseCommand tCommand, String command, BaseMainCommand baseMainCommand, Plugin plugin) {
|
||||
if (Bukkit.getPluginCommand(command) == null) {
|
||||
registerPluginCommand(
|
||||
plugin,
|
||||
@@ -129,8 +130,8 @@ public class TCommandHandler {
|
||||
*/
|
||||
public static void registerCommand(Plugin plugin) {
|
||||
for (Class pluginClass : Files.getClasses(plugin)) {
|
||||
if (BaseMainCommand.class.isAssignableFrom(pluginClass) && pluginClass.isAnnotationPresent(TCommand.class)) {
|
||||
TCommand tCommand = (TCommand) pluginClass.getAnnotation(TCommand.class);
|
||||
if (BaseMainCommand.class.isAssignableFrom(pluginClass) && pluginClass.isAnnotationPresent(BaseCommand.class)) {
|
||||
BaseCommand tCommand = (BaseCommand) pluginClass.getAnnotation(BaseCommand.class);
|
||||
try {
|
||||
registerCommand(tCommand, tCommand.name(), (BaseMainCommand) pluginClass.newInstance(), plugin);
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package io.izzel.taboolib.module.command;
|
||||
package io.izzel.taboolib.module.command.base;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
@@ -11,7 +11,7 @@ import java.lang.annotation.Target;
|
||||
*/
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface TCommand {
|
||||
public @interface BaseCommand {
|
||||
|
||||
String name();
|
||||
|
||||
@@ -13,7 +13,7 @@ import java.util.List;
|
||||
* @Since 2018-08-27 8:42
|
||||
* @BuilderLevel 1.0
|
||||
*/
|
||||
public class SimpleCommandBuilder {
|
||||
public class CommandBuilder {
|
||||
|
||||
public static final CompleterTab EMPTY_COMPLETER_TAB = ((sender, args) -> new ArrayList<>());
|
||||
public static final CompleterCommand EMPTY_COMPLETER_COMMAND = ((sender, args) -> {});
|
||||
@@ -30,7 +30,7 @@ public class SimpleCommandBuilder {
|
||||
private boolean forceRegister;
|
||||
private boolean build;
|
||||
|
||||
SimpleCommandBuilder(String command, Plugin plugin) {
|
||||
CommandBuilder(String command, Plugin plugin) {
|
||||
this.command = command;
|
||||
this.plugin = plugin;
|
||||
this.description = "";
|
||||
@@ -39,61 +39,61 @@ public class SimpleCommandBuilder {
|
||||
this.build = false;
|
||||
}
|
||||
|
||||
public static SimpleCommandBuilder create(String command, Plugin plugin) {
|
||||
return new SimpleCommandBuilder(command.toLowerCase(), plugin);
|
||||
public static CommandBuilder create(String command, Plugin plugin) {
|
||||
return new CommandBuilder(command.toLowerCase(), plugin);
|
||||
}
|
||||
|
||||
public SimpleCommandBuilder command(String command) {
|
||||
public CommandBuilder command(String command) {
|
||||
this.command = command;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SimpleCommandBuilder plugin(Plugin plugin) {
|
||||
public CommandBuilder plugin(Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SimpleCommandBuilder description(String description) {
|
||||
public CommandBuilder description(String description) {
|
||||
this.description = description;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SimpleCommandBuilder usage(String usage) {
|
||||
public CommandBuilder usage(String usage) {
|
||||
this.usage = usage;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SimpleCommandBuilder aliases(String... aliases) {
|
||||
public CommandBuilder aliases(String... aliases) {
|
||||
this.aliases = ArrayUtil.asList(aliases);
|
||||
return this;
|
||||
}
|
||||
|
||||
public SimpleCommandBuilder permission(String permission) {
|
||||
public CommandBuilder permission(String permission) {
|
||||
this.permission = permission;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SimpleCommandBuilder permissionMessage(String permissionMessage) {
|
||||
public CommandBuilder permissionMessage(String permissionMessage) {
|
||||
this.permissionMessage = permissionMessage;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SimpleCommandBuilder execute(CompleterCommand completerCommand) {
|
||||
public CommandBuilder execute(CompleterCommand completerCommand) {
|
||||
this.completerCommand = completerCommand;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SimpleCommandBuilder tab(CompleterTab completerTab) {
|
||||
public CommandBuilder tab(CompleterTab completerTab) {
|
||||
this.completerTab = completerTab;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SimpleCommandBuilder forceRegister() {
|
||||
public CommandBuilder forceRegister() {
|
||||
this.forceRegister = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SimpleCommandBuilder build() {
|
||||
public CommandBuilder build() {
|
||||
Preconditions.checkNotNull(plugin, "缺少 \"plugin\" 部分");
|
||||
Preconditions.checkNotNull(command, "缺少 \"command\" 部分");
|
||||
Preconditions.checkNotNull(completerCommand, "缺少 \"CompleterCommand\" 部分");
|
||||
Reference in New Issue
Block a user