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

feat: begin migrating over to the new getViewers method

This commit is contained in:
LoJoSho
2025-01-17 14:06:40 -06:00
parent 9879c82d40
commit c31d2e1aee
3 changed files with 8 additions and 6 deletions

View File

@@ -21,11 +21,11 @@ import com.hibiscusmc.hmccosmetics.user.manager.UserEmoteManager;
import com.hibiscusmc.hmccosmetics.user.manager.UserWardrobeManager;
import com.hibiscusmc.hmccosmetics.util.HMCCInventoryUtils;
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
import com.hibiscusmc.hmccosmetics.util.HMCCPlayerUtils;
import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager;
import lombok.Getter;
import me.lojosho.hibiscuscommons.hooks.Hooks;
import me.lojosho.hibiscuscommons.util.InventoryUtils;
import me.lojosho.hibiscuscommons.util.ServerUtils;
import me.lojosho.hibiscuscommons.util.packets.PacketManager;
import org.bukkit.Bukkit;
import org.bukkit.Color;
@@ -270,7 +270,7 @@ public class CosmeticUser {
}
}
if (items.isEmpty() || getEntity() == null) return;
PacketManager.equipmentSlotUpdate(getEntity().getEntityId(), items, HMCCPacketManager.getViewers(getEntity().getLocation()));
PacketManager.equipmentSlotUpdate(getEntity().getEntityId(), items, ServerUtils.getViewers(getEntity()));
MessagesUtil.sendDebugMessages("updateCosmetic (All) - end - " + items.size());
}
@@ -540,9 +540,9 @@ public class CosmeticUser {
EquipmentSlot equipmentSlot = HMCCInventoryUtils.getEquipmentSlot(slot);
if (equipmentSlot == null) return;
if (getPlayer() != null) {
PacketManager.equipmentSlotUpdate(getEntity().getEntityId(), equipmentSlot, getPlayer().getInventory().getItem(equipmentSlot), HMCCPacketManager.getViewers(getEntity().getLocation()));
PacketManager.equipmentSlotUpdate(getEntity().getEntityId(), equipmentSlot, getPlayer().getInventory().getItem(equipmentSlot), ServerUtils.getViewers(getEntity()));
} else {
HMCCPacketManager.equipmentSlotUpdate(getEntity().getEntityId(), this, slot, HMCCPacketManager.getViewers(getEntity().getLocation()));
HMCCPacketManager.equipmentSlotUpdate(getEntity().getEntityId(), this, slot, ServerUtils.getViewers(getEntity()));
}
}
@@ -651,7 +651,7 @@ public class CosmeticUser {
if (!isBalloonSpawned()) respawnBalloon();
CosmeticBalloonType balloonType = (CosmeticBalloonType) getCosmetic(CosmeticSlot.BALLOON);
getBalloonManager().addPlayerToModel(this, balloonType);
List<Player> viewer = HMCCPacketManager.getViewers(getEntity().getLocation());
List<Player> viewer = ServerUtils.getViewers(getEntity());
HMCCPacketManager.sendLeashPacket(getBalloonManager().getPufferfishBalloonId(), getPlayer().getEntityId(), viewer);
}
if (hasCosmeticInSlot(CosmeticSlot.BACKPACK)) {

View File

@@ -8,6 +8,7 @@ import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager;
import lombok.Getter;
import lombok.Setter;
import me.lojosho.hibiscuscommons.util.ServerUtils;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Player;
@@ -43,12 +44,12 @@ public class UserEntity {
if (System.currentTimeMillis() - viewerLastUpdate <= 1000) return List.of(); //Prevents mass refreshes
ArrayList<Player> newPlayers = new ArrayList<>();
ArrayList<Player> removePlayers = new ArrayList<>();
List<Player> players = HMCCPacketManager.getViewers(location);
Player ownerPlayer = Bukkit.getPlayer(owner);
if (ownerPlayer == null) {
MessagesUtil.sendDebugMessages("Owner is null (refreshViewers), returning empty list");
return List.of();
}
List<Player> players = ServerUtils.getViewers(ownerPlayer);
for (Player player : players) {
CosmeticUser user = CosmeticUsers.getUser(player);

View File

@@ -18,6 +18,7 @@ import com.hibiscusmc.hmccosmetics.util.packets.wrappers.WrapperPlayServerRelEnt
import me.lojosho.hibiscuscommons.util.packets.PacketManager;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.inventory.EquipmentSlot;