From 5fc994bfb5a98ae04a4a02f0c9ae541172ad888c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=9D=8F=E9=BB=91?= Date: Sat, 6 Jul 2019 22:55:55 +0800 Subject: [PATCH] Fix --- .../command/TabooLibExecuteCommand.java | 37 +- .../common/command/TabooLibLocaleCommand.java | 19 +- .../common/command/TabooLibPluginCommand.java | 37 +- .../{CommandArgument.java => Argument.java} | 17 +- .../module/command/base/BaseCommand.java | 2 +- .../module/command/base/BaseMainCommand.java | 15 +- .../module/command/base/BaseSubCommand.java | 4 +- .../{CommandRegister.java => SubCommand.java} | 2 +- .../util/eagletdl/AlreadyStartException.java | 5 - .../taboolib/util/eagletdl/CompleteEvent.java | 19 - .../util/eagletdl/ConnectedEvent.java | 27 - .../DoNotSupportMultipleThreadException.java | 4 - .../taboolib/util/eagletdl/EagletHandler.java | 8 - .../taboolib/util/eagletdl/EagletTask.java | 477 ------------------ .../taboolib/util/eagletdl/ErrorEvent.java | 20 - .../util/eagletdl/HashNotMatchException.java | 4 - .../taboolib/util/eagletdl/HashUtil.java | 63 --- .../taboolib/util/eagletdl/ProgressEvent.java | 53 -- .../util/eagletdl/RetryFailedException.java | 14 - .../util/eagletdl/SingleThreadDownload.java | 49 -- .../taboolib/util/eagletdl/SplitDownload.java | 92 ---- .../taboolib/util/eagletdl/StartEvent.java | 14 - .../io/izzel/taboolib/util/lite/Logs.java | 34 +- .../taboolib/util/serialize/TSerializer.java | 1 - 24 files changed, 85 insertions(+), 932 deletions(-) rename src/main/scala/io/izzel/taboolib/module/command/base/{CommandArgument.java => Argument.java} (77%) rename src/main/scala/io/izzel/taboolib/module/command/base/{CommandRegister.java => SubCommand.java} (91%) delete mode 100644 src/main/scala/io/izzel/taboolib/util/eagletdl/AlreadyStartException.java delete mode 100644 src/main/scala/io/izzel/taboolib/util/eagletdl/CompleteEvent.java delete mode 100644 src/main/scala/io/izzel/taboolib/util/eagletdl/ConnectedEvent.java delete mode 100644 src/main/scala/io/izzel/taboolib/util/eagletdl/DoNotSupportMultipleThreadException.java delete mode 100644 src/main/scala/io/izzel/taboolib/util/eagletdl/EagletHandler.java delete mode 100644 src/main/scala/io/izzel/taboolib/util/eagletdl/EagletTask.java delete mode 100644 src/main/scala/io/izzel/taboolib/util/eagletdl/ErrorEvent.java delete mode 100644 src/main/scala/io/izzel/taboolib/util/eagletdl/HashNotMatchException.java delete mode 100644 src/main/scala/io/izzel/taboolib/util/eagletdl/HashUtil.java delete mode 100644 src/main/scala/io/izzel/taboolib/util/eagletdl/ProgressEvent.java delete mode 100644 src/main/scala/io/izzel/taboolib/util/eagletdl/RetryFailedException.java delete mode 100644 src/main/scala/io/izzel/taboolib/util/eagletdl/SingleThreadDownload.java delete mode 100644 src/main/scala/io/izzel/taboolib/util/eagletdl/SplitDownload.java delete mode 100644 src/main/scala/io/izzel/taboolib/util/eagletdl/StartEvent.java diff --git a/src/main/scala/io/izzel/taboolib/common/command/TabooLibExecuteCommand.java b/src/main/scala/io/izzel/taboolib/common/command/TabooLibExecuteCommand.java index 99281ce..950dc10 100644 --- a/src/main/scala/io/izzel/taboolib/common/command/TabooLibExecuteCommand.java +++ b/src/main/scala/io/izzel/taboolib/common/command/TabooLibExecuteCommand.java @@ -5,8 +5,8 @@ import io.izzel.taboolib.module.locale.TLocale; import io.izzel.taboolib.module.command.base.BaseMainCommand; import io.izzel.taboolib.module.command.base.BaseSubCommand; import io.izzel.taboolib.module.command.base.BaseCommand; -import io.izzel.taboolib.module.command.base.CommandArgument; -import io.izzel.taboolib.module.command.base.CommandRegister; +import io.izzel.taboolib.module.command.base.Argument; +import io.izzel.taboolib.module.command.base.SubCommand; import io.izzel.taboolib.util.ArrayUtil; import org.bukkit.Bukkit; import org.bukkit.command.Command; @@ -18,8 +18,7 @@ import org.bukkit.entity.Player; * @Since 2018-07-04 21:32 */ @BaseCommand( - name = "taboolibexecute", - aliases = {"texecute"}, + name = "tExecute", permission = "taboolib.admin" ) public class TabooLibExecuteCommand extends BaseMainCommand { @@ -29,7 +28,7 @@ public class TabooLibExecuteCommand extends BaseMainCommand { return TLocale.asString("COMMANDS.TEXECUTE.COMMAND-TITLE"); } - @CommandRegister(priority = 1) + @SubCommand(priority = 1) BaseSubCommand chat = new BaseSubCommand() { @Override @@ -43,10 +42,10 @@ public class TabooLibExecuteCommand extends BaseMainCommand { } @Override - public CommandArgument[] getArguments() { - return new CommandArgument[] { - new CommandArgument(TLocale.asString("COMMANDS.TEXECUTE.CHAT.ARGUMENTS.0")), - new CommandArgument(TLocale.asString("COMMANDS.TEXECUTE.CHAT.ARGUMENTS.1")) + public Argument[] getArguments() { + return new Argument[] { + new Argument(TLocale.asString("COMMANDS.TEXECUTE.CHAT.ARGUMENTS.0")), + new Argument(TLocale.asString("COMMANDS.TEXECUTE.CHAT.ARGUMENTS.1")) }; } @@ -61,7 +60,7 @@ public class TabooLibExecuteCommand extends BaseMainCommand { } }; - @CommandRegister(priority = 1) + @SubCommand(priority = 1) BaseSubCommand command = new BaseSubCommand() { @Override public String getLabel() { @@ -79,10 +78,10 @@ public class TabooLibExecuteCommand extends BaseMainCommand { } @Override - public CommandArgument[] getArguments() { - return new CommandArgument[] { - new CommandArgument(TLocale.asString("COMMANDS.TEXECUTE.COMMAND.ARGUMENTS.0")), - new CommandArgument(TLocale.asString("COMMANDS.TEXECUTE.COMMAND.ARGUMENTS.1")) + public Argument[] getArguments() { + return new Argument[] { + new Argument(TLocale.asString("COMMANDS.TEXECUTE.COMMAND.ARGUMENTS.0")), + new Argument(TLocale.asString("COMMANDS.TEXECUTE.COMMAND.ARGUMENTS.1")) }; } @@ -101,7 +100,7 @@ public class TabooLibExecuteCommand extends BaseMainCommand { } }; - @CommandRegister(priority = 2) + @SubCommand(priority = 2) BaseSubCommand commandAsOp = new BaseSubCommand() { @Override @@ -120,10 +119,10 @@ public class TabooLibExecuteCommand extends BaseMainCommand { } @Override - public CommandArgument[] getArguments() { - return new CommandArgument[] { - new CommandArgument(TLocale.asString("COMMANDS.TEXECUTE.COMMAND-AS-OP.ARGUMENTS.0")), - new CommandArgument(TLocale.asString("COMMANDS.TEXECUTE.COMMAND-AS-OP.ARGUMENTS.1")) + public Argument[] getArguments() { + return new Argument[] { + new Argument(TLocale.asString("COMMANDS.TEXECUTE.COMMAND-AS-OP.ARGUMENTS.0")), + new Argument(TLocale.asString("COMMANDS.TEXECUTE.COMMAND-AS-OP.ARGUMENTS.1")) }; } diff --git a/src/main/scala/io/izzel/taboolib/common/command/TabooLibLocaleCommand.java b/src/main/scala/io/izzel/taboolib/common/command/TabooLibLocaleCommand.java index 3f16b73..6372296 100644 --- a/src/main/scala/io/izzel/taboolib/common/command/TabooLibLocaleCommand.java +++ b/src/main/scala/io/izzel/taboolib/common/command/TabooLibLocaleCommand.java @@ -5,8 +5,8 @@ import io.izzel.taboolib.module.locale.TLocaleLoader; import io.izzel.taboolib.module.command.base.BaseMainCommand; import io.izzel.taboolib.module.command.base.BaseSubCommand; import io.izzel.taboolib.module.command.base.BaseCommand; -import io.izzel.taboolib.module.command.base.CommandArgument; -import io.izzel.taboolib.module.command.base.CommandRegister; +import io.izzel.taboolib.module.command.base.Argument; +import io.izzel.taboolib.module.command.base.SubCommand; import org.bukkit.Bukkit; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; @@ -22,8 +22,7 @@ import java.util.stream.IntStream; * @since 2018-04-22 14:36:28 */ @BaseCommand( - name = "tabooliblocale", - aliases = {"taboolocale", "tlocale"}, + name = "tLocale", permission = "taboolib.admin" ) public class TabooLibLocaleCommand extends BaseMainCommand { @@ -33,7 +32,7 @@ public class TabooLibLocaleCommand extends BaseMainCommand { return TLocale.asString("COMMANDS.TLOCALE.COMMAND-TITLE"); } - @CommandRegister + @SubCommand BaseSubCommand send = new BaseSubCommand() { @Override @@ -47,11 +46,11 @@ public class TabooLibLocaleCommand extends BaseMainCommand { } @Override - public CommandArgument[] getArguments() { - return new CommandArgument[] { - new CommandArgument(TLocale.asString("COMMANDS.TLOCALE.SEND.ARGUMENTS.0")), - new CommandArgument(TLocale.asString("COMMANDS.TLOCALE.SEND.ARGUMENTS.1")), - new CommandArgument(TLocale.asString("COMMANDS.TLOCALE.SEND.ARGUMENTS.2"), false) + public Argument[] getArguments() { + return new Argument[] { + new Argument(TLocale.asString("COMMANDS.TLOCALE.SEND.ARGUMENTS.0")), + new Argument(TLocale.asString("COMMANDS.TLOCALE.SEND.ARGUMENTS.1")), + new Argument(TLocale.asString("COMMANDS.TLOCALE.SEND.ARGUMENTS.2"), false) }; } diff --git a/src/main/scala/io/izzel/taboolib/common/command/TabooLibPluginCommand.java b/src/main/scala/io/izzel/taboolib/common/command/TabooLibPluginCommand.java index 8035b93..bce9e16 100644 --- a/src/main/scala/io/izzel/taboolib/common/command/TabooLibPluginCommand.java +++ b/src/main/scala/io/izzel/taboolib/common/command/TabooLibPluginCommand.java @@ -6,8 +6,8 @@ import io.izzel.taboolib.module.locale.TLocale; import io.izzel.taboolib.module.command.base.BaseCommand; import io.izzel.taboolib.module.command.base.BaseMainCommand; import io.izzel.taboolib.module.command.base.BaseSubCommand; -import io.izzel.taboolib.module.command.base.CommandArgument; -import io.izzel.taboolib.module.command.base.CommandRegister; +import io.izzel.taboolib.module.command.base.Argument; +import io.izzel.taboolib.module.command.base.SubCommand; import io.izzel.taboolib.util.plugin.PluginLoadState; import io.izzel.taboolib.util.plugin.PluginLoadStateType; import io.izzel.taboolib.util.plugin.PluginUnloadState; @@ -27,8 +27,7 @@ import java.util.stream.Collectors; * @Since 2018-05-07 20:14 */ @BaseCommand( - name = "taboolibplugin", - aliases = {"tabooplugin", "tplugin"}, + name = "tPlugin", permission = "taboolib.admin" ) public class TabooLibPluginCommand extends BaseMainCommand { @@ -38,7 +37,7 @@ public class TabooLibPluginCommand extends BaseMainCommand { return TLocale.asString("COMMANDS.TPLUGIN.COMMAND-TITLE"); } - @CommandRegister(priority = 1) + @SubCommand(priority = 1) BaseSubCommand load = new BaseSubCommand() { @Override @@ -52,8 +51,8 @@ public class TabooLibPluginCommand extends BaseMainCommand { } @Override - public CommandArgument[] getArguments() { - return new CommandArgument[] {new CommandArgument(TLocale.asString("COMMANDS.TPLUGIN.LOAD.ARGUMENTS.0"), true)}; + public Argument[] getArguments() { + return new Argument[] {new Argument(TLocale.asString("COMMANDS.TPLUGIN.LOAD.ARGUMENTS.0"), true)}; } @Override @@ -88,7 +87,7 @@ public class TabooLibPluginCommand extends BaseMainCommand { } }; - @CommandRegister(priority = 2) + @SubCommand(priority = 2) BaseSubCommand unload = new BaseSubCommand() { @Override @@ -102,8 +101,8 @@ public class TabooLibPluginCommand extends BaseMainCommand { } @Override - public CommandArgument[] getArguments() { - return new CommandArgument[] {new CommandArgument(TLocale.asString("COMMANDS.TPLUGIN.UNLOAD.ARGUMENTS.0"), true, () -> { + public Argument[] getArguments() { + return new Argument[] {new Argument(TLocale.asString("COMMANDS.TPLUGIN.UNLOAD.ARGUMENTS.0"), true, () -> { return java.util.Arrays.stream(Bukkit.getPluginManager().getPlugins()).map(Plugin::getName).collect(Collectors.toList()); })}; } @@ -132,7 +131,7 @@ public class TabooLibPluginCommand extends BaseMainCommand { } }; - @CommandRegister(priority = 3) + @SubCommand(priority = 3) BaseSubCommand reload = new BaseSubCommand() { @Override @@ -146,8 +145,8 @@ public class TabooLibPluginCommand extends BaseMainCommand { } @Override - public CommandArgument[] getArguments() { - return new CommandArgument[] {new CommandArgument(TLocale.asString("COMMANDS.TPLUGIN.RELOAD.ARGUMENTS.0"), true, () -> { + public Argument[] getArguments() { + return new Argument[] {new Argument(TLocale.asString("COMMANDS.TPLUGIN.RELOAD.ARGUMENTS.0"), true, () -> { return Arrays.stream(Bukkit.getPluginManager().getPlugins()).map(Plugin::getName).collect(Collectors.toList()); })}; } @@ -167,7 +166,7 @@ public class TabooLibPluginCommand extends BaseMainCommand { } }; - @CommandRegister(priority = 4) + @SubCommand(priority = 4) BaseSubCommand info = new BaseSubCommand() { @Override @@ -181,8 +180,8 @@ public class TabooLibPluginCommand extends BaseMainCommand { } @Override - public CommandArgument[] getArguments() { - return new CommandArgument[] {new CommandArgument(TLocale.asString("COMMANDS.TPLUGIN.INFO.ARGUMENTS.0"), true, () -> { + public Argument[] getArguments() { + return new Argument[] {new Argument(TLocale.asString("COMMANDS.TPLUGIN.INFO.ARGUMENTS.0"), true, () -> { return Arrays.stream(Bukkit.getPluginManager().getPlugins()).map(Plugin::getName).collect(Collectors.toList()); })}; } @@ -212,7 +211,7 @@ public class TabooLibPluginCommand extends BaseMainCommand { } }; - @CommandRegister(priority = 5) + @SubCommand(priority = 5) BaseSubCommand list = new BaseSubCommand() { @Override @@ -226,8 +225,8 @@ public class TabooLibPluginCommand extends BaseMainCommand { } @Override - public CommandArgument[] getArguments() { - return new CommandArgument[0]; + public Argument[] getArguments() { + return new Argument[0]; } @Override diff --git a/src/main/scala/io/izzel/taboolib/module/command/base/CommandArgument.java b/src/main/scala/io/izzel/taboolib/module/command/base/Argument.java similarity index 77% rename from src/main/scala/io/izzel/taboolib/module/command/base/CommandArgument.java rename to src/main/scala/io/izzel/taboolib/module/command/base/Argument.java index 75e0900..dae6c7e 100644 --- a/src/main/scala/io/izzel/taboolib/module/command/base/CommandArgument.java +++ b/src/main/scala/io/izzel/taboolib/module/command/base/Argument.java @@ -8,10 +8,13 @@ import java.util.Objects; * @author Bkm016 * @since 2018-04-17 */ -public class CommandArgument { +public class Argument { + // 参数名称 private String name; + // 是否必须 private boolean required; + // 参数补全 private CommandTab tab; public String getName() { @@ -26,19 +29,19 @@ public class CommandArgument { return tab; } - public CommandArgument(String name) { + public Argument(String name) { this(name, true); } - public CommandArgument(String name, CommandTab tab) { + public Argument(String name, CommandTab tab) { this(name, true, tab); } - public CommandArgument(String name, boolean required) { + public Argument(String name, boolean required) { this(name, required, null); } - public CommandArgument(String name, boolean required, CommandTab tab) { + public Argument(String name, boolean required, CommandTab tab) { this.name = name; this.required = required; this.tab = tab; @@ -54,10 +57,10 @@ public class CommandArgument { if (this == o) { return true; } - if (!(o instanceof CommandArgument)) { + if (!(o instanceof Argument)) { return false; } - CommandArgument that = (CommandArgument) o; + Argument that = (Argument) o; return isRequired() == that.isRequired() && Objects.equals(getName(), that.getName()) && Objects.equals(tab, that.tab); diff --git a/src/main/scala/io/izzel/taboolib/module/command/base/BaseCommand.java b/src/main/scala/io/izzel/taboolib/module/command/base/BaseCommand.java index cbc8db3..9bac631 100644 --- a/src/main/scala/io/izzel/taboolib/module/command/base/BaseCommand.java +++ b/src/main/scala/io/izzel/taboolib/module/command/base/BaseCommand.java @@ -23,5 +23,5 @@ public @interface BaseCommand { String usage() default ""; - String[] aliases() default ""; + String[] aliases() default {}; } \ No newline at end of file diff --git a/src/main/scala/io/izzel/taboolib/module/command/base/BaseMainCommand.java b/src/main/scala/io/izzel/taboolib/module/command/base/BaseMainCommand.java index 8e8f3fd..788c171 100644 --- a/src/main/scala/io/izzel/taboolib/module/command/base/BaseMainCommand.java +++ b/src/main/scala/io/izzel/taboolib/module/command/base/BaseMainCommand.java @@ -49,9 +49,9 @@ public abstract class BaseMainCommand implements CommandExecutor, TabExecutor { public static void loadCommandRegister(BaseMainCommand baseMainCommand) { List methods = new ArrayList<>(); List fields = new ArrayList<>(); - baseMainCommand.getLinkClasses().forEach(clazz -> java.util.Arrays.stream(clazz.getDeclaredMethods()).filter(method -> method.getAnnotation(CommandRegister.class) != null).forEach(methods::add)); + baseMainCommand.getLinkClasses().forEach(clazz -> java.util.Arrays.stream(clazz.getDeclaredMethods()).filter(method -> method.getAnnotation(SubCommand.class) != null).forEach(methods::add)); if (methods.size() > 0) { - methods.sort(Comparator.comparingDouble(a -> a.getAnnotation(CommandRegister.class).priority())); + methods.sort(Comparator.comparingDouble(a -> a.getAnnotation(SubCommand.class).priority())); methods.forEach(x -> { try { x.setAccessible(true); @@ -60,9 +60,9 @@ public abstract class BaseMainCommand implements CommandExecutor, TabExecutor { } }); } - baseMainCommand.getLinkClasses().forEach(clazz -> java.util.Arrays.stream(clazz.getDeclaredFields()).filter(field -> field.getAnnotation(CommandRegister.class) != null && field.getType().equals(io.izzel.taboolib.module.command.base.BaseSubCommand.class)).forEach(field -> fields.add(new CommandField(field, clazz)))); + baseMainCommand.getLinkClasses().forEach(clazz -> java.util.Arrays.stream(clazz.getDeclaredFields()).filter(field -> field.getAnnotation(SubCommand.class) != null && field.getType().equals(io.izzel.taboolib.module.command.base.BaseSubCommand.class)).forEach(field -> fields.add(new CommandField(field, clazz)))); if (fields.size() > 0) { - fields.sort(Comparator.comparingDouble(commandField -> commandField.getField().getAnnotation(CommandRegister.class).priority())); + fields.sort(Comparator.comparingDouble(commandField -> commandField.getField().getAnnotation(SubCommand.class).priority())); fields.forEach(commandField -> { try { commandField.getField().setAccessible(true); @@ -123,7 +123,7 @@ public abstract class BaseMainCommand implements CommandExecutor, TabExecutor { return label.stream().filter(l -> args[0].isEmpty() || l.toLowerCase().startsWith(args[0].toLowerCase())).collect(Collectors.toList()); } for (io.izzel.taboolib.module.command.base.BaseSubCommand subCommand : subCommands) { - CommandArgument[] arguments = subCommand.getArguments(); + Argument[] arguments = subCommand.getArguments(); if (args[0].equalsIgnoreCase(subCommand.getLabel()) && args.length - 1 <= arguments.length) { CommandTab commandTab = arguments[args.length - 2].getTab(); if (commandTab != null) { @@ -208,7 +208,10 @@ public abstract class BaseMainCommand implements CommandExecutor, TabExecutor { } private void disguisedPlugin() { - linkClasses.forEach(clazz -> disguisedPlugin(clazz, registerCommand.getPlugin())); + try { + linkClasses.forEach(clazz -> disguisedPlugin(clazz, registerCommand.getPlugin())); + } catch (Throwable ignored) { + } } private void disguisedPlugin(Class targetClass, Plugin plugin) { diff --git a/src/main/scala/io/izzel/taboolib/module/command/base/BaseSubCommand.java b/src/main/scala/io/izzel/taboolib/module/command/base/BaseSubCommand.java index f3b4303..6d6b40e 100644 --- a/src/main/scala/io/izzel/taboolib/module/command/base/BaseSubCommand.java +++ b/src/main/scala/io/izzel/taboolib/module/command/base/BaseSubCommand.java @@ -32,8 +32,8 @@ public abstract class BaseSubCommand { return new String[0]; } - public CommandArgument[] getArguments() { - return new CommandArgument[0]; + public Argument[] getArguments() { + return new Argument[0]; } public CommandType getType() { diff --git a/src/main/scala/io/izzel/taboolib/module/command/base/CommandRegister.java b/src/main/scala/io/izzel/taboolib/module/command/base/SubCommand.java similarity index 91% rename from src/main/scala/io/izzel/taboolib/module/command/base/CommandRegister.java rename to src/main/scala/io/izzel/taboolib/module/command/base/SubCommand.java index 5f2dbac..1d08471 100644 --- a/src/main/scala/io/izzel/taboolib/module/command/base/CommandRegister.java +++ b/src/main/scala/io/izzel/taboolib/module/command/base/SubCommand.java @@ -11,7 +11,7 @@ import java.lang.annotation.Target; */ @Target({ElementType.METHOD, ElementType.FIELD}) @Retention(RetentionPolicy.RUNTIME) -public @interface CommandRegister { +public @interface SubCommand { double priority() default 0; diff --git a/src/main/scala/io/izzel/taboolib/util/eagletdl/AlreadyStartException.java b/src/main/scala/io/izzel/taboolib/util/eagletdl/AlreadyStartException.java deleted file mode 100644 index 9db8106..0000000 --- a/src/main/scala/io/izzel/taboolib/util/eagletdl/AlreadyStartException.java +++ /dev/null @@ -1,5 +0,0 @@ -package io.izzel.taboolib.util.eagletdl; - -public class AlreadyStartException extends RuntimeException { - -} diff --git a/src/main/scala/io/izzel/taboolib/util/eagletdl/CompleteEvent.java b/src/main/scala/io/izzel/taboolib/util/eagletdl/CompleteEvent.java deleted file mode 100644 index 6163b3a..0000000 --- a/src/main/scala/io/izzel/taboolib/util/eagletdl/CompleteEvent.java +++ /dev/null @@ -1,19 +0,0 @@ -package io.izzel.taboolib.util.eagletdl; - -public class CompleteEvent { - private EagletTask task; - private boolean success; - - CompleteEvent(EagletTask task, boolean success) { - this.task = task; - this.success = success; - } - - public boolean isSuccess() { - return success; - } - - public EagletTask getTask() { - return task; - } -} diff --git a/src/main/scala/io/izzel/taboolib/util/eagletdl/ConnectedEvent.java b/src/main/scala/io/izzel/taboolib/util/eagletdl/ConnectedEvent.java deleted file mode 100644 index 3185b26..0000000 --- a/src/main/scala/io/izzel/taboolib/util/eagletdl/ConnectedEvent.java +++ /dev/null @@ -1,27 +0,0 @@ -package io.izzel.taboolib.util.eagletdl; - -public class ConnectedEvent { - - private long contentLength; - private EagletTask task; - - public ConnectedEvent(long length, EagletTask task) { - this.contentLength = length; - this.task = task; - } - - /** - * Get the length of the download task. - *

- * If the length is -1, this task cannot be downloaded in multiple threads. - * - * @return length - */ - public long getContentLength() { - return contentLength; - } - - public EagletTask getTask() { - return task; - } -} diff --git a/src/main/scala/io/izzel/taboolib/util/eagletdl/DoNotSupportMultipleThreadException.java b/src/main/scala/io/izzel/taboolib/util/eagletdl/DoNotSupportMultipleThreadException.java deleted file mode 100644 index 654fdd5..0000000 --- a/src/main/scala/io/izzel/taboolib/util/eagletdl/DoNotSupportMultipleThreadException.java +++ /dev/null @@ -1,4 +0,0 @@ -package io.izzel.taboolib.util.eagletdl; - -public class DoNotSupportMultipleThreadException extends RuntimeException { -} diff --git a/src/main/scala/io/izzel/taboolib/util/eagletdl/EagletHandler.java b/src/main/scala/io/izzel/taboolib/util/eagletdl/EagletHandler.java deleted file mode 100644 index e3eb230..0000000 --- a/src/main/scala/io/izzel/taboolib/util/eagletdl/EagletHandler.java +++ /dev/null @@ -1,8 +0,0 @@ -package io.izzel.taboolib.util.eagletdl; - -@FunctionalInterface -public interface EagletHandler { - - void handle(T event) ; - -} diff --git a/src/main/scala/io/izzel/taboolib/util/eagletdl/EagletTask.java b/src/main/scala/io/izzel/taboolib/util/eagletdl/EagletTask.java deleted file mode 100644 index 394b620..0000000 --- a/src/main/scala/io/izzel/taboolib/util/eagletdl/EagletTask.java +++ /dev/null @@ -1,477 +0,0 @@ -package io.izzel.taboolib.util.eagletdl; - -import io.izzel.taboolib.util.Files; - -import java.io.File; -import java.net.HttpURLConnection; -import java.net.MalformedURLException; -import java.net.Proxy; -import java.net.URL; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.locks.ReentrantLock; - -public class EagletTask { - - private ReentrantLock lock = new ReentrantLock(); - - Map httpHeader = new ConcurrentHashMap<>(); - - private URL url; - - EagletHandler onError = event -> event.getException().printStackTrace(); - - private EagletHandler onStart; - - private EagletHandler onComplete; - - private EagletHandler onConnected; - - private EagletHandler onProgress; - - private Proxy proxy; - - private String md5, sha1, sha256; - - String requestMethod = "GET"; - - private int threadAmount = 1; - - int connectionTimeout = 7000; - int readTimeout = 7000; - int maxRetry = 5; - - private File dest; - - private transient boolean running = false; - private transient long contentLength, maxBlockingTime = 7000; - private transient ExecutorService executorService; - private transient Thread monitor; - - public EagletTask() { - } - - /** - * Stop this task forcefully, and the target file will not be removed. - */ - public void stop() { - executorService.shutdownNow(); - monitor.interrupt(); - } - - /** - * Start the download file - *

- * 开始下载文件 - */ - public EagletTask start() { - // create thread pool for download - executorService = Executors.newFixedThreadPool(threadAmount); - // check if is already running - if (running) { - throw new AlreadyStartException(); - } - // start the monitor thread - monitor = new Thread(() -> { - lock.lock(); - // fire a new start event - if (onStart != null) { - onStart.handle(new StartEvent(this)); - } - try { - // create the target file - Files.file(dest); - HttpURLConnection connection = (HttpURLConnection) url.openConnection(); - // set the connection properties - httpHeader.forEach(connection::addRequestProperty); - connection.setRequestMethod(requestMethod); - connection.setConnectTimeout(30000); - connection.setReadTimeout(30000); - connection.connect(); - contentLength = connection.getContentLengthLong(); - // fire a new connected event - // contains connection properties - if (onConnected != null) { - onConnected.handle(new ConnectedEvent(contentLength, this)); - } - // if this is an unknown length task - if (contentLength == -1 || threadAmount == 1) { - // pass the connection instance to this new thread - SingleThreadDownload download = new SingleThreadDownload(connection, dest, this); - executorService.execute(download); - long last = 0; - do { - Thread.sleep(500); - // check the progress - long progress = download.getCurrentProgress(); - // fire a new progress event - if (onProgress != null) { - onProgress.handle(new ProgressEvent(progress - last < 0 ? 0 : progress - last, this, ((double) progress) / Math.max((double) contentLength, 0D))); - } - last = progress; - // check complete - } while (last != contentLength && !download.isComplete()); - // close the thread pool, DoNotSupportMultipleThreadExceptionrelease resources - executorService.shutdown(); - // change the running flag to false - running = false; - } else { - List splitDownloads = new ArrayList<>(); - // Assign download task length - long blockSize = contentLength / threadAmount; - for (int threadId = 0; threadId < threadAmount; threadId++) { - long startIndex = threadId * blockSize; - long endIndex = (threadId + 1) * blockSize - 1; - if (threadId == (threadAmount - 1)) { - endIndex = contentLength - 1; - } - SplitDownload download = new SplitDownload(url, startIndex, endIndex, dest, this); - // Start downloading - executorService.execute(download); - splitDownloads.add(download); - } - long last = 0; - do { - Thread.sleep(500); - long progress = 0; - // Collect download progress - for (SplitDownload splitDownload : splitDownloads) { - progress += splitDownload.getCurrentIndex() - splitDownload.startIndex; - // blocked then restart from current index - if (!splitDownload.isComplete() && System.currentTimeMillis() - splitDownload.getLastUpdateTime() > maxBlockingTime) { - splitDownload.setStartIndex(splitDownload.getCurrentIndex()); - if (splitDownload.getRetry() <= maxRetry) { - executorService.execute(splitDownload); - } else { - throw new RetryFailedException(this); - } - } - } - // Fire a progress event - if (onProgress != null) { - onProgress.handle(new ProgressEvent(progress - last, this, - ((double) progress) / ((double) contentLength))); - } - last = progress; - // check complete - } while (last < contentLength); - // close the thread pool, release resources - executorService.shutdown(); - // change the running flag to false - running = false; - } - // check hash - if (md5 != null && !md5.equalsIgnoreCase(HashUtil.md5(dest))) { - throw new HashNotMatchException(); - } - if (sha1 != null && !sha1.equalsIgnoreCase(HashUtil.sha1(dest))) { - throw new HashNotMatchException(); - } - if (sha256 != null && !sha256.equalsIgnoreCase(HashUtil.sha256(dest))) { - throw new HashNotMatchException(); - } - if (onComplete != null) { - onComplete.handle(new CompleteEvent(this, true)); - } - } catch (Exception e) { - onError.handle(new ErrorEvent(e, this)); - executorService.shutdown(); - if (onComplete != null) { - onComplete.handle(new CompleteEvent(this, false)); - } - } finally { - lock.unlock(); - } - }, "EagletTaskMonitor"); - monitor.start(); - return this; - } - - public EagletTask waitUntil() { - while (lock.tryLock()) { - lock.unlock(); - } - lock.lock(); - lock.unlock(); - return this; - } - - public EagletTask waitFor(long timeout, TimeUnit unit) { - while (lock.tryLock()) { - lock.unlock(); - } - try { - lock.tryLock(timeout, unit); - } catch (InterruptedException e) { - e.printStackTrace(); - } - return this; - } - - public EagletTask maxRetry(int maxRetry) { - this.maxRetry = maxRetry; - return this; - } - - /** - * Set the sha256 hash of the download file. Case is not sensitive. - *

- * If the hash check failed, an error event will be fired. - * - * @param sha256 file sha1 - * @return task instance - */ - public EagletTask sha256(String sha256) { - this.sha256 = sha256; - return this; - } - - /** - * Set the sha1 hash of the download file. Case is not sensitive. - *

- * If the hash check failed, an error event will be fired. - * - * @param sha1 file sha1 - * @return task instance - */ - public EagletTask sha1(String sha1) { - this.sha1 = sha1; - return this; - } - - /** - * Set the md5 hash of the download file. Case is not sensitive. - *

- * If the hash check failed, an error event will be fired. - * - * @param md5 file md5 - * @return task instance - */ - public EagletTask md5(String md5) { - this.md5 = md5; - return this; - } - - /** - * Set the max blocked time per download thread. - *

- * If the thread blocks exceeded the provided time, this thread will re-start the task. - * - * @param maxBlockingTime time - * @return task instance - */ - private EagletTask maxBlocking(long maxBlockingTime) { - this.maxBlockingTime = maxBlockingTime; - return this; - } - - /** - * Set the progress handler - *

- * This handler will be called every 1000 milli seconds. - *

- * 设置处理进度的时间监听器。该监听器的 handle 方法每秒调用一次。 - * - * @param onProgress handler - * @return task instance - */ - public EagletTask setOnProgress(EagletHandler onProgress) { - this.onProgress = onProgress; - return this; - } - - /** - * Set the download file - * - * @param file the file's absolute path - * @return task instance - */ - public EagletTask file(String file) { - this.dest = new File(file); - return this; - } - - /** - * Set the download file - * - * @param file the file - * @return task instance - */ - public EagletTask file(File file) { - this.dest = file; - return this; - } - - /** - * Set the connected handler - *

- * This will be called when the connection is established - *

- * Async call - * - * @param onConnected onConnected event handler - * @return task instance - */ - public EagletTask setOnConnected(EagletHandler onConnected) { - this.onConnected = onConnected; - return this; - } - - /** - * Set the read timeout, default is 7000 - * - * @param timeout timeout - * @return task instance - */ - public EagletTask readTimeout(int timeout) { - this.readTimeout = timeout; - return this; - } - - /** - * Set the connection timeout, default is 7000 - * - * @param timeout timeout - * @return task instance - */ - public EagletTask connectionTimeout(int timeout) { - this.connectionTimeout = timeout; - return this; - } - - /** - * Set the request method, default is GET - * - * @param requestMethod the request method - * @return task instance - */ - public EagletTask requestMethod(String requestMethod) { - this.requestMethod = requestMethod; - return this; - } - - /** - * Set the complete event handler - *

- * This handler will be called when everything is complete, and the downloaded file is available - *

- * Async call - * - * @param onComplete the handler - * @return task instance - */ - public EagletTask setOnComplete(EagletHandler onComplete) { - this.onComplete = onComplete; - return this; - } - - /** - * Set the start handler - *

- * This handler will be called when the start method is called - *

- * Async call - * - * @param onStart the handler - * @return task instance - */ - public EagletTask setOnStart(EagletHandler onStart) { - this.onStart = onStart; - return this; - } - - /** - * Set the network proxy - * - * @param proxy the proxy - * @return task instance - */ - public EagletTask proxy(Proxy proxy) { - this.proxy = proxy; - return this; - } - - /** - * Set the error handler, default is to print the stack trace - *

- * This handler will be called when an exception is thrown - *

- * Async call - * - * @param onError the handler - * @return task instance - */ - public EagletTask setOnError(EagletHandler onError) { - this.onError = onError; - return this; - } - - - /** - * Set how much thread should be used to download, default is 1 - * - * @param i thread amount - * @return task instance - */ - public EagletTask setThreads(int i) { - if (i < 1) { - throw new RuntimeException("Thread amount cannot be zero or negative!"); - } - threadAmount = i; - return this; - } - - /** - * Set the download source - * - * @param url the url - * @return task instance - */ - public EagletTask url(URL url) { - this.url = url; - return this; - } - - /** - * Set the download source - * - * @param url the url - * @return task instance - */ - public EagletTask url(String url) { - try { - this.url = new URL(url); - } catch (MalformedURLException e) { - onError.handle(new ErrorEvent(e, this)); - } - return this; - } - - /** - * Clear the http header field - * - * @return task instance - */ - public EagletTask clearHeaders() { - httpHeader.clear(); - return this; - } - - /** - * Set the header field of the http request - * - * @param key header key - * @param value header value - * @return builder instance - */ - public EagletTask header(String key, String value) { - httpHeader.put(key, value); - return this; - } - -} diff --git a/src/main/scala/io/izzel/taboolib/util/eagletdl/ErrorEvent.java b/src/main/scala/io/izzel/taboolib/util/eagletdl/ErrorEvent.java deleted file mode 100644 index 115f140..0000000 --- a/src/main/scala/io/izzel/taboolib/util/eagletdl/ErrorEvent.java +++ /dev/null @@ -1,20 +0,0 @@ -package io.izzel.taboolib.util.eagletdl; - -public class ErrorEvent { - - private Throwable e; - private EagletTask task; - - public ErrorEvent(Throwable e, EagletTask task) { - this.e = e; - this.task = task; - } - - public EagletTask getTask() { - return task; - } - - public Throwable getException() { - return e; - } -} diff --git a/src/main/scala/io/izzel/taboolib/util/eagletdl/HashNotMatchException.java b/src/main/scala/io/izzel/taboolib/util/eagletdl/HashNotMatchException.java deleted file mode 100644 index eedbbc8..0000000 --- a/src/main/scala/io/izzel/taboolib/util/eagletdl/HashNotMatchException.java +++ /dev/null @@ -1,4 +0,0 @@ -package io.izzel.taboolib.util.eagletdl; - -public class HashNotMatchException extends RuntimeException { -} diff --git a/src/main/scala/io/izzel/taboolib/util/eagletdl/HashUtil.java b/src/main/scala/io/izzel/taboolib/util/eagletdl/HashUtil.java deleted file mode 100644 index bb76807..0000000 --- a/src/main/scala/io/izzel/taboolib/util/eagletdl/HashUtil.java +++ /dev/null @@ -1,63 +0,0 @@ -package io.izzel.taboolib.util.eagletdl; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.math.BigInteger; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; - -public class HashUtil { - - public static String sha256(File file) { - try { - FileInputStream fis = new FileInputStream(file); - MessageDigest md = MessageDigest.getInstance("SHA256"); - byte[] buffer = new byte[1024]; - int length = -1; - while ((length = fis.read(buffer, 0, 1024)) != -1) { - md.update(buffer, 0, length); - } - BigInteger bigInt = new BigInteger(1, md.digest()); - return bigInt.toString(16); - } catch (NoSuchAlgorithmException | IOException e) { - e.printStackTrace(); - } - return null; - } - - public static String sha1(File file) { - try { - FileInputStream fis = new FileInputStream(file); - MessageDigest md = MessageDigest.getInstance("SHA1"); - byte[] buffer = new byte[1024]; - int length = -1; - while ((length = fis.read(buffer, 0, 1024)) != -1) { - md.update(buffer, 0, length); - } - BigInteger bigInt = new BigInteger(1, md.digest()); - return bigInt.toString(16); - } catch (NoSuchAlgorithmException | IOException e) { - e.printStackTrace(); - } - return null; - } - - public static String md5(File file) { - try { - FileInputStream fis = new FileInputStream(file); - MessageDigest md = MessageDigest.getInstance("MD5"); - byte[] buffer = new byte[1024]; - int length = -1; - while ((length = fis.read(buffer, 0, 1024)) != -1) { - md.update(buffer, 0, length); - } - BigInteger bigInt = new BigInteger(1, md.digest()); - return bigInt.toString(16); - } catch (NoSuchAlgorithmException | IOException e) { - e.printStackTrace(); - } - return null; - } - -} diff --git a/src/main/scala/io/izzel/taboolib/util/eagletdl/ProgressEvent.java b/src/main/scala/io/izzel/taboolib/util/eagletdl/ProgressEvent.java deleted file mode 100644 index 6cbbe09..0000000 --- a/src/main/scala/io/izzel/taboolib/util/eagletdl/ProgressEvent.java +++ /dev/null @@ -1,53 +0,0 @@ -package io.izzel.taboolib.util.eagletdl; - -import java.text.DecimalFormat; - -public class ProgressEvent { - - private long speed; - private EagletTask task; - private double percentage; - - ProgressEvent(long speed, EagletTask task, double percentage) { - this.speed = speed; - this.task = task; - this.percentage = percentage; - } - - public EagletTask getTask() { - return task; - } - - public long getSpeed() { - return speed; - } - - public double getPercentage() { - return percentage; - } - - public String getPercentageFormatted() { - return formatDouble(percentage * 100D) + " %"; - } - - /** - * Get the speed with format like X.00 MiB, Y.50 GiB, etc. - * - * @return formatted speed string - */ - public String getSpeedFormatted() { - return format(getSpeed()); - } - - private static String formatDouble(double d) { - return new DecimalFormat("0.00").format(d); - } - - public static String format(long l) { - if (l < 1024) return l + " B"; - if (l < 1024 * 1024) return formatDouble((double) l / 1024D) + " KiB"; - if (l < 1024 * 1024 * 1024) return formatDouble((double) l / (1024D * 1024D)) + " MiB"; - if (l < 1024 * 1024 * 1024 * 1024L) return formatDouble((double) l / (1024D * 1024D * 1024)) + " GiB"; - return ""; - } -} diff --git a/src/main/scala/io/izzel/taboolib/util/eagletdl/RetryFailedException.java b/src/main/scala/io/izzel/taboolib/util/eagletdl/RetryFailedException.java deleted file mode 100644 index c9fb5f0..0000000 --- a/src/main/scala/io/izzel/taboolib/util/eagletdl/RetryFailedException.java +++ /dev/null @@ -1,14 +0,0 @@ -package io.izzel.taboolib.util.eagletdl; - -public class RetryFailedException extends RuntimeException { - - private EagletTask task; - - RetryFailedException(EagletTask task) { - this.task = task; - } - - public EagletTask getTask() { - return task; - } -} diff --git a/src/main/scala/io/izzel/taboolib/util/eagletdl/SingleThreadDownload.java b/src/main/scala/io/izzel/taboolib/util/eagletdl/SingleThreadDownload.java deleted file mode 100644 index 1a4589d..0000000 --- a/src/main/scala/io/izzel/taboolib/util/eagletdl/SingleThreadDownload.java +++ /dev/null @@ -1,49 +0,0 @@ -package io.izzel.taboolib.util.eagletdl; - -import java.io.*; -import java.net.HttpURLConnection; - -class SingleThreadDownload implements Runnable { - - private HttpURLConnection connection; - private File target; - private EagletTask task; - - private transient long currentProgress = 0, lastUpdateTime = System.currentTimeMillis(); - - private transient boolean complete = false; - - SingleThreadDownload(HttpURLConnection connection, File target, EagletTask task) { - this.connection = connection; - this.target = target; - this.task = task; - } - - long getLastUpdateTime() { - return lastUpdateTime; - } - - long getCurrentProgress() { - return currentProgress; - } - - public boolean isComplete() { - return complete; - } - - @Override - public void run() { - byte[] buf = new byte[1024]; - int len = 0; - try (BufferedInputStream stream = new BufferedInputStream(connection.getInputStream()); BufferedOutputStream outputStream = new BufferedOutputStream(new FileOutputStream(target))) { - while ((len = stream.read(buf)) > 0) { - outputStream.write(buf, 0, len); - currentProgress += len; - lastUpdateTime = System.currentTimeMillis(); - } - } catch (IOException e) { - task.onError.handle(new ErrorEvent(e, task)); - } - complete = true; - } -} diff --git a/src/main/scala/io/izzel/taboolib/util/eagletdl/SplitDownload.java b/src/main/scala/io/izzel/taboolib/util/eagletdl/SplitDownload.java deleted file mode 100644 index bd4a65d..0000000 --- a/src/main/scala/io/izzel/taboolib/util/eagletdl/SplitDownload.java +++ /dev/null @@ -1,92 +0,0 @@ -package io.izzel.taboolib.util.eagletdl; - -import java.io.BufferedInputStream; -import java.io.File; -import java.io.RandomAccessFile; -import java.net.HttpURLConnection; -import java.net.URL; - -class SplitDownload implements Runnable { - - private URL url; - long startIndex, endIndex; - private File target; - private EagletTask task; - - private transient long currentIndex, lastUpdateTime = System.currentTimeMillis(), tmpStart; - private transient int retry = 0; - private transient boolean complete; - - SplitDownload(URL url, long startIndex, long endIndex, File dest, EagletTask task) { - this.url = url; - tmpStart = this.startIndex = this.currentIndex = startIndex; - this.endIndex = endIndex; - target = dest; - this.task = task; - } - - void setStartIndex(long index) { - this.tmpStart = index; - } - - long getLastUpdateTime() { - return lastUpdateTime; - } - - long getCurrentIndex() { - return currentIndex; - } - - int getRetry() { - return retry; - } - - boolean isComplete() { - return complete || currentIndex == endIndex + 1; - } - - @Override - public void run() { - try { - complete = false; - currentIndex = tmpStart; - HttpURLConnection connection = (HttpURLConnection) url.openConnection(); - // set the connection properties - task.httpHeader.forEach(connection::addRequestProperty); - connection.setRequestMethod(task.requestMethod); - connection.setConnectTimeout(task.connectionTimeout); - connection.setReadTimeout(task.readTimeout); - // set the download range - connection.setRequestProperty("Range", "bytes=" + tmpStart + "-" + endIndex); - connection.connect(); - // if response code not equals 206, it means that the server do not support multi thread downloading - if (connection.getResponseCode() == 206) { - RandomAccessFile file = new RandomAccessFile(target, "rwd"); - file.seek(tmpStart); - byte[] buf = new byte[1024]; - int len; - try (BufferedInputStream stream = new BufferedInputStream(connection.getInputStream())) { - while ((len = stream.read(buf)) > 0) { - file.write(buf, 0, len); - lastUpdateTime = System.currentTimeMillis(); - currentIndex += len; - // some mysterious error occurred while downloading - if (currentIndex >= endIndex + 2) { - currentIndex = tmpStart; - lastUpdateTime = 0; - retry++; - return; - } - } - complete = true; - } - file.close(); - } else { - throw new DoNotSupportMultipleThreadException(); - } - } catch (Exception e) { - task.onError.handle(new ErrorEvent(e, task)); - retry++; - } - } -} diff --git a/src/main/scala/io/izzel/taboolib/util/eagletdl/StartEvent.java b/src/main/scala/io/izzel/taboolib/util/eagletdl/StartEvent.java deleted file mode 100644 index 4f95b7d..0000000 --- a/src/main/scala/io/izzel/taboolib/util/eagletdl/StartEvent.java +++ /dev/null @@ -1,14 +0,0 @@ -package io.izzel.taboolib.util.eagletdl; - -public class StartEvent { - - private EagletTask task; - - StartEvent(EagletTask task) { - this.task = task; - } - - public EagletTask getTask() { - return task; - } -} diff --git a/src/main/scala/io/izzel/taboolib/util/lite/Logs.java b/src/main/scala/io/izzel/taboolib/util/lite/Logs.java index 900fcff..ff1ba23 100644 --- a/src/main/scala/io/izzel/taboolib/util/lite/Logs.java +++ b/src/main/scala/io/izzel/taboolib/util/lite/Logs.java @@ -5,8 +5,8 @@ import io.izzel.taboolib.module.locale.TLocale; import io.izzel.taboolib.module.command.base.BaseCommand; import io.izzel.taboolib.module.command.base.BaseMainCommand; import io.izzel.taboolib.module.command.base.BaseSubCommand; -import io.izzel.taboolib.module.command.base.CommandArgument; -import io.izzel.taboolib.module.command.base.CommandRegister; +import io.izzel.taboolib.module.command.base.Argument; +import io.izzel.taboolib.module.command.base.SubCommand; import io.izzel.taboolib.util.Files; import io.izzel.taboolib.util.Strings; import org.bukkit.Bukkit; @@ -35,7 +35,7 @@ public class Logs extends BaseMainCommand { return TLocale.asString("COMMANDS.TLOGS.COMMAND-TITLE"); } - @CommandRegister(priority = 0) + @SubCommand(priority = 0) BaseSubCommand info = new BaseSubCommand() { @Override public String getLabel() { @@ -48,10 +48,10 @@ public class Logs extends BaseMainCommand { } @Override - public CommandArgument[] getArguments() { - return new CommandArgument[] { - new CommandArgument(TLocale.asString("COMMANDS.TLOGS.INFO.ARGUMENTS.0")), - new CommandArgument(TLocale.asString("COMMANDS.TLOGS.INFO.ARGUMENTS.1")) + public Argument[] getArguments() { + return new Argument[] { + new Argument(TLocale.asString("COMMANDS.TLOGS.INFO.ARGUMENTS.0")), + new Argument(TLocale.asString("COMMANDS.TLOGS.INFO.ARGUMENTS.1")) }; } @@ -64,7 +64,7 @@ public class Logs extends BaseMainCommand { } }; - @CommandRegister(priority = 1) + @SubCommand(priority = 1) BaseSubCommand error = new BaseSubCommand() { @Override public String getLabel() { @@ -77,10 +77,10 @@ public class Logs extends BaseMainCommand { } @Override - public CommandArgument[] getArguments() { - return new CommandArgument[] { - new CommandArgument(TLocale.asString("COMMANDS.TLOGS.ERROR.ARGUMENTS.0")), - new CommandArgument(TLocale.asString("COMMANDS.TLOGS.ERROR.ARGUMENTS.1")) + public Argument[] getArguments() { + return new Argument[] { + new Argument(TLocale.asString("COMMANDS.TLOGS.ERROR.ARGUMENTS.0")), + new Argument(TLocale.asString("COMMANDS.TLOGS.ERROR.ARGUMENTS.1")) }; } @@ -93,7 +93,7 @@ public class Logs extends BaseMainCommand { } }; - @CommandRegister(priority = 2) + @SubCommand(priority = 2) BaseSubCommand warning = new BaseSubCommand() { @Override public String getLabel() { @@ -106,10 +106,10 @@ public class Logs extends BaseMainCommand { } @Override - public CommandArgument[] getArguments() { - return new CommandArgument[] { - new CommandArgument(TLocale.asString("COMMANDS.TLOGS.WARNING.ARGUMENTS.0")), - new CommandArgument(TLocale.asString("COMMANDS.TLOGS.WARNING.ARGUMENTS.1")) + public Argument[] getArguments() { + return new Argument[] { + new Argument(TLocale.asString("COMMANDS.TLOGS.WARNING.ARGUMENTS.0")), + new Argument(TLocale.asString("COMMANDS.TLOGS.WARNING.ARGUMENTS.1")) }; } diff --git a/src/main/scala/io/izzel/taboolib/util/serialize/TSerializer.java b/src/main/scala/io/izzel/taboolib/util/serialize/TSerializer.java index d0259ab..92e17f0 100644 --- a/src/main/scala/io/izzel/taboolib/util/serialize/TSerializer.java +++ b/src/main/scala/io/izzel/taboolib/util/serialize/TSerializer.java @@ -88,7 +88,6 @@ public class TSerializer { } public static String write(TSerializable serializable) { - SimpleReflection.checkAndSave(serializable.getClass()); JsonObject jsonObject = new JsonObject(); JsonObject serializeObject = new JsonObject(); for (Field declaredField : serializable.getClass().getDeclaredFields()) {