Refactor vanish handling by moving logic to FrameSpawnerPlayer and improving debug logging
This commit is contained in:
parent
e2ab17fb20
commit
26cb4474c4
|
|
@ -8,7 +8,9 @@ import com.alttd.objects.ParticleSet;
|
||||||
import com.alttd.storage.PlayerSettings;
|
import com.alttd.storage.PlayerSettings;
|
||||||
import com.alttd.util.Logger;
|
import com.alttd.util.Logger;
|
||||||
import com.destroystokyo.paper.ParticleBuilder;
|
import com.destroystokyo.paper.ParticleBuilder;
|
||||||
|
import de.myzelyam.api.vanish.VanishAPI;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Particle;
|
import org.bukkit.Particle;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
@ -49,6 +51,10 @@ public class FrameSpawnerPlayer extends BukkitRunnable {
|
||||||
log.info("Stopped repeating task due to player offline.");
|
log.info("Stopped repeating task due to player offline.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (isVanished(player)) {
|
||||||
|
log.debug("Player {} is vanished, skipping frame spawn.", player.getName());
|
||||||
|
return;
|
||||||
|
}
|
||||||
Location location = player.getLocation();
|
Location location = player.getLocation();
|
||||||
float yaw = location.getYaw();
|
float yaw = location.getYaw();
|
||||||
ParticleSet activeParticleSet = playerSettings.getParticles(aPartType);
|
ParticleSet activeParticleSet = playerSettings.getParticles(aPartType);
|
||||||
|
|
@ -81,4 +87,8 @@ public class FrameSpawnerPlayer extends BukkitRunnable {
|
||||||
if (amount != -1)
|
if (amount != -1)
|
||||||
amount--;
|
amount--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isVanished(Player player) {
|
||||||
|
return VanishAPI.isInvisible(player) || player.getGameMode().equals(GameMode.SPECTATOR);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ import com.alttd.storage.PlayerSettings;
|
||||||
import com.alttd.util.Logger;
|
import com.alttd.util.Logger;
|
||||||
import de.myzelyam.api.vanish.VanishAPI;
|
import de.myzelyam.api.vanish.VanishAPI;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
|
@ -19,6 +20,7 @@ import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
public class ParticleSet {
|
public class ParticleSet {
|
||||||
|
|
||||||
private final List<Frame> frames;
|
private final List<Frame> frames;
|
||||||
|
|
@ -53,7 +55,7 @@ public class ParticleSet {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run(Location location, Player player) {
|
public void run(Location location, Player player) {
|
||||||
if (tooSoon(player.getUniqueId()) || isVanished(player))
|
if (tooSoon(player.getUniqueId()))
|
||||||
return;
|
return;
|
||||||
FrameSpawnerLocation frameSpawnerLocation = new FrameSpawnerLocation(repeat, frames, frameDelay, location, player.getLocation().getYaw());
|
FrameSpawnerLocation frameSpawnerLocation = new FrameSpawnerLocation(repeat, frames, frameDelay, location, player.getLocation().getYaw());
|
||||||
frameSpawnerLocation.runTaskTimerAsynchronously(AltitudeParticles.getInstance(), 0, repeatDelay);
|
frameSpawnerLocation.runTaskTimerAsynchronously(AltitudeParticles.getInstance(), 0, repeatDelay);
|
||||||
|
|
@ -68,10 +70,6 @@ public class ParticleSet {
|
||||||
frameSpawnerPlayer.runTaskTimerAsynchronously(AltitudeParticles.getInstance(), 0, repeatDelay);
|
frameSpawnerPlayer.runTaskTimerAsynchronously(AltitudeParticles.getInstance(), 0, repeatDelay);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isVanished(Player player) {
|
|
||||||
return VanishAPI.isInvisible(player) || player.getGameMode().equals(GameMode.SPECTATOR);
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean tooSoon(UUID uuid) {
|
private boolean tooSoon(UUID uuid) {
|
||||||
PlayerSettings ps = PlayerSettings.getPlayer(uuid);
|
PlayerSettings ps = PlayerSettings.getPlayer(uuid);
|
||||||
if (ps.canRun(aPartType))
|
if (ps.canRun(aPartType))
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user