mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-01 16:19:53 +01:00
SwordsManager cleaning
This commit is contained in:
parent
499411f6a2
commit
8fb8c67148
@ -1,56 +0,0 @@
|
||||
package com.gmail.nossr50.skills.swords;
|
||||
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.runnables.BleedTimer;
|
||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class BleedEventHandler {
|
||||
private McMMOPlayer mcMMOPlayer;
|
||||
private int skillLevel;
|
||||
private LivingEntity defender;
|
||||
protected int skillModifier;
|
||||
|
||||
protected BleedEventHandler(SwordsManager manager, LivingEntity defender) {
|
||||
this.mcMMOPlayer = manager.getMcMMOPlayer();
|
||||
this.skillLevel = manager.getSkillLevel();
|
||||
this.defender = defender;
|
||||
|
||||
calculateSkillModifier();
|
||||
}
|
||||
|
||||
protected void calculateSkillModifier() {
|
||||
this.skillModifier = SkillTools.skillCheck(skillLevel, Swords.bleedMaxBonusLevel);
|
||||
}
|
||||
|
||||
protected void addBleedTicks() {
|
||||
int bleedTicks;
|
||||
|
||||
if (skillLevel >= Swords.bleedMaxBonusLevel) {
|
||||
bleedTicks = Swords.bleedMaxTicks;
|
||||
}
|
||||
else {
|
||||
bleedTicks = Swords.bleedBaseTicks;
|
||||
}
|
||||
|
||||
BleedTimer.add(defender, bleedTicks);
|
||||
}
|
||||
|
||||
protected void sendAbilityMessages() {
|
||||
if (mcMMOPlayer.getProfile().useChatNotifications()) {
|
||||
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Swords.Combat.Bleeding"));
|
||||
}
|
||||
|
||||
if (defender instanceof Player) {
|
||||
Player defendingPlayer = (Player) defender;
|
||||
|
||||
if (Users.getPlayer(defendingPlayer).getProfile().useChatNotifications()) {
|
||||
defendingPlayer.sendMessage(LocaleLoader.getString("Swords.Combat.Bleeding.Started"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
package com.gmail.nossr50.skills.swords;
|
||||
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.utilities.CombatTools;
|
||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||
|
||||
public class CounterAttackEventHandler {
|
||||
private SwordsManager manager;
|
||||
private LivingEntity attacker;
|
||||
private int damage;
|
||||
protected int skillModifier;
|
||||
|
||||
protected CounterAttackEventHandler(SwordsManager manager, LivingEntity attacker, int damage) {
|
||||
this.manager = manager;
|
||||
this.attacker = attacker;
|
||||
this.damage = damage;
|
||||
}
|
||||
|
||||
protected void calculateSkillModifier() {
|
||||
this.skillModifier = SkillTools.skillCheck(manager.getSkillLevel(), Swords.counterAttackMaxBonusLevel);
|
||||
}
|
||||
|
||||
protected void dealDamage() {
|
||||
CombatTools.dealDamage(attacker, damage / Swords.counterAttackModifier);
|
||||
}
|
||||
|
||||
protected void sendAbilityMessages() {
|
||||
manager.getMcMMOPlayer().getPlayer().sendMessage(LocaleLoader.getString("Swords.Combat.Countered"));
|
||||
|
||||
if (attacker instanceof Player) {
|
||||
((Player) attacker).sendMessage(LocaleLoader.getString("Swords.Combat.Counter.Hit"));
|
||||
}
|
||||
}
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
package com.gmail.nossr50.skills.swords;
|
||||
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
|
||||
import com.gmail.nossr50.skills.runnables.BleedTimer;
|
||||
import com.gmail.nossr50.skills.utilities.CombatTools;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
|
||||
public class SerratedStrikesEventHandler {
|
||||
private SwordsManager manager;
|
||||
private LivingEntity target;
|
||||
private int damage;
|
||||
|
||||
protected SerratedStrikesEventHandler(SwordsManager manager, LivingEntity target, int damage) {
|
||||
this.manager = manager;
|
||||
this.target = target;
|
||||
this.damage = damage;
|
||||
}
|
||||
|
||||
protected void applyAbilityEffects() {
|
||||
CombatTools.applyAbilityAoE(manager.getMcMMOPlayer().getPlayer(), target, damage / Swords.serratedStrikesModifier, SkillType.SWORDS);
|
||||
BleedTimer.add(target, Swords.serratedStrikesBleedTicks);
|
||||
}
|
||||
}
|
@ -1,11 +1,16 @@
|
||||
package com.gmail.nossr50.skills.swords;
|
||||
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.SkillManager;
|
||||
import com.gmail.nossr50.skills.runnables.BleedTimer;
|
||||
import com.gmail.nossr50.skills.utilities.CombatTools;
|
||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class SwordsManager extends SkillManager {
|
||||
public SwordsManager(McMMOPlayer mcMMOPlayer) {
|
||||
@ -15,35 +20,48 @@ public class SwordsManager extends SkillManager {
|
||||
/**
|
||||
* Check for Bleed effect.
|
||||
*
|
||||
* @param defender The defending entity
|
||||
* @param target The defending entity
|
||||
*/
|
||||
public void bleedCheck(LivingEntity defender) {
|
||||
BleedEventHandler eventHandler = new BleedEventHandler(this, defender);
|
||||
public void bleedCheck(LivingEntity target) {
|
||||
Player player = getPlayer();
|
||||
|
||||
float chance = (float) ((Swords.bleedMaxChance / Swords.bleedMaxBonusLevel) * getSkillLevel());
|
||||
if (chance > Swords.bleedMaxChance) chance = (float) Swords.bleedMaxChance;
|
||||
if (SkillTools.activationSuccessful(player, skill, Swords.bleedMaxChance, Swords.bleedMaxBonusLevel)) {
|
||||
|
||||
if (chance > Misc.getRandom().nextInt(activationChance)) {
|
||||
eventHandler.addBleedTicks();
|
||||
eventHandler.sendAbilityMessages();
|
||||
if (getSkillLevel() >= Swords.bleedMaxBonusLevel) {
|
||||
BleedTimer.add(target, Swords.bleedMaxTicks);
|
||||
}
|
||||
else {
|
||||
BleedTimer.add(target, Swords.bleedBaseTicks);
|
||||
}
|
||||
|
||||
if (getProfile().useChatNotifications()) {
|
||||
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleeding"));
|
||||
}
|
||||
|
||||
if (target instanceof Player) {
|
||||
Player defender = (Player) target;
|
||||
|
||||
if (Users.getPlayer(defender).getProfile().useChatNotifications()) {
|
||||
defender.sendMessage(LocaleLoader.getString("Swords.Combat.Bleeding.Started"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void counterAttackChecks(LivingEntity attacker, int damage) {
|
||||
CounterAttackEventHandler eventHandler = new CounterAttackEventHandler(this, attacker, damage);
|
||||
eventHandler.calculateSkillModifier();
|
||||
if (SkillTools.activationSuccessful(getPlayer(), skill, Swords.counterAttackMaxChance, Swords.counterAttackMaxBonusLevel)) {
|
||||
CombatTools.dealDamage(attacker, damage / Swords.counterAttackModifier);
|
||||
|
||||
float chance = (float) ((Swords.counterAttackMaxChance / Swords.counterAttackMaxBonusLevel) * getSkillLevel());
|
||||
if (chance > Swords.counterAttackMaxChance) chance = (float) Swords.counterAttackMaxChance;
|
||||
getPlayer().sendMessage(LocaleLoader.getString("Swords.Combat.Countered"));
|
||||
|
||||
if (chance > Misc.getRandom().nextInt(activationChance)) {
|
||||
eventHandler.dealDamage();
|
||||
eventHandler.sendAbilityMessages();
|
||||
if (attacker instanceof Player) {
|
||||
((Player) attacker).sendMessage(LocaleLoader.getString("Swords.Combat.Counter.Hit"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void serratedStrikes(LivingEntity target, int damage) {
|
||||
SerratedStrikesEventHandler eventHandler = new SerratedStrikesEventHandler(this, target, damage);
|
||||
eventHandler.applyAbilityEffects();
|
||||
CombatTools.applyAbilityAoE(getPlayer(), target, damage / Swords.serratedStrikesModifier, skill);
|
||||
BleedTimer.add(target, Swords.serratedStrikesBleedTicks);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user