From 04d1d1e2b900b4bb76eaa73ecbfe0a5f9ebf1b99 Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot Date: Sun, 4 Feb 2024 10:10:28 +1100 Subject: [PATCH] #971: Add Player methods for client-side potion effects By: Jishuna --- .../main/java/org/bukkit/entity/Player.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/paper-api/src/main/java/org/bukkit/entity/Player.java b/paper-api/src/main/java/org/bukkit/entity/Player.java index fe643c1b3b..0294000a80 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Player.java +++ b/paper-api/src/main/java/org/bukkit/entity/Player.java @@ -43,6 +43,8 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.map.MapView; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.messaging.PluginMessageRecipient; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; import org.bukkit.profile.PlayerProfile; import org.bukkit.scoreboard.Scoreboard; import org.jetbrains.annotations.ApiStatus; @@ -925,6 +927,32 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM @ApiStatus.Experimental public void sendBlockUpdate(@NotNull Location loc, @NotNull TileState tileState) throws IllegalArgumentException; + /** + * Change a potion effect for the target entity. This will not actually + * change the entity's potion effects in any way. + *

+ * Note: Sending an effect change to a player for themselves may + * cause unexpected behavior on the client. Effects sent this way will also + * not be removed when their timer reaches 0, they can be removed with + * {@link #sendPotionEffectChangeRemove(LivingEntity, PotionEffectType)} + * + * @param entity the entity whose potion effects to change + * @param effect the effect to change + */ + public void sendPotionEffectChange(@NotNull LivingEntity entity, @NotNull PotionEffect effect); + + /** + * Remove a potion effect for the target entity. This will not actually + * change the entity's potion effects in any way. + *

+ * Note: Sending an effect change to a player for themselves may + * cause unexpected behavior on the client. + * + * @param entity the entity whose potion effects to change + * @param type the effect type to remove + */ + public void sendPotionEffectChangeRemove(@NotNull LivingEntity entity, @NotNull PotionEffectType type); + /** * Render a map and send it to the player in its entirety. This may be * used when streaming the map in the normal manner is not desirable.