Advertisement
Ravenbvutt

Untitled

Aug 11th, 2017
8,759
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.36 KB | None | 0 0
  1. import io.netty.channel.ChannelDuplexHandler;
  2. import io.netty.channel.ChannelFuture;
  3. import io.netty.channel.ChannelHandlerContext;
  4. import io.netty.channel.ChannelPromise;
  5. import java.io.PrintStream;
  6. import java.lang.reflect.Field;
  7. import java.lang.reflect.InvocationTargetException;
  8. import java.lang.reflect.Method;
  9. import java.util.HashMap;
  10. import java.util.HashSet;
  11. import java.util.Iterator;
  12. import java.util.List;
  13. import java.util.Map;
  14. import java.util.Set;
  15. import me.bigteddy98.bannerboard.Main;
  16. import me.bigteddy98.bannerboard.d91da;
  17. import me.bigteddy98.bannerboard.db;
  18. import org.bukkit.Bukkit;
  19. import org.bukkit.plugin.Plugin;
  20. import org.bukkit.scheduler.BukkitTask;
  21.  
  22. public final class b28
  23. extends ChannelDuplexHandler {
  24. private static Field e907;
  25. private static Method c;
  26. private static Class b28;
  27. private static Field db;
  28. private static final Field d07;
  29. private static final Class c8f92;
  30. private static final Field fed;
  31. private static final Field dac4d;
  32. private static final Method ea7fc;
  33. private static final Class cf79b;
  34. private static final Class d5bd;
  35. private static final Field d1ec;
  36. private final Object de2 = new Object();
  37. private final Map cb1a1 = new HashMap();
  38. private final Set c020 = new HashSet();
  39. private ChannelHandlerContext b77;
  40. private final Object a087 = new Object();
  41.  
  42. /*
  43. * WARNING - Removed try catching itself - possible behaviour change.
  44. */
  45. public final void write(ChannelHandlerContext channelHandlerContext, Object iterator, ChannelPromise object) {
  46. block22 : {
  47. try {
  48. short s;
  49. Object object2 = this.a087;
  50. synchronized (object2) {
  51. this.b77 = channelHandlerContext;
  52. this.a087.notifyAll();
  53. }
  54. if (d5bd.isInstance(iterator) && this.c020.contains(s = (short)((Integer)d1ec.get(iterator)).intValue())) {
  55. return;
  56. }
  57. super.write(channelHandlerContext, (Object)iterator, (ChannelPromise)object);
  58. if (cf79b.isInstance(iterator)) {
  59. Short s2;
  60. block21 : {
  61. object = Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3];
  62. if (object.equals("v1_11_R1") || object.equals("v1_12_R1")) {
  63. iterator = (List)d07.get(iterator);
  64. iterator = iterator.iterator();
  65. while (iterator.hasNext()) {
  66. String string;
  67. object = iterator.next();
  68. if (!c8f92.isInstance(object = e907.get(object))) continue;
  69. object2 = (short)((Integer)fed.get(object)).intValue();
  70. if ((object = dac4d.get(object)) == null || !(string = (String)ea7fc.invoke(object, new Object[0])).equalsIgnoreCase("item.map")) continue;
  71. s2 = (short)object2;
  72. break block21;
  73. }
  74. s2 = null;
  75. } else if (object.startsWith("v1_9_") || object.equals("v1_10_R1")) {
  76. iterator = (List)d07.get(iterator);
  77. iterator = iterator.iterator();
  78. while (iterator.hasNext()) {
  79. Object object3;
  80. object = iterator.next();
  81. if (!b28.isInstance(object = e907.get(object)) || !c8f92.isInstance(object3 = c.invoke(object, new Object[0]))) continue;
  82. short s3 = (short)((Integer)fed.get(object3)).intValue();
  83. String string = (String)ea7fc.invoke(dac4d.get(object3), new Object[0]);
  84. if (!string.equalsIgnoreCase("item.map")) continue;
  85. s2 = s3;
  86. break block21;
  87. }
  88. s2 = null;
  89. } else if (object.startsWith("v1_8_")) {
  90. iterator = (List)d07.get(iterator);
  91. iterator = iterator.iterator();
  92. while (iterator.hasNext()) {
  93. object = iterator.next();
  94. if (!c8f92.isInstance(object = db.get(object))) continue;
  95. object2 = (short)((Integer)fed.get(object)).intValue();
  96. if (!(object = (String)ea7fc.invoke(dac4d.get(object), new Object[0])).equalsIgnoreCase("item.map")) continue;
  97. s2 = (short)object2;
  98. break block21;
  99. }
  100. s2 = null;
  101. } else {
  102. throw new RuntimeException("Unknown version " + (String)object);
  103. }
  104. }
  105. Short s4 = s2;
  106. if (s2 != null) {
  107. iterator = this.de2;
  108. synchronized (iterator) {
  109. if (this.c020.contains(s4) && (object = this.cb1a1.get(s4)) != null) {
  110. channelHandlerContext.write(object);
  111. }
  112. break block22;
  113. }
  114. }
  115. }
  116. return;
  117. }
  118. catch (Throwable throwable) {
  119. Throwable throwable2 = throwable;
  120. throwable.printStackTrace();
  121. }
  122. }
  123. }
  124.  
  125. private static Short e907(Object iterator) {
  126. Object object = Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3];
  127. if (object.equals("v1_11_R1") || object.equals("v1_12_R1")) {
  128. iterator = (List)d07.get(iterator);
  129. iterator = iterator.iterator();
  130. while (iterator.hasNext()) {
  131. String string;
  132. object = iterator.next();
  133. if (!c8f92.isInstance(object = e907.get(object))) continue;
  134. short s = (short)((Integer)fed.get(object)).intValue();
  135. if ((object = dac4d.get(object)) == null || !(string = (String)ea7fc.invoke(object, new Object[0])).equalsIgnoreCase("item.map")) continue;
  136. return s;
  137. }
  138. return null;
  139. }
  140. if (object.startsWith("v1_9_") || object.equals("v1_10_R1")) {
  141. iterator = (List)d07.get(iterator);
  142. iterator = iterator.iterator();
  143. while (iterator.hasNext()) {
  144. Object object2;
  145. object = iterator.next();
  146. if (!b28.isInstance(object = e907.get(object)) || !c8f92.isInstance(object2 = c.invoke(object, new Object[0]))) continue;
  147. short s = (short)((Integer)fed.get(object2)).intValue();
  148. String string = (String)ea7fc.invoke(dac4d.get(object2), new Object[0]);
  149. if (!string.equalsIgnoreCase("item.map")) continue;
  150. return s;
  151. }
  152. return null;
  153. }
  154. if (object.startsWith("v1_8_")) {
  155. iterator = (List)d07.get(iterator);
  156. iterator = iterator.iterator();
  157. while (iterator.hasNext()) {
  158. object = iterator.next();
  159. if (!c8f92.isInstance(object = db.get(object))) continue;
  160. short s = (short)((Integer)fed.get(object)).intValue();
  161. if (!(object = (String)ea7fc.invoke(dac4d.get(object), new Object[0])).equalsIgnoreCase("item.map")) continue;
  162. return s;
  163. }
  164. return null;
  165. }
  166. throw new RuntimeException("Unknown version " + (String)object);
  167. }
  168.  
  169. /*
  170. * WARNING - Removed try catching itself - possible behaviour change.
  171. */
  172. public final void e907(short s, byte[] object) {
  173. try {
  174. Object object2 = this.de2;
  175. synchronized (object2) {
  176. object = d91da.e907(s, (byte[])object);
  177. this.cb1a1.put(s, object);
  178. new db(this, object).runTaskAsynchronously((Plugin)Main.e907());
  179. }
  180. }
  181. catch (IllegalAccessException | IllegalArgumentException | InstantiationException | InvocationTargetException exception) {
  182. Exception exception2 = exception;
  183. exception.printStackTrace();
  184. }
  185. }
  186.  
  187. /*
  188. * WARNING - Removed try catching itself - possible behaviour change.
  189. */
  190. public final void e907() {
  191. Object object = this.de2;
  192. synchronized (object) {
  193. this.cb1a1.clear();
  194. return;
  195. }
  196. }
  197.  
  198. /*
  199. * WARNING - Removed try catching itself - possible behaviour change.
  200. */
  201. public final void e907(short s) {
  202. Object object = this.de2;
  203. synchronized (object) {
  204. this.c020.add(s);
  205. return;
  206. }
  207. }
  208.  
  209. static /* synthetic */ Object e907(b28 b282) {
  210. return b282.a087;
  211. }
  212.  
  213. static /* synthetic */ ChannelHandlerContext c(b28 b282) {
  214. return b282.b77;
  215. }
  216.  
  217. static {
  218. try {
  219. String string = Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3];
  220. if (string.startsWith("v1_9_") || string.equals("v1_10_R1") || string.equals("v1_11_R1") || string.equals("v1_12_R1")) {
  221. e907 = d91da.e907("DataWatcher$Item").getDeclaredField("b");
  222. e907.setAccessible(true);
  223. b28 = Class.forName("com.google.common.base.Present");
  224. c = Class.forName("com.google.common.base.Optional").getMethod("get", new Class[0]);
  225. }
  226. if (string.startsWith("v1_8_")) {
  227. try {
  228. db = d91da.e907("DataWatcher$WatchableObject").getDeclaredField("c");
  229. db.setAccessible(true);
  230. }
  231. catch (ClassNotFoundException classNotFoundException) {
  232. db = d91da.e907("WatchableObject").getDeclaredField("c");
  233. db.setAccessible(true);
  234. }
  235. }
  236. d07 = d91da.e907("PacketPlayOutEntityMetadata").getDeclaredField("b");
  237. d07.setAccessible(true);
  238. c8f92 = d91da.e907("ItemStack");
  239. fed = d91da.e907("ItemStack").getDeclaredField("damage");
  240. fed.setAccessible(true);
  241. dac4d = d91da.e907("ItemStack").getDeclaredField("item");
  242. dac4d.setAccessible(true);
  243. ea7fc = d91da.e907("Item").getMethod("getName", new Class[0]);
  244. cf79b = d91da.e907("PacketPlayOutEntityMetadata");
  245. d5bd = d91da.e907("PacketPlayOutMap");
  246. d1ec = d5bd.getDeclaredField("a");
  247. d1ec.setAccessible(true);
  248. return;
  249. }
  250. catch (ClassNotFoundException | NoSuchFieldException | NoSuchMethodException | SecurityException exception) {
  251. System.out.println("The Error:");
  252. exception.printStackTrace();
  253. throw new RuntimeException(exception);
  254. }
  255. }
  256. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement