mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-24 14:16:45 +01:00
Fixing dealDamage and allowPvp in Combat
This commit is contained in:
parent
20248212ae
commit
152b512ea3
@ -361,7 +361,7 @@ public class Combat
|
|||||||
* @param dmg Amount of damage to attempt to do
|
* @param dmg Amount of damage to attempt to do
|
||||||
*/
|
*/
|
||||||
public static void dealDamage(LivingEntity target, int dmg){
|
public static void dealDamage(LivingEntity target, int dmg){
|
||||||
dealDamage(target, dmg, EntityDamageEvent.DamageCause.CUSTOM);
|
dealDamage(target, dmg, EntityDamageEvent.DamageCause.CUSTOM, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -372,11 +372,7 @@ public class Combat
|
|||||||
* @param cause DamageCause to pass to damage event
|
* @param cause DamageCause to pass to damage event
|
||||||
*/
|
*/
|
||||||
public static void dealDamage(LivingEntity target, int dmg, DamageCause cause) {
|
public static void dealDamage(LivingEntity target, int dmg, DamageCause cause) {
|
||||||
EntityDamageEvent ede = new EntityDamageEvent(target, cause, dmg);
|
dealDamage(target, dmg, cause, null);
|
||||||
Bukkit.getPluginManager().callEvent(ede);
|
|
||||||
if(ede.isCancelled()) return;
|
|
||||||
|
|
||||||
target.damage(ede.getDamage());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -387,19 +383,30 @@ public class Combat
|
|||||||
* @param attacker Player to pass to event as damager
|
* @param attacker Player to pass to event as damager
|
||||||
*/
|
*/
|
||||||
public static void dealDamage(LivingEntity target, int dmg, Player attacker) {
|
public static void dealDamage(LivingEntity target, int dmg, Player attacker) {
|
||||||
EntityDamageEvent ede = new EntityDamageByEntityEvent(attacker, target, EntityDamageEvent.DamageCause.ENTITY_ATTACK, dmg);
|
dealDamage(target, dmg, EntityDamageEvent.DamageCause.ENTITY_ATTACK, attacker);
|
||||||
Bukkit.getPluginManager().callEvent(ede);
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attempt to damage target for value dmg with reason ENTITY_ATTACK with damager attacker
|
||||||
|
*
|
||||||
|
* @param target LivingEntity which to attempt to damage
|
||||||
|
* @param dmg Amount of damage to attempt to do
|
||||||
|
* @param cause DamageCause to pass to damage event
|
||||||
|
* @param attacker Entity to pass to event as damager
|
||||||
|
*/
|
||||||
|
public static void dealDamage(LivingEntity target, int dmg, DamageCause cause, Entity attacker) {
|
||||||
|
EntityDamageEvent ede = new EntityDamageByEntityEvent(attacker, target, cause, dmg);
|
||||||
|
Bukkit.getPluginManager().callEvent(ede);
|
||||||
target.damage(ede.getDamage());
|
target.damage(ede.getDamage());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean pvpAllowed(EntityDamageByEntityEvent event, World world)
|
public static boolean pvpAllowed(EntityDamageByEntityEvent event, World world)
|
||||||
{
|
{
|
||||||
if(!event.getEntity().getWorld().getPVP())
|
if(!((world == null)?event.getEntity().getWorld():world).getPVP()) { return false; }
|
||||||
return false;
|
|
||||||
//If it made it this far, pvp is enabled
|
//If it made it this far, pvp is enabled
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getXp(Entity entity, EntityDamageEvent event)
|
public static int getXp(Entity entity, EntityDamageEvent event)
|
||||||
{
|
{
|
||||||
int xp = 0;
|
int xp = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user