feat: 修复快捷点击按钮触发命令错误

Signed-off-by: 502647092 <admin@yumc.pw>
This commit is contained in:
502647092 2016-07-19 23:41:31 +08:00
parent df4a8bc96f
commit 0fcecd63cf
5 changed files with 18 additions and 20 deletions

View File

@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>pw.yumc</groupId> <groupId>pw.yumc</groupId>
<artifactId>Yum</artifactId> <artifactId>Yum</artifactId>
<version>2.6.5</version> <version>2.6.6</version>
<name>Yum</name> <name>Yum</name>
<description>Minecraft 服务器插件管理系统</description> <description>Minecraft 服务器插件管理系统</description>
<build> <build>
@ -61,11 +61,10 @@
<update.description>&amp;a全新 2.X 版本 更多守护与优化</update.description> <update.description>&amp;a全新 2.X 版本 更多守护与优化</update.description>
<update.changes> <update.changes>
&amp;c注意 &amp;6- &amp;cYum更新需要重启服务器!重启服务器!重启服务器!; &amp;c注意 &amp;6- &amp;cYum更新需要重启服务器!重启服务器!重启服务器!;
&amp;b2.6.6 &amp;6- &amp;c修复快捷点击按钮触发命令错误...;
&amp;b2.6.5 &amp;6- &amp;c修复list命令 &amp;a添加全局能耗统计...; &amp;b2.6.5 &amp;6- &amp;c修复list命令 &amp;a添加全局能耗统计...;
&amp;b2.6.4 &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.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冲突)...;
</update.changes> </update.changes>
<env.GIT_COMMIT>DEBUG</env.GIT_COMMIT> <env.GIT_COMMIT>DEBUG</env.GIT_COMMIT>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

View File

@ -98,7 +98,7 @@ public class YumCommand implements HandlerCommands, Listener {
final FancyMessage fm = FancyMessage.newFM(); final FancyMessage fm = FancyMessage.newFM();
fm.text(String.format(filelist, f.name, f.gameVersion, f.releaseType)); fm.text(String.format(filelist, f.name, f.gameVersion, f.releaseType));
fm.then(" "); fm.then(" ");
fm.then(install).command(String.format("yum br install %s %s", f.name, f.downloadUrl)); fm.then(install).command(String.format("/yum br install %s %s", f.name, f.downloadUrl));
fm.send(sender); fm.send(sender);
} }
break; break;
@ -246,15 +246,15 @@ public class YumCommand implements HandlerCommands, Listener {
for (final Plugin plugin : Bukkit.getPluginManager().getPlugins()) { for (final Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
final String pname = plugin.getName(); final String pname = plugin.getName();
final FancyMessage fm = FancyMessage.newFM(); final FancyMessage fm = FancyMessage.newFM();
fm.text(String.format("§6- %-25s", YumAPI.getPlugman().getFormattedName(plugin, true))); fm.text(String.format("§6- %-32s", YumAPI.getPlugman().getFormattedName(plugin, true)));
fm.then(" "); fm.then(" ");
fm.then(update).command("yum u " + pname); fm.then(update).command("/yum u " + pname);
fm.then(" "); fm.then(" ");
fm.then(unload).command("yum unload " + pname); fm.then(unload).command("/yum unload " + pname);
fm.then(" "); fm.then(" ");
fm.then(reload).command("yum re " + pname); fm.then(reload).command("/yum re " + pname);
fm.then(" "); fm.then(" ");
fm.then(delete).command("yum del " + pname); fm.then(delete).command("/yum del " + pname);
fm.send(sender); fm.send(sender);
} }
} }
@ -381,7 +381,7 @@ public class YumCommand implements HandlerCommands, Listener {
final FancyMessage fm = FancyMessage.newFM(); final FancyMessage fm = FancyMessage.newFM();
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).command("yum br look " + p.id); fm.then(look).command("/yum br look " + p.id);
fm.send(sender); fm.send(sender);
} }
} }

View File

