版本更新至 4.08
调整:优化 /tplugin 各项命令,更多提示。 修复:修复 BaseSubCommand 中仅允许控制台类型无效的错误。 新增:/tlib updatePlugin 命令用于下载更新。 新增:自动下载最新版(默认关闭)。
This commit is contained in:
@@ -1,14 +1,24 @@
|
||||
package me.skymc.taboolib.commands;
|
||||
|
||||
import com.ilummc.tlib.resources.TLocale;
|
||||
import com.ilummc.tlib.util.Strings;
|
||||
import me.skymc.taboolib.Main;
|
||||
import me.skymc.taboolib.commands.internal.BaseMainCommand;
|
||||
import me.skymc.taboolib.commands.internal.BaseSubCommand;
|
||||
import me.skymc.taboolib.commands.internal.type.CommandArgument;
|
||||
import me.skymc.taboolib.commands.internal.type.CommandRegister;
|
||||
import me.skymc.taboolib.commands.internal.type.CommandType;
|
||||
import me.skymc.taboolib.commands.taboolib.*;
|
||||
import me.skymc.taboolib.fileutils.FileUtils;
|
||||
import me.skymc.taboolib.inventory.ItemUtils;
|
||||
import me.skymc.taboolib.plugin.PluginUtils;
|
||||
import me.skymc.taboolib.update.UpdateTask;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* @Author sky
|
||||
@@ -723,4 +733,59 @@ public class TabooLibMainCommand extends BaseMainCommand {
|
||||
new ImportCommand(sender, args);
|
||||
}
|
||||
};
|
||||
|
||||
@CommandRegister(priority = 26)
|
||||
BaseSubCommand updatePlugin = new BaseSubCommand() {
|
||||
|
||||
@Override
|
||||
public String getLabel() {
|
||||
return "updatePlugin";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return TLocale.asString("COMMANDS.TABOOLIB.UPDATEPLUGIN.DESCRIPTION");
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandArgument[] getArguments() {
|
||||
return new CommandArgument[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!UpdateTask.isHaveUpdate()) {
|
||||
TLocale.sendTo(sender, "COMMANDS.TABOOLIB.UPDATEPLUGIN.UPDATE-NOT-FOUND");
|
||||
return;
|
||||
}
|
||||
|
||||
File file = new File("plugins/update");
|
||||
if (!file.exists()) {
|
||||
TLocale.sendTo(sender, "COMMANDS.TABOOLIB.UPDATEPLUGIN.UPDATE-NOT-SUPPORT");
|
||||
return;
|
||||
}
|
||||
|
||||
File pluginFile = PluginUtils.getPluginFile(Main.getInst());
|
||||
if (pluginFile == null) {
|
||||
TLocale.sendTo(sender, "COMMANDS.TABOOLIB.UPDATEPLUGIN.FILE-NOT-FOUND");
|
||||
return;
|
||||
}
|
||||
|
||||
new BukkitRunnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
String url = Strings.replaceWithOrder("https://github.com/Bkm016/TabooLib/releases/download/{0}/TabooLib-{0}.jar", UpdateTask.getNewVersion());
|
||||
TLocale.sendTo(sender, "COMMANDS.TABOOLIB.UPDATEPLUGIN.UPDATE-START", url);
|
||||
FileUtils.download(url, new File(file, pluginFile.getName()));
|
||||
TLocale.sendTo(sender, "COMMANDS.TABOOLIB.UPDATEPLUGIN.UPDATE-SUCCESS");
|
||||
}
|
||||
}.runTaskAsynchronously(Main.getInst());
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandType getType() {
|
||||
return CommandType.CONSOLE;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ public abstract class BaseMainCommand implements IMainCommand, CommandExecutor,
|
||||
continue;
|
||||
}
|
||||
if (!isConfirmType(sender, subCommand.getType())) {
|
||||
TLocale.sendTo(sender, "COMMANDS.INTERNAL.ONLY-PLAYER", args[0], TLocale.asString("COMMANDS.INTERNAL.TYPE-" + subCommand.getType()));
|
||||
TLocale.sendTo(sender, "COMMANDS.INTERNAL.TYPE-ERROR", args[0], TLocale.asString("COMMANDS.INTERNAL.TYPE-" + subCommand.getType()));
|
||||
return true;
|
||||
}
|
||||
String[] subCommandArgs = ArrayUtils.removeFirst(args);
|
||||
@@ -166,7 +166,9 @@ public abstract class BaseMainCommand implements IMainCommand, CommandExecutor,
|
||||
}
|
||||
|
||||
private boolean isConfirmType(CommandSender sender, CommandType commandType) {
|
||||
return commandType == CommandType.ALL || (sender instanceof Player && commandType == CommandType.PLAYER);
|
||||
return commandType == CommandType.ALL
|
||||
|| (sender instanceof Player && commandType == CommandType.PLAYER)
|
||||
|| (sender instanceof ConsoleCommandSender && commandType == CommandType.CONSOLE);
|
||||
}
|
||||
|
||||
private void helpCommand(CommandSender sender, String label) {
|
||||
|
||||
@@ -7,6 +7,9 @@ import me.skymc.taboolib.commands.internal.BaseSubCommand;
|
||||
import me.skymc.taboolib.commands.internal.ISubCommand;
|
||||
import me.skymc.taboolib.commands.internal.type.CommandArgument;
|
||||
import me.skymc.taboolib.commands.internal.type.CommandRegister;
|
||||
import me.skymc.taboolib.plugin.PluginLoadState;
|
||||
import me.skymc.taboolib.plugin.PluginLoadStateType;
|
||||
import me.skymc.taboolib.plugin.PluginUnloadState;
|
||||
import me.skymc.taboolib.plugin.PluginUtils;
|
||||
import me.skymc.taboolib.string.ArrayUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -62,16 +65,29 @@ public class TabooLibPluginMainCommand extends BaseMainCommand {
|
||||
public void onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
String name = ArrayUtils.arrayJoin(args, 0);
|
||||
if (PluginUtils.getPluginByName(name) != null) {
|
||||
TLocale.sendTo(sender, "COMMANDS.TPLUGIN.LOAD.INVALID-PLUGIN", name);
|
||||
TLocale.sendTo(sender, "COMMANDS.TPLUGIN.LOAD.INVALID-PLUGIN", name, name + " already loaded!");
|
||||
} else {
|
||||
switch (PluginUtils.load(name)) {
|
||||
case "loaded": {
|
||||
TLocale.sendTo(sender, "COMMANDS.TPLUGIN.LOAD.LOAD-SUCCESS", name);
|
||||
PluginLoadState loadState;
|
||||
try {
|
||||
loadState = PluginUtils.load(name);
|
||||
} catch (Exception e) {
|
||||
loadState = new PluginLoadState(PluginLoadStateType.INVALID_PLUGIN, e.toString());
|
||||
}
|
||||
switch (loadState.getStateType()) {
|
||||
case INVALID_DESCRIPTION: {
|
||||
TLocale.sendTo(sender, "COMMANDS.TPLUGIN.LOAD.INVALID-DESCRIPTION");
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
TLocale.sendTo(sender, "COMMANDS.TPLUGIN.LOAD.LOAD-FAIL", name);
|
||||
case INVALID_PLUGIN: {
|
||||
TLocale.sendTo(sender, "COMMANDS.TPLUGIN.LOAD.INVALID-PLUGIN", name, loadState.getMessage());
|
||||
break;
|
||||
}
|
||||
case FILE_NOT_FOUND: {
|
||||
TLocale.sendTo(sender, "COMMANDS.TPLUGIN.LOAD.FILE-NOT-FOUND", name);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
TLocale.sendTo(sender, "COMMANDS.TPLUGIN.LOAD.LOAD-SUCCESS", name);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -104,14 +120,16 @@ public class TabooLibPluginMainCommand extends BaseMainCommand {
|
||||
} else if (PluginUtils.isIgnored(plugin)) {
|
||||
TLocale.sendTo(sender, "COMMANDS.TPLUGIN.UNLOAD.INVALID-PLUGIN-IGNORED", name);
|
||||
} else {
|
||||
switch (PluginUtils.unload(plugin)) {
|
||||
case "unloaded": {
|
||||
TLocale.sendTo(sender, "COMMANDS.TPLUGIN.UNLOAD.UNLOAD-SUCCESS", name);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
TLocale.sendTo(sender, "COMMANDS.TPLUGIN.UNLOAD.UNLOAD-FAIL", name);
|
||||
}
|
||||
PluginUnloadState unloadState;
|
||||
try {
|
||||
unloadState = PluginUtils.unload(plugin);
|
||||
} catch (Exception e) {
|
||||
unloadState = new PluginUnloadState(true, e.toString());
|
||||
}
|
||||
if (unloadState.isFailed()) {
|
||||
TLocale.sendTo(sender, "COMMANDS.TPLUGIN.UNLOAD.UNLOAD-FAIL", name, unloadState.getMessage());
|
||||
} else {
|
||||
TLocale.sendTo(sender, "COMMANDS.TPLUGIN.UNLOAD.UNLOAD-SUCCESS", name);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -185,9 +203,9 @@ public class TabooLibPluginMainCommand extends BaseMainCommand {
|
||||
String.valueOf(plugin.getDescription().getMain()),
|
||||
String.valueOf(plugin.getDescription().getVersion()),
|
||||
String.valueOf(plugin.getDescription().getWebsite()),
|
||||
String.valueOf(plugin.getDescription().getCommands().keySet()));
|
||||
} catch (Exception ignored) {
|
||||
TLocale.sendTo(sender, "COMMANDS.TPLUGIN.INFO.INVALID-PLUGIN", name);
|
||||
String.valueOf(plugin.getDescription().getCommands() == null ? "" : plugin.getDescription().getCommands().keySet()));
|
||||
} catch (Exception e) {
|
||||
TLocale.sendTo(sender, "COMMANDS.TPLUGIN.INFO.INVALID-DESCRIPTION", name, e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -213,7 +231,7 @@ public class TabooLibPluginMainCommand extends BaseMainCommand {
|
||||
|
||||
@Override
|
||||
public void onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
List<String> pluginList = Arrays.stream(Bukkit.getPluginManager().getPlugins()).map(Plugin::getName).sorted(String.CASE_INSENSITIVE_ORDER).collect(Collectors.toList());
|
||||
List<String> pluginList = Arrays.stream(Bukkit.getPluginManager().getPlugins()).map(PluginUtils::getFormattedName).sorted(String.CASE_INSENSITIVE_ORDER).collect(Collectors.toList());
|
||||
TLocale.sendTo(sender, "COMMANDS.TPLUGIN.LIST.LIST-PLUGIN", String.valueOf(Bukkit.getPluginManager().getPlugins().length), Joiner.on(", ").join(pluginList));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -119,7 +119,7 @@ public class FileUtils {
|
||||
*
|
||||
* @param file 文件夹
|
||||
*/
|
||||
public void deleteAllFile(File file) {
|
||||
public static void deleteAllFile(File file) {
|
||||
if (!file.exists()) {
|
||||
return;
|
||||
}
|
||||
@@ -139,7 +139,7 @@ public class FileUtils {
|
||||
* @param file1 文件1
|
||||
* @param file2 文件2
|
||||
*/
|
||||
public void copyAllFile(String file1, String file2) {
|
||||
public static void copyAllFile(String file1, String file2) {
|
||||
File _file1 = new File(file1);
|
||||
File _file2 = new File(file2);
|
||||
if (!_file2.exists()) {
|
||||
@@ -168,7 +168,7 @@ public class FileUtils {
|
||||
* @param file1 文件1
|
||||
* @param file2 文件2
|
||||
*/
|
||||
public void fileChannelCopy(File file1, File file2) {
|
||||
public static void fileChannelCopy(File file1, File file2) {
|
||||
FileInputStream fileIn = null;
|
||||
FileOutputStream fileOut = null;
|
||||
FileChannel channelIn = null;
|
||||
|
||||
@@ -911,7 +911,7 @@ public class NMSUtil19 {
|
||||
}
|
||||
|
||||
public static Class<?> getBukkitClass(String className) {
|
||||
Class<?> result = null;
|
||||
Class<?> result;
|
||||
try {
|
||||
result = fixBukkitClass(className);
|
||||
} catch (Exception ex) {
|
||||
@@ -930,6 +930,7 @@ public class NMSUtil19 {
|
||||
try {
|
||||
return NMSUtils.class.getClassLoader().loadClass(className);
|
||||
} catch (ClassNotFoundException ignored) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
24
src/main/java/me/skymc/taboolib/plugin/PluginLoadState.java
Normal file
24
src/main/java/me/skymc/taboolib/plugin/PluginLoadState.java
Normal file
@@ -0,0 +1,24 @@
|
||||
package me.skymc.taboolib.plugin;
|
||||
|
||||
/**
|
||||
* @Author sky
|
||||
* @Since 2018-06-01 21:34
|
||||
*/
|
||||
public class PluginLoadState {
|
||||
|
||||
private final PluginLoadStateType stateType;
|
||||
private final String message;
|
||||
|
||||
public PluginLoadState(PluginLoadStateType stateType, String message) {
|
||||
this.stateType = stateType;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public PluginLoadStateType getStateType() {
|
||||
return stateType;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package me.skymc.taboolib.plugin;
|
||||
|
||||
/**
|
||||
* @Author sky
|
||||
* @Since 2018-06-01 21:32
|
||||
*/
|
||||
public enum PluginLoadStateType {
|
||||
|
||||
/**
|
||||
* 目录不存在
|
||||
*/
|
||||
DIRECTORY_NOT_FOUND,
|
||||
|
||||
/**
|
||||
* 插件不存在
|
||||
*/
|
||||
FILE_NOT_FOUND,
|
||||
|
||||
/**
|
||||
* 无效的描述
|
||||
*/
|
||||
INVALID_DESCRIPTION,
|
||||
|
||||
/**
|
||||
* 无效的插件
|
||||
*/
|
||||
INVALID_PLUGIN,
|
||||
|
||||
/**
|
||||
* 载入成功
|
||||
*/
|
||||
LOADED
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package me.skymc.taboolib.plugin;
|
||||
|
||||
/**
|
||||
* @Author sky
|
||||
* @Since 2018-06-01 21:39
|
||||
*/
|
||||
public class PluginUnloadState {
|
||||
|
||||
private final boolean failed;
|
||||
private final String message;
|
||||
|
||||
public PluginUnloadState(boolean failed, String message) {
|
||||
this.failed = failed;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public boolean isFailed() {
|
||||
return failed;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,3 @@
|
||||
//
|
||||
// Source code recreated from a .class file by IntelliJ IDEA
|
||||
// (powered by Fernflower decompiler)
|
||||
//
|
||||
|
||||
package me.skymc.taboolib.plugin;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
@@ -26,16 +21,33 @@ import java.util.logging.Logger;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
/**
|
||||
* @author PluginMan
|
||||
*/
|
||||
public class PluginUtils {
|
||||
|
||||
private PluginUtils() {
|
||||
PluginUtils() {
|
||||
}
|
||||
|
||||
public static File getPluginFile(Plugin plugin) {
|
||||
for (File pluginFile : Objects.requireNonNull(new File("plugins").listFiles())) {
|
||||
if (pluginFile.getName().endsWith(".jar")) {
|
||||
try {
|
||||
PluginDescriptionFile desc = Main.getInst().getPluginLoader().getPluginDescription(pluginFile);
|
||||
if (desc.getName().equalsIgnoreCase(plugin.getName())) {
|
||||
return pluginFile;
|
||||
}
|
||||
} catch (InvalidDescriptionException ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void enable(Plugin plugin) {
|
||||
if (plugin != null && !plugin.isEnabled()) {
|
||||
Bukkit.getPluginManager().enablePlugin(plugin);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void disable(Plugin plugin) {
|
||||
@@ -45,11 +57,11 @@ public class PluginUtils {
|
||||
}
|
||||
|
||||
public static void enableAll() {
|
||||
Arrays.stream(Bukkit.getPluginManager().getPlugins()).filter(plugin -> isIgnored(plugin)).forEach(PluginUtils::enable);
|
||||
Arrays.stream(Bukkit.getPluginManager().getPlugins()).filter(PluginUtils::isIgnored).forEach(PluginUtils::enable);
|
||||
}
|
||||
|
||||
public static void disableAll() {
|
||||
Arrays.stream(Bukkit.getPluginManager().getPlugins()).filter(plugin -> isIgnored(plugin)).forEach(PluginUtils::disable);
|
||||
Arrays.stream(Bukkit.getPluginManager().getPlugins()).filter(PluginUtils::isIgnored).forEach(PluginUtils::disable);
|
||||
}
|
||||
|
||||
public static String getFormattedName(Plugin plugin) {
|
||||
@@ -58,7 +70,7 @@ public class PluginUtils {
|
||||
|
||||
public static String getFormattedName(Plugin plugin, boolean includeVersions) {
|
||||
ChatColor color = plugin.isEnabled() ? ChatColor.GREEN : ChatColor.RED;
|
||||
String pluginName = color + plugin.getName();
|
||||
String pluginName = color + plugin.getName() + ChatColor.RESET;
|
||||
if (includeVersions) {
|
||||
pluginName = pluginName + " (" + plugin.getDescription().getVersion() + ")";
|
||||
}
|
||||
@@ -89,9 +101,8 @@ public class PluginUtils {
|
||||
Map commands = plugin.getDescription().getCommands();
|
||||
if (commands != null) {
|
||||
for (Object o : commands.entrySet()) {
|
||||
Entry thisEntry = (Entry) o;
|
||||
if (thisEntry != null) {
|
||||
parsedCommands.add((String) thisEntry.getKey());
|
||||
if (o != null) {
|
||||
parsedCommands.add((String) ((Entry) o).getKey());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -158,37 +169,28 @@ public class PluginUtils {
|
||||
return plugin.equals(Main.getInst());
|
||||
}
|
||||
|
||||
private static String load(Plugin plugin) {
|
||||
private static PluginLoadState load(Plugin plugin) {
|
||||
return load(plugin.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回内容:
|
||||
*
|
||||
* plugin-directory —— 插件目录不存在
|
||||
* cannot-find —— 插件不存在
|
||||
* invalid-description —— 无效的描述
|
||||
* invalid-plugin —— 无效的插件
|
||||
* loaded —— 载入成功
|
||||
*/
|
||||
public static String load(String name) {
|
||||
public static PluginLoadState load(String name) {
|
||||
Plugin target;
|
||||
File pluginDir = new File("plugins");
|
||||
if (!pluginDir.isDirectory()) {
|
||||
return "plugin-directory";
|
||||
return new PluginLoadState(PluginLoadStateType.DIRECTORY_NOT_FOUND, "null");
|
||||
} else {
|
||||
File pluginFile = new File(pluginDir, name + ".jar");
|
||||
if (!pluginFile.isFile()) {
|
||||
for (File f : Objects.requireNonNull(pluginDir.listFiles())) {
|
||||
if (f.getName().endsWith(".jar")) {
|
||||
if (!pluginFile.exists()) {
|
||||
for (File plugin : Objects.requireNonNull(pluginDir.listFiles())) {
|
||||
if (plugin.getName().endsWith(".jar")) {
|
||||
try {
|
||||
PluginDescriptionFile desc = Main.getInst().getPluginLoader().getPluginDescription(f);
|
||||
PluginDescriptionFile desc = Main.getInst().getPluginLoader().getPluginDescription(plugin);
|
||||
if (desc.getName().equalsIgnoreCase(name)) {
|
||||
pluginFile = f;
|
||||
pluginFile = plugin;
|
||||
break;
|
||||
}
|
||||
} catch (InvalidDescriptionException var11) {
|
||||
return "cannot-find";
|
||||
} catch (InvalidDescriptionException ignored) {
|
||||
return new PluginLoadState(PluginLoadStateType.FILE_NOT_FOUND, "null");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -196,15 +198,15 @@ public class PluginUtils {
|
||||
|
||||
try {
|
||||
target = Bukkit.getPluginManager().loadPlugin(pluginFile);
|
||||
} catch (InvalidDescriptionException var9) {
|
||||
return "invalid-description";
|
||||
} catch (InvalidPluginException var10) {
|
||||
return "invalid-plugin";
|
||||
} catch (InvalidDescriptionException e) {
|
||||
return new PluginLoadState(PluginLoadStateType.INVALID_DESCRIPTION, e.toString());
|
||||
} catch (InvalidPluginException e) {
|
||||
return new PluginLoadState(PluginLoadStateType.INVALID_PLUGIN, e.toString());
|
||||
}
|
||||
|
||||
target.onLoad();
|
||||
Bukkit.getPluginManager().enablePlugin(target);
|
||||
return "loaded";
|
||||
return new PluginLoadState(PluginLoadStateType.LOADED, "null");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -213,20 +215,13 @@ public class PluginUtils {
|
||||
unload(plugin);
|
||||
load(plugin);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void reloadAll() {
|
||||
Arrays.stream(Bukkit.getPluginManager().getPlugins(), 0, Bukkit.getPluginManager().getPlugins().length).filter(PluginUtils::isIgnored).forEach(PluginUtils::reload);
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回内容:
|
||||
*
|
||||
* failed —— 卸载失败
|
||||
* unloaded —— 卸载成功
|
||||
*/
|
||||
public static String unload(Plugin plugin) {
|
||||
public static PluginUnloadState unload(Plugin plugin) {
|
||||
String name = plugin.getName();
|
||||
PluginManager pluginManager = Bukkit.getPluginManager();
|
||||
SimpleCommandMap commandMap = null;
|
||||
@@ -236,7 +231,6 @@ public class PluginUtils {
|
||||
Map<Event, SortedSet<RegisteredListener>> listeners = null;
|
||||
if (pluginManager != null) {
|
||||
pluginManager.disablePlugin(plugin);
|
||||
|
||||
try {
|
||||
Field pluginsField = Bukkit.getPluginManager().getClass().getDeclaredField("plugins");
|
||||
pluginsField.setAccessible(true);
|
||||
@@ -259,8 +253,8 @@ public class PluginUtils {
|
||||
Field knownCommandsField = SimpleCommandMap.class.getDeclaredField("knownCommands");
|
||||
knownCommandsField.setAccessible(true);
|
||||
commands = (Map) knownCommandsField.get(commandMap);
|
||||
} catch (NoSuchFieldException | IllegalAccessException var15) {
|
||||
return "failed";
|
||||
} catch (NoSuchFieldException | IllegalAccessException e) {
|
||||
return new PluginUnloadState(true, e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -276,10 +270,8 @@ public class PluginUtils {
|
||||
Iterator it;
|
||||
if (listeners != null) {
|
||||
it = listeners.values().iterator();
|
||||
|
||||
while (it.hasNext()) {
|
||||
SortedSet<RegisteredListener> set = (SortedSet) it.next();
|
||||
|
||||
while (it.hasNext()) {
|
||||
RegisteredListener value = (RegisteredListener) it.next();
|
||||
if (value.getPlugin() == plugin) {
|
||||
@@ -291,7 +283,6 @@ public class PluginUtils {
|
||||
|
||||
if (commandMap != null) {
|
||||
it = commands.entrySet().iterator();
|
||||
|
||||
while (it.hasNext()) {
|
||||
Entry<String, Command> entry = (Entry) it.next();
|
||||
if (entry.getValue() instanceof PluginCommand) {
|
||||
@@ -312,7 +303,7 @@ public class PluginUtils {
|
||||
Logger.getLogger(PluginUtils.class.getName()).log(Level.SEVERE, null, var13);
|
||||
}
|
||||
}
|
||||
return "unloaded";
|
||||
return new PluginUnloadState(false, "null");
|
||||
}
|
||||
|
||||
private static String consolidateStrings(String[] args, int start) {
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.ilummc.tlib.resources.TLocale;
|
||||
import me.skymc.taboolib.Main;
|
||||
import me.skymc.taboolib.TabooLib;
|
||||
import me.skymc.taboolib.fileutils.FileUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
/**
|
||||
@@ -26,9 +27,6 @@ public class UpdateTask {
|
||||
return newVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* 旧地址:https://internal.github.com/repos/Bkm016/TabooLib/releases/latest
|
||||
*/
|
||||
public UpdateTask() {
|
||||
new BukkitRunnable() {
|
||||
|
||||
@@ -53,6 +51,15 @@ public class UpdateTask {
|
||||
} else {
|
||||
haveUpdate = true;
|
||||
TLocale.Logger.info("UPDATETASK.VERSION-OUTDATED", String.valueOf(TabooLib.getPluginVersion()), String.valueOf(newVersion));
|
||||
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (Main.getInst().getConfig().getBoolean("UPDATE-DOWNLOAD", false)) {
|
||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "taboolib updatePlugin");
|
||||
}
|
||||
}
|
||||
}.runTask(Main.getInst());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user