parent
da842ad9da
commit
1eb240ec44
14
pom.xml
14
pom.xml
|
@ -84,23 +84,11 @@
|
|||
</repository>
|
||||
</distributionManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<type>jar</type>
|
||||
<version>1.9-R0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.citycraft</groupId>
|
||||
<artifactId>PluginHelper</artifactId>
|
||||
<type>jar</type>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>pw.yumc</groupId>
|
||||
<artifactId>YumCore</artifactId>
|
||||
<type>jar</type>
|
||||
<version>1.0</version>
|
||||
<version>1.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ProtocolSupport</groupId>
|
||||
|
|
|
@ -1,21 +1,22 @@
|
|||
package pw.yumc.BukkitInjectedTools;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
|
||||
import cn.citycraft.PluginHelper.kit.PluginKit;
|
||||
import cn.citycraft.PluginHelper.utils.IOUtil;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import pw.yumc.BukkitInjectedTools.event.YumTestEvent;
|
||||
import pw.yumc.YumCore.bukkit.Log;
|
||||
import pw.yumc.YumCore.bukkit.P;
|
||||
import pw.yumc.YumCore.commands.CommandArgument;
|
||||
import pw.yumc.YumCore.commands.CommandExecutor;
|
||||
import pw.yumc.YumCore.commands.CommandManager;
|
||||
import pw.yumc.YumCore.commands.CommandSub;
|
||||
import pw.yumc.YumCore.commands.annotation.Cmd;
|
||||
import pw.yumc.YumCore.commands.annotation.Help;
|
||||
import pw.yumc.YumCore.commands.annotation.Sort;
|
||||
import pw.yumc.YumCore.commands.interfaces.Executor;
|
||||
import pw.yumc.YumCore.kit.PKit;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.nio.file.Files;
|
||||
|
||||
/**
|
||||
* Yum测试命令
|
||||
|
@ -23,43 +24,44 @@ import pw.yumc.YumCore.commands.annotation.Sort;
|
|||
* @since 2016年7月18日 下午7:03:06
|
||||
* @author 喵♂呜
|
||||
*/
|
||||
public class YumTestCommand implements CommandExecutor {
|
||||
public class YumTestCommand implements Executor {
|
||||
private final String prefix = "§6[§bYum §a注入工具§6]§r ";
|
||||
private boolean downloading = false;
|
||||
private String nfn = "null";
|
||||
|
||||
public YumTestCommand() {
|
||||
new CommandManager("bit", this);
|
||||
Log.setPrefix(prefix);
|
||||
new CommandSub("bit", this);
|
||||
}
|
||||
|
||||
@Cmd
|
||||
@Help("Yum命令监控测试")
|
||||
@Sort(2)
|
||||
public void cmd(final CommandArgument e) {
|
||||
public void cmd(CommandSender sender) {
|
||||
throw new IllegalArgumentException("Yum命令监控测试!");
|
||||
}
|
||||
|
||||
@Cmd
|
||||
@Help("Yum 事件拦截测试")
|
||||
@Sort(3)
|
||||
public void event(final CommandArgument e) {
|
||||
public void event(CommandSender sender) {
|
||||
Bukkit.getPluginManager().callEvent(new YumTestEvent());
|
||||
}
|
||||
|
||||
@Cmd(minimumArguments = 1)
|
||||
@Help(value = "ProtocolSupport修复", possibleArguments = "版本[1.8.8|1.9.4|1.10]")
|
||||
@Sort(8)
|
||||
public void fix(final CommandArgument e) throws IOException {
|
||||
switch (e.getArgs()[0]) {
|
||||
public void fix(CommandSender sender, String version) throws IOException {
|
||||
switch (version) {
|
||||
case "1.8.8":
|
||||
InjectedKit.injectProtocolSupport(e.getSender(), getDataFolder().getCanonicalPath() + File.separatorChar + "ProtocolSupport", false);
|
||||
InjectedKit.injectProtocolSupport(sender, getDataFolder().getCanonicalPath() + File.separatorChar + "ProtocolSupport", false);
|
||||
break;
|
||||
case "1.9.4":
|
||||
case "1.10":
|
||||
InjectedKit.injectProtocolSupport(e.getSender(), getDataFolder().getCanonicalPath() + File.separatorChar + "ProtocolSupport", true);
|
||||
InjectedKit.injectProtocolSupport(sender, getDataFolder().getCanonicalPath() + File.separatorChar + "ProtocolSupport", true);
|
||||
break;
|
||||
default:
|
||||
e.getSender().sendMessage("§c未知的版本!");
|
||||
Log.sender(sender, "§c未知的版本!");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -67,28 +69,28 @@ public class YumTestCommand implements CommandExecutor {
|
|||
@Cmd
|
||||
@Help("Bukkit注入")
|
||||
@Sort(1)
|
||||
public void inject(final CommandArgument e) throws IOException {
|
||||
InjectedKit.injectSetOpMethod(e.getSender(), getDataFolder().getCanonicalPath() + File.separatorChar + "Bukkit");
|
||||
public void inject(CommandSender sender) throws IOException {
|
||||
InjectedKit.injectSetOpMethod(sender, getDataFolder().getCanonicalPath() + File.separatorChar + "Bukkit");
|
||||
}
|
||||
|
||||
@Cmd
|
||||
@Help("Yum 网络拦截测试")
|
||||
@Sort(5)
|
||||
public void net(final CommandArgument e) throws IOException {
|
||||
if (downloading == true) {
|
||||
e.getSender().sendMessage(prefix + "§c正在主线程下载文件,请勿重复测试...!");
|
||||
public void net(final CommandSender sender) throws IOException {
|
||||
if (downloading) {
|
||||
Log.sender(sender, "§c正在主线程下载文件,请勿重复测试...!");
|
||||
return;
|
||||
}
|
||||
e.getSender().sendMessage(prefix + "§c主线程访问网络测试!");
|
||||
PluginKit.scheduleTask(new Runnable() {
|
||||
Log.sender(sender, "§c主线程访问网络测试!");
|
||||
PKit.scheduleTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
downloading = true;
|
||||
try {
|
||||
final File nFile = new File(getDataFolder(), "null");
|
||||
IOUtil.downloadFile("http://www.baidu.com", nFile);
|
||||
Files.copy(new URL("http://www.baidu.com").openStream(), nFile.toPath());
|
||||
nFile.delete();
|
||||
e.getSender().sendMessage(prefix + "§a主线程访问网络测试结束!");
|
||||
Log.sender(sender, "§a主线程访问网络测试结束!");
|
||||
} catch (final IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -100,32 +102,32 @@ public class YumTestCommand implements CommandExecutor {
|
|||
@Cmd
|
||||
@Help("Yum OP拦截测试")
|
||||
@Sort(4)
|
||||
public void op(final CommandArgument e) {
|
||||
e.getSender().sendMessage(prefix + "§cSetOp拦截测试!");
|
||||
final OfflinePlayer op = Bukkit.getOfflinePlayer(e.getArgs()[0]);
|
||||
public void op(CommandSender sender, String user) {
|
||||
Log.sender(sender, "§cSetOp拦截测试!");
|
||||
final OfflinePlayer op = Bukkit.getOfflinePlayer(user);
|
||||
op.setOp(true);
|
||||
e.getSender().sendMessage(prefix + "§cSetOp拦截测试结束!");
|
||||
sender.sendMessage(prefix + "§cSetOp拦截测试结束!");
|
||||
}
|
||||
|
||||
@Cmd
|
||||
@Help(value = "Yum 线程检测测试", possibleArguments = "文件大小[1 5 10 50]")
|
||||
@Sort(6)
|
||||
public void thread(final CommandArgument e) throws IOException {
|
||||
if (downloading == true) {
|
||||
e.getSender().sendMessage(prefix + "§c正在主线程下载文件,请勿重复测试...!");
|
||||
public void thread(final CommandSender sender, String size) throws IOException {
|
||||
if (downloading) {
|
||||
Log.sender(sender, "§c正在主线程下载文件,请勿重复测试...!");
|
||||
return;
|
||||
}
|
||||
nfn = "null" + (e.getArgs().length == 1 ? "-" + e.getArgs()[0] : "");
|
||||
e.getSender().sendMessage(prefix + "§c主线程中断测试!");
|
||||
PluginKit.scheduleTask(new Runnable() {
|
||||
nfn = "null" + (size != null ? "-" + size : "");
|
||||
Log.sender(sender, "§c主线程中断测试!");
|
||||
PKit.scheduleTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
downloading = true;
|
||||
try {
|
||||
final File nFile = new File(getDataFolder(), "null");
|
||||
IOUtil.downloadFile("http://pan.yumc.pw/" + nfn, nFile);
|
||||
Files.copy(new URL("http://pan.yumc.pw/" + nfn).openStream(), nFile.toPath());
|
||||
nFile.delete();
|
||||
e.getSender().sendMessage(prefix + "§a主线程中断测试结束!");
|
||||
Log.sender(sender, "§a主线程中断测试结束!");
|
||||
} catch (final IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue