I have this code:
@EventHandler
public void onItemSwap(PlayerItemHeldEvent event) {
Player player = event.getPlayer();
if (isActivated.contains(player.getUniqueId())) {
player.sendMessage("activated: " + player);
for(Player onlinePlayer : Bukkit.getOnlinePlayers()) {
if (onlinePlayer == player) continue;
onlinePlayer.sendEquipmentChange(player, EquipmentSlot.HAND, new ItemStack(Material.AIR));
}
} else {
player.sendMessage("deactivated");
for(Player onlinePlayer : Bukkit.getOnlinePlayers()) {
if (onlinePlayer == player) continue;
onlinePlayer.sendEquipmentChange(player, EquipmentSlot.HAND, new ItemStack(Material.AIR));
}
}
}
And it's supposed to make the item invisible on item swap if it is activate. But for some reason, it does activate, it does send the "activated", it does get the players, but it doesn't send the equipment change packet... Does anyone know why?