mirror of
https://e.coding.net/circlecloud/Yum.git
synced 2024-11-22 06:18:46 +00:00
feat: 更新类库版本 完善网络调试
Signed-off-by: 502647092 <admin@yumc.pw>
This commit is contained in:
parent
ce110a5dd6
commit
eaddb97888
16
pom.xml
16
pom.xml
@ -3,7 +3,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>pw.yumc</groupId>
|
||||
<artifactId>Yum</artifactId>
|
||||
<version>2.7.7</version>
|
||||
<version>2.7.8</version>
|
||||
<name>Yum</name>
|
||||
<description>Minecraft 服务器插件管理系统</description>
|
||||
<build>
|
||||
@ -65,14 +65,10 @@
|
||||
§6- §c修复§eBukkitDev§c下载地址跳转问题...;
|
||||
§6- §c修复§eBukkitDev§c下载为空时的异常...;
|
||||
</update.changes>
|
||||
<env.GIT_COMMIT>DEBUG</env.GIT_COMMIT>
|
||||
<env.GIT_COMMIT>DEV</env.GIT_COMMIT>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>yumc-repo</id>
|
||||
<url>http://repo.yumc.pw/content/groups/public/</url>
|
||||
@ -86,17 +82,11 @@
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<type>jar</type>
|
||||
<version>1.10.2-R0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>pw.yumc</groupId>
|
||||
<artifactId>YumCore</artifactId>
|
||||
<type>jar</type>
|
||||
<version>1.1</version>
|
||||
<version>1.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>pw.yumc</groupId>
|
||||
|
@ -64,7 +64,6 @@ public class Yum extends JavaPlugin {
|
||||
new Statistics();
|
||||
new SubscribeTask();
|
||||
YumAPI.updateRepo(Bukkit.getConsoleSender());
|
||||
YumAPI.updateCheck(Bukkit.getConsoleSender());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -2,8 +2,6 @@ package pw.yumc.Yum.api;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -35,9 +33,6 @@ public class YumAPI {
|
||||
|
||||
/**
|
||||
* 初始化Yum管理中心
|
||||
*
|
||||
* @param plugin
|
||||
* 插件实体
|
||||
*/
|
||||
public YumAPI() {
|
||||
YumAPI.main = P.instance;
|
||||
@ -84,19 +79,6 @@ public class YumAPI {
|
||||
return repo;
|
||||
}
|
||||
|
||||
public static List<Plugin> getUpdateList(CommandSender sender) {
|
||||
List<Plugin> ulist = new ArrayList<>();
|
||||
// try {
|
||||
// for (Entry<String, Plugin> updateplugin : UpdatePlugin.getUpdateList().entrySet()) {
|
||||
// ulist.add(updateplugin.getValue());
|
||||
// }
|
||||
// } catch (Exception | Error e) {
|
||||
// sender.sendMessage("§4错误: §c无法检索全体更新列表!");
|
||||
// sender.sendMessage("§4异常: §c" + e.getMessage());
|
||||
// }
|
||||
return ulist;
|
||||
}
|
||||
|
||||
/**
|
||||
* 注入性能监控器
|
||||
*
|
||||
@ -118,14 +100,11 @@ public class YumAPI {
|
||||
* 命令发送者
|
||||
* @param pluginname
|
||||
* 插件名称
|
||||
* @param version
|
||||
* 插件版本
|
||||
* @return 是否安装成功
|
||||
*/
|
||||
public static boolean install(CommandSender sender, String pluginname, String url) {
|
||||
File pluginFile = new File(Bukkit.getUpdateFolderFile().getParentFile(), pluginname + ".jar");
|
||||
if (download.run(sender, url, pluginFile)) { return plugman.load(sender, pluginFile); }
|
||||
return false;
|
||||
return download.run(sender, url, pluginFile) && plugman.load(sender, pluginFile);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -133,8 +112,6 @@ public class YumAPI {
|
||||
*
|
||||
* @param pluginname
|
||||
* 插件名称
|
||||
* @param version
|
||||
* 插件版本
|
||||
* @return 是否安装成功
|
||||
*/
|
||||
public static boolean install(String pluginname, String url) {
|
||||
@ -174,9 +151,6 @@ public class YumAPI {
|
||||
|
||||
/**
|
||||
* 载入插件
|
||||
*
|
||||
* @param pluginname
|
||||
* 插件名称
|
||||
*/
|
||||
public static void load(File pluginFile) {
|
||||
plugman.load(pluginFile);
|
||||
@ -204,9 +178,6 @@ public class YumAPI {
|
||||
|
||||
/**
|
||||
* 取消注入
|
||||
*
|
||||
* @param plugin
|
||||
* 插件
|
||||
*/
|
||||
public static void uninject() {
|
||||
for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
|
||||
@ -271,64 +242,6 @@ public class YumAPI {
|
||||
return update(null, plugin, url);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新支持Yum的插件
|
||||
*
|
||||
* @param sender
|
||||
* 命令发送者
|
||||
*/
|
||||
public static void updateAll(final CommandSender sender) {
|
||||
main.getServer().getScheduler().runTaskAsynchronously(main, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (runlock) {
|
||||
sender.sendMessage("§d一键更新: §c一键更新运行中 请稍候重试...");
|
||||
return;
|
||||
}
|
||||
runlock = true;
|
||||
int failed = 0;
|
||||
List<Plugin> ulist = getUpdateList(sender);
|
||||
if (ulist.size() > 0) {
|
||||
sender.sendMessage("§d开始更新服务器可更新插件");
|
||||
for (Plugin updateplugin : ulist) {
|
||||
sender.sendMessage("§d一键更新: §a开始更新" + updateplugin.getName() + "!");
|
||||
if (!updateFromYum(sender, updateplugin, null, true)) {
|
||||
failed++;
|
||||
}
|
||||
}
|
||||
if (failed != 0) {
|
||||
sender.sendMessage("§d一键更新: §c升级过程中 §4" + failed + " §c个插件更新失败!");
|
||||
}
|
||||
sender.sendMessage("§d一键更新: §e已下载所有需要升级的插件到 服务器更新 文件夹");
|
||||
sender.sendMessage("§d一键更新: §e插件将在重启后自动更新(或使用§b/yum upgrade§e直接升级)!");
|
||||
updateCheck(sender);
|
||||
} else {
|
||||
sender.sendMessage("§6更新: §e未找到需要更新且可以用Yum处理的插件!");
|
||||
}
|
||||
runlock = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查是否有可更新插件
|
||||
*
|
||||
* @param sender
|
||||
* 命令发送者
|
||||
*/
|
||||
public static void updateCheck(final CommandSender sender) {
|
||||
PKit.runTaskLaterAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
List<Plugin> ulist = getUpdateList(sender);
|
||||
if (ulist.size() > 0) {
|
||||
sender.sendMessage(
|
||||
"§6[§bYum§6]§e自动更新: §a发现 §e" + ulist.size() + " §a个可更新插件 请使用 §b/yum ua §a更新所有插件!");
|
||||
}
|
||||
}
|
||||
}, 60);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新插件
|
||||
*
|
||||
|
@ -3,7 +3,6 @@ package pw.yumc.Yum.commands;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.file.Files;
|
||||
@ -14,12 +13,12 @@ import org.bukkit.command.CommandSender;
|
||||
|
||||
import pw.yumc.Yum.Yum;
|
||||
import pw.yumc.Yum.api.YumAPI;
|
||||
import pw.yumc.YumCore.commands.CommandManager;
|
||||
import pw.yumc.YumCore.commands.CommandSub;
|
||||
import pw.yumc.YumCore.commands.annotation.Async;
|
||||
import pw.yumc.YumCore.commands.annotation.Cmd;
|
||||
import pw.yumc.YumCore.commands.annotation.Help;
|
||||
import pw.yumc.YumCore.commands.annotation.KeyValue;
|
||||
import pw.yumc.YumCore.commands.interfaces.CommandExecutor;
|
||||
import pw.yumc.YumCore.commands.annotation.Option;
|
||||
import pw.yumc.YumCore.commands.interfaces.Executor;
|
||||
import pw.yumc.YumCore.kit.FileKit;
|
||||
|
||||
/**
|
||||
@ -28,7 +27,7 @@ import pw.yumc.YumCore.kit.FileKit;
|
||||
* @since 2016年1月9日 上午10:02:39
|
||||
* @author 喵♂呜
|
||||
*/
|
||||
public class FileCommand implements CommandExecutor {
|
||||
public class FileCommand implements Executor {
|
||||
private static String prefix = "§6[§bYum §a文件管理§6] ";
|
||||
|
||||
private static String file_not_found = prefix + "§b%s §c文件未找到!";
|
||||
@ -50,13 +49,13 @@ public class FileCommand implements CommandExecutor {
|
||||
|
||||
public FileCommand(Yum yum) {
|
||||
plugin = yum;
|
||||
new CommandManager("file", this, PluginTabComplete.instence);
|
||||
new CommandSub("file", this, PluginTabComplete.instence);
|
||||
}
|
||||
|
||||
@Cmd(aliases = "cp", minimumArguments = 2)
|
||||
@Help(value = "复制文件", possibleArguments = "<源文件> <目标目录>")
|
||||
@Async
|
||||
public void copy(CommandSender sender, @KeyValue(key = "check") File src, File des) throws FileNotFoundException, IOException {
|
||||
public void copy(CommandSender sender, @Option(value = "check") File src, File des) throws IOException {
|
||||
if (src.isDirectory()) {
|
||||
sender.sendMessage(String.format(file_is_dir, src.getPath()));
|
||||
return;
|
||||
|
@ -27,11 +27,11 @@ import pw.yumc.Yum.inject.ListenerInjector;
|
||||
import pw.yumc.Yum.inject.TaskInjector;
|
||||
import pw.yumc.Yum.managers.MonitorManager;
|
||||
import pw.yumc.Yum.managers.MonitorManager.MonitorInfo;
|
||||
import pw.yumc.YumCore.commands.CommandManager;
|
||||
import pw.yumc.YumCore.commands.CommandSub;
|
||||
import pw.yumc.YumCore.commands.annotation.Async;
|
||||
import pw.yumc.YumCore.commands.annotation.Cmd;
|
||||
import pw.yumc.YumCore.commands.annotation.Help;
|
||||
import pw.yumc.YumCore.commands.interfaces.CommandExecutor;
|
||||
import pw.yumc.YumCore.commands.interfaces.Executor;
|
||||
import pw.yumc.YumCore.kit.PKit;
|
||||
import pw.yumc.YumCore.kit.StrKit;
|
||||
import pw.yumc.YumCore.reflect.Reflect;
|
||||
@ -41,7 +41,7 @@ import pw.yumc.YumCore.reflect.Reflect;
|
||||
* @since 2016年7月6日 下午5:13:32
|
||||
* @author 喵♂呜
|
||||
*/
|
||||
public class MonitorCommand implements CommandExecutor {
|
||||
public class MonitorCommand implements Executor {
|
||||
public static Throwable lastError = null;
|
||||
|
||||
private String prefix = "§6[§bYum §a能耗监控§6] ";
|
||||
@ -70,7 +70,7 @@ public class MonitorCommand implements CommandExecutor {
|
||||
private double um = 1000000.00;
|
||||
|
||||
public MonitorCommand(Yum yum) {
|
||||
new CommandManager("monitor", this, PluginTabComplete.instence);
|
||||
new CommandSub("monitor", this, PluginTabComplete.instence);
|
||||
}
|
||||
|
||||
@Cmd(aliases = "c", minimumArguments = 1)
|
||||
@ -105,17 +105,9 @@ public class MonitorCommand implements CommandExecutor {
|
||||
CommandInjector injected = (CommandInjector) executor;
|
||||
if (injected.count != 0) {
|
||||
double avgTime = injected.totalTime / um / injected.count;
|
||||
sender.sendMessage(String.format(avgTime < 10 ? milist : miwlist,
|
||||
command.getValue().getName(),
|
||||
injected.totalTime / um,
|
||||
injected.count,
|
||||
avgTime));
|
||||
sender.sendMessage(String.format(avgTime < 10 ? milist : miwlist, command.getValue().getName(), injected.totalTime / um, injected.count, avgTime));
|
||||
} else {
|
||||
sender.sendMessage(String.format(milist,
|
||||
command.getValue().getName(),
|
||||
injected.totalTime / um,
|
||||
injected.count,
|
||||
0D));
|
||||
sender.sendMessage(String.format(milist, command.getValue().getName(), injected.totalTime / um, injected.count, 0D));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -167,11 +159,7 @@ public class MonitorCommand implements CommandExecutor {
|
||||
sender.sendMessage(mieprefix);
|
||||
for (String event : MonitorManager.sortMapByValue(eventTotalTime).keySet()) {
|
||||
double avgTime = eventTotalTime.get(event) / um / eventCount.get(event);
|
||||
sender.sendMessage(String.format(avgTime < 10 ? milist : miwlist,
|
||||
event,
|
||||
eventTotalTime.get(event) / um,
|
||||
eventCount.get(event),
|
||||
avgTime));
|
||||
sender.sendMessage(String.format(avgTime < 10 ? milist : miwlist, event, eventTotalTime.get(event) / um, eventCount.get(event), avgTime));
|
||||
}
|
||||
}
|
||||
|
||||
@ -204,13 +192,7 @@ public class MonitorCommand implements CommandExecutor {
|
||||
break;
|
||||
}
|
||||
MonitorInfo mi = MonitorManager.getMonitorInfo(entry.getKey());
|
||||
sender.sendMessage(String.format(laglist,
|
||||
size,
|
||||
entry.getKey(),
|
||||
getPer(sender, mi.monitor),
|
||||
mi.cmd,
|
||||
mi.event,
|
||||
mi.task));
|
||||
sender.sendMessage(String.format(laglist, size, entry.getKey(), getPer(sender, mi.monitor), mi.cmd, mi.event, mi.task));
|
||||
}
|
||||
}
|
||||
|
||||
@ -269,17 +251,9 @@ public class MonitorCommand implements CommandExecutor {
|
||||
TaskInjector executor = (TaskInjector) task;
|
||||
if (executor.count != 0) {
|
||||
double avgTime = executor.totalTime / um / executor.count;
|
||||
sender.sendMessage(String.format(avgTime < 10 ? milist : miwlist,
|
||||
getClassName(executor.getOriginalTask().getClass()),
|
||||
executor.totalTime / um,
|
||||
executor.count,
|
||||
avgTime));
|
||||
sender.sendMessage(String.format(avgTime < 10 ? milist : miwlist, getClassName(executor.getOriginalTask().getClass()), executor.totalTime / um, executor.count, avgTime));
|
||||
} else {
|
||||
sender.sendMessage(String.format(milist,
|
||||
getClassName(executor.getOriginalTask().getClass()),
|
||||
executor.totalTime / um,
|
||||
executor.count,
|
||||
0D));
|
||||
sender.sendMessage(String.format(milist, getClassName(executor.getOriginalTask().getClass()), executor.totalTime / um, executor.count, 0D));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -301,8 +275,7 @@ public class MonitorCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
private String getClassName(Class<?> clazz) {
|
||||
return StrKit.isBlank(clazz.getSimpleName()) ? clazz.getName().substring(clazz.getName().lastIndexOf(".") + 1)
|
||||
: clazz.getSimpleName();
|
||||
return StrKit.isBlank(clazz.getSimpleName()) ? clazz.getName().substring(clazz.getName().lastIndexOf(".") + 1) : clazz.getSimpleName();
|
||||
}
|
||||
|
||||
private String getPer(CommandSender sender, double per) {
|
||||
|
@ -8,13 +8,13 @@ import org.bukkit.command.CommandSender;
|
||||
|
||||
import pw.yumc.Yum.Yum;
|
||||
import pw.yumc.Yum.managers.ConfigManager;
|
||||
import pw.yumc.YumCore.commands.CommandManager;
|
||||
import pw.yumc.YumCore.commands.CommandSub;
|
||||
import pw.yumc.YumCore.commands.annotation.Async;
|
||||
import pw.yumc.YumCore.commands.annotation.Cmd;
|
||||
import pw.yumc.YumCore.commands.annotation.Help;
|
||||
import pw.yumc.YumCore.commands.interfaces.CommandExecutor;
|
||||
import pw.yumc.YumCore.commands.interfaces.Executor;
|
||||
|
||||
public class NetCommand implements CommandExecutor {
|
||||
public class NetCommand implements Executor {
|
||||
public static HashMap<String, Integer> netlist = new HashMap<>();
|
||||
|
||||
private String prefix = "§6[§bYum §a网络管理§6] ";
|
||||
@ -28,7 +28,7 @@ public class NetCommand implements CommandExecutor {
|
||||
private String p_n_f = prefix + "§c插件 §b%s §c不存在!";
|
||||
|
||||
public NetCommand(Yum yum) {
|
||||
new CommandManager("net", this, PluginTabComplete.instence);
|
||||
new CommandSub("net", this, PluginTabComplete.instence);
|
||||
}
|
||||
|
||||
public static void addNetCount(String pname) {
|
||||
|
@ -4,10 +4,11 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import pw.yumc.Yum.api.YumAPI;
|
||||
import pw.yumc.YumCore.commands.CommandArgument;
|
||||
import pw.yumc.YumCore.commands.annotation.Tab;
|
||||
import pw.yumc.YumCore.commands.interfaces.CommandExecutor;
|
||||
import pw.yumc.YumCore.commands.interfaces.Executor;
|
||||
import pw.yumc.YumCore.kit.StrKit;
|
||||
|
||||
/**
|
||||
@ -15,29 +16,20 @@ import pw.yumc.YumCore.kit.StrKit;
|
||||
* @since 2016年7月7日 上午8:36:47
|
||||
* @author 喵♂呜
|
||||
*/
|
||||
public class PluginTabComplete implements CommandExecutor {
|
||||
public class PluginTabComplete implements Executor {
|
||||
public static PluginTabComplete instence = new PluginTabComplete();
|
||||
|
||||
@Tab
|
||||
public List<String> listtab(CommandArgument e) {
|
||||
String[] args = e.getArgs();
|
||||
public List<String> listtab(CommandSender sender, String label, String[] args) {
|
||||
if (args[0].equalsIgnoreCase("install") || args[0].equalsIgnoreCase("i")) {
|
||||
return StrKit.copyPartialMatches(args[1], YumAPI.getRepo().getAllPluginName(), new ArrayList<String>());
|
||||
} else if (args[0].equalsIgnoreCase("repo") || args[0].equalsIgnoreCase("r")) {
|
||||
if (args.length == 2) { return StrKit.copyPartialMatches(args[1],
|
||||
Arrays.asList(new String[] { "add", "all", "list", "delall", "clean", "update", "del" }),
|
||||
new ArrayList<String>()); }
|
||||
if (args.length == 3 && (args[1] == "add" || args[1] == "del")) { return StrKit.copyPartialMatches(args[2],
|
||||
YumAPI.getRepo().getRepos().keySet(),
|
||||
new ArrayList<String>()); }
|
||||
if (args.length == 2) { return StrKit.copyPartialMatches(args[1], Arrays.asList("add", "all", "list", "delall", "clean", "update", "del"), new ArrayList<String>()); }
|
||||
if (args.length == 3 && ("add".equals(args[1]) || "del".equals(args[1]))) { return StrKit.copyPartialMatches(args[2], YumAPI.getRepo().getRepos().keySet(), new ArrayList<String>()); }
|
||||
} else if (args[0].equalsIgnoreCase("bukkitrepo") || args[0].equalsIgnoreCase("br")) {
|
||||
return StrKit.copyPartialMatches(args[1],
|
||||
Arrays.asList(new String[] { "look", "install" }),
|
||||
new ArrayList<String>());
|
||||
return StrKit.copyPartialMatches(args[1], Arrays.asList("look", "install"), new ArrayList<String>());
|
||||
} else {
|
||||
return StrKit.copyPartialMatches(args[1],
|
||||
YumAPI.getPlugman().getPluginNames(false),
|
||||
new ArrayList<String>());
|
||||
return StrKit.copyPartialMatches(args[args.length - 1], YumAPI.getPlugman().getPluginNames(false), new ArrayList<String>());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -11,9 +11,6 @@ import java.util.Map.Entry;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
@ -27,15 +24,14 @@ import pw.yumc.Yum.models.BukkitDev.Files;
|
||||
import pw.yumc.Yum.models.BukkitDev.Projects;
|
||||
import pw.yumc.Yum.models.RepoSerialization.Repositories;
|
||||
import pw.yumc.YumCore.callback.CallBack.One;
|
||||
import pw.yumc.YumCore.commands.CommandManager;
|
||||
import pw.yumc.YumCore.commands.CommandSub;
|
||||
import pw.yumc.YumCore.commands.annotation.Async;
|
||||
import pw.yumc.YumCore.commands.annotation.Cmd;
|
||||
import pw.yumc.YumCore.commands.annotation.Help;
|
||||
import pw.yumc.YumCore.commands.annotation.Sort;
|
||||
import pw.yumc.YumCore.commands.interfaces.CommandExecutor;
|
||||
import pw.yumc.YumCore.commands.interfaces.Executor;
|
||||
import pw.yumc.YumCore.kit.FileKit;
|
||||
import pw.yumc.YumCore.kit.HttpKit;
|
||||
import pw.yumc.YumCore.kit.PKit;
|
||||
import pw.yumc.YumCore.kit.ZipKit;
|
||||
import pw.yumc.YumCore.tellraw.Tellraw;
|
||||
|
||||
@ -45,7 +41,7 @@ import pw.yumc.YumCore.tellraw.Tellraw;
|
||||
* @since 2016年1月9日 上午10:02:24
|
||||
* @author 喵♂呜
|
||||
*/
|
||||
public class YumCommand implements Listener, CommandExecutor {
|
||||
public class YumCommand implements Executor {
|
||||
private String prefix = "§6[§bYum §a插件管理§6] ";
|
||||
|
||||
private String searchlimit = prefix + "§c为保证搜索速度和准确性 关键词必须大于 3 个字符!";
|
||||
@ -77,16 +73,13 @@ public class YumCommand implements Listener, CommandExecutor {
|
||||
|
||||
public YumCommand(Yum yum) {
|
||||
main = yum;
|
||||
Bukkit.getPluginManager().registerEvents(this, yum);
|
||||
new CommandManager("yum", this, PluginTabComplete.instence);
|
||||
new CommandSub("yum", this, PluginTabComplete.instence);
|
||||
}
|
||||
|
||||
@Async
|
||||
@Cmd(aliases = "br", minimumArguments = 2)
|
||||
@Help(value = "从BukkitDev查看安装插件", possibleArguments = "<操作符> <项目ID|项目名称> [地址]")
|
||||
public void bukkitrepo(final CommandSender sender, final String opt, final String id, final String url) {
|
||||
PKit.runTaskAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
public void bukkitrepo(final CommandSender sender, final String opt, final String id, String url) {
|
||||
switch (opt) {
|
||||
case "look": {
|
||||
sender.sendMessage(String.format(fsearching, id));
|
||||
@ -135,7 +128,7 @@ public class YumCommand implements Listener, CommandExecutor {
|
||||
return;
|
||||
}
|
||||
Files f = lf.get(0);
|
||||
String url = f.downloadUrl;
|
||||
url = f.downloadUrl;
|
||||
File file = new File(Bukkit.getUpdateFolderFile(), YumAPI.getDownload().getFileName(url));
|
||||
YumAPI.getDownload().run(sender, url, file, new One<File>() {
|
||||
@Override
|
||||
@ -157,8 +150,6 @@ public class YumCommand implements Listener, CommandExecutor {
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Cmd(aliases = "del", minimumArguments = 1)
|
||||
@Help(value = "删除插件", possibleArguments = "<插件名称>")
|
||||
@ -200,8 +191,7 @@ public class YumCommand implements Listener, CommandExecutor {
|
||||
Plugin plugin = (JavaPlugin) field.get(clazz.getClassLoader());
|
||||
Bukkit.dispatchCommand(sender, "yum info " + plugin.getName());
|
||||
} catch (ClassNotFoundException | NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e2) {
|
||||
sender.sendMessage("§4错误: 无法找到类 " + classname + " 所对应的插件信息 异常:" + e2.getClass().getSimpleName() + " "
|
||||
+ e2.getMessage() + "!");
|
||||
sender.sendMessage("§4错误: 无法找到类 " + classname + " 所对应的插件信息 异常:" + e2.getClass().getSimpleName() + " " + e2.getMessage() + "!");
|
||||
}
|
||||
}
|
||||
|
||||
@ -253,8 +243,7 @@ public class YumCommand implements Listener, CommandExecutor {
|
||||
if (plist != null) {
|
||||
sender.sendMessage("§6插件注册权限: " + (plist.isEmpty() ? "无" : ""));
|
||||
for (Permission perm : plist) {
|
||||
sender.sendMessage("§6 - §a" + perm.getName() + "§6 - §e"
|
||||
+ (perm.getDescription().isEmpty() ? "无描述" : perm.getDescription()));
|
||||
sender.sendMessage("§6 - §a" + perm.getName() + "§6 - §e" + (perm.getDescription().isEmpty() ? "无描述" : perm.getDescription()));
|
||||
}
|
||||
}
|
||||
sender.sendMessage("§6插件物理路径: §3" + YumAPI.getPlugman().getPluginFile(plugin).getAbsolutePath());
|
||||
@ -318,13 +307,6 @@ public class YumCommand implements Listener, CommandExecutor {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onAdminJoin(PlayerJoinEvent e) {
|
||||
if (e.getPlayer().isOp()) {
|
||||
YumAPI.updateCheck(e.getPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
@Cmd(aliases = "re")
|
||||
@Help(value = "重载插件", possibleArguments = "<插件名称|all|*>")
|
||||
@Sort(5)
|
||||
@ -469,13 +451,6 @@ public class YumCommand implements Listener, CommandExecutor {
|
||||
}
|
||||
}
|
||||
|
||||
@Cmd(aliases = "ua")
|
||||
@Help("更新所有可更新插件")
|
||||
@Sort(14)
|
||||
public void updateall(CommandSender sender) {
|
||||
YumAPI.updateAll(sender);
|
||||
}
|
||||
|
||||
@Cmd(aliases = "ug")
|
||||
@Help(value = "升级或安装插件", possibleArguments = "[插件名称]")
|
||||
@Sort(15)
|
||||
@ -488,8 +463,7 @@ public class YumCommand implements Listener, CommandExecutor {
|
||||
if (plugin != null) {
|
||||
YumAPI.upgrade(sender, plugin);
|
||||
} else {
|
||||
sender.sendMessage(
|
||||
"§c错误: §b插件 " + pluginname + " §c未安装或已卸载 需要安装请使用 §b/yum install " + pluginname + "!");
|
||||
sender.sendMessage("§c错误: §b插件 " + pluginname + " §c未安装或已卸载 需要安装请使用 §b/yum install " + pluginname + "!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ public class CommandInjector implements TabExecutor {
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
} catch (Throwable ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
@ -111,13 +111,7 @@ public class CommandInjector implements TabExecutor {
|
||||
long lagms = lag / MonitorManager.um;
|
||||
long avglagms = totalTime / count / MonitorManager.um;
|
||||
if (Bukkit.isPrimaryThread() && lagms > MonitorManager.lagTime && avglagms > MonitorManager.lagTime) {
|
||||
MonitorManager.lagTip(String.format(warn,
|
||||
sender.getName(),
|
||||
plugin.getName(),
|
||||
label,
|
||||
StrKit.join(args, " "),
|
||||
lagms,
|
||||
avglagms));
|
||||
MonitorManager.lagTip(String.format(warn, sender.getName(), plugin.getName(), label, StrKit.join(args, " "), lagms, avglagms));
|
||||
}
|
||||
MonitorManager.addCmd(plugin.getName(), lag);
|
||||
return result;
|
||||
@ -127,8 +121,7 @@ public class CommandInjector implements TabExecutor {
|
||||
}
|
||||
MonitorCommand.lastError = e;
|
||||
MonitorManager.sendError(sender, plugin, e);
|
||||
MonitorManager.printThrowable(
|
||||
String.format(err, sender.getName(), plugin.getName(), label, StrKit.join(args, " ")), e);
|
||||
MonitorManager.printThrowable(String.format(err, sender.getName(), plugin.getName(), label, StrKit.join(args, " ")), e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ public class ListenerInjector implements EventExecutor {
|
||||
Reflect.on(listener).set("executor", ((ListenerInjector) executor).getOriginalExecutor());
|
||||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
} catch (Throwable ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
@ -98,8 +98,7 @@ public class ListenerInjector implements EventExecutor {
|
||||
}
|
||||
long lagms = lag / MonitorManager.um;
|
||||
long avglagms = eventTotalTime.get(en) / eventCount.get(en) / MonitorManager.um;
|
||||
if (avglagms > MonitorManager.lagTime && lagms > MonitorManager.lagTime
|
||||
&& !ConfigManager.i().getMonitorIgnoreList().contains(plugin.getName())) {
|
||||
if (avglagms > MonitorManager.lagTime && lagms > MonitorManager.lagTime && !ConfigManager.i().getMonitorIgnoreList().contains(plugin.getName())) {
|
||||
MonitorManager.lagTip(String.format(warn, plugin.getName(), event.getEventName(), lagms, avglagms));
|
||||
}
|
||||
MonitorManager.addEvent(plugin.getName(), lag);
|
||||
|
@ -69,7 +69,7 @@ public class TaskInjector implements Runnable {
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
} catch (Throwable ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -42,6 +42,9 @@ public class PluginNetworkListener implements Listener {
|
||||
return;
|
||||
}
|
||||
if (plugin != null) {
|
||||
if (ConfigManager.i().isNetworkDebug() && ConfigManager.i().getNetWorkDebug().contains(plugin.getName())) {
|
||||
new Exception().printStackTrace();
|
||||
}
|
||||
NetCommand.addNetCount(plugin.getName());
|
||||
if (ConfigManager.i().getNetworkBlackList().contains(plugin.getName())) {
|
||||
breakNetwork(e);
|
||||
|
@ -109,6 +109,10 @@ public class ConfigManager {
|
||||
return thread.getBoolean("ThreadSafe", true);
|
||||
}
|
||||
|
||||
public List<String> getNetWorkDebug() {
|
||||
return network.getStringList("Debug");
|
||||
}
|
||||
|
||||
public void reload() {
|
||||
setop.reload();
|
||||
network.reload();
|
||||
|
@ -63,7 +63,7 @@ public class MonitorManager {
|
||||
|
||||
public static void elog(String message) {
|
||||
if (log_to_file) {
|
||||
elog.logSender(message);
|
||||
elog.console(message);
|
||||
} else {
|
||||
Log.console(message);
|
||||
}
|
||||
@ -91,7 +91,7 @@ public class MonitorManager {
|
||||
|
||||
public static void log(String message) {
|
||||
if (log_to_file) {
|
||||
mlog.logSender(message);
|
||||
mlog.console(message);
|
||||
} else {
|
||||
Log.console(message);
|
||||
}
|
||||
@ -143,7 +143,7 @@ public class MonitorManager {
|
||||
/**
|
||||
* 使用 Map按value进行排序
|
||||
*
|
||||
* @param map
|
||||
* @param oriMap
|
||||
* @return
|
||||
*/
|
||||
public static Map<String, Long> sortMapByValue(Map<String, Long> oriMap) {
|
||||
@ -152,7 +152,7 @@ public class MonitorManager {
|
||||
List<Map.Entry<String, Long>> entryList = new ArrayList<>(oriMap.entrySet());
|
||||
Collections.sort(entryList, new MonitorComparator());
|
||||
Iterator<Map.Entry<String, Long>> iter = entryList.iterator();
|
||||
Entry<String, Long> tmpEntry = null;
|
||||
Entry<String, Long> tmpEntry;
|
||||
while (iter.hasNext()) {
|
||||
tmpEntry = iter.next();
|
||||
sortedMap.put(tmpEntry.getKey(), tmpEntry.getValue());
|
||||
|
@ -41,7 +41,7 @@ public class RepositoryManager {
|
||||
|
||||
public boolean addPackage(CommandSender sender, String urlstring) {
|
||||
String json = HttpKit.get(urlstring);
|
||||
if (json == null || json.isEmpty()) { return false; }
|
||||
if (json.isEmpty()) { return false; }
|
||||
PackageInfo pkg = jsonToPackage(json);
|
||||
if (pkg == null) { return false; }
|
||||
updatePackage(sender, pkg);
|
||||
@ -51,8 +51,7 @@ public class RepositoryManager {
|
||||
public boolean addRepositories(CommandSender sender, String urlstring) {
|
||||
String url = handerRepoUrl(urlstring);
|
||||
Repositories repo = repocache.addRepo(url);
|
||||
if (repo == null) { return false; }
|
||||
return updateRepositories(sender, repo);
|
||||
return repo != null && updateRepositories(sender, repo);
|
||||
}
|
||||
|
||||
public void clean() {
|
||||
@ -90,10 +89,7 @@ public class RepositoryManager {
|
||||
List<TagInfo> taglist = plugin.tags;
|
||||
for (int i = 0; i < taglist.size(); i++) {
|
||||
TagInfo tag = taglist.get(i);
|
||||
li.add(" §b" + (i == taglist.size() - 1 ? "┗ " : "┣ ") + String.format("§c%s §a%s §e%s",
|
||||
tag.tag,
|
||||
tag.version,
|
||||
tag.type != null ? tag.type : URLType.Maven));
|
||||
li.add(" §b" + (i == taglist.size() - 1 ? "┗ " : "┣ ") + String.format("§c%s §a%s §e%s", tag.tag, tag.version, tag.type != null ? tag.type : URLType.Maven));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -142,8 +138,7 @@ public class RepositoryManager {
|
||||
String url = urlstring.substring(0, urlstring.endsWith("/") ? urllength - 1 : urllength);
|
||||
handerRepoUrl(url);
|
||||
Repositories repo = repocache.addRepo(urlstring);
|
||||
if (repo == null) { return false; }
|
||||
return updateRepositories(sender, repo);
|
||||
return repo != null && updateRepositories(sender, repo);
|
||||
}
|
||||
|
||||
public PackageInfo jsonToPackage(String json) {
|
||||
@ -194,7 +189,7 @@ public class RepositoryManager {
|
||||
sender = Bukkit.getConsoleSender();
|
||||
}
|
||||
if (repocenter == null || repocenter.repos.isEmpty()) {
|
||||
sender.sendMessage(String.format("§6[§bYum§6] 源 %s 数据为空或列表为空!", repocenter.name));
|
||||
sender.sendMessage(String.format("§6[§bYum§6] 源 %s 数据为空或列表为空!", repocenter == null ? "null" : repocenter.name));
|
||||
return false;
|
||||
}
|
||||
for (Repository repo : repocenter.repos) {
|
||||
|
@ -42,8 +42,8 @@ public class BukkitDev implements Serializable {
|
||||
if (StrKit.isBlank(json) || json.equals("[]")) { return Collections.emptyList(); }
|
||||
List<Files> temp = new ArrayList<>();
|
||||
JSONArray ja = (JSONArray) JSONValue.parse(json);
|
||||
for (int i = 0; i < ja.size(); i++) {
|
||||
temp.add(new Files((JSONObject) ja.get(i)));
|
||||
for (Object aJa : ja) {
|
||||
temp.add(new Files((JSONObject) aJa));
|
||||
}
|
||||
Collections.reverse(temp);
|
||||
return temp;
|
||||
@ -67,8 +67,8 @@ public class BukkitDev implements Serializable {
|
||||
if (StrKit.isBlank(json) || json.equals("[]")) { return Collections.emptyList(); }
|
||||
List<Projects> temp = new ArrayList<>();
|
||||
JSONArray ja = (JSONArray) JSONValue.parse(json);
|
||||
for (int i = 0; i < ja.size(); i++) {
|
||||
temp.add(new Projects((JSONObject) ja.get(i)));
|
||||
for (Object aJa : ja) {
|
||||
temp.add(new Projects((JSONObject) aJa));
|
||||
}
|
||||
return temp;
|
||||
}
|
||||
|
@ -36,10 +36,6 @@ public class PluginInfo implements Serializable {
|
||||
/**
|
||||
* 获得下载直链
|
||||
*
|
||||
* @param sender
|
||||
* 命令发送者
|
||||
* @param version
|
||||
* 版本
|
||||
* @return 下载直链
|
||||
*/
|
||||
public String getDirectUrl() {
|
||||
@ -49,8 +45,6 @@ public class PluginInfo implements Serializable {
|
||||
/**
|
||||
* 获得下载直链
|
||||
*
|
||||
* @param sender
|
||||
* 命令发送者
|
||||
* @param version
|
||||
* 版本
|
||||
* @return 下载直链
|
||||
@ -82,9 +76,7 @@ public class PluginInfo implements Serializable {
|
||||
/**
|
||||
* 获取Maven仓库指定插件的下载地址
|
||||
*
|
||||
* @param sender
|
||||
* - 命令发送者
|
||||
* @param version
|
||||
* @param ver
|
||||
* - 需要更新的版本
|
||||
* @return 更新地址
|
||||
*/
|
||||
@ -148,7 +140,7 @@ public class PluginInfo implements Serializable {
|
||||
final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||
final DocumentBuilder builder = factory.newDocumentBuilder();
|
||||
result = builder.parse(url).getElementsByTagName(tag).item(0).getTextContent();
|
||||
} catch (final Exception e) {
|
||||
} catch (final Exception ignored) {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ public class RepoCache implements Serializable {
|
||||
|
||||
public Repositories getRepo(String repo) {
|
||||
String json = HttpKit.get(repo);
|
||||
if (json == null || json.isEmpty()) {
|
||||
if (json.isEmpty()) {
|
||||
Log.console("§c源地址获取数据为空 §b" + repo);
|
||||
return null;
|
||||
}
|
||||
|
@ -131,6 +131,6 @@ public class RepoSerialization {
|
||||
public enum URLType {
|
||||
Maven,
|
||||
maven,
|
||||
DirectUrl;
|
||||
DirectUrl
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ public class MainThreadCheckTask extends TimerTask {
|
||||
try {
|
||||
Class clazz = Class.forName("org.spigotmc.WatchdogThread");
|
||||
tickMethod = clazz.getDeclaredMethod("tick");
|
||||
} catch (Exception e) {
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -13,6 +13,9 @@ ShowInfo: true
|
||||
NetworkDebug: false
|
||||
#是否允许插件主线程访问网络
|
||||
AllowPrimaryThread: false
|
||||
#调试列表
|
||||
Debug:
|
||||
- AAC
|
||||
#黑名单列表
|
||||
Black:
|
||||
- BukkitInjectedTools
|
||||
|
Loading…
Reference in New Issue
Block a user