/** * Determines if a player can be protected. * * @param player the player to check * @return true if the player can be protected */ public boolean canProtect(Player player) { AFKSession session = sessions.getSession(AFKSession.class, player); return (session.isRequested() && canProtect(true)) || (isAfk(session.getLastUpdate()) && canProtect(false)); }
@EventHandler public void onEntityTargetPlayer(EntityTargetEvent event) { if (event.getTarget() instanceof Player) { if (canProtect((Player) event.getTarget())) { event.setCancelled(true); } } }
if (godComp != null && (canProtect(session.isRequested()) || (passedTime && canProtect(false)))) { if (!godComp.hasGodMode(target)) { godComp.enableGodMode(target);