Java Code Examples for org.bukkit.entity.Entity#getEntityId()

The following examples show how to use org.bukkit.entity.Entity#getEntityId() . 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: PlayerInformationModifier.java    From AACAdditionPro with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Remove the given entity from the underlying map.
 *
 * @param entity - the entity to remove.
 */
private void removeEntity(final Entity entity)
{
    final int entityID = entity.getEntityId();

    for (final Map<Integer, Boolean> maps : observerEntityMap.rowMap().values()) {
        maps.remove(entityID);
    }
}
 
Example 2
Source File: EntityHider.java    From BetonQuest with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Remove the given entity from the underlying map.
 *
 * @param entity    - the entity to remove.
 * @param destroyed - TRUE if the entity was killed, FALSE if it is merely unloading.
 */
protected void removeEntity(Entity entity, boolean destroyed) {
    int entityID = entity.getEntityId();

    List<Map.Entry<Integer, Map<Integer, Boolean>>> list = new CopyOnWriteArrayList<>(observerEntityMap.rowMap().entrySet());
    Iterator<Map.Entry<Integer, Map<Integer, Boolean>>> iterator = list.iterator();

    while (iterator.hasNext()) {
        iterator.next().getValue().remove(entityID);
    }
}
 
Example 3
Source File: Shuffle.java    From ce with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void effect(Event e, ItemStack item, final int level) {
	if(e instanceof EntityDamageByEntityEvent) {
	EntityDamageByEntityEvent event = (EntityDamageByEntityEvent) e;
	Entity target = event.getEntity();
	Player p = (Player) ((Projectile) event.getDamager()).getShooter();
	
	if(target.getEntityId() == p.getEntityId())
		return;
	
	Location pLoc = p.getLocation();
	Location tLoc = target.getLocation();
	
	target.teleport(pLoc);
	p.teleport(tLoc);
	
	EffectManager.playSound(tLoc, "ENTITY_ENDERMAN_TELEPORT", 0.4f, 2f);
	EffectManager.playSound(pLoc, "ENTITY_ENDERMAN_TELEPORT", 0.4f, 2f);

	
	for(int i = 10; i>0; i--) {
		p.getWorld().playEffect(tLoc, Effect.ENDER_SIGNAL, 10);
		p.getWorld().playEffect(pLoc, Effect.ENDER_SIGNAL, 10);
	}
	
	if(target instanceof Player) {
		p.sendMessage(ChatColor.DARK_PURPLE + "You have switched positions with " + target.getName() + "!");
		target.sendMessage(ChatColor.DARK_PURPLE + "You have switched positions with " + p.getName() + "!");
	}
	
	
	}
}
 
Example 4
Source File: LivingEntityShop.java    From Shopkeepers with GNU General Public License v3.0 4 votes vote down vote up
public static String getId(Entity entity) {
	if (entity != null) {
		return "entity" + entity.getEntityId();
	}
	return null;
}