Interface ParticlePacket


public interface ParticlePacket

Class used to handle packet sending.

It wraps NMS Packet object and sends it without Reflection usage.

IMPORTANT NOTE: Each particle type that constructs packets caches and returns exactly one and the same instance of this class.

Any shared usage of this class is annotated with Shared annotation in appropriate context.

For an independent copy of this packet wrapper, check detachCopy() method.

  • Method Summary

    Modifier and Type
    Method
    Description
    Makes an independent from previously called particle type, copy of this packet wrapper.
    void
    sendInRadiusTo(Collection<? extends org.bukkit.entity.Player> players, double radius)
    Sends a packet to every player in given particle packet radius.
    void
    sendInRadiusTo(Collection<? extends org.bukkit.entity.Player> players, double radius, Predicate<? super org.bukkit.entity.Player> predicate)
    Sends a packet to every player in given particle packet radius that matches predicate.
    void
    sendInRadiusTo(org.bukkit.entity.Player player, double radius)
    Sends packet to a Player if in given particle packet radius.
    void
    sendTo(Collection<? extends org.bukkit.entity.Player> players)
    Sends packet to each Player.
    void
    sendTo(Collection<? extends org.bukkit.entity.Player> players, Predicate<? super org.bukkit.entity.Player> predicate)
    Sends packet to each Player that matches predicate.
    void
    sendTo(org.bukkit.entity.Player player)
    Sends packet to a Player.
  • Method Details

    • detachCopy

      ParticlePacket detachCopy()

      Makes an independent from previously called particle type, copy of this packet wrapper.

      Returned instance can be cached and reused.

      Returns:
      an independent copy of this packet instance.
    • sendTo

      void sendTo(org.bukkit.entity.Player player)

      Sends packet to a Player.

      This method is overridden by dynamically generated subclasses and depending on implementation this method will look roughly like this:

      
       public void sendPacket(Player player) {
           ((CraftPlayer) player).getHandle().playerConnection
                   .sendPacket(packet);
       }
       
      Parameters:
      player - a Player to which send a packet.
    • sendInRadiusTo

      void sendInRadiusTo(org.bukkit.entity.Player player, double radius)

      Sends packet to a Player if in given particle packet radius.

      Parameters:
      player - a Player to which send a packet.
      radius - a spherical radius around which send packet to.
    • sendTo

      void sendTo(Collection<? extends org.bukkit.entity.Player> players)

      Sends packet to each Player.

      NOTE: Bukkit internally creates a new copy of player list on World.getPlayers() method. Keep it in mind if you operate on Location or World objects.

      Parameters:
      players - a Collection of Player to which send a packet.
    • sendTo

      void sendTo(Collection<? extends org.bukkit.entity.Player> players, Predicate<? super org.bukkit.entity.Player> predicate)

      Sends packet to each Player that matches predicate.

      NOTE: Bukkit internally creates a new copy of player list on World.getPlayers() method. Keep it in mind if you operate on Location or World objects.

      Parameters:
      players - a Collection of Player to which send a packet.
      predicate - a Predicate used to check if packet should be send to certain player.
    • sendInRadiusTo

      void sendInRadiusTo(Collection<? extends org.bukkit.entity.Player> players, double radius)

      Sends a packet to every player in given particle packet radius.

      NOTE: Bukkit internally creates a new copy of player list on World.getPlayers() method. Keep it in mind if you operate on Location or World objects.

      Parameters:
      players - a Collection of Player to which send a packet.
      radius - a spherical radius around which send packet to.
    • sendInRadiusTo

      void sendInRadiusTo(Collection<? extends org.bukkit.entity.Player> players, double radius, Predicate<? super org.bukkit.entity.Player> predicate)

      Sends a packet to every player in given particle packet radius that matches predicate.

      Predicate is executed after radius check.

      NOTE: Bukkit internally creates a new copy of player list on World.getPlayers() method. Keep it in mind if you operate on Location or World objects.

      Parameters:
      players - a Collection of Player to which send a packet.
      radius - a spherical radius around which send packet to nearby players.
      predicate - a Predicate used to check if packet should be send to certain player.