diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java index aa14dbee85..3cfd3a7fc2 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -58,6 +58,7 @@ import net.minecraft.network.protocol.game.ClientboundSetTitleTextPacket; import net.minecraft.network.protocol.game.ClientboundSetTitlesAnimationPacket; import net.minecraft.network.protocol.game.PacketPlayOutBlockBreakAnimation; import net.minecraft.network.protocol.game.PacketPlayOutBlockChange; +import net.minecraft.network.protocol.game.PacketPlayOutEntityEffect; import net.minecraft.network.protocol.game.PacketPlayOutEntityEquipment; import net.minecraft.network.protocol.game.PacketPlayOutEntitySound; import net.minecraft.network.protocol.game.PacketPlayOutExperience; @@ -66,6 +67,7 @@ import net.minecraft.network.protocol.game.PacketPlayOutMap; import net.minecraft.network.protocol.game.PacketPlayOutMultiBlockChange; import net.minecraft.network.protocol.game.PacketPlayOutNamedSoundEffect; import net.minecraft.network.protocol.game.PacketPlayOutPlayerListHeaderFooter; +import net.minecraft.network.protocol.game.PacketPlayOutRemoveEntityEffect; import net.minecraft.network.protocol.game.PacketPlayOutSpawnPosition; import net.minecraft.network.protocol.game.PacketPlayOutStopSound; import net.minecraft.network.protocol.game.PacketPlayOutUpdateAttributes; @@ -148,6 +150,8 @@ import org.bukkit.craftbukkit.event.CraftEventFactory; import org.bukkit.craftbukkit.inventory.CraftItemStack; import org.bukkit.craftbukkit.map.CraftMapView; import org.bukkit.craftbukkit.map.RenderData; +import org.bukkit.craftbukkit.potion.CraftPotionEffectType; +import org.bukkit.craftbukkit.potion.CraftPotionUtil; import org.bukkit.craftbukkit.profile.CraftPlayerProfile; import org.bukkit.craftbukkit.scoreboard.CraftScoreboard; import org.bukkit.craftbukkit.util.CraftChatMessage; @@ -172,6 +176,8 @@ import org.bukkit.map.MapView; import org.bukkit.metadata.MetadataValue; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.messaging.StandardMessenger; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; import org.bukkit.profile.PlayerProfile; import org.bukkit.scoreboard.Scoreboard; import org.jetbrains.annotations.NotNull; @@ -762,6 +768,30 @@ public class CraftPlayer extends CraftHumanEntity implements Player { getHandle().connection.send(new PacketPlayOutEntityEquipment(entity.getEntityId(), equipment)); } + @Override + public void sendPotionEffectChange(LivingEntity entity, PotionEffect effect) { + Preconditions.checkArgument(entity != null, "Entity cannot be null"); + Preconditions.checkArgument(effect != null, "Effect cannot be null"); + + if (getHandle().connection == null) { + return; + } + + getHandle().connection.send(new PacketPlayOutEntityEffect(entity.getEntityId(), CraftPotionUtil.fromBukkit(effect))); + } + + @Override + public void sendPotionEffectChangeRemove(LivingEntity entity, PotionEffectType type) { + Preconditions.checkArgument(entity != null, "Entity cannot be null"); + Preconditions.checkArgument(type != null, "Type cannot be null"); + + if (getHandle().connection == null) { + return; + } + + getHandle().connection.send(new PacketPlayOutRemoveEntityEffect(entity.getEntityId(), CraftPotionEffectType.bukkitToMinecraft(type))); + } + @Override public WorldBorder getWorldBorder() { return clientWorldBorder;