9
0
mirror of https://github.com/HibiscusMC/HibiscusCommons.git synced 2025-12-19 15:09:26 +00:00

feat: If on paper, simply check for tracked entities rather than recalculating it

This commit is contained in:
LoJoSho
2025-01-17 13:29:18 -06:00
parent 10b32c81fa
commit 0d4a5d826e

View File

@@ -2,6 +2,7 @@ package me.lojosho.hibiscuscommons.util;
import com.comphenix.protocol.wrappers.WrappedGameProfile; import com.comphenix.protocol.wrappers.WrappedGameProfile;
import com.comphenix.protocol.wrappers.WrappedSignedProperty; import com.comphenix.protocol.wrappers.WrappedSignedProperty;
import me.lojosho.hibiscuscommons.HibiscusCommonsPlugin;
import me.lojosho.hibiscuscommons.nms.NMSHandlers; import me.lojosho.hibiscuscommons.nms.NMSHandlers;
import org.bukkit.Color; import org.bukkit.Color;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
@@ -104,6 +105,7 @@ public class ServerUtils {
*/ */
@NotNull @NotNull
public static List<Player> getViewers(@NotNull Entity entity) { public static List<Player> getViewers(@NotNull Entity entity) {
if (HibiscusCommonsPlugin.isOnPaper()) return List.copyOf(entity.getTrackedBy());
ArrayList<Player> viewers = new ArrayList<>(); ArrayList<Player> viewers = new ArrayList<>();
for (Player player : entity.getLocation().getWorld().getPlayers()) { for (Player player : entity.getLocation().getWorld().getPlayers()) {
if (player.canSee(entity)) viewers.add(player); if (player.canSee(entity)) viewers.add(player);