TF-WorldGuardExtraFlagsPlugin/Common/src/main/java/net/goldtreeservers/worldguardextraflags/protocollib/ProtocolLibHelper.java
isokissa3 eb6b63b63f Block sending remove mob effect packet to clients when updating give-effects potion effect timers
Due to how CraftBukkit internally works is that when you add dublicate potion effect type it will be ignored unless you force it. But that causes some issues as the potion effect is removed (for really short period of time) but the packet is still sent to client. After this the new potion effect timer is sent on add mob effect packet. This will cause the nausea effect to reset everytime on clients 1.9 and above. This also fixes latency issues where the different packets dont arrive excatly at the same time and causes blinking on night vision effect.

This is fixed by using ProtocolLib to cancel the sending of remove mob effect packet when we are updating those effects.

On servers with 1.13 that are missing ProtocolLib alternative method will be used
2018-11-30 22:20:32 +02:00

26 lines
674 B
Java

package net.goldtreeservers.worldguardextraflags.protocollib;
import org.bukkit.plugin.Plugin;
import com.comphenix.protocol.ProtocolLibrary;
import lombok.Getter;
import net.goldtreeservers.worldguardextraflags.WorldGuardExtraFlagsPlugin;
public class ProtocolLibHelper
{
@Getter private final WorldGuardExtraFlagsPlugin plugin;
@Getter private final Plugin protocolLibPlugin;
public ProtocolLibHelper(WorldGuardExtraFlagsPlugin plugin, Plugin protocolLibPlugin)
{
this.plugin = plugin;
this.protocolLibPlugin = protocolLibPlugin;
}
public void onEnable()
{
ProtocolLibrary.getProtocolManager().addPacketListener(new RemoveEffectPacketListener());
}
}