/**
   * Construct a new packet filter manager without checking for Netty.
   *
   * @return A new packet filter manager.
   */
  private PacketFilterManager buildInternal() {
    PacketFilterManager manager = new PacketFilterManager(this);

    // It's a cyclic reference, but it's too late to fix now
    asyncManager.setManager(manager);
    return manager;
  }
  /**
   * Create a new packet filter manager.
   *
   * @return A new packet filter manager.
   */
  public InternalManager build() {
    if (reporter == null) throw new IllegalArgumentException("reporter cannot be NULL.");
    if (classLoader == null) throw new IllegalArgumentException("classLoader cannot be NULL.");

    asyncManager = new AsyncFilterManager(reporter, server.getScheduler());
    nettyEnabled = false;

    // Spigot
    if (SpigotPacketInjector.canUseSpigotListener()) {
      // If the server hasn't loaded yet - wait
      if (InjectedServerConnection.getServerConnection(reporter, server) == null) {
        // We need to delay this until we know if Netty is enabled
        final DelayedPacketManager delayed = new DelayedPacketManager(reporter, mcVersion);

        // They must reference each other
        delayed.setAsynchronousManager(asyncManager);
        asyncManager.setManager(delayed);

        Futures.addCallback(
            BukkitFutures.nextEvent(library, WorldInitEvent.class),
            new FutureCallback<WorldInitEvent>() {
              @Override
              public void onSuccess(WorldInitEvent event) {
                // Nevermind
                if (delayed.isClosed()) return;

                try {
                  registerSpigot(delayed);
                } catch (Exception e) {
                  onFailure(e);
                }
              }

              @Override
              public void onFailure(Throwable error) {
                reporter.reportWarning(
                    PacketFilterBuilder.this,
                    Report.newBuilder(REPORT_TEMPORARY_EVENT_ERROR).error(error));
              }
            });

        System.out.println("Delaying due to Spigot");

        // Let plugins use this version instead
        return delayed;
      } else {
        nettyEnabled =
            !MinecraftReflection.isMinecraftObject(
                InjectedServerConnection.getServerConnection(reporter, server));
      }
    }

    // Otherwise - construct the packet filter manager right away
    return buildInternal();
  }