Java Code Examples for com.comphenix.protocol.events.ListenerPriority

The following examples show how to use com.comphenix.protocol.events.ListenerPriority. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: AACAdditionPro   Source File: KeepAlive.java    License: GNU General Public License v3.0 5 votes vote down vote up
public KeepAlive()
{
    super(AACAdditionPro.getInstance(), ListenerPriority.LOW,
          // --------------- Server --------------- //
          // KeepAlive analysis
          PacketType.Play.Server.KEEP_ALIVE,
          // --------------- Client --------------- //
          // KeepAlive analysis
          PacketType.Play.Client.KEEP_ALIVE);
}
 
Example 2
Source Project: AACAdditionPro   Source File: Inventory.java    License: GNU General Public License v3.0 5 votes vote down vote up
public Inventory()
{
    super(AACAdditionPro.getInstance(), ListenerPriority.LOWEST,
          // Look
          PacketType.Play.Client.LOOK,
          // Move
          PacketType.Play.Client.POSITION,
          PacketType.Play.Client.POSITION_LOOK);
}
 
Example 3
public PacketAnalysis()
{
    super(AACAdditionPro.getInstance(), ListenerPriority.LOW,
          // --------------- Server --------------- //
          // Compare
          PacketType.Play.Server.POSITION,
          // --------------- Client --------------- //
          // CombatOrder
          PacketType.Play.Client.USE_ENTITY,
          PacketType.Play.Client.ARM_ANIMATION,
          // EqualRotation
          PacketType.Play.Client.LOOK,
          // EqualRotation + Compare
          PacketType.Play.Client.POSITION_LOOK);
}
 
Example 4
Source Project: ChatItem   Source File: ChatPacketListener.java    License: GNU General Public License v3.0 5 votes vote down vote up
public ChatPacketListener(Plugin plugin, ListenerPriority listenerPriority, Storage s, PacketType... types) {
    super(plugin, listenerPriority, types);
    if(ChatItem.supportsShulkerBoxes()){
        SHULKER_BOXES.addAll(Arrays.asList(Material.BLACK_SHULKER_BOX, Material.BLUE_SHULKER_BOX,
                Material.BROWN_SHULKER_BOX, Material.CYAN_SHULKER_BOX, Material.GRAY_SHULKER_BOX, Material.GREEN_SHULKER_BOX,
                Material.LIGHT_BLUE_SHULKER_BOX, Material.LIME_SHULKER_BOX, Material.MAGENTA_SHULKER_BOX, Material.ORANGE_SHULKER_BOX,
                Material.PINK_SHULKER_BOX, Material.PURPLE_SHULKER_BOX, Material.RED_SHULKER_BOX, Material.LIGHT_GRAY_SHULKER_BOX,
                Material.WHITE_SHULKER_BOX, Material.YELLOW_SHULKER_BOX));
    }
    c = s;
}
 
Example 5
Source Project: BetonQuest   Source File: PacketInterceptor.java    License: GNU General Public License v3.0 5 votes vote down vote up
public PacketInterceptor(Conversation conv, String playerID) {
    this.conv = conv;
    this.player = PlayerConverter.getPlayer(playerID);

    // Intercept Packets
    packetAdapter = new PacketAdapter(BetonQuest.getInstance(), ListenerPriority.HIGHEST,
            PacketType.Play.Server.CHAT

    ) {
        @Override
        public void onPacketSending(PacketEvent event) {
            if (event.getPlayer() != player) {
                return;
            }

            if (event.getPacketType().equals(PacketType.Play.Server.CHAT)) {
                PacketContainer packet = event.getPacket();
                BaseComponent[] bc = (BaseComponent[]) packet.getModifier().read(1);
                if (bc != null && bc.length > 0 && ((TextComponent) bc[0]).getText().contains("_bq_")) {
                    packet.getModifier().write(1, Arrays.copyOfRange(bc, 1, bc.length));
                    event.setPacket(packet);
                    return;
                }

                // Else save message to replay later
                WrapperPlayServerChat chat = new WrapperPlayServerChat(event.getPacket());
                event.setCancelled(true);
                messages.add(chat);
            }
        }
    };

    ProtocolLibrary.getProtocolManager().addPacketListener(packetAdapter);
}
 
