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