1
0
mirror of https://e.coding.net/circlecloud/BukkitInjectedTools.git synced 2024-11-24 01:58:50 +00:00

feat: 添加线程阻断测试 调整主线程网络测试

Signed-off-by: 502647092 <admin@yumc.pw>
This commit is contained in:
502647092 2016-07-05 14:12:49 +08:00
parent 01d6fa17e5
commit 8cc2e8a0ac

View File

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