mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 21:26:46 +01:00
Improved attacker and defender's party check
This commit is contained in:
parent
946ea19371
commit
9b3838b912
@ -1,11 +1,14 @@
|
|||||||
package com.gmail.nossr50.listeners;
|
package com.gmail.nossr50.listeners;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.AnimalTamer;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
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.TNTPrimed;
|
import org.bukkit.entity.TNTPrimed;
|
||||||
|
import org.bukkit.entity.Tameable;
|
||||||
import org.bukkit.entity.Wolf;
|
import org.bukkit.entity.Wolf;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
@ -58,14 +61,22 @@ public class EntityListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Entity defender = event.getEntity();
|
|
||||||
Entity attacker = event.getDamager();
|
Entity attacker = event.getDamager();
|
||||||
|
|
||||||
if (attacker instanceof Player && defender instanceof Player) {
|
if (attacker instanceof Projectile) {
|
||||||
if (!defender.getWorld().getPVP()) {
|
attacker = ((Projectile) attacker).getShooter();
|
||||||
return;
|
}
|
||||||
|
else if (attacker instanceof Tameable) {
|
||||||
|
AnimalTamer animalTamer = ((Tameable) attacker).getOwner();
|
||||||
|
|
||||||
|
if (animalTamer instanceof Player) {
|
||||||
|
attacker = (Player) animalTamer;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Entity defender = event.getEntity();
|
||||||
|
|
||||||
|
if (attacker instanceof Player && defender instanceof Player) {
|
||||||
if (Party.getInstance().inSameParty((Player)defender, (Player)attacker)) {
|
if (Party.getInstance().inSameParty((Player)defender, (Player)attacker)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
|
@ -268,9 +268,7 @@ public class Combat {
|
|||||||
int damage = event.getDamage();
|
int damage = event.getDamage();
|
||||||
|
|
||||||
if (permInstance.archery(attacker) && damage > 0) {
|
if (permInstance.archery(attacker) && damage > 0) {
|
||||||
|
|
||||||
if (permInstance.archeryBonus(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(attacker).getSkillLevel(SkillType.ARCHERY);
|
||||||
double dmgBonusPercent = ((skillLvl / 50) * 0.1D);
|
double dmgBonusPercent = ((skillLvl / 50) * 0.1D);
|
||||||
@ -293,16 +291,8 @@ public class Combat {
|
|||||||
startGainXp(attacker, PPa, target, SkillType.ARCHERY, pluginx);
|
startGainXp(attacker, PPa, target, SkillType.ARCHERY, pluginx);
|
||||||
|
|
||||||
if (target instanceof Player) {
|
if (target instanceof Player) {
|
||||||
Player defender = (Player) target;
|
|
||||||
PlayerProfile PPd = Users.getProfile(defender);
|
|
||||||
|
|
||||||
if (PPa.inParty() && PPd.inParty() && Party.getInstance().inSameParty(defender, attacker)) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (permInstance.daze(attacker)) {
|
if (permInstance.daze(attacker)) {
|
||||||
Archery.dazeCheck(defender, attacker);
|
Archery.dazeCheck((Player) target, attacker);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user