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; + } + }); } }