mirror of
https://github.com/Minestom/Minestom.git
synced 2024-12-28 03:57:50 +01:00
Fix most checkstyle warnings
This commit is contained in:
parent
c3d6af3afe
commit
0ce094567b
@ -404,7 +404,8 @@ public abstract class Entity implements Viewable, EventHandler, DataContainer, P
|
|||||||
|
|
||||||
// remove expired effects
|
// remove expired effects
|
||||||
{
|
{
|
||||||
effects.removeIf(timedPotion -> time >=
|
effects.removeIf(timedPotion -> time
|
||||||
|
>=
|
||||||
(timedPotion.getStartingTime() + timedPotion.getPotion().getDuration() * MinecraftServer.TICK_MS));
|
(timedPotion.getStartingTime() + timedPotion.getPotion().getDuration() * MinecraftServer.TICK_MS));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1474,7 +1475,7 @@ public abstract class Entity implements Viewable, EventHandler, DataContainer, P
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds an effect to an entity
|
* Adds an effect to an entity.
|
||||||
*
|
*
|
||||||
* @param potion The potion to add
|
* @param potion The potion to add
|
||||||
*/
|
*/
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package net.minestom.server.potion;
|
package net.minestom.server.potion;
|
||||||
|
|
||||||
import net.minestom.server.entity.Entity;
|
import net.minestom.server.entity.Entity;
|
||||||
import net.minestom.server.entity.Player;
|
|
||||||
import net.minestom.server.network.packet.server.play.EntityEffectPacket;
|
import net.minestom.server.network.packet.server.play.EntityEffectPacket;
|
||||||
import net.minestom.server.network.packet.server.play.RemoveEntityEffectPacket;
|
import net.minestom.server.network.packet.server.play.RemoveEntityEffectPacket;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@ -12,26 +11,66 @@ public class Potion {
|
|||||||
private final int duration;
|
private final int duration;
|
||||||
private final byte flags;
|
private final byte flags;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new potion.
|
||||||
|
*
|
||||||
|
* @param effect The type of potion.
|
||||||
|
* @param amplifier The strength of the potion.
|
||||||
|
* @param duration The length of the potion in ticks.
|
||||||
|
*/
|
||||||
public Potion(PotionEffect effect, byte amplifier, int duration) {
|
public Potion(PotionEffect effect, byte amplifier, int duration) {
|
||||||
this(effect, amplifier, duration, true, true, false);
|
this(effect, amplifier, duration, true, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new potion.
|
||||||
|
*
|
||||||
|
* @param effect The type of potion.
|
||||||
|
* @param amplifier The strength of the potion.
|
||||||
|
* @param duration The length of the potion in ticks.
|
||||||
|
* @param particles If the potion has particles.
|
||||||
|
*/
|
||||||
public Potion(PotionEffect effect, byte amplifier, int duration, boolean particles) {
|
public Potion(PotionEffect effect, byte amplifier, int duration, boolean particles) {
|
||||||
this(effect, amplifier, duration, particles, true, false);
|
this(effect, amplifier, duration, particles, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new potion.
|
||||||
|
*
|
||||||
|
* @param effect The type of potion.
|
||||||
|
* @param amplifier The strength of the potion.
|
||||||
|
* @param duration The length of the potion in ticks.
|
||||||
|
* @param particles If the potion has particles.
|
||||||
|
* @param icon If the potion has an icon.
|
||||||
|
*/
|
||||||
public Potion(PotionEffect effect, byte amplifier, int duration, boolean particles, boolean icon) {
|
public Potion(PotionEffect effect, byte amplifier, int duration, boolean particles, boolean icon) {
|
||||||
this(effect, amplifier, duration, particles, icon, false);
|
this(effect, amplifier, duration, particles, icon, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new potion.
|
||||||
|
*
|
||||||
|
* @param effect The type of potion.
|
||||||
|
* @param amplifier The strength of the potion.
|
||||||
|
* @param duration The length of the potion in ticks.
|
||||||
|
* @param particles If the potion has particles.
|
||||||
|
* @param icon If the potion has an icon.
|
||||||
|
* @param ambient If the potion came from a beacon.
|
||||||
|
*/
|
||||||
public Potion(PotionEffect effect, byte amplifier, int duration, boolean particles, boolean icon, boolean ambient) {
|
public Potion(PotionEffect effect, byte amplifier, int duration, boolean particles, boolean icon, boolean ambient) {
|
||||||
this.effect = effect;
|
this.effect = effect;
|
||||||
this.amplifier = amplifier;
|
this.amplifier = amplifier;
|
||||||
this.duration = duration;
|
this.duration = duration;
|
||||||
byte flags = 0;
|
byte flags = 0;
|
||||||
if (ambient) flags = (byte)(flags | 0x01);
|
if (ambient) {
|
||||||
if (particles) flags = (byte)(flags | 0x02);
|
flags = (byte) (flags | 0x01);
|
||||||
if (icon) flags = (byte)(flags | 0x04);
|
}
|
||||||
|
if (particles) {
|
||||||
|
flags = (byte) (flags | 0x02);
|
||||||
|
}
|
||||||
|
if (icon) {
|
||||||
|
flags = (byte) (flags | 0x04);
|
||||||
|
}
|
||||||
this.flags = flags;
|
this.flags = flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,6 +90,12 @@ public class Potion {
|
|||||||
return flags;
|
return flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends a packet that a potion effect has been applied to the entity.
|
||||||
|
* <p>
|
||||||
|
* Used internally by {@link net.minestom.server.entity.Player#addEffect(Potion)}
|
||||||
|
* @param entity
|
||||||
|
*/
|
||||||
public void sendAddPacket(@NotNull Entity entity) {
|
public void sendAddPacket(@NotNull Entity entity) {
|
||||||
EntityEffectPacket eep = new EntityEffectPacket();
|
EntityEffectPacket eep = new EntityEffectPacket();
|
||||||
eep.entityId = entity.getEntityId();
|
eep.entityId = entity.getEntityId();
|
||||||
@ -58,6 +103,12 @@ public class Potion {
|
|||||||
entity.sendPacketToViewersAndSelf(eep);
|
entity.sendPacketToViewersAndSelf(eep);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends a packet that a potion effect has been removed from the entity.
|
||||||
|
* <p>
|
||||||
|
* Used internally by {@link net.minestom.server.entity.Player#removeEffect(PotionEffect)}
|
||||||
|
* @param entity
|
||||||
|
*/
|
||||||
public void sendRemovePacket(@NotNull Entity entity) {
|
public void sendRemovePacket(@NotNull Entity entity) {
|
||||||
RemoveEntityEffectPacket reep = new RemoveEntityEffectPacket();
|
RemoveEntityEffectPacket reep = new RemoveEntityEffectPacket();
|
||||||
reep.entityId = entity.getEntityId();
|
reep.entityId = entity.getEntityId();
|
||||||
|
Loading…
Reference in New Issue
Block a user