Add packet update delay setting

This commit is contained in:
fullwall 2022-01-02 01:22:35 +08:00
parent b8b1d7f818
commit 5fffa23e94
11 changed files with 29 additions and 19 deletions

View File

@ -361,20 +361,21 @@ public class CitizensNPC extends AbstractNPC {
resetCachedCoord();
return;
}
if (data().get(NPC.SWIMMING_METADATA, true)) {
if (data().get(NPC.Metadata.SWIMMING, true)) {
NMS.trySwim(getEntity());
}
navigator.run();
if (SUPPORT_GLOWING) {
try {
getEntity().setGlowing(data().get(NPC.GLOWING_METADATA, false));
getEntity().setGlowing(data().get(NPC.Metadata.GLOWING, false));
} catch (NoSuchMethodError e) {
SUPPORT_GLOWING = false;
}
}
boolean isLiving = getEntity() instanceof LivingEntity;
if (updateCounter++ > Setting.PACKET_UPDATE_DELAY.asInt()) {
if (updateCounter++ > data().<Integer> get(NPC.Metadata.PACKET_UPDATE_DELAY,
Setting.PACKET_UPDATE_DELAY.asInt())) {
if (Setting.KEEP_CHUNKS_LOADED.asBoolean()) {
ChunkCoord currentCoord = new ChunkCoord(getStoredLocation());
if (!currentCoord.equals(cachedCoord)) {
@ -393,13 +394,12 @@ public class CitizensNPC extends AbstractNPC {
updateCustomNameVisibility();
if (isLiving) {
NMS.setKnockbackResistance((LivingEntity) getEntity(),
data().get(NPC.DEFAULT_PROTECTED_METADATA, true) ? 1D : 0D);
NMS.setKnockbackResistance((LivingEntity) getEntity(), isProtected() ? 1D : 0D);
}
if (SUPPORT_SILENT && data().has(NPC.SILENT_METADATA)) {
try {
getEntity().setSilent(Boolean.parseBoolean(data().get(NPC.SILENT_METADATA).toString()));
getEntity().setSilent(Boolean.parseBoolean(data().get(NPC.Metadata.SILENT).toString()));
} catch (NoSuchMethodError e) {
SUPPORT_SILENT = false;
}
@ -414,14 +414,14 @@ public class CitizensNPC extends AbstractNPC {
private void updateCustomName() {
boolean nameVisibility = false;
if (!getEntity().isCustomNameVisible()
&& !data().<Object> get(NPC.NAMEPLATE_VISIBLE_METADATA, true).toString().equals("hover")) {
&& !data().<Object> get(NPC.Metadata.NAMEPLATE_VISIBLE, true).toString().equals("hover")) {
getEntity().setCustomName("");
} else if (!requiresNameHologram()) {
nameVisibility = true;
getEntity().setCustomName(getFullName());
}
String teamName = data().get(NPC.SCOREBOARD_FAKE_TEAM_NAME_METADATA, "");
String teamName = data().get(NPC.Metadata.SCOREBOARD_FAKE_TEAM_NAME, "");
Team team = null;
if (!(getEntity() instanceof Player) || teamName.length() == 0
|| (team = Util.getDummyScoreboard().getTeam(teamName)) == null)
@ -437,7 +437,7 @@ public class CitizensNPC extends AbstractNPC {
}
private void updateCustomNameVisibility() {
String nameplateVisible = data().<Object> get(NPC.NAMEPLATE_VISIBLE_METADATA, true).toString();
String nameplateVisible = data().<Object> get(NPC.Metadata.NAMEPLATE_VISIBLE, true).toString();
if (requiresNameHologram()) {
nameplateVisible = "false";
}

View File

@ -425,7 +425,8 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
}
equipmentCache.put(slot, equipment);
}
if (updateCounter++ <= Setting.PACKET_UPDATE_DELAY.asInt() && !itemChanged)
if (updateCounter++ <= npc.data().<Integer> get(NPC.Metadata.PACKET_UPDATE_DELAY,
Setting.PACKET_UPDATE_DELAY.asInt()) && !itemChanged)
return;
updateCounter = 0;
Location current = getBukkitEntity().getLocation(packetLocationCache);

View File

@ -432,7 +432,8 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
}
equipmentCache.put(slot, equipment);
}
if (updateCounter++ <= Setting.PACKET_UPDATE_DELAY.asInt() && !itemChanged)
if (updateCounter++ <= npc.data().<Integer> get(NPC.Metadata.PACKET_UPDATE_DELAY,
Setting.PACKET_UPDATE_DELAY.asInt()) && !itemChanged)
return;
updateCounter = 0;

View File

@ -459,7 +459,8 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
}
equipmentCache.put(slot, equipment);
}
if (updateCounter++ <= Setting.PACKET_UPDATE_DELAY.asInt() && !itemChanged)
if (updateCounter++ <= npc.data().<Integer> get(NPC.Metadata.PACKET_UPDATE_DELAY,
Setting.PACKET_UPDATE_DELAY.asInt()) && !itemChanged)
return;
updateCounter = 0;

View File

@ -450,7 +450,8 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
}
equipmentCache.put(slot, equipment);
}
if (updateCounter++ <= Setting.PACKET_UPDATE_DELAY.asInt() && !itemChanged)
if (updateCounter++ <= npc.data().<Integer> get(NPC.Metadata.PACKET_UPDATE_DELAY,
Setting.PACKET_UPDATE_DELAY.asInt()) && !itemChanged)
return;
updateCounter = 0;

View File

@ -453,7 +453,8 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
}
equipmentCache.put(slot, equipment);
}
if (updateCounter++ <= Setting.PACKET_UPDATE_DELAY.asInt() && !itemChanged)
if (updateCounter++ <= npc.data().<Integer> get(NPC.Metadata.PACKET_UPDATE_DELAY,
Setting.PACKET_UPDATE_DELAY.asInt()) && !itemChanged)
return;
updateCounter = 0;

