Remove cast and instanceof check from Viewable#sendPacketToViewersAndSelf

This commit is contained in:
Kieran Wallbanks 2021-03-25 17:07:05 +00:00
parent 7bd9283e17
commit 845f41b88a
2 changed files with 6 additions and 3 deletions

View File

@ -80,9 +80,6 @@ public interface Viewable {
* @param packet the packet to send
*/
default void sendPacketToViewersAndSelf(@NotNull ServerPacket packet) {
if (this instanceof Player) {
((Player) this).getPlayerConnection().sendPacket(packet);
}
sendPacketToViewers(packet);
}
}

View File

@ -654,6 +654,12 @@ public class Player extends LivingEntity implements CommandSender {
return result;
}
@Override
public void sendPacketToViewersAndSelf(@NotNull ServerPacket packet) {
this.playerConnection.sendPacket(packet);
super.sendPacketToViewersAndSelf(packet);
}
/**
* Changes the player instance and load surrounding chunks if needed.
* <p>