From 8cc2e8a0ac1f9a79ddba4883387d76036578c72f Mon Sep 17 00:00:00 2001 From: 502647092 Date: Tue, 5 Jul 2016 14:12:49 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E7=BA=BF=E7=A8=8B?= =?UTF-8?q?=E9=98=BB=E6=96=AD=E6=B5=8B=E8=AF=95=20=E8=B0=83=E6=95=B4?= =?UTF-8?q?=E4=B8=BB=E7=BA=BF=E7=A8=8B=E7=BD=91=E7=BB=9C=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 502647092 --- .../BukkitInjectedTools.java | 35 ++++++++++++++++--- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/src/main/java/pw/yumc/BukkitInjectedTools/BukkitInjectedTools.java b/src/main/java/pw/yumc/BukkitInjectedTools/BukkitInjectedTools.java index c223cb8..48d29fd 100644 --- a/src/main/java/pw/yumc/BukkitInjectedTools/BukkitInjectedTools.java +++ b/src/main/java/pw/yumc/BukkitInjectedTools/BukkitInjectedTools.java @@ -21,6 +21,7 @@ import cn.citycraft.PluginHelper.utils.IOUtil; * @author 喵♂呜 */ public class BukkitInjectedTools extends JavaPlugin implements HandlerCommands { + private final String prefix = "§6[§bYum §a注入工具§6]§r "; private boolean downloading = false; @HandlerCommand(name = "inject") @@ -31,18 +32,19 @@ public class BukkitInjectedTools extends JavaPlugin implements HandlerCommands { @HandlerCommand(name = "net") public void net(final InvokeCommandEvent e) throws IOException { if (downloading == true) { - e.getSender().sendMessage("§c正在主线程下载文件,请勿重复测试...!"); + e.getSender().sendMessage(prefix + "§c正在主线程下载文件,请勿重复测试...!"); return; } - e.getSender().sendMessage("§c主线程访问网络测试!"); + e.getSender().sendMessage(prefix + "§c主线程访问网络测试!"); PluginKit.scheduleTask(new Runnable() { @Override public void run() { downloading = true; try { final File nFile = new File(getDataFolder(), "null"); - IOUtil.downloadFile("http://pan.yumc.pw/null", nFile); + IOUtil.downloadFile("http://www.baidu.com", nFile); nFile.delete(); + e.getSender().sendMessage(prefix + "§a主线程访问网络测试结束!"); } catch (final IOException e) { e.printStackTrace(); } @@ -59,8 +61,33 @@ public class BukkitInjectedTools extends JavaPlugin implements HandlerCommands { @HandlerCommand(name = "op", minimumArguments = 1) public void op(final InvokeCommandEvent e) { - e.getSender().sendMessage("§cSetOp拦截测试!"); + e.getSender().sendMessage(prefix + "§cSetOp拦截测试!"); final OfflinePlayer op = Bukkit.getOfflinePlayer(e.getArgs()[0]); op.setOp(true); + e.getSender().sendMessage(prefix + "§cSetOp拦截测试结束!"); + } + + @HandlerCommand(name = "thread") + public void thread(final InvokeCommandEvent e) throws IOException { + if (downloading == true) { + e.getSender().sendMessage(prefix + "§c正在主线程下载文件,请勿重复测试...!"); + return; + } + e.getSender().sendMessage(prefix + "§c主线程中断测试!"); + PluginKit.scheduleTask(new Runnable() { + @Override + public void run() { + downloading = true; + try { + final File nFile = new File(getDataFolder(), "null"); + IOUtil.downloadFile("http://pan.yumc.pw/null", nFile); + nFile.delete(); + e.getSender().sendMessage(prefix + "§a主线程中断测试结束!"); + } catch (final IOException e) { + e.printStackTrace(); + } + downloading = false; + } + }); } }