Potion Effects should follow vanilla behavior by default
Skript/Server Version
[19:03:22 INFO]: [Skript] Skript's aliases can be found here: https://github.com/SkriptLang/skript-aliases
[19:03:22 INFO]: [Skript] Skript's documentation can be found here: https://skriptlang.github.io/Skript
[19:03:22 INFO]: [Skript] Server Version: git-Paper-98 (MC: 1.17.1)
[19:03:22 INFO]: [Skript] Skript Version: 2.6-beta2
[19:03:22 INFO]: [Skript] Installed Skript Addons:
Bug Description
When using skript's apply potion effect effect to apply speed 1 for 10 seconds and speed 2 for 5 seconds simultaneously, the result is just speed 2 for 15 seconds.
Expected Behavior
When applying multiple effects of the same type but differing tiers and durations, the effects should 'stack' on top of each other. For example, using /effect to give yourself speed 1 for 10 seconds and then speed 2 for 5 seconds results in you having speed 2 for 5 seconds and then speed 1 for 5 seconds. This was added in 1.15.2. Relevant wiki excerpt
Steps to Reproduce
function testPotionsSkript(p: player): # speed 2 for 15s ??
apply speed 1 to {_p} for 10 seconds
apply speed 2 to {_p} for 5 seconds
function testPotionsVanilla(p: player): # speed 2 for 5s and speed 1 for 5s
execute console command "/effect give %{_p}% minecraft:speed 10 0"
execute console command "/effect give %{_p}% minecraft:speed 5 1"
These two functions should do identical things, but don't. I also tested this following function, but it changed nothing, still speed 2 for 15s
function testPotionsSkript(p: player):
apply speed 1 to {_p} for 10 seconds
apply speed 2 to {_p} for 5 seconds replacing the existing effect
Errors or Screenshots
https://user-images.githubusercontent.com/10354869/125180854-f2924580-e1b3-11eb-942e-b5d90b32803c.mp4
Other
This seems very similar to some of the things mentioned in the suggestion #1458, but given that this directly contradicts the behavior shown in vanilla minecraft, it feels much more like a bug than just a possible spot for improvement.
Agreement
- [X] I have read the guidelines above and confirm I am following them with this report.
~~How does it function if you were to do (as just an example, you can manually adjust times for work with your test)~~
apply swiftness 2 to the player replacing the existing effect
~~Does it provide the proper functionality then?~~
EDIT: apparently I can't read, as you addressed this lol. I will take a look into this some more.
EDIT 2: this may be related to the fact that the method Skript uses is now deprecated. See: https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/entity/LivingEntity.html#addPotionEffect(org.bukkit.potion.PotionEffect,boolean)
I have done some testing and here is what I have found:
command /potiontest: # 15 seconds of speed 2, technically intended behavior
trigger:
apply speed 1 to player for 10 seconds
apply speed 2 to player for 5 seconds
command /potiontesthalfreplace: # 5 seconds of speed 2, then 5 seconds of speed 1
trigger:
apply speed 1 to player for 10 seconds
apply speed 2 to player for 5 seconds replacing the existing effect
command /potiontestreplace: # 5 seconds of speed 2, then 5 seconds of speed 1
trigger:
apply speed 1 to player for 10 seconds replacing the existing effect
apply speed 2 to player for 5 seconds replacing the existing effect
command /potiontestvanilla: # 5 seconds of speed 2, then 5 seconds of speed 1
trigger:
execute console command "/effect give %player% minecraft:speed 10 0"
execute console command "/effect give %player% minecraft:speed 5 1"
I don't think there is technically a "bug" here - but to be honest I think the potion effect should be reworked. It should just be completely consistent with vanilla behavior by default. That means applying the same potion effect type again should not just add the times together by default (or in any way IMO)
I'm not sure what I did to get 15 seconds of speed 2 with the replacing the existing effect version originally, but I tested the code you used and got the same results. I agree with your thoughts on how the effect should be reworked. Thanks for the help.