Check out example codes for "spigot kill entity". It will help you in understanding the concepts better.

Code Example 1

@EventHandler
	public void onEntitySpawn(EntitySpawnEvent event) {
		if (event.getEntityType() == EntityType.CREEPER) {
			if (event.getEntity() instanceof Damageable) {
				
				Damageable creeper = (Damageable) event.getEntity();
				creeper.damage(1000);
			}
		}
    }

Learn ReactJs, React Native from akashmittal.com