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

The following examples show how to use org.bukkit.entity.LivingEntity#hasMetadata() . 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: ListenerResurrect.java    From CombatLogX with GNU General Public License v3.0 6 votes vote down vote up
@EventHandler(priority=EventPriority.NORMAL, ignoreCancelled=true)
public void beforeResurrect(EntityResurrectEvent e) {
    FileConfiguration config = this.expansion.getConfig("citizens-compatibility.yml");
    if(!config.getBoolean("npc-options.prevent-resurrect", true)) return;
    
    LivingEntity entity = e.getEntity();
    if(!entity.hasMetadata("NPC")) return;

    NPCRegistry npcRegistry = CitizensAPI.getNPCRegistry();
    NPC npc = npcRegistry.getNPC(entity);

    NPCManager npcManager = this.expansion.getNPCManager();
    if(npcManager.isInvalid(npc)) return;
    
    e.setCancelled(true);
}
 
Example 2
Source File: DeathManager.java    From StackMob-3 with GNU General Public License v3.0 5 votes vote down vote up
@Override
public DeathStep calculateMethod(LivingEntity dead){
    if(!dead.hasMetadata(GlobalValues.KILL_ONE)){
        for(DeathType deathType : DeathType.values()){
            DeathStep method = getMethod(deathType);
            if(method.isAllowed(dead)){
                return method;
            }
        }
    }
    return null;
}
 
Example 3
Source File: ListenerCombat.java    From CombatLogX with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler(priority=EventPriority.NORMAL, ignoreCancelled=true)
public void beforeTag(PlayerPreTagEvent e) {
    FileConfiguration config = this.expansion.getConfig("citizens-compatibility.yml");
    if(config.getBoolean("npc-tagging", false)) return;

    LivingEntity enemy = e.getEnemy();
    if(enemy == null || !enemy.hasMetadata("NPC")) return;
    
    e.setCancelled(true);
}
 
Example 4
Source File: DPlayerListener.java    From DungeonsXL with GNU General Public License v3.0 4 votes vote down vote up
public static boolean isCitizensNPC(LivingEntity entity) {
    return entity.hasMetadata("NPC");
}