mirror of
https://github.com/TotalFreedomMC/PlayerParticles.git
synced 2024-12-31 20:02:12 +00:00
Slightly better vanish plugin support
This commit is contained in:
parent
2a474faa88
commit
79c8f8ab2c
2 changed files with 25 additions and 6 deletions
|
@ -6,7 +6,6 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
|
@ -40,8 +39,8 @@ public class DataManager {
|
|||
* @return The PPlayer from cache
|
||||
*/
|
||||
public static PPlayer getPPlayer(UUID playerUUID) {
|
||||
List<PPlayer> pplayers = ParticleManager.getPPlayers();
|
||||
synchronized (pplayers) { // Under rare circumstances, the PPlayers list can be changed while it's looping
|
||||
List<PPlayer> pplayers;
|
||||
synchronized (pplayers = ParticleManager.getPPlayers()) { // Under rare circumstances, the PPlayers list can be changed while it's looping
|
||||
for (PPlayer pp : pplayers)
|
||||
if (pp.getUniqueId().equals(playerUUID))
|
||||
return pp;
|
||||
|
@ -64,8 +63,8 @@ public class DataManager {
|
|||
}
|
||||
|
||||
async(() -> {
|
||||
List<ParticleGroup> groups = new ArrayList<ParticleGroup>();
|
||||
List<FixedParticleEffect> fixedParticles = new ArrayList<FixedParticleEffect>();
|
||||
List<ParticleGroup> groups = new ArrayList<>();
|
||||
List<FixedParticleEffect> fixedParticles = new ArrayList<>();
|
||||
|
||||
PlayerParticles.getPlugin().getDBConnector().connect((connection) -> {
|
||||
// Load settings
|
||||
|
|
|
@ -10,6 +10,7 @@ import java.util.Map;
|
|||
import java.util.Map.Entry;
|
||||
|
||||
import com.esophose.playerparticles.util.NMSUtil;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
|
@ -21,6 +22,7 @@ import org.bukkit.material.MaterialData;
|
|||
import com.esophose.playerparticles.manager.ParticleManager;
|
||||
import com.esophose.playerparticles.manager.SettingManager.PSetting;
|
||||
import com.esophose.playerparticles.styles.api.PParticle;
|
||||
import org.bukkit.metadata.MetadataValue;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public enum ParticleEffect {
|
||||
|
@ -329,7 +331,7 @@ public enum ParticleEffect {
|
|||
|
||||
for (PPlayer pplayer : ParticleManager.getPPlayers()) {
|
||||
Player p = pplayer.getPlayer();
|
||||
if (!isFixedEffect && !p.canSee(owner))
|
||||
if (!isFixedEffect && !this.canSee(p, owner))
|
||||
continue;
|
||||
|
||||
if (p != null && pplayer.canSeeParticles() && p.getWorld().equals(center.getWorld()) && center.distanceSquared(p.getLocation()) <= range * range) {
|
||||
|
@ -340,6 +342,24 @@ public enum ParticleEffect {
|
|||
return players;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a player can see another player
|
||||
*
|
||||
* @param player The player
|
||||
* @param target The target
|
||||
* @return True if player can see target, otherwise false
|
||||
*/
|
||||
private boolean canSee(Player player, Player target) {
|
||||
if (player == null || target == null)
|
||||
return true;
|
||||
|
||||
for (MetadataValue meta : target.getMetadata("vanished"))
|
||||
if (meta.asBoolean())
|
||||
return false;
|
||||
|
||||
return player.canSee(target);
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents the property of a particle effect
|
||||
* <p>
|
||||
|
|
Loading…
Reference in a new issue