Example 6
public SpigotProtocolHackPacketListener(EchoPetPlugin echoPetPlugin) {
    super(echoPetPlugin,
            ListenerPriority.HIGHEST,
            PacketType.Play.Server.SPAWN_ENTITY_LIVING,
            PacketType.Play.Server.ENTITY_METADATA);
    this.echoPetPlugin = echoPetPlugin;
    ProtocolLibrary.getProtocolManager().addPacketListener(this);
}
 
Example 7
Source Project: helper   Source File: ProtocolSubscriptionBuilderImpl.java    License: MIT License 4 votes vote down vote up
ProtocolSubscriptionBuilderImpl(Set<PacketType> types, ListenerPriority priority) {
    this.types = ImmutableSet.copyOf(types);
    this.priority = priority;
}
 
Example 8
Source Project: BungeeGuard   Source File: ProtocolHandshakeListener.java    License: MIT License 4 votes vote down vote up
Adapter(Plugin plugin) {
    super(plugin, ListenerPriority.LOWEST, PacketType.Handshake.Client.SET_PROTOCOL);
}
 
Example 9
public DamageIndicator()
{
    super(AACAdditionPro.getInstance(), ListenerPriority.HIGH, PacketType.Play.Server.ENTITY_METADATA, PacketType.Play.Server.NAMED_ENTITY_SPAWN);
}
 
Example 10
private VelocityChangeDataUpdater()
{
    super(AACAdditionPro.getInstance(), ListenerPriority.MONITOR, PacketType.Play.Client.POSITION, PacketType.Play.Client.POSITION_LOOK);
}
 
Example 11
private KeepAliveDataUpdater()
{
    super(AACAdditionPro.getInstance(), ListenerPriority.LOWEST, PacketType.Play.Server.KEEP_ALIVE);
}
 
Example 12
public LookPacketDataUpdater()
{
    super(AACAdditionPro.getInstance(), ListenerPriority.MONITOR, PacketType.Play.Client.LOOK, PacketType.Play.Client.POSITION_LOOK);
}
 
Example 13
Source Project: ChatItem   Source File: HandshakeListener.java    License: GNU General Public License v3.0 4 votes vote down vote up
public HandshakeListener(Plugin plugin, ListenerPriority listenerPriority, PacketType... types) {
    super(plugin, listenerPriority, types);
}
 
Example 14
Source Project: ChatItem   Source File: ChatPacketValidator.java    License: GNU General Public License v3.0 4 votes vote down vote up
public ChatPacketValidator(Plugin plugin, ListenerPriority listenerPriority, Storage s, PacketType... types) {
    super(plugin, listenerPriority, types);
    c = s;
}
 
Example 15
Source Project: CombatLogX   Source File: ForceFieldAdapter.java    License: GNU General Public License v3.0 4 votes vote down vote up
ForceFieldAdapter(ForceField forceField) {
    super(forceField.getExpansion().getPlugin().getPlugin(), ListenerPriority.NORMAL, PacketType.Play.Server.BLOCK_CHANGE);
    this.forceField = forceField;
    this.plugin = this.forceField.getExpansion().getPlugin();
}
 
Example 16
public ServerListPacketListener(SuperVanish plugin) {
    //noinspection deprecation
    super(plugin, ListenerPriority.NORMAL, PacketType.Status.Server.OUT_SERVER_INFO);
    this.plugin = plugin;
}
 
