mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-23 19:16:34 +01:00
Add packet update delay setting
This commit is contained in:
parent
e248d3f7f9
commit
f897ab728d
@ -96,6 +96,7 @@ public class Settings {
|
||||
MESSAGE_COLOUR("general.color-scheme.message", "<a>"),
|
||||
NPC_ATTACK_DISTANCE("npc.pathfinding.attack-range", 1.75 * 1.75),
|
||||
NPC_COST("economy.npc.cost", 100D),
|
||||
PACKET_UPDATE_DELAY("npc.packets.update-delay", 30),
|
||||
QUICK_SELECT("npc.selection.quick-select", false),
|
||||
REMOVE_PLAYERS_FROM_PLAYER_LIST("npc.player.remove-from-list", true),
|
||||
SAVE_TASK_DELAY("storage.save-task.delay", 20 * 60 * 60),
|
||||
|
@ -217,7 +217,8 @@ public class CitizensNPC extends AbstractNPC {
|
||||
}
|
||||
navigator.run();
|
||||
|
||||
if (!getNavigator().isNavigating() && getEntity().getWorld().getTime() % 30 == 0) {
|
||||
if (!getNavigator().isNavigating()
|
||||
&& getEntity().getWorld().getTime() % Setting.PACKET_UPDATE_DELAY.asInt() == 0) {
|
||||
Player player = getEntity() instanceof Player ? (Player) getEntity() : null;
|
||||
NMS.sendPacketNearby(player, getStoredLocation(),
|
||||
new PacketPlayOutEntityTeleport(NMS.getHandle(getEntity())));
|
||||
|
@ -52,7 +52,6 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder {
|
||||
private PlayerNavigation navigation;
|
||||
private final CitizensNPC npc;
|
||||
private final Location packetLocationCache = new Location(null, 0, 0, 0);
|
||||
private int packetUpdateCount;
|
||||
private int useListName = -1;
|
||||
|
||||
public EntityHumanNPC(MinecraftServer minecraftServer, WorldServer world, GameProfile gameProfile,
|
||||
@ -258,7 +257,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder {
|
||||
}
|
||||
|
||||
private void updatePackets(boolean navigating) {
|
||||
if (++packetUpdateCount >= 30) {
|
||||
if (world.getWorld().getTime() % Setting.PACKET_UPDATE_DELAY.asInt() == 0) {
|
||||
Location current = getBukkitEntity().getLocation(packetLocationCache);
|
||||
Packet[] packets = new Packet[navigating ? 6 : 7];
|
||||
if (!navigating) {
|
||||
@ -278,7 +277,6 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder {
|
||||
removeFromPlayerList ? 9999 : ping);
|
||||
}
|
||||
NMS.sendPacketsNearby(getBukkitEntity(), current, packets);
|
||||
packetUpdateCount = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user