mirror of
https://github.com/TotalFreedomMC/TF-WorldGuardExtraFlagsPlugin.git
synced 2024-12-27 01:34:13 +00:00
PotionEffect hasParticles not supported on 1.7
This commit is contained in:
parent
7d12cdb0e1
commit
1addc326db
3 changed files with 32 additions and 5 deletions
|
@ -5,6 +5,7 @@ import java.awt.Color;
|
|||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityPotionEffectEvent;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
|
@ -16,6 +17,7 @@ public class SupportedFeatures
|
|||
@Getter private static boolean frostwalkerSupported;
|
||||
@Getter private static boolean stopSoundSupported;
|
||||
@Getter private static boolean potionEffectEventSupported;
|
||||
@Getter private static boolean potionEffectParticles;
|
||||
|
||||
static
|
||||
{
|
||||
|
@ -42,5 +44,14 @@ public class SupportedFeatures
|
|||
catch (Throwable ignored)
|
||||
{
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
SupportedFeatures.potionEffectParticles = PotionEffect.class.getDeclaredMethod("hasParticles") != null;
|
||||
}
|
||||
catch(Throwable ignored)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ import com.sk89q.worldguard.session.Session;
|
|||
|
||||
import net.goldtreeservers.worldguardextraflags.flags.Flags;
|
||||
import net.goldtreeservers.worldguardextraflags.flags.data.PotionEffectDetails;
|
||||
import net.goldtreeservers.worldguardextraflags.utils.SupportedFeatures;
|
||||
import net.goldtreeservers.worldguardextraflags.wg.WorldGuardUtils;
|
||||
import net.goldtreeservers.worldguardextraflags.wg.wrappers.HandlerWrapper;
|
||||
|
||||
|
@ -91,7 +92,7 @@ public class BlockedEffectsFlagHandler extends HandlerWrapper
|
|||
|
||||
if (effect != null)
|
||||
{
|
||||
this.removedEffects.put(effect.getType(), new PotionEffectDetails(System.nanoTime() + (long)(effect.getDuration() / 20D * TimeUnit.SECONDS.toNanos(1L)), effect.getAmplifier(), effect.isAmbient(), effect.hasParticles()));
|
||||
this.removedEffects.put(effect.getType(), new PotionEffectDetails(System.nanoTime() + (long)(effect.getDuration() / 20D * TimeUnit.SECONDS.toNanos(1L)), effect.getAmplifier(), effect.isAmbient(), SupportedFeatures.isPotionEffectParticles() ? effect.hasParticles() : true));
|
||||
|
||||
player.removePotionEffect(effectType);
|
||||
}
|
||||
|
@ -111,7 +112,14 @@ public class BlockedEffectsFlagHandler extends HandlerWrapper
|
|||
int timeLeft = removedEffect.getTimeLeftInTicks();
|
||||
if (timeLeft > 0)
|
||||
{
|
||||
player.addPotionEffect(new PotionEffect(potionEffect.getKey(), timeLeft, removedEffect.getAmplifier(), removedEffect.isAmbient(), removedEffect.isParticles()), true);
|
||||
if (SupportedFeatures.isPotionEffectParticles())
|
||||
{
|
||||
player.addPotionEffect(new PotionEffect(potionEffect.getKey(), timeLeft, removedEffect.getAmplifier(), removedEffect.isAmbient(), removedEffect.isParticles()), true);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.addPotionEffect(new PotionEffect(potionEffect.getKey(), timeLeft, removedEffect.getAmplifier(), removedEffect.isAmbient()), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ import com.sk89q.worldguard.session.Session;
|
|||
import lombok.Getter;
|
||||
import net.goldtreeservers.worldguardextraflags.flags.Flags;
|
||||
import net.goldtreeservers.worldguardextraflags.flags.data.PotionEffectDetails;
|
||||
import net.goldtreeservers.worldguardextraflags.utils.SupportedFeatures;
|
||||
import net.goldtreeservers.worldguardextraflags.wg.WorldGuardUtils;
|
||||
import net.goldtreeservers.worldguardextraflags.wg.wrappers.HandlerWrapper;
|
||||
|
||||
|
@ -105,7 +106,7 @@ public class GiveEffectsFlagHandler extends HandlerWrapper
|
|||
|
||||
if (this.givenEffects.add(effect.getType()) && effect_ != null)
|
||||
{
|
||||
this.removedEffects.put(effect_.getType(), new PotionEffectDetails(System.nanoTime() + (long)(effect_.getDuration() / 20D * TimeUnit.SECONDS.toNanos(1L)), effect_.getAmplifier(), effect_.isAmbient(), effect_.hasParticles()));
|
||||
this.removedEffects.put(effect_.getType(), new PotionEffectDetails(System.nanoTime() + (long)(effect_.getDuration() / 20D * TimeUnit.SECONDS.toNanos(1L)), effect_.getAmplifier(), effect_.isAmbient(), SupportedFeatures.isPotionEffectParticles() ? effect_.hasParticles() : true));
|
||||
|
||||
player.removePotionEffect(effect_.getType());
|
||||
}
|
||||
|
@ -160,7 +161,14 @@ public class GiveEffectsFlagHandler extends HandlerWrapper
|
|||
|
||||
if (timeLeft > 0)
|
||||
{
|
||||
player.addPotionEffect(new PotionEffect(effect.getKey(), timeLeft, removedEffect.getAmplifier(), removedEffect.isAmbient(), removedEffect.isParticles()), true);
|
||||
if (SupportedFeatures.isPotionEffectParticles())
|
||||
{
|
||||
player.addPotionEffect(new PotionEffect(effect.getKey(), timeLeft, removedEffect.getAmplifier(), removedEffect.isAmbient(), removedEffect.isParticles()), true);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.addPotionEffect(new PotionEffect(effect.getKey(), timeLeft, removedEffect.getAmplifier(), removedEffect.isAmbient()), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -180,7 +188,7 @@ public class GiveEffectsFlagHandler extends HandlerWrapper
|
|||
{
|
||||
for(PotionEffect effect : effects)
|
||||
{
|
||||
this.removedEffects.put(effect.getType(), new PotionEffectDetails(System.nanoTime() + (long)(effect.getDuration() / 20D * TimeUnit.SECONDS.toNanos(1L)), effect.getAmplifier(), effect.isAmbient(), effect.hasParticles()));
|
||||
this.removedEffects.put(effect.getType(), new PotionEffectDetails(System.nanoTime() + (long)(effect.getDuration() / 20D * TimeUnit.SECONDS.toNanos(1L)), effect.getAmplifier(), effect.isAmbient(), SupportedFeatures.isPotionEffectParticles() ? effect.hasParticles() : true));
|
||||
}
|
||||
|
||||
this.check(player, WorldGuardUtils.getCommunicator().getRegionContainer().createQuery().getApplicableRegions(player.getLocation()));
|
||||
|
|
Loading…
Reference in a new issue