Example 17
Source Project: SuperVanish   Source File: VanishIndication.java    License: Mozilla Public License 2.0 4 votes vote down vote up
@Override
public void onEnable() {
    ProtocolLibrary.getProtocolManager().addPacketListener(
            new PacketAdapter(plugin, ListenerPriority.NORMAL, PacketType.Play.Server.PLAYER_INFO) {
                @Override
                public void onPacketSending(PacketEvent event) {
                    // multiple events share same packet object
                    event.setPacket(event.getPacket().shallowClone());
                    List<PlayerInfoData> infoDataList = new ArrayList<>(
                            event.getPacket().getPlayerInfoDataLists().read(0));
                    Player receiver = event.getPlayer();
                    for (PlayerInfoData infoData : ImmutableList.copyOf(infoDataList)) {
                        try {
                            if (!VanishIndication.this.plugin.getVisibilityChanger().getHider()
                                    .isHidden(infoData.getProfile().getUUID(), receiver)
                                    && VanishIndication.this.plugin.getVanishStateMgr()
                                    .isVanished(infoData.getProfile().getUUID())) {
                                if (!receiver.getUniqueId().equals(infoData.getProfile().getUUID()))
                                    if (infoData.getGameMode() != EnumWrappers.NativeGameMode.SPECTATOR) {
                                        int latency;
                                        try {
                                            latency = infoData.getLatency();
                                        } catch (NoSuchMethodError e) {
                                            latency = 21;
                                        }
                                        if (event.getPacket().getPlayerInfoAction().read(0)
                                                != EnumWrappers.PlayerInfoAction.UPDATE_GAME_MODE) {
                                            continue;
                                        }
                                        PlayerInfoData newData = new PlayerInfoData(infoData.getProfile(),
                                                latency, EnumWrappers.NativeGameMode.SPECTATOR,
                                                infoData.getDisplayName());
                                        infoDataList.remove(infoData);
                                        infoDataList.add(newData);
                                    }
                            }
                        } catch (UnsupportedOperationException ignored) {
                            // Ignore temporary players
                        }
                    }
                    event.getPacket().getPlayerInfoDataLists().write(0, infoDataList);
                }
            });
}
 
Example 18
Source Project: UHC   Source File: HardcoreHeartsModule.java    License: MIT License 4 votes vote down vote up
HardcoreHeartsListener() {
    super(HardcoreHeartsModule.this.plugin, ListenerPriority.NORMAL, PacketType.Play.Server.LOGIN);
}
 
Example 19
TabCompletePacketAdapter(AuthMe plugin, PlayerCache playerCache) {
    super(plugin, ListenerPriority.NORMAL, PacketType.Play.Client.TAB_COMPLETE);
    this.playerCache = playerCache;
}
 
Example 20
Source Project: helper   Source File: ProtocolSubscriptionBuilder.java    License: MIT License 3 votes vote down vote up
/**
 * Makes a HandlerBuilder for the given packets
 *
 * @param priority   the priority to listen at
 * @param packets the packets to handle
 * @return a {@link ProtocolSubscriptionBuilder} to construct the event handler
 */
@Nonnull
static ProtocolSubscriptionBuilder newBuilder(@Nonnull ListenerPriority priority, @Nonnull PacketType... packets) {
    Objects.requireNonNull(priority, "priority");
    Objects.requireNonNull(packets, "packets");
    return new ProtocolSubscriptionBuilderImpl(ImmutableSet.copyOf(packets), priority);
}
 
Example 21
Source Project: helper   Source File: Protocol.java    License: MIT License 2 votes vote down vote up
/**
 * Makes a HandlerBuilder for the given packets
 *
 * @param priority   the priority to listen at
 * @param packets the packets to handle
 * @return a {@link ProtocolSubscriptionBuilder} to construct the event handler
 */
@Nonnull
public static ProtocolSubscriptionBuilder subscribe(@Nonnull ListenerPriority priority, @Nonnull PacketType... packets) {
    return ProtocolSubscriptionBuilder.newBuilder(priority, packets);
}
 
Example 22
Source Project: helper   Source File: ProtocolSubscriptionBuilder.java    License: MIT License 2 votes vote down vote up
/**
 * Makes a HandlerBuilder for the given packets
 *
 * @param packets the packets to handle
 * @return a {@link ProtocolSubscriptionBuilder} to construct the event handler
 */
@Nonnull
static ProtocolSubscriptionBuilder newBuilder(@Nonnull PacketType... packets) {
    return newBuilder(ListenerPriority.NORMAL, packets);
}