mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-06-25 10:14:43 +02:00
Modified mcMMO's onEntityDamage to have better compatibility.
This commit is contained in:
@ -33,6 +33,7 @@ import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.Combat;
|
||||
import com.gmail.nossr50.Users;
|
||||
import com.gmail.nossr50.m;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.LoadProperties;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
@ -52,9 +53,13 @@ public class mcEntityListener implements Listener
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onEntityDamage(EntityDamageEvent event)
|
||||
{
|
||||
//Pass around a fake event to see if any plugins cancel it
|
||||
if(!m.EntityDamageEventSimulate(event.getEntity(), event.getCause(), event.getDamage()))
|
||||
return;
|
||||
|
||||
if(event.isCancelled())
|
||||
return;
|
||||
|
||||
|
@ -26,8 +26,10 @@ import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import com.gmail.nossr50.config.*;
|
||||
import com.gmail.nossr50.datatypes.FakeEntityDamageEvent;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.FakeBlockBreakEvent;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
@ -144,6 +146,19 @@ public class m
|
||||
return false; //Return false if something went wrong
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean EntityDamageEventSimulate(Entity damagee, DamageCause cause, int damage)
|
||||
{
|
||||
FakeEntityDamageEvent event = new FakeEntityDamageEvent(damagee, cause, damage);
|
||||
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if(!event.isCancelled())
|
||||
{
|
||||
return true; //Return true if not cancelled
|
||||
} else {
|
||||
return false; //Return false if cancelled
|
||||
}
|
||||
}
|
||||
|
||||
public static void damageTool(Player player, short damage)
|
||||
{
|
||||
|
Reference in New Issue
Block a user