Moved more of the Staves checks into Staves.java, rather than the

mcEntityListener.
This commit is contained in:
GJ 2012-03-21 02:58:18 -04:00
parent 2bf1563b20
commit 45974d2a19
2 changed files with 58 additions and 24 deletions

View File

@ -5,7 +5,6 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
import org.bukkit.entity.TNTPrimed; import org.bukkit.entity.TNTPrimed;
import org.bukkit.entity.Wolf; import org.bukkit.entity.Wolf;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@ -81,28 +80,7 @@ public class mcEntityListener implements Listener {
if (!m.isInvincible(livingDefender, event)) { if (!m.isInvincible(livingDefender, event)) {
Combat.combatChecks(event, plugin); Combat.combatChecks(event, plugin);
} Staves.altFireCheck(event);
if (attacker.hasMetadata("mcmmoFiredFromStaff")) {
event.setDamage(0);
Projectile projectile = (Projectile) attacker;
Player shooter = (Player) projectile.getShooter();
switch (attacker.getType()) {
case EGG:
Staves.eggEffect(livingDefender, shooter);
break;
case FIREBALL:
break;
case SNOWBALL:
break;
default:
break;
}
} }
} }
} }

View File

@ -4,11 +4,13 @@ import java.util.Collection;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Egg; import org.bukkit.entity.Egg;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Fireball; import org.bukkit.entity.Fireball;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile; import org.bukkit.entity.Projectile;
import org.bukkit.entity.Snowball; import org.bukkit.entity.Snowball;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
@ -18,6 +20,35 @@ import com.gmail.nossr50.party.Party;
public class Staves { public class Staves {
public static void altFireCheck(EntityDamageByEntityEvent event) {
LivingEntity defender = (LivingEntity) event.getEntity();
Projectile attacker = (Projectile) event.getDamager();
if (attacker.hasMetadata("mcmmoFiredFromStaff")) {
event.setDamage(0);
Projectile projectile = (Projectile) attacker;
Player shooter = (Player) projectile.getShooter();
switch (attacker.getType()) {
case EGG:
eggEffect(defender, shooter);
break;
case FIREBALL:
break;
case SNOWBALL:
if (defender.getType().equals(EntityType.PLAYER)) {
snowballEffect((Player) defender, shooter);
}
break;
default:
break;
}
}
}
/** /**
* Fire a projectile on alt-fire from a staff. * Fire a projectile on alt-fire from a staff.
@ -55,7 +86,7 @@ public class Staves {
* @param target Entity hit by the projectile * @param target Entity hit by the projectile
* @param shooter Player who fired the projectile * @param shooter Player who fired the projectile
*/ */
public static void eggEffect(LivingEntity target, Player shooter) { private static void eggEffect(LivingEntity target, Player shooter) {
final int TICKS_PER_SECOND = 20; final int TICKS_PER_SECOND = 20;
final int MAX_SLOW_DURATION_SECONDS = 240; final int MAX_SLOW_DURATION_SECONDS = 240;
final int MAX_SPEED_DURATION_SECONDS = 800; final int MAX_SPEED_DURATION_SECONDS = 800;
@ -97,6 +128,21 @@ public class Staves {
} }
} }
/**
* Handle the effects of the Bone's projectile.
*
* @param target Entity hit by the projectile
* @param shooter Player who fired the projectile
*/
private static void snowballEffect(Player target, Player shooter) {
if (Party.getInstance().inSameParty(target, shooter)) {
}
else {
}
}
private static int durationCalulate() { private static int durationCalulate() {
//TODO: Calculate duration based off time held //TODO: Calculate duration based off time held
return 80; return 80;
@ -106,4 +152,14 @@ public class Staves {
//TODO: Calculate amplifier based off skill level //TODO: Calculate amplifier based off skill level
return 10; return 10;
} }
private static int levelLossCalculate() {
//TODO: Calculate levels lost based on time held
return 2;
}
private static int levelGainCalculate() {
//TODO: Calculate levels gained based on skill level
return 1;
}
} }