mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-24 17:22:55 +01:00
Add API to PotionEffect to determine whether particles are visible and displayed to the client. Fixes SPIGOT-125
By: 0x277F <0x277F@gmail.com>
This commit is contained in:
parent
52f6aff4e1
commit
816db9f46b
1 changed files with 27 additions and 5 deletions
|
@ -26,9 +26,28 @@ public class PotionEffect implements ConfigurationSerializable {
|
||||||
private final int duration;
|
private final int duration;
|
||||||
private final PotionEffectType type;
|
private final PotionEffectType type;
|
||||||
private final boolean ambient;
|
private final boolean ambient;
|
||||||
|
private final boolean particles;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a potion effect.
|
* Creates a potion effect.
|
||||||
|
* @param type effect type
|
||||||
|
* @param duration measured in ticks, see {@link
|
||||||
|
* PotionEffect#getDuration()}
|
||||||
|
* @param amplifier the amplifier, see {@link PotionEffect#getAmplifier()}
|
||||||
|
* @param ambient the ambient status, see {@link PotionEffect#isAmbient()}
|
||||||
|
* @param particles the particle status, see {@link PotionEffect#hasParticles()}
|
||||||
|
*/
|
||||||
|
public PotionEffect(PotionEffectType type, int duration, int amplifier, boolean ambient, boolean particles){
|
||||||
|
Validate.notNull(type, "effect type cannot be null");
|
||||||
|
this.type = type;
|
||||||
|
this.duration = duration;
|
||||||
|
this.amplifier = amplifier;
|
||||||
|
this.ambient = ambient;
|
||||||
|
this.particles = particles;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a potion effect. Assumes that particles are visible
|
||||||
*
|
*
|
||||||
* @param type effect type
|
* @param type effect type
|
||||||
* @param duration measured in ticks, see {@link
|
* @param duration measured in ticks, see {@link
|
||||||
|
@ -37,11 +56,7 @@ public class PotionEffect implements ConfigurationSerializable {
|
||||||
* @param ambient the ambient status, see {@link PotionEffect#isAmbient()}
|
* @param ambient the ambient status, see {@link PotionEffect#isAmbient()}
|
||||||
*/
|
*/
|
||||||
public PotionEffect(PotionEffectType type, int duration, int amplifier, boolean ambient) {
|
public PotionEffect(PotionEffectType type, int duration, int amplifier, boolean ambient) {
|
||||||
Validate.notNull(type, "effect type cannot be null");
|
this(type, duration, amplifier, ambient, true);
|
||||||
this.type = type;
|
|
||||||
this.duration = duration;
|
|
||||||
this.amplifier = amplifier;
|
|
||||||
this.ambient = ambient;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -162,6 +177,13 @@ public class PotionEffect implements ConfigurationSerializable {
|
||||||
return ambient;
|
return ambient;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return whether this effect has particles or not
|
||||||
|
*/
|
||||||
|
public boolean hasParticles(){
|
||||||
|
return particles;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
int hash = 1;
|
int hash = 1;
|
||||||
|
|
Loading…
Add table
Reference in a new issue