Java Code Examples for org.bukkit.entity.LivingEntity#getUniqueId()

The following examples show how to use org.bukkit.entity.LivingEntity#getUniqueId() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SentinelTargetingHelper.java    From Sentinel with MIT License 6 votes vote down vote up
/**
 * Returns whether an entity is targeted by this NPC's target lists.
 * Consider calling 'shouldTarget' instead.
 */
public boolean isTargeted(LivingEntity entity) {
    if (isInvisible(entity)) {
        return false;
    }
    if (entity.getUniqueId().equals(getLivingEntity().getUniqueId())) {
        return false;
    }
    if (sentinel.getGuarding() != null && entity.getUniqueId().equals(sentinel.getGuarding())) {
        return false;
    }
    if (isUntargetable(entity)) {
        return false;
    }
    tempTarget.targetID = entity.getUniqueId();
    if (currentTargets.contains(tempTarget)) {
        return true;
    }
    return sentinel.allTargets.isTarget(entity, sentinel);
}
 
Example 2
Source File: SentinelTargetingHelper.java    From Sentinel with MIT License 6 votes vote down vote up
/**
 * Returns whether an entity is marked to be avoided by this NPC's avoid lists.
 */
public boolean isAvoided(LivingEntity entity) {
    if (isInvisible(entity)) {
        return false;
    }
    if (entity.getUniqueId().equals(getLivingEntity().getUniqueId())) {
        return false;
    }
    if (sentinel.getGuarding() != null && entity.getUniqueId().equals(sentinel.getGuarding())) {
        return false;
    }
    tempTarget.targetID = entity.getUniqueId();
    if (currentAvoids.contains(tempTarget)) {
        return true;
    }
    return sentinel.allAvoids.isTarget(entity, sentinel);
}
 
Example 3
Source File: CombatManager.java    From CombatLogX with GNU General Public License v3.0 5 votes vote down vote up
@Override
public OfflinePlayer getByEnemy(LivingEntity enemy) {
    if(enemy == null) return null;

    UUID enemyId = enemy.getUniqueId();
    for(Map.Entry<UUID, UUID> entry : uuidToEnemy.entrySet()) {
        UUID linkedEnemyId = entry.getValue();
        if(!enemyId.equals(linkedEnemyId)) continue;

        UUID playerId = entry.getKey();
        return Bukkit.getOfflinePlayer(playerId);
    }

    return null;
}
 
Example 4
Source File: SentinelManager.java    From CombatLogX with GNU General Public License v3.0 5 votes vote down vote up
private void setAttackFirst(SentinelTrait trait, LivingEntity enemy) {
    if(trait == null || enemy == null) return;
    
    UUID uuid = enemy.getUniqueId();
    String uuidString = uuid.toString();

    SentinelTargetLabel label = new SentinelTargetLabel("uuid:" + uuidString);
    label.addToList(trait.allTargets);
}
 
Example 5
Source File: SentinelTargetingHelper.java    From Sentinel with MIT License 4 votes vote down vote up
/**
 * Returns whether an entity is invisible to this NPC.
 */
public boolean isInvisible(LivingEntity entity) {
    SentinelCurrentTarget sct = new SentinelCurrentTarget();
    sct.targetID = entity.getUniqueId();
    return !currentTargets.contains(sct) && SentinelUtilities.isInvisible(entity);
}