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

Code Example 1

player.damage(damageToDeal);

// For dealing damage to entity convert it to Damageable
if (entity instanceof Damageable) {
	((Damageable) entity).damage(damageToDeal);
}

Learn ReactJs, React Native from akashmittal.com