I'm creating a staff plugin, and i'm currently doing the staff items, but checking if the staff member is looking at the player when he clicks the item is holding me up. Any help would be greatly appreciated!
Are you talking about if the staff member is physically clicking on them, or looking at them from a distance?
If you are talking about physically clicking on them use a PlayerInteractEntityEvent and check what item they are holding.
@EventHandler
public void ItemUseAtPlayer (PlayerInteractEntityEvent e) {
Player clicked = (Player) e.getRightClicked();
Player p = e.getPlayer();
Utils utils = new Utils();
if (Main.getInstance().list.contains(p.getUniqueId().toString()) && p.hasPermission("staffassist.mode")) {
if (p.getItemInHand().getType().equals(Material.BOOK) && p.getItemInHand().getItemMeta().getDisplayName().contains("Inspector")) {
Inventory targetinv = Bukkit.createInventory(null, 54, "§a" + clicked.getName() + "'s Info");
ItemStack[] items = clicked.getInventory().getContents();
ItemStack[] armor = clicked.getInventory().getArmorContents();
utils.reverse(armor);
for (int i = 0; i < items.length; i++) {
targetinv.setItem(i, items[i]);
}
for (int i = 0; i <= armor.length - 1; i++)
{
if (i == 3) {
targetinv.setItem(39 + i, clicked.getItemInHand());
}
targetinv.setItem(38 + i, armor[i]);
}
