mirror of
https://e.coding.net/circlecloud/Yum.git
synced 2024-11-22 06:18:46 +00:00
fix: tabComplete Error
Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
parent
9f54734414
commit
37fb899e95
5
pom.xml
5
pom.xml
@ -3,7 +3,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>Yum</artifactId>
|
||||
<version>2.8.3</version>
|
||||
<version>2.9.0</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<description>Minecraft 服务器插件管理系统</description>
|
||||
@ -16,8 +16,9 @@
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<update.description>§a补丁包 2.8.3 版本</update.description>
|
||||
<update.description>§a补丁包 2.9.0 版本</update.description>
|
||||
<update.changes>
|
||||
§619-09-30 §cfix: tabComplete error;
|
||||
§619-08-28 §cfix: knownCommands not compatible;
|
||||
§cfix: async event on primary thread;
|
||||
§619-08-26 §cfix: 修复不兼容 1.14.4 的问题;
|
||||
|
@ -49,7 +49,7 @@ public class FileCommand implements Executor {
|
||||
|
||||
public FileCommand(Yum yum) {
|
||||
plugin = yum;
|
||||
new CommandSub("file", this, PluginTabComplete.instence);
|
||||
new CommandSub("file", this, PluginTabComplete.INSTANCE);
|
||||
}
|
||||
|
||||
@Cmd(aliases = "cp", minimumArguments = 2)
|
||||
|
@ -70,7 +70,7 @@ public class MonitorCommand implements Executor {
|
||||
private double um = 1000000.00;
|
||||
|
||||
public MonitorCommand(Yum yum) {
|
||||
new CommandSub("monitor", this, PluginTabComplete.instence);
|
||||
new CommandSub("monitor", this, PluginTabComplete.INSTANCE);
|
||||
}
|
||||
|
||||
@Cmd(aliases = "c", minimumArguments = 1)
|
||||
@ -116,7 +116,7 @@ public class MonitorCommand implements Executor {
|
||||
@Cmd(aliases = "e", minimumArguments = 1)
|
||||
@Help(value = "查看插件事件能耗", possibleArguments = "[插件名称]")
|
||||
@Async
|
||||
public void event(CommandSender sender, String pname) throws InstantiationException, IllegalAccessException, NoSuchFieldException {
|
||||
public void event(CommandSender sender, String pname) throws IllegalAccessException, NoSuchFieldException {
|
||||
Plugin plugin = Bukkit.getPluginManager().getPlugin(pname);
|
||||
if (plugin == null) {
|
||||
sender.sendMessage(String.format(p_n_f, pname));
|
||||
|
@ -28,7 +28,7 @@ public class NetCommand implements Executor {
|
||||
private String p_n_f = prefix + "§c插件 §b%s §c不存在!";
|
||||
|
||||
public NetCommand(Yum yum) {
|
||||
new CommandSub("net", this, PluginTabComplete.instence);
|
||||
new CommandSub("net", this, PluginTabComplete.INSTANCE);
|
||||
}
|
||||
|
||||
public static void addNetCount(String pname) {
|
||||
|
@ -9,28 +9,36 @@ import org.bukkit.command.CommandSender;
|
||||
import pw.yumc.Yum.api.YumAPI;
|
||||
import pw.yumc.YumCore.commands.annotation.Tab;
|
||||
import pw.yumc.YumCore.commands.interfaces.Executor;
|
||||
import pw.yumc.YumCore.kit.StrKit;
|
||||
|
||||
/**
|
||||
*
|
||||
* @since 2016年7月7日 上午8:36:47
|
||||
* @author 喵♂呜
|
||||
* @since 2016年7月7日 上午8:36:47
|
||||
*/
|
||||
public class PluginTabComplete implements Executor {
|
||||
public static PluginTabComplete instence = new PluginTabComplete();
|
||||
public static PluginTabComplete INSTANCE = new PluginTabComplete();
|
||||
|
||||
@Tab
|
||||
public List<String> listtab(CommandSender sender, String label, String[] args) {
|
||||
if (args.length > 1 && 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("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("look", "install"), new ArrayList<String>());
|
||||
} else {
|
||||
return StrKit.copyPartialMatches(args[args.length - 1], YumAPI.getPlugman().getPluginNames(false), new ArrayList<String>());
|
||||
public List<String> listTab(CommandSender sender, String label, String[] args) {
|
||||
if (args.length > 0) {
|
||||
switch (args[0]) {
|
||||
case "install":
|
||||
case "i":
|
||||
return YumAPI.getRepo().getAllPluginName();
|
||||
case "repo":
|
||||
case "r":
|
||||
if (args.length == 2) {
|
||||
return Arrays.asList("add", "all", "list", "delall", "clean", "update", "del");
|
||||
}
|
||||
return null;
|
||||
if (args.length == 3) {
|
||||
return new ArrayList<>(YumAPI.getRepo().getRepos().keySet());
|
||||
}
|
||||
break;
|
||||
case "bukkitrepo":
|
||||
case "br":
|
||||
return Arrays.asList("look", "install");
|
||||
default:
|
||||
}
|
||||
}
|
||||
return YumAPI.getPlugman().getPluginNames(false);
|
||||
}
|
||||
}
|
||||
|
@ -38,30 +38,30 @@ import pw.yumc.YumCore.tellraw.Tellraw;
|
||||
/**
|
||||
* Yum命令基类
|
||||
*
|
||||
* @since 2016年1月9日 上午10:02:24
|
||||
* @author 喵♂呜
|
||||
* @since 2016年1月9日 上午10:02:24
|
||||
*/
|
||||
public class YumCommand implements Executor {
|
||||
private String prefix = "§6[§bYum §a插件管理§6] ";
|
||||
|
||||
private String searchlimit = prefix + "§c为保证搜索速度和准确性 关键词必须大于 3 个字符!";
|
||||
private String searchLimit = prefix + "§c为保证搜索速度和准确性 关键词必须大于 3 个字符!";
|
||||
private String searching = prefix + "§a正在从 §eBukkitDev §a获取 §b%s §a的相关数据...";
|
||||
private String not_found_from_bukkit = prefix + "§c未在 §eBukkitDev §c搜索到 §b%s §c的相关插件!";
|
||||
private String notFoundFromBukkit = prefix + "§c未在 §eBukkitDev §c搜索到 §b%s §c的相关插件!";
|
||||
private String result = prefix + "§6关键词 §b%s §6的搜索结果如下:";
|
||||
private String bukkitlistprefix = " §6插件ID §3插件名称 §d发布类型 §a操作";
|
||||
private String bukkitlist = "§6- §e%-6s §b%-25s §d%-10s";
|
||||
private String bukkitListPrefix = " §6插件ID §3插件名称 §d发布类型 §a操作";
|
||||
private String bukkitList = "§6- §e%-6s §b%-25s §d%-10s";
|
||||
|
||||
private String fsearching = prefix + "§a正在从 §eBukkitDev §a获取ID §b%s §a的文件列表...";
|
||||
private String not_found_id_from_bukkit = prefix + "§c未在 §eBukkitDev §c搜索到ID为 §b%s §c的相关插件!";
|
||||
private String filelistprefix = " §6插件名称 §3游戏版本 §d发布类型 §a操作";
|
||||
private String filelist = "§6- §b%-20s §3%-15s §d%-10s";
|
||||
private String notFoundIdFromBukkit = prefix + "§c未在 §eBukkitDev §c搜索到ID为 §b%s §c的相关插件!";
|
||||
private String fileListPrefix = " §6插件名称 §3游戏版本 §d发布类型 §a操作";
|
||||
private String fileList = "§6- §b%-20s §3%-15s §d%-10s";
|
||||
|
||||
private String del = "§c删除: §a插件 §b%s §a版本 §d%s §a已从服务器卸载并删除!";
|
||||
private String delFailed = "§c删除: §a插件 §b%s §c卸载或删除时发生错误 删除失败!";
|
||||
|
||||
private String look = "§6查看";
|
||||
private String install = "§a安装";
|
||||
private String install_tip = "§a点击安装";
|
||||
private String installTip = "§a点击安装";
|
||||
private String update = "§a更新";
|
||||
private String unload = "§d卸载";
|
||||
private String reload = "§6重载";
|
||||
@ -73,7 +73,7 @@ public class YumCommand implements Executor {
|
||||
|
||||
public YumCommand(Yum yum) {
|
||||
main = yum;
|
||||
new CommandSub("yum", this, PluginTabComplete.instence);
|
||||
new CommandSub("yum", this, PluginTabComplete.INSTANCE);
|
||||
}
|
||||
|
||||
@Async
|
||||
@ -85,17 +85,17 @@ public class YumCommand implements Executor {
|
||||
sender.sendMessage(String.format(fsearching, id));
|
||||
List<Files> lf = Files.parseList(HttpKit.get(String.format(BukkitDev.PLUGIN, id)));
|
||||
if (lf.isEmpty()) {
|
||||
sender.sendMessage(String.format(not_found_id_from_bukkit, id));
|
||||
sender.sendMessage(String.format(notFoundIdFromBukkit, id));
|
||||
return;
|
||||
}
|
||||
sender.sendMessage(filelistprefix);
|
||||
sender.sendMessage(fileListPrefix);
|
||||
for (int i = 0; i < lf.size() || i < 8; i++) {
|
||||
Files f = lf.get(i);
|
||||
Tellraw tr = Tellraw.create();
|
||||
tr.text(String.format(filelist, f.name, f.gameVersion, f.releaseType));
|
||||
tr.text(String.format(fileList, f.name, f.gameVersion, f.releaseType));
|
||||
tr.then(" ");
|
||||
tr.then(install).command(String.format("/yum br ai %s %s", f.name, f.downloadUrl));
|
||||
tr.tip(install_tip);
|
||||
tr.tip(installTip);
|
||||
tr.send(sender);
|
||||
}
|
||||
break;
|
||||
@ -124,7 +124,7 @@ public class YumCommand implements Executor {
|
||||
sender.sendMessage(String.format(fsearching, id));
|
||||
List<Files> lf = Files.parseList(HttpKit.get(String.format(BukkitDev.PLUGIN, id)));
|
||||
if (lf.isEmpty()) {
|
||||
sender.sendMessage(String.format(not_found_id_from_bukkit, id));
|
||||
sender.sendMessage(String.format(notFoundIdFromBukkit, id));
|
||||
return;
|
||||
}
|
||||
Files f = lf.get(0);
|
||||
@ -146,8 +146,6 @@ public class YumCommand implements Executor {
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -388,20 +386,20 @@ public class YumCommand implements Executor {
|
||||
@Async
|
||||
public void search(CommandSender sender, String pname) {
|
||||
if (pname.length() < 3) {
|
||||
sender.sendMessage(searchlimit);
|
||||
sender.sendMessage(searchLimit);
|
||||
return;
|
||||
}
|
||||
sender.sendMessage(String.format(searching, pname));
|
||||
List<Projects> list = Projects.parseList(HttpKit.get(String.format(BukkitDev.SEARCH, pname.toLowerCase())));
|
||||
if (list.isEmpty()) {
|
||||
sender.sendMessage(String.format(not_found_from_bukkit, pname));
|
||||
sender.sendMessage(String.format(notFoundFromBukkit, pname));
|
||||
return;
|
||||
}
|
||||
sender.sendMessage(String.format(result, pname));
|
||||
sender.sendMessage(bukkitlistprefix);
|
||||
sender.sendMessage(bukkitListPrefix);
|
||||
for (Projects p : list) {
|
||||
Tellraw fm = Tellraw.create();
|
||||
fm.text(String.format(bukkitlist, p.id, p.name, p.stage));
|
||||
fm.text(String.format(bukkitList, p.id, p.name, p.stage));
|
||||
fm.then(" ");
|
||||
fm.then(look).cmd_tip("/yum br look " + p.id, look);
|
||||
fm.send(sender);
|
||||
@ -488,7 +486,7 @@ public class YumCommand implements Executor {
|
||||
private void sendEntry(CommandSender sender, String prefix, Map<String, Object> map, String key) {
|
||||
Object value = map.get(key);
|
||||
if (value != null) {
|
||||
sender.sendMessage(prefix + (String) value);
|
||||
sender.sendMessage(prefix + value);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user