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

clean: add nms methods in packet manager

This commit is contained in:
LoJoSho
2023-12-23 12:18:11 -06:00
parent c1c40c1556
commit 814419d2a1

View File

@@ -4,14 +4,18 @@ import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.ProtocolLibrary; import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.events.PacketContainer; import com.comphenix.protocol.events.PacketContainer;
import it.unimi.dsi.fastutil.ints.IntArrayList; import it.unimi.dsi.fastutil.ints.IntArrayList;
import me.lojosho.hibiscuscommons.nms.NMSHandlers;
import me.lojosho.hibiscuscommons.util.MessagesUtil; import me.lojosho.hibiscuscommons.util.MessagesUtil;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
@@ -215,6 +219,30 @@ public class PacketManager {
return viewers; return viewers;
} }
public void slotUpdate(
Player player,
int slot
) {
NMSHandlers.getHandler().slotUpdate(player, slot);
}
public void equipmentSlotUpdate(
int entityId,
org.bukkit.inventory.EquipmentSlot slot,
ItemStack item,
List<Player> sendTo
) {
NMSHandlers.getHandler().equipmentSlotUpdate(entityId, slot, item, sendTo);
}
public void equipmentSlotUpdate(
int entityId,
HashMap<EquipmentSlot, ItemStack> equipment,
List<Player> sendTo
) {
NMSHandlers.getHandler().equipmentSlotUpdate(entityId, equipment, sendTo);
}
private static List<Player> getNearbyPlayers(Location location, int distance) { private static List<Player> getNearbyPlayers(Location location, int distance) {
List<Player> players = new ArrayList<>(); List<Player> players = new ArrayList<>();
for (Entity entity : location.getWorld().getNearbyEntities(location, distance, distance, distance)) { for (Entity entity : location.getWorld().getNearbyEntities(location, distance, distance, distance)) {