mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 13:16:45 +01:00
Cleanup
This commit is contained in:
parent
73902d5f92
commit
f66c6ab8fc
@ -7,9 +7,7 @@ import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Tameable;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
@ -30,9 +28,8 @@ public class Swords {
|
||||
*
|
||||
* @param attacker The attacking player
|
||||
* @param entity The defending entity
|
||||
* @param plugin mcMMO plugin instance
|
||||
*/
|
||||
public static void bleedCheck(Player attacker, LivingEntity entity, mcMMO plugin) {
|
||||
public static void bleedCheck(Player attacker, LivingEntity entity) {
|
||||
|
||||
if (entity instanceof Tameable) {
|
||||
Tameable pet = (Tameable) entity;
|
||||
@ -76,33 +73,26 @@ public class Swords {
|
||||
*
|
||||
* @param event The event to modify
|
||||
*/
|
||||
public static void counterAttackChecks(EntityDamageByEntityEvent event) {
|
||||
Entity attacker = event.getDamager();
|
||||
|
||||
public static void counterAttackChecks(Entity attacker, Player defender, int damage) {
|
||||
if (!(attacker instanceof LivingEntity)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Entity target = event.getEntity();
|
||||
PlayerProfile PPd = Users.getProfile(defender);
|
||||
|
||||
if (target instanceof Player) {
|
||||
Player defender = (Player) target;
|
||||
PlayerProfile PPd = Users.getProfile(defender);
|
||||
if (ItemChecks.isSword(defender.getItemInHand()) && Permissions.getInstance().counterAttack(defender)) {
|
||||
final int MAX_BONUS_LEVEL = 600;
|
||||
final int COUNTER_ATTACK_MODIFIER = 2;
|
||||
|
||||
if (ItemChecks.isSword(defender.getItemInHand()) && Permissions.getInstance().counterAttack(defender)) {
|
||||
final int MAX_BONUS_LEVEL = 600;
|
||||
final int COUNTER_ATTACK_MODIFIER = 2;
|
||||
int skillLevel = PPd.getSkillLevel(SkillType.SWORDS);
|
||||
int skillCheck = Misc.skillCheck(skillLevel, MAX_BONUS_LEVEL);
|
||||
|
||||
int skillLevel = PPd.getSkillLevel(SkillType.SWORDS);
|
||||
int skillCheck = Misc.skillCheck(skillLevel, MAX_BONUS_LEVEL);
|
||||
if (random.nextInt(2000) <= skillCheck) {
|
||||
Combat.dealDamage((LivingEntity) attacker, damage / COUNTER_ATTACK_MODIFIER);
|
||||
defender.sendMessage(LocaleLoader.getString("Swords.Combat.Countered"));
|
||||
|
||||
if (random.nextInt(2000) <= skillCheck) {
|
||||
Combat.dealDamage((LivingEntity) attacker, event.getDamage() / COUNTER_ATTACK_MODIFIER);
|
||||
defender.sendMessage(LocaleLoader.getString("Swords.Combat.Countered"));
|
||||
|
||||
if (attacker instanceof Player) {
|
||||
((Player) attacker).sendMessage(LocaleLoader.getString("Swords.Combat.Counter.Hit"));
|
||||
}
|
||||
if (attacker instanceof Player) {
|
||||
((Player) attacker).sendMessage(LocaleLoader.getString("Swords.Combat.Counter.Hit"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ public class Combat {
|
||||
}
|
||||
|
||||
if (permInstance.swordsBleed(attacker)) {
|
||||
Swords.bleedCheck(attacker, target, plugin);
|
||||
Swords.bleedCheck(attacker, target);
|
||||
}
|
||||
|
||||
if (PPa.getAbilityMode(AbilityType.SERRATED_STRIKES) && permInstance.serratedStrikes(attacker)) {
|
||||
@ -183,7 +183,8 @@ public class Combat {
|
||||
startGainXp(master, PPo, target, SkillType.TAMING, plugin);
|
||||
}
|
||||
}
|
||||
} else if (damager instanceof Projectile) {
|
||||
}
|
||||
else if (damager instanceof Projectile) {
|
||||
if (!configInstance.getArcheryPVP() && ((Projectile) damager).getShooter().getType().equals(EntityType.PLAYER)) {
|
||||
if (targetIsPlayer || targetIsTamedPet) {
|
||||
return;
|
||||
@ -201,11 +202,11 @@ public class Combat {
|
||||
|
||||
if (target instanceof Player) {
|
||||
if (configInstance.getSwordsPVP() && damager instanceof Player) {
|
||||
Swords.counterAttackChecks(event);
|
||||
Swords.counterAttackChecks(damager, (Player) target, event.getDamage());
|
||||
}
|
||||
|
||||
if (configInstance.getSwordsPVE() && !(damager instanceof Player)) {
|
||||
Swords.counterAttackChecks(event);
|
||||
Swords.counterAttackChecks(damager, (Player) target, event.getDamage());
|
||||
}
|
||||
|
||||
if (configInstance.getAcrobaticsPVP() && damager instanceof Player) {
|
||||
|
Loading…
Reference in New Issue
Block a user