dealDamage() will now send fake EntityDamageEvent which mcMMO will ignore

This commit is contained in:
nossr50 2012-03-02 16:53:35 -08:00
parent 89ab87b6dd
commit fe7ca65f22
2 changed files with 6 additions and 1 deletions

View File

@ -27,6 +27,7 @@ import com.gmail.nossr50.config.LoadProperties;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.events.FakeEntityDamageByEntityEvent;
import com.gmail.nossr50.events.FakeEntityDamageEvent;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.party.Party;
import com.gmail.nossr50.skills.Acrobatics;
@ -296,7 +297,7 @@ public class Combat
*/
public static void dealDamage(LivingEntity target, int dmg, DamageCause cause) {
if(LoadProperties.eventCallback) {
EntityDamageEvent ede = new EntityDamageEvent(target, cause, dmg);
EntityDamageEvent ede = (EntityDamageEvent) new FakeEntityDamageEvent(target, cause, dmg);
Bukkit.getPluginManager().callEvent(ede);
if(ede.isCancelled()) return;

View File

@ -47,6 +47,7 @@ import com.gmail.nossr50.config.LoadProperties;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.events.FakeEntityDamageByEntityEvent;
import com.gmail.nossr50.events.FakeEntityDamageEvent;
import com.gmail.nossr50.party.Party;
import com.gmail.nossr50.skills.Acrobatics;
import com.gmail.nossr50.skills.Archery;
@ -93,6 +94,9 @@ public class mcEntityListener implements Listener
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onEntityDamage(EntityDamageEvent event)
{
if(event instanceof FakeEntityDamageEvent)
return;
Entity entity = event.getEntity();
EntityType type = entity.getType();
DamageCause cause = event.getCause();