Пример #1
0
 private static Object getHandle(final Object obj) {
   try {
     return getMethod(obj.getClass(), "getHandle", (Class<?>[]) new Class[0])
         .invoke(obj, new Object[0]);
   } catch (Exception e) {
     e.printStackTrace();
     return null;
   }
 }
Пример #2
0
 private static Field getField(final Class<?> clazz, final String name) {
   try {
     final Field field = clazz.getDeclaredField(name);
     field.setAccessible(true);
     return field;
   } catch (Exception e) {
     e.printStackTrace();
     return null;
   }
 }
Пример #3
0
 public static void sendTimings(
     final Player p, final int fadeIn, final int stay, final int fadeOut) {
   if (((CraftPlayer) p).getHandle().playerConnection.networkManager.getVersion()
       < Title.VERSION) {
     return;
   }
   try {
     final Object handle = getHandle(p);
     final Object connection = getField(handle.getClass(), "playerConnection").get(handle);
     final Object packet =
         ProtocolInjector.PacketTitle.class
             .getConstructor(
                 ProtocolInjector.PacketTitle.Action.class,
                 Integer.TYPE,
                 Integer.TYPE,
                 Integer.TYPE)
             .newInstance(ProtocolInjector.PacketTitle.Action.TIMES, fadeIn, stay, fadeOut);
     getMethod(connection.getClass(), "sendPacket", (Class<?>[]) new Class[0])
         .invoke(connection, packet);
   } catch (Exception e) {
     e.printStackTrace();
   }
 }