Only send particles to players who should be seeing them
This commit is contained in:
parent
f48d2166b4
commit
5864918442
|
|
@ -1,10 +1,13 @@
|
||||||
package com.alttd.objects;
|
package com.alttd.objects;
|
||||||
|
|
||||||
|
import com.alttd.storage.PlayerSettings;
|
||||||
import com.destroystokyo.paper.ParticleBuilder;
|
import com.destroystokyo.paper.ParticleBuilder;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class Frame {
|
public class Frame {
|
||||||
List<ParticleBuilder> particles;
|
List<ParticleBuilder> particles;
|
||||||
|
|
@ -19,6 +22,16 @@ public class Frame {
|
||||||
* @param location Location to spawn particles at
|
* @param location Location to spawn particles at
|
||||||
*/
|
*/
|
||||||
public void spawn(Location location) {
|
public void spawn(Location location) {
|
||||||
particles.forEach(particleBuilder -> particleBuilder.location(location).spawn());
|
particles.forEach(particleBuilder -> particleBuilder
|
||||||
|
.location(location)
|
||||||
|
.receivers(Bukkit.getOnlinePlayers().stream()
|
||||||
|
.filter(player -> {
|
||||||
|
PlayerSettings playerSettings = PlayerSettings.getPlayer(player.getUniqueId());
|
||||||
|
if (playerSettings == null)
|
||||||
|
return false;
|
||||||
|
return playerSettings.isSeeingParticles();
|
||||||
|
}).collect(Collectors.toList())
|
||||||
|
)
|
||||||
|
.spawn());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user