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 TypeMethodDescriptionMakes an independent from previously called particle type, copy of this packet wrapper.voidsendInRadiusTo(Collection<? extends org.bukkit.entity.Player> players, double radius) Sends a packet to every player in given particle packet radius.voidsendInRadiusTo(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.voidsendInRadiusTo(org.bukkit.entity.Player player, double radius) Sends packet to aPlayerif in given particle packet radius.voidsendTo(Collection<? extends org.bukkit.entity.Player> players) Sends packet to eachPlayer.voidsendTo(Collection<? extends org.bukkit.entity.Player> players, Predicate<? super org.bukkit.entity.Player> predicate) Sends packet to eachPlayerthat matches predicate.voidsendTo(org.bukkit.entity.Player player) Sends packet to aPlayer.
-
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- aPlayerto which send a packet.
-
sendInRadiusTo
void sendInRadiusTo(org.bukkit.entity.Player player, double radius) Sends packet to a
Playerif in given particle packet radius.- Parameters:
player- aPlayerto which send a packet.radius- a spherical radius around which send packet to.
-
sendTo
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 onLocationorWorldobjects.- Parameters:
players- aCollectionofPlayerto 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
Playerthat matches predicate.NOTE: Bukkit internally creates a new copy of player list on
World.getPlayers()method. Keep it in mind if you operate onLocationorWorldobjects.- Parameters:
players- aCollectionofPlayerto which send a packet.predicate- aPredicateused to check if packet should be send to certain player.
-
sendInRadiusTo
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 onLocationorWorldobjects.- Parameters:
players- aCollectionofPlayerto 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 onLocationorWorldobjects.- Parameters:
players- aCollectionofPlayerto which send a packet.radius- a spherical radius around which send packet to nearby players.predicate- aPredicateused to check if packet should be send to certain player.
-