@ -44,13 +44,11 @@ public class CommandInjector implements TabExecutor {
final PluginCommand pluginCommand = (PluginCommand) command; final PluginCommand pluginCommand = (PluginCommand) command;
final Plugin plugin = pluginCommand.getPlugin(); final Plugin plugin = pluginCommand.getPlugin();
if (plugin.equals(toInjectPlugin)) { if (plugin.equals(toInjectPlugin)) {
CommandExecutor executor = Reflect.on(command).get("executor"); final CommandExecutor executor = Reflect.on(command).get("executor");
TabCompleter completer = Reflect.on(command).get("completer");;
if (executor instanceof CommandInjector) { if (executor instanceof CommandInjector) {
final CommandInjector cInjector = (CommandInjector) executor; return;
executor = cInjector.getOriginalExecutor();
completer = cInjector.getOriginalCompleter();
} }
final TabCompleter completer = Reflect.on(command).get("completer");
final CommandInjector commandInjector = new CommandInjector(executor, completer, toInjectPlugin); final CommandInjector commandInjector = new CommandInjector(executor, completer, toInjectPlugin);
Reflect.on(command).set("executor", commandInjector); Reflect.on(command).set("executor", commandInjector);
Reflect.on(command).set("completer", commandInjector); Reflect.on(command).set("completer", commandInjector);
@ -99,7 +97,8 @@ public class CommandInjector implements TabExecutor {
final long end = System.nanoTime(); final long end = System.nanoTime();
final long lag = end - start; final long lag = end - start;
if (Bukkit.isPrimaryThread() && lag / 1000000 > 10) { if (Bukkit.isPrimaryThread() && lag / 1000000 > 10) {
PluginKit.sc("§6[§bYum §a能耗监控§6] §c注意! §6玩家 §a" + sender.getName() + " §6执行 §b" + plugin.getName() + " §6插件 §d" + label + " " + StrKit.join(args, " ") + " §6命令 §c耗时 §4" + lag / 1000000 + "ms!"); PluginKit.sc("§6[§bYum §a能耗监控§6] §c注意! §6玩家 §a" + sender.getName() + " §6执行 §b" + plugin.getName() + " §6插件 §d" + label + " " + StrKit.join(args, " ") + " §6命令 §c耗时 §4" + lag / 1000000
+ "ms!");
} }
totalTime += lag; totalTime += lag;
count++; count++;

View File

@ -41,9 +41,9 @@ public class ListenerInjector implements EventExecutor {
if (listener instanceof TimedRegisteredListener) { if (listener instanceof TimedRegisteredListener) {
return; return;
} }
EventExecutor originalExecutor = Reflect.on(listener).get("executor"); final EventExecutor originalExecutor = Reflect.on(listener).get("executor");
if (originalExecutor instanceof ListenerInjector) { if (originalExecutor instanceof ListenerInjector) {
originalExecutor = ((ListenerInjector) originalExecutor).getOriginalExecutor(); return;
} }
final ListenerInjector listenerInjector = new ListenerInjector(originalExecutor, plugin); final ListenerInjector listenerInjector = new ListenerInjector(originalExecutor, plugin);
Reflect.on(listener).set("executor", listenerInjector); Reflect.on(listener).set("executor", listenerInjector);

View File

@ -39,9 +39,9 @@ public class TaskInjector implements Runnable {
for (final BukkitTask pendingTask : pendingTasks) { for (final BukkitTask pendingTask : pendingTasks) {
// 忽略异步任务 // 忽略异步任务
if (pendingTask.isSync() && pendingTask.getOwner().equals(plugin)) { if (pendingTask.isSync() && pendingTask.getOwner().equals(plugin)) {
Runnable originalTask = Reflect.on(pendingTask).get("task"); final Runnable originalTask = Reflect.on(pendingTask).get("task");
if (originalTask instanceof TaskInjector) { if (originalTask instanceof TaskInjector) {
originalTask = ((TaskInjector) originalTask).getOriginalTask(); return;
} }
final TaskInjector taskInjector = new TaskInjector(originalTask, plugin); final TaskInjector taskInjector = new TaskInjector(originalTask, plugin);
Reflect.on(pendingTask).set("task", taskInjector); Reflect.on(pendingTask).set("task", taskInjector);