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