The start of the great whitespace cleanup.

This commit is contained in:
GJ 2012-03-06 18:02:18 -05:00
parent e822515403
commit 6733eb93f2
3 changed files with 413 additions and 430 deletions

View File

@ -1,22 +1,25 @@
/* /*
This file is part of mcMMO. * Copyright (C) 2012 Matt 'The Yeti' Burnett & mcMMO Development
* Copyright (C) 2010-2011 'nossr50'
mcMMO is free software: you can redistribute it and/or modify *
it under the terms of the GNU General Public License as published by * This program is free software: you can redistribute it and/or modify
the Free Software Foundation, either version 3 of the License, or * it under the terms of the GNU General Public License as published by
(at your option) any later version. * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
mcMMO is distributed in the hope that it will be useful, *
but WITHOUT ANY WARRANTY; without even the implied warranty of * This program is distributed in the hope that it will be useful,
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * but WITHOUT ANY WARRANTY; without even the implied warranty of
GNU General Public License for more details. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
You should have received a copy of the GNU General Public License *
along with mcMMO. If not, see <http://www.gnu.org/licenses/>. * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package com.gmail.nossr50; package com.gmail.nossr50;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.*; import org.bukkit.entity.*;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent;
@ -40,134 +43,114 @@ import com.gmail.nossr50.skills.Unarmed;
public class Combat public class Combat
{ {
public static void combatChecks(EntityDamageByEntityEvent event, mcMMO pluginx) public static void combatChecks(EntityDamageByEntityEvent event, mcMMO pluginx)
{ {
if(event.getDamage() == 0 || event.getEntity().isDead()) if (event.getDamage() == 0 || event.getEntity().isDead())
return; return;
//Declare Things Entity damager = event.getDamager();
Entity damager = event.getDamager(); LivingEntity target = (LivingEntity) event.getEntity();
LivingEntity target = (LivingEntity) event.getEntity(); int damage = event.getDamage();
int damage = event.getDamage(); EntityType damagerType = damager.getType();
EntityType targetType = target.getType();
/* switch (damagerType)
* PLAYER VERSUS ENTITIES {
*/ case PLAYER:
if(damager instanceof Player) Player attacker = (Player) event.getDamager();
{ ItemStack itemInHand = attacker.getItemInHand();
Player attacker = (Player) event.getDamager(); PlayerProfile PPa = Users.getProfile(attacker);
ItemStack itemInHand = attacker.getItemInHand();
PlayerProfile PPa = Users.getProfile(attacker);
//If there are any abilities to activate combatAbilityChecks(attacker, PPa);
combatAbilityChecks(attacker, PPa);
//Damage modifiers and proc checks if (m.isSwords(itemInHand) && mcPermissions.getInstance().swords(attacker))
if(m.isSwords(itemInHand) && mcPermissions.getInstance().swords(attacker)) {
{ if (!pluginx.misc.bleedTracker.contains(target))
if(!pluginx.misc.bleedTracker.contains(target)) //Bleed Swords.bleedCheck(attacker, target, pluginx);
Swords.bleedCheck(attacker, target, pluginx);
if (PPa.getSerratedStrikesMode()) if (PPa.getSerratedStrikesMode())
Swords.applySerratedStrikes(attacker, event, pluginx); Swords.applySerratedStrikes(attacker, event, pluginx);
if(target instanceof Player) if (targetType.equals(EntityType.PLAYER))
PvPExperienceGain(attacker, PPa, (Player) target, damage, SkillType.SWORDS); PvPExperienceGain(attacker, PPa, (Player) target, damage, SkillType.SWORDS);
else if(!pluginx.misc.mobSpawnerList.contains(target.getEntityId())) else if (!pluginx.misc.mobSpawnerList.contains(target.getEntityId()))
PvEExperienceGain(attacker, PPa, target, damage, SkillType.SWORDS); PvEExperienceGain(attacker, PPa, target, damage, SkillType.SWORDS);
} }
else if(m.isAxes(itemInHand) && mcPermissions.getInstance().axes(attacker)) else if (m.isAxes(itemInHand) && mcPermissions.getInstance().axes(attacker))
{ {
Axes.axesBonus(attacker, event); Axes.axesBonus(attacker, event);
Axes.axeCriticalCheck(attacker, event, pluginx);
Axes.impact(attacker, target, event);
Axes.axeCriticalCheck(attacker, event, pluginx); //Critical hit if (PPa.getSkullSplitterMode())
Axes.applyAoeDamage(attacker, event, pluginx);
//Impact if (targetType.equals(EntityType.PLAYER))
Axes.impact(attacker, target, event); PvPExperienceGain(attacker, PPa, (Player) target, event.getDamage(), SkillType.AXES); //use getDamage because damage is modified in earlier functions
else if (!pluginx.misc.mobSpawnerList.contains(target.getEntityId()))
PvEExperienceGain(attacker, PPa, target, event.getDamage(), SkillType.AXES); //use getDamage because damage is modified in earlier functions
}
else if (itemInHand.getType().equals(Material.AIR) && mcPermissions.getInstance().unarmed(attacker))
{
Unarmed.unarmedBonus(attacker, event);
if (PPa.getSkullSplitterMode()) if (PPa.getBerserkMode())
Axes.applyAoeDamage(attacker, event, pluginx); event.setDamage(damage + (damage / 2));
if(target instanceof Player) if (targetType.equals(EntityType.PLAYER))
PvPExperienceGain(attacker, PPa, (Player) target, event.getDamage(), SkillType.AXES); {
else if(!pluginx.misc.mobSpawnerList.contains(target.getEntityId())) Unarmed.disarmProcCheck(attacker, (Player) target);
PvEExperienceGain(attacker, PPa, target, event.getDamage(), SkillType.AXES); PvPExperienceGain(attacker, PPa, (Player) target, event.getDamage(), SkillType.UNARMED); //use getDamage because damage is modified in earlier functions
} }
else if(itemInHand.getTypeId() == 0 && mcPermissions.getInstance().unarmed(attacker)) //Unarmed else if (!pluginx.misc.mobSpawnerList.contains(target.getEntityId()))
{ PvEExperienceGain(attacker, PPa, target, event.getDamage(), SkillType.UNARMED); //use getDamage because damage is modified in earlier functions
Unarmed.unarmedBonus(attacker, event); }
if(PPa.getBerserkMode()) else if (itemInHand.getType().equals(Material.BONE) && mcPermissions.getInstance().taming(attacker) && targetType.equals(EntityType.WOLF))
event.setDamage(event.getDamage() + (event.getDamage() / 2)); {
Wolf wolf = (Wolf) target;
String message = "Combat.BeastLore" + " ";
int health = wolf.getHealth();
event.setCancelled(true);
if(target instanceof Player) if (wolf.isTamed())
Unarmed.disarmProcCheck(attacker, (Player) target); //Disarm {
message.concat(mcLocale.getString("Combat.BeastLoreOwner", new Object[] {Taming.getOwnerName(wolf)}) + " ");
message.concat(mcLocale.getString("Combat.BeastLoreHealthWolfTamed", new Object[] {health}));
}
else
message.concat(mcLocale.getString("Combat.BeastLoreHealthWolf", new Object[] {health}));
if(target instanceof Player) attacker.sendMessage(message);
PvPExperienceGain(attacker, PPa, (Player) target, event.getDamage(), SkillType.UNARMED); }
else if(!pluginx.misc.mobSpawnerList.contains(target.getEntityId())) case WOLF:
PvEExperienceGain(attacker, PPa, target, event.getDamage(), SkillType.UNARMED); {
} Wolf wolf = (Wolf) damager;
//Player use bone on wolf. if (wolf.isTamed() && wolf.getOwner() instanceof Player)
else if(target instanceof Wolf) {
{ Player master = (Player) wolf.getOwner();
Wolf wolf = (Wolf) target; PlayerProfile PPo = Users.getProfile(master);
if(itemInHand.getTypeId() == 352 && mcPermissions.getInstance().taming(attacker)) if (mcPermissions.getInstance().taming(master))
{ {
event.setCancelled(true); Taming.fastFoodService(PPo, wolf, event);
if(wolf.isTamed()) Taming.sharpenedClaws(PPo, event);
attacker.sendMessage(mcLocale.getString("Combat.BeastLore")+" "+ Taming.gore(PPo, event, master, pluginx);
mcLocale.getString("Combat.BeastLoreOwner", new Object[] {Taming.getOwnerName(wolf)})+" "+ Taming.rewardXp(event, pluginx, master);
mcLocale.getString("Combat.BeastLoreHealthWolfTamed", new Object[] {wolf.getHealth()})); }
else }
attacker.sendMessage(mcLocale.getString("Combat.BeastLore")+" "+ }
mcLocale.getString("Combat.BeastLoreHealthWolf", new Object[] {wolf.getHealth()}));
}
}
}
/* case ARROW:
* TAMING (WOLVES VERSUS ENTITIES) archeryCheck((EntityDamageByEntityEvent)event, pluginx);
*/ }
else if(damager instanceof Wolf)
{
Wolf wolf = (Wolf) damager;
if (wolf.isTamed() && (wolf.getOwner() instanceof Player)) if (targetType.equals(EntityType.PLAYER))
{ {
Player master = (Player) wolf.getOwner(); Swords.counterAttackChecks(event);
PlayerProfile PPo = Users.getProfile(master); Acrobatics.dodgeChecks(event);
if(mcPermissions.getInstance().taming(master)) }
{ }
//Fast Food Service
Taming.fastFoodService(PPo, wolf, event);
//Sharpened Claws
Taming.sharpenedClaws(PPo, event);
//Gore
Taming.gore(PPo, event, master, pluginx);
//Reward XP
Taming.rewardXp(event, pluginx, master);
}
}
}
//Another offensive check for Archery
else if(damager instanceof Arrow)
archeryCheck((EntityDamageByEntityEvent)event, pluginx);
/*
* DEFENSIVE CHECKS
*/
if(target instanceof Player)
{
Swords.counterAttackChecks(event);
Acrobatics.dodgeChecks(event);
}
}
public static void combatAbilityChecks(Player attacker, PlayerProfile PPa) public static void combatAbilityChecks(Player attacker, PlayerProfile PPa)
{ {