mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2025-02-28 18:21:19 +01:00
Send tablist packet globally
This commit is contained in:
parent
9eeae0c5b3
commit
7c441bdefd
@ -134,6 +134,23 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder {
|
|||||||
return controllerJump;
|
return controllerJump;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Packet getListPacket(boolean removeFromPlayerList) {
|
||||||
|
if (PLAYER_INFO_CONSTRUCTOR != null) {
|
||||||
|
try {
|
||||||
|
return PLAYER_INFO_CONSTRUCTOR.newInstance(getBukkitEntity().getPlayerListName(),
|
||||||
|
!removeFromPlayerList, removeFromPlayerList ? 9999 : ping);
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
return (Packet) (removeFromPlayerList ? PLAYER_INFO_REMOVE_METHOD.invoke(null, getBukkitEntity()
|
||||||
|
.getHandle()) : PLAYER_INFO_ADD_METHOD.invoke(null, getBukkitEntity().getHandle()));
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public Navigation getNavigation() {
|
public Navigation getNavigation() {
|
||||||
return navigation;
|
return navigation;
|
||||||
}
|
}
|
||||||
@ -260,9 +277,9 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder {
|
|||||||
private void updatePackets(boolean navigating) {
|
private void updatePackets(boolean navigating) {
|
||||||
if (world.getWorld().getFullTime() % Setting.PACKET_UPDATE_DELAY.asInt() == 0) {
|
if (world.getWorld().getFullTime() % Setting.PACKET_UPDATE_DELAY.asInt() == 0) {
|
||||||
Location current = getBukkitEntity().getLocation(packetLocationCache);
|
Location current = getBukkitEntity().getLocation(packetLocationCache);
|
||||||
Packet[] packets = new Packet[navigating ? 6 : 7];
|
Packet[] packets = new Packet[navigating ? 5 : 6];
|
||||||
if (!navigating) {
|
if (!navigating) {
|
||||||
packets[6] = new PacketPlayOutEntityHeadRotation(this,
|
packets[5] = new PacketPlayOutEntityHeadRotation(this,
|
||||||
(byte) MathHelper.d(NMS.getHeadYaw(this) * 256.0F / 360.0F));
|
(byte) MathHelper.d(NMS.getHeadYaw(this) * 256.0F / 360.0F));
|
||||||
}
|
}
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
@ -276,20 +293,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder {
|
|||||||
if (useListName != this.useListName || this.useListName == -1) {
|
if (useListName != this.useListName || this.useListName == -1) {
|
||||||
this.useListName = useListName;
|
this.useListName = useListName;
|
||||||
}
|
}
|
||||||
if (PLAYER_INFO_CONSTRUCTOR != null) {
|
NMS.sendToOnline(getListPacket(removeFromPlayerList));
|
||||||
try {
|
|
||||||
packets[5] = PLAYER_INFO_CONSTRUCTOR.newInstance(getBukkitEntity().getPlayerListName(),
|
|
||||||
!removeFromPlayerList, removeFromPlayerList ? 9999 : ping);
|
|
||||||
} catch (Exception e) {
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
packets[5] = (Packet) (removeFromPlayerList ? PLAYER_INFO_REMOVE_METHOD.invoke(null,
|
|
||||||
getBukkitEntity().getHandle()) : PLAYER_INFO_ADD_METHOD.invoke(null, getBukkitEntity()
|
|
||||||
.getHandle()));
|
|
||||||
} catch (Exception e) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
NMS.sendPacketsNearby(getBukkitEntity(), current, packets);
|
NMS.sendPacketsNearby(getBukkitEntity(), current, packets);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user