Advertisement
Ravenbvutt

Untitled

Aug 11th, 2017
8,555
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.00 KB | None | 0 0
  1. import io.netty.channel.Channel;
  2. import java.lang.reflect.Constructor;
  3. import java.lang.reflect.Field;
  4. import java.lang.reflect.Method;
  5. import java.util.ArrayList;
  6. import java.util.Collection;
  7. import org.bukkit.Bukkit;
  8. import org.bukkit.entity.Player;
  9.  
  10. public final class d91da {
  11. private static final String e907 = "MINECRAFT";
  12. private static Constructor c;
  13. private static Constructor b28;
  14. private static final Method db;
  15. private static final Field d07;
  16. private static final Field c8f92;
  17. private static Field fed;
  18.  
  19. public static Class e907(String string) {
  20. String string2 = Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3];
  21. return Class.forName("net." + "MINECRAFT".toLowerCase() + ".server." + string2 + "." + string, true, Bukkit.class.getClassLoader());
  22. }
  23.  
  24. public static Class c(String string) {
  25. String string2 = Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3];
  26. return Class.forName("org.bukkit.craftbukkit." + string2 + "." + string, true, Bukkit.class.getClassLoader());
  27. }
  28.  
  29. public static Object e907(short s, byte[] arrby) {
  30. if (b28 != null) {
  31. return b28.newInstance(s, Byte.valueOf(4), false, new ArrayList(), arrby, 0, 0, 128, 128);
  32. }
  33. return c.newInstance(s, Byte.valueOf(4), new ArrayList(), arrby, 0, 0, 128, 128);
  34. }
  35.  
  36. public static Channel e907(Player object) {
  37. object = db.invoke(object, new Object[0]);
  38. object = d07.get(object);
  39. object = c8f92.get(object);
  40. return (Channel)fed.get(object);
  41. }
  42.  
  43. static {
  44. try {
  45. try {
  46. b28 = d91da.e907("PacketPlayOutMap").getConstructor(Integer.TYPE, Byte.TYPE, Boolean.TYPE, Collection.class, byte[].class, Integer.TYPE, Integer.TYPE, Integer.TYPE, Integer.TYPE);
  47. }
  48. catch (NoSuchMethodException noSuchMethodException) {
  49. c = d91da.e907("PacketPlayOutMap").getConstructor(Integer.TYPE, Byte.TYPE, Collection.class, byte[].class, Integer.TYPE, Integer.TYPE, Integer.TYPE, Integer.TYPE);
  50. }
  51. db = d91da.c("entity.CraftPlayer").getMethod("getHandle", new Class[0]);
  52. d07 = d91da.e907("EntityPlayer").getDeclaredField("playerConnection");
  53. c8f92 = d91da.e907("PlayerConnection").getDeclaredField("networkManager");
  54. for (Field field : d91da.e907("NetworkManager").getDeclaredFields()) {
  55. if (field.getType() != Channel.class) continue;
  56. fed = field;
  57. }
  58. if (fed == null) {
  59. throw new RuntimeException("Could not find field with type channel in class NetworkManager");
  60. }
  61. fed.setAccessible(true);
  62. return;
  63. }
  64. catch (ClassNotFoundException | NoSuchFieldException | NoSuchMethodException | SecurityException exception) {
  65. throw new RuntimeException(exception);
  66. }
  67. }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement