Package com.comphenix.protocol.events

Examples of com.comphenix.protocol.events.ListeningWhitelist$Builder


    if (listener == null)
      throw new IllegalArgumentException("listener cannot be NULL.");
    if (!timeoutListeners.add(listener))
      return;
   
    ListeningWhitelist sending = listener.getSendingWhitelist();
    ListeningWhitelist receiving = listener.getReceivingWhitelist();
   
    if (!ListeningWhitelist.isEmpty(sending))
      serverTimeoutListeners.addListener(listener, sending);
    if (!ListeningWhitelist.isEmpty(receiving))
      serverTimeoutListeners.addListener(listener, receiving);
View Full Code Here


   * @return An asynchronous handler.
   */
  public AsyncListenerHandler registerAsyncHandler(PacketListener listener, boolean autoInject) {
    AsyncListenerHandler handler = new AsyncListenerHandler(mainThread, this, listener);
   
    ListeningWhitelist sendingWhitelist = listener.getSendingWhitelist();
    ListeningWhitelist receivingWhitelist = listener.getReceivingWhitelist();
   
    if (!hasValidWhitelist(sendingWhitelist) && !hasValidWhitelist(receivingWhitelist)) {
      throw new IllegalArgumentException("Listener has an empty sending and receiving whitelist.");
    }
   
View Full Code Here

  @Override
  public void unregisterTimeoutHandler(PacketListener listener) {
    if (listener == null)
      throw new IllegalArgumentException("listener cannot be NULL.");
   
    ListeningWhitelist sending = listener.getSendingWhitelist();
    ListeningWhitelist receiving = listener.getReceivingWhitelist();
   
    // Do it in the opposite order
    if (serverTimeoutListeners.removeListener(listener, sending).size() > 0 ||
      clientTimeoutListeners.removeListener(listener, receiving).size() > 0) {
      timeoutListeners.remove(listener);
View Full Code Here

    }
    return result;
  }
 
  public PacketListener createPacketListener(Set<PacketType> type) {
    final ListeningWhitelist serverList = ListeningWhitelist.newBuilder().
        types(filterTypes(type, Sender.SERVER)).
        gamePhaseBoth().
        monitor().
        build();
   
    final ListeningWhitelist clientList = ListeningWhitelist.newBuilder(serverList).
        types(filterTypes(type, Sender.CLIENT)).
        monitor().
        build();
   
    return new PacketListener() {
View Full Code Here

      }
    };
  }
 
  public PacketListener createCompareListener(Set<PacketType> type) {
    final ListeningWhitelist serverList = ListeningWhitelist.newBuilder().
        types(filterTypes(type, Sender.SERVER)).
        gamePhaseBoth().
        lowest().
        build();
   
    final ListeningWhitelist clientList = ListeningWhitelist.newBuilder(serverList).
        types(filterTypes(type, Sender.CLIENT)).
        lowest().
        build();
   
    return new PacketListener() {
View Full Code Here

        this.sending = ListeningWhitelist.newBuilder().monitor().types(PacketRegistry.getServerPacketTypes()).gamePhaseBoth().build();
      if (side.isForClient())
        this.receiving = ListeningWhitelist.newBuilder().monitor().types(PacketRegistry.getClientPacketTypes()).gamePhaseBoth().build();
    } catch (FieldAccessException e) {
      if (side.isForServer())
        this.sending = new ListeningWhitelist(ListenerPriority.MONITOR, Packets.Server.getRegistry().values(), GamePhase.BOTH);
      if (side.isForClient())
        this.receiving = new ListeningWhitelist(ListenerPriority.MONITOR, Packets.Client.getRegistry().values(), GamePhase.BOTH);
      logger.log(Level.WARNING, "Defaulting to 1.3 packets.", e);
    }
  }
View Full Code Here

    Set<Plugin> plugins = new HashSet<Plugin>();
    // Obtain all plugins that have a listener (ignore monitors)
    boolean outGoing = packetType.isOutGoing();
    com.comphenix.protocol.PacketType comType = getPacketType(packetType);
    for (com.comphenix.protocol.events.PacketListener listener : ProtocolLibrary.getProtocolManager().getPacketListeners()) {
      final ListeningWhitelist whitelist;
      if (outGoing) {
        whitelist = listener.getSendingWhitelist();
      } else {
        whitelist = listener.getReceivingWhitelist();
      }
      if (whitelist.getPriority() != ListenerPriority.MONITOR && whitelist.getTypes().contains(comType)) {
        plugins.add(listener.getPlugin());
      }
    }
    return plugins;
  }
View Full Code Here

TOP

Related Classes of com.comphenix.protocol.events.ListeningWhitelist$Builder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.