Fix an array bounds exception
This commit is contained in:
parent
d29bdb70fe
commit
53657f57ca
@ -57,8 +57,8 @@ public class PlayerSkinHandler implements Listener {
|
|||||||
private boolean sleepPackets;
|
private boolean sleepPackets;
|
||||||
|
|
||||||
public boolean canRemove(boolean onMoved) {
|
public boolean canRemove(boolean onMoved) {
|
||||||
return firstPacketSent + (DisguiseConfig.getTablistRemoveDelay() * 50) +
|
return firstPacketSent + (DisguiseConfig.getTablistRemoveDelay() * 50) + (onMoved ? 0 : DisguiseConfig.getPlayerDisguisesSkinExpiresMove() * 50) <
|
||||||
(onMoved ? 0 : DisguiseConfig.getPlayerDisguisesSkinExpiresMove() * 50) < System.currentTimeMillis();
|
System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -75,8 +75,8 @@ public class PlayerSkinHandler implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private final Cache<Player, List<PlayerSkin>> cache = CacheBuilder.newBuilder().weakKeys()
|
private final Cache<Player, List<PlayerSkin>> cache =
|
||||||
.expireAfterWrite(DisguiseConfig.getPlayerDisguisesSkinExpiresMove() * 50, TimeUnit.MILLISECONDS)
|
CacheBuilder.newBuilder().weakKeys().expireAfterWrite(DisguiseConfig.getPlayerDisguisesSkinExpiresMove() * 50, TimeUnit.MILLISECONDS)
|
||||||
.removalListener((event) -> {
|
.removalListener((event) -> {
|
||||||
if (event.getCause() != RemovalCause.EXPIRED) {
|
if (event.getCause() != RemovalCause.EXPIRED) {
|
||||||
return;
|
return;
|
||||||
@ -130,8 +130,8 @@ public class PlayerSkinHandler implements Listener {
|
|||||||
packet.getModifier().write(2, loc.getY());
|
packet.getModifier().write(2, loc.getY());
|
||||||
packet.getModifier().write(3, loc.getZ());
|
packet.getModifier().write(3, loc.getZ());
|
||||||
|
|
||||||
for (PlayerSkin skin : value) {
|
for (PlayerSkin skin : new ArrayList<>(value)) {
|
||||||
if (!skin.isSleepPackets()) {
|
if (!value.contains(skin) || !skin.isSleepPackets()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,8 +176,7 @@ public class PlayerSkinHandler implements Listener {
|
|||||||
|
|
||||||
if (spawn) {
|
if (spawn) {
|
||||||
packets.getDelayedPacketsMap().entrySet().removeIf(entry -> {
|
packets.getDelayedPacketsMap().entrySet().removeIf(entry -> {
|
||||||
entry.getValue()
|
entry.getValue().removeIf(packet -> packet.getType() == Server.ENTITY_EQUIPMENT && isRemove(skin, packet));
|
||||||
.removeIf(packet -> packet.getType() == Server.ENTITY_EQUIPMENT && isRemove(skin, packet));
|
|
||||||
|
|
||||||
return entry.getValue().isEmpty();
|
return entry.getValue().isEmpty();
|
||||||
});
|
});
|
||||||
@ -209,8 +208,7 @@ public class PlayerSkinHandler implements Listener {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR,
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
ignoreCancelled = true)
|
|
||||||
private void onUndisguise(UndisguiseEvent event) {
|
private void onUndisguise(UndisguiseEvent event) {
|
||||||
if (!event.getDisguise().isPlayerDisguise()) {
|
if (!event.getDisguise().isPlayerDisguise()) {
|
||||||
return;
|
return;
|
||||||
@ -246,11 +244,10 @@ public class PlayerSkinHandler implements Listener {
|
|||||||
private void addMetadata(Player player, PlayerSkin skin) throws InvocationTargetException {
|
private void addMetadata(Player player, PlayerSkin skin) throws InvocationTargetException {
|
||||||
PlayerDisguise disguise = skin.getDisguise().get();
|
PlayerDisguise disguise = skin.getDisguise().get();
|
||||||
Entity entity = disguise.getEntity();
|
Entity entity = disguise.getEntity();
|
||||||
WrappedDataWatcher watcher = DisguiseUtilities
|
WrappedDataWatcher watcher = DisguiseUtilities.createSanitizedDataWatcher(WrappedDataWatcher.getEntityWatcher(entity), disguise.getWatcher());
|
||||||
.createSanitizedDataWatcher(WrappedDataWatcher.getEntityWatcher(entity), disguise.getWatcher());
|
|
||||||
|
|
||||||
PacketContainer metaPacket = ProtocolLibrary.getProtocolManager()
|
PacketContainer metaPacket =
|
||||||
.createPacketConstructor(PacketType.Play.Server.ENTITY_METADATA, entity.getEntityId(), watcher, true)
|
ProtocolLibrary.getProtocolManager().createPacketConstructor(PacketType.Play.Server.ENTITY_METADATA, entity.getEntityId(), watcher, true)
|
||||||
.createPacket(entity.getEntityId(), watcher, true);
|
.createPacket(entity.getEntityId(), watcher, true);
|
||||||
|
|
||||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, metaPacket, false);
|
ProtocolLibrary.getProtocolManager().sendServerPacket(player, metaPacket, false);
|
||||||
@ -339,8 +336,7 @@ public class PlayerSkinHandler implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (skin.isDoTabList()) {
|
if (skin.isDoTabList()) {
|
||||||
PacketContainer packetContainer =
|
PacketContainer packetContainer = DisguiseUtilities.getTabPacket(disguise, EnumWrappers.PlayerInfoAction.REMOVE_PLAYER);
|
||||||
DisguiseUtilities.getTabPacket(disguise, EnumWrappers.PlayerInfoAction.REMOVE_PLAYER);
|
|
||||||
|
|
||||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, packetContainer);
|
ProtocolLibrary.getProtocolManager().sendServerPacket(player, packetContainer);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user