mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2025-02-05 23:11:34 +01:00
Respect canSee when sending packets
This commit is contained in:
parent
8c3ef5e629
commit
e248d3f7f9
@ -31,6 +31,7 @@ import org.bukkit.craftbukkit.v1_7_R1.entity.CraftEntity;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
|
||||
@ -217,7 +218,8 @@ public class CitizensNPC extends AbstractNPC {
|
||||
navigator.run();
|
||||
|
||||
if (!getNavigator().isNavigating() && getEntity().getWorld().getTime() % 30 == 0) {
|
||||
NMS.sendPacketNearby(getStoredLocation(),
|
||||
Player player = getEntity() instanceof Player ? (Player) getEntity() : null;
|
||||
NMS.sendPacketNearby(player, getStoredLocation(),
|
||||
new PacketPlayOutEntityTeleport(NMS.getHandle(getEntity())));
|
||||
}
|
||||
|
||||
|
@ -277,7 +277,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder {
|
||||
packets[5] = new PacketPlayOutPlayerInfo(getBukkitEntity().getPlayerListName(), !removeFromPlayerList,
|
||||
removeFromPlayerList ? 9999 : ping);
|
||||
}
|
||||
NMS.sendPacketsNearby(current, packets);
|
||||
NMS.sendPacketsNearby(getBukkitEntity(), current, packets);
|
||||
packetUpdateCount = 0;
|
||||
}
|
||||
}
|
||||
|
@ -342,19 +342,19 @@ public class NMS {
|
||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
|
||||
}
|
||||
|
||||
public static void sendPacketNearby(Location location, Packet packet) {
|
||||
NMS.sendPacketsNearby(location, Arrays.asList(packet), 64);
|
||||
public static void sendPacketNearby(Player from, Location location, Packet packet) {
|
||||
NMS.sendPacketsNearby(from, location, Arrays.asList(packet), 64);
|
||||
}
|
||||
|
||||
public static void sendPacketsNearby(Location location, Collection<Packet> packets) {
|
||||
NMS.sendPacketsNearby(location, packets, 64);
|
||||
public static void sendPacketsNearby(Player from, Location location, Collection<Packet> packets) {
|
||||
NMS.sendPacketsNearby(from, location, packets, 64);
|
||||
}
|
||||
|
||||
public static void sendPacketsNearby(Location location, Collection<Packet> packets, double radius) {
|
||||
public static void sendPacketsNearby(Player from, Location location, Collection<Packet> packets, double radius) {
|
||||
radius *= radius;
|
||||
final org.bukkit.World world = location.getWorld();
|
||||
for (Player ply : Bukkit.getServer().getOnlinePlayers()) {
|
||||
if (ply == null || world != ply.getWorld()) {
|
||||
if (ply == null || world != ply.getWorld() || (from != null && ply.canSee(from))) {
|
||||
continue;
|
||||
}
|
||||
if (location.distanceSquared(ply.getLocation(PACKET_CACHE_LOCATION)) > radius) {
|
||||
@ -366,8 +366,8 @@ public class NMS {
|
||||
}
|
||||
}
|
||||
|
||||
public static void sendPacketsNearby(Location location, Packet... packets) {
|
||||
NMS.sendPacketsNearby(location, Arrays.asList(packets), 64);
|
||||
public static void sendPacketsNearby(Player from, Location location, Packet... packets) {
|
||||
NMS.sendPacketsNearby(from, location, Arrays.asList(packets), 64);
|
||||
}
|
||||
|
||||
public static void sendToOnline(Packet... packets) {
|
||||
|
@ -119,6 +119,7 @@ public enum PlayerAnimation {
|
||||
}
|
||||
|
||||
protected void sendPacketNearby(Packet packet, EntityPlayer player, int radius) {
|
||||
NMS.sendPacketsNearby(player.getBukkitEntity().getLocation(), Arrays.asList(packet), radius);
|
||||
NMS.sendPacketsNearby(player.getBukkitEntity(), player.getBukkitEntity().getLocation(), Arrays.asList(packet),
|
||||
radius);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user