Try fix a ghost armor issue

This commit is contained in:
libraryaddict 2020-11-03 18:56:58 +13:00
parent 6530408282
commit 9489d794d4
2 changed files with 14 additions and 3 deletions

View File

@ -159,9 +159,7 @@ public class PlayerSkinHandler implements Listener {
} }
public void handlePackets(Player player, PlayerDisguise disguise, LibsPackets packets) { public void handlePackets(Player player, PlayerDisguise disguise, LibsPackets packets) {
if (packets.getPackets().stream().anyMatch(p -> p.getType() == Server.NAMED_ENTITY_SPAWN)) { boolean spawn = packets.getPackets().stream().anyMatch(p -> p.getType() == Server.NAMED_ENTITY_SPAWN);
return;
}
List<PlayerSkin> skins = getCache().getIfPresent(player); List<PlayerSkin> skins = getCache().getIfPresent(player);
@ -175,6 +173,17 @@ public class PlayerSkinHandler implements Listener {
return; return;
} }
if (spawn) {
packets.getDelayedPacketsMap().entrySet().removeIf(entry -> {
entry.getValue()
.removeIf(packet -> packet.getType() == Server.ENTITY_EQUIPMENT && isRemove(skin, packet));
return entry.getValue().isEmpty();
});
return;
}
packets.getPackets().removeIf(packet -> isRemove(skin, packet)); packets.getPackets().removeIf(packet -> isRemove(skin, packet));
packets.getDelayedPacketsMap().entrySet().removeIf(entry -> { packets.getDelayedPacketsMap().entrySet().removeIf(entry -> {

View File

@ -74,6 +74,7 @@ public class PacketHandlerSpawn implements IPacketHandler {
*/ */
private void constructSpawnPackets(final Player observer, LibsPackets packets, Entity disguisedEntity) { private void constructSpawnPackets(final Player observer, LibsPackets packets, Entity disguisedEntity) {
Disguise disguise = packets.getDisguise(); Disguise disguise = packets.getDisguise();
boolean sendArmor = true;
if (DisguiseConfig.isMiscDisguisesForLivingEnabled()) { if (DisguiseConfig.isMiscDisguisesForLivingEnabled()) {
if (disguise.getWatcher() instanceof LivingWatcher) { if (disguise.getWatcher() instanceof LivingWatcher) {
@ -215,6 +216,7 @@ public class PacketHandlerSpawn implements IPacketHandler {
boolean normalPlayerDisguise = observer == disguisedEntity || dist > (50 * 50) || boolean normalPlayerDisguise = observer == disguisedEntity || dist > (50 * 50) ||
(observer.getLocation().add(observer.getLocation().getDirection().normalize()) (observer.getLocation().add(observer.getLocation().getDirection().normalize())
.distanceSquared(disguisedEntity.getLocation()) - dist) < 0.3; .distanceSquared(disguisedEntity.getLocation()) - dist) < 0.3;
sendArmor = normalPlayerDisguise;
skin.setSleepPackets(!normalPlayerDisguise); skin.setSleepPackets(!normalPlayerDisguise);