Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import io.netty.channel.Channel;
- import java.lang.reflect.Constructor;
- import java.lang.reflect.Field;
- import java.lang.reflect.Method;
- import java.util.ArrayList;
- import java.util.Collection;
- import org.bukkit.Bukkit;
- import org.bukkit.entity.Player;
- public final class d91da {
- private static final String e907 = "MINECRAFT";
- private static Constructor c;
- private static Constructor b28;
- private static final Method db;
- private static final Field d07;
- private static final Field c8f92;
- private static Field fed;
- public static Class e907(String string) {
- String string2 = Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3];
- return Class.forName("net." + "MINECRAFT".toLowerCase() + ".server." + string2 + "." + string, true, Bukkit.class.getClassLoader());
- }
- public static Class c(String string) {
- String string2 = Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3];
- return Class.forName("org.bukkit.craftbukkit." + string2 + "." + string, true, Bukkit.class.getClassLoader());
- }
- public static Object e907(short s, byte[] arrby) {
- if (b28 != null) {
- return b28.newInstance(s, Byte.valueOf(4), false, new ArrayList(), arrby, 0, 0, 128, 128);
- }
- return c.newInstance(s, Byte.valueOf(4), new ArrayList(), arrby, 0, 0, 128, 128);
- }
- public static Channel e907(Player object) {
- object = db.invoke(object, new Object[0]);
- object = d07.get(object);
- object = c8f92.get(object);
- return (Channel)fed.get(object);
- }
- static {
- try {
- try {
- b28 = d91da.e907("PacketPlayOutMap").getConstructor(Integer.TYPE, Byte.TYPE, Boolean.TYPE, Collection.class, byte[].class, Integer.TYPE, Integer.TYPE, Integer.TYPE, Integer.TYPE);
- }
- catch (NoSuchMethodException noSuchMethodException) {
- c = d91da.e907("PacketPlayOutMap").getConstructor(Integer.TYPE, Byte.TYPE, Collection.class, byte[].class, Integer.TYPE, Integer.TYPE, Integer.TYPE, Integer.TYPE);
- }
- db = d91da.c("entity.CraftPlayer").getMethod("getHandle", new Class[0]);
- d07 = d91da.e907("EntityPlayer").getDeclaredField("playerConnection");
- c8f92 = d91da.e907("PlayerConnection").getDeclaredField("networkManager");
- for (Field field : d91da.e907("NetworkManager").getDeclaredFields()) {
- if (field.getType() != Channel.class) continue;
- fed = field;
- }
- if (fed == null) {
- throw new RuntimeException("Could not find field with type channel in class NetworkManager");
- }
- fed.setAccessible(true);
- return;
- }
- catch (ClassNotFoundException | NoSuchFieldException | NoSuchMethodException | SecurityException exception) {
- throw new RuntimeException(exception);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement