Fix some issues from the merge.

This commit is contained in:
GJ 2012-03-14 02:04:00 -04:00
parent 1470feb958
commit 0a927768f5

View File

@ -1,502 +1,475 @@
package com.gmail.nossr50; package com.gmail.nossr50;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.AnimalTamer; import org.bukkit.entity.AnimalTamer;
import org.bukkit.entity.Animals; import org.bukkit.entity.Animals;
import org.bukkit.entity.Arrow; import org.bukkit.entity.Arrow;
import org.bukkit.entity.Entity; 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.Wolf; import org.bukkit.entity.Wolf;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.config.LoadProperties; import com.gmail.nossr50.config.LoadProperties;
import com.gmail.nossr50.datatypes.PlayerProfile; import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType; import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.events.FakeEntityDamageByEntityEvent; import com.gmail.nossr50.events.FakeEntityDamageByEntityEvent;
import com.gmail.nossr50.events.FakeEntityDamageEvent; import com.gmail.nossr50.events.FakeEntityDamageEvent;
import com.gmail.nossr50.locale.mcLocale; import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.party.Party; import com.gmail.nossr50.party.Party;
import com.gmail.nossr50.skills.Acrobatics; import com.gmail.nossr50.runnables.GainXp;
import com.gmail.nossr50.skills.Archery; import com.gmail.nossr50.skills.Acrobatics;
import com.gmail.nossr50.skills.Axes; import com.gmail.nossr50.skills.Archery;
import com.gmail.nossr50.skills.Skills; import com.gmail.nossr50.skills.Axes;
import com.gmail.nossr50.skills.Swords; import com.gmail.nossr50.skills.Skills;
import com.gmail.nossr50.skills.Taming; import com.gmail.nossr50.skills.Swords;
import com.gmail.nossr50.skills.Unarmed; import com.gmail.nossr50.skills.Taming;
import com.gmail.nossr50.skills.Unarmed;
public class Combat {
public class Combat {
/**
* Apply combat modifiers and process and XP gain. /**
* * Apply combat modifiers and process and XP gain.
* @param event The event to run the combat checks on. *
* @param pluginx mcMMO plugin instance * @param event The event to run the combat checks on.
*/ * @param plugin mcMMO plugin instance
public static void combatChecks(EntityDamageByEntityEvent event, mcMMO pluginx) { */
if (event.getDamage() == 0 || event.getEntity().isDead()) { public static void combatChecks(EntityDamageByEntityEvent event, mcMMO plugin) {
return; if (event.getDamage() == 0 || event.getEntity().isDead()) {
} return;
}
Entity damager = event.getDamager();
LivingEntity target = (LivingEntity) event.getEntity(); Entity damager = event.getDamager();
int damage = event.getDamage(); LivingEntity target = (LivingEntity) event.getEntity();
EntityType damagerType = damager.getType(); int damage = event.getDamage();
EntityType targetType = target.getType(); EntityType damagerType = damager.getType();
EntityType targetType = target.getType();
switch (damagerType) {
case PLAYER: switch (damagerType) {
Player attacker = (Player) event.getDamager(); case PLAYER:
ItemStack itemInHand = attacker.getItemInHand(); Player attacker = (Player) event.getDamager();
PlayerProfile PPa = Users.getProfile(attacker); ItemStack itemInHand = attacker.getItemInHand();
PlayerProfile PPa = Users.getProfile(attacker);
combatAbilityChecks(attacker);
combatAbilityChecks(attacker);
if (ItemChecks.isSword(itemInHand) && mcPermissions.getInstance().swords(attacker)) {
if (!pluginx.misc.bleedTracker.contains(target)) { if (ItemChecks.isSword(itemInHand) && mcPermissions.getInstance().swords(attacker)) {
Swords.bleedCheck(attacker, target, pluginx); if (!plugin.misc.bleedTracker.contains(target)) {
} Swords.bleedCheck(attacker, target, plugin);
}
if (PPa.getSerratedStrikesMode()) {
applyAbilityAoE(attacker, target, damage, pluginx, SkillType.SWORDS); if (PPa.getSerratedStrikesMode()) {
} applyAbilityAoE(attacker, target, damage, plugin, SkillType.SWORDS);
}
startGainXp(attacker, PPa, target, SkillType.SWORDS, pluginx);
} startGainXp(attacker, PPa, target, SkillType.SWORDS, plugin);
else if (ItemChecks.isAxe(itemInHand) && mcPermissions.getInstance().axes(attacker)) { }
Axes.axesBonus(attacker, event); else if (ItemChecks.isAxe(itemInHand) && mcPermissions.getInstance().axes(attacker)) {
Axes.axeCriticalCheck(attacker, event); Axes.axesBonus(attacker, event);
Axes.impact(attacker, target, event); Axes.axeCriticalCheck(attacker, event);
Axes.impact(attacker, target, event);
if (PPa.getSkullSplitterMode()) {
applyAbilityAoE(attacker, target, damage, pluginx, SkillType.AXES); if (PPa.getSkullSplitterMode()) {
} applyAbilityAoE(attacker, target, damage, plugin, SkillType.AXES);
}
startGainXp(attacker, PPa, target, SkillType.AXES, pluginx);
} startGainXp(attacker, PPa, target, SkillType.AXES, plugin);
else if (itemInHand.getType().equals(Material.AIR) && mcPermissions.getInstance().unarmed(attacker)) { }
Unarmed.unarmedBonus(attacker, event); else if (itemInHand.getType().equals(Material.AIR) && mcPermissions.getInstance().unarmed(attacker)) {
Unarmed.unarmedBonus(attacker, event);
if (PPa.getBerserkMode()) {
event.setDamage(damage + (damage / 2)); if (PPa.getBerserkMode()) {
} event.setDamage(damage + (damage / 2));
}
if (targetType.equals(EntityType.PLAYER)) {
Unarmed.disarmProcCheck(attacker, (Player) target); if (targetType.equals(EntityType.PLAYER)) {
} Unarmed.disarmProcCheck(attacker, (Player) target);
}
startGainXp(attacker, PPa, target, SkillType.UNARMED, pluginx);
} startGainXp(attacker, PPa, target, SkillType.UNARMED, plugin);
else if (itemInHand.getType().equals(Material.BONE) && mcPermissions.getInstance().taming(attacker) && targetType.equals(EntityType.WOLF)) { }
Wolf wolf = (Wolf) target; else if (itemInHand.getType().equals(Material.BONE) && mcPermissions.getInstance().taming(attacker) && targetType.equals(EntityType.WOLF)) {
String message = mcLocale.getString("Combat.BeastLore") + " "; Wolf wolf = (Wolf) target;
int health = wolf.getHealth(); String message = mcLocale.getString("Combat.BeastLore") + " ";
event.setCancelled(true); int health = wolf.getHealth();
event.setCancelled(true);
if (wolf.isTamed()) {
message = message.concat(mcLocale.getString("Combat.BeastLoreOwner", new Object[] {Taming.getOwnerName(wolf)}) + " "); if (wolf.isTamed()) {
message = message.concat(mcLocale.getString("Combat.BeastLoreHealthWolfTamed", new Object[] {health})); message = message.concat(mcLocale.getString("Combat.BeastLoreOwner", new Object[] {Taming.getOwnerName(wolf)}) + " ");
} message = message.concat(mcLocale.getString("Combat.BeastLoreHealthWolfTamed", new Object[] {health}));
else { }
message = message.concat(mcLocale.getString("Combat.BeastLoreHealthWolf", new Object[] {health})); else {
} message = message.concat(mcLocale.getString("Combat.BeastLoreHealthWolf", new Object[] {health}));
}
attacker.sendMessage(message);
} attacker.sendMessage(message);
break; }
break;
case WOLF:
Wolf wolf = (Wolf) damager; case WOLF:
Wolf wolf = (Wolf) damager;
if (wolf.isTamed() && wolf.getOwner() instanceof Player) {
Player master = (Player) wolf.getOwner(); if (wolf.isTamed() && wolf.getOwner() instanceof Player) {
PlayerProfile PPo = Users.getProfile(master); Player master = (Player) wolf.getOwner();
PlayerProfile PPo = Users.getProfile(master);
if (mcPermissions.getInstance().taming(master)) {
Taming.fastFoodService(PPo, wolf, event); if (mcPermissions.getInstance().taming(master)) {
Taming.sharpenedClaws(PPo, event); Taming.fastFoodService(PPo, wolf, event);
Taming.gore(PPo, event, master, pluginx); Taming.sharpenedClaws(PPo, event);
Taming.gore(PPo, event, master, plugin);
startGainXp(master, PPo, target, SkillType.TAMING, pluginx); startGainXp(master, PPo, target, SkillType.TAMING, plugin);
} }
} }
break; break;
case ARROW: case ARROW:
archeryCheck((EntityDamageByEntityEvent)event, pluginx); archeryCheck((EntityDamageByEntityEvent) event, plugin);
break; break;
default: default:
break; break;
} }
if (targetType.equals(EntityType.PLAYER)) { if (targetType.equals(EntityType.PLAYER)) {
Swords.counterAttackChecks(event); Swords.counterAttackChecks(event);
Acrobatics.dodgeChecks(event); Acrobatics.dodgeChecks(event);
} }
} }
/** /**
* Process combat abilities based on weapon preparation modes. * Process combat abilities based on weapon preparation modes.
* *
* @param attacker The player attacking * @param attacker The player attacking
*/ */
public static void combatAbilityChecks(Player attacker) { public static void combatAbilityChecks(Player attacker) {
PlayerProfile PPa = Users.getProfile(attacker); PlayerProfile PPa = Users.getProfile(attacker);
if (PPa.getAxePreparationMode()) { if (PPa.getAxePreparationMode()) {
Skills.abilityCheck(attacker, SkillType.AXES); Skills.abilityCheck(attacker, SkillType.AXES);
} }
else if (PPa.getSwordsPreparationMode()) { else if (PPa.getSwordsPreparationMode()) {
Skills.abilityCheck(attacker, SkillType.SWORDS); Skills.abilityCheck(attacker, SkillType.SWORDS);
} }
else if (PPa.getFistsPreparationMode()) { else if (PPa.getFistsPreparationMode()) {
Skills.abilityCheck(attacker, SkillType.UNARMED); Skills.abilityCheck(attacker, SkillType.UNARMED);
} }
} }
/** /**
* Process archery abilities. * Process archery abilities.
* *
* @param event The event to run the archery checks on. * @param event The event to run the archery checks on.
* @param pluginx mcMMO plugin instance * @param pluginx mcMMO plugin instance
*/ */
public static void archeryCheck(EntityDamageByEntityEvent event, mcMMO pluginx) { public static void archeryCheck(EntityDamageByEntityEvent event, mcMMO pluginx) {
Arrow arrow = (Arrow) event.getDamager(); Arrow arrow = (Arrow) event.getDamager();
LivingEntity shooter = arrow.getShooter(); LivingEntity shooter = arrow.getShooter();
LivingEntity target = (LivingEntity) event.getEntity(); LivingEntity target = (LivingEntity) event.getEntity();
if (target instanceof Player) { if (target instanceof Player) {
Player defender = (Player) target; Player defender = (Player) target;
PlayerProfile PPd = Users.getProfile(defender); PlayerProfile PPd = Users.getProfile(defender);
boolean deflect = false; boolean deflect = false;
if (mcPermissions.getInstance().unarmed(defender) && defender.getItemInHand().getType().equals(Material.AIR)) { if (mcPermissions.getInstance().unarmed(defender) && defender.getItemInHand().getType().equals(Material.AIR)) {
if (PPd.getSkillLevel(SkillType.UNARMED) >= 1000 && (Math.random() * 1000 <= 500)) { if (PPd.getSkillLevel(SkillType.UNARMED) >= 1000 && (Math.random() * 1000 <= 500)) {
deflect = true; deflect = true;
} }
else if (Math.random() * 1000 <= (PPd.getSkillLevel(SkillType.UNARMED) / 2)) { else if (Math.random() * 1000 <= (PPd.getSkillLevel(SkillType.UNARMED) / 2)) {
deflect = true; deflect = true;
} }
if (deflect) { if (deflect) {
event.setCancelled(true); event.setCancelled(true);
defender.sendMessage(mcLocale.getString("Combat.ArrowDeflect")); defender.sendMessage(mcLocale.getString("Combat.ArrowDeflect"));
return; return;
} }
} }
} }
if (shooter instanceof Player) { if (shooter instanceof Player) {
Player attacker = (Player) shooter; Player attacker = (Player) shooter;
PlayerProfile PPa = Users.getProfile(attacker); PlayerProfile PPa = Users.getProfile(attacker);
int damage = event.getDamage(); int damage = event.getDamage();
if (mcPermissions.getInstance().archery(attacker) && damage > 0) { if (mcPermissions.getInstance().archery(attacker) && damage > 0) {
Archery.trackArrows(pluginx, target, PPa); Archery.trackArrows(pluginx, target, PPa);
Archery.ignitionCheck(target, attacker); Archery.ignitionCheck(target, attacker);
startGainXp(attacker, PPa, target, SkillType.ARCHERY, pluginx); startGainXp(attacker, PPa, target, SkillType.ARCHERY, pluginx);
if (target instanceof Player) { if (target instanceof Player) {
Player defender = (Player) target; Player defender = (Player) target;
PlayerProfile PPd = Users.getProfile(defender); PlayerProfile PPd = Users.getProfile(defender);
if (PPa.inParty() && PPd.inParty() && Party.getInstance().inSameParty(defender, attacker)) { if (PPa.inParty() && PPd.inParty() && Party.getInstance().inSameParty(defender, attacker)) {
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
Archery.dazeCheck(defender, attacker); Archery.dazeCheck(defender, attacker);
} }
} }
} }
} }
/** /**
* Attempt to damage target for value dmg with reason CUSTOM * Attempt to damage target for value dmg with reason CUSTOM
* *
* @param target LivingEntity which to attempt to damage * @param target LivingEntity which to attempt to damage
* @param dmg Amount of damage to attempt to do * @param dmg Amount of damage to attempt to do
*/ */
public static void dealDamage(LivingEntity target, int dmg) { public static void dealDamage(LivingEntity target, int dmg) {
dealDamage(target, dmg, EntityDamageEvent.DamageCause.CUSTOM); dealDamage(target, dmg, EntityDamageEvent.DamageCause.CUSTOM);
} }
/** /**
* Attempt to damage target for value dmg with reason cause * Attempt to damage target for value dmg with reason cause
* *
* @param target LivingEntity which to attempt to damage * @param target LivingEntity which to attempt to damage
* @param dmg Amount of damage to attempt to do * @param dmg Amount of damage to attempt to do
* @param cause DamageCause to pass to damage event * @param cause DamageCause to pass to damage event
*/ */
public static void dealDamage(LivingEntity target, int dmg, DamageCause cause) { private static void dealDamage(LivingEntity target, int dmg, DamageCause cause) {
if (LoadProperties.eventCallback) { if (LoadProperties.eventCallback) {
EntityDamageEvent ede = (EntityDamageEvent) new FakeEntityDamageEvent(target, cause, dmg); EntityDamageEvent ede = (EntityDamageEvent) new FakeEntityDamageEvent(target, cause, dmg);
Bukkit.getPluginManager().callEvent(ede); Bukkit.getPluginManager().callEvent(ede);
if (ede.isCancelled()) { if (ede.isCancelled()) {
return; return;
} }
target.damage(ede.getDamage()); target.damage(ede.getDamage());
} }
else { else {
target.damage(dmg); target.damage(dmg);
} }
} }
/** /**
* Attempt to damage target for value dmg with reason ENTITY_ATTACK with damager attacker * Attempt to damage target for value dmg with reason ENTITY_ATTACK with damager attacker
* *
* @param target LivingEntity which to attempt to damage * @param target LivingEntity which to attempt to damage
* @param dmg Amount of damage to attempt to do * @param dmg Amount of damage to attempt to do
* @param attacker Player to pass to event as damager * @param attacker Player to pass to event as damager
*/ */
public static void dealDamage(LivingEntity target, int dmg, Player attacker) { public static void dealDamage(LivingEntity target, int dmg, Player attacker) {
if (LoadProperties.eventCallback) { if (LoadProperties.eventCallback) {
EntityDamageEvent ede = (EntityDamageByEntityEvent) new FakeEntityDamageByEntityEvent(attacker, target, EntityDamageEvent.DamageCause.ENTITY_ATTACK, dmg); EntityDamageEvent ede = (EntityDamageByEntityEvent) new FakeEntityDamageByEntityEvent(attacker, target, EntityDamageEvent.DamageCause.ENTITY_ATTACK, dmg);
Bukkit.getPluginManager().callEvent(ede); Bukkit.getPluginManager().callEvent(ede);
if (ede.isCancelled()) { if (ede.isCancelled()) {
return; return;
} }
target.damage(ede.getDamage()); target.damage(ede.getDamage());
} }
else { else {
target.damage(dmg); target.damage(dmg);
} }
} }
/** /**
* Apply Area-of-Effect ability actions. * Apply Area-of-Effect ability actions.
* *
* @param attacker The attacking player * @param attacker The attacking player
* @param target The defending entity * @param target The defending entity
* @param damage The initial damage amount * @param damage The initial damage amount
* @param plugin mcMMO plugin instance * @param plugin mcMMO plugin instance
* @param type The type of skill being used * @param type The type of skill being used
*/ */
private static void applyAbilityAoE(Player attacker, LivingEntity target, int damage, mcMMO plugin, SkillType type) { private static void applyAbilityAoE(Player attacker, LivingEntity target, int damage, mcMMO plugin, SkillType type) {
int numberOfTargets = m.getTier(attacker.getItemInHand()); //The higher the weapon tier, the more targets you hit int numberOfTargets = m.getTier(attacker.getItemInHand()); //The higher the weapon tier, the more targets you hit
int damageAmount = 0; int damageAmount = 0;
if (type.equals(SkillType.AXES)) { if (type.equals(SkillType.AXES)) {
damageAmount = damage / 2; damageAmount = damage / 2;
} }
else if (type.equals(SkillType.SWORDS)) { else if (type.equals(SkillType.SWORDS)) {
damageAmount = damage / 4; damageAmount = damage / 4;
} }
if (damageAmount < 1) { if (damageAmount < 1) {
damageAmount = 1; damageAmount = 1;
} }
for (Entity entity : target.getNearbyEntities(2.5, 2.5, 2.5)) { for (Entity entity : target.getNearbyEntities(2.5, 2.5, 2.5)) {
EntityType entityType = entity.getType(); EntityType entityType = entity.getType();
if (entityType.equals(EntityType.WOLF)) { if (entityType.equals(EntityType.WOLF)) {
Wolf wolf = (Wolf) entity; Wolf wolf = (Wolf) entity;
AnimalTamer tamer = wolf.getOwner(); AnimalTamer tamer = wolf.getOwner();
if (tamer instanceof Player) { if (tamer instanceof Player) {
Player owner = (Player) tamer; Player owner = (Player) tamer;
//Reasons why the target shouldn't be hit if (owner.equals(attacker) || Party.getInstance().inSameParty(attacker, owner)) {
if (owner.equals(attacker)) { continue;
continue; }
} }
}
if (Party.getInstance().inSameParty(attacker, owner)) {
continue; if (entity instanceof LivingEntity && numberOfTargets >= 1) {
} if (entityType.equals(EntityType.PLAYER)) {
} Player defender = (Player) entity;
} PlayerProfile PP = Users.getProfile(defender);
if (entity instanceof LivingEntity && numberOfTargets >= 1) { //Reasons why the target shouldn't be hit
if (entityType.equals(EntityType.PLAYER)) { if (PP.getGodMode()) {
Player defender = (Player) entity; continue;
PlayerProfile PP = Users.getProfile(defender); }
//Reasons why the target shouldn't be hit if (defender.getName().equals(attacker.getName())) { //Is this even possible?
if (PP.getGodMode()) { continue;
continue; }
}
if (Party.getInstance().inSameParty(attacker, defender)) {
if (defender.getName().equals(attacker.getName())) { //Is this even possible? continue;
continue; }
}
if (defender.isDead()) {
if (Party.getInstance().inSameParty(attacker, defender)) { continue;
continue; }
}
//Apply effect to players only if PVP is enabled
if (defender.isDead()) { if (target.getWorld().getPVP()) {
continue; String message = "";
}
if (type.equals(SkillType.AXES)) {
//Apply effect to players only if PVP is enabled message = mcLocale.getString("Axes.HitByCleave");
if (target.getWorld().getPVP()) { }
String message = ""; else if (type.equals(SkillType.SWORDS)) {
message = mcLocale.getString("Swords.HitBySerratedStrikes");
if (type.equals(SkillType.AXES)) { }
message = mcLocale.getString("Axes.HitByCleave");
} dealDamage(defender, damageAmount, attacker);
else if (type.equals(SkillType.SWORDS)) { defender.sendMessage(message);
message = mcLocale.getString("Swords.HitBySerratedStrikes");
} if (type.equals(SkillType.SWORDS)) {
PP.addBleedTicks(5);
dealDamage(defender, damageAmount, attacker); }
defender.sendMessage(message);
numberOfTargets--;
if (type.equals(SkillType.SWORDS)) { }
PP.addBleedTicks(5); }
} else {
LivingEntity livingEntity = (LivingEntity) entity;
numberOfTargets--;
} if (type.equals(SkillType.SWORDS) && !plugin.misc.bleedTracker.contains(entity)) {
} plugin.misc.addToBleedQue(livingEntity);
else { }
LivingEntity livingEntity = (LivingEntity) entity;
dealDamage(livingEntity, damageAmount, attacker);
if (type.equals(SkillType.SWORDS) && !plugin.misc.bleedTracker.contains(entity)) { numberOfTargets--;
plugin.misc.addToBleedQue(livingEntity); }
} }
}
dealDamage(livingEntity, damageAmount, attacker); }
numberOfTargets--;
} /**
} * Start the task that gives combat XP.
} *
} * @param attacker The attacking player
* @param PP The player's PlayerProfile
/** * @param target The defending entity
* Start the task that gives combat XP. * @param skillType The skill being used
* * @param plugin mcMMO plugin instance
* @param attacker The attacking player */
* @param PP The player's PlayerProfile public static void startGainXp(Player attacker, PlayerProfile PP, LivingEntity target, SkillType skillType, mcMMO pluginx)
* @param target The defending entity {
* @param skillType The skill being used double baseXP = 0;
* @param plugin mcMMO plugin instance
*/ if (target instanceof Player) {
public static void startGainXp(Player attacker, PlayerProfile PP, LivingEntity target, SkillType skillType, mcMMO pluginx) if (!LoadProperties.pvpxp) {
{ return;
double baseXP = 0; }
if (target instanceof Player) { Player defender = (Player) target;
if (!LoadProperties.pvpxp) { PlayerProfile PPd = Users.getProfile(defender);
return;
} if (System.currentTimeMillis() >= (PPd.getRespawnATS() * 1000) + 5000 &&
((PPd.getLastLogin() + 5) * 1000) < System.currentTimeMillis() &&
Player defender = (Player) target; defender.getHealth() >= 1) {
PlayerProfile PPd = Users.getProfile(defender); baseXP = 20 * LoadProperties.pvpxprewardmodifier;
}
if (System.currentTimeMillis() >= (PPd.getRespawnATS() * 1000) + 5000 && }
((PPd.getLastLogin() + 5) * 1000) < System.currentTimeMillis() && else if (!pluginx.misc.mobSpawnerList.contains(target.getEntityId())) {
defender.getHealth() >= 1) { if (target instanceof Animals) {
baseXP = 20 * LoadProperties.pvpxprewardmodifier; baseXP = LoadProperties.animalXP; //I'm assuming the 10x multiplier here was accidental...
} }
} else
else if (!pluginx.misc.mobSpawnerList.contains(target.getEntityId())) { {
if (target instanceof Animals) { EntityType type = target.getType();
baseXP = 10 * LoadProperties.animalXP;
} switch (type) {
else case BLAZE:
{ baseXP = LoadProperties.blazeXP;
EntityType type = target.getType(); break;
switch (type) { case CAVE_SPIDER:
case BLAZE: baseXP = LoadProperties.cavespiderXP;
baseXP = LoadProperties.blazeXP; break;
break;
case CAVE_SPIDER: case CREEPER:
baseXP = LoadProperties.cavespiderXP; baseXP = LoadProperties.creeperXP;
break; break;
case CREEPER:
baseXP = LoadProperties.creeperXP; case ENDER_DRAGON:
break; baseXP = LoadProperties.enderdragonXP;
case ENDER_DRAGON: break;
baseXP = LoadProperties.enderdragonXP;
break; case ENDERMAN:
case ENDERMAN: baseXP = LoadProperties.endermanXP;
baseXP = LoadProperties.endermanXP; break;
break;
case GHAST: case GHAST:
baseXP = LoadProperties.ghastXP; baseXP = LoadProperties.ghastXP;
break; break;
case MAGMA_CUBE:
baseXP = LoadProperties.magmacubeXP; case MAGMA_CUBE:
break; baseXP = LoadProperties.magmacubeXP;
case PIG_ZOMBIE: break;
baseXP = LoadProperties.pigzombieXP;
break; case PIG_ZOMBIE:
case SILVERFISH: baseXP = LoadProperties.pigzombieXP;
baseXP = LoadProperties.silverfishXP; break;
break;
case SKELETON: case SILVERFISH:
baseXP = LoadProperties.skeletonXP; baseXP = LoadProperties.silverfishXP;
break; break;
case SLIME:
baseXP = LoadProperties.slimeXP; case SKELETON:
break; baseXP = LoadProperties.skeletonXP;
case SPIDER: break;
baseXP = LoadProperties.spiderXP;
break; case SLIME:
case ZOMBIE: baseXP = LoadProperties.slimeXP;
baseXP = LoadProperties.zombieXP; break;
break;
} case SPIDER:
} baseXP = LoadProperties.spiderXP;
break;
baseXP *= 10;
} case ZOMBIE:
baseXP = LoadProperties.zombieXP;
if (baseXP != 0) break;
Bukkit.getScheduler().scheduleSyncDelayedTask(pluginx, new GainXp(attacker, PP, skillType, baseXP, target), 0);
} default:
break;
} }
}
class GainXp implements Runnable
{ baseXP *= 10;
private Player player = null; }
private PlayerProfile PP = null;
private double baseXp = 0; if (baseXP != 0) {
private SkillType skillType = null; Bukkit.getScheduler().scheduleSyncDelayedTask(pluginx, new GainXp(attacker, PP, skillType, baseXP, target), 0);
private LivingEntity target = null; }
private int baseHealth = 0; }
public GainXp(Player player, PlayerProfile PP, SkillType skillType, double baseXp, LivingEntity target) }
{
this.player = player;
this.PP = PP;
this.skillType = skillType;
this.baseXp = baseXp;
this.target = target;
baseHealth = target.getHealth();
}
@Override
public void run()
{
int health = target.getHealth();
int damage = baseHealth - health;
//May avoid negative xp, we don't know what other plugins do with the entity health
if (damage <= 0)
return;
//Don't reward the player for overkills
if (health < 0)
damage += health;
PP.addXP(skillType, (int) (damage * baseXp), player);
Skills.XpCheckSkill(skillType, player);
}
}