feat: 修复部分BUG 添加从BukkitDev获取插件功能

Signed-off-by: 502647092 <admin@yumc.pw>
This commit is contained in:
502647092 2016-07-19 00:37:04 +08:00
parent e954b10e82
commit 340718446b
4 changed files with 51 additions and 5 deletions

View File

@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>pw.yumc</groupId>
<artifactId>Yum</artifactId>
<version>2.6.3</version>
<version>2.6.4</version>
<name>Yum</name>
<description>Minecraft 服务器插件管理系统</description>
<build>
@ -60,7 +60,7 @@
<properties>
<update.description>&amp;a全新 2.X 版本 更多守护与优化</update.description>
<update.changes>
&amp;e预告 &amp;6- &amp;e下个版本将加入&amp;bBukkitDev&amp;e下载和更新...;
&amp;b2.6.4 &amp;6- &amp;e添加&amp;bBukkitDev&amp;e下载和更新...;
&amp;b2.6.3 &amp;6- &amp;a注入操作延时执行 防止部分任务未注册 添加手动注入...;
&amp;b2.6.2 &amp;6- &amp;d能耗监控添加忽略列表 &amp;3详见monitor.yml...;
&amp;b2.6.1 &amp;6- &amp;c优化能耗监控 命令别名修改为mi(防止与ESS冲突)...;

View File

@ -20,10 +20,14 @@ import cn.citycraft.PluginHelper.commands.HandlerCommand;
import cn.citycraft.PluginHelper.commands.HandlerCommands;
import cn.citycraft.PluginHelper.commands.InvokeCommandEvent;
import cn.citycraft.PluginHelper.commands.InvokeSubCommand;
import cn.citycraft.PluginHelper.jsonresult.JsonHandle;
import cn.citycraft.PluginHelper.utils.IOUtil;
import cn.citycraft.PluginHelper.utils.StrKit;
import pw.yumc.Yum.Yum;
import pw.yumc.Yum.api.YumAPI;
import pw.yumc.Yum.managers.ConfigManager;
import pw.yumc.Yum.models.BukkitDev;
import pw.yumc.Yum.models.BukkitDev.Projects;
import pw.yumc.Yum.models.RepoSerialization.Repositories;
/**
@ -33,6 +37,10 @@ import pw.yumc.Yum.models.RepoSerialization.Repositories;
* @author
*/
public class YumCommand implements HandlerCommands, Listener {
private final String prefix = "§6[§bYum §a插件管理§6] ";
private final String not_found_from_bukkit = prefix + "§c未在BukkitDev搜索到 %s 的相关插件!";
private final String bukkitlistprefix = " §6插件名称 §d发布类型";
private final String bukkitlist = "§6- §b&s §d%s";
Yum main;
public YumCommand(final Yum yum) {
@ -262,6 +270,21 @@ public class YumCommand implements HandlerCommands, Listener {
});
}
@HandlerCommand(name = "search", aliases = "s", minimumArguments = 1, description = "从BukkitDev搜索插件", possibleArguments = "插件名称")
public void search(final InvokeCommandEvent e) {
final String pname = e.getArgs()[0];
final CommandSender sender = e.getSender();
final BukkitDev bd = JsonHandle.fromJson(IOUtil.getData(String.format(BukkitDev.SEARCH, pname)), BukkitDev.class);
if (bd.projects.isEmpty()) {
sender.sendMessage(String.format(not_found_from_bukkit, pname));
return;
}
sender.sendMessage(bukkitlistprefix);
for (final Projects p : bd.projects) {
sender.sendMessage(String.format(bukkitlist, p.name, p.stage));
}
}
/**
* 发生实体消息
*

View File

@ -37,7 +37,6 @@ public class PluginNetworkListener implements Listener {
if (urlinfo.startsWith("socket")) {
return;
}
NetCommand.addNetCount(plugin.getName());
if (ConfigManager.i().getNetworkWhiteURL().contains(e.getUrl().getHost())) {
return;
}
@ -47,6 +46,7 @@ public class PluginNetworkListener implements Listener {
return;
}
if (plugin != null) {
NetCommand.addNetCount(plugin.getName());
if (ConfigManager.i().getNetworkBlackList().contains(plugin.getName())) {
breakNetwork(e);
return;

View File

@ -4,6 +4,29 @@ import java.io.Serializable;
import java.util.List;
public class BukkitDev implements Serializable {
public String name;
public List<PluginInfo> pil;
public volatile static String HOST = "https://api.curseforge.com";
public volatile static String MODULE = "/servermods";
public volatile static String SEARCH = HOST + MODULE + "/projects?search=%s";
public volatile static String PLUGIN = HOST + MODULE + "/files?projectIds=%s";
public List<Projects> projects;
public List<Files> files;
public static class Files {
public int projectId;
public String name;
public String fileUrl;
public String fileName;
public String downloadUrl;
public String gameVersion;
public String md5;
public String releaseType;
}
public static class Projects {
public int id;
public String name;
public String slug;
public String stage;
}
}