mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-12-28 03:27:39 +01:00
Cleanup
This commit is contained in:
parent
f7ee96aa99
commit
7ef72c501e
@ -92,7 +92,7 @@ public class EntityListener implements Listener {
|
|||||||
LivingEntity livingDefender = (LivingEntity)defender;
|
LivingEntity livingDefender = (LivingEntity)defender;
|
||||||
|
|
||||||
if (!Misc.isInvincible(livingDefender, event)) {
|
if (!Misc.isInvincible(livingDefender, event)) {
|
||||||
Combat.combatChecks(event, plugin);
|
Combat.combatChecks(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,6 @@ import org.bukkit.entity.EntityType;
|
|||||||
import org.bukkit.entity.IronGolem;
|
import org.bukkit.entity.IronGolem;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.entity.Projectile;
|
|
||||||
import org.bukkit.entity.Tameable;
|
import org.bukkit.entity.Tameable;
|
||||||
import org.bukkit.entity.Wolf;
|
import org.bukkit.entity.Wolf;
|
||||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||||
@ -47,7 +46,7 @@ public class Combat {
|
|||||||
* @param event The event to run the combat checks on.
|
* @param event The event to run the combat checks on.
|
||||||
* @param plugin mcMMO plugin instance
|
* @param plugin mcMMO plugin instance
|
||||||
*/
|
*/
|
||||||
public static void combatChecks(EntityDamageByEntityEvent event, mcMMO plugin) {
|
public static void combatChecks(EntityDamageByEntityEvent event) {
|
||||||
if (event.getDamage() == 0 || event.getEntity().isDead()) {
|
if (event.getDamage() == 0 || event.getEntity().isDead()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -83,11 +82,11 @@ public class Combat {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (PPa.getAbilityMode(AbilityType.SERRATED_STRIKES) && permInstance.serratedStrikes(attacker)) {
|
if (PPa.getAbilityMode(AbilityType.SERRATED_STRIKES) && permInstance.serratedStrikes(attacker)) {
|
||||||
applyAbilityAoE(attacker, target, event.getDamage() / 4, plugin, SkillType.SWORDS);
|
applyAbilityAoE(attacker, target, event.getDamage() / 4, SkillType.SWORDS);
|
||||||
BleedTimer.add(target, 5);
|
BleedTimer.add(target, 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
startGainXp(attacker, PPa, target, SkillType.SWORDS, plugin);
|
startGainXp(attacker, PPa, target, SkillType.SWORDS);
|
||||||
}
|
}
|
||||||
else if (ItemChecks.isAxe(itemInHand) && permInstance.axes(attacker)) {
|
else if (ItemChecks.isAxe(itemInHand) && permInstance.axes(attacker)) {
|
||||||
if (!configInstance.getAxesPVP()) {
|
if (!configInstance.getAxesPVP()) {
|
||||||
@ -115,10 +114,10 @@ public class Combat {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (PPa.getAbilityMode(AbilityType.SKULL_SPLIITER) && permInstance.skullSplitter(attacker)) {
|
if (PPa.getAbilityMode(AbilityType.SKULL_SPLIITER) && permInstance.skullSplitter(attacker)) {
|
||||||
applyAbilityAoE(attacker, target, event.getDamage() / 2, plugin, SkillType.AXES);
|
applyAbilityAoE(attacker, target, event.getDamage() / 2, SkillType.AXES);
|
||||||
}
|
}
|
||||||
|
|
||||||
startGainXp(attacker, PPa, target, SkillType.AXES, plugin);
|
startGainXp(attacker, PPa, target, SkillType.AXES);
|
||||||
}
|
}
|
||||||
else if (itemInHand.getType().equals(Material.AIR) && permInstance.unarmed(attacker)) {
|
else if (itemInHand.getType().equals(Material.AIR) && permInstance.unarmed(attacker)) {
|
||||||
if (!configInstance.getUnarmedPVP()) {
|
if (!configInstance.getUnarmedPVP()) {
|
||||||
@ -145,7 +144,7 @@ public class Combat {
|
|||||||
Unarmed.disarmProcCheck(attacker, (Player) target);
|
Unarmed.disarmProcCheck(attacker, (Player) target);
|
||||||
}
|
}
|
||||||
|
|
||||||
startGainXp(attacker, PPa, target, SkillType.UNARMED, plugin);
|
startGainXp(attacker, PPa, target, SkillType.UNARMED);
|
||||||
}
|
}
|
||||||
else if (itemInHand.getType().equals(Material.BONE) && permInstance.beastLore(attacker)) {
|
else if (itemInHand.getType().equals(Material.BONE) && permInstance.beastLore(attacker)) {
|
||||||
Taming.beastLore(event, target, attacker);
|
Taming.beastLore(event, target, attacker);
|
||||||
@ -183,12 +182,14 @@ public class Combat {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (permInstance.taming(master)) {
|
if (permInstance.taming(master)) {
|
||||||
startGainXp(master, PPo, target, SkillType.TAMING, plugin);
|
startGainXp(master, PPo, target, SkillType.TAMING);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (damager instanceof Arrow) {
|
else if (damager instanceof Arrow) {
|
||||||
if (((Arrow) damager).getShooter().getType() != EntityType.PLAYER) {
|
LivingEntity shooter = ((Arrow) damager).getShooter();
|
||||||
|
|
||||||
|
if (shooter.getType() != EntityType.PLAYER) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -201,7 +202,7 @@ public class Combat {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
archeryCheck(event, plugin);
|
archeryCheck((Player) shooter, target, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (target instanceof Player) {
|
if (target instanceof Player) {
|
||||||
@ -245,14 +246,11 @@ public class Combat {
|
|||||||
/**
|
/**
|
||||||
* Process archery abilities.
|
* Process archery abilities.
|
||||||
*
|
*
|
||||||
|
* @param shooter The player shooting
|
||||||
|
* @param target The defending entity
|
||||||
* @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
|
|
||||||
*/
|
*/
|
||||||
public static void archeryCheck(EntityDamageByEntityEvent event, mcMMO pluginx) {
|
public static void archeryCheck(Player shooter, LivingEntity target, EntityDamageByEntityEvent event) {
|
||||||
Projectile arrow = (Projectile) event.getDamager();
|
|
||||||
LivingEntity shooter = arrow.getShooter();
|
|
||||||
LivingEntity target = (LivingEntity) event.getEntity();
|
|
||||||
|
|
||||||
if (target instanceof Player) {
|
if (target instanceof Player) {
|
||||||
Player defender = (Player) target;
|
Player defender = (Player) target;
|
||||||
|
|
||||||
@ -263,14 +261,10 @@ public class Combat {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shooter instanceof Player) {
|
if (permInstance.archery(shooter)) {
|
||||||
Player attacker = (Player) shooter;
|
if (permInstance.archeryBonus(shooter)) {
|
||||||
PlayerProfile PPa = Users.getProfile(attacker);
|
|
||||||
|
|
||||||
if (permInstance.archery(attacker)) {
|
|
||||||
if (permInstance.archeryBonus(attacker)) {
|
|
||||||
/*Archery needs a damage bonus to be viable in PVP*/
|
/*Archery needs a damage bonus to be viable in PVP*/
|
||||||
int skillLvl = Users.getProfile(attacker).getSkillLevel(SkillType.ARCHERY);
|
int skillLvl = Users.getProfile(shooter).getSkillLevel(SkillType.ARCHERY);
|
||||||
double dmgBonusPercent = ((skillLvl / 50) * 0.1D);
|
double dmgBonusPercent = ((skillLvl / 50) * 0.1D);
|
||||||
|
|
||||||
/* Cap maximum bonus at 200% */
|
/* Cap maximum bonus at 200% */
|
||||||
@ -286,17 +280,18 @@ public class Combat {
|
|||||||
event.setDamage(damage + archeryBonus);
|
event.setDamage(damage + archeryBonus);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (target instanceof Player && permInstance.daze(attacker)) {
|
if (target instanceof Player && permInstance.daze(shooter)) {
|
||||||
Archery.dazeCheck((Player) target, attacker, event);
|
Archery.dazeCheck((Player) target, shooter, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (permInstance.trackArrows(attacker)) {
|
PlayerProfile PP = Users.getProfile(shooter);
|
||||||
Archery.trackArrows(target, PPa);
|
|
||||||
|
if (permInstance.trackArrows(shooter)) {
|
||||||
|
Archery.trackArrows(target, PP);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (target != attacker) {
|
if (target != shooter) {
|
||||||
startGainXp(attacker, PPa, target, SkillType.ARCHERY, pluginx);
|
startGainXp(shooter, PP, target, SkillType.ARCHERY);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -363,10 +358,9 @@ public class Combat {
|
|||||||
* @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 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, SkillType type) {
|
||||||
ItemStack inHand = attacker.getItemInHand();
|
ItemStack inHand = attacker.getItemInHand();
|
||||||
|
|
||||||
if (ModChecks.isCustomTool(inHand) && !ModChecks.getToolFromItemStack(inHand).isAbilityEnabled()) {
|
if (ModChecks.isCustomTool(inHand) && !ModChecks.getToolFromItemStack(inHand).isAbilityEnabled()) {
|
||||||
@ -390,7 +384,7 @@ public class Combat {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PlayerAnimationEvent armswing = new PlayerAnimationEvent(attacker);
|
PlayerAnimationEvent armswing = new PlayerAnimationEvent(attacker);
|
||||||
plugin.getServer().getPluginManager().callEvent(armswing);
|
mcMMO.p.getServer().getPluginManager().callEvent(armswing);
|
||||||
|
|
||||||
if (entity instanceof Player) {
|
if (entity instanceof Player) {
|
||||||
Player defender = (Player) entity;
|
Player defender = (Player) entity;
|
||||||
@ -458,7 +452,7 @@ public class Combat {
|
|||||||
* @param skillType The skill being used
|
* @param skillType The skill being used
|
||||||
* @param plugin mcMMO plugin instance
|
* @param plugin mcMMO plugin instance
|
||||||
*/
|
*/
|
||||||
public static void startGainXp(Player attacker, PlayerProfile PP, LivingEntity target, SkillType skillType, mcMMO pluginx) {
|
public static void startGainXp(Player attacker, PlayerProfile PP, LivingEntity target, SkillType skillType) {
|
||||||
double baseXP = 0;
|
double baseXP = 0;
|
||||||
|
|
||||||
if (target instanceof Player) {
|
if (target instanceof Player) {
|
||||||
@ -549,7 +543,7 @@ public class Combat {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (baseXP != 0) {
|
if (baseXP != 0) {
|
||||||
mcMMO.p.getServer().getScheduler().scheduleSyncDelayedTask(pluginx, new GainXp(attacker, PP, skillType, baseXP, target), 0);
|
mcMMO.p.getServer().getScheduler().scheduleSyncDelayedTask(mcMMO.p, new GainXp(attacker, PP, skillType, baseXP, target), 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user