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