View File

@ -465,7 +465,8 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
}
equipmentCache.put(slot, equipment);
}
if (updateCounter++ <= Setting.PACKET_UPDATE_DELAY.asInt() && !itemChanged)
if (updateCounter++ <= npc.data().<Integer> get(NPC.Metadata.PACKET_UPDATE_DELAY,
Setting.PACKET_UPDATE_DELAY.asInt()) && !itemChanged)
return;
updateCounter = 0;
Location current = getBukkitEntity().getLocation(packetLocationCache);

View File

@ -495,7 +495,8 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
}
equipmentCache.put(slot, equipment);
}
if (updateCounter++ <= Setting.PACKET_UPDATE_DELAY.asInt() && !itemChanged)
if (updateCounter++ <= npc.data().<Integer> get(NPC.Metadata.PACKET_UPDATE_DELAY,
Setting.PACKET_UPDATE_DELAY.asInt()) && !itemChanged)
return;
updateCounter = 0;

View File

@ -520,7 +520,8 @@ public class EntityHumanNPC extends ServerPlayer implements NPCHolder, Skinnable
}
equipmentCache.put(slot, equipment);
}
if (updateCounter++ <= Setting.PACKET_UPDATE_DELAY.asInt() && !itemChanged)
if (updateCounter++ <= npc.data().<Integer> get(NPC.Metadata.PACKET_UPDATE_DELAY,
Setting.PACKET_UPDATE_DELAY.asInt()) && !itemChanged)
return;
updateCounter = 0;

View File

@ -519,7 +519,8 @@ public class EntityHumanNPC extends ServerPlayer implements NPCHolder, Skinnable
}
equipmentCache.put(slot, equipment);
}
if (updateCounter++ <= Setting.PACKET_UPDATE_DELAY.asInt() && !itemChanged)
if (updateCounter++ <= npc.data().<Integer> get(NPC.Metadata.PACKET_UPDATE_DELAY,
Setting.PACKET_UPDATE_DELAY.asInt()) && !itemChanged)
return;
updateCounter = 0;

View File

@ -425,7 +425,8 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
}
equipmentCache.put(slot, equipment);
}
if (updateCounter++ <= Setting.PACKET_UPDATE_DELAY.asInt() && !itemChanged)
if (updateCounter++ <= npc.data().<Integer> get(NPC.Metadata.PACKET_UPDATE_DELAY,
Setting.PACKET_UPDATE_DELAY.asInt()) && !itemChanged)
return;
updateCounter = 0;
Location current = getBukkitEntity().getLocation(packetLocationCache);