mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-12-24 01:27:41 +01:00
Modified mcMMO's onEntityDamage to have better compatibility.
This commit is contained in:
parent
1910b76b13
commit
786a5f9325
@ -2,7 +2,7 @@ Changelog:
|
||||
#Versions without changelogs probably had very small misc fixes, like tweaks to the source code
|
||||
|
||||
Version 1.2.12
|
||||
- Changed priority of onEntityDamage to come dead last to respect other plugins event cancelling
|
||||
- Modified onEntityDamage to have better compatibility with other plugins
|
||||
- Fixed /mcgod, & /mmoedit defaulting to true
|
||||
- Fixed Fishing not handing out any XP
|
||||
|
||||
|
@ -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)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user