NicMcPhee/CraftBukkit — pull request #9 by Paul-Schliep (2014-05-01 02:25:20+00:00)
Title: Long Method - CraftEventFactory.java

handleEntityDamageEvent was a 55 line method. A good chunk of this was
due to a long elseif block from lines 423-441. Another fair chunk was
from nested if/else blocks from 396-420. The following was extracted
into the method checkMagicOrProjectile(), located at line 429:

if (damager.getBukkitEntity() instanceof ThrownPotion) {
cause = DamageCause.MAGIC;
} else if (damager.getBukkitEntity() instanceof
Projectile) {
cause = DamageCause.PROJECTILE;
}

The following was extracted into the method setCause(), located at line
439:

DamageCause cause = null;
if (source == DamageSource.FIRE) {
cause = DamageCause.FIRE;
} else if (source == DamageSource.STARVE) {
cause = DamageCause.STARVATION;
} else if (source == DamageSource.WITHER) {
cause = DamageCause.WITHER;
} else if (source == DamageSource.STUCK) {
cause = DamageCause.SUFFOCATION;
} else if (source == DamageSource.DROWN) {
cause = DamageCause.DROWNING;
} else if (source == DamageSource.BURN) {
cause = DamageCause.FIRE_TICK;
} else if (source == MELTING) {
cause = DamageCause.MELTING;
} else if (source == POISON) {
cause = DamageCause.POISON;
} else if (source == DamageSource.MAGIC) {
cause = DamageCause.MAGIC;
}

handleEntityDamageEvent() is now 32 lines.